@purview-dev/astroc4 1.0.0-prerelease.2 → 1.0.0-prerelease.4
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 +2 -2
- package/dist/expressive-code.d.ts +14 -0
- package/dist/expressive-code.js +1171 -0
- package/dist/expressive-code.js.map +13 -0
- package/dist/fences.d.ts +32 -0
- package/dist/grammar/langium.d.ts +42 -0
- package/dist/grammar/source.d.ts +90 -0
- package/dist/grammar/textmate.d.ts +51 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +1125 -0
- package/dist/index.js.map +15 -0
- package/{src/grammar → dist}/likec4.tmLanguage.json +3 -3
- package/dist/translations.d.ts +21 -0
- package/package.json +23 -14
- package/src/components/labels.ts +5 -1
- package/src/expressive-code.d.mts +0 -28
- package/src/expressive-code.mjs +0 -46
- package/src/fences.mjs +0 -288
- package/src/grammar/langium.mjs +0 -559
- package/src/grammar/source.mjs +0 -410
- package/src/grammar/textmate.mjs +0 -439
- package/src/index.d.mts +0 -64
- package/src/index.mjs +0 -228
- package/src/types.d.ts +0 -12
- /package/{src/grammar → dist}/like-c4.langium +0 -0
- /package/src/{translations.mjs → translations.ts} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/fences.ts", "../src/grammar/source.ts", "../src/grammar/langium.ts", "../src/grammar/textmate.ts", "../src/translations.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// index.ts\n// path: src/index.ts\n// Starlight plugin that renders LikeC4 architecture diagrams:\n//\n// import astroc4 from '@purview-dev/astroc4';\n// starlight({ plugins: [astroc4()] })\n//\n// It wires up everything a site previously had to configure by hand:\n// - LikeC4VitePlugin, which compiles every .c4 project under the site root\n// into the `likec4:model` / `likec4:icons` / `likec4:projects` modules;\n// - the ```likec4 fence transform (./fences.mjs), appended to the site's\n// Sätteri processor;\n// - the build-time preload that avoids a Windows-only crash (see\n// `preloadLikeC4` in ./fences.mjs);\n// - LikeC4 syntax highlighting, resolved from the live Langium grammar and\n// injected into the site's Expressive Code options (see below);\n// - the component UI strings, through Starlight's i18n system.\n//\n// The highlighting injection is why this is a Starlight plugin and not just an\n// integration: Starlight runs plugin `config:setup` hooks *before* it builds\n// its Expressive Code integration, and a plugin can `updateConfig` the\n// `expressiveCode` option — so the grammar reaches Shiki without the site\n// having to create an `ec.config.mjs`. Expressive Code concatenates\n// `shiki.langs` when it merges integration options with an `ec.config.mjs`, so\n// a site that has one keeps its own languages too.\n\nimport { fileURLToPath } from 'node:url';\n\nimport type { StarlightPlugin, StarlightUserConfig } from '@astrojs/starlight/types';\nimport type { AstroConfig, AstroIntegration, AstroIntegrationLogger } from 'astro';\nimport { LikeC4VitePlugin } from 'likec4/vite-plugin';\n\nimport { likec4Fences, preloadLikeC4 } from './fences.js';\nimport { resolveLikeC4Grammar } from './grammar/source.js';\nimport { LANGUAGE_ALIASES, LANGUAGE_NAME } from './grammar/textmate.js';\nimport { translations } from './translations.js';\n\n/**\n * The published package name. Scoped because npm refuses the unscoped\n * `astroc4` — \"too similar to existing package astro\" — and because the scope\n * makes the specifiers this plugin writes into a site's pages unambiguous.\n */\nconst PACKAGE_NAME = '@purview-dev/astroc4';\n\n/**\n * LikeC4 syntax highlighting, derived from the Langium grammar in\n * `likec4/likec4` and registered with the site's Expressive Code.\n */\nexport interface LikeC4HighlightingOptions {\n\t/**\n\t * Branch, tag or commit SHA to read `like-c4.langium` from.\n\t * Defaults to `main`; pin a tag (`v1.59.4`) or a SHA for reproducible CI.\n\t * Also read from `ASTROC4_REF`.\n\t */\n\tref?: string;\n\t/** Repository to read from. Defaults to `likec4/likec4`. */\n\trepo?: string;\n\t/** Use the bundled snapshot and never touch the network. Also `ASTROC4_OFFLINE=1`. */\n\toffline?: boolean;\n\t/**\n\t * What to do when the grammar cannot be fetched. Defaults to `fail`, so\n\t * `astro build` and `astro check` fail like any other build error.\n\t * A `ref` that does not exist always fails.\n\t */\n\tonError?: 'fail' | 'warn' | 'silent';\n\t/** Seconds a cached fetch stays fresh. Defaults to an hour. */\n\tcacheTtl?: number;\n\t/** Ignore the cache and refetch. */\n\trefresh?: boolean;\n\t/** Where to cache. Defaults to `node_modules/.cache/astroc4`. */\n\tcacheDir?: string;\n\t/** Raw host to read from, for mirrors. Defaults to raw.githubusercontent.com. */\n\tbaseUrl?: string;\n\t/** Request timeout in milliseconds. Defaults to 15000. */\n\ttimeout?: number;\n}\n\nexport interface StarlightLikeC4Options {\n\t/**\n\t * Passed through to `LikeC4VitePlugin` — e.g. `{ workspace: 'diagrams' }` to\n\t * look for .c4 files somewhere other than the site root.\n\t */\n\tvitePlugin?: Parameters<typeof LikeC4VitePlugin>[0];\n\t/** Render ```likec4 fences in .mdx pages as diagrams. Defaults to `true`. */\n\tfences?: boolean;\n\t/**\n\t * Highlight ```c4 / ```likec4 source. Defaults to `true`; `false` leaves\n\t * Expressive Code entirely to the site.\n\t */\n\thighlighting?: boolean | LikeC4HighlightingOptions;\n}\n\nexport default function starlightLikeC4(options: StarlightLikeC4Options = {}): StarlightPlugin {\n\treturn {\n\t\tname: PACKAGE_NAME,\n\t\thooks: {\n\t\t\t'i18n:setup'({ injectTranslations }) {\n\t\t\t\tinjectTranslations(translations);\n\t\t\t},\n\t\t\tasync 'config:setup'({ config, astroConfig, updateConfig, addIntegration, logger }) {\n\t\t\t\taddIntegration(likec4Integration(options));\n\n\t\t\t\tif (options.highlighting === false) return;\n\n\t\t\t\tawait injectHighlighting({\n\t\t\t\t\t// `config` is the Starlight config, `astroConfig` the Astro one:\n\t\t\t\t\t// the site root and the cache directory live on the latter.\n\t\t\t\t\troot: fileURLToPath(astroConfig.root),\n\t\t\t\t\texpressiveCode: config.expressiveCode,\n\t\t\t\t\tupdateConfig,\n\t\t\t\t\tlogger,\n\t\t\t\t\t// `true` means \"on with defaults\"; only an object carries options.\n\t\t\t\t\toptions: typeof options.highlighting === 'object' ? options.highlighting : {},\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** What Starlight's `config:setup` hook offers, narrowed to what is used here. */\ntype StarlightConfigUpdate = Partial<Omit<StarlightUserConfig, 'routeMiddleware'>>;\n\n/** Everything `injectHighlighting` needs, assembled by the hook below. */\ninterface HighlightingContext {\n\troot: string;\n\texpressiveCode: unknown;\n\tupdateConfig: (config: StarlightConfigUpdate) => void;\n\tlogger: AstroIntegrationLogger;\n\toptions: LikeC4HighlightingOptions;\n}\n\n/**\n * Register the LikeC4 grammar with whatever Expressive Code the site ends up\n * with.\n *\n * This is deliberately not wrapped in a try/catch: a ref that does not exist,\n * or a grammar that cannot be read, fails `astro dev`, `astro build`,\n * `astro check` and `astro sync` exactly like any other build error. Sites that\n * cannot reach github.com on every build opt out with `offline: true` or\n * `onError: 'warn'`.\n */\nasync function injectHighlighting({\n\troot,\n\texpressiveCode,\n\tupdateConfig,\n\tlogger,\n\toptions,\n}: HighlightingContext) {\n\tif (expressiveCode === false) {\n\t\tlogger.warn(\n\t\t\t'LikeC4 syntax highlighting is skipped: `expressiveCode: false` disables the code blocks it ' +\n\t\t\t\t'would highlight. Diagrams are unaffected.',\n\t\t);\n\t\treturn;\n\t}\n\n\tconst source = await resolveLikeC4Grammar({ root, ...options, logger });\n\n\tconst registration = {\n\t\t...source.grammar,\n\t\tname: LANGUAGE_NAME,\n\t\taliases: [...LANGUAGE_ALIASES],\n\t};\n\n\tupdateConfig({\n\t\t// `withLikeC4Language` keeps the option's shape generic so it stays usable\n\t\t// outside Starlight; every field it returns is one Expressive Code accepts.\n\t\texpressiveCode: withLikeC4Language(expressiveCode, registration) as StarlightConfigUpdate['expressiveCode'],\n\t});\n\n\tconst { repo, ref, sha, source: from } = source.meta;\n\tlogger.info(\n\t\t`LikeC4 grammar ${repo}@${ref} (${sha})${from === 'network' ? '' : ` from ${from}`} — ` +\n\t\t\t'highlighting ```c4 and ```likec4 fences',\n\t);\n}\n\n/**\n * Add the LikeC4 language to a site's Expressive Code options without\n * disturbing anything already set.\n *\n * Replacing an existing entry rather than appending matters: a site that\n * pinned `likec4Language` from `@purview-dev/astroc4/expressive-code` should get the\n * grammar for the ref it configured here, not two grammars for the same scope.\n * Expressive Code concatenates `shiki.langs` when it merges these options with\n * an `ec.config.mjs`, so a site's own languages survive either way.\n *\n * @param expressiveCode The site's `expressiveCode` option.\n * @param registration Shiki language registration.\n */\nexport function withLikeC4Language(\n\texpressiveCode: unknown,\n\tregistration: Record<string, unknown>,\n): Record<string, unknown> & { shiki: { langs: unknown[] } } {\n\tconst current = isObject(expressiveCode) ? expressiveCode : {};\n\tconst shiki = isObject(current.shiki) ? current.shiki : {};\n\tconst langs: unknown[] = Array.isArray(shiki.langs) ? [...shiki.langs] : [];\n\tconst existing = langs.findIndex(isLikeC4Language);\n\n\tif (existing === -1) langs.push(registration);\n\telse langs[existing] = registration;\n\n\treturn { ...current, shiki: { ...shiki, langs } };\n}\n\n/** A Shiki `langs` entry that already covers LikeC4, as an id or a registration. */\nfunction isLikeC4Language(entry: unknown): boolean {\n\tif (typeof entry === 'string') return entry === LANGUAGE_NAME || LANGUAGE_ALIASES.includes(entry);\n\tif (!isObject(entry)) return false;\n\n\tif (entry.name === LANGUAGE_NAME || entry.scopeName === 'source.likec4') return true;\n\n\treturn Array.isArray(entry.aliases) && entry.aliases.some((alias) => LANGUAGE_ALIASES.includes(alias));\n}\n\nfunction isObject(value: unknown): value is Record<string, any> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n\nfunction likec4Integration({ vitePlugin = {}, fences = true }: StarlightLikeC4Options): AstroIntegration {\n\treturn {\n\t\tname: `${PACKAGE_NAME}/integration`,\n\t\thooks: {\n\t\t\t'astro:config:setup': async ({ command, config, updateConfig, logger }) => {\n\t\t\t\tupdateConfig({\n\t\t\t\t\tvite: {\n\t\t\t\t\t\tplugins: [LikeC4VitePlugin(vitePlugin)],\n\t\t\t\t\t\t// The components ship as .astro/.tsx source, so Vite has to\n\t\t\t\t\t\t// transform them rather than hand them to Node as-is.\n\t\t\t\t\t\tssr: { noExternal: [PACKAGE_NAME] },\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);\n\t\t\t\t}\n\n\t\t\t\t// `command` is only available here, not in `astro:config:done` — and\n\t\t\t\t// this must stay build-only; see `loadLikeC4` in ./fences.mjs.\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},\n\t};\n}\n\n/**\n * Append the fence transform to the site's existing Sätteri processor, keeping\n * whatever Starlight and other integrations already registered on it.\n */\nasync function registerFences(\n\tconfig: AstroConfig,\n\tupdateConfig: (config: Record<string, unknown>) => void,\n\tlogger: AstroIntegrationLogger,\n): Promise<void> {\n\tconst { satteri, isSatteriProcessor } = await import('@astrojs/markdown-satteri');\n\tconst existing = config.markdown?.processor;\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: [likec4Fences()] }) } });\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 ?? []), likec4Fences()],\n\t\t\t}),\n\t\t},\n\t});\n}\n",
|
|
6
|
+
"// fences.mjs\n// path: src/fences.mjs\n// Turns a ```likec4 code fence into a rendered diagram instead of a code block.\n//\n// Two forms:\n//\n// ```likec4 view=\"requestPath\" title=\"Request path\"\n// ```\n// -> renders a view from the site's LikeC4 project (any likec4.config.json).\n//\n// ```likec4 title=\"Example\"\n// specification { element system }\n// model { a = system 'A' b = system 'B' a -> b }\n// views { view index { include * } }\n// ```\n// -> compiles and lays out this snippet at build time, then renders it.\n//\n// Layout needs LikeC4's WASM graph engine, so it has to happen during the\n// build; the browser only rehydrates the resulting JSON.\n//\n// This is a Sätteri mdast plugin, not a remark one. Astro 7 made Sätteri the\n// default Markdown processor, and `remarkPlugins` is a legacy option that is\n// silently ignored unless @astrojs/markdown-remark is installed. The plugin's\n// integration (src/index.mjs) registers it; sites do not add it themselves.\n\nimport { createHash } from 'node:crypto';\nimport { createRequire } from 'node:module';\nimport { fileURLToPath } from 'node:url';\n\nimport type { MdastPluginEntry, PluginFactoryContext } from 'satteri';\n\nconst require = createRequire(import.meta.url);\n\n// `likec4`'s Node API is deliberately NOT imported at module scope. It pulls in\n// Langium, chevrotain, an LSP and the WASM layout engine, and this module is\n// loaded as part of the site's astro.config — on a cold start that was\n// enough to make Astro report \"Configuration file updated. Restarting...\", and the restart\n// killed the content-layer transport, leaving every page a 500. Load it lazily\n// so the cost is paid only when a page actually contains an inline fence.\nlet likec4ApiPromise: Promise<LikeC4Api> | undefined;\n\n/** The one thing this module needs from `likec4`'s Node API. */\ntype LikeC4Api = typeof import('likec4').LikeC4;\n\nfunction loadLikeC4(): Promise<LikeC4Api> {\n\t// A plain `require('likec4')` rather than `import('likec4')`: Vite's SSR\n\t// module runner intercepts dynamic `import()` from any module it loaded\n\t// (this one included) to route it through the runner's own module graph —\n\t// and on Windows that runner can already be mid-teardown by the time a\n\t// page's ```likec4 fence triggers this, crashing the whole `astro build`\n\t// (see `preloadLikeC4` below). `require()` goes through Node's own\n\t// resolver instead, which Node 22+ supports for ESM-only packages like\n\t// this one, sidestepping the runner entirely.\n\tlikec4ApiPromise ??= Promise.resolve(require('likec4').LikeC4);\n\n\treturn likec4ApiPromise;\n}\n\n/**\n * Kick off (and await) the same lazy load `loadLikeC4()` uses, so a later\n * call inside Satteri's processing reuses the already-resolved promise\n * instead of issuing a fresh `import('likec4')`.\n *\n * `astro build` on Windows crashes mid-build (\"Vite module runner has been\n * closed\", followed by a native libuv assertion that kills the process) if\n * that first `import('likec4')` happens while Vite is tearing down the SSR\n * module runner used for the content layer — which is exactly when the first\n * page containing a ```likec4 fence is rendered. Finishing the import before\n * that point removes the race. src/index.mjs calls this from\n * `astro:config:setup` for builds only — the module-scope comment above\n * `loadLikeC4` explains why eager-loading it in dev is unsafe.\n */\nexport function preloadLikeC4(): Promise<LikeC4Api> {\n\treturn loadLikeC4();\n}\n\nconst FENCE_LANG = 'likec4';\n\n/** Component the fence is rewritten into, per form. */\nconst INLINE_COMPONENT = '__LikeC4Fence';\nconst PROJECT_COMPONENT = '__LikeC4View';\n\n// Package specifiers, not relative paths: the import is written into the page\n// being compiled, so it has to resolve from the site, not from this file.\n/** The published package name; see the comment on `PACKAGE_NAME` in index.ts. */\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\n/** The fence components a page can need. */\ntype ComponentName = keyof typeof IMPORTS;\n\n/** What a fence's layout produces: the serialised model and its view ids. */\ninterface Layout {\n\tdump: any;\n\tviewIds: string[];\n}\n\n/**\n * Compiling a snippet costs ~250ms (a Langium workspace per call) and the same\n * page is re-rendered on every dev edit, so key on the source: a build pays\n * that once per distinct snippet, not once per render.\n */\nconst layoutCache = new Map<string, Layout>();\n\n/** The `key=\"value\"` pairs a fence's meta string can carry. */\nexport interface FenceMeta {\n\ttitle?: string;\n\tdescription?: string;\n\theight?: string;\n\tcollapsible?: string;\n\tdefaultOpen?: string;\n\tview?: string;\n\t[key: string]: string | undefined;\n}\n\n/** Parse `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\nasync function layoutSnippet(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// Only the first line of each error — LikeC4's parser errors enumerate\n\t\t// every token it expected, which runs to hundreds of lines.\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\t// `$data` is the plain serialisable model; `$model` is its deprecated alias.\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\n/** A JSX attribute, as the MDX compiler wants it. */\ninterface JsxAttribute {\n\ttype: 'mdxJsxAttribute';\n\tname: string;\n\tvalue: string;\n}\n\n/** ESTree for `import <local> from '<source>';`, as the MDX compiler expects. */\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\n// region plugin\nexport function likec4Fences(): MdastPluginEntry {\n\t// A factory runs once per document, so `used` is safely per-file.\n\treturn (factory: PluginFactoryContext) => {\n\t\t// Astro only supports components in .mdx. Leaving the fence as a code\n\t\t// block is the graceful outcome, but say so — a silent code block where\n\t\t// a diagram was intended is easy to miss in review.\n\t\tif (factory.sourceFormat !== 'mdx') {\n\t\t\tif (!factory.source.includes('```' + FENCE_LANG)) return null;\n\n\t\t\treturn {\n\t\t\t\tname: 'likec4-fences:warn',\n\t\t\t\tcode(node, ctx) {\n\t\t\t\t\tif (node.lang !== FENCE_LANG) return;\n\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[likec4-fences] ${describe(ctx.fileURL)} has a \\`\\`\\`${FENCE_LANG} fence, but fences only ` +\n\t\t\t\t\t\t\t'render as diagrams in .mdx files. Rename the page to .mdx, or use <LikeC4View /> directly.',\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (!factory.source.includes('```' + FENCE_LANG)) return null;\n\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 = (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\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 }),\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 layoutSnippet(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 ?? layout.viewIds[0];\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\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\t// Imports go in once, after every fence on the page is known.\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\nexport default likec4Fences;\n",
|
|
7
|
+
"// source.mjs\n// path: src/grammar/source.mjs\n// Resolves the LikeC4 grammar the site asked for: the Langium grammar from\n// likec4/likec4 at a branch, tag or commit, cached on disk, reduced to a\n// TextMate grammar by ./textmate.mjs.\n//\n// This runs from the site's `astro:config:setup`, so `astro dev`, `astro\n// build`, `astro check` and `astro sync` all go through it — a bad ref or an\n// unreadable grammar fails the command instead of quietly shipping\n// unhighlighted code.\n//\n// Network policy: strict by default (`onError: 'fail'`). A *bad ref* is user\n// error and always fails. A *network failure* may fall back to the cache from\n// the last successful fetch, and then to the bundled snapshot, but only when\n// `onError` says so.\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, readFile, rename, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { parseLangium } from './langium.js';\nimport { buildTmLanguage, type TmGrammar } from './textmate.js';\n\n/** Upstream repository and the paths the grammar is read from. */\nexport const DEFAULT_REPO = 'likec4/likec4';\nexport const DEFAULT_REF = 'main';\nexport const LANGIUM_PATH = 'packages/language-server/src/like-c4.langium';\nexport const DEFAULT_BASE_URL = 'https://raw.githubusercontent.com';\n\n/** Shape of a cache file. Bump when the fields change. */\nconst CACHE_VERSION = 1;\n\nconst BUNDLED_GRAMMAR = new URL('./likec4.tmLanguage.json', import.meta.url);\nconst BUNDLED_LANGIUM = new URL('./like-c4.langium', import.meta.url);\n\n/** The refs a repository actually has: branches, tags, `a1b2c3d`. */\nconst REF_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/;\n\nexport type OnError = 'fail' | 'warn' | 'silent';\n\n/** Everything the resolver accepts. The site only ever sets a few of these. */\nexport interface GrammarSourceOptions {\n\t/** Repository to read from. Defaults to likec4/likec4. */\n\trepo?: string;\n\t/** Branch, tag or commit SHA. Defaults to `main`. */\n\tref?: string;\n\t/** Use the bundled snapshot, never the network. */\n\toffline?: boolean;\n\t/** What to do when the grammar cannot be fetched. */\n\tonError?: OnError;\n\t/** Seconds a cached fetch stays fresh. */\n\tcacheTtl?: number;\n\t/** Ignore the cache and refetch. */\n\trefresh?: boolean;\n\t/** Raw file host, for mirrors and proxies. */\n\tbaseUrl?: string;\n\t/** Request timeout in milliseconds. */\n\ttimeout?: number;\n\t/** Site root, for the default cache directory. */\n\troot?: string;\n\t/** Where to cache, overriding the default. */\n\tcacheDir?: string;\n\t/** Environment, for `ASTROC4_*` overrides. */\n\tenv?: NodeJS.ProcessEnv;\n\t/** Astro's logger. */\n\tlogger?: { info?: (message: string) => void; warn?: (message: string) => void };\n\t/** Injected in tests. */\n\tfetchImpl?: typeof fetch;\n\t/** Bundled Langium text, for tests. */\n\tbundledLangiumPath?: string;\n}\n\n/** Where a grammar came from, for logs and tests. */\nexport interface GrammarMeta {\n\trepo: string;\n\tref: string;\n\t/** Where it came from. */\n\tsource: 'network' | 'cache' | 'bundled';\n\tfetchedAt: number;\n\tetag?: string | undefined;\n\t/** Content hash of the Langium source. */\n\tsha: string;\n\t/** Why the bundled snapshot was used. */\n\treason?: string;\n}\n\nexport interface GrammarSource {\n\t/** The TextMate grammar for Shiki. */\n\tgrammar: TmGrammar;\n\t/** The Langium source it was derived from. */\n\tlangium: string;\n\t/** Where it came from, for logs and tests. */\n\tmeta: GrammarMeta;\n}\n\n/** A repo and ref, which is all a cache entry is keyed on. */\ninterface GrammarIdentity {\n\trepo: string;\n\tref: string;\n}\n\n/** Raised for a ref this repository cannot have — always a user error. */\nexport class GrammarRefError extends Error {\n\toverride name = 'GrammarRefError';\n}\n\n/** Raised when the grammar could not be fetched, or came back unusable. */\nexport class GrammarFetchError extends Error {\n\toverride name = 'GrammarFetchError';\n}\n\nexport async function resolveLikeC4Grammar(options: GrammarSourceOptions = {}): Promise<GrammarSource> {\n\tconst env = options.env ?? process.env;\n\tconst repo = options.repo ?? DEFAULT_REPO;\n\tconst ref = env.ASTROC4_REF || options.ref || DEFAULT_REF;\n\tconst offline = options.offline ?? isTruthy(env.ASTROC4_OFFLINE);\n\tconst onError = options.onError ?? 'fail';\n\tconst logger = options.logger;\n\n\tvalidateRef(ref);\n\n\tif (offline) {\n\t\treturn bundled('offline: true', options);\n\t}\n\n\tconst cache = await readCache(options, { repo, ref });\n\n\tif (cache?.fresh && !options.refresh) {\n\t\treturn derive(cache.langium, { repo, ref, source: 'cache', fetchedAt: cache.fetchedAt, etag: cache.etag });\n\t}\n\n\tlet fetched;\n\n\ttry {\n\t\tfetched = await fetchLangiumSource({ ...options, repo, ref, etag: cache?.etag });\n\t} catch (error) {\n\t\tif (!(error instanceof Error)) throw error;\n\n\t\t// A bad ref will fail the same way forever: never paper over it.\n\t\tif (error instanceof GrammarRefError) throw error;\n\n\t\tif (onError === 'fail') throw error;\n\n\t\tif (onError === 'warn') logger?.warn?.(`[astroc4] ${error.message}`);\n\n\t\tif (cache) {\n\t\t\tif (onError === 'warn') {\n\t\t\t\tlogger?.warn?.(`[astroc4] using the grammar cached at ${new Date(cache.fetchedAt).toISOString()}`);\n\t\t\t}\n\n\t\t\treturn derive(cache.langium, {\n\t\t\t\trepo,\n\t\t\t\tref,\n\t\t\t\tsource: 'cache',\n\t\t\t\tfetchedAt: cache.fetchedAt,\n\t\t\t\tetag: cache.etag,\n\t\t\t});\n\t\t}\n\n\t\treturn bundled(error.message, options);\n\t}\n\n\tif ('notModified' in fetched) {\n\t\tif (!cache) {\n\t\t\tthrow new GrammarFetchError(\n\t\t\t\t'the grammar host answered 304 for a grammar that is not cached — retry with `refresh: true`',\n\t\t\t);\n\t\t}\n\n\t\tawait writeCache(options, { repo, ref }, cache);\n\n\t\treturn derive(cache.langium, { repo, ref, source: 'cache', fetchedAt: cache.fetchedAt, etag: cache.etag });\n\t}\n\n\tconst result = derive(fetched.text, { repo, ref, source: 'network', etag: fetched.etag });\n\tawait writeCache(options, { repo, ref }, { langium: fetched.text, etag: fetched.etag });\n\n\treturn result;\n}\n\n/** Where a derivation came from, before it becomes `GrammarMeta`. */\ninterface DeriveInfo {\n\trepo: string;\n\tref: string;\n\tsource: 'network' | 'cache' | 'bundled';\n\tfetchedAt?: number;\n\tetag?: string | undefined;\n}\n\nfunction derive(langium: string, info: DeriveInfo): GrammarSource {\n\tlet vocabulary;\n\n\ttry {\n\t\tvocabulary = parseLangium(langium);\n\t} catch (cause) {\n\t\tthrow new GrammarFetchError(\n\t\t\t`${info.repo}@${info.ref}: the grammar could not be read — ${cause instanceof Error ? cause.message : String(cause)}`,\n\t\t\t{ cause },\n\t\t);\n\t}\n\n\tconst sha = grammarSha(langium);\n\n\treturn {\n\t\tgrammar: buildTmLanguage(vocabulary, { repo: info.repo, ref: info.ref, sha }),\n\t\tlangium,\n\t\tmeta: {\n\t\t\trepo: info.repo,\n\t\t\tref: info.ref,\n\t\t\tsource: info.source,\n\t\t\tfetchedAt: info.fetchedAt ?? Date.now(),\n\t\t\tetag: info.etag,\n\t\t\tsha,\n\t\t},\n\t};\n}\n\n/**\n * The snapshot shipped with this package, for `offline: true` and for falling\n * back when the network is down and `onError` allows it. It is derived from\n * the committed `like-c4.langium`, so it matches `likec4.tmLanguage.json` (the\n * snapshot test asserts exactly that). Its provenance is the snapshot's own,\n * not the ref that was asked for.\n * @param reason Why it is being used, surfaced in logs.\n */\nasync function bundled(reason: string, options: GrammarSourceOptions): Promise<GrammarSource> {\n\tconst path = options.bundledLangiumPath ?? fileURLToPath(BUNDLED_LANGIUM);\n\tconst snapshot = await bundledProvenance();\n\n\tconst source = derive(await readFile(path, 'utf8'), {\n\t\trepo: snapshot.repo ?? DEFAULT_REPO,\n\t\tref: snapshot.ref ?? DEFAULT_REF,\n\t\tsource: 'bundled',\n\t});\n\n\tsource.meta.reason = reason;\n\n\treturn source;\n}\n\n/** `$generated` from the shipped grammar, so logs name the real snapshot. */\nasync function bundledProvenance(): Promise<{ repo?: string; ref?: string }> {\n\ttry {\n\t\tconst { $generated } = JSON.parse(await readFile(fileURLToPath(BUNDLED_GRAMMAR), 'utf8'));\n\n\t\treturn { repo: $generated?.repo, ref: $generated?.ref };\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n/** Short content hash — the identity that actually changes highlighting. */\nexport function grammarSha(source: string): string {\n\treturn createHash('sha256').update(source).digest('hex').slice(0, 12);\n}\n\n// region refs\n\n/**\n * Rejects anything that cannot name a ref, before it reaches the network.\n */\nexport function validateRef(ref: string): string {\n\tif (typeof ref !== 'string' || ref.length === 0) {\n\t\tthrow new GrammarRefError('the LikeC4 grammar `ref` must be a branch, tag or commit SHA');\n\t}\n\n\tif (!REF_PATTERN.test(ref) || ref.includes('..') || ref.endsWith('/') || ref.includes('//')) {\n\t\tthrow new GrammarRefError(\n\t\t\t`\"${ref}\" is not a usable LikeC4 grammar ref — expected a branch, tag or commit SHA such as \"main\" or \"v1.59.4\"`,\n\t\t);\n\t}\n\n\treturn ref;\n}\n\n\n// endregion\n\n// region fetch\n\n/** What a fetch returns: the text, or the news that the ETag still matches. */\nexport type FetchResult = { text: string; etag?: string | undefined } | { notModified: true };\n\nexport async function fetchLangiumSource(\n\toptions: GrammarSourceOptions & { repo: string; ref: string; etag?: string | undefined },\n): Promise<FetchResult> {\n\tconst repo = options.repo;\n\tconst ref = options.ref;\n\tconst baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '');\n\tconst url = `${baseUrl}/${repo}/${ref}/${LANGIUM_PATH}`;\n\tconst timeout = options.timeout ?? 15_000;\n\tconst request = options.fetchImpl ?? fetch;\n\n\tconst headers: Record<string, string> = { 'user-agent': 'astroc4', accept: 'text/plain' };\n\tif (options.etag) headers['if-none-match'] = options.etag;\n\n\tlet response;\n\n\ttry {\n\t\tresponse = await request(url, { headers, redirect: 'follow', signal: AbortSignal.timeout(timeout) });\n\t} catch (cause) {\n\t\tthrow new GrammarFetchError(\n\t\t\t`could not fetch the LikeC4 grammar from ${url} — ${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t'Builds are strict by default: pass `highlighting: { offline: true }` to use the bundled grammar instead.',\n\t\t\t{ cause },\n\t\t);\n\t}\n\n\tif (response.status === 304) return { notModified: true };\n\n\tif (response.status === 404) {\n\t\tthrow new GrammarRefError(\n\t\t\t`${repo} has no \"${ref}\", or it no longer has ${LANGIUM_PATH} (${url}). ` +\n\t\t\t\t'Use a tag such as \"v1.59.4\", a commit SHA, or \"main\".',\n\t\t);\n\t}\n\n\tif (!response.ok) {\n\t\tthrow new GrammarFetchError(\n\t\t\t`${url} responded ${response.status} ${response.statusText} — set ` +\n\t\t\t\t'`highlighting: { onError: \"warn\" }` to fall back to the bundled grammar.',\n\t\t);\n\t}\n\n\tconst text = await response.text();\n\n\tif (text.trim().length === 0) {\n\t\tthrow new GrammarFetchError(`${url} returned an empty file — the grammar is not usable`);\n\t}\n\n\treturn { text, etag: response.headers.get('etag') ?? undefined };\n}\n\n// endregion\n\n// region cache\n\n/**\n * Cache location: `node_modules/.cache/astroc4`, which every Astro project\n * already ignores. One file per repo@ref, so switching `ref` never thrashes.\n */\nfunction cachePath(options: GrammarSourceOptions, identity: GrammarIdentity): string {\n\tconst dir =\n\t\toptions.cacheDir ?? join(options.root ?? process.cwd(), 'node_modules', '.cache', 'astroc4');\n\tconst key = createHash('sha256').update(`${identity.repo}@${identity.ref}`).digest('hex').slice(0, 16);\n\n\treturn join(dir, `grammar-${key}.json`);\n}\n\n/** What a cache file holds. */\ntype CacheWriteEntry = { langium: string; etag?: string | undefined };\n/** A cache entry, plus whether it is still inside its TTL. */\ninterface CacheEntry extends CacheWriteEntry {\n\tfetchedAt: number;\n}\ninterface FreshCacheEntry extends CacheEntry {\n\tfresh: boolean;\n}\n\nasync function readCache(\n\toptions: GrammarSourceOptions,\n\tidentity: GrammarIdentity,\n): Promise<FreshCacheEntry | undefined> {\n\tlet raw;\n\n\ttry {\n\t\traw = await readFile(cachePath(options, identity), 'utf8');\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\ttry {\n\t\tconst entry = JSON.parse(raw);\n\n\t\tif (\n\t\t\tentry?.version !== CACHE_VERSION ||\n\t\t\tentry.repo !== identity.repo ||\n\t\t\tentry.ref !== identity.ref ||\n\t\t\ttypeof entry.langium !== 'string' ||\n\t\t\ttypeof entry.fetchedAt !== 'number'\n\t\t) {\n\t\t\t// A cache written by a different version of this package, or a\n\t\t\t// truncated file. Refetching is cheaper than debugging it.\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst ttl = options.cacheTtl ?? 3600;\n\n\t\treturn { ...entry, fresh: Date.now() - entry.fetchedAt < ttl * 1000 };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Best effort: a read-only `node_modules` must not fail a build, it only means\n * the next one has to fetch again.\n */\nasync function writeCache(\n\toptions: GrammarSourceOptions,\n\tidentity: GrammarIdentity,\n\tentry: CacheWriteEntry,\n): Promise<void> {\n\tconst path = cachePath(options, identity);\n\tconst temporary = `${path}.${process.pid}.tmp`;\n\n\ttry {\n\t\tawait mkdir(join(path, '..'), { recursive: true });\n\t\tawait writeFile(\n\t\t\ttemporary,\n\t\t\tJSON.stringify({\n\t\t\t\tversion: CACHE_VERSION,\n\t\t\t\trepo: identity.repo,\n\t\t\t\tref: identity.ref,\n\t\t\t\tetag: entry.etag,\n\t\t\t\tfetchedAt: Date.now(),\n\t\t\t\tlangium: entry.langium,\n\t\t\t}),\n\t\t\t'utf8',\n\t\t);\n\t\t// Rename rather than write in place: two Astro processes can resolve the\n\t\t// same cache entry at once during `astro check && astro build`.\n\t\tawait rename(temporary, path);\n\t} catch (error) {\n\t\toptions.logger?.warn?.(\n\t\t\t`[astroc4] could not cache the LikeC4 grammar in ${path} — ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t}\n}\n\n// endregion\n\nfunction isTruthy(value: string | undefined): boolean {\n\treturn typeof value === 'string' && /^(1|true|yes|on)$/i.test(value.trim());\n}\n\nexport default resolveLikeC4Grammar;\n\n",
|
|
8
|
+
"// langium.mjs\n// path: src/grammar/langium.mjs\n// Reduces the LikeC4 Langium grammar to the vocabulary a TextMate grammar\n// needs: which words open a block, which are plain keywords, which are\n// property names, which belong to a closed value domain (shapes, colours,\n// arrow heads…) and which tokens have to be matched structurally (comments,\n// strings, icon ids).\n//\n// The grammar is read from likec4/likec4 at a ref the site chooses:\n// `packages/language-server/src/like-c4.langium`. Deriving from it is what\n// keeps highlighting in step with the language — `ElementShape` gained `agent`\n// after v1.59.4, and the TextMate grammar upstream maintains by hand still\n// does not know about it.\n//\n// Deliberately no Langium dependency: this is a tolerant scanner over one\n// file, not a parser for the grammar language, and it has to survive upstream\n// reformatting. Anything it cannot classify is dropped rather than guessed.\n\n/** Rules that describe a closed set of values are named after what they hold. */\nconst NOT_VALUE_DOMAINS = /Id$/;\n\n/** Property names the grammar matches as `key='…'` assignments. */\nconst PROPERTY_SUPPLEMENTS = ['kind', 'tag'];\n\n/** A token produced by the scanner. */\nexport type TokenType = 'literal' | 'regex' | 'ident' | 'punct';\nexport interface Token {\n\ttype: TokenType;\n\tvalue: string;\n}\n\n/** A `terminal` rule, with its value as written. */\nexport interface Terminal {\n\thidden: boolean;\n\tkind: 'regex' | 'literal';\n\t/** Raw regex source (without slashes) or the literal. */\n\tvalue: string;\n}\n\n/** A parser rule, fragment or terminal, as the scanner reads it. */\nexport interface Rule {\n\tname: string;\n\tkind: 'rule' | 'fragment' | 'terminal';\n\thidden: boolean;\n\treturns?: string | undefined;\n\ttokens: Token[];\n}\n\n/** Everything the TextMate generator needs to know about the language. */\nexport interface Vocabulary {\n\t/** Keywords that open a `{ … }` block. */\n\tblocks: string[];\n\t/** Every remaining word-like literal. */\n\tkeywords: string[];\n\t/** Property names from `key='…'` assignments. */\n\tproperties: string[];\n\t/** Relationship connectors containing `->`. */\n\tarrows: string[];\n\t/** `returns string` value domains, by rule name. */\n\tenums: Record<string, string[]>;\n\t/** Icon packs from the `LIB_ICON` terminal. */\n\ticons: string[];\n\t/** Literals from the `BOOLEAN` terminal. */\n\tbooleans: string[];\n\t/** Parser rules seen — used for sanity checks. */\n\truleCount: number;\n}\n\nexport function parseLangium(source: string): Vocabulary {\n\t// `grammar LikeC4` is a header, not a rule, and it has no `;`: leaving it in\n\t// would glue it to the first real rule and hide that rule from the scanner.\n\tconst statements = splitStatements(\n\t\tstripComments(source).replace(/^[ \\t]*grammar[ \\t]+[A-Za-z_]\\w*[ \\t]*$/gm, ''),\n\t);\n\tconst rules = statements.map(readStatement).filter((rule) => rule !== undefined);\n\n\tconst parserRules = rules.filter((rule) => rule.kind === 'rule' || rule.kind === 'fragment');\n\n\tif (parserRules.length === 0) {\n\t\tthrow new Error(\n\t\t\t'the file contains no Langium parser rules — is this still `packages/language-server/src/like-c4.langium`?',\n\t\t);\n\t}\n\n\tconst enums = resolveEnums(parserRules);\n\tconst blocks = findBlocks(parserRules);\n\tconst properties = unique([...findProperties(parserRules), ...PROPERTY_SUPPLEMENTS]);\n\tconst arrows = findArrows(parserRules);\n\tconst literals = unique(\n\t\tparserRules.flatMap((rule) => rule.tokens.filter((t) => t.type === 'literal').map((t) => t.value)),\n\t);\n\n\tconst classified = new Set([...blocks, ...properties, ...Object.values(enums).flat()]);\n\tconst keywords = literals.filter(\n\t\t(value) => /^[A-Za-z_]\\w*$/.test(value) && !classified.has(value),\n\t);\n\n\tconst terminals = readTerminals(rules);\n\n\t// A grammar with parser rules but no structure at all is not a LikeC4\n\t// grammar — most likely the path now holds something else. A small grammar\n\t// can legitimately have no \"leftover\" keywords, so blocks and value domains\n\t// count too.\n\tif (keywords.length === 0 && blocks.length === 0 && Object.keys(enums).length === 0) {\n\t\tthrow new Error('the file contains no LikeC4 keywords — the Langium grammar could not be read');\n\t}\n\n\treturn {\n\t\tblocks,\n\t\tkeywords,\n\t\tproperties,\n\t\tarrows,\n\t\tenums,\n\t\ticons: terminalAlternatives(terminals.LIB_ICON),\n\t\tbooleans: terminalAlternatives(terminals.BOOLEAN),\n\t\truleCount: parserRules.length,\n\t};\n}\n\n// region scanning\n\n/**\n * Blank out `//` and block comments. String and regex literals are copied\n * verbatim, because a `//` inside `/https?:\\/\\//` is not a comment.\n */\nfunction stripComments(source: string): string {\n\tlet out = '';\n\tlet i = 0;\n\n\twhile (i < source.length) {\n\t\tconst char = source[i];\n\n\t\tif (char === '/' && source[i + 1] === '/') {\n\t\t\twhile (i < source.length && source[i] !== '\\n') i++;\n\t\t\tout += ' ';\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '/' && source[i + 1] === '*') {\n\t\t\ti += 2;\n\t\t\twhile (i < source.length && !(source[i] === '*' && source[i + 1] === '/')) i++;\n\t\t\ti += 2;\n\t\t\tout += ' ';\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"'\" || char === '\"') {\n\t\t\tconst end = endOfString(source, i);\n\t\t\tout += source.slice(i, end);\n\t\t\ti = end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '/') {\n\t\t\tconst end = endOfRegex(source, i);\n\t\t\tout += source.slice(i, end);\n\t\t\ti = end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tout += char;\n\t\ti++;\n\t}\n\n\treturn out;\n}\n\n/** Index just past the quoted literal that opens at `start`. */\nfunction endOfString(source: string, start: number): number {\n\tconst quote = source[start];\n\tlet i = start + 1;\n\n\twhile (i < source.length) {\n\t\tif (source[i] === '\\\\') {\n\t\t\ti += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (source[i] === quote) return i + 1;\n\t\ti++;\n\t}\n\n\treturn source.length;\n}\n\n/** Index just past the regex literal that opens at `start`. */\nfunction endOfRegex(source: string, start: number): number {\n\tlet i = start + 1;\n\tlet inClass = false;\n\n\twhile (i < source.length) {\n\t\tconst char = source[i];\n\n\t\tif (char === '\\\\') {\n\t\t\ti += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '[') inClass = true;\n\t\telse if (char === ']') inClass = false;\n\t\telse if (char === '/' && !inClass) return i + 1;\n\n\t\ti++;\n\t}\n\n\treturn source.length;\n}\n\n/**\n * Split on the `;` that ends each rule, ignoring the ones inside strings,\n * regexes and `{ … }` — interfaces have fields, and rules have `{infer X}`\n * actions, both of which can contain semicolons.\n */\nfunction splitStatements(source: string): string[] {\n\tconst statements: string[] = [];\n\tlet depth = 0;\n\tlet start = 0;\n\tlet i = 0;\n\n\twhile (i < source.length) {\n\t\tconst char = source[i];\n\n\t\tif (char === \"'\" || char === '\"') {\n\t\t\ti = endOfString(source, i);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '/') {\n\t\t\ti = endOfRegex(source, i);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '{') depth++;\n\t\telse if (char === '}') depth = Math.max(0, depth - 1);\n\t\telse if (char === ';' && depth === 0) {\n\t\t\tstatements.push(source.slice(start, i));\n\t\t\tstart = i + 1;\n\t\t}\n\n\t\ti++;\n\t}\n\n\tconst tail = source.slice(start).trim();\n\tif (tail.length > 0) statements.push(tail);\n\n\treturn statements.filter((statement) => statement.trim().length > 0);\n}\n\nconst HEADERS: { kind: 'rule' | 'fragment' | 'terminal'; hidden: boolean; pattern: RegExp }[] = [\n\t// `hidden terminal WS: /[ \\t]+/`\n\t{ kind: 'terminal', hidden: true, pattern: /^\\s*hidden\\s+terminal\\s+([A-Za-z_]\\w*)\\s*(?:<[^>]*>)?\\s*:/ },\n\t// `terminal LIB_ICON: /…/`, `terminal fragment HASH: '#'`\n\t{\n\t\tkind: 'terminal',\n\t\thidden: false,\n\t\tpattern:\n\t\t\t/^\\s*terminal\\s+(?:fragment\\s+)?([A-Za-z_]\\w*)\\s*(?:<[^>]*>)?\\s*(?:returns\\s+[A-Za-z_]\\w*\\s*)?:/,\n\t},\n\t// `fragment RelationConnector:`\n\t{ kind: 'fragment', hidden: false, pattern: /^\\s*fragment\\s+([A-Za-z_]\\w*)\\s*:/ },\n\t// `Model:`, `ModelViews:`, `entry LikeC4Grammar:`, `Relation<isExplicit>:`\n\t{\n\t\tkind: 'rule',\n\t\thidden: false,\n\t\tpattern: /^\\s*(?:entry\\s+)?([A-Za-z_]\\w*)\\s*(?:<[^>]*>)?\\s*(?:returns\\s+([A-Za-z_]\\w*)\\s*)?:/,\n\t},\n];\n\nfunction readStatement(statement: string): Rule | undefined {\n\tfor (const header of HEADERS) {\n\t\tconst match = header.pattern.exec(statement);\n\t\tconst name = match?.[1];\n\t\tif (!match || !name) continue;\n\n\t\treturn {\n\t\t\tname,\n\t\t\tkind: header.kind,\n\t\t\thidden: header.hidden,\n\t\t\treturns: header.kind === 'rule' ? match[2] : undefined,\n\t\t\ttokens: tokenize(statement.slice(match[0].length)),\n\t\t};\n\t}\n\n\treturn undefined;\n}\n\nfunction tokenize(body: string): Token[] {\n\tconst tokens: Token[] = [];\n\tlet i = 0;\n\n\twhile (i < body.length) {\n\t\tconst char = body.charAt(i);\n\n\t\tif (/\\s/.test(char)) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"'\" || char === '\"') {\n\t\t\tconst end = endOfString(body, i);\n\t\t\ttokens.push({ type: 'literal', value: unquote(body.slice(i, end)) });\n\t\t\ti = end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '/') {\n\t\t\tconst end = endOfRegex(body, i);\n\t\t\ttokens.push({ type: 'regex', value: body.slice(i + 1, end - 1) });\n\t\t\ti = end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst identifier = /^[A-Za-z_]\\w*/.exec(body.slice(i));\n\t\tif (identifier) {\n\t\t\ttokens.push({ type: 'ident', value: identifier[0] });\n\t\t\ti += identifier[0].length;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Multi-character punctuation (`+=`, `?=`) is irrelevant: only `=`, `|`,\n\t\t// `(` and `)` are inspected, and per-character tokens give all four.\n\t\ttokens.push({ type: 'punct', value: char });\n\t\ti++;\n\t}\n\n\treturn tokens;\n}\n\n/** Strip the quotes and resolve the escapes Langium allows in literals. */\nfunction unquote(quoted: string): string {\n\tconst inner = quoted.slice(1, -1);\n\tlet out = '';\n\n\tfor (let i = 0; i < inner.length; i++) {\n\t\tif (inner[i] !== '\\\\') {\n\t\t\tout += inner[i];\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst escaped = inner[++i];\n\t\tif (escaped === 'n') out += '\\n';\n\t\telse if (escaped === 't') out += '\\t';\n\t\telse if (escaped === 'r') out += '\\r';\n\t\telse out += escaped ?? '';\n\t}\n\n\treturn out;\n}\n\n// endregion\n\n// region vocabulary\n\n/**\n * Rules of the shape `'specification' '{' …` or `name='model' '{' …` open a\n * block. The first literal of the rule is the keyword, and it only counts when\n * the rule reaches a `{` without branching first: `'element' kind=ElementKind\n * ('{' …)` has an optional body, so `element` stays a keyword.\n */\nfunction findBlocks(rules: Rule[]): string[] {\n\treturn unique(\n\t\trules.flatMap((rule) => {\n\t\t\tconst tokens = rule.tokens;\n\t\t\tconst first = tokens.findIndex((token) => token.type === 'literal');\n\t\t\tconst keyword = first === -1 ? undefined : tokens[first]?.value;\n\n\t\t\tif (!keyword || keyword === '{' || !/^[A-Za-z_]\\w*$/.test(keyword)) return [];\n\n\t\t\tfor (let i = first + 1; i < tokens.length; i++) {\n\t\t\t\tconst token = tokens[i];\n\t\t\t\tif (!token) break;\n\t\t\t\tif (token.value === '(' || token.value === '|') return [];\n\t\t\t\tif (token.type === 'literal' && token.value === '{') return [keyword];\n\t\t\t}\n\n\t\t\treturn [];\n\t\t}),\n\t);\n}\n\n/**\n * `key='title'` and `key=('head' | 'tail')` name a property. Positional\n * arguments (`props+=String`) and `name=` (block headers) are ignored.\n */\nfunction findProperties(rules: Rule[]): string[] {\n\tconst properties: string[] = [];\n\n\tfor (const rule of rules) {\n\t\tconst tokens = rule.tokens;\n\n\t\tfor (let i = 0; i < tokens.length; i++) {\n\t\t\tconst token = tokens[i];\n\t\t\tif (!token || token.type !== 'ident' || token.value !== 'key') continue;\n\n\t\t\tconst equals = equalsIndex(tokens, i);\n\t\t\tif (equals === -1) continue;\n\n\t\t\tlet j = equals + 1;\n\n\t\t\tif (tokens[j]?.value === '(') {\n\t\t\t\tfor (j++; j < tokens.length && tokens[j]?.value !== ')'; j++) {\n\t\t\t\t\tconst inner = tokens[j];\n\t\t\t\t\tif (inner?.type === 'literal') properties.push(inner.value);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst value = tokens[j];\n\t\t\tif (value?.type === 'literal') properties.push(value.value);\n\t\t}\n\t}\n\n\treturn properties.filter((value) => /^[A-Za-z_]\\w*$/.test(value));\n}\n\n/**\n * Index of the `=` that assigns `tokens[i]` (`key=`, `key?=`, `key+=`), or `-1`\n * when the identifier is not being assigned.\n */\nfunction equalsIndex(tokens: Token[], i: number): number {\n\tif (tokens[i]?.type !== 'ident') return -1;\n\n\tconst next = tokens[i + 1]?.value;\n\tif (next === '=') return i + 1;\n\tif ((next === '?' || next === '+') && tokens[i + 2]?.value === '=') return i + 2;\n\n\treturn -1;\n}\n\n/**\n * The connectors live in one fragment:\n * dotKind=RelationKindDotRef | '-[' kind=[RelationshipKind] (… '->') | … | '->'\n */\nfunction findArrows(rules: Rule[]): string[] {\n\tconst connector = rules.find((rule) => rule.name === 'RelationConnector');\n\tconst fromConnector = (connector?.tokens ?? [])\n\t\t.filter((token) => token.type === 'literal' && token.value.includes('->'))\n\t\t.map((token) => token.value);\n\n\t// Longest first: TextMate alternation is first-match, so `]->` has to be\n\t// tried before `->` at the same position.\n\treturn unique([...fromConnector, '->', '<->']).sort((a, b) => b.length - a.length || a.localeCompare(b));\n}\n\n/**\n * A `returns string` rule whose body is only literals, `|` and references to\n * other such rules is a closed value domain — `BorderStyleValue: LineOptions |\n * 'none'` inherits from `LineOptions` that way. Anything referencing a rule\n * that is not itself a value domain (e.g. `Id returns string`) resolves to\n * nothing and is dropped.\n */\nfunction resolveEnums(rules: Rule[]): Record<string, string[]> {\n\tconst candidates = new Map<string, string[]>();\n\n\tfor (const rule of rules) {\n\t\tif (rule.returns !== 'string' || NOT_VALUE_DOMAINS.test(rule.name)) continue;\n\n\t\tconst onlyValuesAndChoices = rule.tokens.every(\n\t\t\t(token) =>\n\t\t\t\ttoken.type === 'literal' ||\n\t\t\t\ttoken.type === 'ident' ||\n\t\t\t\t(token.type === 'punct' && (token.value === '|' || token.value === ';')),\n\t\t);\n\n\t\tif (onlyValuesAndChoices) candidates.set(rule.name, []);\n\t}\n\n\t// Fixpoint, because `BorderStyleValue` can only resolve once `LineOptions`\n\t// has. One pass per rule is enough for any acyclic grammar.\n\tfor (let pass = 0; pass < rules.length; pass++) {\n\t\tlet changed = false;\n\n\t\tfor (const rule of rules) {\n\t\t\tif (!candidates.has(rule.name)) continue;\n\n\t\t\tconst resolved: string[] = [];\n\t\t\tlet complete = true;\n\n\t\t\tfor (const token of rule.tokens) {\n\t\t\t\tif (token.type === 'literal') {\n\t\t\t\t\tresolved.push(token.value);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (token.type !== 'ident') continue;\n\n\t\t\t\tconst inherited = candidates.get(token.value);\n\t\t\t\tif (inherited === undefined) {\n\t\t\t\t\tcomplete = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tresolved.push(...inherited);\n\t\t\t}\n\n\t\t\tconst next = unique(resolved);\n\t\t\tif (!complete || next.length === 0) continue;\n\n\t\t\tif ((candidates.get(rule.name) ?? []).length !== next.length) {\n\t\t\t\tcandidates.set(rule.name, next);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!changed) break;\n\t}\n\n\tconst enums: Record<string, string[]> = {};\n\tfor (const [name, values] of [...candidates].sort(([a], [b]) => a.localeCompare(b))) {\n\t\tif (values.length > 0) enums[name] = values;\n\t}\n\n\treturn enums;\n}\n\n/** Reads every `terminal` rule, keyed by name. */\nfunction readTerminals(rules: Rule[]): Record<string, Terminal> {\n\tconst terminals: Record<string, Terminal> = {};\n\n\tfor (const rule of rules) {\n\t\tif (rule.kind !== 'terminal') continue;\n\n\t\tconst token = rule.tokens.find((candidate) => candidate.type === 'regex' || candidate.type === 'literal');\n\t\tif (!token) continue;\n\n\t\tterminals[rule.name] = {\n\t\t\thidden: rule.hidden,\n\t\t\tkind: token.type === 'regex' ? 'regex' : 'literal',\n\t\t\tvalue: token.value,\n\t\t};\n\t}\n\n\treturn terminals;\n}\n\n/**\n * The alternatives of the first group in a terminal's regex:\n * `(aws|azure|bootstrap|gcp|md|tech):[-\\w]+` -> the icon packs.\n */\nfunction terminalAlternatives(terminal: Terminal | undefined): string[] {\n\tif (!terminal || terminal.kind !== 'regex') return [];\n\n\tconst group = /\\(([^()]*)\\)/.exec(terminal.value);\n\tif (!group) return [];\n\n\treturn unique((group[1] ?? '').split('|').map((value) => value.trim())).filter((value) =>\n\t\t/^[A-Za-z][\\w-]*$/.test(value),\n\t);\n}\n\nfunction unique(values: string[]): string[] {\n\treturn [...new Set(values)].sort((a, b) => a.localeCompare(b));\n}\n\n// endregion\n\nexport default parseLangium;\n\n",
|
|
9
|
+
"// textmate.mjs\n// path: src/grammar/textmate.mjs\n// Builds the Shiki / TextMate grammar for LikeC4 out of the vocabulary read\n// from the live Langium grammar (./langium.mjs).\n//\n// Two layers:\n// - generated — every word list: blocks, keywords, property names and closed\n// value domains. These are exactly the lists that go stale when the\n// language grows (`agent` was added to `ElementShape` after v1.59.4).\n// - structural — how LikeC4 source is *shaped* rather than which words it\n// uses: comments, quoted and triple-quoted strings, `#tag` vs `#hex`,\n// `tech:astro` icons, `-[https]->` arrows, `element system` declarations.\n// These are curated here because a Langium rule does not say how a token\n// should look, only that it is one.\n//\n// The result must stay plain JSON: Expressive Code JSON-round-trips integration\n// options before the `<Code>` component renders them, and throws on functions\n// or RegExp instances.\n\nimport type { Vocabulary } from './langium.js';\n\n/** Scope name of the grammar, as upstream's VS Code extension uses it. */\nexport const SCOPE_NAME = 'source.likec4';\n\n/** Shiki language id, plus the short alias used by ` ```c4 ` fences. */\nexport const LANGUAGE_NAME = 'likec4';\nexport const LANGUAGE_ALIASES = ['c4'];\n\nconst TMLANGUAGE_SCHEMA =\n\t'https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json';\n\n/**\n * Closed value domains: they colour as values, not as keywords.\n * Anything the grammar adds under these names is picked up automatically.\n */\nconst VALUE_DOMAINS = [\n\t'BorderStyleValue',\n\t'DynamicViewDisplayVariantValue',\n\t'EdgeRoutingValue',\n\t'ElementShape',\n\t'IconPositionValue',\n\t'LineOptions',\n\t'ArrowType',\n\t'RankValue',\n\t'SizeValue',\n\t'SizingValue',\n\t'ThemeColor',\n\t'ViewLayoutDirection',\n];\n\n/** Control-flow keywords read as keywords, not as a value domain. */\nconst KEYWORD_DOMAINS = ['DynamicViewFlowKeyword'];\n\n/** `source` / `target` are the only value-like variables. */\nconst VARIABLE_DOMAINS = ['Participant'];\n\n/** Operators whose scope is a word, kept curated: they are not all literals. */\nconst OPERATOR_WORDS = ['and', 'or', 'not', 'is'];\n\n/** Used when the grammar cannot be read — never expected, never silent. */\nconst FALLBACK_ICON_PACKS = ['aws', 'azure', 'bootstrap', 'gcp', 'tech'];\n\n/** One TextMate pattern. `match`/`begin`/`end` are regex *source*, not `RegExp`. */\nexport interface TmPattern {\n\tname?: string;\n\tcomment?: string;\n\tinclude?: string;\n\tmatch?: string;\n\tbegin?: string;\n\tend?: string;\n\tcontentName?: string;\n\tcaptures?: Record<string, { name: string }>;\n\tbeginCaptures?: Record<string, { name: string }>;\n\tendCaptures?: Record<string, { name: string }>;\n\tpatterns?: TmPattern[];\n}\n\n/** A TextMate grammar: JSON all the way down, never a `RegExp`. */\nexport interface TmGrammar {\n\t$schema: string;\n\tname: string;\n\tdisplayName: string;\n\tscopeName: string;\n\tfileTypes: string[];\n\tpatterns: TmPattern[];\n\t// Each repository entry is a pattern group; the tests index into them.\n\trepository: Record<string, any>;\n\t$generated?: { repo: string; ref: string; sha?: string; by: string };\n}\n\n/** Where the grammar came from, written into the snapshot's `$generated`. */\nexport interface TmProvenance {\n\trepo?: string;\n\tref?: string;\n\tsha?: string;\n}\n\n/** Turns a vocabulary into a TextMate grammar, JSON-serialisable. */\nexport function buildTmLanguage(vocabulary: Vocabulary, meta: TmProvenance = {}): TmGrammar {\n\tconst control = uniqueDomain(vocabulary, KEYWORD_DOMAINS);\n\tconst variables = uniqueDomain(vocabulary, VARIABLE_DOMAINS);\n\tconst icons = vocabulary.icons.length > 0 ? vocabulary.icons : FALLBACK_ICON_PACKS;\n\n\t// Words that are always syntax, never the name of a kind: `deployed =\n\t// instanceOf a` must not paint `instanceOf` as a type.\n\tconst reserved = alternationOf([...vocabulary.keywords, ...vocabulary.blocks, ...control]);\n\n\tconst grammar: TmGrammar = {\n\t\t$schema: TMLANGUAGE_SCHEMA,\n\t\t...(meta.repo && meta.ref\n\t\t\t? {\n\t\t\t\t\t$generated: {\n\t\t\t\t\t\trepo: meta.repo,\n\t\t\t\t\t\tref: meta.ref,\n\t\t\t\t\t\t...(meta.sha ? { sha: meta.sha } : {}),\n\t\t\t\t\t\tby: 'astroc4/scripts/sync-grammar.ts',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tname: LANGUAGE_NAME,\n\t\tdisplayName: 'LikeC4',\n\t\tscopeName: SCOPE_NAME,\n\t\tfileTypes: ['c4', 'likec4'],\n\t\tpatterns: [{ include: '#everything' }],\n\t\trepository: {\n\t\t\teverything: {\n\t\t\t\tpatterns: [\n\t\t\t\t\t'comments',\n\t\t\t\t\t'strings',\n\t\t\t\t\t'urls',\n\t\t\t\t\t'icons',\n\t\t\t\t\t'hex-colors',\n\t\t\t\t\t'tags',\n\t\t\t\t\t'typed-arrow',\n\t\t\t\t\t'declarations',\n\t\t\t\t\t'keywords',\n\t\t\t\t\t'numbers',\n\t\t\t\t\t'operators',\n\t\t\t\t\t'punctuation',\n\t\t\t\t].map((name) => ({ include: `#${name}` })),\n\t\t\t},\n\t\t\tcomments: comments(),\n\t\t\tstrings: strings(),\n\t\t\turls: urls(),\n\t\t\ticons: iconIds(icons),\n\t\t\t'hex-colors': hexColours(),\n\t\t\ttags: tags(),\n\t\t\t'typed-arrow': typedArrow(),\n\t\t\tdeclarations: declarations(reserved),\n\t\t\tkeywords: keywords({ ...vocabulary, control, variables }),\n\t\t\tnumbers: numbers(),\n\t\t\toperators: operators(vocabulary.arrows),\n\t\t\tpunctuation: punctuation(),\n\t\t},\n\t};\n\n\tif (meta.repo && meta.ref) {\n\t\tgrammar.$generated = {\n\t\t\trepo: meta.repo,\n\t\t\tref: meta.ref,\n\t\t\t...(meta.sha ? { sha: meta.sha } : {}),\n\t\t\tby: 'astroc4/scripts/sync-grammar.ts',\n\t\t};\n\t}\n\n\treturn grammar;\n}\n// region structural patterns\n\nfunction comments() {\n\treturn {\n\t\tpatterns: [\n\t\t\t{\n\t\t\t\tname: 'comment.block.likec4',\n\t\t\t\tbegin: '/\\\\*',\n\t\t\t\tend: '\\\\*/',\n\t\t\t\tcaptures: { 0: { name: 'punctuation.definition.comment.likec4' } },\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'comment.line.double-slash.likec4',\n\t\t\t\tmatch: '//.*$',\n\t\t\t\tcaptures: { 0: { name: 'punctuation.definition.comment.likec4' } },\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * `'…'`, `\"…\"`, and the markdown strings `''' … '''` / `\"\"\" … \"\"\"` that\n * LikeC4 uses for descriptions.\n */\nfunction strings() {\n\tconst triple = (quote: string): TmPattern => ({\n\t\tname: 'string.quoted.triple.likec4',\n\t\tbegin: quote.repeat(3),\n\t\tend: quote.repeat(3),\n\t\tbeginCaptures: { 0: { name: 'punctuation.definition.string.begin.likec4' } },\n\t\tendCaptures: { 0: { name: 'punctuation.definition.string.end.likec4' } },\n\t});\n\n\tconst single = (quote: string, name: string): TmPattern => ({\n\t\tname,\n\t\tbegin: quote,\n\t\tend: `${quote}|$`,\n\t\tbeginCaptures: { 0: { name: 'punctuation.definition.string.begin.likec4' } },\n\t\tendCaptures: { 0: { name: 'punctuation.definition.string.end.likec4' } },\n\t\tpatterns: [{ name: 'constant.character.escape.likec4', match: '\\\\\\\\.' }],\n\t});\n\n\treturn {\n\t\tpatterns: [\n\t\t\ttriple(\"'\"),\n\t\t\ttriple('\"'),\n\t\t\tsingle(\"'\", 'string.quoted.single.likec4'),\n\t\t\tsingle('\"', 'string.quoted.double.likec4'),\n\t\t],\n\t};\n}\n\nfunction urls() {\n\treturn { name: 'markup.underline.link.likec4', match: \"\\\\bhttps?://[^\\\\s'\\\"]+\" };\n}\n\n/**\n * Icon ids (`tech:astro`, `aws:lambda`). The packs come from the `LIB_ICON`\n * terminal, so a pack added upstream highlights without touching this package.\n */\nfunction iconIds(packs: string[]): TmPattern {\n\treturn {\n\t\tcomment: 'Bundled icon ids: `tech:nginx`, `aws:…`, `gcp:…`, …',\n\t\tmatch: `\\\\b(${alternationOf(packs)})(:)([\\\\w-]+)`,\n\t\tcaptures: {\n\t\t\t1: { name: 'support.constant.icon-pack.likec4' },\n\t\t\t2: { name: 'punctuation.separator.likec4' },\n\t\t\t3: { name: 'support.constant.icon.likec4' },\n\t\t},\n\t};\n}\n\n/** `#0046BE` is a colour, `#compute` is a tag — hex first, so it wins. */\nfunction hexColours() {\n\treturn {\n\t\tname: 'constant.other.color.rgb-value.hex.likec4',\n\t\tmatch: '#(?:[0-9A-Fa-f]{8}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})(?![\\\\w-])',\n\t};\n}\n\nfunction tags() {\n\treturn { name: 'entity.name.tag.likec4', match: '#[A-Za-z_][\\\\w-]*' };\n}\n\n/** `a -[https]-> b` — the relationship kind inside the connector. */\nfunction typedArrow() {\n\treturn {\n\t\tcomment: '`a -[https]-> b`',\n\t\tmatch: '(-\\\\[)\\\\s*([A-Za-z_][\\\\w-]*)\\\\s*(\\\\]->)',\n\t\tcaptures: {\n\t\t\t1: { name: 'keyword.operator.arrow.likec4' },\n\t\t\t2: { name: 'entity.name.type.relationship.likec4' },\n\t\t\t3: { name: 'keyword.operator.arrow.likec4' },\n\t\t},\n\t};\n}\n\n/**\n * Declarations: the name being introduced is scoped, the name only being\n * referred to is not. Runs before the keyword patterns so `element system`\n * reads as a declaration rather than as two keywords.\n *\n * `reserved` is the alternation of syntax words (`instanceOf`, `extend`, …), so\n * `deployed = instanceOf a` scopes `instanceOf` as a keyword rather than as the\n * element kind the name is being assigned.\n */\nfunction declarations(reserved: string): TmPattern {\n\tconst notReserved = reserved ? `(?!(?:${reserved})\\\\b)` : '';\n\n\treturn {\n\t\tpatterns: [\n\t\t\t{\n\t\t\t\tcomment:\n\t\t\t\t\t'`element system`, `deploymentNode region`, `tag tls`, `relationship https`. Not `where tag is #x`.',\n\t\t\t\tmatch: '\\\\b(element|deploymentNode|tag|relationship)\\\\s+(?!is\\\\b)([A-Za-z_][\\\\w-]*)(?=\\\\s*(?:\\\\{|$|//))',\n\t\t\t\tcaptures: {\n\t\t\t\t\t1: { name: 'storage.type.likec4' },\n\t\t\t\t\t2: { name: 'entity.name.type.likec4' },\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tcomment:\n\t\t\t\t\t'`color testingBlue #0046BE` declares; `color testingBlue` inside a style block only refers.',\n\t\t\t\tmatch: '\\\\b(color)\\\\s+([A-Za-z_][\\\\w-]*)(?=\\\\s+#)',\n\t\t\t\tcaptures: {\n\t\t\t\t\t1: { name: 'storage.type.likec4' },\n\t\t\t\t\t2: { name: 'entity.name.type.likec4' },\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tcomment: '`view index`, `dynamic view firstRequest`, `deployment view prod`, `view internals of site`',\n\t\t\t\tmatch: '\\\\b(?:(dynamic|deployment)\\\\s+)?(view)\\\\s+([A-Za-z_]\\\\w*)',\n\t\t\t\tcaptures: {\n\t\t\t\t\t1: { name: 'storage.modifier.likec4' },\n\t\t\t\t\t2: { name: 'storage.type.view.likec4' },\n\t\t\t\t\t3: { name: 'entity.name.function.view.likec4' },\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tcomment: \"`reader = actor 'Engineer'`\",\n\t\t\t\tmatch: `\\\\b([A-Za-z_]\\\\w*)\\\\s*(=)(?!=)\\\\s*${notReserved}([A-Za-z_]\\\\w*)?`,\n\t\t\t\tcaptures: {\n\t\t\t\t\t1: { name: 'variable.other.definition.likec4' },\n\t\t\t\t\t2: { name: 'keyword.operator.assignment.likec4' },\n\t\t\t\t\t3: { name: 'entity.name.type.likec4' },\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n}\n\n// endregion\n\n// region generated keyword patterns\n\n/**\n * Order matters here: blocks before plain keywords (so `model {` is a block),\n * operator words before keywords (`is`, `not`), variables before value domains\n * (so `source`/`target` stay variables even though `RankValue` reuses `source`).\n *\n */\nfunction keywords(vocabulary: Vocabulary & { control: string[]; variables: string[] }): TmPattern {\n\tconst patterns: TmPattern[] = [];\n\n\tconst blocks = alternationOf(vocabulary.blocks);\n\tif (blocks) {\n\t\tpatterns.push({\n\t\t\tcomment: 'Keywords that open a block: `model { … }`.',\n\t\t\tname: 'keyword.control.block.likec4',\n\t\t\tmatch: `\\\\b(?:${blocks})\\\\b(?=\\\\s*\\\\{)`,\n\t\t});\n\t}\n\n\t// Blocks repeat in the keyword list on purpose: `predicateGroup mine { … }`\n\t// is not followed by `{`, and still has to colour as a keyword. The block\n\t// pattern above wins wherever the brace is there.\n\tconst control = alternationOf([...vocabulary.keywords, ...vocabulary.control, ...vocabulary.blocks]);\n\n\t// Word operators (`is`, `not`) come before the keyword list, which also\n\t// contains them: `where tag is #x` reads as an operator, not a keyword.\n\tpatterns.push({\n\t\tname: 'keyword.operator.word.likec4',\n\t\tmatch: `\\\\b(?:${alternationOf(OPERATOR_WORDS)})\\\\b`,\n\t});\n\n\tif (control) {\n\t\tpatterns.push({ name: 'keyword.control.likec4', match: `\\\\b(?:${control})\\\\b` });\n\t}\n\n\tconst variables = alternationOf(vocabulary.variables);\n\tif (variables) {\n\t\tpatterns.push({ name: 'variable.language.likec4', match: `\\\\b(?:${variables})\\\\b` });\n\t}\n\n\tconst properties = alternationOf(vocabulary.properties);\n\tif (properties) {\n\t\tpatterns.push({ name: 'support.type.property-name.likec4', match: `\\\\b(?:${properties})\\\\b` });\n\t}\n\n\tconst values = alternationOf(uniqueDomain(vocabulary, VALUE_DOMAINS));\n\tif (values) {\n\t\tpatterns.push({ name: 'constant.language.likec4', match: `\\\\b(?:${values})\\\\b` });\n\t}\n\n\treturn { patterns };\n}\n\nfunction numbers() {\n\treturn { name: 'constant.numeric.likec4', match: '\\\\b\\\\d+(?:\\\\.\\\\d+)?%?' };\n}\n\n/**\n * Relationship connectors, longest first so `]->` wins over `->`.\n */\nfunction operators(arrows: string[]): TmPattern {\n\tconst patterns: TmPattern[] = [];\n\n\tconst connectors = alternationOf(arrows);\n\tif (connectors) {\n\t\tpatterns.push({ name: 'keyword.operator.arrow.likec4', match: connectors });\n\t}\n\n\tpatterns.push({ name: 'keyword.operator.wildcard.likec4', match: '\\\\.\\\\*\\\\*|\\\\.\\\\*|\\\\*\\\\*|\\\\*' });\n\n\treturn { patterns };\n}\n\nfunction punctuation() {\n\treturn {\n\t\tpatterns: [\n\t\t\t{ name: 'punctuation.section.block.begin.likec4', match: '\\\\{' },\n\t\t\t{ name: 'punctuation.section.block.end.likec4', match: '\\\\}' },\n\t\t\t{ name: 'punctuation.separator.comma.likec4', match: ',' },\n\t\t\t{ name: 'punctuation.accessor.likec4', match: '\\\\.' },\n\t\t],\n\t};\n}\n\n// endregion\n\n// region helpers\n\n/**\n * Every value of the named domains, deduplicated and sorted. Missing domains\n * are skipped rather than failing: upstream is free to rename a rule, and a\n * renamed domain still reaches the grammar through `keywords`.\n */\nfunction uniqueDomain(vocabulary: Vocabulary, names: string[]): string[] {\n\tconst values = names.flatMap((name) => vocabulary.enums[name] ?? []);\n\n\treturn [...new Set(values)].sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * `['a', 'b']` -> `a|b`, escaped for a TextMate regex. Returns '' for an empty\n * list so callers can skip the pattern instead of emitting `\\b(?:)\\b`.\n */\nfunction alternationOf(values: string[]): string {\n\treturn values.map(escapeRegExp).join('|');\n}\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n// endregion\n\nexport default buildTmLanguage;\n\n",
|
|
10
|
+
"// translations.mjs\n// path: src/translations.mjs\n// UI strings for the diagram components, injected into Starlight's i18n system\n// by the plugin's `i18n:setup` hook. A site overrides or adds a language the\n// same way it does for Starlight's own strings — a `src/content/i18n/<lang>.json`\n// containing any of these keys.\n//\n// Placeholders are `{name}`, not i18next's `{{name}}`: some values (the list of\n// available projects, say) are only known in the browser, so the template has\n// to reach the island unformatted. See `format()` in src/components/labels.ts.\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.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"
|
|
11
|
+
],
|
|
12
|
+
"mappings": ";AA0BA,0BAAS;AAIT;;;ACLA;AACA;AACA;AAIA,IAAM,WAAU,cAAc,YAAY,GAAG;AAQ7C,IAAI;AAKJ,SAAS,UAAU,GAAuB;AAAA,EASzC,qBAAqB,QAAQ,QAAQ,SAAQ,QAAQ,EAAE,MAAM;AAAA,EAE7D,OAAO;AAAA;AAiBD,SAAS,aAAa,GAAuB;AAAA,EACnD,OAAO,WAAW;AAAA;AAGnB,IAAM,aAAa;AAGnB,IAAM,mBAAmB;AACzB,IAAM,oBAAoB;AAK1B,IAAM,eAAe;AAErB,IAAM,UAAU;AAAA,GACd,mBAAmB,GAAG;AAAA,GACtB,oBAAoB,GAAG;AACzB;AAgBA,IAAM,cAAc,IAAI;AAcjB,SAAS,cAAc,CAAC,MAA4C;AAAA,EAC1E,MAAM,UAAqB,CAAC;AAAA,EAE5B,IAAI,CAAC;AAAA,IAAM,OAAO;AAAA,EAElB,MAAM,UAAU;AAAA,EAChB,IAAI;AAAA,EAEJ,QAAQ,QAAQ,QAAQ,KAAK,IAAI,OAAO,MAAM;AAAA,IAC7C,MAAM,MAAM,MAAM;AAAA,IAClB,IAAI,CAAC;AAAA,MAAK;AAAA,IAEV,QAAQ,OAAO,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM;AAAA,EACpD;AAAA,EAEA,OAAO;AAAA;AAGR,eAAe,aAAa,CAAC,QAAiC;AAAA,EAC7D,MAAM,MAAM,WAAW,QAAQ,EAAE,OAAO,MAAM,EAAE,OAAO,KAAK;AAAA,EAC5D,MAAM,SAAS,YAAY,IAAI,GAAG;AAAA,EAElC,IAAI;AAAA,IAAQ,OAAO;AAAA,EAEnB,MAAM,SAAS,MAAM,WAA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Ac;AAAA,QACrB;AAAA;AAAA,IAEF;AAAA,EACD;AAAA;AAOD,eAAe,cAAc,CAC5B,QACA,cACA,QACgB;AAAA,EAChB,QAAQ,SAAS,uBAAuB,MAAM;AAAA,EAC9C,MAAM,WAAW,OAAO,UAAU;AAAA,EAGlC,IAAI,aAAa,WAAW;AAAA,IAC3B,aAAa,EAAE,UAAU,EAAE,WAAW,QAAQ,EAAE,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;AAAA,IACrF;AAAA,EACD;AAAA,EAEA,IAAI,CAAC,mBAAmB,QAAQ,GAAG;AAAA,IAClC,OAAO,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,aAAa,CAAC;AAAA,MACvE,CAAC;AAAA,IACF;AAAA,EACD,CAAC;AAAA;",
|
|
13
|
+
"debugId": "BA2D1DBED70A424964756E2164756E21",
|
|
14
|
+
"names": []
|
|
15
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"repo": "likec4/likec4",
|
|
5
5
|
"ref": "main",
|
|
6
6
|
"sha": "da5af77245f9",
|
|
7
|
-
"by": "astroc4/scripts/sync-grammar.
|
|
7
|
+
"by": "astroc4/scripts/sync-grammar.ts"
|
|
8
8
|
},
|
|
9
9
|
"name": "likec4",
|
|
10
10
|
"displayName": "LikeC4",
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"match": "\\bhttps?://[^\\s'\"]+"
|
|
164
164
|
},
|
|
165
165
|
"icons": {
|
|
166
|
-
"comment": "Bundled icon ids: `tech:nginx`, `aws
|
|
166
|
+
"comment": "Bundled icon ids: `tech:nginx`, `aws:…`, `gcp:…`, …",
|
|
167
167
|
"match": "\\b(aws|azure|bootstrap|gcp|md|tech)(:)([\\w-]+)",
|
|
168
168
|
"captures": {
|
|
169
169
|
"1": {
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
"keywords": {
|
|
262
262
|
"patterns": [
|
|
263
263
|
{
|
|
264
|
-
"comment": "Keywords that open a block: `model {
|
|
264
|
+
"comment": "Keywords that open a block: `model { … }`.",
|
|
265
265
|
"name": "keyword.control.block.likec4",
|
|
266
266
|
"match": "\\b(?:add|deployment|diff|dynamicPredicateGroup|global|group|likec4lib|model|predicateGroup|rank|remove|specification|style|styleGroup|views)\\b(?=\\s*\\{)"
|
|
267
267
|
},
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const translations: {
|
|
2
|
+
en: {
|
|
3
|
+
'likec4.view.title': string;
|
|
4
|
+
'likec4.view.description': string;
|
|
5
|
+
'likec4.view.hint': string;
|
|
6
|
+
'likec4.view.badge': string;
|
|
7
|
+
'likec4.view.loading': string;
|
|
8
|
+
'likec4.fence.title': string;
|
|
9
|
+
'likec4.fence.hint': string;
|
|
10
|
+
'likec4.fence.loading': string;
|
|
11
|
+
'likec4.error.title': string;
|
|
12
|
+
'likec4.error.body': string;
|
|
13
|
+
'likec4.error.retry': string;
|
|
14
|
+
'likec4.error.viewIdRequired': string;
|
|
15
|
+
'likec4.error.noProjects': string;
|
|
16
|
+
'likec4.error.unknownProject': string;
|
|
17
|
+
'likec4.error.unresolvedProject': string;
|
|
18
|
+
'likec4.error.loadFailed': string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default translations;
|
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.4",
|
|
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": {
|
|
@@ -32,29 +32,38 @@
|
|
|
32
32
|
],
|
|
33
33
|
"type": "module",
|
|
34
34
|
"exports": {
|
|
35
|
-
".":
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./expressive-code": {
|
|
40
|
+
"types": "./dist/expressive-code.d.ts",
|
|
41
|
+
"import": "./dist/expressive-code.js"
|
|
42
|
+
},
|
|
43
|
+
"./grammar/likec4.tmLanguage.json": "./dist/likec4.tmLanguage.json",
|
|
38
44
|
"./components/LikeC4View.astro": "./src/components/LikeC4View.astro",
|
|
39
45
|
"./components/LikeC4Fence.astro": "./src/components/LikeC4Fence.astro"
|
|
40
46
|
},
|
|
41
47
|
"files": [
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"!src
|
|
48
|
+
"dist",
|
|
49
|
+
"src/components",
|
|
50
|
+
"!src/components/__tests__",
|
|
51
|
+
"src/translations.ts"
|
|
45
52
|
],
|
|
46
53
|
"scripts": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
54
|
+
"build:lib": "bun scripts/build.ts",
|
|
55
|
+
"prepublishOnly": "bun scripts/check-dist.ts",
|
|
56
|
+
"dev": "bun run build:lib && cd playground && astro dev",
|
|
57
|
+
"build": "bun run build:lib && cd playground && astro build",
|
|
49
58
|
"preview": "cd playground && astro preview",
|
|
50
|
-
"check": "cd playground && astro check",
|
|
59
|
+
"check": "bun run build:lib && cd playground && astro check && cd .. && bunx tsc -p tsconfig.scripts.json --noEmit",
|
|
51
60
|
"test": "vitest run",
|
|
52
61
|
"test:watch": "vitest",
|
|
53
62
|
"test:network": "ASTROC4_NETWORK=1 vitest run src/grammar/__tests__/network.test.ts",
|
|
54
|
-
"test:site": "bun scripts/test-site.
|
|
55
|
-
"test:smoke": "
|
|
56
|
-
"grammar:sync": "bun scripts/sync-grammar.
|
|
57
|
-
"grammar:check": "bun scripts/sync-grammar.
|
|
63
|
+
"test:site": "bun run build:lib && bun scripts/test-site.ts",
|
|
64
|
+
"test:smoke": "bun scripts/smoke.ts",
|
|
65
|
+
"grammar:sync": "bun scripts/sync-grammar.ts",
|
|
66
|
+
"grammar:check": "bun scripts/sync-grammar.ts --check",
|
|
58
67
|
"likec4:validate": "likec4 validate playground/src/likec4"
|
|
59
68
|
},
|
|
60
69
|
"peerDependencies": {
|
package/src/components/labels.ts
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
// the server and pass the islands plain strings, because `Astro.locals.t` does
|
|
5
5
|
// not exist in the browser.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Ships alongside this file: `files` publishes `src/components` *and*
|
|
8
|
+
// `src/translations.ts`, so the components stay self-contained source. The
|
|
9
|
+
// specifier keeps its `.js` extension because that is what the emitted
|
|
10
|
+
// declarations carry and what the site's bundler maps back to this `.ts` file.
|
|
11
|
+
import { translations } from '../translations.js';
|
|
8
12
|
|
|
9
13
|
export type TranslationKey = keyof (typeof translations)['en'];
|
|
10
14
|
export type Translate = (key: TranslationKey) => string;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// expressive-code.d.mts
|
|
2
|
-
// path: src/expressive-code.d.mts
|
|
3
|
-
// Types for src/expressive-code.mjs — see src/index.d.mts for why they exist.
|
|
4
|
-
|
|
5
|
-
import type { LanguageRegistration } from 'shiki';
|
|
6
|
-
|
|
7
|
-
/** Shiki registration for LikeC4, under `likec4` with a `c4` alias. */
|
|
8
|
-
export declare const likec4Language: LanguageRegistration & { aliases: string[] };
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Resolve the grammar from likec4/likec4 at the requested ref and return it as
|
|
12
|
-
* a Shiki language registration.
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadLikeC4Language(options?: {
|
|
15
|
-
ref?: string;
|
|
16
|
-
repo?: string;
|
|
17
|
-
offline?: boolean;
|
|
18
|
-
onError?: 'fail' | 'warn' | 'silent';
|
|
19
|
-
cacheTtl?: number;
|
|
20
|
-
refresh?: boolean;
|
|
21
|
-
cacheDir?: string;
|
|
22
|
-
baseUrl?: string;
|
|
23
|
-
timeout?: number;
|
|
24
|
-
root?: string;
|
|
25
|
-
}): Promise<LanguageRegistration & { aliases: string[] }>;
|
|
26
|
-
|
|
27
|
-
export default likec4Language;
|
|
28
|
-
|
package/src/expressive-code.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// expressive-code.mjs
|
|
2
|
-
// path: src/expressive-code.mjs
|
|
3
|
-
// LikeC4 syntax highlighting for Expressive Code (Starlight's code blocks).
|
|
4
|
-
// Shiki ships no LikeC4 grammar, so without this .c4 source renders as plain
|
|
5
|
-
// text.
|
|
6
|
-
//
|
|
7
|
-
// The Starlight plugin injects this language into the site's Expressive Code
|
|
8
|
-
// options for you (see src/index.mjs) resolved from the live Langium grammar.
|
|
9
|
-
// The exports here cover the two cases the plugin cannot:
|
|
10
|
-
//
|
|
11
|
-
// - a site that already has an `ec.config.mjs`, which can add the bundled
|
|
12
|
-
// grammar with one line:
|
|
13
|
-
//
|
|
14
|
-
// import { likec4Language } from '@purview-dev/astroc4/expressive-code';
|
|
15
|
-
// export default defineEcConfig({ shiki: { langs: [likec4Language] } });
|
|
16
|
-
//
|
|
17
|
-
// - anything else that needs the grammar programmatically, e.g. a Markdown
|
|
18
|
-
// pipeline of its own: `await loadLikeC4Language({ ref: 'v1.59.4' })`.
|
|
19
|
-
//
|
|
20
|
-
// `likec4Language` is the bundled snapshot, so it works without network
|
|
21
|
-
// access; `loadLikeC4Language` fetches the ref you ask for.
|
|
22
|
-
|
|
23
|
-
import grammar from './grammar/likec4.tmLanguage.json' with { type: 'json' };
|
|
24
|
-
import { resolveLikeC4Grammar } from './grammar/source.mjs';
|
|
25
|
-
import { LANGUAGE_ALIASES, LANGUAGE_NAME } from './grammar/textmate.mjs';
|
|
26
|
-
|
|
27
|
-
/** @type {import('shiki').LanguageRegistration} */
|
|
28
|
-
export const likec4Language = {
|
|
29
|
-
...grammar,
|
|
30
|
-
name: LANGUAGE_NAME,
|
|
31
|
-
aliases: [...LANGUAGE_ALIASES],
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Resolve the grammar from likec4/likec4 at the ref you ask for and return it
|
|
36
|
-
* as a Shiki language registration.
|
|
37
|
-
* @param {import('./grammar/source.mjs').GrammarSourceOptions} [options]
|
|
38
|
-
* @returns {Promise<import('shiki').LanguageRegistration>}
|
|
39
|
-
*/
|
|
40
|
-
export async function loadLikeC4Language(options) {
|
|
41
|
-
const { grammar: resolved } = await resolveLikeC4Grammar(options);
|
|
42
|
-
|
|
43
|
-
return { ...resolved, name: LANGUAGE_NAME, aliases: [...LANGUAGE_ALIASES] };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default likec4Language;
|