@kernlang/core 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/schema.js ADDED
@@ -0,0 +1,481 @@
1
+ /**
2
+ * AST Schema Validation — validates IRNode shape after parsing, before codegen.
3
+ *
4
+ * Defines required/optional props and allowed child types per node type.
5
+ * Catches malformed ASTs (missing required props, wrong children) at the
6
+ * parse boundary instead of scattering validation across 76 codegen functions.
7
+ *
8
+ * Props are classified by kind:
9
+ * - 'identifier' → validated by emitIdentifier
10
+ * - 'typeAnnotation' → validated by emitTypeAnnotation
11
+ * - 'importPath' → validated by emitImportSpecifier
12
+ * - 'rawExpr' → intentional escape hatch (handler code, expressions)
13
+ * - 'rawBlock' → intentional escape hatch (<<<...>>> blocks)
14
+ * - 'string' → free-form string value
15
+ * - 'boolean' → 'true'/'false'
16
+ * - 'number' → numeric value
17
+ */
18
+ // ── Schema Definitions ──────────────────────────────────────────────────
19
+ export const NODE_SCHEMAS = {
20
+ type: {
21
+ props: {
22
+ name: { required: true, kind: 'identifier' },
23
+ values: { kind: 'string' },
24
+ alias: { kind: 'rawExpr' },
25
+ export: { kind: 'boolean' },
26
+ },
27
+ },
28
+ interface: {
29
+ props: {
30
+ name: { required: true, kind: 'identifier' },
31
+ extends: { kind: 'typeAnnotation' },
32
+ export: { kind: 'boolean' },
33
+ },
34
+ allowedChildren: ['field'],
35
+ },
36
+ union: {
37
+ props: {
38
+ name: { required: true, kind: 'identifier' },
39
+ discriminant: { required: true, kind: 'identifier' },
40
+ export: { kind: 'boolean' },
41
+ },
42
+ allowedChildren: ['variant'],
43
+ },
44
+ variant: {
45
+ props: {
46
+ name: { required: true, kind: 'identifier' },
47
+ },
48
+ allowedChildren: ['field'],
49
+ },
50
+ field: {
51
+ props: {
52
+ name: { required: true, kind: 'identifier' },
53
+ type: { kind: 'typeAnnotation' },
54
+ optional: { kind: 'boolean' },
55
+ default: { kind: 'rawExpr' },
56
+ private: { kind: 'boolean' },
57
+ readonly: { kind: 'boolean' },
58
+ },
59
+ },
60
+ service: {
61
+ props: {
62
+ name: { required: true, kind: 'identifier' },
63
+ implements: { kind: 'typeAnnotation' },
64
+ export: { kind: 'boolean' },
65
+ },
66
+ allowedChildren: ['field', 'method', 'constructor', 'singleton'],
67
+ },
68
+ method: {
69
+ props: {
70
+ name: { required: true, kind: 'identifier' },
71
+ params: { kind: 'string' },
72
+ returns: { kind: 'typeAnnotation' },
73
+ async: { kind: 'boolean' },
74
+ stream: { kind: 'boolean' },
75
+ private: { kind: 'boolean' },
76
+ static: { kind: 'boolean' },
77
+ },
78
+ allowedChildren: ['handler'],
79
+ },
80
+ fn: {
81
+ props: {
82
+ name: { required: true, kind: 'identifier' },
83
+ params: { kind: 'string' },
84
+ returns: { kind: 'typeAnnotation' },
85
+ async: { kind: 'boolean' },
86
+ stream: { kind: 'boolean' },
87
+ export: { kind: 'boolean' },
88
+ },
89
+ allowedChildren: ['handler', 'signal', 'cleanup'],
90
+ },
91
+ machine: {
92
+ props: {
93
+ name: { required: true, kind: 'identifier' },
94
+ export: { kind: 'boolean' },
95
+ },
96
+ allowedChildren: ['state', 'transition'],
97
+ },
98
+ state: {
99
+ props: {
100
+ name: { required: true, kind: 'identifier' },
101
+ initial: { kind: 'boolean' },
102
+ },
103
+ },
104
+ transition: {
105
+ props: {
106
+ name: { required: true, kind: 'identifier' },
107
+ from: { required: true, kind: 'string' },
108
+ to: { required: true, kind: 'identifier' },
109
+ },
110
+ allowedChildren: ['handler'],
111
+ },
112
+ error: {
113
+ props: {
114
+ name: { required: true, kind: 'identifier' },
115
+ extends: { required: true, kind: 'identifier' },
116
+ message: { kind: 'string' },
117
+ export: { kind: 'boolean' },
118
+ },
119
+ allowedChildren: ['field', 'handler'],
120
+ },
121
+ config: {
122
+ props: {
123
+ name: { required: true, kind: 'identifier' },
124
+ export: { kind: 'boolean' },
125
+ },
126
+ allowedChildren: ['field'],
127
+ },
128
+ store: {
129
+ props: {
130
+ name: { required: true, kind: 'identifier' },
131
+ path: { required: true, kind: 'string' },
132
+ key: { required: true, kind: 'identifier' },
133
+ model: { required: true, kind: 'identifier' },
134
+ export: { kind: 'boolean' },
135
+ },
136
+ },
137
+ test: {
138
+ props: {
139
+ name: { required: true, kind: 'string' },
140
+ },
141
+ allowedChildren: ['describe', 'it', 'handler'],
142
+ },
143
+ event: {
144
+ props: {
145
+ name: { required: true, kind: 'identifier' },
146
+ export: { kind: 'boolean' },
147
+ },
148
+ allowedChildren: ['type'],
149
+ },
150
+ import: {
151
+ props: {
152
+ from: { required: true, kind: 'importPath' },
153
+ names: { kind: 'string' },
154
+ default: { kind: 'identifier' },
155
+ types: { kind: 'boolean' },
156
+ },
157
+ },
158
+ const: {
159
+ props: {
160
+ name: { required: true, kind: 'identifier' },
161
+ type: { kind: 'typeAnnotation' },
162
+ value: { kind: 'rawExpr' },
163
+ export: { kind: 'boolean' },
164
+ },
165
+ allowedChildren: ['handler'],
166
+ },
167
+ on: {
168
+ props: {
169
+ event: { required: true, kind: 'string' },
170
+ handler: { kind: 'identifier' },
171
+ key: { kind: 'string' },
172
+ async: { kind: 'boolean' },
173
+ },
174
+ allowedChildren: ['handler'],
175
+ },
176
+ websocket: {
177
+ props: {
178
+ path: { kind: 'string' },
179
+ name: { kind: 'identifier' },
180
+ export: { kind: 'boolean' },
181
+ },
182
+ allowedChildren: ['on'],
183
+ },
184
+ derive: {
185
+ props: {
186
+ name: { required: true, kind: 'identifier' },
187
+ expr: { required: true, kind: 'rawExpr' },
188
+ type: { kind: 'typeAnnotation' },
189
+ export: { kind: 'boolean' },
190
+ },
191
+ },
192
+ transform: {
193
+ props: {
194
+ name: { required: true, kind: 'identifier' },
195
+ target: { kind: 'rawExpr' },
196
+ via: { kind: 'rawExpr' },
197
+ type: { kind: 'typeAnnotation' },
198
+ export: { kind: 'boolean' },
199
+ },
200
+ allowedChildren: ['handler'],
201
+ },
202
+ action: {
203
+ props: {
204
+ name: { required: true, kind: 'identifier' },
205
+ params: { kind: 'string' },
206
+ returns: { kind: 'typeAnnotation' },
207
+ idempotent: { kind: 'boolean' },
208
+ reversible: { kind: 'boolean' },
209
+ export: { kind: 'boolean' },
210
+ },
211
+ allowedChildren: ['handler'],
212
+ },
213
+ guard: {
214
+ props: {
215
+ name: { kind: 'string' },
216
+ expr: { required: true, kind: 'rawExpr' },
217
+ else: { kind: 'rawExpr' },
218
+ confidence: { kind: 'number' },
219
+ },
220
+ },
221
+ assume: {
222
+ props: {
223
+ expr: { required: true, kind: 'rawExpr' },
224
+ scope: { kind: 'string' },
225
+ evidence: { required: true, kind: 'string' },
226
+ fallback: { required: true, kind: 'rawExpr' },
227
+ confidence: { kind: 'number' },
228
+ },
229
+ },
230
+ invariant: {
231
+ props: {
232
+ name: { kind: 'string' },
233
+ expr: { required: true, kind: 'rawExpr' },
234
+ confidence: { kind: 'number' },
235
+ },
236
+ },
237
+ each: {
238
+ props: {
239
+ name: { required: true, kind: 'identifier' },
240
+ in: { required: true, kind: 'rawExpr' },
241
+ index: { kind: 'identifier' },
242
+ },
243
+ },
244
+ collect: {
245
+ props: {
246
+ name: { required: true, kind: 'identifier' },
247
+ from: { required: true, kind: 'rawExpr' },
248
+ where: { kind: 'rawExpr' },
249
+ order: { kind: 'rawExpr' },
250
+ limit: { kind: 'number' },
251
+ export: { kind: 'boolean' },
252
+ },
253
+ },
254
+ branch: {
255
+ props: {
256
+ name: { required: true, kind: 'identifier' },
257
+ on: { required: true, kind: 'rawExpr' },
258
+ },
259
+ allowedChildren: ['path'],
260
+ },
261
+ model: {
262
+ props: {
263
+ name: { required: true, kind: 'identifier' },
264
+ table: { kind: 'string' },
265
+ export: { kind: 'boolean' },
266
+ },
267
+ allowedChildren: ['column', 'relation'],
268
+ },
269
+ repository: {
270
+ props: {
271
+ name: { required: true, kind: 'identifier' },
272
+ model: { required: true, kind: 'identifier' },
273
+ export: { kind: 'boolean' },
274
+ },
275
+ allowedChildren: ['method'],
276
+ },
277
+ dependency: {
278
+ props: {
279
+ name: { required: true, kind: 'identifier' },
280
+ scope: { kind: 'string' },
281
+ export: { kind: 'boolean' },
282
+ },
283
+ allowedChildren: ['inject', 'returns'],
284
+ },
285
+ cache: {
286
+ props: {
287
+ name: { required: true, kind: 'identifier' },
288
+ backend: { kind: 'string' },
289
+ prefix: { kind: 'string' },
290
+ ttl: { kind: 'number' },
291
+ export: { kind: 'boolean' },
292
+ },
293
+ allowedChildren: ['entry', 'invalidate'],
294
+ },
295
+ module: {
296
+ props: {
297
+ name: { required: true, kind: 'identifier' },
298
+ export: { kind: 'boolean' },
299
+ },
300
+ },
301
+ provider: {
302
+ props: {
303
+ name: { required: true, kind: 'identifier' },
304
+ type: { required: true, kind: 'typeAnnotation' },
305
+ },
306
+ allowedChildren: ['prop', 'handler'],
307
+ },
308
+ hook: {
309
+ props: {
310
+ name: { required: true, kind: 'identifier' },
311
+ params: { kind: 'string' },
312
+ returns: { kind: 'typeAnnotation' },
313
+ },
314
+ allowedChildren: ['handler', 'memo', 'callback', 'ref', 'effect'],
315
+ },
316
+ effect: {
317
+ props: {
318
+ name: { kind: 'identifier' },
319
+ deps: { kind: 'string' },
320
+ once: { kind: 'boolean' },
321
+ },
322
+ allowedChildren: ['prop', 'handler', 'cleanup'],
323
+ },
324
+ // ── Web / UI node types ──────────────────────────────────────────────
325
+ page: {
326
+ props: {
327
+ name: { required: true, kind: 'identifier' },
328
+ client: { kind: 'boolean' },
329
+ async: { kind: 'boolean' },
330
+ route: { kind: 'string' },
331
+ segment: { kind: 'string' },
332
+ },
333
+ },
334
+ layout: {
335
+ props: {
336
+ lang: { kind: 'string' },
337
+ route: { kind: 'string' },
338
+ },
339
+ },
340
+ loading: {
341
+ props: {},
342
+ },
343
+ metadata: {
344
+ props: {
345
+ title: { kind: 'string' },
346
+ description: { kind: 'string' },
347
+ keywords: { kind: 'string' },
348
+ ogImage: { kind: 'string' },
349
+ },
350
+ },
351
+ link: {
352
+ props: {
353
+ to: { required: true, kind: 'string' },
354
+ },
355
+ },
356
+ textarea: {
357
+ props: {
358
+ bind: { kind: 'identifier' },
359
+ placeholder: { kind: 'string' },
360
+ spellcheck: { kind: 'boolean' },
361
+ },
362
+ },
363
+ slider: {
364
+ props: {
365
+ bind: { kind: 'identifier' },
366
+ min: { kind: 'number' },
367
+ max: { kind: 'number' },
368
+ step: { kind: 'number' },
369
+ },
370
+ },
371
+ toggle: {
372
+ props: {
373
+ bind: { kind: 'identifier' },
374
+ },
375
+ },
376
+ grid: {
377
+ props: {
378
+ cols: { kind: 'number' },
379
+ gap: { kind: 'number' },
380
+ },
381
+ },
382
+ component: {
383
+ props: {
384
+ ref: { kind: 'identifier' },
385
+ name: { kind: 'identifier' },
386
+ bind: { kind: 'identifier' },
387
+ onChange: { kind: 'rawExpr' },
388
+ props: { kind: 'string' },
389
+ disabled: { kind: 'rawExpr' },
390
+ },
391
+ },
392
+ icon: {
393
+ props: {
394
+ name: { required: true, kind: 'identifier' },
395
+ },
396
+ },
397
+ logic: {
398
+ props: {
399
+ code: { kind: 'rawBlock' },
400
+ },
401
+ allowedChildren: ['handler'],
402
+ },
403
+ form: {
404
+ props: {
405
+ action: { kind: 'string' },
406
+ method: { kind: 'string' },
407
+ },
408
+ },
409
+ svg: {
410
+ props: {
411
+ icon: { kind: 'string' },
412
+ size: { kind: 'number' },
413
+ viewBox: { kind: 'string' },
414
+ width: { kind: 'number' },
415
+ height: { kind: 'number' },
416
+ content: { kind: 'string' },
417
+ fill: { kind: 'string' },
418
+ stroke: { kind: 'string' },
419
+ },
420
+ },
421
+ };
422
+ /**
423
+ * Validate an IRNode tree against the schema definitions.
424
+ * Returns violations found. Empty array = valid.
425
+ */
426
+ export function validateSchema(root) {
427
+ const violations = [];
428
+ validateNode(root, violations);
429
+ return violations;
430
+ }
431
+ function validateNode(node, violations) {
432
+ const schema = Object.hasOwn(NODE_SCHEMAS, node.type) ? NODE_SCHEMAS[node.type] : undefined;
433
+ if (schema) {
434
+ const props = node.props || {};
435
+ // Check required props
436
+ for (const [propName, propSchema] of Object.entries(schema.props)) {
437
+ if (propSchema.required && !(propName in props)) {
438
+ violations.push({
439
+ nodeType: node.type,
440
+ message: `'${node.type}' requires prop '${propName}'`,
441
+ line: node.loc?.line,
442
+ col: node.loc?.col,
443
+ });
444
+ }
445
+ }
446
+ // Cross-prop validation: component needs ref or name
447
+ if (node.type === 'component' && !('ref' in props) && !('name' in props)) {
448
+ violations.push({
449
+ nodeType: 'component',
450
+ message: "'component' requires either 'ref' or 'name' prop",
451
+ line: node.loc?.line,
452
+ col: node.loc?.col,
453
+ });
454
+ }
455
+ // Check allowed children
456
+ if (schema.allowedChildren && node.children) {
457
+ for (const child of node.children) {
458
+ if (!schema.allowedChildren.includes(child.type)) {
459
+ // Don't flag structural children that are consumed by parents
460
+ // (handler, reason, evidence, needs, etc.)
461
+ const universalChildren = ['handler', 'cleanup', 'reason', 'evidence', 'needs', 'signal'];
462
+ if (!universalChildren.includes(child.type)) {
463
+ violations.push({
464
+ nodeType: node.type,
465
+ message: `'${node.type}' does not allow child type '${child.type}' (allowed: ${schema.allowedChildren.join(', ')})`,
466
+ line: child.loc?.line,
467
+ col: child.loc?.col,
468
+ });
469
+ }
470
+ }
471
+ }
472
+ }
473
+ }
474
+ // Recurse into children
475
+ if (node.children) {
476
+ for (const child of node.children) {
477
+ validateNode(child, violations);
478
+ }
479
+ }
480
+ }
481
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAgBH,2EAA2E;AAE3E,MAAM,CAAC,MAAM,YAAY,GAA+B;IACtD,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE;YAC5C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,KAAK,EAAE,EAAE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oBAC1F,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC5C,UAAU,CAAC,IAAI,CAAC;4BACd,QAAQ,EAAE,IAAI,CAAC,IAAI;4BACnB,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,gCAAgC,KAAK,CAAC,IAAI,eAAe,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;4BACnH,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI;4BACrB,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG;yBACpB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;AACH,CAAC"}
package/dist/spec.d.ts CHANGED
@@ -11,19 +11,20 @@
11
11
  */
