@kernlang/core 3.1.5 → 3.1.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 (93) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +5 -2
  3. package/dist/codegen/data-layer.d.ts +12 -0
  4. package/dist/codegen/data-layer.js +292 -0
  5. package/dist/codegen/data-layer.js.map +1 -0
  6. package/dist/codegen/events.d.ts +9 -0
  7. package/dist/codegen/events.js +158 -0
  8. package/dist/codegen/events.js.map +1 -0
  9. package/dist/codegen/functions.d.ts +8 -0
  10. package/dist/codegen/functions.js +147 -0
  11. package/dist/codegen/functions.js.map +1 -0
  12. package/dist/codegen/ground-layer.d.ts +22 -0
  13. package/dist/codegen/ground-layer.js +317 -0
  14. package/dist/codegen/ground-layer.js.map +1 -0
  15. package/dist/codegen/machines.d.ts +9 -0
  16. package/dist/codegen/machines.js +127 -0
  17. package/dist/codegen/machines.js.map +1 -0
  18. package/dist/codegen/modules.d.ts +10 -0
  19. package/dist/codegen/modules.js +40 -0
  20. package/dist/codegen/modules.js.map +1 -0
  21. package/dist/codegen/semantic-types.d.ts +14 -0
  22. package/dist/codegen/semantic-types.js +31 -0
  23. package/dist/codegen/semantic-types.js.map +1 -0
  24. package/dist/codegen/test-gen.d.ts +7 -0
  25. package/dist/codegen/test-gen.js +56 -0
  26. package/dist/codegen/test-gen.js.map +1 -0
  27. package/dist/codegen/type-system.d.ts +11 -0
  28. package/dist/codegen/type-system.js +162 -0
  29. package/dist/codegen/type-system.js.map +1 -0
  30. package/dist/codegen-core.d.ts +26 -33
  31. package/dist/codegen-core.js +58 -1367
  32. package/dist/codegen-core.js.map +1 -1
  33. package/dist/config.d.ts +20 -1
  34. package/dist/config.js +23 -3
  35. package/dist/config.js.map +1 -1
  36. package/dist/coverage-gap.js +6 -2
  37. package/dist/coverage-gap.js.map +1 -1
  38. package/dist/decompiler.d.ts +9 -0
  39. package/dist/decompiler.js +17 -2
  40. package/dist/decompiler.js.map +1 -1
  41. package/dist/errors.d.ts +5 -0
  42. package/dist/errors.js +10 -0
  43. package/dist/errors.js.map +1 -1
  44. package/dist/index.d.ts +11 -4
  45. package/dist/index.js +9 -3
  46. package/dist/index.js.map +1 -1
  47. package/dist/node-props.d.ts +253 -0
  48. package/dist/node-props.js +35 -0
  49. package/dist/node-props.js.map +1 -0
  50. package/dist/parser-core.d.ts +5 -0
  51. package/dist/parser-core.js +363 -0
  52. package/dist/parser-core.js.map +1 -0
  53. package/dist/parser-diagnostics.d.ts +14 -0
  54. package/dist/parser-diagnostics.js +31 -0
  55. package/dist/parser-diagnostics.js.map +1 -0
  56. package/dist/parser-keywords.d.ts +5 -0
  57. package/dist/parser-keywords.js +135 -0
  58. package/dist/parser-keywords.js.map +1 -0
  59. package/dist/parser-style.d.ts +3 -0
  60. package/dist/parser-style.js +73 -0
  61. package/dist/parser-style.js.map +1 -0
  62. package/dist/parser-token-stream.d.ts +27 -0
  63. package/dist/parser-token-stream.js +69 -0
  64. package/dist/parser-token-stream.js.map +1 -0
  65. package/dist/parser-tokenizer.d.ts +11 -0
  66. package/dist/parser-tokenizer.js +188 -0
  67. package/dist/parser-tokenizer.js.map +1 -0
  68. package/dist/parser.d.ts +59 -12
  69. package/dist/parser.js +51 -862
  70. package/dist/parser.js.map +1 -1
  71. package/dist/schema.d.ts +7 -2
  72. package/dist/schema.js +7 -2
  73. package/dist/schema.js.map +1 -1
  74. package/dist/source-map.d.ts +27 -0
  75. package/dist/source-map.js +82 -0
  76. package/dist/source-map.js.map +1 -0
  77. package/dist/spec.d.ts +1 -1
  78. package/dist/spec.js +2 -0
  79. package/dist/spec.js.map +1 -1
  80. package/dist/styles-tailwind.d.ts +10 -0
  81. package/dist/styles-tailwind.js +10 -0
  82. package/dist/styles-tailwind.js.map +1 -1
  83. package/dist/template-engine.d.ts +10 -5
  84. package/dist/template-engine.js +10 -5
  85. package/dist/template-engine.js.map +1 -1
  86. package/dist/types.d.ts +8 -3
  87. package/dist/utils.d.ts +20 -0
  88. package/dist/utils.js +20 -0
  89. package/dist/utils.js.map +1 -1
  90. package/dist/walk.d.ts +40 -0
  91. package/dist/walk.js +107 -0
  92. package/dist/walk.js.map +1 -0
  93. package/package.json +2 -2
