aktion-runtime 0.5.4 → 0.5.5

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 (68) hide show
  1. package/README.md +90 -114
  2. package/dist/aktion.iife.js +106 -460
  3. package/dist/aktion.iife.js.map +1 -1
  4. package/dist/aktion.js +5530 -5076
  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} +13669 -12428
  11. package/dist/language.js.map +1 -0
  12. package/dist/plugin.cjs +2650 -0
  13. package/dist/plugin.cjs.map +1 -0
  14. package/dist/plugin.js +2650 -0
  15. package/dist/plugin.js.map +1 -0
  16. package/dist/system_prompt.txt +164 -447
  17. package/dist/system_prompt_chat.txt +33 -84
  18. package/dist/{node/index-DBgA3bHQ.cjs → testing.js} +28116 -12689
  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 -24
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/language-api.d.ts +8 -8
  33. package/dist/types/parser/types.d.ts +8 -8
  34. package/dist/types/plugin/index.d.ts +13 -6
  35. package/dist/types/renderer/renderer.d.ts +28 -0
  36. package/dist/types/runtime/builtins.d.ts +5 -11
  37. package/dist/types/runtime/effects.d.ts +15 -0
  38. package/dist/types/runtime/http.d.ts +0 -1
  39. package/dist/types/testing/index.d.ts +201 -0
  40. package/dist/types/theme/index.d.ts +3 -3
  41. package/dist/types/theme/styles.d.ts +1 -1
  42. package/dist/types/tooling/formatter.d.ts +7 -1
  43. package/dist/types/tooling/index.d.ts +0 -3
  44. package/package.json +21 -19
  45. package/dist/node/compile-BUw0GAvN.cjs +0 -491
  46. package/dist/node/compile-BUw0GAvN.cjs.map +0 -1
  47. package/dist/node/compile-DxttTzo8.js +0 -492
  48. package/dist/node/compile-DxttTzo8.js.map +0 -1
  49. package/dist/node/compiler.cjs +0 -11
  50. package/dist/node/compiler.cjs.map +0 -1
  51. package/dist/node/compiler.js +0 -11
  52. package/dist/node/compiler.js.map +0 -1
  53. package/dist/node/index-8OvnOYPI.js.map +0 -1
  54. package/dist/node/index-DBgA3bHQ.cjs.map +0 -1
  55. package/dist/node/language.cjs +0 -1244
  56. package/dist/node/language.cjs.map +0 -1
  57. package/dist/node/language.js +0 -1244
  58. package/dist/node/language.js.map +0 -1
  59. package/dist/node/vite.cjs +0 -65
  60. package/dist/node/vite.cjs.map +0 -1
  61. package/dist/node/vite.js +0 -65
  62. package/dist/node/vite.js.map +0 -1
  63. package/dist/types/compiler/compile.d.ts +0 -54
  64. package/dist/types/compiler/emit.d.ts +0 -15
  65. package/dist/types/compiler/sourcemap.d.ts +0 -40
  66. package/dist/types/library/components/theme.d.ts +0 -2
  67. package/dist/types/plugin/vite.d.ts +0 -21
  68. package/dist/types/tooling/codemod.d.ts +0 -36