12
12
  export declare const KERN_VERSION = "2.0.0";
13
13
  export declare const IR_GRAMMAR = "\ndocument = node+\nnode = indent type (SP prop)* (SP style)? (SP themeref)* NL child*\nchild = node\nindent = \" \"*\ntype = ident\nprop = ident \"=\" value\nvalue = quoted | bare\nquoted = '\"' [^\"]* '\"'\nbare = [^\\s{$]+\nstyle = \"{\" spair (\",\" spair)* \"}\"\nspair = sident \":\" svalue | \":\" pseudo \":\" sident \":\" svalue\npseudo = \"press\" | \"hover\" | \"active\" | \"focus\"\nsident = shorthand | ident\nsvalue = [^,}]+\nthemeref = \"$\" ident\nident = [A-Za-z_][A-Za-z0-9_-]*\nSP = \" \"+\nNL = \"\\n\" | EOF\n";
14
- export declare const NODE_TYPES: readonly ["screen", "row", "col", "card", "scroll", "text", "image", "progress", "divider", "codeblock", "section", "button", "input", "modal", "list", "item", "tabs", "tab", "header", "theme", "server", "route", "middleware", "handler", "schema", "stream", "spawn", "timer", "on", "env", "websocket", "params", "auth", "validate", "respond", "trigger", "cli", "command", "arg", "flag", "import", "separator", "table", "thead", "tbody", "tr", "th", "td", "scoreboard", "metric", "spinner", "progress", "box", "gradient", "state", "repl", "guard", "parallel", "dispatch", "then", "each", "generateMetadata", "notFound", "redirect", "fetch", "type", "interface", "field", "fn", "union", "variant", "service", "method", "singleton", "constructor", "signal", "cleanup", "machine", "transition", "error", "module", "export", "config", "store", "test", "describe", "it", "event", "hook", "provider", "effect", "memo", "callback", "ref", "context", "cleanup", "prop", "returns", "input-area", "output-area", "text-input", "select-input", "model", "column", "relation", "repository", "dependency", "inject", "cache", "entry", "invalidate", "conditional", "select", "option", "template", "slot", "body", "derive", "transform", "action", "assume", "invariant", "branch", "path", "resolve", "candidate", "discriminator", "collect", "pattern", "apply", "expect", "recover", "strategy", "reason", "evidence", "needs", "rule", "message"];
14
+ export declare const NODE_TYPES: readonly ["screen", "page", "row", "col", "card", "grid", "scroll", "text", "image", "progress", "divider", "codeblock", "section", "form", "button", "input", "textarea", "slider", "toggle", "modal", "list", "item", "tabs", "tab", "header", "link", "theme", "server", "route", "middleware", "handler", "schema", "stream", "spawn", "timer", "on", "env", "websocket", "params", "auth", "validate", "respond", "trigger", "cli", "command", "arg", "flag", "import", "separator", "table", "thead", "tbody", "tr", "th", "td", "scoreboard", "metric", "spinner", "box", "gradient", "state", "repl", "guard", "parallel", "dispatch", "then", "each", "layout", "loading", "metadata", "generateMetadata", "notFound", "redirect", "fetch", "type", "interface", "field", "fn", "const", "union", "variant", "service", "method", "singleton", "constructor", "signal", "cleanup", "machine", "transition", "error", "module", "export", "config", "store", "test", "describe", "it", "event", "hook", "provider", "effect", "logic", "memo", "callback", "ref", "context", "prop", "returns", "input-area", "output-area", "text-input", "select-input", "model", "column", "relation", "repository", "dependency", "inject", "cache", "entry", "invalidate", "conditional", "component", "select", "option", "icon", "svg", "template", "slot", "body", "derive", "transform", "action", "assume", "invariant", "branch", "path", "resolve", "candidate", "discriminator", "collect", "pattern", "apply", "expect", "recover", "strategy", "reason", "evidence", "needs", "rule", "message"];
15
15
  export type IRNodeType = (typeof NODE_TYPES)[number];
