@kernlang/core 3.3.9 → 3.4.1
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/capability-matrix.d.ts +15 -0
- package/dist/capability-matrix.js +245 -0
- package/dist/capability-matrix.js.map +1 -0
- package/dist/codegen/body-ts.d.ts +68 -0
- package/dist/codegen/body-ts.js +214 -0
- package/dist/codegen/body-ts.js.map +1 -0
- package/dist/codegen/data-layer.d.ts +1 -1
- package/dist/codegen/data-layer.js +59 -23
- package/dist/codegen/data-layer.js.map +1 -1
- package/dist/codegen/events.js +1 -1
- package/dist/codegen/events.js.map +1 -1
- package/dist/codegen/functions.js +48 -7
- package/dist/codegen/functions.js.map +1 -1
- package/dist/codegen/ground-layer.js +10 -6
- package/dist/codegen/ground-layer.js.map +1 -1
- package/dist/codegen/helpers.d.ts +3 -1
- package/dist/codegen/helpers.js +5 -1
- package/dist/codegen/helpers.js.map +1 -1
- package/dist/codegen/kern-stdlib.d.ts +63 -0
- package/dist/codegen/kern-stdlib.js +160 -0
- package/dist/codegen/kern-stdlib.js.map +1 -0
- package/dist/codegen/machines.js +4 -3
- package/dist/codegen/machines.js.map +1 -1
- package/dist/codegen/modules.d.ts +1 -0
- package/dist/codegen/modules.js +52 -1
- package/dist/codegen/modules.js.map +1 -1
- package/dist/codegen/screens.js +31 -9
- package/dist/codegen/screens.js.map +1 -1
- package/dist/codegen/stdlib-preamble.d.ts +58 -0
- package/dist/codegen/stdlib-preamble.js +271 -0
- package/dist/codegen/stdlib-preamble.js.map +1 -0
- package/dist/codegen/type-system.d.ts +113 -1
- package/dist/codegen/type-system.js +404 -31
- package/dist/codegen/type-system.js.map +1 -1
- package/dist/codegen-core.d.ts +2 -2
- package/dist/codegen-core.js +65 -10
- package/dist/codegen-core.js.map +1 -1
- package/dist/codegen-expression.d.ts +11 -0
- package/dist/codegen-expression.js +199 -0
- package/dist/codegen-expression.js.map +1 -0
- package/dist/concepts.d.ts +3 -3
- package/dist/config.d.ts +16 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/decompiler.js +575 -4
- package/dist/decompiler.js.map +1 -1
- package/dist/importer.d.ts +1 -0
- package/dist/importer.js +574 -34
- package/dist/importer.js.map +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/node-props.d.ts +181 -1
- package/dist/node-props.js.map +1 -1
- package/dist/parser-core.d.ts +7 -1
- package/dist/parser-core.js +33 -7
- package/dist/parser-core.js.map +1 -1
- package/dist/parser-diagnostics.js +8 -0
- package/dist/parser-diagnostics.js.map +1 -1
- package/dist/parser-expression.d.ts +22 -0
- package/dist/parser-expression.js +774 -0
- package/dist/parser-expression.js.map +1 -0
- package/dist/parser-keywords.js +16 -0
- package/dist/parser-keywords.js.map +1 -1
- package/dist/parser-tokenizer.d.ts +5 -3
- package/dist/parser-tokenizer.js +97 -16
- package/dist/parser-tokenizer.js.map +1 -1
- package/dist/parser-validate-effects.d.ts +21 -0
- package/dist/parser-validate-effects.js +188 -0
- package/dist/parser-validate-effects.js.map +1 -0
- package/dist/parser-validate-expressions.d.ts +6 -0
- package/dist/parser-validate-expressions.js +41 -0
- package/dist/parser-validate-expressions.js.map +1 -0
- package/dist/parser-validate-propagation.d.ts +105 -0
- package/dist/parser-validate-propagation.js +684 -0
- package/dist/parser-validate-propagation.js.map +1 -0
- package/dist/parser-validate-union-kind.d.ts +24 -0
- package/dist/parser-validate-union-kind.js +97 -0
- package/dist/parser-validate-union-kind.js.map +1 -0
- package/dist/parser.d.ts +10 -3
- package/dist/parser.js +11 -5
- package/dist/parser.js.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +562 -30
- package/dist/schema.js.map +1 -1
- package/dist/semantic-validator.js +24 -13
- package/dist/semantic-validator.js.map +1 -1
- package/dist/spec.d.ts +5 -2
- package/dist/spec.js +36 -2
- package/dist/spec.js.map +1 -1
- package/dist/types.d.ts +7 -1
- package/dist/types.js +7 -1
- package/dist/types.js.map +1 -1
- package/dist/value-ir.d.ts +96 -0
- package/dist/value-ir.js +25 -0
- package/dist/value-ir.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,10 +3,122 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Extracted from codegen-core.ts for modular codegen architecture.
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
6
|
+
import { type IRNode } from '../types.js';
|
|
7
7
|
export declare function generateType(node: IRNode): string[];
|
|
8
8
|
export declare function generateInterface(node: IRNode): string[];
|
|
9
9
|
export declare function generateUnion(node: IRNode): string[];
|
|
10
10
|
export declare function generateClass(node: IRNode): string[];
|
|
11
11
|
export declare function generateService(node: IRNode): string[];
|
|
12
|
+
export declare function generateEnum(node: IRNode): string[];
|
|
12
13
|
export declare function generateConst(node: IRNode): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Slice 3d — emit a TS destructuring statement from a `destructure` node.
|
|
16
|
+
*
|
|
17
|
+
* Two paths:
|
|
18
|
+
* (1) `expr={{...}}` escape hatch — emit the carried code verbatim. Used
|
|
19
|
+
* by the importer for complex patterns (rest `...`, defaults `=v`,
|
|
20
|
+
* nested `{a:{b}}`, computed keys) where structured children would
|
|
21
|
+
* lose information.
|
|
22
|
+
* (2) Structured children — `binding` for object patterns (with optional
|
|
23
|
+
* `key=` for renames) or `element` for array patterns (with `index=`
|
|
24
|
+
* for ordered position). Codegen detects which child kind dominates
|
|
25
|
+
* and emits `{a, b: alias} = src` or `[a, b, , c] = src` (holes from
|
|
26
|
+
* index gaps).
|
|
27
|
+
*
|
|
28
|
+
* `kind` defaults to `const` when omitted. `type` (optional) flows through
|
|
29
|
+
* `emitTypeAnnotation` and is appended after the LHS pattern.
|
|
30
|
+
*/
|
|
31
|
+
export declare function generateDestructure(node: IRNode): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Slice 3c-extension #3 / shared with slice 3d destructure: format the LHS
|
|
34
|
+
* pattern (`{a, b: alias}` or `[x, , y]`) from a node's `binding` (object)
|
|
35
|
+
* or `element` (array) children. Returns null when neither is present (used
|
|
36
|
+
* by the destructure node validator); throws when the node mixes both.
|
|
37
|
+
*
|
|
38
|
+
* Used by:
|
|
39
|
+
* - `generateDestructure` (slice 3d) — full statement: `const {a,b} = src;`
|
|
40
|
+
* - `parseParamListFromChildren` (slice 3c-extension #3) — pattern-only LHS
|
|
41
|
+
* of a destructured fn parameter: `{a, b}: Point` or `[x, y]`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatBindingPatternFromChildren(node: IRNode): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Slice 3e — emit a TS Map literal from a `mapLit` node.
|
|
46
|
+
*
|
|
47
|
+
* mapLit name=cache type="Map<string, number>"
|
|
48
|
+
* mapEntry key="foo" value=1
|
|
49
|
+
* mapEntry key="bar" value=2
|
|
50
|
+
*
|
|
51
|
+
* → `const cache: Map<string, number> = new Map([['foo', 1], ['bar', 2]]);`
|
|
52
|
+
*
|
|
53
|
+
* `expr={{...}}` escape hatch carries a raw TS statement verbatim — used
|
|
54
|
+
* by the importer fallback when a Map literal contains shapes the
|
|
55
|
+
* structured emitter can't represent (computed keys, conditional entries,
|
|
56
|
+
* spread). Mirrors slice 3d destructure escape-hatch policy.
|
|
57
|
+
*/
|
|
58
|
+
export declare function generateMapLit(node: IRNode): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Slice 3e — emit a TS Set literal from a `setLit` node.
|
|
61
|
+
*
|
|
62
|
+
* setLit name=allowed type="Set<string>"
|
|
63
|
+
* setItem value="admin"
|
|
64
|
+
* setItem value="user"
|
|
65
|
+
*
|
|
66
|
+
* → `const allowed: Set<string> = new Set(['admin', 'user']);`
|
|
67
|
+
*
|
|
68
|
+
* Same `expr={{...}}` escape-hatch policy as `mapLit`/`destructure`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function generateSetLit(node: IRNode): string[];
|
|
71
|
+
/** Emit the right-hand side of an expression-typed prop (e.g. `const.value`,
|
|
72
|
+
* `let.value`) from its raw IR form.
|
|
73
|
+
*
|
|
74
|
+
* - `<prop>={{ expr }}` (ExprObject) — emit `.code` raw (escape hatch for arbitrary TS).
|
|
75
|
+
* - `<prop>="literal"` (quoted, tracked in __quotedProps) — emit as JSON-quoted string
|
|
76
|
+
* so output is valid TS even when the literal contains expression-illegal characters.
|
|
77
|
+
* - bare `<prop>=...` — try ValueIR parse + emit for canonicalization. Fall back to raw
|
|
78
|
+
* string on parse failure (validator emits INVALID_EXPRESSION but codegen still ships).
|
|
79
|
+
*
|
|
80
|
+
* Slice 3e — `propName` parameter (default 'value') lets non-`value` props
|
|
81
|
+
* participate in the same quoted-vs-bare distinction. `mapEntry.key` and
|
|
82
|
+
* `mapEntry.value` both flow through this with their own __quotedProps key. */
|
|
83
|
+
export declare function emitConstValue(node: IRNode, rawValue: unknown, propName?: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Slice 3c — produce a TS parameter-list string from `param` child IR nodes.
|
|
86
|
+
*
|
|
87
|
+
* Mirrors `parseParamList` (which parses the legacy `params="..."` string)
|
|
88
|
+
* but reads structured child nodes so each parameter's `value=` flows through
|
|
89
|
+
* `emitConstValue` for ValueIR canonicalisation. Identifier/type annotations
|
|
90
|
+
* are routed through the schema emitters so authored bad input raises
|
|
91
|
+
* KernCodegenError instead of producing broken TS.
|
|
92
|
+
*
|
|
93
|
+
* Per child:
|
|
94
|
+
* - `value=` (slice 3c, ValueIR-canonicalised) — JSON-quoted for quoted
|
|
95
|
+
* string literals, parsed+re-emitted for bare expressions, raw for
|
|
96
|
+
* `{{...}}` ExprObject. Same routing as slice 3b field.value.
|
|
97
|
+
* - `default=` (rawExpr passthrough) — kept for back-compat / MCP usage.
|
|
98
|
+
* - When both set, `value` wins. The slice 3a/3b gate treats unquoted
|
|
99
|
+
* empty `value=` as absent so it doesn't trigger the
|
|
100
|
+
* `parseExpression('')` throw → empty fallback → `name: T = ;` bug.
|
|
101
|
+
*
|
|
102
|
+
* `options.stripDefaults`: TS forbids parameter initializers in overload
|
|
103
|
+
* signatures — the implementation alone may carry defaults. Same flag as
|
|
104
|
+
* the sibling `parseParamList`.
|
|
105
|
+
*/
|
|
106
|
+
export declare function parseParamListFromChildren(paramNodes: IRNode[], options?: {
|
|
107
|
+
stripDefaults?: boolean;
|
|
108
|
+
}): string;
|
|
109
|
+
/**
|
|
110
|
+
* Slice 3c — unified TS parameter-list emitter for any callable IR node.
|
|
111
|
+
*
|
|
112
|
+
* Reads the node's `param` children first (canonical, ValueIR-routed). If
|
|
113
|
+
* none, falls back to the legacy `params="..."` string. If neither, returns
|
|
114
|
+
* the fallback (default empty).
|
|
115
|
+
*
|
|
116
|
+
* Children win when present. Mixed mode is intentionally unsupported — a
|
|
117
|
+
* signature is either fully-structured-children or fully-legacy-string.
|
|
118
|
+
* Producers (importer, migrate-class-body) emit children all-or-nothing
|
|
119
|
+
* per signature; consumers don't need to reconcile partial states.
|
|
120
|
+
*/
|
|
121
|
+
export declare function emitParamList(node: IRNode, options?: {
|
|
122
|
+
stripDefaults?: boolean;
|
|
123
|
+
fallback?: string;
|
|
124
|
+
}): string;
|