aktion-runtime 0.5.4 → 0.5.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.
Files changed (82) hide show
  1. package/README.md +206 -125
  2. package/dist/aktion.iife.js +106 -460
  3. package/dist/aktion.iife.js.map +1 -1
  4. package/dist/aktion.js +13612 -12644
  5. package/dist/aktion.js.map +1 -1
  6. package/dist/aktion.umd.cjs +106 -460
  7. package/dist/aktion.umd.cjs.map +1 -1
  8. package/dist/devtools.js +1367 -0
  9. package/dist/devtools.js.map +1 -0
  10. package/dist/{node/index-8OvnOYPI.js → language.js} +14789 -12298
  11. package/dist/language.js.map +1 -0
  12. package/dist/plugin.cjs +2660 -0
  13. package/dist/plugin.cjs.map +1 -0
  14. package/dist/plugin.js +2660 -0
  15. package/dist/plugin.js.map +1 -0
  16. package/dist/system_prompt.txt +200 -451
  17. package/dist/system_prompt_chat.txt +35 -85
  18. package/dist/testing.js +30190 -0
  19. package/dist/testing.js.map +1 -0
  20. package/dist/types/aktion-modules.d.ts +6 -10
  21. package/dist/types/compiler/index.d.ts +9 -11
  22. package/dist/types/compiler/linker.d.ts +11 -11
  23. package/dist/types/compiler/project.d.ts +45 -0
  24. package/dist/types/compiler/runtime.d.ts +22 -26
  25. package/dist/types/devtools/hook.d.ts +88 -0
  26. package/dist/types/devtools/index.d.ts +35 -0
  27. package/dist/types/devtools/panel.d.ts +109 -0
  28. package/dist/types/devtools/protocol.d.ts +130 -0
  29. package/dist/types/devtools/styles.d.ts +7 -0
  30. package/dist/types/element.d.ts +56 -25
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/language/builtins.d.ts +52 -0
  33. package/dist/types/language/index.d.ts +5 -2
  34. package/dist/types/language-api.d.ts +12 -8
  35. package/dist/types/library/components/helpers.d.ts +0 -5
  36. package/dist/types/library/components/wrappers.d.ts +1 -0
  37. package/dist/types/parser/types.d.ts +8 -9
  38. package/dist/types/plugin/index.d.ts +13 -6
  39. package/dist/types/renderer/renderer.d.ts +28 -0
  40. package/dist/types/runtime/builtins.d.ts +5 -11
  41. package/dist/types/runtime/effects.d.ts +16 -18
  42. package/dist/types/runtime/evaluator.d.ts +46 -5
  43. package/dist/types/runtime/http.d.ts +41 -1
  44. package/dist/types/runtime/index.d.ts +2 -1
  45. package/dist/types/runtime/router.d.ts +28 -2
  46. package/dist/types/runtime/toast.d.ts +45 -0
  47. package/dist/types/runtime/util.d.ts +11 -1
  48. package/dist/types/testing/index.d.ts +201 -0
  49. package/dist/types/theme/index.d.ts +3 -3
  50. package/dist/types/theme/styles.d.ts +1 -1
  51. package/dist/types/tooling/formatter.d.ts +7 -1
  52. package/dist/types/tooling/index.d.ts +6 -3
  53. package/dist/types/tooling/language-service.d.ts +10 -5
  54. package/dist/types/tooling/navigation.d.ts +91 -0
  55. package/dist/types/tooling/semantic-tokens.d.ts +24 -0
  56. package/dist/types/tooling/signature-help.d.ts +21 -0
  57. package/package.json +21 -19
  58. package/dist/node/compile-BUw0GAvN.cjs +0 -491
  59. package/dist/node/compile-BUw0GAvN.cjs.map +0 -1
  60. package/dist/node/compile-DxttTzo8.js +0 -492
  61. package/dist/node/compile-DxttTzo8.js.map +0 -1
  62. package/dist/node/compiler.cjs +0 -11
  63. package/dist/node/compiler.cjs.map +0 -1
  64. package/dist/node/compiler.js +0 -11
  65. package/dist/node/compiler.js.map +0 -1
  66. package/dist/node/index-8OvnOYPI.js.map +0 -1
  67. package/dist/node/index-DBgA3bHQ.cjs +0 -14069
  68. package/dist/node/index-DBgA3bHQ.cjs.map +0 -1
  69. package/dist/node/language.cjs +0 -1244
  70. package/dist/node/language.cjs.map +0 -1
  71. package/dist/node/language.js +0 -1244
  72. package/dist/node/language.js.map +0 -1
  73. package/dist/node/vite.cjs +0 -65
  74. package/dist/node/vite.cjs.map +0 -1
  75. package/dist/node/vite.js +0 -65
  76. package/dist/node/vite.js.map +0 -1
  77. package/dist/types/compiler/compile.d.ts +0 -54
  78. package/dist/types/compiler/emit.d.ts +0 -15
  79. package/dist/types/compiler/sourcemap.d.ts +0 -40
  80. package/dist/types/library/components/theme.d.ts +0 -2
  81. package/dist/types/plugin/vite.d.ts +0 -21
  82. package/dist/types/tooling/codemod.d.ts +0 -36