package/dist/parser.d.ts CHANGED
@@ -1,21 +1,53 @@
1
+ /**
2
+ * KERN Parser — public API surface.
3
+ *
4
+ * Implementation is split across sibling modules:
5
+ * - parser-diagnostics.ts — diagnostic infrastructure
6
+ * - parser-tokenizer.ts — character-level tokenizer
7
+ * - parser-token-stream.ts — token cursor
8
+ * - parser-style.ts — style block parsing
9
+ * - parser-keywords.ts — keyword-specific handlers
10
+ * - parser-core.ts — line parsing, tree building, orchestration
11
+ */
1
12
  import type { IRNode, ParseDiagnostic, ParseResult } from './types.js';
2
13
  import { type KernRuntime } from './runtime.js';
3
14
  import type { ParserHintsConfig } from './runtime.js';
4
- export type TokenKind = 'identifier' | 'number' | 'equals' | 'quoted' | 'expr' | 'style' | 'themeRef' | 'slash' | 'comma' | 'whitespace' | 'unknown';
5
- export interface Token {
6
- kind: TokenKind;
7
- value: string;
8
- pos: number;
9
- }
10
- export declare function tokenizeLine(line: string): Token[];
15
+ export type { TokenKind, Token } from './parser-tokenizer.js';
16
+ export { tokenizeLine } from './parser-tokenizer.js';
11
17
  /** Register parser hints for an evolved node type. */
12
18
  export declare function registerParserHints(keyword: string, hints: ParserHintsConfig): void;
13
19
  /** Unregister parser hints (for rollback/testing). */
14
20
  export declare function unregisterParserHints(keyword: string): void;
15
21
  /** Clear all parser hints (for test isolation). */
16
22
  export declare function clearParserHints(): void;
17
- /** Get warnings from the last parse() call */
23
+ /**
24
+ * Get diagnostic messages from the last parse() call as plain strings.
25
+ *
26
+ * @remarks Returns messages for all severities (error, warning, info).
27
+ * For structured diagnostics with severity filtering, use {@link getParseDiagnostics}.
28
+ */
18
29
  export declare function getParseWarnings(): string[];
30
+ /** Get structured diagnostics from the last parse() call. */
31
+ export declare function getParseDiagnostics(runtime?: KernRuntime): ParseDiagnostic[];
32
+ /**
33
+ * Parse KERN source into an IR node tree.
34
+ *
35
+ * Recovers from errors gracefully — malformed lines produce `DROPPED_LINE`
36
+ * diagnostics but never throw. Use {@link parseStrict} if you want errors to throw.
37
+ *
38
+ * @param source - KERN indentation-based source text
39
+ * @param runtime - Optional KernRuntime instance for isolation (defaults to shared singleton)
40
+ * @returns Root IRNode of the parsed tree
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const root = parse('page "Home"\n text "Hello"');
45
+ * // root.type === 'page', root.children[0].type === 'text'
46
+ * ```
47
+ *
48
+ * @see {@link parseWithDiagnostics} to also receive parse diagnostics
49
+ * @see {@link parseStrict} to throw on errors
50
+ */
19
51
  export declare function parse(source: string, runtime?: KernRuntime): IRNode;
20
52
  /**
21
53
  * Parse KERN source into a document-wrapped IR tree.
@@ -23,13 +55,28 @@ export declare function parse(source: string, runtime?: KernRuntime): IRNode;
23
55
  * top-level nodes (e.g., multiple `rule` definitions) are siblings.
24
56
  */
25
57
  export declare function parseDocument(source: string, runtime?: KernRuntime): IRNode;
26
- /** Get structured diagnostics from the last parse() call. */
27
- export declare function getParseDiagnostics(runtime?: KernRuntime): ParseDiagnostic[];
28
- /** Parse with diagnostics — returns both tree and structured diagnostics. */
58
+ /**
59
+ * Parse KERN source and return both the IR tree and structured diagnostics.
60
+ *
61
+ * Unlike {@link parse}, this returns a {@link ParseResult} containing the full
62
+ * diagnostics array, useful for editor integrations and lint-style reporting.
63
+ *
64
+ * @param source - KERN indentation-based source text
65
+ * @param runtime - Optional KernRuntime instance for isolation
66
+ * @returns `{ root: IRNode, diagnostics: ParseDiagnostic[] }`
67
+ */
29
68
  export declare function parseWithDiagnostics(source: string, runtime?: KernRuntime): ParseResult;
30
69
  /** Parse with diagnostics (document mode). */
31
70
  export declare function parseDocumentWithDiagnostics(source: string, runtime?: KernRuntime): ParseResult;
32
- /** Strict parse — throws KernParseError if any diagnostic has severity=error or schema violation. */
71
+ /**
72
+ * Strict parse — throws if any diagnostic has severity `'error'` or a schema violation is found.
73
+ *
74
+ * @param source - KERN indentation-based source text
75
+ * @param runtime - Optional KernRuntime instance for isolation
76
+ * @returns Root IRNode of the parsed tree
77
+ * @throws {KernParseError} When the source contains errors or schema violations.
78
+ * The error includes a code frame and the full diagnostics array.
79
+ */
33
80
  export declare function parseStrict(source: string, runtime?: KernRuntime): IRNode;
34
81
  /** Strict document parse — throws KernParseError if any diagnostic has severity=error or schema violation. */
35
82
  export declare function parseDocumentStrict(source: string, runtime?: KernRuntime): IRNode;