AI-native design editor. Open-source Figma alternative.
refactor: import app modules statically, and load heavy dependencies through named loaders (#1636)
Danila Poyarkov13c8260d8ac0
diff --git a/AGENTS.md b/AGENTS.mdindex 891dfa30b..4e9b6d7f3 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -71,7 +71,7 @@ Before a PR run `bun run check`, `bun run format`, `bun run test:unit`, and `bun- Window API augmentations belong to the owning compilation boundary: `src/global.d.ts` for the app, the package's `global.d.ts` for package DOM gaps, `tests/helpers/tauri/native-global.d.ts` for native tests. Never put `declare global` in specs or implementation modules; include canonical declarations through tsconfig. Keep app API contracts named and owned by their implementation domain; derive vendor API types from top-level type imports. Optional runtime globals stay optional and need a runtime guard.- Use `structuredClone` or typed copy helpers for nested mutable data. Self-review for duplication, named shared types, precise unions, and files approaching ~600 lines.- Detect desktop with `IS_TAURI`, never ad-hoc `__TAURI_INTERNALS__` checks.-- Import modules statically. Inline `import()` is for code split on purpose: routes and async components, a heavy dependency only some sessions need, and the `src/main.ts` support gate. Tauri modules are always static, since they reach the native side only when called (`open-pencil/no-inline-tauri-imports`).+- Import modules statically; an inline `import()` is for code split on purpose: routes and async components, the `src/main.ts` support gate, and a heavy dependency only some sessions need. That dependency loads through one named function in its owning module, which callers import statically (`src/app/editor/tokens/stylesheet.ts`). Tauri modules are always static, since they reach the native side only when called (`open-pencil/no-inline-tauri-imports`).### Dependency documentationdiff --git a/src/app/ai/agents/setup/accounts.ts b/src/app/ai/agents/setup/accounts.tsindex d3bfc4633..55cae92ac 100644--- a/src/app/ai/agents/setup/accounts.ts+++ b/src/app/ai/agents/setup/accounts.ts@@ -10,6 +10,9 @@ import {} from '@/app/ai/agents/acp/auth/session'import type { AgentAuthMethod, AgentAuthStatus } from '@/app/ai/agents/acp/auth/status'import { startTerminalSignIn, type TerminalSignIn } from '@/app/ai/agents/acp/auth/terminal'+import { linkOwnTools } from '@/app/ai/agents/acp/tools'+import { agentWorkspace } from '@/app/ai/agents/setup/native'+import { getAutomationAuthToken } from '@/app/automation/mcp/spawn'/** What setup knows about the account a coding agent uses. */export interface AgentAccount {@@ -175,14 +178,8 @@ export function createAgentAccounts(options: {/** Starts a session as a chat does: in the agent workspace, linked to OpenPencil's tools. */const chatTools: ToolsProbe = {- cwd: async () => (await import('@/app/ai/agents/setup/native')).agentWorkspace(),- link: async () => {- const [{ getAutomationAuthToken }, { linkOwnTools }] = await Promise.all([- import('@/app/automation/mcp/spawn'),- import('@/app/ai/agents/acp/tools')- ])- return linkOwnTools(await getAutomationAuthToken())- }+ cwd: agentWorkspace,+ link: async () => linkOwnTools(await getAutomationAuthToken())}export const agentAccounts = createAgentAccounts({diff --git a/src/app/ai/agents/setup/discovery.ts b/src/app/ai/agents/setup/discovery.tsindex 3d52adc93..b077bbfd9 100644--- a/src/app/ai/agents/setup/discovery.ts+++ b/src/app/ai/agents/setup/discovery.ts@@ -13,6 +13,7 @@ import {HARNESS_PACKAGE} from '@/app/ai/agents/pi/companion'import { MCP_EXECUTABLE, MCP_INSTALL_TARGET, MCP_PACKAGE_NAME } from '@/app/automation/mcp/failure'+import { restartMCPRuntime } from '@/app/automation/mcp/runtime'import { detectUserAgent } from '@/app/tauri/command'import {@@ -285,7 +286,6 @@ export const agentDiscovery = createAgentDiscovery({installBridge: installCanvasBridge,installHarness: installHarnessCompanion,async restartBridge() {- const { restartMCPRuntime } = await import('@/app/automation/mcp/runtime')const result = await restartMCPRuntime()if (!result.ok) throw result.error}diff --git a/src/app/ai/chat/session.ts b/src/app/ai/chat/session.tsindex 611869749..dfc1b102b 100644--- a/src/app/ai/chat/session.ts+++ b/src/app/ai/chat/session.ts@@ -6,6 +6,8 @@ import { ref } from 'vue'import { ACP_AGENTS, AI_PROVIDERS } from '@open-pencil/core/constants'import type { ACPAgentID, AIProviderID } from '@open-pencil/core/constants'+import { readPiAccount } from '@/app/ai/agents/pi/settings'+import { agentWorkspace } from '@/app/ai/agents/setup/native'import { AgentSetupError, assertAgentReady } from '@/app/ai/agents/setup/readiness'import { classifyAIChatError, type AIChatFailure } from '@/app/ai/chat/failure'import { notifyReplyEnded } from '@/app/ai/chat/notifications'@@ -17,8 +19,10 @@ import { resolveLanguageModelID } from '@/app/ai/models/language-model'import { cloudCreditRefusal } from '@/app/ai/providers/openpencil/failure'import { OPENPENCIL_AI_PROVIDER } from '@/app/ai/providers/openpencil/provider'import { settleMessage } from '@/app/ai/reply/settle'+import { harnessSkills } from '@/app/ai/skills/harness'import { currentRun } from '@/app/ai/tools'-import type { AgentTurnUsage } from '@/app/ai/transports/acp'+import { ACPChatTransport, type AgentTurnUsage } from '@/app/ai/transports/acp'+import { HarnessChatTransport } from '@/app/ai/transports/pi'import { createToolLoopTransport } from '@/app/ai/transports/tool-loop'import { restAgents } from '@/app/automation/agents'import { diagnosticErrorDetails } from '@/app/diagnostics'@@ -30,6 +34,7 @@ import {} from '@/app/diagnostics/events'import type { AIDiagnosticContext } from '@/app/diagnostics/events/ai'import type { getActiveEditorStore } from '@/app/editor/active-store'+import { buildPiMCPServers } from '@/app/integrations/mcp'import { trackUsage } from '@/app/telemetry'import { createTraceStore } from './history/idb'@@ -56,8 +61,6 @@ export async function createACPTransport(const agentDef = ACP_AGENTS.find((a) => a.id === agentId)if (!agentDef) throw new Error(`Unknown ACP agent: ${agentId}`)- const { ACPChatTransport } = await import('@/app/ai/transports/acp')- const { agentWorkspace } = await import('@/app/ai/agents/setup/native')// A folder of its own, not the home folder, whose project settings the agent would read.return new ACPChatTransport({ agentDef, cwd: await agentWorkspace(), store, onUsage })}@@ -167,13 +170,6 @@ export function createChatSessionManager({const runtime = await createAIModelRuntime('design')if (runtime?.kind !== 'harness') throw new Error('The Design agent is not configured for Pi')await assertAgentReady('pi')- const [{ HarnessChatTransport }, { buildPiMCPServers }, { readPiAccount }, { harnessSkills }] =- await Promise.all([- import('@/app/ai/transports/pi'),- import('@/app/integrations/mcp'),- import('@/app/ai/agents/pi/settings'),- import('@/app/ai/skills/harness')- ])// A saved key is an AI Gateway key; without one, Pi uses the CLI's own sign-in.const apiKey = await resolveModelConnectionAPIKey(runtime.role.connection.id)const account = apiKey ? null : await readPiAccount()diff --git a/src/app/ai/transports/acp.ts b/src/app/ai/transports/acp.tsindex 9aca2a89c..606fce088 100644--- a/src/app/ai/transports/acp.ts+++ b/src/app/ai/transports/acp.ts@@ -15,10 +15,14 @@ import type { ACPAgentDef } from '@open-pencil/core/constants'import { parseAuthStatusUpdate } from '@/app/ai/agents/acp/auth/status'import { setAgentCommands } from '@/app/ai/agents/acp/commands'import { createUpdateMapper } from '@/app/ai/agents/acp/events'+import { requestPermissionFromUser } from '@/app/ai/agents/acp/permission'import { spawnACPProcess } from '@/app/ai/agents/acp/process'import { linkOwnTools } from '@/app/ai/agents/acp/tools'+import { agentAccounts } from '@/app/ai/agents/setup/accounts'+import { notifyPermissionWaiting } from '@/app/ai/chat/notifications'import SYSTEM_PROMPT from '@/app/ai/chat/system-prompt'import { endRun, forgetAgentChat, startAgentRun } from '@/app/ai/reply/run'+import { getAutomationAuthToken } from '@/app/automation/mcp/spawn'import { describeDiagnosticError, recordACPTransportFailure } from '@/app/diagnostics'import type { EditorStore } from '@/app/editor/active-store'@@ -301,10 +305,6 @@ export class ACPChatTransport implements ChatTransport<UIMessage> {async requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse> {- const [{ requestPermissionFromUser }, { notifyPermissionWaiting }] = await Promise.all([- import('@/app/ai/agents/acp/permission'),- import('@/app/ai/chat/notifications')- ])const title = params.toolCall.title ?? ''return requestPermissionFromUser(params,@@ -328,7 +328,6 @@ export class ACPChatTransport implements ChatTransport<UIMessage> {extNotification: async (method, params) => {const status = parseAuthStatusUpdate(method, params)if (!status) return- const { agentAccounts } = await import('@/app/ai/agents/setup/accounts')agentAccounts.report(this.agentDef.id, status)}}@@ -341,7 +340,6 @@ export class ACPChatTransport implements ChatTransport<UIMessage> {})stopped.catch(() => undefined)const untilStopped = <T>(request: Promise<T>): Promise<T> => Promise.race([request, stopped])- const { getAutomationAuthToken } = await import('@/app/automation/mcp/spawn')let automationAuthToken: string | nulltry {automationAuthToken = await getAutomationAuthToken()diff --git a/src/app/diagnostics/settings.ts b/src/app/diagnostics/settings.tsindex afe43f55f..2b6a4684d 100644--- a/src/app/diagnostics/settings.ts+++ b/src/app/diagnostics/settings.ts@@ -1,6 +1,6 @@import { useLocalStorage } from '@vueuse/core'import { clamp } from 'es-toolkit'-import { computed, ref } from 'vue'+import { computed } from 'vue'/*** Number of most recent events kept locally. Bounded rather than a closed set@@ -35,22 +35,12 @@ const diagnosticsRetention = useLocalStorage<DiagnosticsRetention>(500,{ serializer: { read: (value) => resolveDiagnosticsRetention(value), write: String } })-const diagnosticsCount = ref(0)-const diagnosticsSize = ref(0)export function useDiagnosticsSettings() {return {diagnosticsEnabled,usageEnabled,- diagnosticsRetention,- diagnosticsCount: computed(() => diagnosticsCount.value),- diagnosticsSize: computed(() => diagnosticsSize.value),- refreshDiagnosticsStats: async () => {- const { diagnostics } = await import('./recorder')- const events = await diagnostics.list()- diagnosticsCount.value = events.length- diagnosticsSize.value = JSON.stringify(events).length- }+ diagnosticsRetention}}@@ -66,9 +56,4 @@ export function getDiagnosticsRetention(): DiagnosticsRetention {return diagnosticsRetention.value}-export async function pruneDiagnostics(retention: DiagnosticsRetention): Promise<void> {- const { diagnostics } = await import('./recorder')- await diagnostics.prune(retention)-}-export const diagnosticsRetentionOptions = computed(() => diagnosticsRetentionPresets)diff --git a/src/app/document/close/prompt.ts b/src/app/document/close/prompt.tsindex e8b965076..a4fda6380 100644--- a/src/app/document/close/prompt.ts+++ b/src/app/document/close/prompt.ts@@ -3,6 +3,7 @@ import { shallowRef } from 'vue'import { IS_TAURI } from '@/constants'import { confirmDocumentClose, type ClosableDocument, type CloseChoice } from './controller'+import { chooseNativeDocumentClose } from './native'export const closePrompt = shallowRef<{ documentName: string } | null>(null)let resolvePrompt: ((choice: CloseChoice) => void) | null = null@@ -18,10 +19,7 @@ export function answerClosePrompt(choice: CloseChoice): void {export function requestDocumentClose(document: ClosableDocument, documentName: string) {const result = pending.then(() =>confirmDocumentClose(document, async () => {- if (IS_TAURI) {- const { chooseNativeDocumentClose } = await import('./native')- return chooseNativeDocumentClose(documentName)- }+ if (IS_TAURI) return chooseNativeDocumentClose(documentName)return new Promise<CloseChoice>((resolve) => {resolvePrompt = resolveclosePrompt.value = { documentName }diff --git a/src/app/editor/tokens/copy.ts b/src/app/editor/tokens/copy.tsindex bb916e8e0..c8b1ad4ce 100644--- a/src/app/editor/tokens/copy.ts+++ b/src/app/editor/tokens/copy.ts@@ -7,6 +7,8 @@ import { copyPendingText } from '@/app/editor/clipboard/text'import { notificationMessages } from '@/app/i18n/notifications'import { toast } from '@/app/shell/ui'+import { variablesStylesheet } from './stylesheet'+const FORMAT_LABELS: Record<TokenStylesheetFormat, string> = {css: 'CSS',tailwind: 'Tailwind CSS'@@ -33,11 +35,9 @@ class NothingToCopyError extends Error {/** Copy the document's variables as a stylesheet, and name what had to be left out. */export function createTokenCopy(store: EditorStore) {return async function copyTokens(format: TokenStylesheetFormat): Promise<void> {- // The stylesheet generator and its CSS parser load only when someone copies tokens. The- // clipboard write starts before either is ready, while the click still allows it.- const stylesheet = import('@open-pencil/dom-css/export').then(({ tokenStylesheet }) =>- tokenStylesheet(store.graph, { format })- )+ // The clipboard write starts before the stylesheet generator has loaded, while the click+ // still allows it.+ const stylesheet = variablesStylesheet(store.graph, { format })const css = stylesheet.then((result) => {if (!result.css) throw new NothingToCopyError()return result.cssdiff --git a/src/app/editor/tokens/design-tokens.ts b/src/app/editor/tokens/design-tokens.tsindex 882b681a1..6d600f981 100644--- a/src/app/editor/tokens/design-tokens.ts+++ b/src/app/editor/tokens/design-tokens.ts@@ -2,6 +2,7 @@ import { uniq } from 'es-toolkit/array'import { strFromU8, strToU8, unzipSync, zipSync, type Zippable } from 'fflate'import type {+ DesignTokenBundle,DesignTokenIssue,DesignTokenSourceFile} from '@open-pencil/core/io/formats/design-tokens'@@ -31,12 +32,15 @@ function issueName(issue: DesignTokenIssue): string {return issue.kind === 'unsupported-effect' ? issue.style : issue.token}+/** The W3C token reader and writer load with the first import or export. */+const loadDesignTokens = () => import('@open-pencil/core/io/formats/design-tokens')+/*** Saves the document's variables and styles as W3C design tokens: a zip of one file per* collection mode, the styles, and the resolver that combines them.*/export async function exportDesignTokenArchive(store: EditorStore): Promise<void> {- const { exportDesignTokens } = await import('@open-pencil/core/io/formats/design-tokens')+ const { exportDesignTokens } = await loadDesignTokens()const { files, issues } = exportDesignTokens(store.graph)const entries: Zippable = {}for (const file of files)@@ -58,9 +62,7 @@ export async function exportDesignTokenArchive(store: EditorStore): Promise<void* Picked files as token sources: JSON as it is, archives unpacked. A folder's files keep their* paths inside it, which is how a resolver's `$ref`s and per-folder collections find them.*/-export async function readDesignTokenFiles(- files: readonly File[]-): Promise<DesignTokenSourceFile[]> {+async function readDesignTokenFiles(files: readonly File[]): Promise<DesignTokenSourceFile[]> {const sources: DesignTokenSourceFile[] = []for (const file of files) {const path = file.webkitRelativePath || file.name@@ -76,3 +78,11 @@ export async function readDesignTokenFiles(}return sources}++/** What picked token files, folders, or archives of them would define in the document. */+export async function readDesignTokenImport(files: readonly File[]): Promise<DesignTokenBundle> {+ // Files that cannot be read leave the reader unloaded.+ const sources = await readDesignTokenFiles(files)+ const { readDesignTokens } = await loadDesignTokens()+ return readDesignTokens(sources)+}diff --git a/src/app/editor/tokens/stylesheet.ts b/src/app/editor/tokens/stylesheet.tsnew file mode 100644index 000000000..d92d9bf80--- /dev/null+++ b/src/app/editor/tokens/stylesheet.ts@@ -0,0 +1,14 @@+import type { TokenStylesheet, TokenStylesheetOptions } from '@open-pencil/dom-css/export'+import type { SceneGraph } from '@open-pencil/scene-graph'++/**+ * The document's variables as a stylesheet. The generator and its CSS parser load with the first+ * preview or copy, since most sessions never show variables as CSS.+ */+export async function variablesStylesheet(+ graph: SceneGraph,+ options: TokenStylesheetOptions+): Promise<TokenStylesheet> {+ const { tokenStylesheet } = await import('@open-pencil/dom-css/export')+ return tokenStylesheet(graph, options)+}diff --git a/src/app/integrations/storage/s3/client.ts b/src/app/integrations/storage/s3/client.tsindex 028a9f622..d4867a9f6 100644--- a/src/app/integrations/storage/s3/client.ts+++ b/src/app/integrations/storage/s3/client.ts@@ -1,5 +1,10 @@import type { S3Client } from '@aws-sdk/client-s3'+import {+ CloudCORSError,+ formatBrowserCORSHelpMessage,+ isLikelyCORSOrNetworkError+} from '@/app/integrations/storage/s3/cors'import { asFetch, storageFetch } from '@/app/integrations/storage/s3/fetch'import type * as S3SDK from '@/app/integrations/storage/s3/sdk'import type { S3CompatibleConfig } from '@/app/integrations/storage/s3/types'@@ -81,8 +86,6 @@ async function send<Output>()}// Re-export as a typed error so UI can detect CORS/network blocks.- const { CloudCORSError, isLikelyCORSOrNetworkError, formatBrowserCORSHelpMessage } =- await import('@/app/integrations/storage/s3/cors')if (isLikelyCORSOrNetworkError(error)) {throw new CloudCORSError(formatBrowserCORSHelpMessage())}diff --git a/src/app/integrations/storage/s3/fetch.ts b/src/app/integrations/storage/s3/fetch.tsindex 518d672b3..bb8c060b8 100644--- a/src/app/integrations/storage/s3/fetch.ts+++ b/src/app/integrations/storage/s3/fetch.ts@@ -1,4 +1,5 @@import { isTauri } from '@/app/tauri/env'+import { tauriFetch } from '@/app/tauri/http'/*** How long a request waits for its answer, or a download for its next bytes, before it fails, so a@@ -90,7 +91,6 @@ async function fetchWithTimeout(let response: Responsetry {if (isTauri()) {- const { tauriFetch } = await import('@/app/tauri/http')response = await tauriFetch(input, { ...init, signal })} else if (input instanceof Request) {// Request bodies are owned by the Request; re-wrap so we can attach a timeout signal.diff --git a/src/app/shell/menu/app-menu.ts b/src/app/shell/menu/app-menu.tsindex 37fc2c1b7..912c1220f 100644--- a/src/app/shell/menu/app-menu.ts+++ b/src/app/shell/menu/app-menu.ts@@ -49,7 +49,7 @@ import { APP_MENU_SCHEMA } from '@/app/shell/menu/schema'import { appMenuShortcutLabel } from '@/app/shell/menu/shortcut'import { openFileDialog } from '@/app/shell/menu/use'import { useAppTheme } from '@/app/shell/theme'-import { closeTab, activeTab, switchAdjacentTab } from '@/app/tabs'+import { closeTab, activeTab, createTab, openNewFileTab, switchAdjacentTab } from '@/app/tabs'export interface AppMenuGroup {label: string@@ -177,12 +177,8 @@ export function useAppMenu() {}const actions: Partial<Record<string, () => void>> = {- new: () => {- void import('@/app/tabs').then((m) => m.createTab())- },- 'new-tab': () => {- void import('@/app/tabs').then((m) => m.openNewFileTab())- },+ new: () => createTab(),+ 'new-tab': () => openNewFileTab(),open: () => void openFileDialog(),'open-tour': () => {openTour().catch((error: unknown) => console.error('[Tour] Could not open the tour:', error))diff --git a/src/app/shell/menu/navigation.ts b/src/app/shell/menu/navigation.tsindex 9c1ce11f5..78aabf6f0 100644--- a/src/app/shell/menu/navigation.ts+++ b/src/app/shell/menu/navigation.ts@@ -1,12 +1,10 @@import type { Router } from 'vue-router'import { homeLocation, type HomeLocation } from '@/app/home/location'+import { showNewTab } from '@/app/tabs'function showHome(router: Router): void {- void router- .push('/')- .then(() => import('@/app/tabs'))- .then(({ showNewTab }) => showNewTab())+ void router.push('/').then(showNewTab)}/** Shows Home at one of its places, in a new tab when a document is open. */diff --git a/src/components/MobileHud/context.ts b/src/components/MobileHud/context.tsindex 9ad52f471..bb34d99b8 100644--- a/src/components/MobileHud/context.ts+++ b/src/components/MobileHud/context.ts@@ -18,6 +18,7 @@ import type { FollowTarget } from '@/app/presence/types'import { openFileDialog } from '@/app/shell/menu/use'import { useSendLink } from '@/app/shell/share/link'import { toast } from '@/app/shell/ui'+import { createTab } from '@/app/tabs'import { roomStatusText } from '@/components/collab-room/statusText'import { toolIcons } from '@/components/icons'import { presenceRows } from '@/components/presence/rows'@@ -63,7 +64,7 @@ function createMobileHudContext() {{icon: IconFilePlus,label: 'New',- action: () => void import('@/app/tabs').then((m) => m.createTab())+ action: () => createTab()},{ icon: IconFolderOpen, label: 'Open…', action: () => void openFileDialog() },{ icon: IconSave, label: 'Save', action: () => void store.saveFigFile() },diff --git a/src/components/settings/diagnostics/DiagnosticsSettingsPanel.vue b/src/components/settings/diagnostics/DiagnosticsSettingsPanel.vueindex e3ae6787f..f2a46a644 100644--- a/src/components/settings/diagnostics/DiagnosticsSettingsPanel.vue+++ b/src/components/settings/diagnostics/DiagnosticsSettingsPanel.vue@@ -12,7 +12,6 @@ import {DIAGNOSTICS_RETENTION_MAX,DIAGNOSTICS_RETENTION_MIN,diagnosticsRetentionPresets,- pruneDiagnostics,useDiagnosticsSettings} from '@/app/diagnostics/settings'import { toast } from '@/app/shell/ui'@@ -29,13 +28,15 @@ const { common, diagnostics: diagnosticMessages } = useI18n()const { copy: copyText, copied } = useClipboard({ copiedDuring: 1500 })const clearOpen = ref(false)-const {- diagnosticsEnabled,- diagnosticsCount,- diagnosticsSize,- diagnosticsRetention,- refreshDiagnosticsStats-} = useDiagnosticsSettings()+const { diagnosticsEnabled, diagnosticsRetention } = useDiagnosticsSettings()+const diagnosticsCount = ref(0)+const diagnosticsSize = ref(0)++async function refreshDiagnosticsStats(): Promise<void> {+ const events = await diagnostics.list()+ diagnosticsCount.value = events.length+ diagnosticsSize.value = JSON.stringify(events).length+}const retentionValue = computed({get: () => diagnosticsRetention.value,@@ -46,7 +47,7 @@ const retentionValue = computed({/** Retention is a stored policy change, so pruning follows the committed value. */async function commitRetention(value: number): Promise<void> {- await pruneDiagnostics(value)+ await diagnostics.prune(value)await refreshDiagnosticsStats()}diff --git a/src/components/variables/TokenOutput.vue b/src/components/variables/TokenOutput.vueindex 43b72ebcd..1a217b52c 100644--- a/src/components/variables/TokenOutput.vue+++ b/src/components/variables/TokenOutput.vue@@ -16,6 +16,7 @@ import { useEditor } from '@open-pencil/vue'import { useI18n } from '@open-pencil/vue/i18n'import { useSceneComputed } from '@open-pencil/vue/internal/scene-computed'+import { variablesStylesheet } from '@/app/editor/tokens/stylesheet'import CodeViewer from '@/components/code-editor/CodeViewer.vue'import IconButton from '@/components/ui/button/IconButton.vue'import { useMenuUI } from '@/components/ui/menu/menu'@@ -45,8 +46,7 @@ const collectionVariables = useSceneComputed(() => [*/const stylesheet = computedAsync(async () => {const ids = new Set(collectionVariables.value.map((variable) => variable.id))- const { tokenStylesheet } = await import('@open-pencil/dom-css/export')- const { css } = await tokenStylesheet(editor.graph, {+ const { css } = await variablesStylesheet(editor.graph, {format: 'css',include: (variable) => ids.has(variable.id)})diff --git a/src/components/variables/VariablesDialog.vue b/src/components/variables/VariablesDialog.vueindex e61ccd337..4bae604c1 100644--- a/src/components/variables/VariablesDialog.vue+++ b/src/components/variables/VariablesDialog.vue@@ -11,7 +11,7 @@ import { createTokenCopy } from '@/app/editor/tokens/copy'import {DESIGN_TOKEN_FILE_ACCEPT,exportDesignTokenArchive,- readDesignTokenFiles+ readDesignTokenImport} from '@/app/editor/tokens/design-tokens'import { pendingTokenImport } from '@/app/editor/tokens/dialog'import { notificationMessages } from '@/app/i18n/notifications'@@ -58,10 +58,9 @@ let importRequest = 0function importFiles(files: readonly File[]) {const request = ++importRequestvoid (async () => {- const sources = await readDesignTokenFiles(files)- const { readDesignTokens } = await import('@open-pencil/core/io/formats/design-tokens')+ const bundle = await readDesignTokenImport(files)if (request !== importRequest) return- importBundle.value = readDesignTokens(sources)+ importBundle.value = bundleimportOpen.value = true})().catch((error: unknown) => {if (request === importRequest) reportFailure(error)