@aftertext/compiler 0.0.0-stage → 0.1.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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -2
  3. package/dist/ast/expression.d.ts +55 -0
  4. package/dist/ast/expression.d.ts.map +1 -0
  5. package/dist/ast/expression.js +2 -0
  6. package/dist/ast/expression.js.map +1 -0
  7. package/dist/ast/index.d.ts +6 -0
  8. package/dist/ast/index.d.ts.map +1 -0
  9. package/dist/ast/index.js +2 -0
  10. package/dist/ast/index.js.map +1 -0
  11. package/dist/ast/inline.d.ts +39 -0
  12. package/dist/ast/inline.d.ts.map +1 -0
  13. package/dist/ast/inline.js +2 -0
  14. package/dist/ast/inline.js.map +1 -0
  15. package/dist/ast/presentation.d.ts +41 -0
  16. package/dist/ast/presentation.d.ts.map +1 -0
  17. package/dist/ast/presentation.js +8 -0
  18. package/dist/ast/presentation.js.map +1 -0
  19. package/dist/ast/span.d.ts +19 -0
  20. package/dist/ast/span.d.ts.map +1 -0
  21. package/dist/ast/span.js +2 -0
  22. package/dist/ast/span.js.map +1 -0
  23. package/dist/ast/story.d.ts +354 -0
  24. package/dist/ast/story.d.ts.map +1 -0
  25. package/dist/ast/story.js +2 -0
  26. package/dist/ast/story.js.map +1 -0
  27. package/dist/compile.d.ts +25 -0
  28. package/dist/compile.d.ts.map +1 -0
  29. package/dist/compile.js +19 -0
  30. package/dist/compile.js.map +1 -0
  31. package/dist/diagnostics/codes.d.ts +26 -0
  32. package/dist/diagnostics/codes.d.ts.map +1 -0
  33. package/dist/diagnostics/codes.js +69 -0
  34. package/dist/diagnostics/codes.js.map +1 -0
  35. package/dist/diagnostics/index.d.ts +3 -0
  36. package/dist/diagnostics/index.d.ts.map +1 -0
  37. package/dist/diagnostics/index.js +2 -0
  38. package/dist/diagnostics/index.js.map +1 -0
  39. package/dist/diagnostics/types.d.ts +19 -0
  40. package/dist/diagnostics/types.d.ts.map +1 -0
  41. package/dist/diagnostics/types.js +2 -0
  42. package/dist/diagnostics/types.js.map +1 -0
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +11 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/parser/blocks.d.ts +40 -0
  48. package/dist/parser/blocks.d.ts.map +1 -0
  49. package/dist/parser/blocks.js +927 -0
  50. package/dist/parser/blocks.js.map +1 -0
  51. package/dist/parser/directive-line.d.ts +21 -0
  52. package/dist/parser/directive-line.d.ts.map +1 -0
  53. package/dist/parser/directive-line.js +50 -0
  54. package/dist/parser/directive-line.js.map +1 -0
  55. package/dist/parser/document.d.ts +13 -0
  56. package/dist/parser/document.d.ts.map +1 -0
  57. package/dist/parser/document.js +28 -0
  58. package/dist/parser/document.js.map +1 -0
  59. package/dist/parser/expression-lexer.d.ts +44 -0
  60. package/dist/parser/expression-lexer.d.ts.map +1 -0
  61. package/dist/parser/expression-lexer.js +166 -0
  62. package/dist/parser/expression-lexer.js.map +1 -0
  63. package/dist/parser/expression-parser.d.ts +13 -0
  64. package/dist/parser/expression-parser.d.ts.map +1 -0
  65. package/dist/parser/expression-parser.js +201 -0
  66. package/dist/parser/expression-parser.js.map +1 -0
  67. package/dist/parser/frontmatter.d.ts +23 -0
  68. package/dist/parser/frontmatter.d.ts.map +1 -0
  69. package/dist/parser/frontmatter.js +158 -0
  70. package/dist/parser/frontmatter.js.map +1 -0
  71. package/dist/parser/index.d.ts +2 -0
  72. package/dist/parser/index.d.ts.map +1 -0
  73. package/dist/parser/index.js +2 -0
  74. package/dist/parser/index.js.map +1 -0
  75. package/dist/parser/lexical-primitives.d.ts +38 -0
  76. package/dist/parser/lexical-primitives.d.ts.map +1 -0
  77. package/dist/parser/lexical-primitives.js +46 -0
  78. package/dist/parser/lexical-primitives.js.map +1 -0
  79. package/dist/parser/lines.d.ts +32 -0
  80. package/dist/parser/lines.d.ts.map +1 -0
  81. package/dist/parser/lines.js +60 -0
  82. package/dist/parser/lines.js.map +1 -0
  83. package/dist/parser/markdown.d.ts +19 -0
  84. package/dist/parser/markdown.d.ts.map +1 -0
  85. package/dist/parser/markdown.js +221 -0
  86. package/dist/parser/markdown.js.map +1 -0
  87. package/dist/parser/serializer-safety.d.ts +57 -0
  88. package/dist/parser/serializer-safety.d.ts.map +1 -0
  89. package/dist/parser/serializer-safety.js +66 -0
  90. package/dist/parser/serializer-safety.js.map +1 -0
  91. package/dist/validation/index.d.ts +2 -0
  92. package/dist/validation/index.d.ts.map +1 -0
  93. package/dist/validation/index.js +2 -0
  94. package/dist/validation/index.js.map +1 -0
  95. package/dist/validation/validate.d.ts +4 -0
  96. package/dist/validation/validate.d.ts.map +1 -0
  97. package/dist/validation/validate.js +221 -0
  98. package/dist/validation/validate.js.map +1 -0
  99. package/package.json +43 -4
