@miragon/modeler-shell 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +2869 -0
- package/LICENSE +21 -0
- package/README.md +566 -2
- package/THIRD_PARTY_NOTICES.md +52 -0
- package/dist/appearance-BBaM_4bD.d.ts +323 -0
- package/dist/appearance-D3FUcbu6.d.cts +53 -0
- package/dist/appearance-D3FUcbu6.d.ts +53 -0
- package/dist/appearance-XX3JC3pI.d.cts +323 -0
- package/dist/chunk-66HCSJNY.js +2792 -0
- package/dist/chunk-66HCSJNY.js.map +1 -0
- package/dist/chunk-KYDG5DMX.js +136 -0
- package/dist/chunk-KYDG5DMX.js.map +1 -0
- package/dist/chunk-N4QXFF3A.js +23 -0
- package/dist/chunk-N4QXFF3A.js.map +1 -0
- package/dist/chunk-OADW3GPA.js +785 -0
- package/dist/chunk-OADW3GPA.js.map +1 -0
- package/dist/core.cjs +873 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +246 -0
- package/dist/core.d.ts +246 -0
- package/dist/core.js +131 -0
- package/dist/core.js.map +1 -0
- package/dist/diagram-js.cjs +1147 -0
- package/dist/diagram-js.cjs.map +1 -0
- package/dist/diagram-js.d.cts +170 -0
- package/dist/diagram-js.d.ts +170 -0
- package/dist/diagram-js.js +879 -0
- package/dist/diagram-js.js.map +1 -0
- package/dist/index.cjs +3632 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +143 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol-DhYBakWL.d.cts +15 -0
- package/dist/protocol-IeW8bf4f.d.ts +15 -0
- package/dist/shell.css +1603 -0
- package/dist/testing-vscode-stub.cjs +332 -0
- package/dist/testing-vscode-stub.cjs.map +1 -0
- package/dist/testing-vscode-stub.d.cts +65 -0
- package/dist/testing-vscode-stub.d.ts +65 -0
- package/dist/testing-vscode-stub.js +154 -0
- package/dist/testing-vscode-stub.js.map +1 -0
- package/dist/testing.cjs +4663 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +231 -0
- package/dist/testing.d.ts +231 -0
- package/dist/testing.js +4483 -0
- package/dist/testing.js.map +1 -0
- package/dist/toasts-Bp0REqdq.d.cts +142 -0
- package/dist/toasts-Bp0REqdq.d.ts +142 -0
- package/dist/types-CnRrINRs.d.cts +445 -0
- package/dist/types-PuDZczzy.d.ts +445 -0
- package/dist/vscode-extension.cjs +215 -0
- package/dist/vscode-extension.cjs.map +1 -0
- package/dist/vscode-extension.d.cts +103 -0
- package/dist/vscode-extension.d.ts +103 -0
- package/dist/vscode-extension.js +24 -0
- package/dist/vscode-extension.js.map +1 -0
- package/dist/vscode-webview.cjs +3561 -0
- package/dist/vscode-webview.cjs.map +1 -0
- package/dist/vscode-webview.d.cts +84 -0
- package/dist/vscode-webview.d.ts +84 -0
- package/dist/vscode-webview.js +259 -0
- package/dist/vscode-webview.js.map +1 -0
- package/package.json +145 -4
- package/src/core/appearance.ts +104 -0
- package/src/core/feedback/appearance.ts +141 -0
- package/src/core/feedback/problems.ts +23 -0
- package/src/core/feedback/toasts.ts +118 -0
- package/src/core/fit.ts +220 -0
- package/src/core/index.ts +127 -0
- package/src/core/keymap.ts +295 -0
- package/src/core/layout.ts +69 -0
- package/src/core/messages.ts +159 -0
- package/src/core/sizes.ts +85 -0
- package/src/core/types.ts +106 -0
- package/src/core/web-chrome/bottom-row.ts +37 -0
- package/src/core/web-chrome/drop.ts +78 -0
- package/src/core/web-chrome/top-row.ts +66 -0
- package/src/core/zoom.ts +74 -0
- package/src/core.ts +2 -0
- package/src/diagram-js/connect.ts +75 -0
- package/src/diagram-js/index.ts +16 -0
- package/src/diagram-js/module.ts +20 -0
- package/src/diagram-js/palette-skin.ts +267 -0
- package/src/diagram-js/palette.css +269 -0
- package/src/diagram-js/service.ts +243 -0
- package/src/diagram-js/types.ts +67 -0
- package/src/diagram-js/viewport.ts +583 -0
- package/src/diagram-js.ts +2 -0
- package/src/dom/buttons.css +124 -0
- package/src/dom/element.ts +51 -0
- package/src/dom/feedback/appearance.ts +184 -0
- package/src/dom/feedback/feedback.css +435 -0
- package/src/dom/feedback/problems-popover.ts +287 -0
- package/src/dom/feedback/toasts.ts +431 -0
- package/src/dom/hint.ts +51 -0
- package/src/dom/icons.ts +309 -0
- package/src/dom/index.ts +42 -0
- package/src/dom/inspector.ts +35 -0
- package/src/dom/keys.ts +67 -0
- package/src/dom/ledger.ts +87 -0
- package/src/dom/legend.ts +85 -0
- package/src/dom/menu.ts +404 -0
- package/src/dom/mount.ts +731 -0
- package/src/dom/problems.ts +73 -0
- package/src/dom/shell-dom.css +969 -0
- package/src/dom/status.ts +72 -0
- package/src/dom/tooltip.ts +237 -0
- package/src/dom/types.ts +459 -0
- package/src/dom/web/drop-zone.ts +181 -0
- package/src/dom/web/empty-state.ts +144 -0
- package/src/dom/web/legal.ts +75 -0
- package/src/dom/web/menu-groups.ts +69 -0
- package/src/dom/web/primary.ts +124 -0
- package/src/dom/web/web.css +386 -0
- package/src/dom/zoom-panel.ts +154 -0
- package/src/index.ts +3 -0
- package/src/shell.css +9 -0
- package/src/testing/case-tools.ts +164 -0
- package/src/testing/cases.ts +1077 -0
- package/src/testing/checks.ts +868 -0
- package/src/testing/facts.ts +641 -0
- package/src/testing/geometry.ts +652 -0
- package/src/testing/harness.ts +187 -0
- package/src/testing/index.ts +19 -0
- package/src/testing/page-tools.ts +457 -0
- package/src/testing/page.ts +27 -0
- package/src/testing/vscode-stub.ts +237 -0
- package/src/testing/web-cases.ts +913 -0
- package/src/testing/web-checks.ts +1049 -0
- package/src/testing/web-facts.ts +713 -0
- package/src/testing-vscode-stub.ts +2 -0
- package/src/testing.ts +2 -0
- package/src/vscode/extension/html.ts +107 -0
- package/src/vscode/extension/index.ts +8 -0
- package/src/vscode/extension/reveal.ts +9 -0
- package/src/vscode/extension/theme-bridge.ts +85 -0
- package/src/vscode/extension/types.ts +36 -0
- package/src/vscode/protocol.ts +31 -0
- package/src/vscode/webview/appearance.ts +141 -0
- package/src/vscode/webview/index.ts +8 -0
- package/src/vscode/webview/mount.ts +88 -0
- package/src/vscode/webview/state.ts +116 -0
- package/src/vscode-extension.ts +2 -0
- package/src/vscode-webview.ts +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vscode-extension.ts","../src/core/appearance.ts","../src/vscode/extension/html.ts","../src/vscode/protocol.ts","../src/vscode/extension/theme-bridge.ts","../src/vscode/extension/reveal.ts"],"sourcesContent":["// \"@miragon/modeler-shell/vscode/extension\": the extension-host side (the vscode namespace is injected).\nexport * from \"./vscode/extension/index.js\";\n","/** The modes a Miragon modeler can show (guide §13.3). */\nexport type Theme = \"light\" | \"dark\";\n\n/** High contrast; written as `data-cd-kontrast=\"hoch\"` on the same element as `data-cd-theme`. */\nexport type Kontrast = \"hoch\";\n\nexport interface Appearance {\n theme: Theme;\n kontrast?: Kontrast | undefined;\n}\n\n/**\n * The one appearance decision of guide §13.5: a theme the modeler cannot show is never shown\n * (`themes[0]` wins, so `[\"light\"]` stays light whatever the host requests); `kontrast` always\n * passes through. Throws when `themes` is empty.\n */\nexport function resolveAppearance(requested: Appearance, themes: readonly Theme[]): Appearance {\n const [fallback] = themes;\n if (fallback === undefined) {\n throw new Error(\n \"@miragon/modeler-shell: resolveAppearance needs at least one theme the modeler can show\",\n );\n }\n const theme = themes.includes(requested.theme) ? requested.theme : fallback;\n return withKontrast(theme, requested.kontrast);\n}\n\n// Appearances arrive through postMessage and settings, so only the one known value passes.\nfunction withKontrast(theme: Theme, kontrast: unknown): Appearance {\n return kontrast === \"hoch\" ? { theme, kontrast } : { theme };\n}\n\n/**\n * The appearance VS Code requests for `vscode.window.activeColorTheme.kind`:\n * 1 Light → light, 2 Dark → dark, 3 HighContrast → dark + hoch, 4 HighContrastLight → light + hoch;\n * any other value → light.\n */\nexport function appearanceFromColorThemeKind(kind: number): Appearance {\n switch (kind) {\n case 2:\n return { theme: \"dark\" };\n case 3:\n return { theme: \"dark\", kontrast: \"hoch\" };\n case 4:\n return { theme: \"light\", kontrast: \"hoch\" };\n default:\n return { theme: \"light\" };\n }\n}\n\n/** The values of the setting `miragon.<modeler>.colorTheme` (it ships once a modeler can show dark). */\nexport type ColorThemeSetting = \"automatic\" | \"light\" | \"dark\";\n\n/**\n * The requested appearance in an IDE host: the setting's theme unless it is `automatic` (or\n * missing), the contrast always from the color theme kind.\n */\nexport function requestedAppearance(kind: number, setting?: ColorThemeSetting | undefined): Appearance {\n const fromKind = appearanceFromColorThemeKind(kind);\n const theme = setting === \"light\" || setting === \"dark\" ? setting : fromKind.theme;\n return withKontrast(theme, fromKind.kontrast);\n}\n\n/**\n * The fallback signal inside a VS Code webview: the body classes `vscode-high-contrast-light`\n * (checked first, VS Code adds `vscode-high-contrast` to it as well), `vscode-high-contrast`,\n * `vscode-dark`, `vscode-light`. `undefined` when none is set. Never use them for styling.\n */\nexport function appearanceFromBodyClasses(classes: Iterable<string>): Appearance | undefined {\n const present = new Set(classes);\n if (present.has(\"vscode-high-contrast-light\")) return { theme: \"light\", kontrast: \"hoch\" };\n if (present.has(\"vscode-high-contrast\")) return { theme: \"dark\", kontrast: \"hoch\" };\n if (present.has(\"vscode-dark\")) return { theme: \"dark\" };\n if (present.has(\"vscode-light\")) return { theme: \"light\" };\n return undefined;\n}\n\n/**\n * VS Code's `workbench.reduceMotion` as the webview sees it: the body class `vscode-reduce-motion`\n * (the webview host page sets it). Never use it for styling; the shell mirrors it as\n * `REDUCED_MOTION_CLASS` on `<html>`.\n */\nexport function reducedMotionFromBodyClasses(classes: Iterable<string>): boolean {\n return new Set(classes).has(\"vscode-reduce-motion\");\n}\n\n/**\n * On `<html>` while the host asks for reduced motion although the OS does not (VS Code's\n * `workbench.reduceMotion`): the shell's animations stop as under `prefers-reduced-motion`, and an\n * explicit fit jumps.\n */\nexport const REDUCED_MOTION_CLASS = \"cd-shell-reduce-motion\";\n\nexport interface AppearanceAttributes {\n \"data-cd-theme\": Theme;\n \"data-cd-kontrast\"?: Kontrast;\n}\n\n/** The attributes for `<html>` (own document) or the modeler container (foreign page). */\nexport function appearanceAttributes(appearance: Appearance): AppearanceAttributes {\n return appearance.kontrast === \"hoch\"\n ? { \"data-cd-theme\": appearance.theme, \"data-cd-kontrast\": \"hoch\" }\n : { \"data-cd-theme\": appearance.theme };\n}\n","import { appearanceAttributes, type Appearance } from \"../../core/index.js\";\n\nexport interface WebviewHtmlOptions {\n /** `webview.cspSource` */\n cspSource: string;\n /** The bundle, `webview.asWebviewUri(…).toString()`. */\n scriptUri: string;\n /** Stylesheets in load order (token CSS first, see API.md). */\n styleUris?: readonly string[] | undefined;\n /** `<title>` */\n title: string;\n /** The tool's UI language for `<html lang>`; English modelers pass `\"en\"`. */\n lang: string;\n /** Resolved appearance (`currentAppearance`), written before the first paint. */\n appearance: Appearance;\n /** Markup inside `<body>` before the script; default `<div id=\"app\"></div>`. */\n body?: string | undefined;\n /** Script nonce; default `createNonce()`. */\n nonce?: string | undefined;\n /**\n * Allow inline styles (`style-src … 'unsafe-inline'`), default `true`: renderers write `style`\n * attributes into markup (palette entries, SVG strings). The shell and diagram-js themselves\n * only style through the CSSOM and run without it; pass `false` once the renderer does too.\n */\n inlineStyles?: boolean | undefined;\n}\n\nconst NONCE_ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\nconst NONCE_LENGTH = 32;\n/** Bytes at or above this limit are rejected, so every character is equally likely. */\nconst UNBIASED_BYTE_LIMIT = 256 - (256 % NONCE_ALPHABET.length);\n/** The `base64-value` of a CSP `nonce-source`. */\nconst CSP_NONCE = /^[A-Za-z0-9+/_-]+={0,2}$/;\n\nconst DEFAULT_BODY = '<div id=\"app\"></div>';\n\n/** 32 characters `[A-Za-z0-9]` from `crypto.getRandomValues`. */\nexport function createNonce(): string {\n let nonce = \"\";\n while (nonce.length < NONCE_LENGTH) {\n for (const byte of crypto.getRandomValues(new Uint8Array(NONCE_LENGTH))) {\n if (byte < UNBIASED_BYTE_LIMIT && nonce.length < NONCE_LENGTH) {\n nonce += NONCE_ALPHABET.charAt(byte % NONCE_ALPHABET.length);\n }\n }\n }\n return nonce;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\");\n}\n\nfunction attribute(name: string, value: string): string {\n return `${name}=\"${escapeHtml(value)}\"`;\n}\n\nfunction contentSecurityPolicy(cspSource: string, nonce: string, inlineStyles: boolean): string {\n return [\n \"default-src 'none'\",\n `img-src ${cspSource} data: blob:`,\n inlineStyles ? `style-src ${cspSource} 'unsafe-inline'` : `style-src ${cspSource}`,\n `font-src ${cspSource} data:`,\n `script-src 'nonce-${nonce}'`,\n ].join(\"; \");\n}\n\n/**\n * The webview document: `<html lang class=\"cd-shell-document\" data-cd-theme [data-cd-kontrast]>`,\n * the CSP (`default-src 'none'`, `img-src <cspSource> data: blob:`, `style-src <cspSource>` plus\n * `'unsafe-inline'` unless `inlineStyles: false`, `font-src <cspSource> data:`,\n * `script-src 'nonce-…'`), the stylesheets, `body` and the nonce'd script. Attribute values and the\n * title are escaped; `body` is markup and is not. Throws for a `nonce` that is not a CSP base64\n * value.\n */\nexport function renderWebviewHtml(options: WebviewHtmlOptions): string {\n const nonce = options.nonce ?? createNonce();\n if (!CSP_NONCE.test(nonce)) {\n throw new Error(`@miragon/modeler-shell: renderWebviewHtml got an invalid nonce \"${nonce}\"`);\n }\n const appearance = appearanceAttributes(options.appearance);\n const kontrast = appearance[\"data-cd-kontrast\"];\n const htmlAttributes = [\n attribute(\"lang\", options.lang),\n attribute(\"class\", \"cd-shell-document\"),\n attribute(\"data-cd-theme\", appearance[\"data-cd-theme\"]),\n ...(kontrast ? [attribute(\"data-cd-kontrast\", kontrast)] : []),\n ].join(\" \");\n const stylesheets = (options.styleUris ?? []).map(\n (uri) => `\\n <link ${attribute(\"rel\", \"stylesheet\")} ${attribute(\"href\", uri)} />`,\n );\n\n return `<!doctype html>\n<html ${htmlAttributes}>\n <head>\n <meta charset=\"UTF-8\" />\n <meta http-equiv=\"Content-Security-Policy\" ${attribute(\"content\", contentSecurityPolicy(options.cspSource, nonce, options.inlineStyles !== false))} />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />${stylesheets.join(\"\")}\n <title>${escapeHtml(options.title)}</title>\n </head>\n <body>\n ${options.body ?? DEFAULT_BODY}\n <script ${attribute(\"nonce\", nonce)} ${attribute(\"src\", options.scriptUri)}></script>\n </body>\n</html>\n`;\n}\n","import type { Appearance } from \"../core/index.js\";\n\n/** The one message the theme bridge posts to the webview. */\nexport const APPEARANCE_MESSAGE_TYPE = \"modelerShell.appearance\";\n\nexport interface AppearanceMessage {\n type: typeof APPEARANCE_MESSAGE_TYPE;\n /** Already resolved against the modeler's themes. */\n appearance: Appearance;\n}\n\n/** A plain, JSON-safe message (no `kontrast: undefined` key). */\nexport function appearanceMessage(appearance: Appearance): AppearanceMessage {\n return {\n type: APPEARANCE_MESSAGE_TYPE,\n appearance: appearance.kontrast\n ? { theme: appearance.theme, kontrast: appearance.kontrast }\n : { theme: appearance.theme },\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Type guard for `MessageEvent.data` in the webview. */\nexport function isAppearanceMessage(value: unknown): value is AppearanceMessage {\n if (!isRecord(value) || value.type !== APPEARANCE_MESSAGE_TYPE || !isRecord(value.appearance)) return false;\n const { theme, kontrast } = value.appearance;\n return (theme === \"light\" || theme === \"dark\") && (kontrast === undefined || kontrast === \"hoch\");\n}\n","import {\n requestedAppearance,\n resolveAppearance,\n type Appearance,\n type ColorThemeSetting,\n type Theme,\n} from \"../../core/index.js\";\nimport { appearanceMessage } from \"../protocol.js\";\nimport type { DisposableLike, VsCodeLike, WebviewPanelLike } from \"./types.js\";\n\nexport interface ThemeBridgeOptions {\n /** The modes the modeler can show, a static value of the modeler package (`[\"light\"]` today). */\n themes: readonly Theme[];\n /** Full key of `miragon.<modeler>.colorTheme`; omit until the modeler can show dark. */\n settingKey?: string | undefined;\n}\n\nfunction isColorThemeSetting(value: unknown): value is ColorThemeSetting {\n return value === \"automatic\" || value === \"light\" || value === \"dark\";\n}\n\nfunction readColorThemeSetting(vscode: VsCodeLike, settingKey: string): ColorThemeSetting | undefined {\n const separator = settingKey.lastIndexOf(\".\");\n const value =\n separator < 0\n ? vscode.workspace.getConfiguration().get<unknown>(settingKey)\n : vscode.workspace\n .getConfiguration(settingKey.slice(0, separator))\n .get<unknown>(settingKey.slice(separator + 1));\n return isColorThemeSetting(value) ? value : undefined;\n}\n\n/**\n * The resolved appearance right now: color theme kind (and setting) through `resolveAppearance`.\n * A setting value outside `automatic | light | dark` counts as `automatic`.\n */\nexport function currentAppearance(vscode: VsCodeLike, options: ThemeBridgeOptions): Appearance {\n const setting = options.settingKey ? readColorThemeSetting(vscode, options.settingKey) : undefined;\n return resolveAppearance(requestedAppearance(vscode.window.activeColorTheme.kind, setting), options.themes);\n}\n\n/**\n * Posts an `AppearanceMessage` to the panel's webview on `onDidChangeActiveColorTheme`, on a change\n * of `settingKey` and whenever the panel becomes visible again (hidden retained webviews may miss\n * messages). Disposes itself with the panel. Throws when `themes` is empty.\n */\nexport function connectThemeBridge(\n vscode: VsCodeLike,\n panel: WebviewPanelLike,\n options: ThemeBridgeOptions,\n): DisposableLike {\n if (options.themes.length === 0) {\n throw new Error(\"@miragon/modeler-shell: connectThemeBridge needs at least one theme\");\n }\n const { settingKey } = options;\n const post = (): void => {\n void panel.webview.postMessage(appearanceMessage(currentAppearance(vscode, options)));\n };\n\n let wasVisible = panel.visible;\n const subscriptions: DisposableLike[] = [\n vscode.window.onDidChangeActiveColorTheme(post),\n panel.onDidChangeViewState(({ webviewPanel }) => {\n const becameVisible = webviewPanel.visible && !wasVisible;\n wasVisible = webviewPanel.visible;\n if (becameVisible) post();\n }),\n ];\n if (settingKey) {\n subscriptions.push(\n vscode.workspace.onDidChangeConfiguration((event) => {\n if (event.affectsConfiguration(settingKey)) post();\n }),\n );\n }\n\n let disposed = false;\n const dispose = (): void => {\n if (disposed) return;\n disposed = true;\n for (const subscription of subscriptions.splice(0)) subscription.dispose();\n };\n subscriptions.push(panel.onDidDispose(dispose));\n return { dispose };\n}\n","/**\n * The label VS Code itself uses for revealing a file, for the action on the export notification:\n * `darwin` \"Reveal in Finder\", `win32` \"Reveal in File Explorer\", otherwise \"Open Containing Folder\".\n */\nexport function revealFileLabel(platform: string): string {\n if (platform === \"darwin\") return \"Reveal in Finder\";\n if (platform === \"win32\") return \"Reveal in File Explorer\";\n return \"Open Containing Folder\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBO,SAAS,kBAAkB,WAAuB,QAAsC;AAC7F,QAAM,CAAC,QAAQ,IAAI;AACnB,MAAI,aAAa,QAAW;AAC1B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,QAAQ,OAAO,SAAS,UAAU,KAAK,IAAI,UAAU,QAAQ;AACnE,SAAO,aAAa,OAAO,UAAU,QAAQ;AAC/C;AAGA,SAAS,aAAa,OAAc,UAA+B;AACjE,SAAO,aAAa,SAAS,EAAE,OAAO,SAAS,IAAI,EAAE,MAAM;AAC7D;AAOO,SAAS,6BAA6B,MAA0B;AACrE,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,EAAE,OAAO,OAAO;AAAA,IACzB,KAAK;AACH,aAAO,EAAE,OAAO,QAAQ,UAAU,OAAO;AAAA,IAC3C,KAAK;AACH,aAAO,EAAE,OAAO,SAAS,UAAU,OAAO;AAAA,IAC5C;AACE,aAAO,EAAE,OAAO,QAAQ;AAAA,EAC5B;AACF;AASO,SAAS,oBAAoB,MAAc,SAAqD;AACrG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ACd,kBAAc;AAAA,MACZ,OAAO,UAAU,yBAAyB,CAAC,UAAU;AACnD,YAAI,MAAM,qBAAqB,UAAU,EAAG,MAAK;AAAA,MACnD,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,WAAW;AACf,QAAM,UAAU,MAAY;AAC1B,QAAI,SAAU;AACd,eAAW;AACX,eAAW,gBAAgB,cAAc,OAAO,CAAC,EAAG,cAAa,QAAQ;AAAA,EAC3E;AACA,gBAAc,KAAK,MAAM,aAAa,OAAO,CAAC;AAC9C,SAAO,EAAE,QAAQ;AACnB;;;AChFO,SAAS,gBAAgB,UAA0B;AACxD,MAAI,aAAa,SAAU,QAAO;AAClC,MAAI,aAAa,QAAS,QAAO;AACjC,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { A as Appearance, T as Theme } from './appearance-D3FUcbu6.cjs';
|
|
2
|
+
export { A as APPEARANCE_MESSAGE_TYPE, a as AppearanceMessage, b as appearanceMessage, i as isAppearanceMessage } from './protocol-DhYBakWL.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The parts of the `vscode` namespace the extension helpers use, typed structurally: the shell
|
|
6
|
+
* never imports `vscode`; the extension passes its own `import * as vscode from "vscode"`.
|
|
7
|
+
*/
|
|
8
|
+
interface DisposableLike {
|
|
9
|
+
dispose(): unknown;
|
|
10
|
+
}
|
|
11
|
+
interface ColorThemeLike {
|
|
12
|
+
/** `vscode.ColorThemeKind`: 1 Light, 2 Dark, 3 HighContrast, 4 HighContrastLight. */
|
|
13
|
+
readonly kind: number;
|
|
14
|
+
}
|
|
15
|
+
interface VsCodeLike {
|
|
16
|
+
readonly window: {
|
|
17
|
+
readonly activeColorTheme: ColorThemeLike;
|
|
18
|
+
onDidChangeActiveColorTheme(listener: (theme: ColorThemeLike) => unknown): DisposableLike;
|
|
19
|
+
};
|
|
20
|
+
readonly workspace: {
|
|
21
|
+
getConfiguration(section?: string): {
|
|
22
|
+
get<T>(key: string): T | undefined;
|
|
23
|
+
};
|
|
24
|
+
onDidChangeConfiguration(listener: (event: {
|
|
25
|
+
affectsConfiguration(section: string): boolean;
|
|
26
|
+
}) => unknown): DisposableLike;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** `vscode.WebviewPanel` as far as the theme bridge needs it. */
|
|
30
|
+
interface WebviewPanelLike {
|
|
31
|
+
readonly webview: {
|
|
32
|
+
postMessage(message: unknown): unknown;
|
|
33
|
+
};
|
|
34
|
+
readonly visible: boolean;
|
|
35
|
+
onDidChangeViewState(listener: (event: {
|
|
36
|
+
readonly webviewPanel: {
|
|
37
|
+
readonly visible: boolean;
|
|
38
|
+
};
|
|
39
|
+
}) => unknown): DisposableLike;
|
|
40
|
+
onDidDispose(listener: () => unknown): DisposableLike;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface WebviewHtmlOptions {
|
|
44
|
+
/** `webview.cspSource` */
|
|
45
|
+
cspSource: string;
|
|
46
|
+
/** The bundle, `webview.asWebviewUri(…).toString()`. */
|
|
47
|
+
scriptUri: string;
|
|
48
|
+
/** Stylesheets in load order (token CSS first, see API.md). */
|
|
49
|
+
styleUris?: readonly string[] | undefined;
|
|
50
|
+
/** `<title>` */
|
|
51
|
+
title: string;
|
|
52
|
+
/** The tool's UI language for `<html lang>`; English modelers pass `"en"`. */
|
|
53
|
+
lang: string;
|
|
54
|
+
/** Resolved appearance (`currentAppearance`), written before the first paint. */
|
|
55
|
+
appearance: Appearance;
|
|
56
|
+
/** Markup inside `<body>` before the script; default `<div id="app"></div>`. */
|
|
57
|
+
body?: string | undefined;
|
|
58
|
+
/** Script nonce; default `createNonce()`. */
|
|
59
|
+
nonce?: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Allow inline styles (`style-src … 'unsafe-inline'`), default `true`: renderers write `style`
|
|
62
|
+
* attributes into markup (palette entries, SVG strings). The shell and diagram-js themselves
|
|
63
|
+
* only style through the CSSOM and run without it; pass `false` once the renderer does too.
|
|
64
|
+
*/
|
|
65
|
+
inlineStyles?: boolean | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** 32 characters `[A-Za-z0-9]` from `crypto.getRandomValues`. */
|
|
68
|
+
declare function createNonce(): string;
|
|
69
|
+
/**
|
|
70
|
+
* The webview document: `<html lang class="cd-shell-document" data-cd-theme [data-cd-kontrast]>`,
|
|
71
|
+
* the CSP (`default-src 'none'`, `img-src <cspSource> data: blob:`, `style-src <cspSource>` plus
|
|
72
|
+
* `'unsafe-inline'` unless `inlineStyles: false`, `font-src <cspSource> data:`,
|
|
73
|
+
* `script-src 'nonce-…'`), the stylesheets, `body` and the nonce'd script. Attribute values and the
|
|
74
|
+
* title are escaped; `body` is markup and is not. Throws for a `nonce` that is not a CSP base64
|
|
75
|
+
* value.
|
|
76
|
+
*/
|
|
77
|
+
declare function renderWebviewHtml(options: WebviewHtmlOptions): string;
|
|
78
|
+
|
|
79
|
+
interface ThemeBridgeOptions {
|
|
80
|
+
/** The modes the modeler can show, a static value of the modeler package (`["light"]` today). */
|
|
81
|
+
themes: readonly Theme[];
|
|
82
|
+
/** Full key of `miragon.<modeler>.colorTheme`; omit until the modeler can show dark. */
|
|
83
|
+
settingKey?: string | undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The resolved appearance right now: color theme kind (and setting) through `resolveAppearance`.
|
|
87
|
+
* A setting value outside `automatic | light | dark` counts as `automatic`.
|
|
88
|
+
*/
|
|
89
|
+
declare function currentAppearance(vscode: VsCodeLike, options: ThemeBridgeOptions): Appearance;
|
|
90
|
+
/**
|
|
91
|
+
* Posts an `AppearanceMessage` to the panel's webview on `onDidChangeActiveColorTheme`, on a change
|
|
92
|
+
* of `settingKey` and whenever the panel becomes visible again (hidden retained webviews may miss
|
|
93
|
+
* messages). Disposes itself with the panel. Throws when `themes` is empty.
|
|
94
|
+
*/
|
|
95
|
+
declare function connectThemeBridge(vscode: VsCodeLike, panel: WebviewPanelLike, options: ThemeBridgeOptions): DisposableLike;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The label VS Code itself uses for revealing a file, for the action on the export notification:
|
|
99
|
+
* `darwin` "Reveal in Finder", `win32` "Reveal in File Explorer", otherwise "Open Containing Folder".
|
|
100
|
+
*/
|
|
101
|
+
declare function revealFileLabel(platform: string): string;
|
|
102
|
+
|
|
103
|
+
export { type ColorThemeLike, type DisposableLike, type ThemeBridgeOptions, type VsCodeLike, type WebviewHtmlOptions, type WebviewPanelLike, connectThemeBridge, createNonce, currentAppearance, renderWebviewHtml, revealFileLabel };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { A as Appearance, T as Theme } from './appearance-D3FUcbu6.js';
|
|
2
|
+
export { A as APPEARANCE_MESSAGE_TYPE, a as AppearanceMessage, b as appearanceMessage, i as isAppearanceMessage } from './protocol-IeW8bf4f.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The parts of the `vscode` namespace the extension helpers use, typed structurally: the shell
|
|
6
|
+
* never imports `vscode`; the extension passes its own `import * as vscode from "vscode"`.
|
|
7
|
+
*/
|
|
8
|
+
interface DisposableLike {
|
|
9
|
+
dispose(): unknown;
|
|
10
|
+
}
|
|
11
|
+
interface ColorThemeLike {
|
|
12
|
+
/** `vscode.ColorThemeKind`: 1 Light, 2 Dark, 3 HighContrast, 4 HighContrastLight. */
|
|
13
|
+
readonly kind: number;
|
|
14
|
+
}
|
|
15
|
+
interface VsCodeLike {
|
|
16
|
+
readonly window: {
|
|
17
|
+
readonly activeColorTheme: ColorThemeLike;
|
|
18
|
+
onDidChangeActiveColorTheme(listener: (theme: ColorThemeLike) => unknown): DisposableLike;
|
|
19
|
+
};
|
|
20
|
+
readonly workspace: {
|
|
21
|
+
getConfiguration(section?: string): {
|
|
22
|
+
get<T>(key: string): T | undefined;
|
|
23
|
+
};
|
|
24
|
+
onDidChangeConfiguration(listener: (event: {
|
|
25
|
+
affectsConfiguration(section: string): boolean;
|
|
26
|
+
}) => unknown): DisposableLike;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** `vscode.WebviewPanel` as far as the theme bridge needs it. */
|
|
30
|
+
interface WebviewPanelLike {
|
|
31
|
+
readonly webview: {
|
|
32
|
+
postMessage(message: unknown): unknown;
|
|
33
|
+
};
|
|
34
|
+
readonly visible: boolean;
|
|
35
|
+
onDidChangeViewState(listener: (event: {
|
|
36
|
+
readonly webviewPanel: {
|
|
37
|
+
readonly visible: boolean;
|
|
38
|
+
};
|
|
39
|
+
}) => unknown): DisposableLike;
|
|
40
|
+
onDidDispose(listener: () => unknown): DisposableLike;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface WebviewHtmlOptions {
|
|
44
|
+
/** `webview.cspSource` */
|
|
45
|
+
cspSource: string;
|
|
46
|
+
/** The bundle, `webview.asWebviewUri(…).toString()`. */
|
|
47
|
+
scriptUri: string;
|
|
48
|
+
/** Stylesheets in load order (token CSS first, see API.md). */
|
|
49
|
+
styleUris?: readonly string[] | undefined;
|
|
50
|
+
/** `<title>` */
|
|
51
|
+
title: string;
|
|
52
|
+
/** The tool's UI language for `<html lang>`; English modelers pass `"en"`. */
|
|
53
|
+
lang: string;
|
|
54
|
+
/** Resolved appearance (`currentAppearance`), written before the first paint. */
|
|
55
|
+
appearance: Appearance;
|
|
56
|
+
/** Markup inside `<body>` before the script; default `<div id="app"></div>`. */
|
|
57
|
+
body?: string | undefined;
|
|
58
|
+
/** Script nonce; default `createNonce()`. */
|
|
59
|
+
nonce?: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Allow inline styles (`style-src … 'unsafe-inline'`), default `true`: renderers write `style`
|
|
62
|
+
* attributes into markup (palette entries, SVG strings). The shell and diagram-js themselves
|
|
63
|
+
* only style through the CSSOM and run without it; pass `false` once the renderer does too.
|
|
64
|
+
*/
|
|
65
|
+
inlineStyles?: boolean | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** 32 characters `[A-Za-z0-9]` from `crypto.getRandomValues`. */
|
|
68
|
+
declare function createNonce(): string;
|
|
69
|
+
/**
|
|
70
|
+
* The webview document: `<html lang class="cd-shell-document" data-cd-theme [data-cd-kontrast]>`,
|
|
71
|
+
* the CSP (`default-src 'none'`, `img-src <cspSource> data: blob:`, `style-src <cspSource>` plus
|
|
72
|
+
* `'unsafe-inline'` unless `inlineStyles: false`, `font-src <cspSource> data:`,
|
|
73
|
+
* `script-src 'nonce-…'`), the stylesheets, `body` and the nonce'd script. Attribute values and the
|
|
74
|
+
* title are escaped; `body` is markup and is not. Throws for a `nonce` that is not a CSP base64
|
|
75
|
+
* value.
|
|
76
|
+
*/
|
|
77
|
+
declare function renderWebviewHtml(options: WebviewHtmlOptions): string;
|
|
78
|
+
|
|
79
|
+
interface ThemeBridgeOptions {
|
|
80
|
+
/** The modes the modeler can show, a static value of the modeler package (`["light"]` today). */
|
|
81
|
+
themes: readonly Theme[];
|
|
82
|
+
/** Full key of `miragon.<modeler>.colorTheme`; omit until the modeler can show dark. */
|
|
83
|
+
settingKey?: string | undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The resolved appearance right now: color theme kind (and setting) through `resolveAppearance`.
|
|
87
|
+
* A setting value outside `automatic | light | dark` counts as `automatic`.
|
|
88
|
+
*/
|
|
89
|
+
declare function currentAppearance(vscode: VsCodeLike, options: ThemeBridgeOptions): Appearance;
|
|
90
|
+
/**
|
|
91
|
+
* Posts an `AppearanceMessage` to the panel's webview on `onDidChangeActiveColorTheme`, on a change
|
|
92
|
+
* of `settingKey` and whenever the panel becomes visible again (hidden retained webviews may miss
|
|
93
|
+
* messages). Disposes itself with the panel. Throws when `themes` is empty.
|
|
94
|
+
*/
|
|
95
|
+
declare function connectThemeBridge(vscode: VsCodeLike, panel: WebviewPanelLike, options: ThemeBridgeOptions): DisposableLike;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The label VS Code itself uses for revealing a file, for the action on the export notification:
|
|
99
|
+
* `darwin` "Reveal in Finder", `win32` "Reveal in File Explorer", otherwise "Open Containing Folder".
|
|
100
|
+
*/
|
|
101
|
+
declare function revealFileLabel(platform: string): string;
|
|
102
|
+
|
|
103
|
+
export { type ColorThemeLike, type DisposableLike, type ThemeBridgeOptions, type VsCodeLike, type WebviewHtmlOptions, type WebviewPanelLike, connectThemeBridge, createNonce, currentAppearance, renderWebviewHtml, revealFileLabel };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connectThemeBridge,
|
|
3
|
+
createNonce,
|
|
4
|
+
currentAppearance,
|
|
5
|
+
renderWebviewHtml,
|
|
6
|
+
revealFileLabel
|
|
7
|
+
} from "./chunk-KYDG5DMX.js";
|
|
8
|
+
import {
|
|
9
|
+
APPEARANCE_MESSAGE_TYPE,
|
|
10
|
+
appearanceMessage,
|
|
11
|
+
isAppearanceMessage
|
|
12
|
+
} from "./chunk-N4QXFF3A.js";
|
|
13
|
+
import "./chunk-OADW3GPA.js";
|
|
14
|
+
export {
|
|
15
|
+
APPEARANCE_MESSAGE_TYPE,
|
|
16
|
+
appearanceMessage,
|
|
17
|
+
connectThemeBridge,
|
|
18
|
+
createNonce,
|
|
19
|
+
currentAppearance,
|
|
20
|
+
isAppearanceMessage,
|
|
21
|
+
renderWebviewHtml,
|
|
22
|
+
revealFileLabel
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=vscode-extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|