16
+ import { type KernRuntime } from './runtime.js';
16
17
  /** Register an evolved node type (called at startup from .kern/evolved/). */
17
18
  export declare function registerEvolvedType(keyword: string): void;
18
19
  /** Unregister an evolved node type (for rollback/testing). */
19
20
  export declare function unregisterEvolvedType(keyword: string): void;
20
21
  /** Check if a type is a known node type (core or evolved). */
21
- export declare function isKnownNodeType(type: string): boolean;
22
- /** Get all dynamically registered evolved types. */
22
+ export declare function isKnownNodeType(type: string, runtime?: KernRuntime): boolean;
23
+ /** Get all dynamically registered evolved types (defensive copy). */
23
24
  export declare function getEvolvedTypes(): ReadonlySet<string>;
24
25
  /** Clear all dynamic types (for test isolation). */
25
26
  export declare function clearEvolvedTypes(): void;
26
27
  /** Reserved keywords — evolved nodes cannot use these. */
27
- export declare const KERN_RESERVED: Set<"route" | "middleware" | "config" | "entry" | "command" | "hook" | "theme" | "template" | "websocket" | "model" | "service" | "error" | "type" | "slot" | "import" | "body" | "handler" | "then" | "export" | "field" | "variant" | "constructor" | "params" | "method" | "stream" | "returns" | "singleton" | "signal" | "cleanup" | "message" | "state" | "transition" | "path" | "describe" | "it" | "event" | "scroll" | "on" | "reason" | "evidence" | "needs" | "guard" | "invariant" | "item" | "branch" | "candidate" | "discriminator" | "select" | "metric" | "strategy" | "pattern" | "option" | "table" | "column" | "relation" | "text" | "inject" | "invalidate" | "interface" | "fn" | "union" | "machine" | "module" | "store" | "test" | "derive" | "transform" | "action" | "assume" | "each" | "collect" | "resolve" | "expect" | "recover" | "apply" | "repository" | "dependency" | "cache" | "conditional" | "effect" | "auth" | "screen" | "row" | "col" | "card" | "image" | "progress" | "divider" | "codeblock" | "section" | "button" | "input" | "modal" | "list" | "tabs" | "tab" | "header" | "server" | "schema" | "spawn" | "timer" | "env" | "validate" | "respond" | "trigger" | "cli" | "arg" | "flag" | "separator" | "thead" | "tbody" | "tr" | "th" | "td" | "scoreboard" | "spinner" | "box" | "gradient" | "repl" | "parallel" | "dispatch" | "generateMetadata" | "notFound" | "redirect" | "fetch" | "provider" | "memo" | "callback" | "ref" | "context" | "prop" | "input-area" | "output-area" | "text-input" | "select-input" | "rule">;
28
+ export declare const KERN_RESERVED: ReadonlySet<string>;
28
29
  export declare const STYLE_SHORTHANDS: Record<string, string>;