@@ -1,1244 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-DBgA3bHQ.cjs");
4
- const grammarSpec = {
5
- name: "aktion",
6
- atoms: ["true", "false", "null", "undefined"],
7
- // Full reserved-word set, kept in sync with `KEYWORDS_AKTION` in
8
- // `src/parser/lexer.ts` plus the reserved top-level handle `aktion` and the
9
- // router handle `route`. Aktion's `$`-prefixed builtins (`$effect`, `$emit`,
10
- // …) lex as StateIdentifiers, so they are not in this keyword list. Every
11
- // entry is documented in `keywordDocs` so the playground can show a popup.
12
- keywords: [
13
- "function",
14
- "if",
15
- "else",
16
- "switch",
17
- "case",
18
- "break",
19
- "continue",
20
- "for",
21
- "while",
22
- "do",
23
- "of",
24
- "in",
25
- "let",
26
- "var",
27
- "const",
28
- "await",
29
- "async",
30
- "return",
31
- "default",
32
- "try",
33
- "catch",
34
- "finally",
35
- "throw",
36
- "new",
37
- "typeof",
38
- "instanceof",
39
- "delete",
40
- "void",
41
- "aktion",
42
- "route"
43
- ],
44
- operators: ["+", "-", "*", "/", "%", "!", "=", "<", ">", "?", ":", ".", ","],
45
- // Long operators include `??` and `?.` (nullish coalescing + optional chain)
46
- // and `...` (spread). Order matters: longest match wins.
47
- operatorsLong: ["...", "==", "!=", ">=", "<=", "&&", "||", "??", "?."],
48
- brackets: [
49
- { open: "(", close: ")" },
50
- { open: "[", close: "]" },
51
- { open: "{", close: "}" }
52
- ],
53
- comments: { line: "//", blockStart: "/*", blockEnd: "*/" },
54
- strings: {
55
- singleLineQuotes: ['"', "'"],
56
- multiLineQuote: "`"
57
- },
58
- identifier: {
59
- start: /[A-Za-z_]/,
60
- part: /[A-Za-z0-9_]/
61
- },
62
- sigils: { state: "$" }
63
- };
64
- const keywordDocs = {
65
- aktion: {
66
- summary: "Reserved entry-point binding — the root of the rendered UI tree.",
67
- syntax: "aktion = Component(...)",
68
- example: 'aktion = Stack([Heading("Hi"), Text("Welcome")])'
69
- },
70
- route: {
71
- summary: "Reactive router handle — exposes path, params, query, and navigate().",
72
- syntax: "route.path · route.params · route.query · route.navigate(path)",
73
- example: 'Button("Home", () => route.navigate("/"))'
74
- },
75
- $emit: {
76
- summary: "Dispatch a custom DOM event from the host element.",
77
- syntax: '$emit("event-name", detail)',
78
- example: 'Button("Save", () => $emit("saved", { id: $id }))'
79
- },
80
- function: {
81
- summary: "Declare a component or action — first-letter case does not matter.",
82
- syntax: "function name(params) { ... }",
83
- example: "function Greeting(name) {\n return Text(`Hello ${name}`)\n}"
84
- },
85
- $effect: {
86
- summary: "Run a side-effect when dependencies change (timers, fetch, analytics).",
87
- syntax: "$effect(() => { ... }, [deps])",
88
- example: '$effect(() => {\n $now = $util.now()\n}, ["every(1000)"])'
89
- },
90
- if: {
91
- summary: "Conditional statement — run a block when a condition is truthy.",
92
- syntax: "if (condition) { ... } else { ... }",
93
- example: "if (!$user) {\n return Spinner()\n}"
94
- },
95
- else: {
96
- summary: "Fallback branch executed when the matching `if` condition is falsy.",
97
- syntax: "if (condition) { ... } else { ... }",
98
- example: "if ($ok) { return Done() } else { return Retry() }"
99
- },
100
- switch: {
101
- summary: "Multi-way branch on a value — pair each arm with `case` / `default`.",
102
- syntax: "switch (value) { case x: ...; default: ... }",
103
- example: 'switch (tab) {\n case "list": return List()\n default: return Empty()\n}'
104
- },
105
- case: {
106
- summary: "A labelled arm inside a `switch` statement.",
107
- syntax: "case value: statements; break",
108
- example: 'case "grid": return Grid($items)'
109
- },
110
- break: {
111
- summary: "Exit the nearest enclosing loop or `switch` immediately.",
112
- syntax: "break",
113
- example: "for (let i = 0; i < n; i++) {\n if (done) break\n}"
114
- },
115
- continue: {
116
- summary: "Skip to the next iteration of the nearest enclosing loop.",
117
- syntax: "continue",
118
- example: "for (let x of items) {\n if (!x.ok) continue\n}"
119
- },
120
- for: {
121
- summary: "Loop — classic `for`, `for…of` (values), or `for…in` (keys).",
122
- syntax: "for (let i = 0; i < n; i++) { ... }",
123
- example: "for (let item of $items) {\n log(item)\n}"
124
- },
125
- while: {
126
- summary: "Loop while a condition stays truthy (checked before each pass).",
127
- syntax: "while (condition) { ... }",
128
- example: "while (i > 0) {\n i = i - 1\n}"
129
- },
130
- do: {
131
- summary: "Run a block once, then repeat while a condition holds.",
132
- syntax: "do { ... } while (condition)",
133
- example: "do {\n step()\n} while (hasMore)"
134
- },
135
- of: {
136
- summary: "Iterate the VALUES of an array/iterable in a `for…of` loop.",
137
- syntax: "for (let item of iterable) { ... }",
138
- example: "for (let row of $rows) { render(row) }"
139
- },
140
- in: {
141
- summary: "Iterate the KEYS of an object (`for…in`) or test key membership.",
142
- syntax: 'for (let key in obj) { ... } · "key" in obj',
143
- example: "for (let k in $config) { use(k) }"
144
- },
145
- let: {
146
- summary: "Declare a block-scoped mutable variable (supports destructuring).",
147
- syntax: "let name = value · let [a, b] = arr · let { x } = obj",
148
- example: "let { name, age = 0 } = $user"
149
- },
150
- var: {
151
- summary: "Declare a variable (function-scoped) — `let` is preferred.",
152
- syntax: "var name = value",
153
- example: "var total = 0"
154
- },
155
- const: {
156
- summary: "Declare a block-scoped constant binding (supports destructuring).",
157
- syntax: "const name = value",
158
- example: "const [first, ...rest] = $items"
159
- },
160
- await: {
161
- summary: "Await a promise inside an action/effect body (or expression).",
162
- syntax: "await expression",
163
- example: 'let res = await $http({ url: "https://api.example.com" })'
164
- },
165
- async: {
166
- summary: "Marks a function as async — accepted as a no-op modifier.",
167
- syntax: "async function name() { ... }",
168
- example: "async function load() {\n let data = await fetch()\n}"
169
- },
170
- return: {
171
- summary: "Return a value from a component / action / helper body.",
172
- syntax: "return expression",
173
- example: 'return Card({ title: "Done" })'
174
- },
175
- default: {
176
- summary: "The fallback arm of a `switch` (or wildcard route in Router).",
177
- syntax: "default: statements",
178
- example: "default: return NotFound()"
179
- },
180
- try: {
181
- summary: "Run code that may throw, handling errors in a `catch` block.",
182
- syntax: "try { ... } catch (e) { ... } finally { ... }",
183
- example: "try {\n risky()\n} catch (e) {\n log(e)\n}"
184
- },
185
- catch: {
186
- summary: "Handle an error thrown inside the preceding `try` block.",
187
- syntax: "catch (error) { ... }",
188
- example: "catch (e) { $error = e }"
189
- },
190
- finally: {
191
- summary: "Run cleanup after `try` / `catch`, regardless of outcome.",
192
- syntax: "finally { ... }",
193
- example: "finally { $loading = false }"
194
- },
195
- throw: {
196
- summary: "Raise an error — caught by an enclosing `try` / `catch`.",
197
- syntax: "throw value",
198
- example: 'throw "invalid state"'
199
- },
200
- new: {
201
- summary: "Construct an instance of a host class (Date, Map, Set, …).",
202
- syntax: "new Constructor(args)",
203
- example: "let now = new Date()"
204
- },
205
- typeof: {
206
- summary: `Return a string naming a value's type ("number", "string", …).`,
207
- syntax: "typeof value",
208
- example: 'if (typeof x === "number") { ... }'
209
- },
210
- instanceof: {
211
- summary: "Test whether a value is an instance of a constructor.",
212
- syntax: "value instanceof Constructor",
213
- example: "if (d instanceof Date) { ... }"
214
- },
215
- delete: {
216
- summary: "Remove a property from an object.",
217
- syntax: "delete obj.prop",
218
- example: "delete $form.draft"
219
- },
220
- void: {
221
- summary: "Evaluate an expression and yield `undefined`.",
222
- syntax: "void expression",
223
- example: "void sideEffect()"
224
- }
225
- };
226
- function createStreamTokenizer(spec = grammarSpec) {
227
- const startState = () => ({ inBacktick: false, inBlockComment: false });
228
- const copyState = (state) => ({ ...state });
229
- const atomSet = new Set(spec.atoms);
230
- const keywordSet = new Set(spec.keywords);
231
- const componentCallRe = /^[A-Z][A-Za-z0-9_]*/;
232
- const lowerIdentRe = /^[a-z_][A-Za-z0-9_]*/;
233
- const numberRe = /^-?\d+(?:\.\d+)?/;
234
- const operatorChars = /* @__PURE__ */ new Set([...spec.operators.join(""), ..."=<>!&|"]);
235
- const consumeStringBody = (stream, quote) => {
236
- while (!stream.eol()) {
237
- const ch = stream.next();
238
- if (!ch) return;
239
- if (ch === "\\") {
240
- stream.next();
241
- continue;
242
- }
243
- if (ch === quote) return;
244
- }
245
- };
246
- const token = (stream, state) => {
247
- if (state.inBacktick) {
248
- while (!stream.eol()) {
249
- const ch = stream.next();
250
- if (ch === "\\") {
251
- stream.next();
252
- continue;
253
- }
254
- if (ch === "`") {
255
- state.inBacktick = false;
256
- return "string";
257
- }
258
- }
259
- return "string";
260
- }
261
- if (state.inBlockComment) {
262
- while (!stream.eol()) {
263
- if (stream.match(spec.comments.blockEnd, true)) {
264
- state.inBlockComment = false;
265
- return "comment";
266
- }
267
- stream.next();
268
- }
269
- return "comment";
270
- }
271
- if (stream.eatWhile(/[ \t]/)) return null;
272
- if (stream.match(spec.comments.line, true)) {
273
- stream.skipToEnd();
274
- return "comment";
275
- }
276
- if (stream.match(spec.comments.blockStart, true)) {
277
- state.inBlockComment = true;
278
- while (!stream.eol()) {
279
- if (stream.match(spec.comments.blockEnd, true)) {
280
- state.inBlockComment = false;
281
- return "comment";
282
- }
283
- stream.next();
284
- }
285
- return "comment";
286
- }
287
- const next = stream.peek();
288
- if (next === null || next === void 0) return null;
289
- if (spec.strings.singleLineQuotes.includes(next)) {
290
- const quote = next;
291
- stream.next();
292
- consumeStringBody(stream, quote);
293
- return "string";
294
- }
295
- if (next === spec.strings.multiLineQuote) {
296
- stream.next();
297
- while (!stream.eol()) {
298
- const ch = stream.next();
299
- if (ch === "\\") {
300
- stream.next();
301
- continue;
302
- }
303
- if (ch === "`") return "string";
304
- }
305
- state.inBacktick = true;
306
- return "string";
307
- }
308
- if (next >= "0" && next <= "9") {
309
- if (stream.match(numberRe, true)) return "number";
310
- }
311
- if (next === "-" && stream.match(/^-\d+(?:\.\d+)?/, false)) {
312
- if (stream.match(numberRe, true)) return "number";
313
- }
314
- if (next === spec.sigils.state) {
315
- stream.next();
316
- if (stream.peek() === spec.sigils.state) stream.next();
317
- stream.eatWhile(spec.identifier.part);
318
- return "state";
319
- }
320
- if (spec.identifier.start.test(next)) {
321
- const upper = stream.match(componentCallRe, true);
322
- if (upper) {
323
- return "component";
324
- }
325
- const lower = stream.match(lowerIdentRe, true);
326
- if (lower) {
327
- const text = lower[0];
328
- if (atomSet.has(text)) return "atom";
329
- if (keywordSet.has(text)) return "keyword";
330
- const ahead = stream.peek();
331
- if (ahead === ".") return "loopvar";
332
- return "identifier";
333
- }
334
- }
335
- for (const op of spec.operatorsLong) {
336
- if (stream.match(op, true)) return "operator";
337
- }
338
- if (next === ".") {
339
- stream.next();
340
- if (stream.peek() && spec.identifier.start.test(stream.peek())) {
341
- stream.eatWhile(spec.identifier.part);
342
- return "property";
343
- }
344
- return "punctuation";
345
- }
346
- if ("()[]{},:?".includes(next)) {
347
- stream.next();
348
- return "punctuation";
349
- }
350
- if (operatorChars.has(next)) {
351
- stream.next();
352
- return "operator";
353
- }
354
- stream.next();
355
- return null;
356
- };
357
- return {
358
- startState,
359
- copyState,
360
- token,
361
- languageData: {
362
- commentTokens: { line: spec.comments.line, block: { open: spec.comments.blockStart, close: spec.comments.blockEnd } },
363
- closeBrackets: { brackets: ["(", "[", "{", '"', "'", "`"] },
364
- indentOnInput: /^\s*[)\]}]$/
365
- }
366
- };
367
- }
368
- const defaultTagMap = {
369
- comment: "comment",
370
- string: "string",
371
- number: "number",
372
- atom: "atom",
373
- keyword: "keyword",
374
- state: "variableName.special",
375
- component: "typeName",
376
- identifier: "variableName",
377
- loopvar: "variableName.local",
378
- property: "propertyName",
379
- operator: "operator",
380
- punctuation: null
381
- };
382
- const KEYWORDS = [
383
- { label: "function", detail: "Declare a component or action — either case works" },
384
- { label: "$effect", detail: "Reactive side-effect: $effect(() => { ... }, [deps])" },
385
- { label: "$router", detail: "pages = $router({ '/': Home(), default: NotFound() })" },
386
- { label: "switch", detail: "switch (value) { case …: …; break; default: … }" },
387
- { label: "for", detail: "for (let x of xs) { … }" },
388
- { label: "if", detail: "if (condition) { … } else { … }" },
389
- { label: "return", detail: "Return value from a component or action" },
390
- { label: "let", detail: "Declare a variable (reactive if $-prefixed)" },
391
- { label: "const", detail: "Declare a constant" },
392
- { label: "$emit", detail: "$emit('name', detail) — dispatch a CustomEvent" },
393
- { label: "cleanup", detail: "Register an effect teardown callback" }
394
- ];
395
- function getDiagnostics(source, library) {
396
- const program = index.parse(source);
397
- const schemaErrors = index.validateProgramSchema(program, library);
398
- return [
399
- ...program.errors.map((e) => ({
400
- line: e.line,
401
- column: e.column,
402
- message: e.message,
403
- severity: "error"
404
- })),
405
- ...schemaErrors.map((e) => ({
406
- line: e.line,
407
- column: e.column,
408
- message: e.message,
409
- severity: "error"
410
- }))
411
- ];
412
- }
413
- function getCompletions(source, position, library) {
414
- const ctx = analyseCursor(source, position);
415
- if (ctx.afterDollar) {
416
- return [
417
- { label: "$name = value", kind: "state", detail: "Declare or assign a reactive atom" },
418
- { label: "$state(initial)", kind: "builtin", detail: "Hook: per-instance state → [value, setValue] (like useState)" },
419
- { label: "$memo(() => value, [deps])", kind: "builtin", detail: "Hook: value recomputed only when deps change (like useMemo)" },
420
- { label: "$effect(() => {}, [deps])", kind: "builtin", detail: "Declarative side effect" },
421
- { label: "$store({ ...state, ...methods })", kind: "builtin", detail: "Global store: shared state + actions" },
422
- { label: "$http({ url, method, ... })", kind: "builtin", detail: "Reactive HTTP resource" },
423
- { label: "$router({ '/': Home(), default: NotFound() })", kind: "builtin", detail: "Outlet-first router" },
424
- { label: "$util", kind: "builtin", detail: "Runtime helper namespace ($util.format, $util.sum, …)" },
425
- { label: "$emit('name', detail)", kind: "builtin", detail: "Dispatch a CustomEvent" },
426
- { label: "$theme({ colors, radius, ... })", kind: "builtin", detail: "In-script theme override" },
427
- { label: "$storage", kind: "builtin", detail: "Persistent storage namespace ($storage.local, …)" },
428
- { label: "$console", kind: "builtin", detail: "Console namespace ($console.log, …)" },
429
- { label: "$i18n({ translations, ... })", kind: "builtin", detail: "Translation bundle" }
430
- ];
431
- }
432
- if (ctx.insideCall && ctx.callee) {
433
- const spec = index.findComponent(library, ctx.callee);
434
- if (spec) {
435
- return propCompletions(spec);
436
- }
437
- }
438
- const keywordItems = /* @__PURE__ */ new Map();
439
- for (const [label, doc] of Object.entries(keywordDocs)) {
440
- keywordItems.set(label, {
441
- label,
442
- kind: "keyword",
443
- detail: doc.summary,
444
- documentation: `${doc.syntax}
445
-
446
- ${doc.example}`
447
- });
448
- }
449
- for (const k of KEYWORDS) {
450
- if (!keywordItems.has(k.label)) {
451
- keywordItems.set(k.label, { label: k.label, kind: "keyword", detail: k.detail });
452
- }
453
- }
454
- return [
455
- ...keywordItems.values(),
456
- ...library.components.map((c) => ({
457
- label: c.name,
458
- kind: "component",
459
- detail: signaturePreview(c),
460
- documentation: c.description
461
- }))
462
- ];
463
- }
464
- function getHoverInfo(source, position, library) {
465
- const word = wordAt(source, position);
466
- if (!word) return null;
467
- const spec = index.findComponent(library, word);
468
- if (spec) {
469
- return {
470
- kind: "component",
471
- contents: `**${spec.name}** — ${spec.description ?? "Component."}
472
-
473
- Signature: \`${signaturePreview(spec)}\``
474
- };
475
- }
476
- if (word === "$state") {
477
- return { kind: "builtin", contents: "**$state(initial)** — hook returning `[value, setValue]` (per-instance state, like React's useState)" };
478
- }
479
- if (word === "$memo") {
480
- return { kind: "builtin", contents: "**$memo(() => value, [deps])** — hook returning a value recomputed only when a dependency changes (like React's useMemo)" };
481
- }
482
- if (word.startsWith("$")) {
483
- return { kind: "state", contents: `**${word}** — reactive state atom` };
484
- }
485
- const doc = keywordDocs[word];
486
- if (doc) {
487
- return { kind: "unknown", contents: formatKeywordHover(word, doc) };
488
- }
489
- const kw = KEYWORDS.find((k) => k.label === word);
490
- if (kw) {
491
- return { kind: "unknown", contents: `**${word}** — ${kw.detail}` };
492
- }
493
- return null;
494
- }
495
- function formatKeywordHover(word, doc) {
496
- return `**${word}** — ${doc.summary}
497
-
498
- **Syntax**
499
-
500
- \`\`\`js
501
- ${doc.syntax}
502
- \`\`\`
503
-
504
- **Example**
505
-
506
- \`\`\`js
507
- ${doc.example}
508
- \`\`\``;
509
- }
510
- function analyseCursor(source, position) {
511
- const offset = lineColumnToOffset(source, position);
512
- const prefix = source.slice(0, offset);
513
- const afterDollar = /\$[A-Za-z_]*$/.test(prefix);
514
- let depth = 0;
515
- let openCallIdx = -1;
516
- for (let i = prefix.length - 1; i >= 0; i -= 1) {
517
- const ch = prefix[i];
518
- if (ch === ")") depth += 1;
519
- else if (ch === "(") {
520
- if (depth === 0) {
521
- openCallIdx = i;
522
- break;
523
- }
524
- depth -= 1;
525
- }
526
- }
527
- let callee;
528
- let insideCall = false;
529
- if (openCallIdx > 0) {
530
- insideCall = true;
531
- const upto = prefix.slice(0, openCallIdx);
532
- const m = /([A-Za-z_][\w]*)\s*$/.exec(upto);
533
- if (m) callee = m[1];
534
- }
535
- return { callee, insideCall, afterDollar };
536
- }
537
- function propCompletions(spec) {
538
- const positional = index.findPositionalProp(spec);
539
- return spec.props.map((prop) => ({
540
- label: `${prop.name}:`,
541
- kind: "prop",
542
- detail: propDetail(prop, positional?.name === prop.name),
543
- documentation: prop.description
544
- }));
545
- }
546
- function propDetail(prop, isPositional) {
547
- const tags = [];
548
- if (isPositional) tags.push("positional");
549
- if (prop.required) tags.push("required");
550
- if (prop.enum) tags.push(`enum: ${prop.enum.map((e) => `"${e}"`).join(" | ")}`);
551
- const tagText = tags.length > 0 ? ` (${tags.join(", ")})` : "";
552
- return `${prop.type}${tagText}`;
553
- }
554
- function signaturePreview(spec) {
555
- const positional = index.findPositionalProp(spec);
556
- const positionalLabel = positional ? positional.name : "";
557
- const rest = spec.props.filter((p) => p.name !== positional?.name).map((p) => `${p.name}${p.optional || !p.required ? "?" : ""}: ${p.type}`).join(", ");
558
- if (positionalLabel === "" && rest === "") return `${spec.name}()`;
559
- if (positionalLabel === "") return `${spec.name}(${rest})`;
560
- if (rest === "") return `${spec.name}(${positionalLabel})`;
561
- return `${spec.name}(${positionalLabel}, ${rest})`;
562
- }
563
- function lineColumnToOffset(source, pos) {
564
- let line = 1;
565
- let col = 1;
566
- for (let i = 0; i < source.length; i += 1) {
567
- if (line === pos.line && col === pos.column) return i;
568
- if (source[i] === "\n") {
569
- line += 1;
570
- col = 1;
571
- } else {
572
- col += 1;
573
- }
574
- }
575
- return source.length;
576
- }
577
- function wordAt(source, pos) {
578
- const offset = lineColumnToOffset(source, pos);
579
- const isWord = (c) => /[\w$]/.test(c);
580
- let start = offset;
581
- while (start > 0 && isWord(source[start - 1])) start -= 1;
582
- let end = offset;
583
- while (end < source.length && isWord(source[end])) end += 1;
584
- if (start === end) return null;
585
- return source.slice(start, end);
586
- }
587
- const snippetCatalog = [
588
- {
589
- name: "App",
590
- description: "Top-level `aktion` binding — every program needs one.",
591
- template: 'aktion = Column([\n ${1:Card([CardHeader("${2:Hello}")])}\n])'
592
- },
593
- {
594
- name: "Card",
595
- description: "Card with header + body block.",
596
- template: 'card${1} = Card([\n CardHeader("${2:Title}", { subtitle: "${3:Subtitle}" }),\n Column([\n Text("${4:Body copy goes here.}")\n ])\n])'
597
- },
598
- {
599
- name: "Row",
600
- description: "Horizontal toolbar — label on the left, actions pushed to the right.",
601
- template: 'toolbar${1} = Row([\n Text("${2:Section title}", { variant: "large-heavy" }),\n Spacer(),\n Button("${3:Action}", { variant: "primary" })\n], { gap: "m" })'
602
- },
603
- {
604
- name: "Center",
605
- description: "Center content on both axes inside a tall region.",
606
- template: 'empty${1} = Center([\n EmptyState("${2:Nothing here yet}", { description: "${3:Create your first item to get started.}" })\n], { minHeight: "${4:50vh}" })'
607
- },
608
- {
609
- name: "Hero",
610
- description: "Landing-page hero with eyebrow, title, subtitle, and a CTA.",
611
- template: 'function ${4:start}() { route.navigate("/start") }\nfunction ${5:openDemo}() { route.navigate("/demo") }\nhero${1} = Hero(\n "${2:Ship faster}",\n { subtitle: "${3:From idea to production in minutes.}",\n primary: Button("${6:Get started}", { action: ${4:start}, variant: "primary" }),\n secondary: Button("${7:Live demo}", { action: ${5:openDemo}, variant: "ghost" }),\n eyebrow: "${8:v2 launch}" }\n)'
612
- },
613
- {
614
- name: "PageHeader",
615
- description: "Dashboard page header with breadcrumbs and actions.",
616
- template: 'function ${6:runAction}() { /* TODO: implement */ }\nheader${1} = PageHeader(\n "${2:Page title}",\n { subtitle: "${3:Subtitle / meta line}",\n breadcrumbs: ["${4:Workspace}", "${5:Section}"],\n actions: [Button("${7:Action}", { action: ${6:runAction}, variant: "primary" })],\n status: Badge("${8:On track}", { variant: "success" }) }\n)'
617
- },
618
- {
619
- name: "Stats",
620
- description: "Responsive KPI strip with four StatCards.",
621
- template: 'metrics${1} = Stats([\n StatCard("${2:Active}", { value: "${3:12}", trend: "flat" }),\n StatCard("${4:At risk}", { value: "${5:4}", trend: "up", delta: "+2" }),\n StatCard("${6:Shipped}", { value: "${7:8}", trend: "up", delta: "+3" }),\n StatCard("${8:On-time}", { value: "${9:87%}", trend: "down", delta: "-3%" })\n])'
622
- },
623
- {
624
- name: "GridLayout",
625
- description: "12-column sidebar layout with named GridItem spans.",
626
- template: 'sidebar${1} = Card([CardHeader("${2:Sidebar}")])\nmain${1} = Card([CardHeader("${3:Main}")])\naktion = Grid([\n GridItem(sidebar${1}, { span: "1/4" }),\n GridItem(main${1}, { span: "3/4" })\n], { columns: 12, gap: "l" })'
627
- },
628
- {
629
- name: "KanbanBoard",
630
- description: "Three-column kanban board with sample cards.",
631
- template: 'board${1} = KanbanBoard([\n KanbanColumn("To do", { items: [\n KanbanCard("${2:Migrate auth}", { description: "${3:Roll out the new SDK.}", tags: ["auth"], assignee: "${4:Asha}" })\n ] }),\n KanbanColumn("Doing", { items: [\n KanbanCard("${5:Streaming UI v2}", { description: "${6:Ship 20 new components.}", tags: ["frontend"], assignee: "${7:Alex}", tone: "primary" })\n ] }),\n KanbanColumn("Done", { items: [\n KanbanCard("${8:Activity timeline}", { description: "${9:Shipped to 100%.}", tags: ["shipped"], assignee: "${10:Mira}", tone: "success" })\n ] })\n])'
632
- },
633
- {
634
- name: "FollowUpBlock",
635
- description: "Chat follow-up prompts.",
636
- template: 'follow${1} = FollowUpBlock([\n FollowUpItem("${2:Show me a chart}"),\n FollowUpItem("${3:Add a filter}"),\n FollowUpItem("${4:Export as CSV}")\n])'
637
- },
638
- {
639
- name: "Router",
640
- description: "Multi-page router via $router({…}) with NavLink sidebar.",
641
- template: 'pages = $router({\n "/": HomePage(),\n "/dashboard": DashboardPage(),\n "/users/:id": UserPage(params.id),\n "/docs/*": DocsPage(params._),\n default: NotFoundPage()\n})\n\nfunction HomePage() {\n return Card([CardHeader("Welcome")])\n}\nfunction DashboardPage() {\n return Card([CardHeader("Dashboard")])\n}\nfunction UserPage(id) {\n return Card([CardHeader(`User ${id}`)])\n}\nfunction DocsPage(rest) {\n return Card([CardHeader(`Docs · ${rest}`)])\n}\nfunction NotFoundPage() {\n return Callout("Not found", { variant: "warning", description: `We couldn\'t find ${route.path}.` })\n}\n\nnav${1} = Row([\n NavLink("Home", { to: "/", variant: "ghost", exact: true }),\n NavLink("Dashboard", { to: "/dashboard", variant: "ghost" }),\n NavLink("Users", { to: "/users", variant: "ghost" })\n], { gap: "s" })'
642
- },
643
- {
644
- name: "Effect",
645
- description: "Lifecycle-managed effect (clock/interval) with cleanup.",
646
- template: '$${3:now} = ""\n\n$effect(() => {\n let id = setInterval(() => { $${3:now} = new Date().toISOString() }, 1000)\n cleanup(() => clearInterval(id))\n}, ["mount"])\n\nbody = Text($${3:now})'
647
- },
648
- {
649
- name: "Action",
650
- description: "Action declaration that POSTs through the $http() builtin.",
651
- template: '$${1:items} = []\n\nfunction add(text) {\n $${1:items} = [...$${1:items}, { id: $${1:items}.length + 1, text: text }]\n $response = $http({ url: "https://api.example.com/save", method: "POST", body: { item: { text: text } } })\n}'
652
- },
653
- {
654
- name: "MapList",
655
- description: "Map an array of items into a list of components using `.map`.",
656
- template: "list${1} = $items.map(item => Card([Text(item.${2:name})]))"
657
- },
658
- {
659
- name: "ForLoop",
660
- description: "Iterate over an array statement-style — usable in a function body.",
661
- template: "function build${1:List}() {\n let out = []\n for (let item of $items) {\n out.push(Card([Text(item.${2:name})]))\n }\n return Column(out)\n}"
662
- },
663
- {
664
- name: "FormReactive",
665
- description: "Two-way bound input with submit action.",
666
- template: '$draft = ""\n$items = []\n\nfunction add() {\n $items = [...$items, { id: $items.length + 1, text: $draft }]\n $draft = ""\n}\n\nform${1} = Column([\n Input("${2:draft}", { placeholder: "What needs doing?", type: "text", value: $draft }),\n Button("Add", { action: add, variant: "primary" })\n])'
667
- },
668
- {
669
- name: "Theme",
670
- description: "Brand-style theme override applied on top of the base theme.",
671
- template: 'theme = $theme({\n name: "${1:brand}",\n colors: {\n primary: "${2:#0969da}",\n primaryHover: "${3:#0860c4}",\n bg: "${4:#ffffff}",\n text: "${5:#1f2328}"\n },\n radius: { button: "${6:6px}", input: "${7:6px}" },\n font: {\n family: "${8:-apple-system, BlinkMacSystemFont, sans-serif}",\n heading: "${9:-apple-system, BlinkMacSystemFont, sans-serif}"\n }\n})'
672
- },
673
- {
674
- name: "Component",
675
- description: "Reusable component declaration — first-letter case is not significant; a function with no `return` simply renders nothing.",
676
- template: "function ${1:UserCard}(${2:user}) {\n return Card([\n Avatar(${2:user}.name),\n Text(${2:user}.role)\n ])\n}\n\nlist = $users.map(u => ${1:UserCard}(u))"
677
- },
678
- {
679
- name: "Ternary",
680
- description: "Pick between two expressions — the JS way to express a value-producing if.",
681
- template: "body${1} = ${2:condition} ? ${3:trueBranch} : ${4:falseBranch}"
682
- },
683
- {
684
- name: "IfStatement",
685
- description: "Imperative `if (cond) { … } else { … }` — usable inside function / effect bodies.",
686
- template: "if (${1:condition}) {\n ${2:// then branch}\n} else {\n ${3:// else branch}\n}"
687
- },
688
- {
689
- name: "SwitchStatement",
690
- description: "Switch on a value with case/default/break — statement form.",
691
- template: 'switch (${1:$tab}) {\n case "overview": ${2:// …}; break\n case "billing": ${3:// …}; break\n case "security": ${4:// …}; break\n default: ${5:// …}\n}'
692
- },
693
- {
694
- name: "TemplateLiteral",
695
- description: "Template literal with `${}` interpolation.",
696
- template: "greeting${1} = `Hello ${${2:$user.name}}, you have ${${3:$messages.length}} messages`"
697
- },
698
- {
699
- name: "Http",
700
- description: "Fire an $http() request and bind the reactive resource bag.",
701
- template: '$${1:response} = $http({\n url: "${2:https://api.example.com/items}",\n method: "${3:GET}",\n headers: { "Content-Type": "application/json" }\n})'
702
- },
703
- {
704
- name: "State",
705
- description: "Reactive state atom — declared with `$name = value`.",
706
- template: '$${1:name} = ${2:"default"}'
707
- },
708
- {
709
- name: "Store",
710
- description: "Global store — colocated state + actions shared across components (like Zustand/Pinia).",
711
- template: "${1:cart} = $store({\n ${2:items}: [],\n ${3:count}: (s) => s.${2:items}.length,\n ${4:add}: (s, item) => { s.${2:items} = [...s.${2:items}, item] },\n})"
712
- },
713
- {
714
- name: "useState",
715
- description: "`$state` hook — per-instance state with a [value, setValue] pair (like React's useState).",
716
- template: 'const [${1:value}, set${2:Value}] = $state(${3:"default"})'
717
- },
718
- {
719
- name: "useMemo",
720
- description: "`$memo` hook — value recomputed only when a dependency changes (like React's useMemo).",
721
- template: "const ${1:memoized} = $memo(() => ${2:compute}, [${3:deps}])"
722
- },
723
- {
724
- name: "Hook",
725
- description: "Custom hook declaration — a `$`-prefixed function that composes $state / $memo.",
726
- template: "function $use${1:Counter}(${2:start}) {\n const [${3:count}, set${4:Count}] = $state(${2:start})\n return { ${3:count}: ${3:count}, increment: () => set${4:Count}(v => v + 1) }\n}"
727
- },
728
- {
729
- name: "ResponsiveGrid",
730
- description: "Grid with a responsive column map per breakpoint.",
731
- template: 'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: "${3:l}" })'
732
- }
733
- ];
734
- function getSnippets() {
735
- return snippetCatalog;
736
- }
737
- const baseFonts = {
738
- fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
739
- fontFamilyHeading: "system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
740
- fontFamilyMono: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"
741
- };
742
- const baseFontScale = {
743
- fontSizeBase: "14px",
744
- fontSizeSm: "12px",
745
- fontSizeLg: "16px",
746
- fontSizeHeading: "16px",
747
- fontSizeTitle: "22px",
748
- fontWeightBody: "400",
749
- fontWeightHeading: "700",
750
- lineHeightBody: "1.5",
751
- lineHeightHeading: "1.2",
752
- letterSpacingHeading: "0",
753
- headingTextTransform: "none"
754
- };
755
- const baseSpacing = {
756
- spacingXs: "4px",
757
- spacingS: "8px",
758
- spacingM: "12px",
759
- spacingL: "20px",
760
- spacingXl: "32px"
761
- };
762
- const baseRadii = {
763
- radiusXs: "4px",
764
- radiusSm: "6px",
765
- radiusMd: "10px",
766
- radiusLg: "16px",
767
- radiusPill: "999px",
768
- radiusButton: "6px",
769
- radiusInput: "6px"
770
- };
771
- const baseButtons = {
772
- buttonFontWeight: "600",
773
- buttonTextTransform: "none",
774
- buttonLetterSpacing: "0",
775
- buttonPaddingY: "8px",
776
- buttonPaddingX: "14px"
777
- };
778
- const baseMotion = {
779
- transitionDuration: "120ms"
780
- };
781
- const lightTheme = {
782
- colorBg: "#ffffff",
783
- colorBgSubtle: "#f8fafc",
784
- colorSurface: "#ffffff",
785
- colorSurfaceMuted: "#f1f5f9",
786
- colorBorder: "#e2e8f0",
787
- colorBorderSubtle: "rgba(15, 23, 42, 0.08)",
788
- colorText: "#0f172a",
789
- colorTextMuted: "#475569",
790
- colorPrimary: "#6366f1",
791
- colorPrimaryHover: "#4f46e5",
792
- colorPrimaryText: "#ffffff",
793
- colorAccent: "#6366f1",
794
- colorAccentHover: "#4f46e5",
795
- colorAccentText: "#ffffff",
796
- colorFocusRing: "#6366f1",
797
- colorSuccess: "#10b981",
798
- colorWarning: "#f59e0b",
799
- colorDanger: "#ef4444",
800
- colorInfo: "#06b6d4",
801
- shadowSm: "0 1px 2px rgba(15, 23, 42, 0.06)",
802
- shadowMd: "0 6px 24px rgba(15, 23, 42, 0.08)",
803
- shadowLg: "0 18px 60px rgba(15, 23, 42, 0.12)",
804
- borderWidth: "1px",
805
- chart1: "#6366f1",
806
- chart2: "#10b981",
807
- chart3: "#f59e0b",
808
- chart4: "#ef4444",
809
- chart5: "#06b6d4",
810
- chart6: "#8b5cf6",
811
- ...baseFonts,
812
- ...baseFontScale,
813
- ...baseSpacing,
814
- ...baseRadii,
815
- ...baseButtons,
816
- ...baseMotion
817
- };
818
- const darkTheme = {
819
- ...lightTheme,
820
- colorBg: "#0b1220",
821
- colorBgSubtle: "#0f172a",
822
- colorSurface: "#111827",
823
- colorSurfaceMuted: "#1e293b",
824
- colorBorder: "#1f2937",
825
- colorBorderSubtle: "rgba(248, 250, 252, 0.08)",
826
- colorText: "#f8fafc",
827
- colorTextMuted: "#94a3b8",
828
- colorPrimary: "#818cf8",
829
- colorPrimaryHover: "#6366f1",
830
- colorPrimaryText: "#0b1220",
831
- colorAccent: "#818cf8",
832
- colorAccentHover: "#6366f1",
833
- colorAccentText: "#0b1220",
834
- colorFocusRing: "#818cf8",
835
- shadowSm: "0 1px 2px rgba(0, 0, 0, 0.4)",
836
- shadowMd: "0 8px 24px rgba(0, 0, 0, 0.4)",
837
- shadowLg: "0 22px 60px rgba(0, 0, 0, 0.55)"
838
- };
839
- const neonTheme = {
840
- ...lightTheme,
841
- colorBg: "#05060f",
842
- colorBgSubtle: "#0a0c1c",
843
- colorSurface: "#0d1024",
844
- colorSurfaceMuted: "#161a36",
845
- colorBorder: "#2a2f6b",
846
- colorBorderSubtle: "rgba(236, 72, 153, 0.18)",
847
- colorText: "#f5f3ff",
848
- colorTextMuted: "#a5b4fc",
849
- colorPrimary: "#ec4899",
850
- colorPrimaryHover: "#f472b6",
851
- colorPrimaryText: "#05060f",
852
- colorAccent: "#22d3ee",
853
- colorAccentHover: "#67e8f9",
854
- colorAccentText: "#05060f",
855
- colorFocusRing: "#ec4899",
856
- colorSuccess: "#34d399",
857
- colorWarning: "#fbbf24",
858
- colorDanger: "#f87171",
859
- colorInfo: "#22d3ee",
860
- fontFamily: "'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
861
- fontFamilyHeading: "'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
862
- fontFamilyMono: "'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
863
- letterSpacingHeading: "0.02em",
864
- radiusXs: "2px",
865
- radiusSm: "2px",
866
- radiusMd: "4px",
867
- radiusLg: "6px",
868
- radiusButton: "2px",
869
- radiusInput: "2px",
870
- shadowSm: "0 0 0 1px rgba(236, 72, 153, 0.25), 0 0 12px rgba(34, 211, 238, 0.18)",
871
- shadowMd: "0 0 0 1px rgba(236, 72, 153, 0.35), 0 0 28px rgba(34, 211, 238, 0.22)",
872
- shadowLg: "0 0 0 1px rgba(236, 72, 153, 0.45), 0 0 48px rgba(34, 211, 238, 0.35)",
873
- spacingXs: "4px",
874
- spacingS: "8px",
875
- spacingM: "14px",
876
- spacingL: "22px",
877
- spacingXl: "36px",
878
- chart1: "#ec4899",
879
- chart2: "#22d3ee",
880
- chart3: "#fbbf24",
881
- chart4: "#a78bfa",
882
- chart5: "#34d399",
883
- chart6: "#f472b6"
884
- };
885
- const pastelTheme = {
886
- ...lightTheme,
887
- colorBg: "#fdf6ff",
888
- colorBgSubtle: "#fbf2ff",
889
- colorSurface: "#ffffff",
890
- colorSurfaceMuted: "#f4ecff",
891
- colorBorder: "#ead8ff",
892
- colorBorderSubtle: "rgba(168, 132, 232, 0.18)",
893
- colorText: "#3b1f56",
894
- colorTextMuted: "#7d6193",
895
- colorPrimary: "#a78bfa",
896
- colorPrimaryHover: "#8b5cf6",
897
- colorPrimaryText: "#ffffff",
898
- colorAccent: "#5eead4",
899
- colorAccentHover: "#2dd4bf",
900
- colorAccentText: "#0f3a35",
901
- colorFocusRing: "#a78bfa",
902
- colorSuccess: "#5eead4",
903
- colorWarning: "#fcd34d",
904
- colorDanger: "#fda4af",
905
- colorInfo: "#93c5fd",
906
- fontFamily: "'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
907
- fontFamilyHeading: "'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
908
- fontFamilyMono: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
909
- radiusXs: "8px",
910
- radiusSm: "12px",
911
- radiusMd: "20px",
912
- radiusLg: "28px",
913
- radiusButton: "16px",
914
- radiusInput: "16px",
915
- shadowSm: "0 4px 14px rgba(168, 132, 232, 0.12)",
916
- shadowMd: "0 18px 40px rgba(168, 132, 232, 0.18)",
917
- shadowLg: "0 28px 70px rgba(168, 132, 232, 0.22)",
918
- spacingXs: "6px",
919
- spacingS: "12px",
920
- spacingM: "18px",
921
- spacingL: "28px",
922
- spacingXl: "44px",
923
- chart1: "#a78bfa",
924
- chart2: "#5eead4",
925
- chart3: "#fcd34d",
926
- chart4: "#fda4af",
927
- chart5: "#93c5fd",
928
- chart6: "#f9a8d4"
929
- };
930
- const glassTheme = {
931
- ...lightTheme,
932
- colorBg: "#0f1730",
933
- colorBgSubtle: "#13204a",
934
- colorSurface: "rgba(255, 255, 255, 0.08)",
935
- colorSurfaceMuted: "rgba(255, 255, 255, 0.04)",
936
- colorBorder: "rgba(255, 255, 255, 0.18)",
937
- colorBorderSubtle: "rgba(255, 255, 255, 0.10)",
938
- colorText: "#f1f5ff",
939
- colorTextMuted: "#b6c3e6",
940
- colorPrimary: "#60a5fa",
941
- colorPrimaryHover: "#3b82f6",
942
- colorPrimaryText: "#0b132b",
943
- colorAccent: "#22d3ee",
944
- colorAccentHover: "#67e8f9",
945
- colorAccentText: "#0b132b",
946
- colorFocusRing: "#60a5fa",
947
- colorSuccess: "#34d399",
948
- colorWarning: "#fbbf24",
949
- colorDanger: "#fb7185",
950
- colorInfo: "#22d3ee",
951
- fontFamily: "'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
952
- fontFamilyHeading: "'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
953
- fontFamilyMono: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
954
- radiusXs: "6px",
955
- radiusSm: "10px",
956
- radiusMd: "16px",
957
- radiusLg: "24px",
958
- radiusButton: "12px",
959
- radiusInput: "12px",
960
- shadowSm: "0 1px 2px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.08)",
961
- shadowMd: "0 18px 50px rgba(7, 14, 33, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.10)",
962
- shadowLg: "0 28px 80px rgba(7, 14, 33, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12)",
963
- spacingXs: "4px",
964
- spacingS: "10px",
965
- spacingM: "16px",
966
- spacingL: "24px",
967
- spacingXl: "40px",
968
- chart1: "#60a5fa",
969
- chart2: "#22d3ee",
970
- chart3: "#a78bfa",
971
- chart4: "#f472b6",
972
- chart5: "#34d399",
973
- chart6: "#fbbf24"
974
- };
975
- const brutalistTheme = {
976
- ...lightTheme,
977
- colorBg: "#fef9c3",
978
- colorBgSubtle: "#fde68a",
979
- colorSurface: "#ffffff",
980
- colorSurfaceMuted: "#fef3c7",
981
- colorBorder: "#0a0a0a",
982
- colorBorderSubtle: "#0a0a0a",
983
- colorText: "#0a0a0a",
984
- colorTextMuted: "#3f3f46",
985
- colorPrimary: "#1d4ed8",
986
- colorPrimaryHover: "#1e40af",
987
- colorPrimaryText: "#ffffff",
988
- colorAccent: "#dc2626",
989
- colorAccentHover: "#b91c1c",
990
- colorAccentText: "#ffffff",
991
- colorFocusRing: "#0a0a0a",
992
- colorSuccess: "#16a34a",
993
- colorWarning: "#ea580c",
994
- colorDanger: "#dc2626",
995
- colorInfo: "#0891b2",
996
- fontFamily: "'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",
997
- fontFamilyHeading: "'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",
998
- fontFamilyMono: "'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
999
- fontWeightHeading: "800",
1000
- letterSpacingHeading: "-0.01em",
1001
- headingTextTransform: "uppercase",
1002
- radiusXs: "0px",
1003
- radiusSm: "0px",
1004
- radiusMd: "0px",
1005
- radiusLg: "0px",
1006
- radiusPill: "0px",
1007
- radiusButton: "0px",
1008
- radiusInput: "0px",
1009
- borderWidth: "2px",
1010
- shadowSm: "3px 3px 0 0 #0a0a0a",
1011
- shadowMd: "6px 6px 0 0 #0a0a0a",
1012
- shadowLg: "10px 10px 0 0 #0a0a0a",
1013
- spacingXs: "4px",
1014
- spacingS: "10px",
1015
- spacingM: "16px",
1016
- spacingL: "22px",
1017
- spacingXl: "36px",
1018
- buttonFontWeight: "800",
1019
- buttonTextTransform: "uppercase",
1020
- buttonLetterSpacing: "0.02em",
1021
- chart1: "#dc2626",
1022
- chart2: "#1d4ed8",
1023
- chart3: "#16a34a",
1024
- chart4: "#ea580c",
1025
- chart5: "#7c3aed",
1026
- chart6: "#0a0a0a"
1027
- };
1028
- const skylineTheme = {
1029
- ...lightTheme,
1030
- colorBg: "#eff2f7",
1031
- colorBgSubtle: "#e6ecf3",
1032
- colorSurface: "#ffffff",
1033
- colorSurfaceMuted: "#f4f7fb",
1034
- colorBorder: "#d6deea",
1035
- colorBorderSubtle: "rgba(13, 27, 58, 0.08)",
1036
- colorText: "#0d1b3a",
1037
- colorTextMuted: "#5a6a85",
1038
- colorPrimary: "#003580",
1039
- colorPrimaryHover: "#002a66",
1040
- colorPrimaryText: "#ffffff",
1041
- colorAccent: "#0095d6",
1042
- colorAccentHover: "#0078ad",
1043
- colorAccentText: "#ffffff",
1044
- colorFocusRing: "#0095d6",
1045
- colorSuccess: "#1b8f4f",
1046
- colorWarning: "#c47e00",
1047
- colorDanger: "#c8362b",
1048
- colorInfo: "#0095d6",
1049
- fontFamily: "'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
1050
- fontFamilyHeading: "'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
1051
- fontFamilyMono: "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
1052
- radiusXs: "3px",
1053
- radiusSm: "4px",
1054
- radiusMd: "6px",
1055
- radiusLg: "10px",
1056
- radiusButton: "4px",
1057
- radiusInput: "4px",
1058
- shadowSm: "0 1px 0 rgba(13, 27, 58, 0.04), 0 1px 3px rgba(13, 27, 58, 0.06)",
1059
- shadowMd: "0 4px 16px rgba(13, 27, 58, 0.08), 0 1px 3px rgba(13, 27, 58, 0.04)",
1060
- shadowLg: "0 16px 40px rgba(13, 27, 58, 0.12), 0 2px 6px rgba(13, 27, 58, 0.06)",
1061
- spacingXs: "4px",
1062
- spacingS: "8px",
1063
- spacingM: "14px",
1064
- spacingL: "20px",
1065
- spacingXl: "32px",
1066
- chart1: "#003580",
1067
- chart2: "#0095d6",
1068
- chart3: "#1b8f4f",
1069
- chart4: "#c47e00",
1070
- chart5: "#d43594",
1071
- chart6: "#5a6a85"
1072
- };
1073
- const builtInThemes = {
1074
- light: lightTheme,
1075
- dark: darkTheme,
1076
- neon: neonTheme,
1077
- pastel: pastelTheme,
1078
- glass: glassTheme,
1079
- brutalist: brutalistTheme,
1080
- skyline: skylineTheme
1081
- };
1082
- const projectParam = (prop) => {
1083
- const param = {
1084
- name: prop.name,
1085
- type: prop.type,
1086
- required: !prop.optional
1087
- };
1088
- if (prop.description) param.description = prop.description;
1089
- if (prop.enum && prop.enum.length > 0) param.enumValues = prop.enum;
1090
- return param;
1091
- };
1092
- const buildSignature = (spec) => {
1093
- const parts = spec.props.map((p) => p.optional ? `${p.name}?` : p.name);
1094
- return `${spec.name}(${parts.join(", ")})`;
1095
- };
1096
- const buildGroupIndex = (library) => {
1097
- const index2 = /* @__PURE__ */ new Map();
1098
- for (const group of library.componentGroups ?? []) {
1099
- for (const name of group.components) index2.set(name, group.name);
1100
- }
1101
- return index2;
1102
- };
1103
- function getComponentCatalog(library = index.defaultLibrary) {
1104
- const groupOf = buildGroupIndex(library);
1105
- return library.components.map((spec) => ({
1106
- name: spec.name,
1107
- group: groupOf.get(spec.name) ?? "Other",
1108
- description: spec.description,
1109
- params: spec.props.map(projectParam),
1110
- signature: buildSignature(spec)
1111
- }));
1112
- }
1113
- function indexCatalog(entries) {
1114
- const out = {};
1115
- for (const entry of entries) out[entry.name] = entry;
1116
- return out;
1117
- }
1118
- function getLanguageSpec(library = index.defaultLibrary) {
1119
- const components = getComponentCatalog(library);
1120
- return {
1121
- grammar: grammarSpec,
1122
- tokenizer: createStreamTokenizer(grammarSpec),
1123
- tagMap: defaultTagMap,
1124
- components,
1125
- componentsByName: indexCatalog(components),
1126
- snippets: getSnippets(),
1127
- keywordDocs,
1128
- themeNames: Object.keys(builtInThemes),
1129
- severityTokenMap: { "parse-error": "error" },
1130
- iconAliases: COMMON_ICON_ALIASES
1131
- };
1132
- }
1133
- const COMMON_ICON_ALIASES = [
1134
- "house",
1135
- "user",
1136
- "users",
1137
- "gear",
1138
- "bell",
1139
- "envelope",
1140
- "magnifying-glass",
1141
- "plus",
1142
- "minus",
1143
- "pen",
1144
- "trash",
1145
- "check",
1146
- "xmark",
1147
- "arrow-right",
1148
- "arrow-left",
1149
- "arrow-up",
1150
- "arrow-down",
1151
- "chevron-right",
1152
- "chevron-left",
1153
- "chevron-down",
1154
- "chevron-up",
1155
- "ellipsis",
1156
- "ellipsis-vertical",
1157
- "star",
1158
- "heart",
1159
- "bookmark",
1160
- "calendar",
1161
- "clock",
1162
- "file",
1163
- "folder",
1164
- "image",
1165
- "video",
1166
- "music",
1167
- "chart-line",
1168
- "chart-bar",
1169
- "chart-pie",
1170
- "gauge",
1171
- "table",
1172
- "circle-info",
1173
- "circle-check",
1174
- "circle-exclamation",
1175
- "circle-question",
1176
- "triangle-exclamation",
1177
- "shield",
1178
- "lock",
1179
- "unlock",
1180
- "key",
1181
- "rocket",
1182
- "bolt",
1183
- "fire",
1184
- "snowflake",
1185
- "sun",
1186
- "moon",
1187
- "cloud",
1188
- "code",
1189
- "terminal",
1190
- "database",
1191
- "server",
1192
- "globe",
1193
- "link",
1194
- "share",
1195
- "download",
1196
- "upload",
1197
- "filter",
1198
- "sort",
1199
- "list",
1200
- "grid",
1201
- "columns",
1202
- "sidebar",
1203
- "bars",
1204
- "tag",
1205
- "tags",
1206
- "flag",
1207
- "trophy",
1208
- "medal",
1209
- "gift",
1210
- "cart-shopping",
1211
- "credit-card",
1212
- "money-bill",
1213
- "receipt",
1214
- "wallet",
1215
- "comment",
1216
- "comments",
1217
- "paper-plane",
1218
- "inbox",
1219
- "paper-clip",
1220
- "phone",
1221
- "video-camera",
1222
- "play",
1223
- "pause",
1224
- "stop",
1225
- "forward",
1226
- "backward",
1227
- "expand",
1228
- "compress",
1229
- "eye",
1230
- "eye-slash",
1231
- "thumbs-up",
1232
- "thumbs-down",
1233
- "thumbtack"
1234
- ];
1235
- exports.defaultLibrary = index.defaultLibrary;
1236
- exports.getCompletions = getCompletions;
1237
- exports.getComponentCatalog = getComponentCatalog;
1238
- exports.getDiagnostics = getDiagnostics;
1239
- exports.getHoverInfo = getHoverInfo;
1240
- exports.getLanguageSpec = getLanguageSpec;
1241
- exports.getSnippets = getSnippets;
1242
- exports.grammarSpec = grammarSpec;
1243
- exports.keywordDocs = keywordDocs;
1244
- //# sourceMappingURL=language.cjs.map