@@ -0,0 +1,354 @@
1
+ import type { ExpressionNode } from "./expression.js";
2
+ import type { InlineNode } from "./inline.js";
3
+ import type { PresentationCommand } from "./presentation.js";
4
+ import type { SourcePosition, SourceSpan } from "./span.js";
5
+ /** A state value allowed in v0.1 frontmatter `state:` and in `@set`. */
6
+ export type StateValue = string | number | boolean | null;
7
+ /**
8
+ * The story's initial state, declared in frontmatter's `state:` block and
9
+ * normalized into a plain map. First-class on StoryDocument — not folded
10
+ * into generic metadata — since it is the seed for runtime story state,
11
+ * a distinct concern from title/entry.
12
+ */
13
+ export type StoryStateDefinition = Readonly<Record<string, StateValue>>;
14
+ export interface StoryMetadata {
15
+ readonly title: string | undefined;
16
+ readonly entry: string | undefined;
17
+ /** Absent when the source had no frontmatter block. */
18
+ readonly span: SourceSpan | undefined;
19
+ }
20
+ export interface ParagraphNode {
21
+ readonly type: "Paragraph";
22
+ readonly children: readonly InlineNode[];
23
+ readonly span: SourceSpan;
24
+ }
25
+ export interface HeadingNode {
26
+ readonly type: "Heading";
27
+ readonly depth: 1 | 2 | 3 | 4 | 5 | 6;
28
+ readonly children: readonly InlineNode[];
29
+ readonly span: SourceSpan;
30
+ /**
31
+ * The exact authored Heading content bytes, excluding the opening marker,
32
+ * opening separator whitespace, any recognized ATX closing-hash sequence,
33
+ * trailing Heading syntax/whitespace, the Setext underline (and its
34
+ * indentation), and the line ending. Non-optional: an empty ATX Heading
35
+ * (e.g. `#`) still has a valid zero-width `contentSourceSpan` rather than
36
+ * `undefined` — see docs/CORE_SPEC.md Section 25.49. This is the sole
37
+ * patch target for Heading Structured Editing; never reconstruct source
38
+ * from `children`, which is not lossless (delimiter choice, escaping,
39
+ * spacing, and closing-hash/underline syntax are not AST-preserved).
40
+ */
41
+ readonly contentSourceSpan: SourceSpan;
42
+ /**
43
+ * The exact authored Heading *level* marker bytes, excluding everything
44
+ * else: for ATX, exactly the opening `#` run (e.g. `###` in
45
+ * `### Heading ###`), excluding separator whitespace, content, closing
46
+ * hashes, trailing whitespace, and the line ending; for Setext, exactly
47
+ * the underline character run (e.g. `=======` in `Heading\n=======`),
48
+ * excluding content, the line ending before the underline, underline
49
+ * indentation, underline trailing whitespace, and the line ending after.
50
+ * Non-optional: every Heading has a valid, non-zero-width level span.
51
+ * This is the sole patch target for Heading Level Editing — changing only
52
+ * this span changes `depth` while preserving authored style and content
53
+ * exactly. docs/CORE_SPEC.md Section 25.50.
54
+ */
55
+ readonly levelSourceSpan: SourceSpan;
56
+ }
57
+ export interface PresentationNode {
58
+ readonly type: "Presentation";
59
+ readonly command: PresentationCommand;
60
+ readonly span: SourceSpan;
61
+ /**
62
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 25.36):
63
+ * absolute source spans of each recognized `key=value` parameter's
64
+ * authored VALUE text (e.g. `to=1.20` maps `"to"` to the span slicing
65
+ * exactly `1.20`, never `to=` or surrounding whitespace). Optional on
66
+ * this public type only so existing hand-constructed `PresentationNode`
67
+ * object literals (tests, downstream tooling) remain source-compatible —
68
+ * every `PresentationNode` the compiler itself produces always populates
69
+ * it (an empty record when the directive has no named parameters). Not
70
+ * part of `PresentationCommand`, never read by Runtime/Player, and does
71
+ * not change DSL semantics — this is source-analysis data only, enabling
72
+ * targeted, formatting-preserving source edits without re-parsing.
73
+ */
74
+ readonly parameterValueSpans?: Readonly<Record<string, SourceSpan>>;
75
+ /**
76
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 25.36):
77
+ * the absolute source span of the directive's single authored positional
78
+ * (non-`key=value`) argument token — e.g. `@pause 0.50s` maps this to the
79
+ * span slicing exactly `0.50s`. Populated if and only if the directive's
80
+ * argument text contains exactly one positional token; `undefined` when
81
+ * there are zero, or two-or-more, positional tokens. `undefined` does
82
+ * **not** mean "no positional value was authored" — with two or more
83
+ * positional tokens, the parser's own semantic value is a synthetic
84
+ * join of non-contiguous source text (e.g. a named parameter may sit
85
+ * between two positional tokens), so no single `SourceSpan` could
86
+ * represent it without also covering unrelated source; no such span is
87
+ * ever synthesized. Optional on this public type for the same
88
+ * source-compatibility reason as `parameterValueSpans`.
89
+ */
90
+ readonly positionalValueSpan?: SourceSpan;
91
+ /**
92
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 14): the
93
+ * absolute source position immediately after the final non-whitespace
94
+ * character of the directive's authored argument text, before any
95
+ * trailing line whitespace and before the line terminator. Populated for
96
+ * every successfully-parsed compiler-produced `PresentationNode`,
97
+ * regardless of directive kind. Never derived from `span.end`, which
98
+ * includes trailing line whitespace and is therefore unsafe as a source-
99
+ * tooling append anchor. Optional on this public type for the same
100
+ * source-compatibility reason as `parameterValueSpans`/
101
+ * `positionalValueSpan`.
102
+ */
103
+ readonly argumentsEndPosition?: SourcePosition;
104
+ /**
105
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 14): for
106
+ * a recognized named (`key=value`) parameter, the absolute source span
107
+ * that, deleted via a single text replacement with `""`, removes exactly
108
+ * that parameter's complete authored `key=value` token plus exactly one
109
+ * adjacent authored inter-token separator (chosen so the directive-name-
110
+ * to-first-argument boundary is never touched — see the compiler source
111
+ * for the exact position rule), while preserving every other authored
112
+ * byte of the directive exactly. Populated for key `k` **if and only if**
113
+ * `k` occurs exactly once in the directive's argument text; `undefined`
114
+ * both when `k` is not authored at all and when `k` occurs two-or-more
115
+ * times. **`undefined` does not mean "not authored"** — with duplicate
116
+ * occurrences, the existing last-occurrence-wins `parameterValueSpans`
117
+ * still resolves an effective value, but no single removal range could
118
+ * safely delete "the property" (deleting only the effective last
119
+ * occurrence would silently reveal an earlier duplicate as the new
120
+ * authored value) — the same availability-style principle already
121
+ * documented on `positionalValueSpan`. This is generic, directive-kind-
122
+ * agnostic metadata: it may be populated for any recognized named key,
123
+ * including one a particular tool does not expose Remove support for.
124
+ * Optional on this public type for the same source-compatibility reason
125
+ * as the other metadata fields above.
126
+ */
127
+ readonly parameterRemovalSpans?: Readonly<Record<string, SourceSpan>>;
128
+ /**
129
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 14): the
130
+ * absolute source span covering every positional (non-`key=value`) token
131
+ * in the directive's argument text, populated **if and only if** at
132
+ * least one positional token exists AND all positional tokens occupy one
133
+ * uninterrupted physical run — i.e. no named `key=value` token occurs
134
+ * between the first and last positional token. Includes all authored
135
+ * inter-token whitespace between positional tokens verbatim (never
136
+ * re-canonicalized, even though the parser's own semantic value joins
137
+ * them with a single space). For exactly one positional token this
138
+ * necessarily covers the identical raw range as `positionalValueSpan` —
139
+ * both are populated in that case, which is expected, not a
140
+ * contradiction; this field does not replace, broaden, or redefine
141
+ * `positionalValueSpan`'s own unchanged one-token-only contract.
142
+ * **`undefined` does not mean "no positional value exists"** — it may
143
+ * also mean positional tokens exist but are physically non-contiguous
144
+ * because a named-parameter token is interleaved among them (the same
145
+ * availability-style principle already documented on
146
+ * `positionalValueSpan`/`parameterRemovalSpans`). Generic and
147
+ * directive-kind-agnostic; optional on this public type for the same
148
+ * source-compatibility reason as the other metadata fields above.
149
+ */
150
+ readonly contiguousPositionalSpan?: SourceSpan;
151
+ /**
152
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 14): the
153
+ * absolute source span that, deleted via a single text replacement with
154
+ * `""`, removes this entire authored Presentation directive cleanly —
155
+ * `start` is always exactly `span.start` (never adjusted backward into
156
+ * preceding source), and `end` extends `span.end` by this directive's
157
+ * own physical source line's terminator width (0 at true end-of-file, 1
158
+ * for an authored `\n`, 2 for an authored `\r\n`), so deletion never
159
+ * leaves an accidental blank line behind. A directive owns only its own
160
+ * immediately-following line terminator for this purpose — never a
161
+ * preceding terminator, never additional following blank-line trivia,
162
+ * never neighboring block or container syntax. Unlike
163
+ * `parameterRemovalSpans`, there is no ambiguity condition: every
164
+ * successfully-parsed `PresentationNode` has exactly one physical
165
+ * directive line, so this field is always populated for a
166
+ * compiler-produced node. Optional on this public type for the same
167
+ * source-compatibility reason as the other metadata fields above.
168
+ */
169
+ readonly commandRemovalSpan?: SourceSpan;
170
+ }
171
+ export interface SetNode {
172
+ readonly type: "Set";
173
+ readonly name: string;
174
+ readonly expression: ExpressionNode;
175
+ readonly span: SourceSpan;
176
+ readonly nameSourceSpan: SourceSpan;
177
+ readonly expressionSourceSpan: SourceSpan;
178
+ }
179
+ export interface GotoNode {
180
+ readonly type: "Goto";
181
+ readonly target: string;
182
+ readonly span: SourceSpan;
183
+ readonly targetSourceSpan: SourceSpan;
184
+ }
185
+ export interface ChoiceItem {
186
+ readonly text: string;
187
+ readonly target: string;
188
+ readonly condition: ExpressionNode | undefined;
189
+ readonly span: SourceSpan;
190
+ /**
191
+ * The exact absolute source span of the authored condition text, after
192
+ * the syntactic `if` separator — e.g. for `- Go -> north if (a || b) && c`
193
+ * this slices exactly to `(a || b) && c`. Populated whenever the Choice
194
+ * tail syntactically contains `target if <condition text>`, independently
195
+ * of whether that condition text later parses successfully — it is a
196
+ * source-tooling fact about the Choice grammar's own tail shape, not a
197
+ * semantic-success signal. `undefined` for an unconditional item. A
198
+ * malformed condition has `condition === undefined` while this span is
199
+ * still defined, so test this field (not `condition`) to learn whether a
200
+ * condition was authored.
201
+ *
202
+ * `condition.span` (an `ExpressionNode`'s own span) must NOT be used as a
203
+ * substitute for this field: the expression parser returns the inner node
204
+ * directly for a parenthesized sub-expression without widening its span to
205
+ * include the surrounding parentheses, so `condition.span` silently omits
206
+ * an opening `(` whenever parentheses wrap only part of a larger
207
+ * expression (needed for operator precedence) rather than the whole
208
+ * condition — corrupting any source slice built from it.
209
+ */
210
+ readonly conditionSourceSpan?: SourceSpan;
211
+ }
212
+ export interface ChoiceNode {
213
+ readonly type: "Choice";
214
+ readonly items: readonly ChoiceItem[];
215
+ readonly span: SourceSpan;
216
+ }
217
+ export type ConditionalBranchKind = "if" | "elseif" | "else";
218
+ export interface ConditionalBranch {
219
+ readonly kind: ConditionalBranchKind;
220
+ /** Present for "if" and "elseif" branches; absent for "else". */
221
+ readonly condition: ExpressionNode | undefined;
222
+ readonly blocks: readonly StoryBlock[];
223
+ readonly span: SourceSpan;
224
+ /**
225
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 25.36,
226
+ * "Expansion: Nested Presentation Command Insertion"): the exact line-
227
+ * terminator byte sequence immediately following `span.end`, if one
228
+ * exists — `"\n"`, `"\r\n"`, or `""` when `span.end` sits at true end-of-
229
+ * file with no authored terminator to reuse (only reachable for a branch
230
+ * whose enclosing Conditional is itself unclosed/malformed). A local
231
+ * source fact only, mirroring `SceneNode.followingLineEnding`. Optional
232
+ * on this public type for the same hand-construction-compatibility
233
+ * reason as every other metadata field in this line; every compiler-
234
+ * produced `ConditionalBranch` populates it.
235
+ */
236
+ readonly followingLineEnding?: "\n" | "\r\n" | "";
237
+ /**
238
+ * The exact absolute source span of the authored condition text on an
239
+ * `@if` or `@elseif` header line. Populated only for non-`else` branches
240
+ * whose directive has non-empty args; `undefined` for `@else`, which has no
241
+ * condition value at all (never a zero-width span). Mirrors
242
+ * `VariantBranch.conditionSourceSpan`: `condition.span` must not be used as
243
+ * a substitute, since it omits surrounding parentheses for partially
244
+ * parenthesized expressions.
245
+ */
246
+ readonly conditionSourceSpan?: SourceSpan;
247
+ }
248
+ export interface ConditionalNode {
249
+ readonly type: "Conditional";
250
+ readonly branches: readonly ConditionalBranch[];
251
+ readonly span: SourceSpan;
252
+ }
253
+ export type VariantBranchKind = "when" | "otherwise";
254
+ export interface VariantBranch {
255
+ readonly kind: VariantBranchKind;
256
+ /** Deterministic id, e.g. `alice-status:0` or `alice-status:otherwise`. */
257
+ readonly branchId: string;
258
+ /** Present for "when" branches; absent for "otherwise". */
259
+ readonly condition: ExpressionNode | undefined;
260
+ readonly blocks: readonly StoryBlock[];
261
+ readonly span: SourceSpan;
262
+ /**
263
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 25.36,
264
+ * "Expansion: Nested Presentation Command Insertion"): identical contract
265
+ * to `ConditionalBranch.followingLineEnding` above — the exact line-
266
+ * terminator byte sequence immediately following `span.end`, `""` only
267
+ * when `span.end` sits at true end-of-file (only reachable for a branch
268
+ * whose enclosing Variant is itself unclosed/malformed). Optional on this
269
+ * public type for the same hand-construction-compatibility reason as
270
+ * every other metadata field in this line; every compiler-produced
271
+ * `VariantBranch` populates it.
272
+ */
273
+ readonly followingLineEnding?: "\n" | "\r\n" | "";
274
+ /**
275
+ * The exact absolute source span of the authored condition text on a
276
+ * `@when` header line — e.g. for `@when (a || b) && c` this slices exactly
277
+ * to `(a || b) && c`. Populated whenever the branch directive syntactically
278
+ * presents a condition payload (i.e. `kind === "when"` with non-empty
279
+ * directive args), independently of whether that payload later parses
280
+ * successfully — a source-tooling fact about the branch header's own
281
+ * shape, not a semantic-success signal. `undefined` for an `otherwise`
282
+ * branch, exactly matching `condition === undefined`.
283
+ *
284
+ * `condition.span` (an `ExpressionNode`'s own span) must NOT be used as a
285
+ * substitute for this field, for the identical reason documented on
286
+ * `ChoiceItem.conditionSourceSpan` above: the expression parser returns
287
+ * the inner node directly for a parenthesized sub-expression without
288
+ * widening its span to include the surrounding parentheses, so
289
+ * `condition.span` silently omits an opening `(` whenever parentheses wrap
290
+ * only part of a larger expression rather than the whole condition —
291
+ * corrupting any source slice built from it.
292
+ */
293
+ readonly conditionSourceSpan?: SourceSpan;
294
+ }
295
+ export interface VariantNode {
296
+ readonly type: "Variant";
297
+ readonly id: string;
298
+ /**
299
+ * The exact absolute source span of the authored Variant declaration ID
300
+ * on the `@variant` header line — e.g. for `@variant my variant` this
301
+ * slices exactly to `my variant`, excluding `@variant`, the separator
302
+ * whitespace before the ID, any trailing header whitespace, and the EOL.
303
+ * Unlike `VariantBranch.conditionSourceSpan`, this field is always
304
+ * present (never `undefined`): for an empty authored ID — both bare
305
+ * `@variant` and separator-only `@variant ` (the parser cannot
306
+ * distinguish these two forms at the `args` level) — this is a
307
+ * zero-width span (`start.offset === end.offset`) at the parser-computed
308
+ * `argsStartColumn` position, giving source-tooling a coordinate to patch
309
+ * even when no ID text was authored at all. docs/CORE_SPEC.md Section
310
+ * 25.46.
311
+ */
312
+ readonly idSourceSpan: SourceSpan;
313
+ readonly branches: readonly VariantBranch[];
314
+ readonly span: SourceSpan;
315
+ }
316
+ export type StoryBlock = ParagraphNode | HeadingNode | PresentationNode | SetNode | GotoNode | ChoiceNode | ConditionalNode | VariantNode;
317
+ export interface SceneNode {
318
+ readonly type: "Scene";
319
+ readonly id: string;
320
+ readonly blocks: readonly StoryBlock[];
321
+ readonly span: SourceSpan;
322
+ /**
323
+ * Compiler/source-tooling metadata (docs/CORE_SPEC.md Section 25.35):
324
+ * the exact line-terminator byte sequence immediately following
325
+ * `span.end`, if one exists — `"\n"`, `"\r\n"`, or `""` when `span.end`
326
+ * sits at true end-of-file with no authored terminator to reuse. Carries
327
+ * no indentation, blank-line trivia, or generated text — a neutral fact
328
+ * only, derived directly from the same per-line terminator tracking the
329
+ * parser already performs while splitting source into lines. Optional on
330
+ * this public type for the same source-compatibility reason as every
331
+ * other metadata field in this line (existing hand-constructed
332
+ * `SceneNode` object literals remain source-compatible); every
333
+ * compiler-produced `SceneNode` populates it.
334
+ */
335
+ readonly followingLineEnding?: "\n" | "\r\n" | "";
336
+ }
337
+ export interface StoryDocument {
338
+ readonly type: "StoryDocument";
339
+ readonly metadata: StoryMetadata;
340
+ readonly initialState: StoryStateDefinition;
341
+ /**
342
+ * The scene id runtime code should start execution from — compiler-
343
+ * normalized execution semantics, distinct from author-facing
344
+ * `metadata.entry`. Resolution order: the author's explicit `entry` if
345
+ * given (even if it turns out not to reference a real scene — that is
346
+ * reported separately as an AT1004 diagnostic, the same way a dangling
347
+ * `@goto` target is), otherwise the document's first scene, otherwise
348
+ * the synthetic leading scene id ("main"). Always set, so runtime code
349
+ * never needs to guess or re-derive which scene starts the story.
350
+ */
351
+ readonly entryScene: string;
352
+ readonly scenes: readonly SceneNode[];
353
+ }
354
+ //# sourceMappingURL=story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story.d.ts","sourceRoot":"","sources":["../../src/ast/story.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5D,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAExE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CACvC;AAMD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B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EAAE,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAMD,MAAM,MAAM,UAAU,GAClB,aAAa,GACb,WAAW,GACX,gBAAgB,GAChB,OAAO,GACP,QAAQ,GACR,UAAU,GACV,eAAe,GACf,WAAW,CAAC;AAEhB,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,EAAE,CAAC;CACnD;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;CACvC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=story.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story.js","sourceRoot":"","sources":["../../src/ast/story.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { StoryDocument } from "./ast/story.js";
2
+ import type { Diagnostic } from "./diagnostics/types.js";
3
+ export interface CompileResult {
4
+ /** The compiled Story AST. Always present — this compiler recovers from
5
+ * ordinary source errors rather than failing to produce a document. */
6
+ readonly document: StoryDocument;
7
+ readonly diagnostics: readonly Diagnostic[];
8
+ /**
9
+ * `true` when `diagnostics` contains at least one `severity: "error"`
10
+ * entry. Warnings (e.g. AT3001) do not count — `document` is still a
11
+ * reasonable best-effort result even when this is `true`.
12
+ */
13
+ readonly hasErrors: boolean;
14
+ }
15
+ /**
16
+ * Compiles AfterText source into a validated Story AST plus diagnostics.
17
+ *
18
+ * Pipeline: directive scanning → Markdown parsing of prose regions →
19
+ * Story AST construction → validation → CompileResult. Ordinary source
20
+ * errors (unknown directives, unclosed blocks, malformed expressions,
21
+ * dangling references) are reported as diagnostics; this function does
22
+ * not throw for them.
23
+ */
24
+ export declare function compile(source: string): CompileResult;
25
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,MAAM,WAAW,aAAa;IAC5B;4EACwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAMrD"}
@@ -0,0 +1,19 @@
1
+ import { parseDocument } from "./parser/document.js";
2
+ import { validate } from "./validation/validate.js";
3
+ /**
4
+ * Compiles AfterText source into a validated Story AST plus diagnostics.
5
+ *
6
+ * Pipeline: directive scanning → Markdown parsing of prose regions →
7
+ * Story AST construction → validation → CompileResult. Ordinary source
8
+ * errors (unknown directives, unclosed blocks, malformed expressions,
9
+ * dangling references) are reported as diagnostics; this function does
10
+ * not throw for them.
11
+ */
12
+ export function compile(source) {
13
+ const { document, diagnostics } = parseDocument(source);
14
+ const validationDiagnostics = validate(document);
15
+ const allDiagnostics = [...diagnostics, ...validationDiagnostics];
16
+ const hasErrors = allDiagnostics.some((d) => d.severity === "error");
17
+ return { document, diagnostics: allDiagnostics, hasErrors };
18
+ }
19
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAepD;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,qBAAqB,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,qBAAqB,CAAC,CAAC;IAClE,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACrE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { SourceSpan } from "../ast/span.js";
2
+ import type { Diagnostic } from "./types.js";
3
+ export declare const Diagnostics: {
4
+ readonly unknownDirective: (name: string, span: SourceSpan) => Diagnostic;
5
+ readonly unclosedBlock: (kind: string, span: SourceSpan) => Diagnostic;
6
+ readonly duplicateScene: (id: string, span: SourceSpan) => Diagnostic;
7
+ readonly unknownSceneReference: (id: string, span: SourceSpan) => Diagnostic;
8
+ readonly malformedChoiceItem: (reason: string, span: SourceSpan) => Diagnostic;
9
+ readonly conditionalBranchAfterElse: (span: SourceSpan) => Diagnostic;
10
+ readonly duplicateVariantId: (id: string, span: SourceSpan) => Diagnostic;
11
+ readonly variantWithoutWhenBranch: (id: string, span: SourceSpan) => Diagnostic;
12
+ readonly unknownVariantReference: (id: string, span: SourceSpan) => Diagnostic;
13
+ readonly variantBranchAfterOtherwise: (id: string, span: SourceSpan) => Diagnostic;
14
+ readonly malformedExpression: (reason: string, span: SourceSpan) => Diagnostic;
15
+ readonly expressionNumericNotFinite: (span: SourceSpan) => Diagnostic;
16
+ readonly unknownBuiltin: (name: string, span: SourceSpan) => Diagnostic;
17
+ readonly wrongBuiltinArity: (name: string, expected: number, actual: number, span: SourceSpan) => Diagnostic;
18
+ readonly invalidBuiltinArgument: (name: string, span: SourceSpan) => Diagnostic;
19
+ readonly unsupportedStateValue: (key: string, span: SourceSpan) => Diagnostic;
20
+ readonly unsupportedStateKey: (key: string, reason: string, span: SourceSpan) => Diagnostic;
21
+ readonly invalidFrontmatter: (reason: string, span: SourceSpan) => Diagnostic;
22
+ readonly malformedPresentation: (reason: string, span: SourceSpan) => Diagnostic;
23
+ readonly presentationNumericNotFinite: (span: SourceSpan) => Diagnostic;
24
+ readonly unsupportedMarkdown: (construct: string, span: SourceSpan) => Diagnostic;
25
+ };
26
+ //# sourceMappingURL=codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/diagnostics/codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,YAAY,CAAC;AAWjE,eAAO,MAAM,WAAW;sCACC,MAAM,QAAQ,UAAU,KAAG,UAAU;mCAGxC,MAAM,QAAQ,UAAU,KAAG,UAAU;kCAQtC,MAAM,QAAQ,UAAU,KAAG,UAAU;yCAG9B,MAAM,QAAQ,UAAU,KAAG,UAAU;2CAQnC,MAAM,QAAQ,UAAU,KAAG,UAAU;gDAGhC,UAAU,KAAG,UAAU;sCAQjC,MAAM,QAAQ,UAAU,KAAG,UAAU;4CAG/B,MAAM,QAAQ,UAAU,KAAG,UAAU;2CAQtC,MAAM,QAAQ,UAAU,KAAG,UAAU;+CAGjC,MAAM,QAAQ,UAAU,KAAG,UAAU;2CAQzC,MAAM,QAAQ,UAAU,KAAG,UAAU;gDAGhC,UAAU,KAAG,UAAU;oCAQnC,MAAM,QAAQ,UAAU,KAAG,UAAU;uCAGlC,MAAM,YAAY,MAAM,UAAU,MAAM,QAAQ,UAAU,KAAG,UAAU;4CAQlE,MAAM,QAAQ,UAAU,KAAG,UAAU;0CAGvC,MAAM,QAAQ,UAAU,KAAG,UAAU;wCAQvC,MAAM,UAAU,MAAM,QAAQ,UAAU,KAAG,UAAU;0CAGnD,MAAM,QAAQ,UAAU,KAAG,UAAU;6CAGlC,MAAM,QAAQ,UAAU,KAAG,UAAU;kDAGhC,UAAU,KAAG,UAAU;8CAQ3B,MAAM,QAAQ,UAAU,KAAG,UAAU;CAQ5D,CAAC"}
@@ -0,0 +1,69 @@
1
+ function diagnostic(severity, code, message, span) {
2
+ return { severity, code, message, span };
3
+ }
4
+ export const Diagnostics = {
5
+ unknownDirective(name, span) {
6
+ return diagnostic("error", "AT1001", `Unknown directive "@${name}".`, span);
7
+ },
8
+ unclosedBlock(kind, span) {
9
+ return diagnostic("error", "AT1002", `Unclosed "@${kind}" block: missing matching "@end".`, span);
10
+ },
11
+ duplicateScene(id, span) {
12
+ return diagnostic("error", "AT1003", `Duplicate scene id "${id}".`, span);
13
+ },
14
+ unknownSceneReference(id, span) {
15
+ return diagnostic("error", "AT1004", `Reference to unknown scene "${id}".`, span);
16
+ },
17
+ malformedChoiceItem(reason, span) {
18
+ return diagnostic("error", "AT1005", `Malformed choice item: ${reason}`, span);
19
+ },
20
+ conditionalBranchAfterElse(span) {
21
+ return diagnostic("error", "AT1006", `A conditional has a branch after "@else": "@else" must be the last branch.`, span);
22
+ },
23
+ duplicateVariantId(id, span) {
24
+ return diagnostic("error", "AT1101", `Duplicate variant id "${id}".`, span);
25
+ },
26
+ variantWithoutWhenBranch(id, span) {
27
+ return diagnostic("error", "AT1102", `Variant "${id}" has no "@when" branch.`, span);
28
+ },
29
+ unknownVariantReference(id, span) {
30
+ return diagnostic("error", "AT1103", `Reference to unknown Variant "${id}".`, span);
31
+ },
32
+ variantBranchAfterOtherwise(id, span) {
33
+ return diagnostic("error", "AT1104", `Variant "${id}" has a branch after "@otherwise": "@otherwise" must be the last branch.`, span);
34
+ },
35
+ malformedExpression(reason, span) {
36
+ return diagnostic("error", "AT2001", `Malformed expression: ${reason}`, span);
37
+ },
38
+ expressionNumericNotFinite(span) {
39
+ return diagnostic("error", "AT2005", "Numeric literal is not representable as a finite number.", span);
40
+ },
41
+ unknownBuiltin(name, span) {
42
+ return diagnostic("error", "AT2002", `Unknown builtin call "${name}".`, span);
43
+ },
44
+ wrongBuiltinArity(name, expected, actual, span) {
45
+ return diagnostic("error", "AT2003", `"${name}" expects ${expected} argument${expected === 1 ? "" : "s"}, got ${actual}.`, span);
46
+ },
47
+ invalidBuiltinArgument(name, span) {
48
+ return diagnostic("error", "AT2004", `"${name}" requires a string literal argument.`, span);
49
+ },
50
+ unsupportedStateValue(key, span) {
51
+ return diagnostic("error", "AT1201", `Unsupported initial state value for "${key}": only string, number, boolean, and null are allowed.`, span);
52
+ },
53
+ unsupportedStateKey(key, reason, span) {
54
+ return diagnostic("error", "AT1201", `Unsupported initial state key "${key}": ${reason}`, span);
55
+ },
56
+ invalidFrontmatter(reason, span) {
57
+ return diagnostic("error", "AT1202", `Invalid frontmatter: ${reason}`, span);
58
+ },
59
+ malformedPresentation(reason, span) {
60
+ return diagnostic("error", "AT1301", `Malformed presentation directive: ${reason}`, span);
61
+ },
62
+ presentationNumericNotFinite(span) {
63
+ return diagnostic("error", "AT1302", "Numeric value is not representable as a finite number.", span);
64
+ },
65
+ unsupportedMarkdown(construct, span) {
66
+ return diagnostic("warning", "AT3001", `Unsupported Markdown construct "${construct}": falling back to plain text.`, span);
67
+ }
68
+ };
69
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.js","sourceRoot":"","sources":["../../src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,IAAgB;QACjD,OAAO,UAAU,CACf,OAAO,EACP,QAAQ,EACR,wCAAwC,GAAG,wDAAwD,EACnG,IAAI,CACL,CAAC;IACJ,CAAC;IACD,mBAAmB,CAAC,GAAW,EAAE,MAAc,EAAE,IAAgB;QAC/D,OAAO,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,kCAAkC,GAAG,MAAM,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IAClG,CAAC;IACD,kBAAkB,CAAC,MAAc,EAAE,IAAgB;QACjD,OAAO,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,wBAAwB,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IAC/E,CAAC;IACD,qBAAqB,CAAC,MAAc,EAAE,IAAgB;QACpD,OAAO,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,qCAAqC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5F,CAAC;IACD,4BAA4B,CAAC,IAAgB;QAC3C,OAAO,UAAU,CACf,OAAO,EACP,QAAQ,EACR,wDAAwD,EACxD,IAAI,CACL,CAAC;IACJ,CAAC;IACD,mBAAmB,CAAC,SAAiB,EAAE,IAAgB;QACrD,OAAO,UAAU,CACf,SAAS,EACT,QAAQ,EACR,mCAAmC,SAAS,gCAAgC,EAC5E,IAAI,CACL,CAAC;IACJ,CAAC;CACO,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { Diagnostic, DiagnosticCode, DiagnosticSeverity } from "./types.js";
2
+ export { Diagnostics } from "./codes.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Diagnostics } from "./codes.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { SourceSpan } from "../ast/span.js";
2
+ export type DiagnosticSeverity = "error" | "warning";
3
+ /**
4
+ * Stable diagnostic codes. Numbers are grouped by concern:
5
+ * 1000s — structural (directives, blocks, scenes)
6
+ * 1100s — variants
7
+ * 1200s — frontmatter (`state:` values, overall YAML validity)
8
+ * 1300s — presentation directives (@background/@layer/@camera/@music/@sfx/@pause)
9
+ * 2000s — expressions
10
+ * 3000s — Markdown (warnings for constructs outside the supported subset)
11
+ */
12
+ export type DiagnosticCode = "AT1001" | "AT1002" | "AT1003" | "AT1004" | "AT1005" | "AT1006" | "AT1101" | "AT1102" | "AT1103" | "AT1104" | "AT1201" | "AT1202" | "AT1301" | "AT1302" | "AT2001" | "AT2002" | "AT2003" | "AT2004" | "AT2005" | "AT3001";
13
+ export interface Diagnostic {
14
+ readonly severity: DiagnosticSeverity;
15
+ readonly code: DiagnosticCode;
16
+ readonly message: string;
17
+ readonly span: SourceSpan;
18
+ }
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/diagnostics/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/diagnostics/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export { compile, type CompileResult } from "./compile.js";
2
+ export type { SourcePosition, SourceSpan, LiteralValue, UnaryOperator, BinaryOperator, LiteralExpression, IdentifierExpression, UnaryExpression, BinaryExpression, CallExpression, ExpressionNode, TextInline, EmphasisInline, StrongInline, InlineCodeInline, LinkInline, LineBreakInline, InlineNode, BackgroundCommand, LayerCommand, CameraAction, CameraZoomCommand, CameraCommand, MusicCommand, SfxCommand, PauseCommand, PresentationCommand, StateValue, StoryStateDefinition, StoryMetadata, ParagraphNode, HeadingNode, PresentationNode, SetNode, GotoNode, ChoiceItem, ChoiceNode, ConditionalBranchKind, ConditionalBranch, ConditionalNode, VariantBranchKind, VariantBranch, VariantNode, StoryBlock, SceneNode, StoryDocument } from "./ast/index.js";
3
+ export type { Diagnostic, DiagnosticCode, DiagnosticSeverity } from "./diagnostics/index.js";
4
+ export { isChoiceTargetBoundarySafe, isPresentationNamedArgumentValueBoundarySafe } from "./parser/serializer-safety.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3D,YAAY,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,aAAa,EACd,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAO7F,OAAO,EAAE,0BAA0B,EAAE,4CAA4C,EAAE,MAAM,+BAA+B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ // Public API surface. Deliberately excludes anything from parser/ that
2
+ // touches remark/mdast/unified — runtime-facing code must depend only on
3
+ // the AfterText-owned AST types re-exported here.
4
+ export { compile } from "./compile.js";
5
+ // Serializer-boundary-safety predicates (docs/CORE_SPEC.md Section 25.40,
6
+ // "Source-Generation Safety Helpers") — small, additive, lexical-only
7
+ // helpers for tools that generate AfterText source. Sourced from
8
+ // `parser/serializer-safety.ts`, which (like this whole module) has no
9
+ // `remark`/`mdast` dependency, unlike `parser/blocks.ts` itself.
10
+ export { isChoiceTargetBoundarySafe, isPresentationNamedArgumentValueBoundarySafe } from "./parser/serializer-safety.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yEAAyE;AACzE,kDAAkD;AAElD,OAAO,EAAE,OAAO,EAAsB,MAAM,cAAc,CAAC;AAqD3D,0EAA0E;AAC1E,sEAAsE;AACtE,iEAAiE;AACjE,uEAAuE;AACvE,iEAAiE;AACjE,OAAO,EAAE,0BAA0B,EAAE,4CAA4C,EAAE,MAAM,+BAA+B,CAAC"}