29
30
  export declare const VALUE_SHORTHANDS: Record<string, string>;
package/dist/spec.js CHANGED
@@ -34,17 +34,17 @@ NL = "\\n" | EOF
34
34
  // ── Node Types ──────────────────────────────────────────────────────────
35
35
  export const NODE_TYPES = [
36
36
  // Layout
37
- 'screen', 'row', 'col', 'card', 'scroll',
37
+ 'screen', 'page', 'row', 'col', 'card', 'grid', 'scroll',
38
38
  // Content
39
39
  'text', 'image', 'progress', 'divider', 'codeblock',
40
40
  // Structural
41
- 'section',
41
+ 'section', 'form',
42
42
  // Interactive
43
- 'button', 'input', 'modal',
43
+ 'button', 'input', 'textarea', 'slider', 'toggle', 'modal',
44
44
  // Lists
45
45
  'list', 'item',
46
46
  // Navigation
47
- 'tabs', 'tab', 'header',
47
+ 'tabs', 'tab', 'header', 'link',
48
48
  // Meta
49
49
  'theme',
50
50
  // Backend
@@ -56,12 +56,14 @@ export const NODE_TYPES = [
56
56
  'cli', 'command', 'arg', 'flag', 'import',
57
57
  // Terminal
58
58
  'separator', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'scoreboard', 'metric',
59
- 'spinner', 'progress', 'box', 'gradient',
59
+ 'spinner', 'box', 'gradient',
60
60
  'state', 'repl', 'guard', 'parallel', 'dispatch', 'then', 'each',
61
+ // Next.js App Router
62
+ 'layout', 'loading',
61
63
  // Next.js production patterns
62
- 'generateMetadata', 'notFound', 'redirect', 'fetch',
64
+ 'metadata', 'generateMetadata', 'notFound', 'redirect', 'fetch',
63
65
  // Core Language — type system, functions, state machines
64
- 'type', 'interface', 'field', 'fn',
66
+ 'type', 'interface', 'field', 'fn', 'const',
65
67
  'union', 'variant',
66
68
  'service', 'method', 'singleton', 'constructor',
67
69
  'signal', 'cleanup',
@@ -71,8 +73,8 @@ export const NODE_TYPES = [
71
73
  'test', 'describe', 'it',
72
74
  'event',
73
75
  // React — hooks, providers, effects
74
- 'hook', 'provider', 'effect',
75
- 'memo', 'callback', 'ref', 'context', 'cleanup',
76
+ 'hook', 'provider', 'effect', 'logic',
77
+ 'memo', 'callback', 'ref', 'context',
76
78
  'prop', 'returns',
77
79
  // Ink — terminal React (Ink) specific nodes
78
80
  'input-area', 'output-area', 'text-input', 'select-input',
@@ -82,8 +84,10 @@ export const NODE_TYPES = [
82
84
  'dependency', 'inject',
83
85
  'cache', 'entry', 'invalidate',
84
86
  // UI controls
85
- 'conditional',
87
+ 'conditional', 'component',
86
88
  'select', 'option',
89
+ // Graphics
90
+ 'icon', 'svg',
87
91
  // Template system
88
92
  'template', 'slot', 'body',
89
93
  // Ground layer — semantic reasoning
@@ -100,39 +104,46 @@ export const NODE_TYPES = [
100
104
  ];
101
105
  // ── Dynamic Node Types (Evolve v4 — graduated nodes) ────────────────────
102
106
  // Evolved nodes register here at startup. Checked by parser alongside NODE_TYPES.
103
- const _dynamicNodeTypes = new Set();
107
+ import { defaultRuntime } from './runtime.js';
104
108
  /** Register an evolved node type (called at startup from .kern/evolved/). */
105
109
  export function registerEvolvedType(keyword) {
106
- _dynamicNodeTypes.add(keyword);
110
+ defaultRuntime.registerEvolvedType(keyword);
107
111
  }
108
112
  /** Unregister an evolved node type (for rollback/testing). */
109
113
  export function unregisterEvolvedType(keyword) {
110
- _dynamicNodeTypes.delete(keyword);
114
+ defaultRuntime.unregisterEvolvedType(keyword);
111
115
  }
112
116
  /** Check if a type is a known node type (core or evolved). */
113
- export function isKnownNodeType(type) {
114
- return NODE_TYPES.includes(type) || _dynamicNodeTypes.has(type);
117
+ export function isKnownNodeType(type, runtime) {
118
+ const rt = runtime ?? defaultRuntime;
119
+ return NODE_TYPES.includes(type) || rt.dynamicNodeTypes.has(type);
115
120
  }
116
- /** Get all dynamically registered evolved types. */
121
+ /** Get all dynamically registered evolved types (defensive copy). */
117
122
  export function getEvolvedTypes() {
118
- return _dynamicNodeTypes;
123
+ return defaultRuntime.getEvolvedTypes();
119
124
  }
120
125
  /** Clear all dynamic types (for test isolation). */
121
126
  export function clearEvolvedTypes() {
122
- _dynamicNodeTypes.clear();
127
+ defaultRuntime.clearEvolvedTypes();
123
128
  }
124
129
  /** Reserved keywords — evolved nodes cannot use these. */
125
- export const KERN_RESERVED = new Set(NODE_TYPES);
130
+ export const KERN_RESERVED = Object.freeze(new Set(NODE_TYPES));
126
131
  // ── Style Shorthands (FROZEN at v1.0 — 30 entries) ──────────────────────
127
132
  // Any CSS property not in this map uses the escape hatch: "property":"value"
128
133
  // This map will NOT grow. Use quoted keys for new CSS properties.
129
134
  export const STYLE_SHORTHANDS = {
130
135
  // Spacing
131
136
  p: 'padding', m: 'margin',
137
+ px: 'paddingX', py: 'paddingY',
132
138
  pt: 'paddingTop', pb: 'paddingBottom', pl: 'paddingLeft', pr: 'paddingRight',
139
+ mx: 'marginX', my: 'marginY',
133
140
  mt: 'marginTop', mb: 'marginBottom', ml: 'marginLeft', mr: 'marginRight',
134
141
  // Sizing
135
142
  w: 'width', h: 'height', f: 'flex',
143
+ 'max-width': 'maxWidth', 'min-width': 'minWidth',
144
+ 'max-height': 'maxHeight', 'min-height': 'minHeight',
145
+ // Positioning
146
+ 'z-index': 'zIndex',
136
147
  // Colors
137
148
  bg: 'backgroundColor', c: 'color', bc: 'borderColor',
138
149
  // Typography