@@ -1 +0,0 @@
1
- {"version":3,"file":"language.js","sources":["../../src/language/grammar.ts","../../src/tooling/language-service.ts","../../src/language/snippets.ts","../../src/theme/index.ts","../../src/language/components.ts","../../src/language/index.ts"],"sourcesContent":["/**\n * Pure-data grammar description for Aktion.\n *\n * The grammar lives here as plain JSON-style data and a minimal stream\n * tokenizer factory. The stream tokenizer returned by\n * `createStreamTokenizer` matches the shape of CodeMirror 6's `StreamParser`\n * (`token`, `startState`, `copyState`), but it does NOT import CodeMirror or\n * any DOM API — so the same data drives Monaco, a VS Code TextMate grammar,\n * or any other editor.\n *\n * Token kinds are reported as semantic strings. Consumers map them to their\n * own highlight tags (CodeMirror's `tags`, Monaco's `TokenType`, etc.).\n */\n\nexport type GrammarTokenKind =\n | \"comment\" // // line and /* block */\n | \"string\" // \"double\" 'single' `backtick`\n | \"number\" // 12, -3.14\n | \"atom\" // true / false / null\n | \"keyword\" // function, if, else, for, switch, return, …\n | \"state\" // $variable\n | \"component\" // Capitalised identifier in call position\n | \"identifier\" // lowercase identifier\n | \"operator\" // +, -, *, /, ==, &&, …\n | \"punctuation\" // ( ) [ ] { } , : ?\n | \"loopvar\" // first segment of `row.name` / `params.id`\n | \"property\"; // segment after `.`\n\nexport interface GrammarSpec {\n name: \"aktion\";\n /** Literal atoms (true / false / null). */\n atoms: readonly string[];\n /** Reserved keywords that drive control flow and declarations. */\n keywords: readonly string[];\n /** Operators (longest-match first when tokenising). */\n operators: readonly string[];\n /** Two-character operators that must be matched before single chars. */\n operatorsLong: readonly string[];\n /** Brackets that must be balanced; useful for editor bracket matching. */\n brackets: ReadonlyArray<{ open: string; close: string }>;\n comments: {\n /** Primary line-comment introducer (used by editors for Ctrl+/ toggle). */\n line: string;\n blockStart: string;\n blockEnd: string;\n };\n strings: {\n /** Quote characters allowed for single-line escape-supporting strings. */\n singleLineQuotes: readonly string[];\n /** Quote character for multi-line raw strings (no escaping needed). */\n multiLineQuote: string;\n };\n identifier: {\n start: RegExp;\n part: RegExp;\n };\n /** Sigils that mark non-identifier categories. */\n sigils: {\n state: string;\n };\n}\n\nexport const grammarSpec: GrammarSpec = {\n name: \"aktion\",\n atoms: [\"true\", \"false\", \"null\", \"undefined\"],\n // Full reserved-word set, kept in sync with `KEYWORDS_AKTION` in\n // `src/parser/lexer.ts` plus the reserved top-level handle `aktion` and the\n // router handle `route`. Aktion's `$`-prefixed builtins (`$effect`, `$emit`,\n // …) lex as StateIdentifiers, so they are not in this keyword list. Every\n // entry is documented in `keywordDocs` so the playground can show a popup.\n keywords: [\n \"function\", \"if\", \"else\", \"switch\", \"case\", \"break\",\n \"continue\", \"for\", \"while\", \"do\", \"of\", \"in\", \"let\", \"var\", \"const\",\n \"await\", \"async\", \"return\", \"default\", \"try\", \"catch\", \"finally\",\n \"throw\", \"new\", \"typeof\", \"instanceof\", \"delete\", \"void\",\n \"aktion\", \"route\",\n ],\n operators: [\"+\", \"-\", \"*\", \"/\", \"%\", \"!\", \"=\", \"<\", \">\", \"?\", \":\", \".\", \",\"],\n // Long operators include `??` and `?.` (nullish coalescing + optional chain)\n // and `...` (spread). Order matters: longest match wins.\n operatorsLong: [\"...\", \"==\", \"!=\", \">=\", \"<=\", \"&&\", \"||\", \"??\", \"?.\"],\n brackets: [\n { open: \"(\", close: \")\" },\n { open: \"[\", close: \"]\" },\n { open: \"{\", close: \"}\" },\n ],\n comments: { line: \"//\", blockStart: \"/*\", blockEnd: \"*/\" },\n strings: {\n singleLineQuotes: ['\"', \"'\"],\n multiLineQuote: \"`\",\n },\n identifier: {\n start: /[A-Za-z_]/,\n part: /[A-Za-z0-9_]/,\n },\n sigils: { state: \"$\" },\n};\n\n/**\n * Documentation for a reserved keyword — surfaced by the language\n * service hover provider and the playground keyword-popup. Each entry\n * has a one-line `summary`, a `syntax` skeleton, and a runnable\n * `example` snippet.\n */\nexport interface KeywordDoc {\n /** One-line description of what the keyword does. */\n summary: string;\n /** Syntax skeleton, e.g. `if (condition) { … } else { … }`. */\n syntax: string;\n /** Short usage example. */\n example: string;\n}\n\n/**\n * Canonical explanations for every reserved word / top-level handle in\n * `grammarSpec.keywords`. Single source of truth shared by the language\n * service (`getHoverInfo`) and the playground keyword popups so the two\n * never drift. Keep this in sync with `grammarSpec.keywords`.\n */\nexport const keywordDocs: Record<string, KeywordDoc> = {\n aktion: {\n summary: \"Reserved entry-point binding — the root of the rendered UI tree.\",\n syntax: \"aktion = Component(...)\",\n example: 'aktion = Stack([Heading(\"Hi\"), Text(\"Welcome\")])',\n },\n route: {\n summary: \"Reactive router handle — exposes path, params, query, and navigate().\",\n syntax: \"route.path · route.params · route.query · route.navigate(path)\",\n example: 'Button(\"Home\", () => route.navigate(\"/\"))',\n },\n $emit: {\n summary: \"Dispatch a custom DOM event from the host element.\",\n syntax: '$emit(\"event-name\", detail)',\n example: 'Button(\"Save\", () => $emit(\"saved\", { id: $id }))',\n },\n function: {\n summary: \"Declare a component or action — first-letter case does not matter.\",\n syntax: \"function name(params) { ... }\",\n example: 'function Greeting(name) {\\n return Text(`Hello ${name}`)\\n}',\n },\n $effect: {\n summary: \"Run a side-effect when dependencies change (timers, fetch, analytics).\",\n syntax: \"$effect(() => { ... }, [deps])\",\n example: '$effect(() => {\\n $now = $util.now()\\n}, [\"every(1000)\"])',\n },\n if: {\n summary: \"Conditional statement — run a block when a condition is truthy.\",\n syntax: \"if (condition) { ... } else { ... }\",\n example: \"if (!$user) {\\n return Spinner()\\n}\",\n },\n else: {\n summary: \"Fallback branch executed when the matching `if` condition is falsy.\",\n syntax: \"if (condition) { ... } else { ... }\",\n example: 'if ($ok) { return Done() } else { return Retry() }',\n },\n switch: {\n summary: \"Multi-way branch on a value — pair each arm with `case` / `default`.\",\n syntax: \"switch (value) { case x: ...; default: ... }\",\n example: 'switch (tab) {\\n case \"list\": return List()\\n default: return Empty()\\n}',\n },\n case: {\n summary: \"A labelled arm inside a `switch` statement.\",\n syntax: \"case value: statements; break\",\n example: 'case \"grid\": return Grid($items)',\n },\n break: {\n summary: \"Exit the nearest enclosing loop or `switch` immediately.\",\n syntax: \"break\",\n example: \"for (let i = 0; i < n; i++) {\\n if (done) break\\n}\",\n },\n continue: {\n summary: \"Skip to the next iteration of the nearest enclosing loop.\",\n syntax: \"continue\",\n example: \"for (let x of items) {\\n if (!x.ok) continue\\n}\",\n },\n for: {\n summary: \"Loop — classic `for`, `for…of` (values), or `for…in` (keys).\",\n syntax: \"for (let i = 0; i < n; i++) { ... }\",\n example: \"for (let item of $items) {\\n log(item)\\n}\",\n },\n while: {\n summary: \"Loop while a condition stays truthy (checked before each pass).\",\n syntax: \"while (condition) { ... }\",\n example: \"while (i > 0) {\\n i = i - 1\\n}\",\n },\n do: {\n summary: \"Run a block once, then repeat while a condition holds.\",\n syntax: \"do { ... } while (condition)\",\n example: \"do {\\n step()\\n} while (hasMore)\",\n },\n of: {\n summary: \"Iterate the VALUES of an array/iterable in a `for…of` loop.\",\n syntax: \"for (let item of iterable) { ... }\",\n example: \"for (let row of $rows) { render(row) }\",\n },\n in: {\n summary: \"Iterate the KEYS of an object (`for…in`) or test key membership.\",\n syntax: 'for (let key in obj) { ... } · \"key\" in obj',\n example: 'for (let k in $config) { use(k) }',\n },\n let: {\n summary: \"Declare a block-scoped mutable variable (supports destructuring).\",\n syntax: \"let name = value · let [a, b] = arr · let { x } = obj\",\n example: \"let { name, age = 0 } = $user\",\n },\n var: {\n summary: \"Declare a variable (function-scoped) — `let` is preferred.\",\n syntax: \"var name = value\",\n example: \"var total = 0\",\n },\n const: {\n summary: \"Declare a block-scoped constant binding (supports destructuring).\",\n syntax: \"const name = value\",\n example: \"const [first, ...rest] = $items\",\n },\n await: {\n summary: \"Await a promise inside an action/effect body (or expression).\",\n syntax: \"await expression\",\n example: \"let res = await $http({ url: \\\"https://api.example.com\\\" })\",\n },\n async: {\n summary: \"Marks a function as async — accepted as a no-op modifier.\",\n syntax: \"async function name() { ... }\",\n example: \"async function load() {\\n let data = await fetch()\\n}\",\n },\n return: {\n summary: \"Return a value from a component / action / helper body.\",\n syntax: \"return expression\",\n example: 'return Card({ title: \"Done\" })',\n },\n default: {\n summary: \"The fallback arm of a `switch` (or wildcard route in Router).\",\n syntax: \"default: statements\",\n example: 'default: return NotFound()',\n },\n try: {\n summary: \"Run code that may throw, handling errors in a `catch` block.\",\n syntax: \"try { ... } catch (e) { ... } finally { ... }\",\n example: 'try {\\n risky()\\n} catch (e) {\\n log(e)\\n}',\n },\n catch: {\n summary: \"Handle an error thrown inside the preceding `try` block.\",\n syntax: \"catch (error) { ... }\",\n example: 'catch (e) { $error = e }',\n },\n finally: {\n summary: \"Run cleanup after `try` / `catch`, regardless of outcome.\",\n syntax: \"finally { ... }\",\n example: 'finally { $loading = false }',\n },\n throw: {\n summary: \"Raise an error — caught by an enclosing `try` / `catch`.\",\n syntax: \"throw value\",\n example: 'throw \"invalid state\"',\n },\n new: {\n summary: \"Construct an instance of a host class (Date, Map, Set, …).\",\n syntax: \"new Constructor(args)\",\n example: \"let now = new Date()\",\n },\n typeof: {\n summary: 'Return a string naming a value\\'s type (\"number\", \"string\", …).',\n syntax: \"typeof value\",\n example: 'if (typeof x === \"number\") { ... }',\n },\n instanceof: {\n summary: \"Test whether a value is an instance of a constructor.\",\n syntax: \"value instanceof Constructor\",\n example: \"if (d instanceof Date) { ... }\",\n },\n delete: {\n summary: \"Remove a property from an object.\",\n syntax: \"delete obj.prop\",\n example: \"delete $form.draft\",\n },\n void: {\n summary: \"Evaluate an expression and yield `undefined`.\",\n syntax: \"void expression\",\n example: \"void sideEffect()\",\n },\n};\n\n/**\n * Mutable state carried by the stream tokenizer between calls. We track the\n * unclosed multi-line constructs (backtick strings, block comments).\n */\nexport interface StreamState {\n inBacktick: boolean;\n inBlockComment: boolean;\n}\n\nexport interface StreamLike {\n /** True at column 0 of a line (CodeMirror exposes `stream.sol()`). */\n sol(): boolean;\n /** Returns next char without consuming. */\n peek(): string | null | undefined;\n /** Consume and return the next char, advancing the stream. */\n next(): string | undefined;\n /** Consume while the predicate matches. */\n eatWhile(test: RegExp | ((ch: string) => boolean)): boolean;\n /** Consume one char if it matches; returns whether it consumed. */\n eat(test: string | RegExp | ((ch: string) => boolean)): string | undefined;\n /**\n * Consume everything up to (and optionally including) the given string or\n * regex. CodeMirror's `skipTo` matches the string in the rest of the line.\n * We rely only on `match(string, consume?)` which is available in CM6.\n */\n match(pattern: string | RegExp, consume?: boolean): boolean | RegExpMatchArray | null;\n /** Skip to end of line. */\n skipToEnd(): void;\n /** True at end of line. */\n eol(): boolean;\n}\n\nexport interface StreamTokenizer {\n startState(): StreamState;\n copyState(state: StreamState): StreamState;\n token(stream: StreamLike, state: StreamState): GrammarTokenKind | null;\n /**\n * Language metadata that CodeMirror's `StreamLanguage.define(...)` will pick\n * up — comment style and bracket pairs for auto-pairing.\n */\n languageData: {\n commentTokens: { line: string; block: { open: string; close: string } };\n closeBrackets: { brackets: readonly string[] };\n indentOnInput: RegExp;\n };\n}\n\n/**\n * Lookahead tokenizer driven by `grammarSpec`. Suitable for\n * `StreamLanguage.define(...)` in CodeMirror 6, but framework-agnostic.\n */\nexport function createStreamTokenizer(spec: GrammarSpec = grammarSpec): StreamTokenizer {\n const startState = (): StreamState => ({ inBacktick: false, inBlockComment: false });\n const copyState = (state: StreamState): StreamState => ({ ...state });\n\n const atomSet = new Set(spec.atoms);\n const keywordSet = new Set(spec.keywords);\n const componentCallRe = /^[A-Z][A-Za-z0-9_]*/;\n const lowerIdentRe = /^[a-z_][A-Za-z0-9_]*/;\n const numberRe = /^-?\\d+(?:\\.\\d+)?/;\n const operatorChars = new Set([...spec.operators.join(\"\"), ...\"=<>!&|\"]);\n\n const consumeStringBody = (stream: StreamLike, quote: string): void => {\n while (!stream.eol()) {\n const ch = stream.next();\n if (!ch) return;\n if (ch === \"\\\\\") {\n stream.next();\n continue;\n }\n if (ch === quote) return;\n }\n };\n\n const token = (stream: StreamLike, state: StreamState): GrammarTokenKind | null => {\n // Resume open multi-line constructs.\n if (state.inBacktick) {\n while (!stream.eol()) {\n const ch = stream.next();\n if (ch === \"\\\\\") { stream.next(); continue; }\n if (ch === \"`\") { state.inBacktick = false; return \"string\"; }\n }\n return \"string\";\n }\n if (state.inBlockComment) {\n while (!stream.eol()) {\n if (stream.match(spec.comments.blockEnd, true)) {\n state.inBlockComment = false;\n return \"comment\";\n }\n stream.next();\n }\n return \"comment\";\n }\n\n // Skip whitespace.\n if (stream.eatWhile(/[ \\t]/)) return null;\n\n if (stream.match(spec.comments.line, true)) {\n stream.skipToEnd();\n return \"comment\";\n }\n if (stream.match(spec.comments.blockStart, true)) {\n state.inBlockComment = true;\n while (!stream.eol()) {\n if (stream.match(spec.comments.blockEnd, true)) {\n state.inBlockComment = false;\n return \"comment\";\n }\n stream.next();\n }\n return \"comment\";\n }\n\n const next = stream.peek();\n if (next === null || next === undefined) return null;\n\n // Strings.\n if (spec.strings.singleLineQuotes.includes(next)) {\n const quote = next;\n stream.next();\n consumeStringBody(stream, quote);\n return \"string\";\n }\n if (next === spec.strings.multiLineQuote) {\n stream.next();\n while (!stream.eol()) {\n const ch = stream.next();\n if (ch === \"\\\\\") { stream.next(); continue; }\n if (ch === \"`\") return \"string\";\n }\n state.inBacktick = true;\n return \"string\";\n }\n\n // Numbers (also matches `-1`, `-3.14`).\n if (next >= \"0\" && next <= \"9\") {\n if (stream.match(numberRe, true)) return \"number\";\n }\n if (next === \"-\" && stream.match(/^-\\d+(?:\\.\\d+)?/, false)) {\n if (stream.match(numberRe, true)) return \"number\";\n }\n\n // Sigil-prefixed identifiers.\n if (next === spec.sigils.state) {\n stream.next();\n // Legacy `$$name` is a hard error in Aktion 0.5; the\n // tokenizer still highlights both `$`s as one `state` token so the\n // user sees a single red squiggle pointing at the migration site\n // instead of two unrelated tokens.\n if (stream.peek() === spec.sigils.state) stream.next();\n stream.eatWhile(spec.identifier.part);\n return \"state\";\n }\n\n // Identifiers + atoms + component calls + property access.\n if (spec.identifier.start.test(next)) {\n const upper = stream.match(componentCallRe, true);\n if (upper) {\n return \"component\";\n }\n const lower = stream.match(lowerIdentRe, true);\n if (lower) {\n const text = (lower as RegExpMatchArray)[0];\n if (atomSet.has(text)) return \"atom\";\n if (keywordSet.has(text)) return \"keyword\";\n const ahead = stream.peek();\n if (ahead === \".\") return \"loopvar\";\n return \"identifier\";\n }\n }\n\n // Multi-char operators.\n for (const op of spec.operatorsLong) {\n if (stream.match(op, true)) return \"operator\";\n }\n\n // Property access: `.name`.\n if (next === \".\") {\n stream.next();\n if (stream.peek() && spec.identifier.start.test(stream.peek() as string)) {\n stream.eatWhile(spec.identifier.part);\n return \"property\";\n }\n return \"punctuation\";\n }\n\n // Brackets / commas / colons / question.\n if (\"()[]{},:?\".includes(next)) {\n stream.next();\n return \"punctuation\";\n }\n\n // Single-char operators.\n if (operatorChars.has(next)) {\n stream.next();\n return \"operator\";\n }\n\n stream.next();\n return null;\n };\n\n return {\n startState,\n copyState,\n token,\n languageData: {\n commentTokens: { line: spec.comments.line, block: { open: spec.comments.blockStart, close: spec.comments.blockEnd } },\n closeBrackets: { brackets: [\"(\", \"[\", \"{\", '\"', \"'\", \"`\"] },\n indentOnInput: /^\\s*[)\\]}]$/,\n },\n };\n}\n\n/**\n * Default mapping from grammar token kinds to CodeMirror highlight tag names.\n *\n * Returned as plain strings so consumers can resolve them to whatever their\n * highlighter understands. We keep `tagName: string | null` so consumers may\n * skip a kind entirely (e.g. punctuation is often left unhighlighted).\n */\nexport const defaultTagMap: Record<GrammarTokenKind, string | null> = {\n comment: \"comment\",\n string: \"string\",\n number: \"number\",\n atom: \"atom\",\n keyword: \"keyword\",\n state: \"variableName.special\",\n component: \"typeName\",\n identifier: \"variableName\",\n loopvar: \"variableName.local\",\n property: \"propertyName\",\n operator: \"operator\",\n punctuation: null,\n};\n","/**\n * Aktion 0.5 §27 — minimal in-process language service.\n *\n * Goal: ship the *data* a Language Server Protocol (LSP) implementation\n * would need — completions, diagnostics, hover info — as a pure\n * JSON-friendly API. A real LSP server can wrap these calls behind a\n * WebSocket / stdio transport; library consumers can also use them\n * directly inside in-browser editors.\n *\n * Surface\n * -------\n *\n * - `getDiagnostics(source, library)` — every parse + schema error.\n * - `getCompletions(source, position, library)` — component names,\n * known prop names for the call site under the cursor, and state-tier\n * keywords.\n * - `getHoverInfo(source, position, library)` — the description /\n * signature for the symbol under the cursor.\n *\n * Why not a real LSP? Network/process plumbing for a full LSP is an\n * order of magnitude more code than the language service it would wrap.\n * Shipping the projection makes the surface available to every host\n * today (LSP wrapper is straightforward when needed).\n */\n\nimport { parse } from \"../parser/index.js\";\nimport type { ComponentLibrary, ComponentSpec, PropSpec } from \"../library/types.js\";\nimport { findComponent } from \"../library/registry.js\";\nimport { validateProgramSchema } from \"../library/validate.js\";\nimport { findPositionalProp } from \"../library/types.js\";\nimport { keywordDocs, type KeywordDoc } from \"../language/grammar.js\";\n\nexport interface Position {\n /** 1-indexed line number. */\n line: number;\n /** 1-indexed column number. */\n column: number;\n}\n\nexport interface Diagnostic {\n line: number;\n column: number;\n message: string;\n /** `error` when the program will not render; `warning` is reserved for the future. */\n severity: \"error\" | \"warning\";\n}\n\nexport interface CompletionItem {\n /** Insertion text (the user types this to accept). */\n label: string;\n /**\n * What kind of symbol this is. Useful when the host wants to render\n * different icons per kind (LSP / editor UIs typically display these).\n */\n kind:\n | \"component\"\n | \"prop\"\n | \"state\"\n | \"builtin\"\n | \"keyword\";\n /** Short textual description. */\n detail?: string;\n /** Long-form documentation surfaced in a tooltip. */\n documentation?: string;\n}\n\nexport interface HoverInfo {\n /** Markdown-friendly text rendered in the hover popup. */\n contents: string;\n /** Symbol kind for clients that prefer typed surfaces. */\n kind: \"component\" | \"prop\" | \"state\" | \"builtin\" | \"unknown\";\n}\n\nconst KEYWORDS: ReadonlyArray<{ label: string; detail: string }> = [\n { label: \"function\", detail: \"Declare a component or action — either case works\" },\n { label: \"$effect\", detail: \"Reactive side-effect: $effect(() => { ... }, [deps])\" },\n { label: \"$router\", detail: \"pages = $router({ '/': Home(), default: NotFound() })\" },\n { label: \"switch\", detail: \"switch (value) { case …: …; break; default: … }\" },\n { label: \"for\", detail: \"for (let x of xs) { … }\" },\n { label: \"if\", detail: \"if (condition) { … } else { … }\" },\n { label: \"return\", detail: \"Return value from a component or action\" },\n { label: \"let\", detail: \"Declare a variable (reactive if $-prefixed)\" },\n { label: \"const\", detail: \"Declare a constant\" },\n { label: \"$emit\", detail: \"$emit('name', detail) — dispatch a CustomEvent\" },\n { label: \"cleanup\", detail: \"Register an effect teardown callback\" },\n];\n\n/**\n * Combine parse-level + schema-level diagnostics into one list. Every\n * entry has a `severity` field so editors can theme errors vs warnings\n * (in 0.5 every entry is currently `error` — there are no soft\n * warnings — but the surface stays future-proof).\n */\nexport function getDiagnostics(\n source: string,\n library: ComponentLibrary,\n): Diagnostic[] {\n const program = parse(source);\n const schemaErrors = validateProgramSchema(program, library);\n return [\n ...program.errors.map((e) => ({\n line: e.line,\n column: e.column,\n message: e.message,\n severity: \"error\" as const,\n })),\n ...schemaErrors.map((e) => ({\n line: e.line,\n column: e.column,\n message: e.message,\n severity: \"error\" as const,\n })),\n ];\n}\n\n/**\n * Completion items for the cursor position `position`. Heuristics are\n * intentionally simple — the prompt + the closed schema (§16) make\n * deep static analysis unnecessary:\n *\n * - Inside `(...)` after a known component name → the spec's prop\n * names (filtered to unconsumed props).\n * - After `$` → state-tier keywords (`$state`, `$persist`, …).\n * - At top of line / inside a block → top-level keywords + the\n * full library component list.\n */\nexport function getCompletions(\n source: string,\n position: Position,\n library: ComponentLibrary,\n): CompletionItem[] {\n const ctx = analyseCursor(source, position);\n\n // After `$` — surface the reactive-atom hint plus the built-in hooks\n // (`$state` / `$memo`), which also start with the `$` sigil.\n if (ctx.afterDollar) {\n return [\n { label: \"$name = value\", kind: \"state\" as const, detail: \"Declare or assign a reactive atom\" },\n { label: \"$state(initial)\", kind: \"builtin\" as const, detail: \"Hook: per-instance state → [value, setValue] (like useState)\" },\n { label: \"$memo(() => value, [deps])\", kind: \"builtin\" as const, detail: \"Hook: value recomputed only when deps change (like useMemo)\" },\n { label: \"$effect(() => {}, [deps])\", kind: \"builtin\" as const, detail: \"Declarative side effect\" },\n { label: \"$store({ ...state, ...methods })\", kind: \"builtin\" as const, detail: \"Global store: shared state + actions\" },\n { label: \"$http({ url, method, ... })\", kind: \"builtin\" as const, detail: \"Reactive HTTP resource\" },\n { label: \"$router({ '/': Home(), default: NotFound() })\", kind: \"builtin\" as const, detail: \"Outlet-first router\" },\n { label: \"$util\", kind: \"builtin\" as const, detail: \"Runtime helper namespace ($util.format, $util.sum, …)\" },\n { label: \"$emit('name', detail)\", kind: \"builtin\" as const, detail: \"Dispatch a CustomEvent\" },\n { label: \"$theme({ colors, radius, ... })\", kind: \"builtin\" as const, detail: \"In-script theme override\" },\n { label: \"$storage\", kind: \"builtin\" as const, detail: \"Persistent storage namespace ($storage.local, …)\" },\n { label: \"$console\", kind: \"builtin\" as const, detail: \"Console namespace ($console.log, …)\" },\n { label: \"$i18n({ translations, ... })\", kind: \"builtin\" as const, detail: \"Translation bundle\" },\n ];\n }\n\n // Inside a call's `(...)` argument list for a known component.\n if (ctx.insideCall && ctx.callee) {\n const spec = findComponent(library, ctx.callee);\n if (spec) {\n return propCompletions(spec);\n }\n }\n\n // Default: top-level keywords + all library component names. We merge\n // the curated `KEYWORDS` (which include non-reserved helpers like\n // `Router` / `cleanup`) with the full reserved-word set from\n // `keywordDocs`, de-duplicated by label.\n const keywordItems = new Map<string, CompletionItem>();\n for (const [label, doc] of Object.entries(keywordDocs)) {\n keywordItems.set(label, {\n label,\n kind: \"keyword\",\n detail: doc.summary,\n documentation: `${doc.syntax}\\n\\n${doc.example}`,\n });\n }\n for (const k of KEYWORDS) {\n if (!keywordItems.has(k.label)) {\n keywordItems.set(k.label, { label: k.label, kind: \"keyword\", detail: k.detail });\n }\n }\n return [\n ...keywordItems.values(),\n ...library.components.map((c) => ({\n label: c.name,\n kind: \"component\" as const,\n detail: signaturePreview(c),\n documentation: c.description,\n })),\n ];\n}\n\n/**\n * Hover info for the symbol under the cursor. Returns `null` when the\n * cursor is not over a recognised symbol.\n */\nexport function getHoverInfo(\n source: string,\n position: Position,\n library: ComponentLibrary,\n): HoverInfo | null {\n const word = wordAt(source, position);\n if (!word) return null;\n const spec = findComponent(library, word);\n if (spec) {\n return {\n kind: \"component\",\n contents:\n `**${spec.name}** — ${spec.description ?? \"Component.\"}\\n\\n` +\n `Signature: \\`${signaturePreview(spec)}\\``,\n };\n }\n if (word === \"$state\") {\n return { kind: \"builtin\", contents: \"**$state(initial)** — hook returning `[value, setValue]` (per-instance state, like React's useState)\" };\n }\n if (word === \"$memo\") {\n return { kind: \"builtin\", contents: \"**$memo(() => value, [deps])** — hook returning a value recomputed only when a dependency changes (like React's useMemo)\" };\n }\n if (word.startsWith(\"$\")) {\n return { kind: \"state\", contents: `**${word}** — reactive state atom` };\n }\n // Reserved-word hover: rich definition + syntax + example from the\n // shared keyword docs (single source of truth in `grammar.ts`).\n const doc = keywordDocs[word];\n if (doc) {\n return { kind: \"unknown\", contents: formatKeywordHover(word, doc) };\n }\n const kw = KEYWORDS.find((k) => k.label === word);\n if (kw) {\n return { kind: \"unknown\", contents: `**${word}** — ${kw.detail}` };\n }\n return null;\n}\n\n/** Render a keyword's docs as Markdown (definition, syntax, example). */\nfunction formatKeywordHover(word: string, doc: KeywordDoc): string {\n return (\n `**${word}** — ${doc.summary}\\n\\n` +\n `**Syntax**\\n\\n\\`\\`\\`js\\n${doc.syntax}\\n\\`\\`\\`\\n\\n` +\n `**Example**\\n\\n\\`\\`\\`js\\n${doc.example}\\n\\`\\`\\``\n );\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ninterface CursorContext {\n /** Caller name when the cursor sits inside `Caller(...)`. */\n callee?: string;\n /** True when the cursor is past `(` and before the matching `)`. */\n insideCall: boolean;\n /** True when the previous non-whitespace token is `$` — user typing a tier. */\n afterDollar: boolean;\n}\n\nfunction analyseCursor(source: string, position: Position): CursorContext {\n const offset = lineColumnToOffset(source, position);\n const prefix = source.slice(0, offset);\n\n const afterDollar = /\\$[A-Za-z_]*$/.test(prefix);\n\n // Walk backwards from the cursor to find an unbalanced `(`. If we\n // find one, capture the identifier (or `Caller(`-style) that\n // precedes it.\n let depth = 0;\n let openCallIdx = -1;\n for (let i = prefix.length - 1; i >= 0; i -= 1) {\n const ch = prefix[i]!;\n if (ch === \")\") depth += 1;\n else if (ch === \"(\") {\n if (depth === 0) { openCallIdx = i; break; }\n depth -= 1;\n }\n }\n let callee: string | undefined;\n let insideCall = false;\n if (openCallIdx > 0) {\n insideCall = true;\n const upto = prefix.slice(0, openCallIdx);\n const m = /([A-Za-z_][\\w]*)\\s*$/.exec(upto);\n if (m) callee = m[1];\n }\n\n return { callee, insideCall, afterDollar };\n}\n\nfunction propCompletions(spec: ComponentSpec): CompletionItem[] {\n const positional = findPositionalProp(spec);\n return spec.props.map((prop) => ({\n label: `${prop.name}:`,\n kind: \"prop\" as const,\n detail: propDetail(prop, positional?.name === prop.name),\n documentation: prop.description,\n }));\n}\n\nfunction propDetail(prop: PropSpec, isPositional: boolean): string {\n const tags: string[] = [];\n if (isPositional) tags.push(\"positional\");\n if (prop.required) tags.push(\"required\");\n if (prop.enum) tags.push(`enum: ${prop.enum.map((e) => `\"${e}\"`).join(\" | \")}`);\n const tagText = tags.length > 0 ? ` (${tags.join(\", \")})` : \"\";\n return `${prop.type}${tagText}`;\n}\n\nfunction signaturePreview(spec: ComponentSpec): string {\n const positional = findPositionalProp(spec);\n const positionalLabel = positional ? positional.name : \"\";\n const rest = spec.props\n .filter((p) => p.name !== positional?.name)\n .map((p) => `${p.name}${p.optional || !p.required ? \"?\" : \"\"}: ${p.type}`)\n .join(\", \");\n if (positionalLabel === \"\" && rest === \"\") return `${spec.name}()`;\n if (positionalLabel === \"\") return `${spec.name}(${rest})`;\n if (rest === \"\") return `${spec.name}(${positionalLabel})`;\n return `${spec.name}(${positionalLabel}, ${rest})`;\n}\n\nfunction lineColumnToOffset(source: string, pos: Position): number {\n let line = 1;\n let col = 1;\n for (let i = 0; i < source.length; i += 1) {\n if (line === pos.line && col === pos.column) return i;\n if (source[i] === \"\\n\") {\n line += 1;\n col = 1;\n } else {\n col += 1;\n }\n }\n return source.length;\n}\n\nfunction wordAt(source: string, pos: Position): string | null {\n const offset = lineColumnToOffset(source, pos);\n // Expand left + right while we're on a word/identifier-like char.\n const isWord = (c: string): boolean => /[\\w$]/.test(c);\n let start = offset;\n while (start > 0 && isWord(source[start - 1]!)) start -= 1;\n let end = offset;\n while (end < source.length && isWord(source[end]!)) end += 1;\n if (start === end) return null;\n return source.slice(start, end);\n}\n","/**\n * Snippet templates for common Aktion composites.\n *\n * Placeholders use `${1:label}` syntax. CodeMirror's `snippet()` from\n * `@codemirror/autocomplete` parses this format natively. Monaco and VS\n * Code do too (it matches the LSP snippet format).\n */\n\nexport interface SnippetEntry {\n /** Snippet key — used as the autocomplete completion label. */\n name: string;\n /** Human-readable description shown in the autocomplete popup. */\n description: string;\n /** The template body with `${n:label}` placeholders. */\n template: string;\n}\n\nexport const snippetCatalog: readonly SnippetEntry[] = [\n {\n name: \"App\",\n description: \"Top-level `aktion` binding — every program needs one.\",\n template:\n 'aktion = Column([\\n' +\n ' ${1:Card([CardHeader(\"${2:Hello}\")])}\\n' +\n '])',\n },\n {\n name: \"Card\",\n description: \"Card with header + body block.\",\n template:\n 'card${1} = Card([\\n' +\n ' CardHeader(\"${2:Title}\", { subtitle: \"${3:Subtitle}\" }),\\n' +\n ' Column([\\n' +\n ' Text(\"${4:Body copy goes here.}\")\\n' +\n ' ])\\n' +\n '])',\n },\n {\n name: \"Row\",\n description: \"Horizontal toolbar — label on the left, actions pushed to the right.\",\n template:\n 'toolbar${1} = Row([\\n' +\n ' Text(\"${2:Section title}\", { variant: \"large-heavy\" }),\\n' +\n ' Spacer(),\\n' +\n ' Button(\"${3:Action}\", { variant: \"primary\" })\\n' +\n '], { gap: \"m\" })',\n },\n {\n name: \"Center\",\n description: \"Center content on both axes inside a tall region.\",\n template:\n 'empty${1} = Center([\\n' +\n ' EmptyState(\"${2:Nothing here yet}\", { description: \"${3:Create your first item to get started.}\" })\\n' +\n '], { minHeight: \"${4:50vh}\" })',\n },\n {\n name: \"Hero\",\n description: \"Landing-page hero with eyebrow, title, subtitle, and a CTA.\",\n template:\n 'function ${4:start}() { route.navigate(\"/start\") }\\n' +\n 'function ${5:openDemo}() { route.navigate(\"/demo\") }\\n' +\n 'hero${1} = Hero(\\n' +\n ' \"${2:Ship faster}\",\\n' +\n ' { subtitle: \"${3:From idea to production in minutes.}\",\\n' +\n ' primary: Button(\"${6:Get started}\", { action: ${4:start}, variant: \"primary\" }),\\n' +\n ' secondary: Button(\"${7:Live demo}\", { action: ${5:openDemo}, variant: \"ghost\" }),\\n' +\n ' eyebrow: \"${8:v2 launch}\" }\\n' +\n ')',\n },\n {\n name: \"PageHeader\",\n description: \"Dashboard page header with breadcrumbs and actions.\",\n template:\n 'function ${6:runAction}() { /* TODO: implement */ }\\n' +\n 'header${1} = PageHeader(\\n' +\n ' \"${2:Page title}\",\\n' +\n ' { subtitle: \"${3:Subtitle / meta line}\",\\n' +\n ' breadcrumbs: [\"${4:Workspace}\", \"${5:Section}\"],\\n' +\n ' actions: [Button(\"${7:Action}\", { action: ${6:runAction}, variant: \"primary\" })],\\n' +\n ' status: Badge(\"${8:On track}\", { variant: \"success\" }) }\\n' +\n ')',\n },\n {\n name: \"Stats\",\n description: \"Responsive KPI strip with four StatCards.\",\n template:\n 'metrics${1} = Stats([\\n' +\n ' StatCard(\"${2:Active}\", { value: \"${3:12}\", trend: \"flat\" }),\\n' +\n ' StatCard(\"${4:At risk}\", { value: \"${5:4}\", trend: \"up\", delta: \"+2\" }),\\n' +\n ' StatCard(\"${6:Shipped}\", { value: \"${7:8}\", trend: \"up\", delta: \"+3\" }),\\n' +\n ' StatCard(\"${8:On-time}\", { value: \"${9:87%}\", trend: \"down\", delta: \"-3%\" })\\n' +\n '])',\n },\n {\n name: \"GridLayout\",\n description: \"12-column sidebar layout with named GridItem spans.\",\n template:\n 'sidebar${1} = Card([CardHeader(\"${2:Sidebar}\")])\\n' +\n 'main${1} = Card([CardHeader(\"${3:Main}\")])\\n' +\n 'aktion = Grid([\\n' +\n ' GridItem(sidebar${1}, { span: \"1/4\" }),\\n' +\n ' GridItem(main${1}, { span: \"3/4\" })\\n' +\n '], { columns: 12, gap: \"l\" })',\n },\n {\n name: \"KanbanBoard\",\n description: \"Three-column kanban board with sample cards.\",\n template:\n 'board${1} = KanbanBoard([\\n' +\n ' KanbanColumn(\"To do\", { items: [\\n' +\n ' KanbanCard(\"${2:Migrate auth}\", { description: \"${3:Roll out the new SDK.}\", tags: [\"auth\"], assignee: \"${4:Asha}\" })\\n' +\n ' ] }),\\n' +\n ' KanbanColumn(\"Doing\", { items: [\\n' +\n ' KanbanCard(\"${5:Streaming UI v2}\", { description: \"${6:Ship 20 new components.}\", tags: [\"frontend\"], assignee: \"${7:Alex}\", tone: \"primary\" })\\n' +\n ' ] }),\\n' +\n ' KanbanColumn(\"Done\", { items: [\\n' +\n ' KanbanCard(\"${8:Activity timeline}\", { description: \"${9:Shipped to 100%.}\", tags: [\"shipped\"], assignee: \"${10:Mira}\", tone: \"success\" })\\n' +\n ' ] })\\n' +\n '])',\n },\n {\n name: \"FollowUpBlock\",\n description: \"Chat follow-up prompts.\",\n template:\n 'follow${1} = FollowUpBlock([\\n' +\n ' FollowUpItem(\"${2:Show me a chart}\"),\\n' +\n ' FollowUpItem(\"${3:Add a filter}\"),\\n' +\n ' FollowUpItem(\"${4:Export as CSV}\")\\n' +\n '])',\n },\n {\n name: \"Router\",\n description: \"Multi-page router via $router({…}) with NavLink sidebar.\",\n template:\n 'pages = $router({\\n' +\n ' \"/\": HomePage(),\\n' +\n ' \"/dashboard\": DashboardPage(),\\n' +\n ' \"/users/:id\": UserPage(params.id),\\n' +\n ' \"/docs/*\": DocsPage(params._),\\n' +\n ' default: NotFoundPage()\\n' +\n '})\\n\\n' +\n 'function HomePage() {\\n' +\n ' return Card([CardHeader(\"Welcome\")])\\n' +\n '}\\n' +\n 'function DashboardPage() {\\n' +\n ' return Card([CardHeader(\"Dashboard\")])\\n' +\n '}\\n' +\n 'function UserPage(id) {\\n' +\n ' return Card([CardHeader(`User ${id}`)])\\n' +\n '}\\n' +\n 'function DocsPage(rest) {\\n' +\n ' return Card([CardHeader(`Docs · ${rest}`)])\\n' +\n '}\\n' +\n 'function NotFoundPage() {\\n' +\n ' return Callout(\"Not found\", { variant: \"warning\", description: `We couldn\\'t find ${route.path}.` })\\n' +\n '}\\n\\n' +\n 'nav${1} = Row([\\n' +\n ' NavLink(\"Home\", { to: \"/\", variant: \"ghost\", exact: true }),\\n' +\n ' NavLink(\"Dashboard\", { to: \"/dashboard\", variant: \"ghost\" }),\\n' +\n ' NavLink(\"Users\", { to: \"/users\", variant: \"ghost\" })\\n' +\n '], { gap: \"s\" })',\n },\n {\n name: \"Effect\",\n description: \"Lifecycle-managed effect (clock/interval) with cleanup.\",\n template:\n '$${3:now} = \"\"\\n\\n' +\n '$effect(() => {\\n' +\n ' let id = setInterval(() => { $${3:now} = new Date().toISOString() }, 1000)\\n' +\n ' cleanup(() => clearInterval(id))\\n' +\n '}, [\"mount\"])\\n\\n' +\n 'body = Text($${3:now})',\n },\n {\n name: \"Action\",\n description: \"Action declaration that POSTs through the $http() builtin.\",\n template:\n '$${1:items} = []\\n\\n' +\n 'function add(text) {\\n' +\n ' $${1:items} = [...$${1:items}, { id: $${1:items}.length + 1, text: text }]\\n' +\n ' $response = $http({ url: \"https://api.example.com/save\", method: \"POST\", body: { item: { text: text } } })\\n' +\n '}',\n },\n {\n name: \"MapList\",\n description: \"Map an array of items into a list of components using `.map`.\",\n template:\n 'list${1} = $items.map(item => Card([Text(item.${2:name})]))',\n },\n {\n name: \"ForLoop\",\n description: \"Iterate over an array statement-style — usable in a function body.\",\n template:\n 'function build${1:List}() {\\n' +\n ' let out = []\\n' +\n ' for (let item of $items) {\\n' +\n ' out.push(Card([Text(item.${2:name})]))\\n' +\n ' }\\n' +\n ' return Column(out)\\n' +\n '}',\n },\n {\n name: \"FormReactive\",\n description: \"Two-way bound input with submit action.\",\n template:\n '$draft = \"\"\\n' +\n '$items = []\\n\\n' +\n 'function add() {\\n' +\n ' $items = [...$items, { id: $items.length + 1, text: $draft }]\\n' +\n ' $draft = \"\"\\n' +\n '}\\n\\n' +\n 'form${1} = Column([\\n' +\n ' Input(\"${2:draft}\", { placeholder: \"What needs doing?\", type: \"text\", value: $draft }),\\n' +\n ' Button(\"Add\", { action: add, variant: \"primary\" })\\n' +\n '])',\n },\n {\n name: \"Theme\",\n description: \"Brand-style theme override applied on top of the base theme.\",\n template:\n 'theme = $theme({\\n' +\n ' name: \"${1:brand}\",\\n' +\n ' colors: {\\n' +\n ' primary: \"${2:#0969da}\",\\n' +\n ' primaryHover: \"${3:#0860c4}\",\\n' +\n ' bg: \"${4:#ffffff}\",\\n' +\n ' text: \"${5:#1f2328}\"\\n' +\n ' },\\n' +\n ' radius: { button: \"${6:6px}\", input: \"${7:6px}\" },\\n' +\n ' font: {\\n' +\n ' family: \"${8:-apple-system, BlinkMacSystemFont, sans-serif}\",\\n' +\n ' heading: \"${9:-apple-system, BlinkMacSystemFont, sans-serif}\"\\n' +\n ' }\\n' +\n '})',\n },\n {\n name: \"Component\",\n description: \"Reusable component declaration — first-letter case is not significant; a function with no `return` simply renders nothing.\",\n template:\n 'function ${1:UserCard}(${2:user}) {\\n' +\n ' return Card([\\n' +\n ' Avatar(${2:user}.name),\\n' +\n ' Text(${2:user}.role)\\n' +\n ' ])\\n' +\n '}\\n\\n' +\n 'list = $users.map(u => ${1:UserCard}(u))',\n },\n {\n name: \"Ternary\",\n description: \"Pick between two expressions — the JS way to express a value-producing if.\",\n template:\n 'body${1} = ${2:condition} ? ${3:trueBranch} : ${4:falseBranch}',\n },\n {\n name: \"IfStatement\",\n description: \"Imperative `if (cond) { … } else { … }` — usable inside function / effect bodies.\",\n template:\n 'if (${1:condition}) {\\n' +\n ' ${2:// then branch}\\n' +\n '} else {\\n' +\n ' ${3:// else branch}\\n' +\n '}',\n },\n {\n name: \"SwitchStatement\",\n description: \"Switch on a value with case/default/break — statement form.\",\n template:\n 'switch (${1:$tab}) {\\n' +\n ' case \"overview\": ${2:// …}; break\\n' +\n ' case \"billing\": ${3:// …}; break\\n' +\n ' case \"security\": ${4:// …}; break\\n' +\n ' default: ${5:// …}\\n' +\n '}',\n },\n {\n name: \"TemplateLiteral\",\n description: \"Template literal with `${}` interpolation.\",\n template: 'greeting${1} = `Hello ${${2:$user.name}}, you have ${${3:$messages.length}} messages`',\n },\n {\n name: \"Http\",\n description: \"Fire an $http() request and bind the reactive resource bag.\",\n template:\n '$${1:response} = $http({\\n' +\n ' url: \"${2:https://api.example.com/items}\",\\n' +\n ' method: \"${3:GET}\",\\n' +\n ' headers: { \"Content-Type\": \"application/json\" }\\n' +\n '})',\n },\n {\n name: \"State\",\n description: \"Reactive state atom — declared with `$name = value`.\",\n template: '$${1:name} = ${2:\"default\"}',\n },\n {\n name: \"Store\",\n description: \"Global store — colocated state + actions shared across components (like Zustand/Pinia).\",\n template:\n '${1:cart} = $store({\\n' +\n ' ${2:items}: [],\\n' +\n ' ${3:count}: (s) => s.${2:items}.length,\\n' +\n ' ${4:add}: (s, item) => { s.${2:items} = [...s.${2:items}, item] },\\n' +\n '})',\n },\n {\n name: \"useState\",\n description: \"`$state` hook — per-instance state with a [value, setValue] pair (like React's useState).\",\n template: 'const [${1:value}, set${2:Value}] = $state(${3:\"default\"})',\n },\n {\n name: \"useMemo\",\n description: \"`$memo` hook — value recomputed only when a dependency changes (like React's useMemo).\",\n template: 'const ${1:memoized} = $memo(() => ${2:compute}, [${3:deps}])',\n },\n {\n name: \"Hook\",\n description: \"Custom hook declaration — a `$`-prefixed function that composes $state / $memo.\",\n template:\n 'function $use${1:Counter}(${2:start}) {\\n' +\n ' const [${3:count}, set${4:Count}] = $state(${2:start})\\n' +\n ' return { ${3:count}: ${3:count}, increment: () => set${4:Count}(v => v + 1) }\\n' +\n '}',\n },\n {\n name: \"ResponsiveGrid\",\n description: \"Grid with a responsive column map per breakpoint.\",\n template: 'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: \"${3:l}\" })',\n },\n];\n\nexport function getSnippets(): readonly SnippetEntry[] {\n return snippetCatalog;\n}\n","/**\n * Theme tokens applied as CSS custom properties on the host element.\n *\n * Built-in themes:\n * - \"light\" (default)\n * - \"dark\"\n * - \"neon\" (cyberpunk-inspired, dark with glowing accents)\n * - \"pastel\" (soft, friendly, light & rounded)\n * - \"glass\" (frosted glass, translucent surfaces, vivid gradient bg)\n * - \"brutalist\" (neo-brutalism, hard edges, thick borders, bold colors)\n * - \"skyline\" (deep navy + cyan, crisp & calm)\n *\n * Consumers can also pass a JSON object via the `theme` attribute, call\n * `element.setTheme({...})`, or declare `theme = Theme({...})` inside a\n * Aktion program. All three paths flow through `mergeTheme`\n * so partial token maps are layered on top of the `light` defaults.\n *\n * Token taxonomy:\n * - **Color** — surface, semantic, brand accents, focus ring.\n * - **Typography** — body and heading families, sizes, weights, line\n * heights, letter spacing, and heading text-transform. Enough surface\n * to mirror brand systems (GitHub, Stripe, Apple, IONOS, Notion, …).\n * - **Shape & spacing** — radii (xs/sm/md/lg/pill/button/input), border\n * width, shadows, spacing scale.\n * - **Buttons** — font-weight, text-transform, letter-spacing, padding.\n * - **Charts** — six rotating series colors.\n * - **Motion** — transition duration shared by hover / focus animations.\n */\n\nexport interface ThemeTokens {\n /* ----- Surface & semantic colors --------------------------------- */\n colorBg: string;\n colorBgSubtle: string;\n colorSurface: string;\n colorSurfaceMuted: string;\n colorBorder: string;\n colorBorderSubtle: string;\n colorText: string;\n colorTextMuted: string;\n colorPrimary: string;\n colorPrimaryHover: string;\n colorPrimaryText: string;\n /** Secondary brand accent (links, chips, callouts). Defaults to primary. */\n colorAccent: string;\n colorAccentHover: string;\n colorAccentText: string;\n /** Focus ring color (CSS color). Defaults to primary. */\n colorFocusRing: string;\n colorSuccess: string;\n colorWarning: string;\n colorDanger: string;\n colorInfo: string;\n /* ----- Typography ------------------------------------------------- */\n fontFamily: string;\n /** Font stack used for headings (Card title, Page header, SectionHeader…). */\n fontFamilyHeading: string;\n fontFamilyMono: string;\n /** Root font size — body text defaults to this value. */\n fontSizeBase: string;\n fontSizeSm: string;\n fontSizeLg: string;\n /** Font size for Card/Section headings. */\n fontSizeHeading: string;\n /** Font size for page-level titles (PageHeader, Cover, Hero). */\n fontSizeTitle: string;\n fontWeightBody: string;\n fontWeightHeading: string;\n lineHeightBody: string;\n lineHeightHeading: string;\n /** Letter spacing applied to titles & headings (e.g. \"-0.01em\"). */\n letterSpacingHeading: string;\n /** `text-transform` applied to titles & headings (e.g. \"uppercase\"). */\n headingTextTransform: string;\n /* ----- Shape ------------------------------------------------------ */\n /** Micro radius (pills, dots, status chips). */\n radiusXs: string;\n radiusSm: string;\n radiusMd: string;\n radiusLg: string;\n /** Fully-rounded radius — `999px` by default. */\n radiusPill: string;\n /** Button-specific radius. Falls back to `radiusSm`. */\n radiusButton: string;\n /** Input-specific radius. Falls back to `radiusSm`. */\n radiusInput: string;\n /** Width of every solid border (default 1px; brutalist uses 2px). */\n borderWidth: string;\n shadowSm: string;\n shadowMd: string;\n shadowLg: string;\n /* ----- Spacing ---------------------------------------------------- */\n spacingXs: string;\n spacingS: string;\n spacingM: string;\n spacingL: string;\n spacingXl: string;\n /* ----- Buttons ---------------------------------------------------- */\n buttonFontWeight: string;\n buttonTextTransform: string;\n buttonLetterSpacing: string;\n buttonPaddingY: string;\n buttonPaddingX: string;\n /* ----- Motion ----------------------------------------------------- */\n transitionDuration: string;\n /* ----- Chart palette --------------------------------------------- */\n chart1: string;\n chart2: string;\n chart3: string;\n chart4: string;\n chart5: string;\n chart6: string;\n}\n\nconst baseFonts = {\n fontFamily: \"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\",\n fontFamilyHeading: \"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\",\n fontFamilyMono: \"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n} as const;\n\nconst baseFontScale = {\n fontSizeBase: \"14px\",\n fontSizeSm: \"12px\",\n fontSizeLg: \"16px\",\n fontSizeHeading: \"16px\",\n fontSizeTitle: \"22px\",\n fontWeightBody: \"400\",\n fontWeightHeading: \"700\",\n lineHeightBody: \"1.5\",\n lineHeightHeading: \"1.2\",\n letterSpacingHeading: \"0\",\n headingTextTransform: \"none\",\n} as const;\n\nconst baseSpacing = {\n spacingXs: \"4px\",\n spacingS: \"8px\",\n spacingM: \"12px\",\n spacingL: \"20px\",\n spacingXl: \"32px\",\n} as const;\n\nconst baseRadii = {\n radiusXs: \"4px\",\n radiusSm: \"6px\",\n radiusMd: \"10px\",\n radiusLg: \"16px\",\n radiusPill: \"999px\",\n radiusButton: \"6px\",\n radiusInput: \"6px\",\n} as const;\n\nconst baseButtons = {\n buttonFontWeight: \"600\",\n buttonTextTransform: \"none\",\n buttonLetterSpacing: \"0\",\n buttonPaddingY: \"8px\",\n buttonPaddingX: \"14px\",\n} as const;\n\nconst baseMotion = {\n transitionDuration: \"120ms\",\n} as const;\n\nexport const lightTheme: ThemeTokens = {\n colorBg: \"#ffffff\",\n colorBgSubtle: \"#f8fafc\",\n colorSurface: \"#ffffff\",\n colorSurfaceMuted: \"#f1f5f9\",\n colorBorder: \"#e2e8f0\",\n colorBorderSubtle: \"rgba(15, 23, 42, 0.08)\",\n colorText: \"#0f172a\",\n colorTextMuted: \"#475569\",\n colorPrimary: \"#6366f1\",\n colorPrimaryHover: \"#4f46e5\",\n colorPrimaryText: \"#ffffff\",\n colorAccent: \"#6366f1\",\n colorAccentHover: \"#4f46e5\",\n colorAccentText: \"#ffffff\",\n colorFocusRing: \"#6366f1\",\n colorSuccess: \"#10b981\",\n colorWarning: \"#f59e0b\",\n colorDanger: \"#ef4444\",\n colorInfo: \"#06b6d4\",\n shadowSm: \"0 1px 2px rgba(15, 23, 42, 0.06)\",\n shadowMd: \"0 6px 24px rgba(15, 23, 42, 0.08)\",\n shadowLg: \"0 18px 60px rgba(15, 23, 42, 0.12)\",\n borderWidth: \"1px\",\n chart1: \"#6366f1\",\n chart2: \"#10b981\",\n chart3: \"#f59e0b\",\n chart4: \"#ef4444\",\n chart5: \"#06b6d4\",\n chart6: \"#8b5cf6\",\n ...baseFonts,\n ...baseFontScale,\n ...baseSpacing,\n ...baseRadii,\n ...baseButtons,\n ...baseMotion,\n};\n\nexport const darkTheme: ThemeTokens = {\n ...lightTheme,\n colorBg: \"#0b1220\",\n colorBgSubtle: \"#0f172a\",\n colorSurface: \"#111827\",\n colorSurfaceMuted: \"#1e293b\",\n colorBorder: \"#1f2937\",\n colorBorderSubtle: \"rgba(248, 250, 252, 0.08)\",\n colorText: \"#f8fafc\",\n colorTextMuted: \"#94a3b8\",\n colorPrimary: \"#818cf8\",\n colorPrimaryHover: \"#6366f1\",\n colorPrimaryText: \"#0b1220\",\n colorAccent: \"#818cf8\",\n colorAccentHover: \"#6366f1\",\n colorAccentText: \"#0b1220\",\n colorFocusRing: \"#818cf8\",\n shadowSm: \"0 1px 2px rgba(0, 0, 0, 0.4)\",\n shadowMd: \"0 8px 24px rgba(0, 0, 0, 0.4)\",\n shadowLg: \"0 22px 60px rgba(0, 0, 0, 0.55)\",\n};\n\n/**\n * Neon — cyberpunk-flavoured dark mode. Magenta/cyan glow, sharper corners,\n * monospace headings, and high-contrast surfaces.\n */\nexport const neonTheme: ThemeTokens = {\n ...lightTheme,\n colorBg: \"#05060f\",\n colorBgSubtle: \"#0a0c1c\",\n colorSurface: \"#0d1024\",\n colorSurfaceMuted: \"#161a36\",\n colorBorder: \"#2a2f6b\",\n colorBorderSubtle: \"rgba(236, 72, 153, 0.18)\",\n colorText: \"#f5f3ff\",\n colorTextMuted: \"#a5b4fc\",\n colorPrimary: \"#ec4899\",\n colorPrimaryHover: \"#f472b6\",\n colorPrimaryText: \"#05060f\",\n colorAccent: \"#22d3ee\",\n colorAccentHover: \"#67e8f9\",\n colorAccentText: \"#05060f\",\n colorFocusRing: \"#ec4899\",\n colorSuccess: \"#34d399\",\n colorWarning: \"#fbbf24\",\n colorDanger: \"#f87171\",\n colorInfo: \"#22d3ee\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n fontFamilyHeading: \"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n fontFamilyMono: \"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n letterSpacingHeading: \"0.02em\",\n radiusXs: \"2px\",\n radiusSm: \"2px\",\n radiusMd: \"4px\",\n radiusLg: \"6px\",\n radiusButton: \"2px\",\n radiusInput: \"2px\",\n shadowSm: \"0 0 0 1px rgba(236, 72, 153, 0.25), 0 0 12px rgba(34, 211, 238, 0.18)\",\n shadowMd: \"0 0 0 1px rgba(236, 72, 153, 0.35), 0 0 28px rgba(34, 211, 238, 0.22)\",\n shadowLg: \"0 0 0 1px rgba(236, 72, 153, 0.45), 0 0 48px rgba(34, 211, 238, 0.35)\",\n spacingXs: \"4px\",\n spacingS: \"8px\",\n spacingM: \"14px\",\n spacingL: \"22px\",\n spacingXl: \"36px\",\n chart1: \"#ec4899\",\n chart2: \"#22d3ee\",\n chart3: \"#fbbf24\",\n chart4: \"#a78bfa\",\n chart5: \"#34d399\",\n chart6: \"#f472b6\",\n};\n\n/**\n * Pastel — soft, friendly, light and rounded. Larger paddings, big radii,\n * lavender + mint palette, gentle shadows.\n */\nexport const pastelTheme: ThemeTokens = {\n ...lightTheme,\n colorBg: \"#fdf6ff\",\n colorBgSubtle: \"#fbf2ff\",\n colorSurface: \"#ffffff\",\n colorSurfaceMuted: \"#f4ecff\",\n colorBorder: \"#ead8ff\",\n colorBorderSubtle: \"rgba(168, 132, 232, 0.18)\",\n colorText: \"#3b1f56\",\n colorTextMuted: \"#7d6193\",\n colorPrimary: \"#a78bfa\",\n colorPrimaryHover: \"#8b5cf6\",\n colorPrimaryText: \"#ffffff\",\n colorAccent: \"#5eead4\",\n colorAccentHover: \"#2dd4bf\",\n colorAccentText: \"#0f3a35\",\n colorFocusRing: \"#a78bfa\",\n colorSuccess: \"#5eead4\",\n colorWarning: \"#fcd34d\",\n colorDanger: \"#fda4af\",\n colorInfo: \"#93c5fd\",\n fontFamily: \"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n fontFamilyHeading: \"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n fontFamilyMono: \"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n radiusXs: \"8px\",\n radiusSm: \"12px\",\n radiusMd: \"20px\",\n radiusLg: \"28px\",\n radiusButton: \"16px\",\n radiusInput: \"16px\",\n shadowSm: \"0 4px 14px rgba(168, 132, 232, 0.12)\",\n shadowMd: \"0 18px 40px rgba(168, 132, 232, 0.18)\",\n shadowLg: \"0 28px 70px rgba(168, 132, 232, 0.22)\",\n spacingXs: \"6px\",\n spacingS: \"12px\",\n spacingM: \"18px\",\n spacingL: \"28px\",\n spacingXl: \"44px\",\n chart1: \"#a78bfa\",\n chart2: \"#5eead4\",\n chart3: \"#fcd34d\",\n chart4: \"#fda4af\",\n chart5: \"#93c5fd\",\n chart6: \"#f9a8d4\",\n};\n\n/**\n * Glass — modern glassmorphism. Vivid gradient backdrop, frosted translucent\n * surfaces (real backdrop-filter blur applied via the stylesheet), generous\n * radii, and a cool indigo→cyan accent. Designed for hero sections and\n * marketing-style UIs.\n */\nexport const glassTheme: ThemeTokens = {\n ...lightTheme,\n colorBg: \"#0f1730\",\n colorBgSubtle: \"#13204a\",\n colorSurface: \"rgba(255, 255, 255, 0.08)\",\n colorSurfaceMuted: \"rgba(255, 255, 255, 0.04)\",\n colorBorder: \"rgba(255, 255, 255, 0.18)\",\n colorBorderSubtle: \"rgba(255, 255, 255, 0.10)\",\n colorText: \"#f1f5ff\",\n colorTextMuted: \"#b6c3e6\",\n colorPrimary: \"#60a5fa\",\n colorPrimaryHover: \"#3b82f6\",\n colorPrimaryText: \"#0b132b\",\n colorAccent: \"#22d3ee\",\n colorAccentHover: \"#67e8f9\",\n colorAccentText: \"#0b132b\",\n colorFocusRing: \"#60a5fa\",\n colorSuccess: \"#34d399\",\n colorWarning: \"#fbbf24\",\n colorDanger: \"#fb7185\",\n colorInfo: \"#22d3ee\",\n fontFamily: \"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n fontFamilyHeading: \"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n fontFamilyMono: \"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n radiusXs: \"6px\",\n radiusSm: \"10px\",\n radiusMd: \"16px\",\n radiusLg: \"24px\",\n radiusButton: \"12px\",\n radiusInput: \"12px\",\n shadowSm: \"0 1px 2px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.08)\",\n shadowMd: \"0 18px 50px rgba(7, 14, 33, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.10)\",\n shadowLg: \"0 28px 80px rgba(7, 14, 33, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12)\",\n spacingXs: \"4px\",\n spacingS: \"10px\",\n spacingM: \"16px\",\n spacingL: \"24px\",\n spacingXl: \"40px\",\n chart1: \"#60a5fa\",\n chart2: \"#22d3ee\",\n chart3: \"#a78bfa\",\n chart4: \"#f472b6\",\n chart5: \"#34d399\",\n chart6: \"#fbbf24\",\n};\n\n/**\n * Brutalist — neo-brutalism. Hard 2px black borders, chunky offset shadows,\n * loud primary colors, all-caps display type, and zero gradients. Designed\n * to look hand-built and unapologetically bold.\n */\nexport const brutalistTheme: ThemeTokens = {\n ...lightTheme,\n colorBg: \"#fef9c3\",\n colorBgSubtle: \"#fde68a\",\n colorSurface: \"#ffffff\",\n colorSurfaceMuted: \"#fef3c7\",\n colorBorder: \"#0a0a0a\",\n colorBorderSubtle: \"#0a0a0a\",\n colorText: \"#0a0a0a\",\n colorTextMuted: \"#3f3f46\",\n colorPrimary: \"#1d4ed8\",\n colorPrimaryHover: \"#1e40af\",\n colorPrimaryText: \"#ffffff\",\n colorAccent: \"#dc2626\",\n colorAccentHover: \"#b91c1c\",\n colorAccentText: \"#ffffff\",\n colorFocusRing: \"#0a0a0a\",\n colorSuccess: \"#16a34a\",\n colorWarning: \"#ea580c\",\n colorDanger: \"#dc2626\",\n colorInfo: \"#0891b2\",\n fontFamily: \"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif\",\n fontFamilyHeading: \"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif\",\n fontFamilyMono: \"'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n fontWeightHeading: \"800\",\n letterSpacingHeading: \"-0.01em\",\n headingTextTransform: \"uppercase\",\n radiusXs: \"0px\",\n radiusSm: \"0px\",\n radiusMd: \"0px\",\n radiusLg: \"0px\",\n radiusPill: \"0px\",\n radiusButton: \"0px\",\n radiusInput: \"0px\",\n borderWidth: \"2px\",\n shadowSm: \"3px 3px 0 0 #0a0a0a\",\n shadowMd: \"6px 6px 0 0 #0a0a0a\",\n shadowLg: \"10px 10px 0 0 #0a0a0a\",\n spacingXs: \"4px\",\n spacingS: \"10px\",\n spacingM: \"16px\",\n spacingL: \"22px\",\n spacingXl: \"36px\",\n buttonFontWeight: \"800\",\n buttonTextTransform: \"uppercase\",\n buttonLetterSpacing: \"0.02em\",\n chart1: \"#dc2626\",\n chart2: \"#1d4ed8\",\n chart3: \"#16a34a\",\n chart4: \"#ea580c\",\n chart5: \"#7c3aed\",\n chart6: \"#0a0a0a\",\n};\n\n/**\n * Skyline — enterprise cloud-console aesthetic. Deep navy primary, calm\n * cyan accents, very pale blue page background, white surfaces with crisp\n * 1px borders, small radii, and a clean Inter type stack. The look should\n * feel at home in an admin panel: dense, scannable, minimal chrome.\n */\nexport const skylineTheme: ThemeTokens = {\n ...lightTheme,\n colorBg: \"#eff2f7\",\n colorBgSubtle: \"#e6ecf3\",\n colorSurface: \"#ffffff\",\n colorSurfaceMuted: \"#f4f7fb\",\n colorBorder: \"#d6deea\",\n colorBorderSubtle: \"rgba(13, 27, 58, 0.08)\",\n colorText: \"#0d1b3a\",\n colorTextMuted: \"#5a6a85\",\n colorPrimary: \"#003580\",\n colorPrimaryHover: \"#002a66\",\n colorPrimaryText: \"#ffffff\",\n colorAccent: \"#0095d6\",\n colorAccentHover: \"#0078ad\",\n colorAccentText: \"#ffffff\",\n colorFocusRing: \"#0095d6\",\n colorSuccess: \"#1b8f4f\",\n colorWarning: \"#c47e00\",\n colorDanger: \"#c8362b\",\n colorInfo: \"#0095d6\",\n fontFamily: \"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n fontFamilyHeading: \"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n fontFamilyMono: \"'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n radiusXs: \"3px\",\n radiusSm: \"4px\",\n radiusMd: \"6px\",\n radiusLg: \"10px\",\n radiusButton: \"4px\",\n radiusInput: \"4px\",\n shadowSm: \"0 1px 0 rgba(13, 27, 58, 0.04), 0 1px 3px rgba(13, 27, 58, 0.06)\",\n shadowMd: \"0 4px 16px rgba(13, 27, 58, 0.08), 0 1px 3px rgba(13, 27, 58, 0.04)\",\n shadowLg: \"0 16px 40px rgba(13, 27, 58, 0.12), 0 2px 6px rgba(13, 27, 58, 0.06)\",\n spacingXs: \"4px\",\n spacingS: \"8px\",\n spacingM: \"14px\",\n spacingL: \"20px\",\n spacingXl: \"32px\",\n chart1: \"#003580\",\n chart2: \"#0095d6\",\n chart3: \"#1b8f4f\",\n chart4: \"#c47e00\",\n chart5: \"#d43594\",\n chart6: \"#5a6a85\",\n};\n\nexport const builtInThemes: Record<string, ThemeTokens> = {\n light: lightTheme,\n dark: darkTheme,\n neon: neonTheme,\n pastel: pastelTheme,\n glass: glassTheme,\n brutalist: brutalistTheme,\n skyline: skylineTheme,\n};\n\nconst TOKEN_TO_CSS: Record<keyof ThemeTokens, string> = {\n colorBg: \"--rui-color-bg\",\n colorBgSubtle: \"--rui-color-bg-subtle\",\n colorSurface: \"--rui-color-surface\",\n colorSurfaceMuted: \"--rui-color-surface-muted\",\n colorBorder: \"--rui-color-border\",\n colorBorderSubtle: \"--rui-color-border-subtle\",\n colorText: \"--rui-color-text\",\n colorTextMuted: \"--rui-color-text-muted\",\n colorPrimary: \"--rui-color-primary\",\n colorPrimaryHover: \"--rui-color-primary-hover\",\n colorPrimaryText: \"--rui-color-primary-text\",\n colorAccent: \"--rui-color-accent\",\n colorAccentHover: \"--rui-color-accent-hover\",\n colorAccentText: \"--rui-color-accent-text\",\n colorFocusRing: \"--rui-color-focus-ring\",\n colorSuccess: \"--rui-color-success\",\n colorWarning: \"--rui-color-warning\",\n colorDanger: \"--rui-color-danger\",\n colorInfo: \"--rui-color-info\",\n fontFamily: \"--rui-font-family\",\n fontFamilyHeading: \"--rui-font-family-heading\",\n fontFamilyMono: \"--rui-font-family-mono\",\n fontSizeBase: \"--rui-font-size-base\",\n fontSizeSm: \"--rui-font-size-sm\",\n fontSizeLg: \"--rui-font-size-lg\",\n fontSizeHeading: \"--rui-font-size-heading\",\n fontSizeTitle: \"--rui-font-size-title\",\n fontWeightBody: \"--rui-font-weight-body\",\n fontWeightHeading: \"--rui-font-weight-heading\",\n lineHeightBody: \"--rui-line-height-body\",\n lineHeightHeading: \"--rui-line-height-heading\",\n letterSpacingHeading: \"--rui-letter-spacing-heading\",\n headingTextTransform: \"--rui-heading-text-transform\",\n radiusXs: \"--rui-radius-xs\",\n radiusSm: \"--rui-radius-sm\",\n radiusMd: \"--rui-radius-md\",\n radiusLg: \"--rui-radius-lg\",\n radiusPill: \"--rui-radius-pill\",\n radiusButton: \"--rui-radius-button\",\n radiusInput: \"--rui-radius-input\",\n borderWidth: \"--rui-border-width\",\n shadowSm: \"--rui-shadow-sm\",\n shadowMd: \"--rui-shadow-md\",\n shadowLg: \"--rui-shadow-lg\",\n spacingXs: \"--rui-spacing-xs\",\n spacingS: \"--rui-spacing-s\",\n spacingM: \"--rui-spacing-m\",\n spacingL: \"--rui-spacing-l\",\n spacingXl: \"--rui-spacing-xl\",\n buttonFontWeight: \"--rui-button-font-weight\",\n buttonTextTransform: \"--rui-button-text-transform\",\n buttonLetterSpacing: \"--rui-button-letter-spacing\",\n buttonPaddingY: \"--rui-button-padding-y\",\n buttonPaddingX: \"--rui-button-padding-x\",\n transitionDuration: \"--rui-transition-duration\",\n chart1: \"--rui-chart-1\",\n chart2: \"--rui-chart-2\",\n chart3: \"--rui-chart-3\",\n chart4: \"--rui-chart-4\",\n chart5: \"--rui-chart-5\",\n chart6: \"--rui-chart-6\",\n};\n\nexport type ThemeInput = string | Partial<ThemeTokens>;\n\nexport interface ResolvedTheme {\n /** Built-in theme name when known, otherwise \"custom\". Drives `data-rui-theme`. */\n name: string;\n tokens: ThemeTokens;\n}\n\nexport function resolveTheme(input: ThemeInput | null | undefined): ResolvedTheme {\n if (!input) return { name: \"light\", tokens: lightTheme };\n if (typeof input === \"string\") {\n const key = input.trim().toLowerCase();\n if (key.startsWith(\"{\")) {\n try {\n return { name: \"custom\", tokens: mergeTheme(JSON.parse(input) as Partial<ThemeTokens>) };\n } catch {\n return { name: \"light\", tokens: lightTheme };\n }\n }\n const tokens = builtInThemes[key];\n if (tokens) return { name: key, tokens };\n return { name: \"light\", tokens: lightTheme };\n }\n return { name: \"custom\", tokens: mergeTheme(input) };\n}\n\n/**\n * Apply theme tokens to the host element. Also sets `data-rui-theme` so the\n * shadow-DOM stylesheet can hook into theme-specific overrides (fonts,\n * gradients, animations, etc.) that go beyond raw token values.\n */\nexport function applyTheme(host: HTMLElement, theme: ResolvedTheme | ThemeTokens): void {\n const resolved: ResolvedTheme =\n \"tokens\" in theme ? theme : { name: \"custom\", tokens: theme };\n for (const [key, cssVar] of Object.entries(TOKEN_TO_CSS) as Array<[keyof ThemeTokens, string]>) {\n host.style.setProperty(cssVar, resolved.tokens[key]);\n }\n host.setAttribute(\"data-rui-theme\", resolved.name);\n}\n\n/**\n * Apply *only* the tokens explicitly listed in `partial`. Leaves every other\n * CSS variable untouched, so this composes cleanly on top of whatever base\n * theme `applyTheme(...)` last wrote. Used by the in-script `Theme(...)`\n * construct so authors can override just a handful of tokens without\n * wiping the rest of the active theme.\n *\n * Unknown keys are ignored — both for forward compatibility and to keep\n * malformed LLM output from polluting the host's inline styles.\n */\nexport function applyPartialTheme(\n host: HTMLElement,\n partial: Partial<ThemeTokens>,\n): ReadonlyArray<keyof ThemeTokens> {\n const applied: Array<keyof ThemeTokens> = [];\n for (const key of Object.keys(partial) as Array<keyof ThemeTokens>) {\n const cssVar = TOKEN_TO_CSS[key];\n if (!cssVar) continue;\n const value = partial[key];\n if (typeof value !== \"string\" || value === \"\") continue;\n host.style.setProperty(cssVar, value);\n applied.push(key);\n }\n return applied;\n}\n\n/**\n * Remove an array of token CSS variables from the host's inline style. Used\n * to \"undo\" a previous `applyPartialTheme(...)` call so the next render\n * inherits whatever the base theme provides rather than the stale override.\n */\nexport function clearTokenOverrides(\n host: HTMLElement,\n keys: ReadonlyArray<keyof ThemeTokens>,\n): void {\n for (const key of keys) {\n const cssVar = TOKEN_TO_CSS[key];\n if (cssVar) host.style.removeProperty(cssVar);\n }\n}\n\n/**\n * Filter an arbitrary object down to the keys recognised by `ThemeTokens`,\n * stringifying primitive values along the way. Used when an Aktion program\n * declares `theme = Theme({...})` — the evaluator hands us\n * a plain JS object, and we want to ignore anything that isn't a real token\n * (LLM typo guard) before applying it.\n */\nexport function sanitiseThemeTokens(input: unknown): Partial<ThemeTokens> {\n if (!input || typeof input !== \"object\" || Array.isArray(input)) return {};\n const out: Partial<ThemeTokens> = {};\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n if (!(key in TOKEN_TO_CSS)) continue;\n if (value == null) continue;\n if (typeof value === \"string\") {\n if (value.trim() === \"\") continue;\n out[key as keyof ThemeTokens] = value;\n } else if (typeof value === \"number\") {\n out[key as keyof ThemeTokens] = String(value);\n }\n }\n return out;\n}\n\nfunction mergeTheme(partial: Partial<ThemeTokens>): ThemeTokens {\n return { ...lightTheme, ...partial };\n}\n","/**\n * Component catalog derived from the runtime library.\n *\n * We project `ComponentSpec` (which carries a DOM-flavoured `render` fn) into\n * a flat, JSON-serialisable shape that any editor or tool can consume without\n * pulling in the renderer or the DOM.\n */\n\nimport type { ComponentLibrary, ComponentSpec, PropSpec } from \"../library/types.js\";\nimport { defaultLibrary } from \"../library/index.js\";\n\nexport interface ComponentParam {\n name: string;\n type: string;\n required: boolean;\n description?: string;\n enumValues?: readonly string[];\n}\n\nexport interface ComponentEntry {\n name: string;\n group: string;\n description: string;\n params: ComponentParam[];\n /** Short positional signature, e.g. `Card(children, variant?)`. */\n signature: string;\n}\n\nconst projectParam = (prop: PropSpec): ComponentParam => {\n const param: ComponentParam = {\n name: prop.name,\n type: prop.type,\n required: !prop.optional,\n };\n if (prop.description) param.description = prop.description;\n if (prop.enum && prop.enum.length > 0) param.enumValues = prop.enum;\n return param;\n};\n\nconst buildSignature = (spec: ComponentSpec): string => {\n const parts = spec.props.map((p) => (p.optional ? `${p.name}?` : p.name));\n return `${spec.name}(${parts.join(\", \")})`;\n};\n\nconst buildGroupIndex = (library: ComponentLibrary): Map<string, string> => {\n const index = new Map<string, string>();\n for (const group of library.componentGroups ?? []) {\n for (const name of group.components) index.set(name, group.name);\n }\n return index;\n};\n\n/**\n * Project a library's component specs into a flat catalog. Defaults to the\n * built-in `defaultLibrary`, but accepts a custom library so consumers that\n * register extra components via `registerComponents()` get the right autocomplete\n * data.\n */\nexport function getComponentCatalog(library: ComponentLibrary = defaultLibrary): ComponentEntry[] {\n const groupOf = buildGroupIndex(library);\n return library.components.map((spec) => ({\n name: spec.name,\n group: groupOf.get(spec.name) ?? \"Other\",\n description: spec.description,\n params: spec.props.map(projectParam),\n signature: buildSignature(spec),\n }));\n}\n\n/**\n * Returns an index of component name → entry for O(1) lookup. Convenient\n * inside editor extensions that need to render details on hover.\n */\nexport function indexCatalog(entries: ComponentEntry[]): Record<string, ComponentEntry> {\n const out: Record<string, ComponentEntry> = {};\n for (const entry of entries) out[entry.name] = entry;\n return out;\n}\n","/**\n * Reusable language-support module for Aktion.\n *\n * Framework-agnostic: this module ships pure data (grammar tokens, the\n * component catalog, builtins, snippets, theme names, severity tokens) plus\n * a lightweight stream tokenizer factory. It does not import CodeMirror,\n * Monaco, or any DOM API at the top level, so the same metadata can drive a\n * VS Code extension, a Monaco editor, a CodeMirror 6 instance, or pure-CLI\n * linting.\n *\n * Consume via `getLanguageSpec(library?)` — see `./README.md` for example\n * wiring against CodeMirror, Monaco, and VS Code.\n */\n\nimport type { ComponentLibrary } from \"../library/types.js\";\nimport { defaultLibrary } from \"../library/index.js\";\nimport { builtInThemes } from \"../theme/index.js\";\n\nimport {\n grammarSpec,\n createStreamTokenizer,\n defaultTagMap,\n keywordDocs,\n type GrammarSpec,\n type GrammarTokenKind,\n type StreamTokenizer,\n type KeywordDoc,\n} from \"./grammar.js\";\nimport {\n getComponentCatalog,\n indexCatalog,\n type ComponentEntry,\n type ComponentParam,\n} from \"./components.js\";\nimport { getSnippets, type SnippetEntry } from \"./snippets.js\";\n\nexport type {\n GrammarSpec,\n GrammarTokenKind,\n StreamTokenizer,\n KeywordDoc,\n ComponentEntry,\n ComponentParam,\n SnippetEntry,\n};\n\nexport {\n grammarSpec,\n createStreamTokenizer,\n defaultTagMap,\n keywordDocs,\n getComponentCatalog,\n indexCatalog,\n getSnippets,\n};\n\n/**\n * Diagnostic severity buckets that map to common editor lint levels.\n * Editors typically map: `error` → red squiggle, `warning` → yellow,\n * `info` → blue, `hint` → grey.\n */\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"info\" | \"hint\";\n\nexport interface LanguageSpec {\n grammar: GrammarSpec;\n /** Build a fresh tokenizer instance suitable for CodeMirror StreamLanguage. */\n tokenizer: StreamTokenizer;\n /** Map from grammar token kind → CodeMirror highlight tag name. */\n tagMap: Record<GrammarTokenKind, string | null>;\n components: ComponentEntry[];\n componentsByName: Record<string, ComponentEntry>;\n snippets: readonly SnippetEntry[];\n /**\n * Reserved-keyword documentation (definition + syntax + example),\n * keyed by keyword. Powers keyword highlight-popups and hover help.\n */\n keywordDocs: Record<string, KeywordDoc>;\n /** Built-in theme names; useful for theme-picker autocomplete. */\n themeNames: readonly string[];\n /** Default severity for the parser's ParseError stream. */\n severityTokenMap: Record<\"parse-error\", DiagnosticSeverity>;\n /**\n * Font Awesome icon aliases used by components that accept `icon: string`.\n * Editors can use these to power icon-name autocomplete.\n */\n iconAliases: readonly string[];\n}\n\n/**\n * Build a complete language spec ready for editor consumption. Pass a custom\n * `ComponentLibrary` if your host has registered extra components via\n * `<aktion-app>.registerComponents([...])` — the returned spec will\n * include them in autocomplete and inspection tooltips.\n */\nexport function getLanguageSpec(library: ComponentLibrary = defaultLibrary): LanguageSpec {\n const components = getComponentCatalog(library);\n return {\n grammar: grammarSpec,\n tokenizer: createStreamTokenizer(grammarSpec),\n tagMap: defaultTagMap,\n components,\n componentsByName: indexCatalog(components),\n snippets: getSnippets(),\n keywordDocs,\n themeNames: Object.keys(builtInThemes),\n severityTokenMap: { \"parse-error\": \"error\" },\n iconAliases: COMMON_ICON_ALIASES,\n };\n}\n\n/**\n * A pragmatic shortlist of Font Awesome icon names that the design system\n * uses in templates. Editors get a useful autocomplete without us shipping\n * the full FA dictionary (which is ~2 MB).\n */\nconst COMMON_ICON_ALIASES: readonly string[] = [\n \"house\", \"user\", \"users\", \"gear\", \"bell\", \"envelope\", \"magnifying-glass\",\n \"plus\", \"minus\", \"pen\", \"trash\", \"check\", \"xmark\", \"arrow-right\", \"arrow-left\",\n \"arrow-up\", \"arrow-down\", \"chevron-right\", \"chevron-left\", \"chevron-down\",\n \"chevron-up\", \"ellipsis\", \"ellipsis-vertical\", \"star\", \"heart\", \"bookmark\",\n \"calendar\", \"clock\", \"file\", \"folder\", \"image\", \"video\", \"music\",\n \"chart-line\", \"chart-bar\", \"chart-pie\", \"gauge\", \"table\",\n \"circle-info\", \"circle-check\", \"circle-exclamation\", \"circle-question\",\n \"triangle-exclamation\", \"shield\", \"lock\", \"unlock\", \"key\", \"rocket\",\n \"bolt\", \"fire\", \"snowflake\", \"sun\", \"moon\", \"cloud\", \"code\", \"terminal\",\n \"database\", \"server\", \"globe\", \"link\", \"share\", \"download\", \"upload\",\n \"filter\", \"sort\", \"list\", \"grid\", \"columns\", \"sidebar\", \"bars\",\n \"tag\", \"tags\", \"flag\", \"trophy\", \"medal\", \"gift\", \"cart-shopping\",\n \"credit-card\", \"money-bill\", \"receipt\", \"wallet\", \"comment\", \"comments\",\n \"paper-plane\", \"inbox\", \"paper-clip\", \"phone\", \"video-camera\",\n \"play\", \"pause\", \"stop\", \"forward\", \"backward\", \"expand\", \"compress\",\n \"eye\", \"eye-slash\", \"thumbs-up\", \"thumbs-down\", \"thumbtack\",\n];\n"],"names":[],"mappings":";AA8DO,MAAM,cAA2B;AAAA,EACtC,MAAM;AAAA,EACN,OAAO,CAAC,QAAQ,SAAS,QAAQ,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5C,UAAU;AAAA,IACR;AAAA,IAAY;AAAA,IAAM;AAAA,IAAQ;AAAA,IAAU;AAAA,IAAQ;AAAA,IAC5C;AAAA,IAAY;AAAA,IAAO;AAAA,IAAS;AAAA,IAAM;AAAA,IAAM;AAAA,IAAM;AAAA,IAAO;AAAA,IAAO;AAAA,IAC5D;AAAA,IA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AAS;AAAA,EAAe;AAAA,EAClE;AAAA,EAAY;AAAA,EAAc;AAAA,EAAiB;AAAA,EAAgB;AAAA,EAC3D;AAAA,EAAc;AAAA,EAAY;AAAA,EAAqB;AAAA,EAAQ;AAAA,EAAS;AAAA,EAChE;AAAA,EAAY;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAU;AAAA,EAAS;AAAA,EAAS;AAAA,EACzD;AAAA,EAAc;AAAA,EAAa;AAAA,EAAa;AAAA,EAAS;AAAA,EACjD;AAAA,EAAe;AAAA,EAAgB;AAAA,EAAsB;AAAA,EACrD;AAAA,EAAwB;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAU;AAAA,EAAO;AAAA,EAC3D;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAa;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAQ;AAAA,EAC7D;AAAA,EAAY;AAAA,EAAU;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAY;AAAA,EAC5D;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAW;AAAA,EACxD;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAU;AAAA,EAAS;AAAA,EAAQ;AAAA,EAClD;AAAA,EAAe;AAAA,EAAc;AAAA,EAAW;AAAA,EAAU;AAAA,EAAW;AAAA,EAC7D;AAAA,EAAe;AAAA,EAAS;AAAA,EAAc;AAAA,EAAS;AAAA,EAC/C;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAY;AAAA,EAAU;AAAA,EAC1D;AAAA,EAAO;AAAA,EAAa;AAAA,EAAa;AAAA,EAAe;AAClD;"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const compile = require("./compile-BUw0GAvN.cjs");
4
- function aktionPlugin(options = {}) {
5
- let isServe = false;
6
- return {
7
- name: "aktion",
8
- // Run before the core JS/TS transforms so we own `.aktion` modules and
9
- // downstream tooling only ever sees the generated JS.
10
- enforce: "pre",
11
- configResolved(config) {
12
- isServe = config.command === "serve";
13
- },
14
- transform(code, id) {
15
- if (!isAktionId(id)) return null;
16
- const cleanId = stripQuery(id);
17
- const result = compile.compile(code, {
18
- path: cleanId,
19
- library: options.library,
20
- schemaErrorsFatal: options.schemaErrorsFatal,
21
- requireEntry: options.requireEntry,
22
- runtimeModuleId: options.runtimeModuleId,
23
- sourcemap: true
24
- });
25
- for (const dep of result.dependencies) {
26
- if (dep !== cleanId) this.addWatchFile(dep);
27
- }
28
- const fatal = result.diagnostics.find((d) => d.severity === "error");
29
- if (fatal) {
30
- return this.error(fatal.message, { line: fatal.line, column: fatal.column });
31
- }
32
- for (const diag of result.diagnostics) {
33
- if (diag.severity === "warning") {
34
- this.warn(diag.message, { line: diag.line, column: diag.column });
35
- }
36
- }
37
- const finalCode = isServe ? result.code + HMR_FOOTER : result.code;
38
- return { code: finalCode, map: result.map };
39
- }
40
- };
41
- }
42
- function isAktionId(id) {
43
- return stripQuery(id).endsWith(".aktion");
44
- }
45
- function stripQuery(id) {
46
- const q = id.indexOf("?");
47
- const base = q === -1 ? id : id.slice(0, q);
48
- const h = base.indexOf("#");
49
- return h === -1 ? base : base.slice(0, h);
50
- }
51
- const HMR_FOOTER = `
52
- if (import.meta.hot) {
53
- import.meta.hot.accept((mod) => {
54
- const next = mod && mod.default;
55
- if (!next || typeof document === "undefined") return;
56
- for (const el of document.querySelectorAll("aktion-app")) {
57
- if (el.sourceId !== next.path) continue;
58
- el.mountCompiled(next, el.serializeState());
59
- }
60
- });
61
- }
62
- `;
63
- exports.aktionPlugin = aktionPlugin;
64
- exports.default = aktionPlugin;
65
- //# sourceMappingURL=vite.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.cjs","sources":["../../src/plugin/vite.ts"],"sourcesContent":["/**\n * The Aktion Vite/Rollup plugin (`aktion-runtime/vite`).\n *\n * This is the ONLY module that imports from `vite`/`rollup`, and it is shipped\n * as a separate Node entry (see `vite.node.config.ts`) so neither the plugin\n * nor the compiler it pulls in (`compile()` + the linker + `magic-string`)\n * ever reaches the browser bundle.\n *\n * Responsibilities:\n * - `transform`: compile a `.aktion` file (resolving any cross-file\n * `import`/`export` graph) into a module exporting a `CompiledProgram`,\n * surface diagnostics as build errors/warnings with source positions\n * (driving Vite's overlay), and append a self-accepting HMR block in dev.\n * - HMR: the appended block re-mounts every `<aktion-app>` showing the\n * changed module via `mountCompiled(next, el.serializeState())`, so live\n * `$state` survives an edit. Imported `.aktion` files are registered with\n * `this.addWatchFile`, so editing a dependency re-triggers the entry.\n */\n\nimport type { Plugin } from \"vite\";\nimport { compile } from \"../compiler/compile.js\";\nimport type { ComponentLibrary } from \"../library/types.js\";\n\nexport interface AktionPluginOptions {\n /** Library to validate against at build time. Default: the default library. */\n library?: ComponentLibrary;\n /** Treat schema violations as fatal build errors vs. warnings. Default: true. */\n schemaErrorsFatal?: boolean;\n /** Warn when a program has no `aktion = …` entry binding. Default: true. */\n requireEntry?: boolean;\n /** Specifier the emitted module imports the runtime helper from. Default: `\"aktion-runtime\"`. */\n runtimeModuleId?: string;\n}\n\n/**\n * The Aktion Vite/Rollup plugin. Add it to `plugins` in `vite.config.ts`:\n *\n * import aktion from \"aktion-runtime/vite\";\n * export default { plugins: [aktion()] };\n */\nexport function aktionPlugin(options: AktionPluginOptions = {}): Plugin {\n let isServe = false;\n return {\n name: \"aktion\",\n // Run before the core JS/TS transforms so we own `.aktion` modules and\n // downstream tooling only ever sees the generated JS.\n enforce: \"pre\",\n configResolved(config) {\n isServe = config.command === \"serve\";\n },\n transform(code, id) {\n if (!isAktionId(id)) return null;\n const cleanId = stripQuery(id);\n\n const result = compile(code, {\n path: cleanId,\n library: options.library,\n schemaErrorsFatal: options.schemaErrorsFatal,\n requireEntry: options.requireEntry,\n runtimeModuleId: options.runtimeModuleId,\n sourcemap: true,\n });\n\n // Register imported `.aktion` files so editing a dependency re-runs this\n // transform (HMR across the module graph).\n for (const dep of result.dependencies) {\n if (dep !== cleanId) this.addWatchFile(dep);\n }\n\n // First fatal diagnostic stops the build and drives the Vite overlay\n // (Rollup builds the code frame from the module source at this position).\n const fatal = result.diagnostics.find((d) => d.severity === \"error\");\n if (fatal) {\n return this.error(fatal.message, { line: fatal.line, column: fatal.column });\n }\n for (const diag of result.diagnostics) {\n if (diag.severity === \"warning\") {\n this.warn(diag.message, { line: diag.line, column: diag.column });\n }\n }\n\n const finalCode = isServe ? result.code + HMR_FOOTER : result.code;\n return { code: finalCode, map: result.map };\n },\n };\n}\n\n/** True for `*.aktion` ids (query/hash stripped). */\nexport function isAktionId(id: string): boolean {\n return stripQuery(id).endsWith(\".aktion\");\n}\n\nfunction stripQuery(id: string): string {\n const q = id.indexOf(\"?\");\n const base = q === -1 ? id : id.slice(0, q);\n const h = base.indexOf(\"#\");\n return h === -1 ? base : base.slice(0, h);\n}\n\n/**\n * Dev-only HMR block appended to every compiled module. Self-accepting, so an\n * edit updates in place instead of triggering a full reload; the callback\n * re-mounts every `<aktion-app>` that hosts this module, replaying its\n * serialized `$state` so live UI state survives the edit.\n */\nconst HMR_FOOTER = `\nif (import.meta.hot) {\n import.meta.hot.accept((mod) => {\n const next = mod && mod.default;\n if (!next || typeof document === \"undefined\") return;\n for (const el of document.querySelectorAll(\"aktion-app\")) {\n if (el.sourceId !== next.path) continue;\n el.mountCompiled(next, el.serializeState());\n }\n });\n}\n`;\n"],"names":["compile"],"mappings":";;;AAwCO,SAAS,aAAa,UAA+B,IAAY;AACtE,MAAI,UAAU;AACd,SAAO;AAAA,IACL,MAAM;AAAA;AAAA;AAAA,IAGN,SAAS;AAAA,IACT,eAAe,QAAQ;AACrB,gBAAU,OAAO,YAAY;AAAA,IAC/B;AAAA,IACA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,WAAW,EAAE,EAAG,QAAO;AAC5B,YAAM,UAA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Tzo8.js";
2
- function aktionPlugin(options = {}) {
3
- let isServe = false;
4
- return {
5
- name: "aktion",
6
- // Run before the core JS/TS transforms so we own `.aktion` modules and
7
- // downstream tooling only ever sees the generated JS.
8
- enforce: "pre",
9
- configResolved(config) {
10
- isServe = config.command === "serve";
11
- },
12
- transform(code, id) {
13
- if (!isAktionId(id)) return null;
14
- const cleanId = stripQuery(id);
15
- const result = compile(code, {
16
- path: cleanId,
17
- library: options.library,
18
- schemaErrorsFatal: options.schemaErrorsFatal,
19
- requireEntry: options.requireEntry,
20
- runtimeModuleId: options.runtimeModuleId,
21
- sourcemap: true
22
- });
23
- for (const dep of result.dependencies) {
24
- if (dep !== cleanId) this.addWatchFile(dep);
25
- }
26
- const fatal = result.diagnostics.find((d) => d.severity === "error");
27
- if (fatal) {
28
- return this.error(fatal.message, { line: fatal.line, column: fatal.column });
29
- }
30
- for (const diag of result.diagnostics) {
31
- if (diag.severity === "warning") {
32
- this.warn(diag.message, { line: diag.line, column: diag.column });
33
- }
34
- }
35
- const finalCode = isServe ? result.code + HMR_FOOTER : result.code;
36
- return { code: finalCode, map: result.map };
37
- }
38
- };
39
- }
40
- function isAktionId(id) {
41
- return stripQuery(id).endsWith(".aktion");
42
- }
43
- function stripQuery(id) {
44
- const q = id.indexOf("?");
45
- const base = q === -1 ? id : id.slice(0, q);
46
- const h = base.indexOf("#");
47
- return h === -1 ? base : base.slice(0, h);
48
- }
49
- const HMR_FOOTER = `
50
- if (import.meta.hot) {
51
- import.meta.hot.accept((mod) => {
52
- const next = mod && mod.default;
53
- if (!next || typeof document === "undefined") return;
54
- for (const el of document.querySelectorAll("aktion-app")) {
55
- if (el.sourceId !== next.path) continue;
56
- el.mountCompiled(next, el.serializeState());
57
- }
58
- });
59
- }
60
- `;
61
- export {
62
- aktionPlugin,
63
- aktionPlugin as default
64
- };
65
- //# sourceMappingURL=vite.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.js","sources":["../../src/plugin/vite.ts"],"sourcesContent":["/**\n * The Aktion Vite/Rollup plugin (`aktion-runtime/vite`).\n *\n * This is the ONLY module that imports from `vite`/`rollup`, and it is shipped\n * as a separate Node entry (see `vite.node.config.ts`) so neither the plugin\n * nor the compiler it pulls in (`compile()` + the linker + `magic-string`)\n * ever reaches the browser bundle.\n *\n * Responsibilities:\n * - `transform`: compile a `.aktion` file (resolving any cross-file\n * `import`/`export` graph) into a module exporting a `CompiledProgram`,\n * surface diagnostics as build errors/warnings with source positions\n * (driving Vite's overlay), and append a self-accepting HMR block in dev.\n * - HMR: the appended block re-mounts every `<aktion-app>` showing the\n * changed module via `mountCompiled(next, el.serializeState())`, so live\n * `$state` survives an edit. Imported `.aktion` files are registered with\n * `this.addWatchFile`, so editing a dependency re-triggers the entry.\n */\n\nimport type { Plugin } from \"vite\";\nimport { compile } from \"../compiler/compile.js\";\nimport type { ComponentLibrary } from \"../library/types.js\";\n\nexport interface AktionPluginOptions {\n /** Library to validate against at build time. Default: the default library. */\n library?: ComponentLibrary;\n /** Treat schema violations as fatal build errors vs. warnings. Default: true. */\n schemaErrorsFatal?: boolean;\n /** Warn when a program has no `aktion = …` entry binding. Default: true. */\n requireEntry?: boolean;\n /** Specifier the emitted module imports the runtime helper from. Default: `\"aktion-runtime\"`. */\n runtimeModuleId?: string;\n}\n\n/**\n * The Aktion Vite/Rollup plugin. Add it to `plugins` in `vite.config.ts`:\n *\n * import aktion from \"aktion-runtime/vite\";\n * export default { plugins: [aktion()] };\n */\nexport function aktionPlugin(options: AktionPluginOptions = {}): Plugin {\n let isServe = false;\n return {\n name: \"aktion\",\n // Run before the core JS/TS transforms so we own `.aktion` modules and\n // downstream tooling only ever sees the generated JS.\n enforce: \"pre\",\n configResolved(config) {\n isServe = config.command === \"serve\";\n },\n transform(code, id) {\n if (!isAktionId(id)) return null;\n const cleanId = stripQuery(id);\n\n const result = compile(code, {\n path: cleanId,\n library: options.library,\n schemaErrorsFatal: options.schemaErrorsFatal,\n requireEntry: options.requireEntry,\n runtimeModuleId: options.runtimeModuleId,\n sourcemap: true,\n });\n\n // Register imported `.aktion` files so editing a dependency re-runs this\n // transform (HMR across the module graph).\n for (const dep of result.dependencies) {\n if (dep !== cleanId) this.addWatchFile(dep);\n }\n\n // First fatal diagnostic stops the build and drives the Vite overlay\n // (Rollup builds the code frame from the module source at this position).\n const fatal = result.diagnostics.find((d) => d.severity === \"error\");\n if (fatal) {\n return this.error(fatal.message, { line: fatal.line, column: fatal.column });\n }\n for (const diag of result.diagnostics) {\n if (diag.severity === \"warning\") {\n this.warn(diag.message, { line: diag.line, column: diag.column });\n }\n }\n\n const finalCode = isServe ? result.code + HMR_FOOTER : result.code;\n return { code: finalCode, map: result.map };\n },\n };\n}\n\n/** True for `*.aktion` ids (query/hash stripped). */\nexport function isAktionId(id: string): boolean {\n return stripQuery(id).endsWith(\".aktion\");\n}\n\nfunction stripQuery(id: string): string {\n const q = id.indexOf(\"?\");\n const base = q === -1 ? id : id.slice(0, q);\n const h = base.indexOf(\"#\");\n return h === -1 ? base : base.slice(0, h);\n}\n\n/**\n * Dev-only HMR block appended to every compiled module. Self-accepting, so an\n * edit updates in place instead of triggering a full reload; the callback\n * re-mounts every `<aktion-app>` that hosts this module, replaying its\n * serialized `$state` so live UI state survives the edit.\n */\nconst HMR_FOOTER = `\nif (import.meta.hot) {\n import.meta.hot.accept((mod) => {\n const next = mod && mod.default;\n if (!next || typeof document === \"undefined\") return;\n for (const el of document.querySelectorAll(\"aktion-app\")) {\n if (el.sourceId !== next.path) continue;\n el.mountCompiled(next, el.serializeState());\n }\n });\n}\n`;\n"],"names":[],"mappings":";AAwCO,SAAS,aAAa,UAA+B,IAAY;AACtE,MAAI,UAAU;AACd,SAAO;AAAA,IACL,MAAM;AAAA;AAAA;AAAA,IAGN,SAAS;AAAA,IACT,eAAe,QAAQ;AACrB,gBAAU,OAAO,YAAY;AAAA,IAC/B;AAAA,IACA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,WAAW,EAAE,EAAG,QAAO;A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program } from '../parser/types.js';
3
- import { RawSourceMap } from './sourcemap.js';
4
- import { ModuleResolver } from './linker.js';
5
- /** A single build-time diagnostic. Positions are 1-indexed, matching `loc`. */
6
- export interface CompileDiagnostic {
7
- line: number;
8
- column: number;
9
- message: string;
10
- severity: "error" | "warning";
11
- }
12
- export interface CompileOptions {
13
- /** Module id / file path — embedded in the artefact + diagnostics + map. */
14
- path?: string;
15
- /** Library to validate against. Default: `defaultLibrary`. */
16
- library?: ComponentLibrary;
17
- /** Treat schema violations as `error` (fatal) vs `warning`. Default: true. */
18
- schemaErrorsFatal?: boolean;
19
- /** Warn when no top-level `aktion = …` entry binding exists. Default: true. */
20
- requireEntry?: boolean;
21
- /** Generate a source map. Default: true. */
22
- sourcemap?: boolean;
23
- /** Specifier the emitted module imports the runtime helper from. */
24
- runtimeModuleId?: string;
25
- /**
26
- * Resolver for cross-file `import`/`export`. Defaults to a Node fs resolver
27
- * (relative specifiers resolved against the importer's directory). Tests pass
28
- * an in-memory resolver. A single-file program never invokes it.
29
- */
30
- resolver?: ModuleResolver;
31
- }
32
- export interface CompileResult {
33
- /** ES module text exporting a `CompiledProgram` (default export). */
34
- code: string;
35
- /** v3 source map, or `null` when `sourcemap: false`. */
36
- map: RawSourceMap | null;
37
- /** Parse + schema + lint diagnostics. The caller decides fatality. */
38
- diagnostics: CompileDiagnostic[];
39
- /** The parsed (and, once linked, merged) AST — returned for tests / callers. */
40
- program: Program;
41
- /**
42
- * Absolute paths of imported `.aktion` modules pulled into this program
43
- * (empty for a single-file program). The Vite plugin registers these with
44
- * `addWatchFile` so editing a dependency re-triggers the entry's transform.
45
- */
46
- dependencies: string[];
47
- }
48
- /**
49
- * Parse + validate `source` and generate the compiled ES module. Always
50
- * returns `code` (even when diagnostics contain errors) so the plugin can
51
- * choose between failing the build (driving the Vite overlay) and emitting
52
- * anyway; the plugin owns that policy.
53
- */
54
- export declare function compile(source: string, options?: CompileOptions): CompileResult;
@@ -1,15 +0,0 @@
1
- import { Program } from '../parser/types.js';
2
- export interface EmitOptions {
3
- /**
4
- * Module specifier the emitted code imports `defineCompiledProgram` from.
5
- * Defaults to `"aktion-runtime"`. Override for monorepos / local examples
6
- * that resolve the runtime under a different name.
7
- */
8
- runtimeModuleId?: string;
9
- }
10
- /**
11
- * Build the ES module source that exports the compiled program. The result is
12
- * deterministic for a given `(program, source, path)` so repeated builds and
13
- * resumed/cached transforms produce byte-identical output.
14
- */
15
- export declare function emitModule(program: Program, source: string, path: string, options?: EmitOptions): string;
@@ -1,40 +0,0 @@
1
- /**
2
- * Source-map generation for the build-time compiler (Node-oriented).
3
- *
4
- * Fidelity note — read before "improving" this. The Aktion DSL is compiled to
5
- * an inert data blob (`JSON.parse(...)`), NOT transpiled line-for-line to JS,
6
- * and the parser records start-only `loc` (line + column, 1-indexed) with no
7
- * end position or byte offset (see `src/parser/types.ts`). So a high-precision
8
- * range map is neither possible nor meaningful here. What IS valuable, and
9
- * what we produce, is a valid v3 map that:
10
- *
11
- * - registers the original `.aktion` file as a source with its full content
12
- * (`sourcesContent`), so it shows up in browser devtools, and
13
- * - anchors the generated module back to the original source,
14
- *
15
- * which is exactly what lets Vite chain the map and surface the original file.
16
- * Per-statement range mappings are a future enhancement gated on the parser
17
- * recording end positions.
18
- *
19
- * We use `magic-string` (already a transitive dep, promoted to a direct one)
20
- * because it is the de-facto standard every Vite/Rollup plugin uses, so the
21
- * VLQ-encoded output is guaranteed compatible with Vite's source-map pipeline.
22
- */
23
- /**
24
- * Plain v3 source map object (decoupled from magic-string's class instance).
25
- * Shaped to match Vite/Rollup's `ExistingRawSourceMap` so it flows straight
26
- * into the bundler's source-map pipeline when returned from `transform`.
27
- */
28
- export interface RawSourceMap {
29
- version: number;
30
- sources: string[];
31
- sourcesContent: string[];
32
- names: string[];
33
- mappings: string;
34
- file?: string;
35
- }
36
- /**
37
- * Produce a v3 source map tying `generatedCode` back to `source`. `path` names
38
- * the original file in `sources`; the map's `file` is `path + ".js"`.
39
- */
40
- export declare function generateSourceMap(source: string, generatedCode: string, path: string): RawSourceMap;
@@ -1,2 +0,0 @@
1
- import { ComponentSpec } from '../types.js';
2
- export declare const Theme: ComponentSpec;
@@ -1,21 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { ComponentLibrary } from '../library/types.js';
3
- export interface AktionPluginOptions {
4
- /** Library to validate against at build time. Default: the default library. */
5
- library?: ComponentLibrary;
6
- /** Treat schema violations as fatal build errors vs. warnings. Default: true. */
7
- schemaErrorsFatal?: boolean;
8
- /** Warn when a program has no `aktion = …` entry binding. Default: true. */
9
- requireEntry?: boolean;
10
- /** Specifier the emitted module imports the runtime helper from. Default: `"aktion-runtime"`. */
11
- runtimeModuleId?: string;
12
- }
13
- /**
14
- * The Aktion Vite/Rollup plugin. Add it to `plugins` in `vite.config.ts`:
15
- *
16
- * import aktion from "aktion-runtime/vite";
17
- * export default { plugins: [aktion()] };
18
- */
19
- export declare function aktionPlugin(options?: AktionPluginOptions): Plugin;
20
- /** True for `*.aktion` ids (query/hash stripped). */
21
- export declare function isAktionId(id: string): boolean;
@@ -1,36 +0,0 @@
1
- /**
2
- * Aktion 0.5 §27 — automatic v1 → 0.5 source codemod.
3
- *
4
- * The migration helper accepts a *v1* source string and returns a
5
- * best-effort *0.5* equivalent, plus a list of advisory notes describing
6
- * each transformation. The codemod targets the legacy surfaces enumerated
7
- * in `language-update-final.md` Appendix A; surfaces that have no clean
8
- * textual rewrite (e.g. `Action([@Set, …])`'s open-ended payload DSL)
9
- * surface a note pointing the author at the manual migration path.
10
- *
11
- * Why a text codemod rather than an AST-to-AST one? The v1 grammar is
12
- * accepted as a hard parse error by the current parser (the legacy
13
- * `name=value`, `$$x` sigil, `Name(args) = expr` macros, etc. all raise
14
- * definitive errors). Re-introducing v1 syntax just to round-trip
15
- * through the parser would defeat the purpose of removing it — and a
16
- * focused set of regexes handles the line-oriented transforms cleanly
17
- * because the v1 grammar is itself line-oriented.
18
- *
19
- * The codemod is idempotent: feeding its output back through `migrateV1`
20
- * is a no-op.
21
- */
22
- export interface MigrateV1Result {
23
- /** Best-effort 0.5 source. */
24
- source: string;
25
- /** Human-readable record of every transform that fired, in source order. */
26
- notes: string[];
27
- /** Hand-migration hints for surfaces that have no clean text rewrite. */
28
- manualMigrations: string[];
29
- }
30
- /**
31
- * Run the v1 → 0.5 codemod on `source`. The transform is best-effort:
32
- * unmigratable surfaces produce a `manualMigrations` note instead of an
33
- * automatic rewrite, so the caller knows which lines still need a human
34
- * touch.
35
- */
36
- export declare function migrateV1(source: string): MigrateV1Result;