@purview-dev/astroc4 1.0.0-prerelease.4 → 1.0.0-prerelease.6
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/README.md +222 -77
- package/dist/expressive-code.d.ts +0 -4
- package/dist/expressive-code.js.map +5 -5
- package/dist/fences.d.ts +45 -16
- package/dist/file-layout.d.ts +4 -0
- package/dist/grammar/langium.d.ts +0 -4
- package/dist/grammar/source.d.ts +0 -12
- package/dist/grammar/textmate.d.ts +0 -2
- package/dist/icon-assets.d.ts +28 -0
- package/dist/icon-plugin.d.ts +16 -0
- package/dist/index.d.ts +21 -43
- package/dist/index.js +707 -97
- package/dist/index.js.map +15 -9
- package/dist/integration.d.ts +27 -0
- package/dist/integration.js +827 -0
- package/dist/integration.js.map +17 -0
- package/dist/projects.d.ts +24 -0
- package/dist/translations.d.ts +1 -0
- package/dist/workspace.d.ts +5 -0
- package/package.json +24 -4
- package/src/components/DiagramFrame.astro +14 -16
- package/src/components/DiagramShell.astro +19 -20
- package/src/components/ErrorBoundary.tsx +1 -5
- package/src/components/LikeC4Fence.astro +3 -6
- package/src/components/LikeC4InlineView.tsx +6 -16
- package/src/components/LikeC4ProjectView.tsx +0 -5
- package/src/components/LikeC4View.astro +75 -21
- package/src/components/LoadingPlaceholder.astro +10 -9
- package/src/components/icon-source.ts +5 -22
- package/src/components/labels.ts +10 -16
- package/src/components/md-fences.tsx +37 -0
- package/src/components/render-icon.tsx +0 -9
- package/src/components/utils.ts +40 -7
- package/src/translations.ts +3 -10
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/integration.ts", "../src/fences.ts", "../src/translations.ts", "../src/file-layout.ts", "../src/icon-plugin.ts", "../src/icon-assets.ts", "../src/projects.ts", "../src/workspace.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { existsSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { AstroConfig, AstroIntegration, AstroIntegrationLogger } from 'astro';\nimport { LikeC4VitePlugin } from 'likec4/vite-plugin';\nimport type { Plugin as VitePlugin } from 'vite';\n\nimport { likec4Fences, preloadLikeC4 } from './fences.ts';\nimport { fileLayoutPlugin } from './file-layout.ts';\nimport { astroc4IconPlugin, type Astroc4IconPlugin } from './icon-plugin.ts';\nimport { discoverProjects, resolveProjects, type ResolvedProject } from './projects.ts';\nimport { prepareWorkspace, PROJECTS_MODULE_ID, projectsModule } from './workspace.ts';\n\n/** Scoped because npm refuses the unscoped `astroc4` as too similar to `astro`. */\nexport const PACKAGE_NAME = '@purview-dev/astroc4';\n\nexport interface LikeC4IntegrationOptions {\n\t/**\n\t * Passed through to `LikeC4VitePlugin`. Setting `workspace` or\n\t * `languageServices` takes project discovery over, and `projects` is ignored.\n\t */\n\tvitePlugin?: Parameters<typeof LikeC4VitePlugin>[0];\n\t/**\n\t * Named LikeC4 projects, compiled alongside those discovered under the site\n\t * root: `{ architecture: '../../docs/architecture/likec4' }`. Folders are\n\t * relative to the site root or absolute.\n\t */\n\tprojects?: Record<string, string>;\n\t/** Render ```likec4 fences in .md and .mdx pages as diagrams. Defaults to `true`. */\n\tfences?: boolean;\n}\n\n/**\n * `likec4/react` is built with the React Compiler and imports `c` from\n * `react/compiler-runtime`, which React 19 ships as CommonJS. Unless Vite\n * pre-bundles it, `astro dev` serves it raw and every island fails with\n * \"does not provide an export named 'c'\" — while `astro build` stays green.\n */\nconst OPTIMIZED_DEPENDENCIES = ['react/compiler-runtime'];\n\n/**\n * Mounts the fences of .md pages. Injected into every page, so React and LikeC4\n * are only `import()`ed on a page that has a placeholder.\n */\nconst MD_FENCES_SCRIPT = [\n\t`const mountLikeC4Fences = () => {`,\n\t` if (!document.querySelector('[data-astroc4-fence]:not([data-astroc4-mounted])')) return;`,\n\t` import('${PACKAGE_NAME}/components/md-fences').then((module) => module.mountFences());`,\n\t`};`,\n\t`if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', mountLikeC4Fences);`,\n\t`else mountLikeC4Fences();`,\n\t`document.addEventListener('astro:page-load', mountLikeC4Fences);`,\n].join('\\n');\n\n/**\n * The `optimizeDeps.include` entries the site still lacks. Only missing ones:\n * Vite's `mergeConfig` concatenates arrays. Unresolvable ones are skipped, since\n * naming a package Vite cannot find breaks the optimizer.\n */\nexport function missingOptimizedDependencies(include: unknown, root: string): string[] {\n\tconst existing = Array.isArray(include) ? include : [];\n\n\treturn OPTIMIZED_DEPENDENCIES.filter(\n\t\t(dependency) => !existing.includes(dependency) && resolvesFrom(dependency, root),\n\t);\n}\n\n// Walks node_modules as Vite does: under Bun, `createRequire` also finds\n// packages in Bun's global cache, which Vite never looks in.\nfunction resolvesFrom(specifier: string, root: string): boolean {\n\tconst name = specifier.split('/', specifier.startsWith('@') ? 2 : 1).join('/');\n\n\tfor (let dir = resolve(root); ; dir = dirname(dir)) {\n\t\tif (existsSync(join(dir, 'node_modules', name, 'package.json'))) return true;\n\t\tif (dirname(dir) === dir) return false;\n\t}\n}\n\nexport function likec4Integration({\n\tvitePlugin = {},\n\tprojects,\n\tfences = true,\n}: LikeC4IntegrationOptions = {}): AstroIntegration {\n\tlet icons: Astroc4IconPlugin | undefined;\n\n\treturn {\n\t\tname: `${PACKAGE_NAME}/integration`,\n\t\thooks: {\n\t\t\t'astro:config:setup': async ({ command, config, updateConfig, injectScript, logger }) => {\n\t\t\t\tconst root = fileURLToPath(config.root);\n\t\t\t\tconst optimizeDeps = missingOptimizedDependencies(config.vite?.optimizeDeps?.include, root);\n\t\t\t\tconst { pluginOptions, resolved, stagingDir } = await workspaceFor(root, vitePlugin, projects, logger);\n\n\t\t\t\ticons = astroc4IconPlugin({ projects: resolved, base: config.base ?? '/', siteRoot: root, stagingDir });\n\n\t\t\t\tupdateConfig({\n\t\t\t\t\tvite: {\n\t\t\t\t\t\tplugins: [LikeC4VitePlugin(pluginOptions), projectsPlugin(resolved), icons, fileLayoutPlugin()],\n\t\t\t\t\t\t// The components ship as .astro/.tsx source for Vite to transform.\n\t\t\t\t\t\tssr: { noExternal: [PACKAGE_NAME] },\n\t\t\t\t\t\t...(optimizeDeps.length > 0 ? { optimizeDeps: { include: optimizeDeps } } : {}),\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (fences) {\n\t\t\t\t\tawait registerFences(config, updateConfig, logger, resolved);\n\t\t\t\t\tinjectScript('page', MD_FENCES_SCRIPT);\n\t\t\t\t}\n\n\t\t\t\tawait ensureReactRenderer(config, updateConfig, logger);\n\n\t\t\t\t// Build only: loading LikeC4 eagerly in dev restarts the server (see ./fences.ts).\n\t\t\t\tif (command === 'build') {\n\t\t\t\t\tawait preloadLikeC4();\n\t\t\t\t}\n\t\t\t},\n\t\t\t'astro:build:done': async ({ dir }) => {\n\t\t\t\tawait icons?.emit(fileURLToPath(dir));\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * The options `LikeC4VitePlugin` gets, and the projects pages can name. With\n * `projects`, every project is linked into one staging workspace, because the\n * plugin compiles a single folder.\n */\nasync function workspaceFor(\n\troot: string,\n\tvitePlugin: NonNullable<LikeC4IntegrationOptions['vitePlugin']>,\n\tconfigured: Record<string, string> | undefined,\n\tlogger: AstroIntegrationLogger,\n): Promise<{\n\tpluginOptions: NonNullable<LikeC4IntegrationOptions['vitePlugin']>;\n\tresolved: ResolvedProject[];\n\tstagingDir?: string;\n}> {\n\tconst hasConfigured = configured !== undefined && Object.keys(configured).length > 0;\n\n\tif (vitePlugin.workspace !== undefined || 'languageServices' in vitePlugin) {\n\t\tif (hasConfigured) {\n\t\t\tlogger.warn(\n\t\t\t\t'`projects` is ignored because `vitePlugin.workspace` or `vitePlugin.languageServices` is set; remove one of them.',\n\t\t\t);\n\t\t}\n\n\t\treturn { pluginOptions: vitePlugin, resolved: [] };\n\t}\n\n\tconst discovered = await discoverProjects(root);\n\n\tif (!hasConfigured) {\n\t\treturn { pluginOptions: vitePlugin, resolved: discovered };\n\t}\n\n\tconst resolved = await resolveProjects({ root, configured, discovered });\n\tconst workspace = await prepareWorkspace(resolved, join(root, '.astro', 'astroc4'));\n\n\treturn { pluginOptions: { ...(vitePlugin as { workspace?: string }), workspace }, resolved, stagingDir: workspace };\n}\n\n/** Serves `virtual:astroc4/projects`: the names components may pass as `project`. */\nfunction projectsPlugin(projects: ResolvedProject[]): VitePlugin {\n\tconst resolvedId = `\\0${PROJECTS_MODULE_ID}`;\n\n\treturn {\n\t\tname: `${PACKAGE_NAME}/projects`,\n\t\tresolveId: (id) => (id === PROJECTS_MODULE_ID ? resolvedId : undefined),\n\t\tload: (id) => (id === resolvedId ? projectsModule(projects) : undefined),\n\t};\n}\n\n/**\n * Add `@astrojs/react` when the site has not: without a renderer the\n * `client:only=\"react\"` islands fail with Astro's generic \"no renderer\" error.\n * Integrations pushed here still have their hooks run in this pass. MDX and\n * Expressive Code are left to the site, because they change its content types\n * and code blocks.\n */\nasync function ensureReactRenderer(\n\tconfig: AstroConfig,\n\tupdateConfig: (config: Record<string, unknown>) => void,\n\tlogger: AstroIntegrationLogger,\n): Promise<void> {\n\tif (config.integrations.some((integration) => integration.name === '@astrojs/react')) return;\n\n\ttry {\n\t\tconst { default: react } = await import('@astrojs/react');\n\n\t\tupdateConfig({ integrations: [react()] });\n\t\tlogger.info('added @astrojs/react: the LikeC4 diagrams are React islands (client:only=\"react\").');\n\t} catch {\n\t\tlogger.warn(\n\t\t\t'@astrojs/react is not installed, so <LikeC4View> cannot render. Install it (`astro add react`).',\n\t\t);\n\t}\n}\n\n/** Append the fence transform to the site's Sätteri processor, keeping its plugins. */\nasync function registerFences(\n\tconfig: AstroConfig,\n\tupdateConfig: (config: Record<string, unknown>) => void,\n\tlogger: AstroIntegrationLogger,\n\tprojects: ResolvedProject[],\n): Promise<void> {\n\tconst { satteri, isSatteriProcessor } = await import('@astrojs/markdown-satteri');\n\tconst existing = config.markdown?.processor;\n\tconst fences = () =>\n\t\tlikec4Fences({\n\t\t\troot: fileURLToPath(config.root),\n\t\t\t// Empty when the site took discovery over: then only the browser knows.\n\t\t\tprojects: projects.length > 0 ? projects.map((project) => project.name) : undefined,\n\t\t});\n\n\t// No processor configured means Astro's default, which is Sätteri.\n\tif (existing === undefined) {\n\t\tupdateConfig({ markdown: { processor: satteri({ mdastPlugins: [fences()] }) } });\n\t\treturn;\n\t}\n\n\tif (!isSatteriProcessor(existing)) {\n\t\tlogger.warn(\n\t\t\t'```likec4 fences are disabled: the site is not using the Sätteri Markdown processor. ' +\n\t\t\t\t'<LikeC4View /> still works.',\n\t\t);\n\t\treturn;\n\t}\n\n\tconst existingOptions = existing.options ?? {};\n\n\tupdateConfig({\n\t\tmarkdown: {\n\t\t\tprocessor: satteri({\n\t\t\t\t...existingOptions,\n\t\t\t\tmdastPlugins: [...(existingOptions.mdastPlugins ?? []), fences()],\n\t\t\t}),\n\t\t},\n\t});\n}\n\nexport default likec4Integration;\n",
|
|
6
|
+
"// Turns ```likec4 fences into diagrams: an empty fence with `view=` shows a\n// project view, a fence with DSL (or `file=`) is compiled and laid out here, at\n// build time, because layout needs LikeC4's WASM graph engine.\n//\n// A Sätteri mdast plugin, not a remark one: Astro 7's default processor is\n// Sätteri, and `remarkPlugins` is silently ignored without\n// @astrojs/markdown-remark.\n\nimport { createHash } from 'node:crypto';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, isAbsolute, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport { fileURLToPath } from 'node:url';\n\nimport type { MdastPluginEntry, PluginFactoryContext } from 'satteri';\n\nimport { translations } from './translations.ts';\n\nconst require = createRequire(import.meta.url);\n\n// Not imported at module scope: `likec4` pulls in Langium, an LSP and the WASM\n// layout engine, and loading that with astro.config made Astro restart on a\n// cold start, which killed the content layer.\nlet likec4ApiPromise: Promise<LikeC4Api> | undefined;\n\ntype LikeC4Api = typeof import('likec4').LikeC4;\n\nfunction loadLikeC4(): Promise<LikeC4Api> {\n\t// `require`, not `import()`: Vite's SSR module runner intercepts dynamic\n\t// imports from modules it loaded, and on Windows it can already be tearing\n\t// down when a page's fence gets here, which crashed `astro build`.\n\tlikec4ApiPromise ??= Promise.resolve(require('likec4').LikeC4);\n\n\treturn likec4ApiPromise;\n}\n\n/**\n * Finishes loading LikeC4 before the first page renders, so the load cannot race\n * the module runner's teardown. Called for builds only.\n */\nexport function preloadLikeC4(): Promise<LikeC4Api> {\n\treturn loadLikeC4();\n}\n\nconst FENCE_LANG = 'likec4';\n\nconst INLINE_COMPONENT = '__LikeC4Fence';\nconst PROJECT_COMPONENT = '__LikeC4View';\n\n// Package specifiers: the import is written into the site's page.\nconst PACKAGE_NAME = '@purview-dev/astroc4';\n\nconst IMPORTS = {\n\t[INLINE_COMPONENT]: `${PACKAGE_NAME}/components/LikeC4Fence.astro`,\n\t[PROJECT_COMPONENT]: `${PACKAGE_NAME}/components/LikeC4View.astro`,\n} as const;\n\ntype ComponentName = keyof typeof IMPORTS;\n\nconst STRINGS = translations.en;\n\ninterface Layout {\n\tdump: any;\n\tviewIds: string[];\n}\n\n/** Keyed by source: a compile costs ~250ms and dev re-renders a page on every edit. */\nconst layoutCache = new Map<string, Layout>();\n\nexport interface FenceMeta {\n\ttitle?: string;\n\tdescription?: string;\n\theight?: string;\n\tcollapsible?: string;\n\tdefaultOpen?: string;\n\tview?: string;\n\tproject?: string;\n\tfile?: string;\n\t[key: string]: string | undefined;\n}\n\n/** Parse `key=\"value\"` / `key='value'` / `key=value` pairs from the fence's meta string. */\nexport function parseFenceMeta(meta: string | null | undefined): FenceMeta {\n\tconst options: FenceMeta = {};\n\n\tif (!meta) return options;\n\n\tconst pattern = /(\\w+)=(?:\"([^\"]*)\"|'([^']*)'|(\\S+))/g;\n\tlet match;\n\n\twhile ((match = pattern.exec(meta)) !== null) {\n\t\tconst key = match[1];\n\t\tif (!key) continue;\n\n\t\toptions[key] = match[2] ?? match[3] ?? match[4] ?? '';\n\t}\n\n\treturn options;\n}\n\n/** Compile and lay out LikeC4 source; shared by fences and `<LikeC4View file>`. */\nexport async function layoutSource(source: string): Promise<Layout> {\n\tconst key = createHash('sha256').update(source).digest('hex');\n\tconst cached = layoutCache.get(key);\n\n\tif (cached) return cached;\n\n\tconst LikeC4 = await loadLikeC4();\n\tconst likec4 = await LikeC4.fromSource(source);\n\n\tif (likec4.hasErrors()) {\n\t\t// First line only: parser errors list every expected token.\n\t\tconst detail = likec4\n\t\t\t.getErrors()\n\t\t\t.map((error) => String(error.message).split('\\n')[0]?.trim() ?? '')\n\t\t\t.slice(0, 3)\n\t\t\t.join('; ');\n\n\t\tthrow new Error(detail || 'the snippet could not be parsed');\n\t}\n\n\tconst model = await likec4.layoutedModel();\n\tconst dump = JSON.parse(JSON.stringify(model.$data));\n\n\tconst result: Layout = { dump, viewIds: Object.keys(dump.views ?? {}) };\n\tlayoutCache.set(key, result);\n\n\treturn result;\n}\n\ninterface JsxAttribute {\n\ttype: 'mdxJsxAttribute';\n\tname: string;\n\tvalue: string;\n}\n\n/** `import <local> from '<source>';` as the MDX compiler expects it. */\nfunction importNode(local: string, source: string) {\n\treturn {\n\t\ttype: 'mdxjsEsm',\n\t\tvalue: `import ${local} from ${JSON.stringify(source)};`,\n\t\tdata: {\n\t\t\testree: {\n\t\t\t\ttype: 'Program',\n\t\t\t\tsourceType: 'module',\n\t\t\t\tbody: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'ImportDeclaration',\n\t\t\t\t\t\tspecifiers: [\n\t\t\t\t\t\t\t{ type: 'ImportDefaultSpecifier', local: { type: 'Identifier', name: local } },\n\t\t\t\t\t\t],\n\t\t\t\t\t\tsource: { type: 'Literal', value: source, raw: JSON.stringify(source) },\n\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction attributes(pairs: Record<string, string | undefined>): JsxAttribute[] {\n\treturn Object.entries(pairs)\n\t\t.filter(([, value]) => value !== undefined && value !== null && value !== '')\n\t\t.map(([name, value]) => ({ type: 'mdxJsxAttribute', name, value: String(value) }));\n}\n\nfunction describe(fileURL: URL | undefined): string {\n\tif (!fileURL) return 'a content file';\n\n\ttry {\n\t\treturn fileURLToPath(fileURL);\n\t} catch {\n\t\treturn String(fileURL);\n\t}\n}\n\nexport interface FenceReporter {\n\twarn: (message: string) => void;\n}\n\nexport interface FenceOptions {\n\t/** @deprecated Unused since 1.0.0-prerelease.6. */\n\treporter?: FenceReporter;\n\t/** @deprecated Unused since 1.0.0-prerelease.6. */\n\tmdx?: boolean;\n\t/** The site root. A fence's `file=\"…\"` must stay inside it; without one, `file=` is refused. */\n\troot?: string;\n\t/**\n\t * The project names a page may pass as `project`. When given, an empty fence's\n\t * `project` is checked at build time; without it, only the browser can.\n\t */\n\tprojects?: string[];\n}\n\n// region plugin\nexport function likec4Fences({ root, projects }: FenceOptions = {}): MdastPluginEntry {\n\t// A factory runs once per document, so `used` is per page.\n\treturn (factory: PluginFactoryContext) => {\n\t\tif (!factory.source.includes('```' + FENCE_LANG)) return null;\n\n\t\t// A .md page cannot hold a component, so it gets a placeholder that the\n\t\t// injected page script mounts (src/components/md-fences.tsx).\n\t\tconst markdown = factory.sourceFormat !== 'mdx';\n\t\tconst used = new Set<ComponentName>();\n\n\t\treturn {\n\t\t\tname: 'likec4-fences',\n\n\t\t\tasync code(node, ctx) {\n\t\t\t\tif (node.lang !== FENCE_LANG) return;\n\n\t\t\t\tconst where = `${describe(ctx.fileURL)}: \\`\\`\\`${FENCE_LANG} fence`;\n\t\t\t\tconst options = parseFenceMeta(node.meta);\n\t\t\t\tconst source = options.file\n\t\t\t\t\t? await readFenceFile(options.file, ctx.fileURL, root, where)\n\t\t\t\t\t: (node.value ?? '').trim();\n\n\t\t\t\tconst common = {\n\t\t\t\t\ttitle: options.title,\n\t\t\t\t\tdescription: options.description,\n\t\t\t\t\theight: options.height,\n\t\t\t\t\tcollapsible: options.collapsible,\n\t\t\t\t\tdefaultOpen: options.defaultOpen,\n\t\t\t\t};\n\n\t\t\t\tif (source.length === 0) {\n\t\t\t\t\tif (!options.view) {\n\t\t\t\t\t\tthrow new Error(`${where} is empty, so it needs \\`view=\"<id>\"\\` to name a view in the project model.`);\n\t\t\t\t\t}\n\n\t\t\t\t\tcheckProject(options.project, projects, where);\n\n\t\t\t\t\tif (markdown) {\n\t\t\t\t\t\tctx.replaceNode(node, {\n\t\t\t\t\t\t\traw: fencePlaceholder({ ...placeholderOptions(options), viewId: options.view, project: options.project }),\n\t\t\t\t\t\t\tmdxExpressions: false,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tused.add(PROJECT_COMPONENT);\n\n\t\t\t\t\tctx.replaceNode(node, {\n\t\t\t\t\t\ttype: 'mdxJsxFlowElement',\n\t\t\t\t\t\tname: PROJECT_COMPONENT,\n\t\t\t\t\t\tattributes: attributes({ ...common, viewId: options.view, project: options.project }),\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t});\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet layout;\n\n\t\t\t\ttry {\n\t\t\t\t\tlayout = await layoutSource(source);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${where} is not valid LikeC4 — ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst viewId = options.view ?? defaultView(source, layout.viewIds);\n\n\t\t\t\tif (!viewId || !layout.viewIds.includes(viewId)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${where} has no view \"${viewId ?? '(none)'}\". Declared: ${layout.viewIds.join(', ') || '(none)'}.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (markdown) {\n\t\t\t\t\tctx.replaceNode(node, {\n\t\t\t\t\t\traw: fencePlaceholder({ ...placeholderOptions(options), viewId, model: layout.dump }),\n\t\t\t\t\t\tmdxExpressions: false,\n\t\t\t\t\t});\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tused.add(INLINE_COMPONENT);\n\n\t\t\t\tctx.replaceNode(node, {\n\t\t\t\t\ttype: 'mdxJsxFlowElement',\n\t\t\t\t\tname: INLINE_COMPONENT,\n\t\t\t\t\tattributes: attributes({ ...common, viewId, model: JSON.stringify(layout.dump) }),\n\t\t\t\t\tchildren: [],\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tafter(root, ctx) {\n\t\t\t\tif (used.size === 0) return;\n\n\t\t\t\tctx.insertChildAt(\n\t\t\t\t\troot,\n\t\t\t\t\t0,\n\t\t\t\t\t[...used].map((local) => importNode(local, IMPORTS[local])),\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t};\n}\n// endregion\n\n/** The same rule `<LikeC4View>` applies: required with several projects, and must exist. */\nfunction checkProject(project: string | undefined, projects: string[] | undefined, where: string): void {\n\tif (projects === undefined) return;\n\n\tconst requested = project?.trim();\n\tconst available = projects.join(', ');\n\n\tif (!requested) {\n\t\tif (projects.length > 1) {\n\t\t\tthrow new Error(`${where}: ${STRINGS['likec4.error.projectRequired'].replace('{available}', available)}`);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (!projects.includes(requested)) {\n\t\tthrow new Error(\n\t\t\t`${where}: ${STRINGS['likec4.error.unknownProject']\n\t\t\t\t.replace('{projectId}', requested)\n\t\t\t\t.replace('{available}', available || '(none)')}`,\n\t\t);\n\t}\n}\n\n/**\n * The first `view <id>` the source declares. LikeC4 adds an automatic `index`\n * view and lists it first, so the first laid-out view would be that overview.\n */\nfunction defaultView(source: string, viewIds: string[]): string | undefined {\n\t// Skips matches that are not laid-out views, such as \"a view of …\" in a title.\n\tfor (const match of source.matchAll(/(?<![\\w-])view\\s+([\\w-]+)/g)) {\n\t\tif (viewIds.includes(match[1]!)) return match[1];\n\t}\n\n\treturn viewIds[0];\n}\n\nexport interface FencePlaceholder {\n\tviewId: string;\n\t/** The laid-out model of an inline or `file=` fence; absent for a project view. */\n\tmodel?: unknown;\n\tproject?: string;\n\ttitle?: string;\n\tdescription?: string;\n\theight?: number;\n\tcollapsible?: boolean;\n\tdefaultOpen?: boolean;\n}\n\n/** A theme token with the same fallbacks the Astro components use. */\nconst token = {\n\tborder: 'var(--likec4-border, var(--sl-color-gray-5, rgba(128, 128, 128, 0.35)))',\n\tsurface: 'var(--likec4-surface, var(--sl-color-bg, transparent))',\n\tsurfaceAlt: 'var(--likec4-surface-alt, var(--sl-color-bg-nav, rgba(128, 128, 128, 0.06)))',\n\ttext: 'var(--likec4-text, var(--sl-color-white, inherit))',\n\ttextMuted: 'var(--likec4-text-muted, var(--sl-color-gray-2, rgba(128, 128, 128, 0.95)))',\n};\n\n/**\n * The HTML a .md fence becomes: the shell, and a sized frame carrying the view\n * and model for `md-fences.tsx`. Everything is escaped — titles and model labels\n * are author text.\n */\nexport function fencePlaceholder({\n\tviewId,\n\tmodel,\n\tproject,\n\ttitle = STRINGS['likec4.fence.title'],\n\tdescription,\n\theight = 420,\n\tcollapsible = true,\n\tdefaultOpen = true,\n}: FencePlaceholder): string {\n\tconst data = [\n\t\t`data-astroc4-fence`,\n\t\t`data-view-id=\"${escapeHtml(viewId)}\"`,\n\t\tproject ? `data-project=\"${escapeHtml(project)}\"` : '',\n\t\tmodel === undefined ? '' : `data-model=\"${escapeHtml(JSON.stringify(model))}\"`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n\n\tconst headerStyle = `display: block; padding: 1em 1.25rem; border-bottom: 1px solid ${token.border}; background: ${token.surface};`;\n\tconst heading = [\n\t\t`<h3 style=\"display: inline; margin: 0; font-size: 1rem; font-weight: 600; color: ${token.text};\">${escapeHtml(title)}</h3>`,\n\t\tdescription\n\t\t\t? `<p style=\"margin: 0.25rem 0 0; font-size: 0.875rem; color: ${token.textMuted};\">${escapeHtml(description)}</p>`\n\t\t\t: '',\n\t].join('');\n\n\tconst body = [\n\t\t`<div style=\"padding: 1em 1.25rem;\">`,\n\t\t`<div class=\"likec4-frame\" style=\"position: relative; width: 100%; height: ${height}px; min-height: ${height}px;\">`,\n\t\t`<p class=\"likec4-loading\" aria-live=\"polite\" style=\"color: ${token.textMuted};\">${escapeHtml(STRINGS['likec4.fence.loading'])}</p>`,\n\t\t`</div>`,\n\t\t`</div>`,\n\t].join('');\n\n\tconst shell = collapsible\n\t\t? `<details${defaultOpen ? ' open' : ''}><summary style=\"cursor: pointer; ${headerStyle}\">${heading}</summary>${body}</details>`\n\t\t: `<header style=\"${headerStyle}\">${heading}</header>${body}`;\n\n\treturn [\n\t\t`<section class=\"not-content likec4-md-fence\" ${data} style=\"margin: 1.5rem 0; overflow: hidden; border: 1px solid ${token.border}; border-radius: 0.75rem; background: ${token.surfaceAlt};\">`,\n\t\tshell,\n\t\t`</section>`,\n\t].join('');\n}\n\nfunction placeholderOptions(\n\toptions: FenceMeta,\n): Pick<FencePlaceholder, 'title' | 'description' | 'height' | 'collapsible' | 'defaultOpen'> {\n\tconst height = Number.parseInt(options.height ?? '', 10);\n\n\treturn {\n\t\ttitle: options.title || undefined,\n\t\tdescription: options.description || undefined,\n\t\theight: Number.isFinite(height) ? height : undefined,\n\t\tcollapsible: options.collapsible !== 'false',\n\t\tdefaultOpen: options.defaultOpen !== 'false',\n\t};\n}\n\nfunction escapeHtml(value: string): string {\n\treturn value\n\t\t.replaceAll('&', '&')\n\t\t.replaceAll('\"', '"')\n\t\t.replaceAll(\"'\", ''')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>');\n}\n\n/**\n * A fence's `file=\"…\"`, relative to its page. Refused outside the site, so a page\n * cannot pull arbitrary files from the build machine.\n */\nasync function readFenceFile(\n\tfile: string,\n\tpageURL: URL | undefined,\n\troot: string | undefined,\n\twhere: string,\n): Promise<string> {\n\tif (!pageURL || !root) {\n\t\tthrow new Error(`${where} uses file=\"${file}\", which needs the page's location and the site root.`);\n\t}\n\n\tconst path = resolve(dirname(fileURLToPath(pageURL)), file);\n\tconst fromRoot = relative(resolve(root), path);\n\n\tif (fromRoot.startsWith('..') || isAbsolute(fromRoot)) {\n\t\tthrow new Error(`${where} uses file=\"${file}\", which is outside the site (${path}).`);\n\t}\n\n\ttry {\n\t\treturn (await readFile(path, 'utf8')).trim();\n\t} catch {\n\t\tthrow new Error(`${where} uses file=\"${file}\", which does not exist (${path}).`);\n\t}\n}\n\nexport default likec4Fences;\n",
|
|
7
|
+
"// Placeholders are `{name}`, not i18next's `{{name}}`: some values are only\n// known in the browser, so the template has to reach the island unformatted.\n\nexport const translations = {\n\ten: {\n\t\t'likec4.view.title': 'Architecture diagram',\n\t\t'likec4.view.description': 'Interactive LikeC4 diagram for this section.',\n\t\t'likec4.view.hint': 'Click a node in the diagram to open its details.',\n\t\t'likec4.view.badge': 'Click any node to open the modal',\n\t\t'likec4.view.loading': 'Loading architecture diagram…',\n\t\t'likec4.fence.title': 'Diagram',\n\t\t'likec4.fence.hint': 'Click any node to open its details.',\n\t\t'likec4.fence.loading': 'Loading diagram…',\n\t\t'likec4.error.title': 'We couldn’t load this diagram.',\n\t\t'likec4.error.body': 'Please retry, or refresh the page if the issue persists.',\n\t\t'likec4.error.retry': 'Retry',\n\t\t'likec4.error.viewIdRequired': 'A LikeC4 viewId is required to render the diagram.',\n\t\t'likec4.error.noProjects': 'No LikeC4 projects are available in this workspace.',\n\t\t'likec4.error.unknownProject': 'Unknown LikeC4 projectId \"{projectId}\". Available projects: {available}.',\n\t\t'likec4.error.projectRequired': 'Several LikeC4 projects exist ({available}); pass project=\"…\".',\n\t\t'likec4.error.unresolvedProject': 'Unable to resolve a LikeC4 project.',\n\t\t'likec4.error.loadFailed': 'Unable to load LikeC4 project \"{projectId}\".',\n\t},\n};\n\nexport default translations;\n",
|
|
8
|
+
"// Compiles `<LikeC4View file=\"…\">` sources here, in Vite's plugin context,\n// because the SSR module runner cannot safely load LikeC4's Node API.\n\nimport { readFile } from 'node:fs/promises';\n\nimport type { Plugin as VitePlugin } from 'vite';\n\nimport { layoutSource } from './fences.ts';\n\n/** The import query `LikeC4View.astro` adds to a `.c4` file it renders. */\nexport const FILE_LAYOUT_QUERY = '?astroc4-layout';\n\nexport function fileLayoutPlugin(): VitePlugin {\n\treturn {\n\t\tname: '@purview-dev/astroc4/file-layout',\n\t\tasync load(id) {\n\t\t\tif (!id.endsWith(FILE_LAYOUT_QUERY)) return null;\n\n\t\t\tconst file = id.slice(0, -FILE_LAYOUT_QUERY.length);\n\t\t\tthis.addWatchFile(file);\n\n\t\t\tlet layout;\n\n\t\t\ttry {\n\t\t\t\tlayout = await layoutSource(await readFile(file, 'utf8'));\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(`[astroc4] ${file} is not valid LikeC4 — ${(error as Error).message}`);\n\t\t\t}\n\n\t\t\treturn `export default ${JSON.stringify(layout)};`;\n\t\t},\n\t};\n}\n",
|
|
9
|
+
"// LikeC4 serializes its generated modules with `/` escaped as `\\u002F` (so they\n// can be inlined into HTML), so URLs are matched in both forms and written back\n// in the form they were found in.\n\nimport { readFile, copyFile, mkdir } from 'node:fs/promises';\nimport { dirname, extname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport type { Plugin as VitePlugin } from 'vite';\n\nimport { buildIconManifest, ICON_ROUTE, type IconAsset, unstage } from './icon-assets.ts';\nimport type { ResolvedProject } from './projects.ts';\n\n/** The ids LikeC4's Vite plugin resolves its per-project modules to. */\nconst LIKEC4_MODULE = /likec4:plugin\\/(?<projectId>[^/]+)\\/[^/]+$/;\n\n/** A `file:///…` URL, plain or with LikeC4's escaped slashes. */\nconst FILE_URL = /file:(?:\\\\u002F|\\/){3}[^\"'`\\s]+/g;\n\nconst CONTENT_TYPES: Record<string, string> = {\n\t'.svg': 'image/svg+xml',\n\t'.png': 'image/png',\n\t'.jpg': 'image/jpeg',\n\t'.jpeg': 'image/jpeg',\n\t'.gif': 'image/gif',\n\t'.webp': 'image/webp',\n\t'.ico': 'image/x-icon',\n};\n\nexport interface IconPluginState {\n\tprojects: ResolvedProject[];\n\tbase: string;\n\t/** The site root; files under its `public/` are left to Astro. */\n\tsiteRoot: string;\n\tstagingDir?: string;\n}\n\nexport type Astroc4IconPlugin = VitePlugin & {\n\t/** Keyed by compiled `file://` URL. */\n\tmanifest(): Map<string, IconAsset>;\n\temit(outDir: string): Promise<void>;\n};\n\nexport function astroc4IconPlugin(state: IconPluginState): Astroc4IconPlugin {\n\tconst manifest = new Map<string, IconAsset>();\n\tconst byUrl = new Map<string, IconAsset>();\n\tconst base = state.base.replace(/\\/+$/, '');\n\n\tfunction gather(project: ResolvedProject, fileUrl: string): IconAsset | undefined {\n\t\tconst known = manifest.get(fileUrl);\n\t\tif (known) return known;\n\n\t\tconst entries = [\n\t\t\t// Re-validating against what is already served is how a second file at\n\t\t\t// the same URL is caught, whichever module compiled first.\n\t\t\t...[...byUrl.values()].map((asset) => ({\n\t\t\t\tproject: state.projects.find((p) => p.name === asset.projectName)!,\n\t\t\t\tfileUrl: pathToFileURL(asset.file).href,\n\t\t\t\tsource: `LikeC4 project \"${asset.projectName}\"`,\n\t\t\t})),\n\t\t\t{ project, fileUrl, source: `LikeC4 project \"${project.name}\"` },\n\t\t];\n\n\t\tconst asset = buildIconManifest(entries, state.base, state.siteRoot).get(fileUrl);\n\t\tif (!asset) return undefined;\n\n\t\tmanifest.set(fileUrl, asset);\n\n\t\t// Astro serves and copies `public/` itself.\n\t\tif (!asset.public) byUrl.set(asset.url, asset);\n\n\t\treturn asset;\n\t}\n\n\treturn {\n\t\tname: '@purview-dev/astroc4/icons',\n\t\tenforce: 'post',\n\t\ttransform(code, id) {\n\t\t\tconst match = LIKEC4_MODULE.exec(id);\n\t\t\tif (!match) return null;\n\n\t\t\tconst project = state.projects.find((p) => p.likec4Id === match.groups!.projectId);\n\t\t\tif (!project || !code.includes('file:')) return null;\n\n\t\t\tconst rewritten = code.replace(FILE_URL, (found) => {\n\t\t\t\tconst escapedForm = found.includes('\\\\u002F');\n\t\t\t\tconst [fileUrl, query] = found.replaceAll('\\\\u002F', '/').split('?', 2) as [string, string | undefined];\n\t\t\t\tconst real = unstage(fileUrl, project, state.stagingDir);\n\n\t\t\t\t// LikeC4's icons module imports each local icon (`?raw`, `?inline`).\n\t\t\t\t// Point the import at the real file so Vite can load it; only the\n\t\t\t\t// lookup keys and model values become served URLs.\n\t\t\t\tif (query !== undefined) {\n\t\t\t\t\treturn `${fileURLToPath(real).replaceAll('\\\\', '/')}?${query}`;\n\t\t\t\t}\n\n\t\t\t\tconst asset = gather(project, real);\n\n\t\t\t\tif (!asset) return found;\n\n\t\t\t\treturn escapedForm ? asset.url.replaceAll('/', '\\\\u002F') : asset.url;\n\t\t\t});\n\n\t\t\treturn rewritten === code ? null : { code: rewritten, map: null };\n\t\t},\n\t\tconfigureServer(server) {\n\t\t\tconst prefix = `${base}${ICON_ROUTE}`;\n\n\t\t\tserver.middlewares.use(async (req, res, next) => {\n\t\t\t\tconst url = req.url?.split('?')[0];\n\n\t\t\t\tif (!url?.startsWith(prefix)) return next();\n\n\t\t\t\tconst asset = byUrl.get(url);\n\n\t\t\t\t// Only what the model asked for is ever served: no path from the\n\t\t\t\t// request reaches the file system.\n\t\t\t\tif (!asset) {\n\t\t\t\t\tres.statusCode = 404;\n\t\t\t\t\tres.end();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tres.setHeader('Content-Type', CONTENT_TYPES[extname(asset.file).toLowerCase()] ?? 'application/octet-stream');\n\t\t\t\tres.end(await readFile(asset.file));\n\t\t\t});\n\t\t},\n\t\tmanifest: () => manifest,\n\t\tasync emit(outDir) {\n\t\t\tfor (const asset of byUrl.values()) {\n\t\t\t\tconst target = join(outDir, ...decodeURIComponent(asset.url.slice(base.length)).split('/'));\n\n\t\t\t\tawait mkdir(dirname(target), { recursive: true });\n\t\t\t\tawait copyFile(asset.file, target);\n\t\t\t}\n\t\t},\n\t};\n}\n",
|
|
10
|
+
"// LikeC4 compiles local icons to absolute `file://` URLs, which 404 for\n// visitors and leak the build machine's folders, so each is mapped to a URL\n// under `/_astroc4/`:\n//\n// @ -> <project>/images icon @/azure/entra/x.svg -> /_astroc4/<project>/azure/entra/x.svg\n// @brand -> ../brand icon @brand/logo.svg -> /_astroc4/<project>/brand/logo.svg\n// (no alias) icon ../shared/a.svg -> /_astroc4/<project>/__up/shared/a.svg\n//\n// Files under the site's `public/` get their public URL, and Astro serves them.\n\nimport { realpathSync } from 'node:fs';\nimport { isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport { Astroc4ConfigError, type ResolvedProject } from './projects.ts';\n\n/** After Astro's `base`. */\nexport const ICON_ROUTE = '/_astroc4/';\n\n/** Replaces `..` in a relative icon path, so URLs never climb. */\nconst UP = '__up';\n\nexport interface IconAsset {\n\t/** With links resolved. */\n\tfile: string;\n\t/** Including Astro's `base`. */\n\turl: string;\n\tprojectName: string;\n\t/** Under the site's `public/`: Astro serves and copies it, astroc4 does neither. */\n\tpublic?: boolean;\n}\n\nexport function iconAssetFor(\n\tproject: ResolvedProject,\n\tfileUrl: string,\n\tbase: string,\n\tsiteRoot: string,\n): IconAsset | null {\n\tconst file = realFile(fileUrl);\n\tconst prefix = base.replace(/\\/+$/, '');\n\tconst publicFolder = tryRealpath(join(siteRoot, 'public'));\n\n\tif (isInside(file, publicFolder)) {\n\t\tconst path = split(relative(publicFolder, file)).map(encodeURIComponent).join('/');\n\n\t\treturn { file, url: `${prefix}/${path}`, projectName: project.name, public: true };\n\t}\n\n\tconst segments = aliasSegments(project, file) ?? relativeSegments(tryRealpath(project.folder), file);\n\tconst path = [project.name, ...segments].map(encodeURIComponent).join('/');\n\n\treturn { file, url: `${prefix}${ICON_ROUTE}${path}`, projectName: project.name };\n}\n\n/**\n * LikeC4 resolves relative icon paths and `imageAliases` lexically against the\n * staging link it opened, so `resolve(link, x)` is mapped back to\n * `resolve(project.folder, x)`.\n */\nexport function unstage(fileUrl: string, project: ResolvedProject, stagingDir: string | undefined): string {\n\tif (stagingDir === undefined) return fileUrl;\n\n\tlet path: string;\n\n\ttry {\n\t\tpath = fileURLToPath(decodeDrive(fileUrl));\n\t} catch {\n\t\treturn fileUrl;\n\t}\n\n\tconst fromLink = relative(join(stagingDir, project.name), path);\n\n\treturn pathToFileURL(resolve(project.folder, fromLink)).href;\n}\n\n/**\n * @throws Astroc4ConfigError for a missing icon, or two files that would be\n * served at the same URL.\n */\nexport function buildIconManifest(\n\tentries: Array<{ project: ResolvedProject; fileUrl: string; source: string }>,\n\tbase: string,\n\tsiteRoot: string,\n): Map<string, IconAsset> {\n\tconst manifest = new Map<string, IconAsset>();\n\tconst byUrl = new Map<string, { asset: IconAsset; source: string }>();\n\n\tfor (const { project, fileUrl, source } of entries) {\n\t\tlet asset: IconAsset | null;\n\n\t\ttry {\n\t\t\tasset = iconAssetFor(project, fileUrl, base, siteRoot);\n\t\t} catch (error) {\n\t\t\tthrow new Astroc4ConfigError(`${source}: ${(error as Error).message.replace(/^\\[astroc4\\] /, '')}`);\n\t\t}\n\n\t\tif (asset === null) continue;\n\n\t\tconst existing = byUrl.get(asset.url);\n\n\t\tif (existing && !samePath(existing.asset.file, asset.file)) {\n\t\t\tthrow new Astroc4ConfigError(\n\t\t\t\t`two icons would be served at ${asset.url}: ${existing.asset.file} (${existing.source}) and ${asset.file} (${source}). Rename one, or give its alias another name.`,\n\t\t\t);\n\t\t}\n\n\t\tbyUrl.set(asset.url, { asset, source });\n\t\tmanifest.set(fileUrl, asset);\n\t}\n\n\treturn manifest;\n}\n\n/** The longest alias folder containing `file`: `[alias name?, …path under it]`. */\nfunction aliasSegments(project: ResolvedProject, file: string): string[] | null {\n\tlet best: { folder: string; alias: string } | null = null;\n\n\tfor (const [alias, folder] of Object.entries(project.imageAliases)) {\n\t\tconst real = tryRealpath(folder);\n\n\t\tif (isInside(file, real) && (best === null || real.length > best.folder.length)) {\n\t\t\tbest = { folder: real, alias };\n\t\t}\n\t}\n\n\tif (best === null) return null;\n\n\tconst name = best.alias.replace(/^@/, '');\n\n\treturn [...(name ? [name] : []), ...split(relative(best.folder, file))];\n}\n\nfunction relativeSegments(folder: string, file: string): string[] {\n\treturn split(relative(folder, file)).map((segment) => (segment === '..' ? UP : segment));\n}\n\nfunction realFile(fileUrl: string): string {\n\tlet path: string;\n\n\ttry {\n\t\t// `file:///p%3A/…` is how LikeC4 writes a Windows drive; decoding first\n\t\t// lets `fileURLToPath` read it like `file:///P:/…`.\n\t\tpath = fileURLToPath(decodeDrive(fileUrl));\n\t} catch {\n\t\tthrow new Astroc4ConfigError(`icon ${fileUrl} is not a file URL.`);\n\t}\n\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\tthrow new Astroc4ConfigError(`icon ${path} does not exist.`);\n\t}\n}\n\nfunction decodeDrive(fileUrl: string): string {\n\treturn fileUrl.replace(/^file:\\/\\/\\/([A-Za-z])%3A/i, 'file:///$1:');\n}\n\nfunction tryRealpath(path: string): string {\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\nfunction isInside(file: string, folder: string): boolean {\n\tconst path = relative(folder, file);\n\n\treturn path.length > 0 && !path.startsWith('..') && !isAbsolute(path);\n}\n\nfunction samePath(a: string, b: string): boolean {\n\treturn sep === '\\\\' ? a.toLowerCase() === b.toLowerCase() : a === b;\n}\n\nfunction split(path: string): string[] {\n\treturn path.split(/[\\\\/]+/).filter((segment) => segment.length > 0);\n}\n",
|
|
11
|
+
"import { readdir, readFile, stat } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport type { ConfigFilenames } from 'likec4/config';\n\n/**\n * LikeC4's config file names, in the order it prefers them. `satisfies` fails\n * the type-check when LikeC4 adds or renames one.\n */\nconst CONFIG_FILES = [\n\t'.likec4rc',\n\t'.likec4.config.json',\n\t'likec4.config.json',\n\t'likec4.config.js',\n\t'likec4.config.cjs',\n\t'likec4.config.mjs',\n\t'likec4.config.ts',\n\t'likec4.config.cts',\n\t'likec4.config.mts',\n] as const satisfies typeof ConfigFilenames;\n\nconst JSON_CONFIG_FILES: readonly string[] = CONFIG_FILES.slice(0, 3);\n\nexport interface ResolvedProject {\n\t/** The name components pass as `project`. */\n\tname: string;\n\tfolder: string;\n\t/** The `name` in the project's own config — LikeC4's project id. */\n\tlikec4Id: string;\n\tsource: 'configured' | 'discovered';\n\t/** `imageAliases` from the config, each resolved to an absolute folder. */\n\timageAliases: Record<string, string>;\n}\n\nexport class Astroc4ConfigError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(`[astroc4] ${message}`);\n\t\tthis.name = 'Astroc4ConfigError';\n\t}\n}\n\n/** Every LikeC4 project under `root`, skipping `node_modules` and dot folders. */\nexport async function discoverProjects(root: string): Promise<ResolvedProject[]> {\n\tconst found: ResolvedProject[] = [];\n\n\tasync function walk(folder: string): Promise<void> {\n\t\tconst entries = await readdir(folder, { withFileTypes: true });\n\t\tconst file = configFileIn(entries.filter((entry) => entry.isFile()).map((entry) => entry.name));\n\n\t\tif (file) {\n\t\t\tconst config = await readConfig(folder, file);\n\t\t\tfound.push(toProject(config.name, folder, config, 'discovered'));\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory() || entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n\t\t\tawait walk(join(folder, entry.name));\n\t\t}\n\t}\n\n\tawait walk(resolve(root));\n\treturn found;\n}\n\n/**\n * Configured projects first, in declaration order, then the discovered ones\n * no configured entry already covers.\n */\nexport async function resolveProjects(options: {\n\troot: string;\n\tconfigured?: Record<string, string>;\n\tdiscovered: ResolvedProject[];\n}): Promise<ResolvedProject[]> {\n\tconst configured: ResolvedProject[] = [];\n\n\tfor (const [name, path] of Object.entries(options.configured ?? {})) {\n\t\tconst folder = resolve(options.root, path);\n\n\t\tif (!(await isDirectory(folder))) {\n\t\t\tthrow new Astroc4ConfigError(`project \"${name}\": folder ${folder} does not exist.`);\n\t\t}\n\n\t\tconst file = configFileIn(await readdir(folder));\n\n\t\tif (!file) {\n\t\t\tthrow new Astroc4ConfigError(\n\t\t\t\t`project \"${name}\": no LikeC4 config file (likec4.config.json, .likec4rc, likec4.config.ts, …) in ${folder}.`,\n\t\t\t);\n\t\t}\n\n\t\tconfigured.push(toProject(name, folder, await readConfig(folder, file), 'configured'));\n\t}\n\n\tconst configuredFolders = new Set(configured.map((project) => project.folder));\n\tconst projects = [\n\t\t...configured,\n\t\t...options.discovered.filter((project) => !configuredFolders.has(project.folder)),\n\t];\n\n\tconst byName = new Map<string, ResolvedProject>();\n\n\tfor (const project of projects) {\n\t\tconst existing = byName.get(project.name);\n\n\t\tif (existing) {\n\t\t\tthrow new Astroc4ConfigError(\n\t\t\t\t`two LikeC4 projects are named \"${project.name}\": ${existing.folder} and ${project.folder}.`,\n\t\t\t);\n\t\t}\n\n\t\tbyName.set(project.name, project);\n\t}\n\n\t// LikeC4 registers a project by its config's `name`, so two that share one\n\t// collide inside the compiler however they are named here.\n\tconst byId = new Map<string, ResolvedProject>();\n\n\tfor (const project of projects) {\n\t\tconst existing = byId.get(project.likec4Id);\n\n\t\tif (existing) {\n\t\t\tthrow new Astroc4ConfigError(\n\t\t\t\t`two LikeC4 projects declare \"name\": \"${project.likec4Id}\" in their configs: ${existing.folder} and ${project.folder}. Rename one.`,\n\t\t\t);\n\t\t}\n\n\t\tbyId.set(project.likec4Id, project);\n\t}\n\n\treturn projects;\n}\n\ninterface LikeC4Config {\n\tname: string;\n\timageAliases?: Record<string, string>;\n}\n\nfunction configFileIn(names: string[]): string | undefined {\n\treturn CONFIG_FILES.find((file) => names.includes(file));\n}\n\n/**\n * A project's config, read the way LikeC4 reads it: JSON files as JSON5, the\n * rest bundled and evaluated, and `name` defaulting to the folder's name.\n */\nasync function readConfig(folder: string, file: string): Promise<LikeC4Config> {\n\tconst path = join(folder, file);\n\tlet config: unknown;\n\n\ttry {\n\t\tconfig = JSON_CONFIG_FILES.includes(file) ? await readJsonConfig(path) : await evaluateConfig(path, folder);\n\t} catch (error) {\n\t\tthrow new Astroc4ConfigError(`${path} could not be read: ${(error as Error).message}`);\n\t}\n\n\tif (typeof config !== 'object' || config === null || Array.isArray(config)) {\n\t\tthrow new Astroc4ConfigError(`${path} must define a config object.`);\n\t}\n\n\tconst { name = basename(folder), imageAliases } = config as { name?: unknown; imageAliases?: unknown };\n\n\tif (typeof name !== 'string' || name.trim().length === 0) {\n\t\tthrow new Astroc4ConfigError(`${path} has an empty \"name\".`);\n\t}\n\n\treturn { name, imageAliases: isRecord(imageAliases) ? imageAliases : undefined };\n}\n\nasync function readJsonConfig(path: string): Promise<unknown> {\n\tconst { default: JSON5 } = await import('json5');\n\tconst text = (await readFile(path, 'utf8')).trim();\n\n\treturn JSON5.parse(text || '{}');\n}\n\n/**\n * `likec4/config`'s helpers are identity functions, so they are replaced with\n * one, as LikeC4 does: a project outside the site need not be able to resolve\n * the package.\n */\nasync function evaluateConfig(path: string, folder: string): Promise<unknown> {\n\tconst { bundleRequire } = await import('bundle-require');\n\n\tconst { mod } = await bundleRequire({\n\t\tfilepath: path,\n\t\tcwd: folder,\n\t\tesbuildOptions: {\n\t\t\tresolveExtensions: ['.ts', '.mts', '.cts', '.mjs', '.js', '.cjs'],\n\t\t\tplugins: [\n\t\t\t\t{\n\t\t\t\t\tname: 'astroc4-likec4-config',\n\t\t\t\t\tsetup(build) {\n\t\t\t\t\t\tbuild.onResolve({ filter: /^@?likec4\\/config$/ }, (args) => ({\n\t\t\t\t\t\t\tpath: args.path,\n\t\t\t\t\t\t\tnamespace: 'astroc4-likec4-config',\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tbuild.onLoad({ filter: /.*/, namespace: 'astroc4-likec4-config' }, () => ({\n\t\t\t\t\t\t\tcontents: [\n\t\t\t\t\t\t\t\t'const identity = (value) => value;',\n\t\t\t\t\t\t\t\t'export { identity as defineConfig, identity as defineGenerators, identity as defineStyle, identity as defineTheme, identity as defineThemeColor };',\n\t\t\t\t\t\t\t].join('\\n'),\n\t\t\t\t\t\t\tloader: 'js',\n\t\t\t\t\t\t}));\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t});\n\n\treturn (mod as { default?: unknown }).default ?? mod;\n}\n\nfunction toProject(\n\tname: string,\n\tfolder: string,\n\tconfig: LikeC4Config,\n\tsource: ResolvedProject['source'],\n): ResolvedProject {\n\tconst imageAliases = Object.fromEntries(\n\t\tObject.entries(config.imageAliases ?? {}).map(([alias, path]) => [alias, resolve(folder, path)]),\n\t);\n\n\treturn { name, folder: resolve(folder), likec4Id: config.name, source, imageAliases };\n}\n\nfunction isRecord(value: unknown): value is Record<string, string> {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t!Array.isArray(value) &&\n\t\tObject.values(value).every((entry) => typeof entry === 'string')\n\t);\n}\n\nasync function isDirectory(path: string): Promise<boolean> {\n\treturn (await stat(path).catch(() => null))?.isDirectory() ?? false;\n}\n",
|
|
12
|
+
"// `LikeC4VitePlugin` takes a single `workspace`, so every project is linked\n// (not copied, so LikeC4 sees edits) under one staging folder. It lives in\n// `.astro/`, never `node_modules/`: LikeC4 excludes `**/node_modules/**`.\n\nimport { lstat, mkdir, readdir, readlink, realpath, rm, symlink } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\n\nimport type { ResolvedProject } from './projects.ts';\n\nexport const PROJECTS_MODULE_ID = 'virtual:astroc4/projects';\n\n/** @returns The staging folder to hand `LikeC4VitePlugin` as its `workspace`. */\nexport async function prepareWorkspace(projects: ResolvedProject[], cacheDir: string): Promise<string> {\n\tconst staging = join(cacheDir, 'workspace');\n\tawait mkdir(staging, { recursive: true });\n\n\tconst wanted = new Map(projects.map((project) => [project.name, resolve(project.folder)]));\n\n\tfor (const entry of await readdir(staging)) {\n\t\tconst target = wanted.get(entry);\n\n\t\tif (target === undefined || !(await pointsAt(join(staging, entry), target))) {\n\t\t\t// `rm` on a link removes the link, never what it points at.\n\t\t\tawait rm(join(staging, entry), { recursive: false, force: true });\n\t\t}\n\t}\n\n\tfor (const [name, folder] of wanted) {\n\t\tconst link = join(staging, name);\n\n\t\tif (await exists(link)) continue;\n\n\t\t// A junction needs no elevated rights on Windows; elsewhere the type\n\t\t// argument is ignored and a plain directory symlink is made.\n\t\tawait symlink(folder, link, 'junction');\n\t}\n\n\treturn staging;\n}\n\nexport function projectsModule(projects: ResolvedProject[]): string {\n\tconst names = projects.map((project) => project.name);\n\tconst ids = Object.fromEntries(projects.map((project) => [project.name, project.likec4Id]));\n\n\treturn [\n\t\t`export const projectNames = ${JSON.stringify(names)};`,\n\t\t`export const likec4IdFor = ${JSON.stringify(ids)};`,\n\t].join('\\n');\n}\n\nasync function pointsAt(link: string, target: string): Promise<boolean> {\n\ttry {\n\t\tconst stats = await lstat(link);\n\n\t\tif (!stats.isSymbolicLink()) return false;\n\n\t\tawait readlink(link);\n\t\treturn (await realpath(link)) === (await realpath(target));\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function exists(path: string): Promise<boolean> {\n\treturn (await lstat(path).catch(() => null)) !== null;\n}\n"
|
|
13
|
+
],
|
|
14
|
+
"mappings": ";AAAA;AACA,oBAAS,kBAAS,kBAAM;AACxB,0BAAS;AAGT;;;ACGA;AACA;AACA;AACA;AACA;;;ACTO,IAAM,eAAe;AAAA,EAC3B,IAAI;AAAA,IACH,qBAAqB;AAAA,IACrB,2BAA2B;AAAA,IAC3B,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,IACvB,sBAAsB;AAAA,IACtB,qBAAqB;AAAA,IACrB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,qBAAqB;AAAA,IACrB,sBAAsB;AAAA,IACtB,+BAA+B;AAAA,IAC/B,2BAA2B;AAAA,IAC3B,+BAA+B;AAAA,IAC/B,gCAAgC;AAAA,IAChC,kCAAkC;AAAA,IAClC,2BAA2B;AAAA,EAC5B;AACD;;;ADLA,IAAM,WAAU,cAAc,YAAY,GAAG;AAK7C,IAAI;AAIJ,SAAS,UAAU,GAAuB;AAAA,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AAO,KACN,0FACC,6BACF;AAAA,IACA;AAAA,EACD;AAAA,EAEA,MAAM,kBAAkB,SAAS,WAAW,CAAC;AAAA,EAE7C,aAAa;AAAA,IACZ,UAAU;AAAA,MACT,WAAW,QAAQ;AAAA,WACf;AAAA,QACH,cAAc,CAAC,GAAI,gBAAgB,gBAAgB,CAAC,GAAI,OAAO,CAAC;AAAA,MACjE,CAAC;AAAA,IACF;AAAA,EACD,CAAC;AAAA;AAGF,IAAe;",
|
|
15
|
+
"debugId": "6B1EB5C52F4EEAE864756E2164756E21",
|
|
16
|
+
"names": []
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ResolvedProject {
|
|
2
|
+
/** The name components pass as `project`. */
|
|
3
|
+
name: string;
|
|
4
|
+
folder: string;
|
|
5
|
+
/** The `name` in the project's own config — LikeC4's project id. */
|
|
6
|
+
likec4Id: string;
|
|
7
|
+
source: 'configured' | 'discovered';
|
|
8
|
+
/** `imageAliases` from the config, each resolved to an absolute folder. */
|
|
9
|
+
imageAliases: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export declare class Astroc4ConfigError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
/** Every LikeC4 project under `root`, skipping `node_modules` and dot folders. */
|
|
15
|
+
export declare function discoverProjects(root: string): Promise<ResolvedProject[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Configured projects first, in declaration order, then the discovered ones
|
|
18
|
+
* no configured entry already covers.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveProjects(options: {
|
|
21
|
+
root: string;
|
|
22
|
+
configured?: Record<string, string>;
|
|
23
|
+
discovered: ResolvedProject[];
|
|
24
|
+
}): Promise<ResolvedProject[]>;
|
package/dist/translations.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const translations: {
|
|
|
14
14
|
'likec4.error.viewIdRequired': string;
|
|
15
15
|
'likec4.error.noProjects': string;
|
|
16
16
|
'likec4.error.unknownProject': string;
|
|
17
|
+
'likec4.error.projectRequired': string;
|
|
17
18
|
'likec4.error.unresolvedProject': string;
|
|
18
19
|
'likec4.error.loadFailed': string;
|
|
19
20
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ResolvedProject } from './projects.js';
|
|
2
|
+
export declare const PROJECTS_MODULE_ID = "virtual:astroc4/projects";
|
|
3
|
+
/** @returns The staging folder to hand `LikeC4VitePlugin` as its `workspace`. */
|
|
4
|
+
export declare function prepareWorkspace(projects: ResolvedProject[], cacheDir: string): Promise<string>;
|
|
5
|
+
export declare function projectsModule(projects: ResolvedProject[]): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purview-dev/astroc4",
|
|
3
|
-
"version": "1.0.0-prerelease.
|
|
3
|
+
"version": "1.0.0-prerelease.6",
|
|
4
4
|
"description": "Interactive LikeC4 architecture diagrams for Astro and Starlight: <LikeC4View>, ```likec4 fences, and LikeC4 syntax highlighting derived from the live Langium grammar.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
"architecture-as-code",
|
|
22
22
|
"architecture-diagrams",
|
|
23
23
|
"diagrams",
|
|
24
|
+
"ui",
|
|
24
25
|
"astro",
|
|
25
26
|
"astro-integration",
|
|
27
|
+
"withastro",
|
|
26
28
|
"starlight",
|
|
27
29
|
"starlight-plugin",
|
|
28
30
|
"expressive-code",
|
|
@@ -36,13 +38,18 @@
|
|
|
36
38
|
"types": "./dist/index.d.ts",
|
|
37
39
|
"import": "./dist/index.js"
|
|
38
40
|
},
|
|
41
|
+
"./integration": {
|
|
42
|
+
"types": "./dist/integration.d.ts",
|
|
43
|
+
"import": "./dist/integration.js"
|
|
44
|
+
},
|
|
39
45
|
"./expressive-code": {
|
|
40
46
|
"types": "./dist/expressive-code.d.ts",
|
|
41
47
|
"import": "./dist/expressive-code.js"
|
|
42
48
|
},
|
|
43
49
|
"./grammar/likec4.tmLanguage.json": "./dist/likec4.tmLanguage.json",
|
|
44
50
|
"./components/LikeC4View.astro": "./src/components/LikeC4View.astro",
|
|
45
|
-
"./components/LikeC4Fence.astro": "./src/components/LikeC4Fence.astro"
|
|
51
|
+
"./components/LikeC4Fence.astro": "./src/components/LikeC4Fence.astro",
|
|
52
|
+
"./components/md-fences": "./src/components/md-fences.tsx"
|
|
46
53
|
},
|
|
47
54
|
"files": [
|
|
48
55
|
"dist",
|
|
@@ -56,7 +63,9 @@
|
|
|
56
63
|
"dev": "bun run build:lib && cd playground && astro dev",
|
|
57
64
|
"build": "bun run build:lib && cd playground && astro build",
|
|
58
65
|
"preview": "cd playground && astro preview",
|
|
59
|
-
"
|
|
66
|
+
"dev:astro": "bun run build:lib && cd examples/astro && astro dev",
|
|
67
|
+
"build:astro": "bun run build:lib && cd examples/astro && astro build",
|
|
68
|
+
"check": "bun run build:lib && cd playground && astro check && cd ../examples/astro && astro check && cd ../.. && bunx tsc -p tsconfig.scripts.json --noEmit",
|
|
60
69
|
"test": "vitest run",
|
|
61
70
|
"test:watch": "vitest",
|
|
62
71
|
"test:network": "ASTROC4_NETWORK=1 vitest run src/grammar/__tests__/network.test.ts",
|
|
@@ -77,15 +86,22 @@
|
|
|
77
86
|
"react-dom": ">=19.0.0",
|
|
78
87
|
"shiki": ">=1.0.0"
|
|
79
88
|
},
|
|
89
|
+
"peerDependenciesMeta": {
|
|
90
|
+
"@astrojs/starlight": {
|
|
91
|
+
"optional": true
|
|
92
|
+
}
|
|
93
|
+
},
|
|
80
94
|
"devDependencies": {
|
|
81
95
|
"@astrojs/check": "^0.9.12",
|
|
82
96
|
"@astrojs/markdown-satteri": "^0.4.6",
|
|
97
|
+
"@astrojs/mdx": "^8.1.2",
|
|
83
98
|
"@astrojs/react": "^7.1.2",
|
|
84
99
|
"@astrojs/starlight": "^0.42.8",
|
|
85
100
|
"@likec4/core": "^1.59.4",
|
|
86
101
|
"@types/react": "^19.3.0",
|
|
87
102
|
"@types/react-dom": "^19.3.0",
|
|
88
103
|
"astro": "^7.4.4",
|
|
104
|
+
"astro-expressive-code": "^0.44.3",
|
|
89
105
|
"likec4": "^1.59.4",
|
|
90
106
|
"playwright": "^1.63.0",
|
|
91
107
|
"react": "^19.3.0",
|
|
@@ -102,6 +118,10 @@
|
|
|
102
118
|
"packageManager": "bun@1.4.4",
|
|
103
119
|
"publishConfig": {
|
|
104
120
|
"access": "public"
|
|
121
|
+
},
|
|
122
|
+
"dependencies": {
|
|
123
|
+
"bundle-require": "^5.1.0",
|
|
124
|
+
"esbuild": "^0.28.2",
|
|
125
|
+
"json5": "^2.2.3"
|
|
105
126
|
}
|
|
106
127
|
}
|
|
107
|
-
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
// DiagramFrame.astro
|
|
3
|
-
// path: src/components/DiagramFrame.astro
|
|
4
|
-
// The sized container a LikeC4 island renders into. Shared by <LikeC4View>
|
|
5
|
-
// (project model) and <LikeC4Fence> (inline DSL) so both size identically.
|
|
6
|
-
|
|
7
2
|
interface Props {
|
|
8
|
-
/** Rendered height in pixels. */
|
|
9
3
|
height?: number;
|
|
10
4
|
}
|
|
11
5
|
|
|
@@ -17,15 +11,19 @@ const { height = 480 } = Astro.props;
|
|
|
17
11
|
</div>
|
|
18
12
|
|
|
19
13
|
<style>
|
|
20
|
-
/* LikeC4's renderer measures its container, so it needs a concrete height
|
|
21
|
-
|
|
22
|
-
canvas. The per-instance value arrives as an inline custom property. */
|
|
14
|
+
/* LikeC4's renderer measures its container, so it needs a concrete height.
|
|
15
|
+
See DiagramShell for the token contract. */
|
|
23
16
|
.likec4-frame {
|
|
17
|
+
--_likec4-surface: var(--likec4-surface, var(--sl-color-bg, transparent));
|
|
18
|
+
--_likec4-danger: var(--likec4-danger, var(--sl-color-red, #c0392b));
|
|
19
|
+
--_likec4-danger-soft: var(--likec4-danger-soft, var(--sl-color-red-low, rgba(192, 57, 43, 0.12)));
|
|
20
|
+
--_likec4-danger-text: var(--likec4-danger-text, var(--sl-color-red-high, #8b1d1d));
|
|
21
|
+
|
|
24
22
|
min-height: var(--likec4-height);
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
/* :global() because the
|
|
28
|
-
|
|
25
|
+
/* :global() because LikeC4 and the error boundary create this markup at
|
|
26
|
+
runtime, without a scope hash. */
|
|
29
27
|
.likec4-frame :global(.likec4-view),
|
|
30
28
|
.likec4-frame :global([data-likec4-view]) {
|
|
31
29
|
width: 100%;
|
|
@@ -35,13 +33,13 @@ const { height = 480 } = Astro.props;
|
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
.likec4-frame :global(.likec4-error) {
|
|
38
|
-
border: 1px solid var(--
|
|
36
|
+
border: 1px solid var(--_likec4-danger);
|
|
39
37
|
border-radius: 0.5rem;
|
|
40
|
-
background: var(--
|
|
38
|
+
background: var(--_likec4-danger-soft);
|
|
41
39
|
padding: 1rem;
|
|
42
40
|
font-size: 0.875rem;
|
|
43
41
|
line-height: 1.25rem;
|
|
44
|
-
color: var(--
|
|
42
|
+
color: var(--_likec4-danger-text);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
.likec4-frame :global(.likec4-error p) {
|
|
@@ -55,7 +53,7 @@ const { height = 480 } = Astro.props;
|
|
|
55
53
|
|
|
56
54
|
.likec4-frame :global(.likec4-error__retry) {
|
|
57
55
|
margin-top: 0.75rem;
|
|
58
|
-
border: 1px solid var(--
|
|
56
|
+
border: 1px solid var(--_likec4-danger);
|
|
59
57
|
border-radius: 0.375rem;
|
|
60
58
|
background: transparent;
|
|
61
59
|
padding: 0.375rem 0.75rem;
|
|
@@ -67,6 +65,6 @@ const { height = 480 } = Astro.props;
|
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
.likec4-frame :global(.likec4-error__retry:hover) {
|
|
70
|
-
background: var(--
|
|
68
|
+
background: var(--_likec4-surface);
|
|
71
69
|
}
|
|
72
70
|
</style>
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
// DiagramShell.astro
|
|
3
|
-
// path: src/components/DiagramShell.astro
|
|
4
|
-
// Framed, optionally collapsible container around a diagram so it reads as a
|
|
5
|
-
// deliberate block inside the prose rather than a loose widget.
|
|
6
|
-
//
|
|
7
|
-
// Plain CSS over Starlight's custom properties rather than utility classes: a
|
|
8
|
-
// host site's Tailwind does not scan this package, so any class it did not
|
|
9
|
-
// already generate would silently be unstyled.
|
|
10
|
-
|
|
11
2
|
interface Props {
|
|
12
3
|
title: string;
|
|
13
4
|
description?: string;
|
|
14
5
|
hint?: string;
|
|
15
|
-
/** Whether the shell can be collapsed/expanded. */
|
|
16
6
|
collapsible?: boolean;
|
|
17
|
-
/** Initial open state when collapsible is enabled. */
|
|
18
7
|
defaultOpen?: boolean;
|
|
19
8
|
}
|
|
20
9
|
|
|
@@ -54,23 +43,33 @@ const { title, description, hint, collapsible = true, defaultOpen = true } = Ast
|
|
|
54
43
|
</section>
|
|
55
44
|
|
|
56
45
|
<style>
|
|
46
|
+
/* Token contract: a site sets the public `--likec4-*` tokens on any ancestor;
|
|
47
|
+
components never declare them, only read them into private `--_likec4-*`
|
|
48
|
+
names, so an override inherits instead of fighting scoped specificity.
|
|
49
|
+
Unset, they fall back to Starlight's palette, then to scheme-neutral
|
|
50
|
+
greys and `inherit` (an undefined `var()` with no fallback is invalid). */
|
|
57
51
|
.likec4-shell {
|
|
52
|
+
--_likec4-border: var(--likec4-border, var(--sl-color-gray-5, rgba(128, 128, 128, 0.35)));
|
|
53
|
+
--_likec4-surface: var(--likec4-surface, var(--sl-color-bg, transparent));
|
|
54
|
+
--_likec4-surface-alt: var(--likec4-surface-alt, var(--sl-color-bg-nav, rgba(128, 128, 128, 0.06)));
|
|
55
|
+
--_likec4-text: var(--likec4-text, var(--sl-color-white, inherit));
|
|
56
|
+
--_likec4-text-muted: var(--likec4-text-muted, var(--sl-color-gray-2, rgba(128, 128, 128, 0.95)));
|
|
57
|
+
--_likec4-accent: var(--likec4-accent, var(--sl-color-text-accent, inherit));
|
|
58
|
+
|
|
58
59
|
margin-block: 1em;
|
|
59
60
|
overflow: hidden;
|
|
60
|
-
border: 1px solid var(--
|
|
61
|
+
border: 1px solid var(--_likec4-border);
|
|
61
62
|
border-radius: 0.75rem;
|
|
62
|
-
background: var(--
|
|
63
|
+
background: var(--_likec4-surface-alt);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
.likec4-shell__header {
|
|
66
|
-
border-bottom: 1px solid var(--
|
|
67
|
-
background: var(--
|
|
67
|
+
border-bottom: 1px solid var(--_likec4-border);
|
|
68
|
+
background: var(--_likec4-surface);
|
|
68
69
|
padding: 1em 1.25rem;
|
|
69
70
|
line-height: 1.4;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
/* Use the native details/summary marker so this matches Starlight's own
|
|
73
|
-
collapsible blocks instead of inventing a second disclosure style. */
|
|
74
73
|
summary.likec4-shell__header {
|
|
75
74
|
cursor: pointer;
|
|
76
75
|
}
|
|
@@ -86,7 +85,7 @@ const { title, description, hint, collapsible = true, defaultOpen = true } = Ast
|
|
|
86
85
|
font-size: 1rem;
|
|
87
86
|
line-height: 1.5rem;
|
|
88
87
|
font-weight: 600;
|
|
89
|
-
color: var(--
|
|
88
|
+
color: var(--_likec4-text);
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
.likec4-shell__title--block {
|
|
@@ -97,7 +96,7 @@ const { title, description, hint, collapsible = true, defaultOpen = true } = Ast
|
|
|
97
96
|
margin: 0.25rem 0 0;
|
|
98
97
|
font-size: 0.875rem;
|
|
99
98
|
line-height: 1.25rem;
|
|
100
|
-
color: var(--
|
|
99
|
+
color: var(--_likec4-text-muted);
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
.likec4-shell__hint {
|
|
@@ -105,7 +104,7 @@ const { title, description, hint, collapsible = true, defaultOpen = true } = Ast
|
|
|
105
104
|
font-size: 0.75rem;
|
|
106
105
|
line-height: 1rem;
|
|
107
106
|
font-weight: 500;
|
|
108
|
-
color: var(--
|
|
107
|
+
color: var(--_likec4-accent);
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
.likec4-shell__body {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// path: src/components/ErrorBoundary.tsx
|
|
3
|
-
// Keeps a crashing LikeC4 island (the renderer depends on browser-only
|
|
4
|
-
// measurement APIs) from blanking the surrounding docs page. Styled by the
|
|
5
|
-
// `.likec4-error` rules in DiagramFrame.astro, which is always its ancestor.
|
|
1
|
+
// Styled by the `.likec4-error` rules in DiagramFrame.astro, always an ancestor.
|
|
6
2
|
|
|
7
3
|
import { Component, type ReactNode } from 'react';
|
|
8
4
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
//
|
|
3
|
-
// path: src/components/LikeC4Fence.astro
|
|
4
|
-
// Target of the ```likec4 fence transform. Authors never write this directly —
|
|
5
|
-
// src/fences.mjs rewrites the fence into it, passing the model it compiled at
|
|
6
|
-
// build time as a JSON string.
|
|
2
|
+
// Target of the ```likec4 fence transform in .mdx (src/fences.ts).
|
|
7
3
|
|
|
8
4
|
import DiagramFrame from './DiagramFrame.astro';
|
|
9
5
|
import DiagramShell from './DiagramShell.astro';
|
|
@@ -23,7 +19,8 @@ interface Props {
|
|
|
23
19
|
defaultOpen?: string;
|
|
24
20
|
}
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
// See `LikeC4View.astro`: `t` is Starlight's, and absent on a plain Astro page.
|
|
23
|
+
const t = getTranslator((Astro.locals as { t?: unknown }).t);
|
|
27
24
|
const labels = getIslandLabels(t, 'likec4.fence.loading');
|
|
28
25
|
|
|
29
26
|
const {
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Renders a LikeC4 model that was compiled at build time from a ```likec4
|
|
4
|
-
// fence, rather than loaded from the workspace project.
|
|
5
|
-
//
|
|
6
|
-
// The DSL is parsed and laid out by the fence plugin during the build (layout
|
|
7
|
-
// needs a WASM graph engine, so it cannot happen in the browser); this island
|
|
8
|
-
// only rehydrates the resulting plain-JSON model.
|
|
1
|
+
// Layout needs a WASM graph engine, so fences are laid out at build time and
|
|
2
|
+
// this island only rehydrates the plain-JSON model.
|
|
9
3
|
|
|
10
4
|
import { getProjectIcons } from 'likec4:icons';
|
|
11
5
|
import { projects } from 'likec4:projects';
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// at hydration with "createRequire is not a function". This is the same module
|
|
15
|
-
// `likec4/react` itself imports.
|
|
6
|
+
// Not `likec4/model`: it pulls `createRequire` into the browser bundle, which
|
|
7
|
+
// fails at hydration with "createRequire is not a function".
|
|
16
8
|
import { LikeC4Model } from '@likec4/core/model';
|
|
17
9
|
import type { aux, UnknownLayouted } from 'likec4/model';
|
|
18
10
|
import { LikeC4View as GenericLikeC4View, LikeC4ModelProvider } from 'likec4/react';
|
|
@@ -26,7 +18,6 @@ type Props = {
|
|
|
26
18
|
/** Layouted model dump produced at build time. */
|
|
27
19
|
model: unknown;
|
|
28
20
|
viewId: string;
|
|
29
|
-
/** Translated on the server; defaults to English. */
|
|
30
21
|
labels?: IslandLabels;
|
|
31
22
|
};
|
|
32
23
|
|
|
@@ -34,9 +25,8 @@ function LikeC4InlineViewContent({ model, viewId }: Props) {
|
|
|
34
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- dump is plain JSON
|
|
35
26
|
const likec4model = useMemo(() => LikeC4Model.create(model as any), [model]);
|
|
36
27
|
|
|
37
|
-
// Inline models
|
|
38
|
-
//
|
|
39
|
-
// renderer from the first project rather than shipping a second copy.
|
|
28
|
+
// Inline models have no icon bundle of their own; pack ids are global, so
|
|
29
|
+
// borrow the first project's renderer rather than shipping a second copy.
|
|
40
30
|
const iconRenderer = useMemo(() => {
|
|
41
31
|
const first = projects[0];
|
|
42
32
|
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// LikeC4ProjectView.tsx
|
|
2
|
-
// path: src/components/LikeC4ProjectView.tsx
|
|
3
|
-
// React island that loads a LikeC4 project model (via the `likec4:*` virtual
|
|
4
|
-
// modules provided by LikeC4VitePlugin) and renders one view from it.
|
|
5
1
|
// Browser-only: mount it with `client:only="react"`.
|
|
6
2
|
|
|
7
3
|
import { type ElementIconRenderer, getProjectIcons } from 'likec4:icons';
|
|
@@ -24,7 +20,6 @@ import {
|
|
|
24
20
|
type Props = {
|
|
25
21
|
viewId: string;
|
|
26
22
|
projectId?: string;
|
|
27
|
-
/** Translated on the server; defaults to English. */
|
|
28
23
|
labels?: IslandLabels;
|
|
29
24
|
};
|
|
30
25
|
|