mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge pull request #2529 from appwrite/feat-profiles-cdn
This commit is contained in:
10 files changed
+63
-4406
No files matched your search
@@ -8,7 +8,9 @@ on:
|
||||
- 'static/**/*'
|
||||
|
||||
env:
|
||||
PUBLIC_CONSOLE_PROFILE: 'default'
|
||||
PUBLIC_APPWRITE_ENDPOINT: http://appwrite.test/v1
|
||||
PUBLIC_AI_SERVICE_BASE_URL: 'http://appwrite.test/v1'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
"@appwrite.io/pink-legacy": "^1.0.3",
|
||||
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@8f82877",
|
||||
"@faker-js/faker": "^9.9.0",
|
||||
"@imagine.dev/web-components": "https://pkg.vc/-/@appwrite/%40imagine.dev%2Fweb-components@1d24352",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@sentry/sveltekit": "^8.55.0",
|
||||
"@stripe/stripe-js": "^3.5.0",
|
||||
|
||||
@@ -13,6 +13,8 @@ const config: PlaywrightTestConfig = {
|
||||
webServer: {
|
||||
timeout: 120000,
|
||||
env: {
|
||||
PUBLIC_CONSOLE_PROFILE: '',
|
||||
PUBLIC_AI_SERVICE_BASE_URL: '',
|
||||
PUBLIC_APPWRITE_ENDPOINT: 'https://stage.cloud.appwrite.io/v1',
|
||||
PUBLIC_CONSOLE_MODE: 'cloud',
|
||||
PUBLIC_APPWRITE_MULTI_REGION: 'true',
|
||||
|
||||
Generated
+8
-4356
File diff suppressed because it is too large.
Load diff
@@ -19,7 +19,7 @@
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { goto, beforeNavigate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { base, resolve } from '$app/paths';
|
||||
import { currentPlan, newOrgModal, organization } from '$lib/stores/organization';
|
||||
import { Click, trackEvent } from '$lib/actions/analytics';
|
||||
import { ID, type Models, Query } from '@appwrite.io/console';
|
||||
@@ -171,7 +171,9 @@
|
||||
if (loadedProjects.projects.length > 4) {
|
||||
projectLinks.push({
|
||||
name: 'All projects',
|
||||
href: `${base}/organization-${selectedOrg.$id}`
|
||||
href: resolve('/(console)/organization-[organization]', {
|
||||
organization: selectedOrg.$id
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { initImagineConfig, initImagineRouting } from '@imagine.dev/web-components/web-components';
|
||||
import { PUBLIC_APPWRITE_ENDPOINT, PUBLIC_AI_SERVICE_BASE_URL } from '$env/static/public';
|
||||
import ImagineCss from '@imagine.dev/web-components/imagine-web-components.css?url';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { get } from 'svelte/store';
|
||||
import { goto } from '$app/navigation';
|
||||
@@ -10,8 +8,10 @@ const COMPONENT_SELECTOR = 'imagine-web-components-wrapper[data-appwrite-studio]
|
||||
const STYLE_ATTRIBUTE = 'data-appwrite-studio-style';
|
||||
const BLOCK_START_BASE_OFFSET = 48;
|
||||
const INLINE_START_BASE_OFFSET = 8;
|
||||
const CDN_URL = 'https://esm.sh/@imagine.dev/web-components@0/web-components?bundle=false&deps=react@19.1.0,react-dom@19.1.0';
|
||||
|
||||
let component: HTMLElement | null = null;
|
||||
let webComponentsModule: Record<string, any> | null = null;
|
||||
let configInitialized = false;
|
||||
let routingInitialized = false;
|
||||
let lastRouteKey: string | null = null;
|
||||
@@ -84,7 +84,7 @@ function injectStyles(node: HTMLElement, attempt = 0) {
|
||||
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = ImagineCss;
|
||||
link.href = 'https://esm.sh/@imagine.dev/web-components@0/imagine-web-components.css';
|
||||
link.setAttribute(STYLE_ATTRIBUTE, 'true');
|
||||
shadow.prepend(link);
|
||||
})
|
||||
@@ -93,6 +93,28 @@ function injectStyles(node: HTMLElement, attempt = 0) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the web components module, loading it from CDN if necessary
|
||||
*/
|
||||
export async function getWebComponents() {
|
||||
if (!webComponentsModule) {
|
||||
webComponentsModule = await import(/* @vite-ignore */ CDN_URL);
|
||||
}
|
||||
return webComponentsModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to a route in the web components
|
||||
*/
|
||||
export async function navigateToRoute(...args: any[]) {
|
||||
try {
|
||||
const { navigateToRoute: navigate } = await getWebComponents();
|
||||
return navigate(...args);
|
||||
} catch (error) {
|
||||
console.error('Failed to navigate:', error);
|
||||
}
|
||||
}
|
||||
|
||||
export function ensureStudioComponent(): HTMLElement | null {
|
||||
if (!hasDocument()) {
|
||||
return component;
|
||||
@@ -233,8 +255,11 @@ export function hideStudio() {
|
||||
restoreBodyScroll();
|
||||
}
|
||||
|
||||
export function initImagine(region: string, projectId: string) {
|
||||
if (!configInitialized) {
|
||||
export async function initImagine(region: string, projectId: string) {
|
||||
try {
|
||||
const { initImagineConfig, initImagineRouting } = await getWebComponents();
|
||||
|
||||
if (!configInitialized) {
|
||||
initImagineConfig(
|
||||
{
|
||||
AI_SERVICE_ENDPOINT: PUBLIC_AI_SERVICE_BASE_URL,
|
||||
@@ -275,6 +300,9 @@ export function initImagine(region: string, projectId: string) {
|
||||
}
|
||||
});
|
||||
|
||||
routingInitialized = true;
|
||||
lastRouteKey = routeKey;
|
||||
routingInitialized = true;
|
||||
lastRouteKey = routeKey;
|
||||
} catch (error) {
|
||||
console.error('Failed to load web components library:', error);
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,8 @@
|
||||
<script lang="ts">
|
||||
import './shim.css';
|
||||
import { onMount } from 'svelte';
|
||||
import { ensureStudioComponent, initImagine } from './studio-widget';
|
||||
import { ensureStudioComponent, initImagine, getWebComponents } from './studio-widget';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { changeTheme } from '@imagine.dev/web-components/web-components';
|
||||
|
||||
const { region, projectId }: { region: string; projectId: string } = $props();
|
||||
|
||||
@@ -15,8 +14,15 @@
|
||||
ensureStudioComponent();
|
||||
initImagine(region, projectId);
|
||||
|
||||
return app.subscribe(($app) => {
|
||||
changeTheme($app.themeInUse);
|
||||
return app.subscribe(async ($app) => {
|
||||
try {
|
||||
const { changeTheme } = await getWebComponents();
|
||||
if (changeTheme) {
|
||||
changeTheme($app.themeInUse);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to change theme:', error);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount, tick } from 'svelte';
|
||||
import { attachStudioTo, ensureStudioComponent, hideStudio } from '$lib/studio/studio-widget';
|
||||
import { navigateToRoute } from '@imagine.dev/web-components/web-components';
|
||||
import { attachStudioTo, ensureStudioComponent, hideStudio, navigateToRoute } from '$lib/studio/studio-widget';
|
||||
|
||||
let anchor: HTMLElement = $state();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount, tick } from 'svelte';
|
||||
import { attachStudioTo, ensureStudioComponent, hideStudio } from '$lib/studio/studio-widget';
|
||||
import { navigateToRoute } from '@imagine.dev/web-components/web-components';
|
||||
import { attachStudioTo, ensureStudioComponent, hideStudio, navigateToRoute } from '$lib/studio/studio-widget';
|
||||
import { page } from '$app/state';
|
||||
|
||||
let anchor: HTMLElement = $state();
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import { exec } from 'child_process';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
console.log('Fetching latest @appwrite/imagine package URL...');
|
||||
|
||||
const response = await fetch(
|
||||
'https://pkg.vc/-/@appwrite/@imagine.dev/web-components~refs/heads/main'
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch package URL: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
const packageUrl = response.url;
|
||||
console.log(`Package URL: ${packageUrl}`);
|
||||
|
||||
const command = `pnpm install ${packageUrl}`;
|
||||
console.log(`Running command: ${command}`);
|
||||
|
||||
const { stdout, stderr } = await execAsync(command);
|
||||
|
||||
if (stdout) {
|
||||
console.log('stdout:', stdout);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.log('stderr:', stderr);
|
||||
}
|
||||
|
||||
console.log('Successfully updated @appwrite/imagine package!');
|
||||
Reference in new issue
Block a user