@reactra/babel-plugin 0.1.0-alpha.0

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 +17 -0
  3. package/dist/ast/index.d.ts +2 -0
  4. package/dist/ast/index.d.ts.map +1 -0
  5. package/dist/ast/index.js +3 -0
  6. package/dist/ast/index.js.map +1 -0
  7. package/dist/ast/nodes.d.ts +437 -0
  8. package/dist/ast/nodes.d.ts.map +1 -0
  9. package/dist/ast/nodes.js +35 -0
  10. package/dist/ast/nodes.js.map +1 -0
  11. package/dist/behaviours/index.d.ts +18 -0
  12. package/dist/behaviours/index.d.ts.map +1 -0
  13. package/dist/behaviours/index.js +36 -0
  14. package/dist/behaviours/index.js.map +1 -0
  15. package/dist/behaviours/plugin.d.ts +22 -0
  16. package/dist/behaviours/plugin.d.ts.map +1 -0
  17. package/dist/behaviours/plugin.js +70 -0
  18. package/dist/behaviours/plugin.js.map +1 -0
  19. package/dist/behaviours/replayable.d.ts +10 -0
  20. package/dist/behaviours/replayable.d.ts.map +1 -0
  21. package/dist/behaviours/replayable.js +86 -0
  22. package/dist/behaviours/replayable.js.map +1 -0
  23. package/dist/behaviours/types.d.ts +77 -0
  24. package/dist/behaviours/types.d.ts.map +1 -0
  25. package/dist/behaviours/types.js +10 -0
  26. package/dist/behaviours/types.js.map +1 -0
  27. package/dist/behaviours/undoable.d.ts +10 -0
  28. package/dist/behaviours/undoable.d.ts.map +1 -0
  29. package/dist/behaviours/undoable.js +62 -0
  30. package/dist/behaviours/undoable.js.map +1 -0
  31. package/dist/compile.d.ts +69 -0
  32. package/dist/compile.d.ts.map +1 -0
  33. package/dist/compile.js +75 -0
  34. package/dist/compile.js.map +1 -0
  35. package/dist/conventions/index.d.ts +110 -0
  36. package/dist/conventions/index.d.ts.map +1 -0
  37. package/dist/conventions/index.js +193 -0
  38. package/dist/conventions/index.js.map +1 -0
  39. package/dist/index.d.ts +48 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +77 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/passes/index.d.ts +5 -0
  44. package/dist/passes/index.d.ts.map +1 -0
  45. package/dist/passes/index.js +6 -0
  46. package/dist/passes/index.js.map +1 -0
  47. package/dist/passes/pass-1-parse.d.ts +3 -0
  48. package/dist/passes/pass-1-parse.d.ts.map +1 -0
  49. package/dist/passes/pass-1-parse.js +21 -0
  50. package/dist/passes/pass-1-parse.js.map +1 -0
  51. package/dist/passes/pass-2-extract.d.ts +4 -0
  52. package/dist/passes/pass-2-extract.d.ts.map +1 -0
  53. package/dist/passes/pass-2-extract.js +762 -0
  54. package/dist/passes/pass-2-extract.js.map +1 -0
  55. package/dist/passes/pass-3-readset.d.ts +11 -0
  56. package/dist/passes/pass-3-readset.d.ts.map +1 -0
  57. package/dist/passes/pass-3-readset.js +338 -0
  58. package/dist/passes/pass-3-readset.js.map +1 -0
  59. package/dist/passes/pass-9-codegen.d.ts +27 -0
  60. package/dist/passes/pass-9-codegen.d.ts.map +1 -0
  61. package/dist/passes/pass-9-codegen.js +2755 -0
  62. package/dist/passes/pass-9-codegen.js.map +1 -0
  63. package/dist/preprocess/helpers.d.ts +71 -0
  64. package/dist/preprocess/helpers.d.ts.map +1 -0
  65. package/dist/preprocess/helpers.js +342 -0
  66. package/dist/preprocess/helpers.js.map +1 -0
  67. package/dist/preprocess/index.d.ts +6 -0
  68. package/dist/preprocess/index.d.ts.map +1 -0
  69. package/dist/preprocess/index.js +11 -0
  70. package/dist/preprocess/index.js.map +1 -0
  71. package/dist/preprocess/keywords.d.ts +28 -0
  72. package/dist/preprocess/keywords.d.ts.map +1 -0
  73. package/dist/preprocess/keywords.js +99 -0
  74. package/dist/preprocess/keywords.js.map +1 -0
  75. package/dist/preprocess/lexer.d.ts +8 -0
  76. package/dist/preprocess/lexer.d.ts.map +1 -0
  77. package/dist/preprocess/lexer.js +143 -0
  78. package/dist/preprocess/lexer.js.map +1 -0
  79. package/dist/preprocess/preprocess.d.ts +3 -0
  80. package/dist/preprocess/preprocess.d.ts.map +1 -0
  81. package/dist/preprocess/preprocess.js +568 -0
  82. package/dist/preprocess/preprocess.js.map +1 -0
  83. package/dist/preprocess/rewriters.d.ts +35 -0
  84. package/dist/preprocess/rewriters.d.ts.map +1 -0
  85. package/dist/preprocess/rewriters.js +1391 -0
  86. package/dist/preprocess/rewriters.js.map +1 -0
  87. package/dist/preprocess/source-map.d.ts +70 -0
  88. package/dist/preprocess/source-map.d.ts.map +1 -0
  89. package/dist/preprocess/source-map.js +253 -0
  90. package/dist/preprocess/source-map.js.map +1 -0
  91. package/dist/preprocess/types.d.ts +57 -0
  92. package/dist/preprocess/types.d.ts.map +1 -0
  93. package/dist/preprocess/types.js +7 -0
  94. package/dist/preprocess/types.js.map +1 -0
  95. package/dist/sidecar.d.ts +137 -0
  96. package/dist/sidecar.d.ts.map +1 -0
  97. package/dist/sidecar.js +172 -0
  98. package/dist/sidecar.js.map +1 -0
  99. package/package.json +42 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Akhil Shastri and the Reactra contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @reactra/babel-plugin
2
+
3
+ > The Reactra compiler — transforms the Reactra DSL into standard React 19 TSX.
4
+
5
+ **Alpha** — published under the npm dist-tag `alpha`. APIs may change before 1.0.
6
+
7
+ ```bash
8
+ npm install @reactra/babel-plugin@alpha
9
+ ```
10
+
11
+ Part of [Reactra](https://github.com/akhilshastri/reactra) — a compiler-first,
12
+ React-19-compatible framework. See the [documentation](https://reactra-docs.vercel.app) to get
13
+ started.
14
+
15
+ ## License
16
+
17
+ MIT
@@ -0,0 +1,2 @@
1
+ export * from "./nodes.ts";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA"}
@@ -0,0 +1,3 @@
1
+ // Re-export Reactra AST node interfaces.
2
+ export * from "./nodes.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,437 @@
1
+ import type { CallExpression, Expression, ArrowFunctionExpression } from "@babel/types";
2
+ export type ContainerKind = "component" | "service" | "route-store" | "session-store" | "export-store";
3
+ export interface ContainerNode {
4
+ kind: ContainerKind;
5
+ name: string;
6
+ exported: boolean;
7
+ /** the __reactra_{kind}__(name, factory) call expression */
8
+ call: CallExpression;
9
+ /** the factory arrow whose body holds the body markers */
10
+ factory: ArrowFunctionExpression;
11
+ states: StateNode[];
12
+ deriveds: DerivedNode[];
13
+ actions: ActionNode[];
14
+ commands: CommandNode[];
15
+ resources: ResourceNode[];
16
+ refs: RefNode[];
17
+ effects: EffectNode[];
18
+ mounts: MountNode[];
19
+ cleanups: CleanupNode[];
20
+ injects: InjectNode[];
21
+ provides: ProvideNode[];
22
+ uses?: UsesNode;
23
+ view?: ViewNode;
24
+ params: ParamNode[];
25
+ queries: QueryNode[];
26
+ meta?: MetaNode;
27
+ prefetch?: PrefetchNode;
28
+ transition?: TransitionNode;
29
+ storeUses: StoreUseNode[];
30
+ errorBoundary?: ErrorBoundaryNode;
31
+ suspense?: SuspenseNode;
32
+ /**
33
+ * Day 23 / `#7b`: per-component list of `await(r) { ... } pending { ... }
34
+ * error(e) { ... }` blocks extracted from the view body. Populated by
35
+ * a Pass-2 walker after the view is captured. The runtime path is
36
+ * still Pass-9's inline rewrite (Suspense + ErrorBoundary + use());
37
+ * this list exists so devtools / LSP / future passes can enumerate
38
+ * await sites without re-parsing the view AST. Empty for components
39
+ * without a view OR without any `await(r){...}` calls.
40
+ */
41
+ awaitBlocks: AwaitBlockNode[];
42
+ inputs: InputNode[];
43
+ preserved?: PreservedNode;
44
+ subtreePath?: string;
45
+ keySig?: string;
46
+ /**
47
+ * Service-only — Wave 3 §2b. Captures the `scoped` / `server` modifier
48
+ * on `export service scoped X { ... }` / `export service server X
49
+ * { ... }`. Mapped from the preprocessor's marker name in Pass 2 —
50
+ * `__reactra_service_scoped__` → `"scoped"`,
51
+ * `__reactra_service_server__` → `"server"`. Absent for app-singleton
52
+ * `export service X` (the default).
53
+ */
54
+ serviceModifier?: "scoped" | "server";
55
+ /**
56
+ * Component-only — the React-style props parameter (Component DSL §1.1).
57
+ * `propsParam` is the verbatim parameter text Pass 9 re-emits on the component
58
+ * arrow (`const X = (<propsParam>) => …`); absent for a bare `component X {`.
59
+ * `propNames` are the binding names Pass 3 adds to the reactive read-set: each
60
+ * destructured binding for `({ a, b })`, or the single bag identifier for
61
+ * `(props)` (a `props.x` member read then resolves to the `props` object).
62
+ */
63
+ propsParam?: string;
64
+ propNames?: string[];
65
+ }
66
+ export interface StateNode {
67
+ kind: "state";
68
+ name: string;
69
+ initializer: Expression;
70
+ /** original source text of the initializer (for codegen) */
71
+ initializerText: string;
72
+ /** the __reactra_state__("name", init) call expression */
73
+ call: CallExpression;
74
+ }
75
+ export interface DerivedNode {
76
+ kind: "derived";
77
+ name: string;
78
+ /** thunk arrow ()=>(expr); body holds the expression */
79
+ thunk: ArrowFunctionExpression;
80
+ /** original source text of the expression */
81
+ exprText: string;
82
+ /**
83
+ * Reactive reads in the expression — the `useMemo` dependency array.
84
+ * Populated by Pass 3 (read-set analysis); `[]` means no reactive reads.
85
+ * Without this the emitted `useMemo(fn, [])` would freeze at first render.
86
+ */
87
+ deps: string[];
88
+ call: CallExpression;
89
+ }
90
+ export interface ActionNode {
91
+ kind: "action";
92
+ name: string;
93
+ isAsync: boolean;
94
+ /** the (args)=>{ body } arrow */
95
+ arrow: ArrowFunctionExpression;
96
+ /**
97
+ * Reactive reads in the body — the `useCallback` dependency array.
98
+ * Populated by Pass 3 (read-set analysis); `[]` means no reactive reads.
99
+ * Without this the emitted `useCallback(fn, [])` captures stale state.
100
+ */
101
+ deps: string[];
102
+ call: CallExpression;
103
+ }
104
+ /**
105
+ * The `command` write primitive (forms / CQRS twin of `resource`). Slice 1: the
106
+ * BLOCK form `command f(args) { body }` — implicitly async — lowers to React 19
107
+ * `useActionState` (Pass 9 `emitCommand`), exposing `f.pending`/`f.result`/`f.error`.
108
+ * The arrow + `optimistic {}` form and the `uses replayable`/`undoable` recording
109
+ * layer (begin/commit/rollback → the P2 channel) are later slices.
110
+ */
111
+ export interface CommandNode {
112
+ kind: "command";
113
+ name: string;
114
+ /**
115
+ * "block" = `command f() { body }` → `useActionState` (Slice 1).
116
+ * "arrow" = `command f() => fetcher` → `useTransition` (Slice 3a; + `useOptimistic`
117
+ * once the `optimistic {}` clause lands in Slice 3b).
118
+ */
119
+ form: "block" | "arrow";
120
+ /**
121
+ * block: the `async (args) => { body }` arrow; arrow: the `async (args) => (fetcher)`
122
+ * arrow. Emitted verbatim (source-mapped) inside the reducer / transition.
123
+ */
124
+ arrow: ArrowFunctionExpression;
125
+ /**
126
+ * Arrow form only — the `() => { writes }` arrow from the `optimistic {}` clause
127
+ * (Slice 3b). Each `X = expr` is lowered to BOTH the optimistic setter (`__setOpt_X`,
128
+ * applied before the await) and the real setter (`setX`, the commit on success);
129
+ * React's `useOptimistic` auto-reverts on failure. Absent = no optimistic clause.
130
+ */
131
+ optimistic?: ArrowFunctionExpression;
132
+ /**
133
+ * Arrow form only — resource names from the `invalidate [a, b]` clause (Slice 4).
134
+ * After the command settles successfully, each listed resource's cache entry is
135
+ * invalidated (`__getResourceCache().invalidate([...])`) so it refetches. Absent
136
+ * = no invalidate clause.
137
+ */
138
+ invalidate?: string[];
139
+ /**
140
+ * Arrow form only — the `(e) => { body }` arrow from the `rollback(e) {}` clause
141
+ * (Slice 4). Run in the catch on failure (IIFE-called with the error). When
142
+ * present the failure is treated as handled (no re-throw); useOptimistic still
143
+ * auto-reverts. Absent = the error propagates (or, under recording, re-throws).
144
+ */
145
+ rollback?: ArrowFunctionExpression;
146
+ call: CallExpression;
147
+ }
148
+ export interface ResourceNode {
149
+ kind: "resource";
150
+ name: string;
151
+ /** ()=>deps thunk */
152
+ depsThunk: ArrowFunctionExpression;
153
+ /** (deps, ctx)=>fn(deps) arrow */
154
+ fetcher: ArrowFunctionExpression;
155
+ /**
156
+ * Compiler stage 3 — opt-in modifier flags from the DSL grammar
157
+ * (`resource X(deps) [signal] [cache] [swr] [retry] => fn`). Pass 9
158
+ * merges these into the third `useResource(deps, fn, opts)` argument
159
+ * and into the route-store warm-companion's `warmResource(name, deps,
160
+ * fn, signal)` call (warm itself is best-effort; only `signal` affects
161
+ * the fetcher arrow). Absent = all false → emitted opts stay at just
162
+ * `{ resourceName: "..." }` (architect Q2 Path B preserved).
163
+ */
164
+ optCache?: boolean;
165
+ optSwr?: boolean;
166
+ optRetry?: boolean;
167
+ /**
168
+ * Parameterized-modifier values (the args inside `swr(…)` / `cache(ttl: …)` /
169
+ * `retry(…)`). Source text of the value expression, already normalized by the
170
+ * rewriter (durations → ms). Absent = the modifier was written bare and Pass 9
171
+ * uses the default (`ttlMs: 60_000`, `retry: 3`). `cacheTtl` applies to whichever
172
+ * of `swr`/`cache` is set (swr → SWR window; cache → hard-expiry refetch).
173
+ */
174
+ cacheTtl?: string;
175
+ retryCount?: string;
176
+ /**
177
+ * The `select(<arrow>)` selector's source text (Option A). Pass 9 emits it as
178
+ * the `select` ResourceOption; the shadow types `.data` as `ReturnType<typeof
179
+ * (<select>)>`. Both read this one string → no shadow⇄Pass-9 drift (B1).
180
+ */
181
+ select?: string;
182
+ /**
183
+ * R028 (advisory) — names of deps that mint a fresh object/array reference per
184
+ * render: an inline `ObjectExpression`/`ArrayExpression` dep literal, or an
185
+ * identifier naming a same-container `derived` whose thunk RHS is an object/
186
+ * array literal. Such a dep never key-equals across renders, so the resource
187
+ * refetches every render and the `depsToKey` id cache grows unbounded
188
+ * (Component DSL §2.4). Populated by Pass 3; absent/empty = stable. Pass 9
189
+ * emits a `console.warn` per offending name. Inline-literal deps have no
190
+ * identifier name, so they appear as a synthetic `"(inline object literal)"` /
191
+ * `"(inline array literal)"` marker.
192
+ */
193
+ unstableDeps?: string[];
194
+ call: CallExpression;
195
+ }
196
+ export interface EffectNode {
197
+ kind: "effect";
198
+ /** present for `effect on(x)` — null for plain `effect` */
199
+ watch?: ArrowFunctionExpression;
200
+ /** ()=>{body} arrow */
201
+ body: ArrowFunctionExpression;
202
+ call: CallExpression;
203
+ }
204
+ export interface MountNode {
205
+ kind: "mount";
206
+ body: ArrowFunctionExpression;
207
+ call: CallExpression;
208
+ }
209
+ export interface CleanupNode {
210
+ kind: "cleanup";
211
+ body: ArrowFunctionExpression;
212
+ call: CallExpression;
213
+ }
214
+ export interface RefNode {
215
+ kind: "ref";
216
+ name: string;
217
+ initializer: Expression;
218
+ initializerText: string;
219
+ call: CallExpression;
220
+ }
221
+ export interface ViewNode {
222
+ kind: "view";
223
+ /** ()=>(<>JSX</>) arrow */
224
+ body: ArrowFunctionExpression;
225
+ /**
226
+ * R029 (advisory) — the number of `.map()` calls in this view whose callback
227
+ * returns a `JSXElement` with no `key` attribute (and no `JSXSpreadAttribute`,
228
+ * which may carry a key). Fragment shorthand `<>…</>` returns are excluded
229
+ * (a fragment cannot take a key). Populated by Pass 3; `0`/absent = clean.
230
+ * Pass 9 emits one `console.warn` per offending `.map()`. Emission-invisible.
231
+ */
232
+ keylessMaps?: number;
233
+ call: CallExpression;
234
+ }
235
+ export interface ParamNode {
236
+ kind: "param";
237
+ name: string;
238
+ call: CallExpression;
239
+ }
240
+ export interface QueryNode {
241
+ kind: "query";
242
+ name: string;
243
+ /**
244
+ * The declared TS type text (e.g. `"number"`, `"string"`,
245
+ * `'"active" | "archived"'`), threaded from the preprocessor so Pass-9 can
246
+ * emit the right runtime coercion. Defaults to `"string"` when the
247
+ * declaration omits the annotation.
248
+ */
249
+ tsType: string;
250
+ defaultExpr?: Expression;
251
+ defaultText?: string;
252
+ /**
253
+ * Custom parser identifier from `query foo: T from parseFoo` (Router §3.1).
254
+ * When present, Pass 9 emits `const foo = parseFoo(__route.query.foo)` instead
255
+ * of the generic `coerceQuery(...)` — the user's parser owns the conversion.
256
+ */
257
+ fromParser?: string;
258
+ call: CallExpression;
259
+ }
260
+ export interface MetaNode {
261
+ kind: "meta";
262
+ /** the meta object literal expression */
263
+ object: Expression;
264
+ call: CallExpression;
265
+ }
266
+ export interface PrefetchNode {
267
+ kind: "prefetch";
268
+ trigger: "hover" | "visible" | "mount" | "none";
269
+ call: CallExpression;
270
+ }
271
+ export interface TransitionNode {
272
+ kind: "transition";
273
+ name: string;
274
+ durationMs?: number;
275
+ call: CallExpression;
276
+ }
277
+ export type StoreUseClassification = "bare" | "argumented" | "keyed";
278
+ /** A renamed field selection — `inject store X { source: local }` (Store v4.7 §2.5). */
279
+ export interface StoreFieldRename {
280
+ readonly source: string;
281
+ readonly local: string;
282
+ /** Set when the user wrote `source as local` — invalid (S017); raised in Pass 9. */
283
+ readonly as?: boolean;
284
+ }
285
+ /** A field-selection entry: a bare field name, or a `{ source: local }` rename. */
286
+ export type StoreField = string | StoreFieldRename;
287
+ /** The in-scope binding name of a field entry — the rename target, else the field itself. */
288
+ export declare const fieldLocal: (f: StoreField) => string;
289
+ export interface StoreUseNode {
290
+ kind: "store-use";
291
+ storeName: string;
292
+ classification: StoreUseClassification;
293
+ /** for argumented + keyed: the args object literal `{ input: routeSource }` */
294
+ args?: Expression;
295
+ /** for keyed: the key expression */
296
+ key?: Expression;
297
+ /**
298
+ * Explicit field selection from `inject store X { a, b }` (Store §2.5).
299
+ * Present → codegen destructures exactly these names; absent → namespace
300
+ * binding (`const X = useReactraStore<X>("X")`, member access). Backlog 1a.
301
+ * A renamed entry `{ b: localB }` is a {@link StoreFieldRename} (Store v4.7);
302
+ * the **local** name is the in-scope binding and the Pass-3 read-set key.
303
+ */
304
+ fields?: StoreField[];
305
+ /**
306
+ * Optional `:Type` override from `inject store X({…}): IFoo { … }` (Store §2.5,
307
+ * Compiler v14). Present → codegen emits `useReactraStore<IFoo>` so TypeScript
308
+ * surfaces an incompatible structural subset (S015 is type-level/LSP, not a
309
+ * Babel-pass check). Independent of `fields` and `classification`. The override
310
+ * types the value but never binds the store *name* (still `import type { X }`).
311
+ */
312
+ typeOverride?: string;
313
+ /**
314
+ * Namespace alias from `inject store X as Y` (Store v4.9 §2.5). Present →
315
+ * Pass 9 binds `const Y = useReactraStore<X>("X")` and Pass 3 keys the
316
+ * namespace read-set on `Y`. Namespace-only — `alias` + `fields` is S018.
317
+ */
318
+ alias?: string;
319
+ call: CallExpression;
320
+ }
321
+ export interface InjectNode {
322
+ kind: "inject";
323
+ name: string;
324
+ /**
325
+ * Kind qualifier from `inject service X` (Requirements v14). Absent for the
326
+ * `inject X from <source>` forms and for a bare `inject X` (the latter is
327
+ * SVC015 — missing qualifier and no source clause).
328
+ */
329
+ serviceKind?: "service";
330
+ /** `"config"` / `"inject"` when an explicit `from <source>` clause is present. */
331
+ source?: string;
332
+ /**
333
+ * Namespace alias from `inject service X as Y` (Service v2.3 §4.2). Present →
334
+ * Pass 9 binds `const Y = useService("X")` (or `ServiceRegistry.get`). The
335
+ * service identity (`name`) is unchanged; only the local binding is renamed.
336
+ */
337
+ alias?: string;
338
+ call: CallExpression;
339
+ }
340
+ export interface ProvideNode {
341
+ kind: "provide";
342
+ name: string;
343
+ /** the value expression after `with` */
344
+ value: Expression;
345
+ valueText: string;
346
+ call: CallExpression;
347
+ }
348
+ export interface UsesNode {
349
+ kind: "uses";
350
+ names: string[];
351
+ call: CallExpression;
352
+ }
353
+ export interface ErrorBoundaryNode {
354
+ kind: "error-boundary";
355
+ errorParam: string;
356
+ body: ArrowFunctionExpression;
357
+ call: CallExpression;
358
+ }
359
+ /**
360
+ * One `await(r) { … } pending { … } error(e) { … }` block discovered in
361
+ * a component's view body. `resourceName` is the text of the resource
362
+ * expression — typically a bare identifier (e.g. `"customer"`) but can be
363
+ * any expression (e.g. `"profile.data"`); the sidecar consumer treats
364
+ * it as opaque. `hasPending` / `hasError` mirror whether the optional
365
+ * branches are present in the source.
366
+ */
367
+ export interface AwaitBlockNode {
368
+ kind: "await-block";
369
+ resourceName: string;
370
+ hasPending: boolean;
371
+ hasError: boolean;
372
+ }
373
+ export interface SuspenseNode {
374
+ kind: "suspense";
375
+ body: ArrowFunctionExpression;
376
+ call: CallExpression;
377
+ }
378
+ export type InputRequired = "required" | "optional" | "default";
379
+ export interface InputNode {
380
+ kind: "input";
381
+ name: string;
382
+ requirement: InputRequired;
383
+ /** present when requirement === "default" */
384
+ defaultExpr?: Expression;
385
+ defaultText?: string;
386
+ /**
387
+ * The declared TS type text (e.g. `"string"`, `"Customer"`), threaded from the
388
+ * preprocessor for the shadow emitter (Run 2 / D3). Pass-9 codegen does NOT read
389
+ * it — store inputs lower structurally — so adding it is emission-invisible
390
+ * (golden byte-identical). Absent when unannotated.
391
+ */
392
+ tsType?: string;
393
+ call: CallExpression;
394
+ }
395
+ export interface PreservedNode {
396
+ kind: "preserved";
397
+ /** state field names to preserve */
398
+ fields: string[];
399
+ call: CallExpression;
400
+ }
401
+ /**
402
+ * The output of Pass 2 (extraction): a flat list of containers per source
403
+ * file, each with its body markers fully classified. Later passes consume
404
+ * this structure.
405
+ */
406
+ export interface FileGraph {
407
+ /** original source string — needed by passes to slice expression text */
408
+ source: string;
409
+ /** preprocessed source that was actually parsed */
410
+ preprocessed: string;
411
+ /** top-level Reactra declarations */
412
+ containers: ContainerNode[];
413
+ /**
414
+ * Verbatim text of every top-level `import …` statement in the source.
415
+ * The preprocessor never touches module-scope imports, so the slices are
416
+ * directly equivalent to what the user wrote. Pass 9 re-emits them above
417
+ * the compiler-injected imports so the user's modules stay reachable
418
+ * inside container bodies.
419
+ */
420
+ userImports: string[];
421
+ /**
422
+ * Verbatim text of every top-level `interface` / `type` declaration in the
423
+ * source (including `export`ed ones). These are pure type-level (hoisted,
424
+ * zero runtime), so Pass 9 re-emits them after the imports — letting a DSL
425
+ * file declare its own props types (`interface FieldProps { … }`) in-file
426
+ * (Component DSL §1.1). Non-type top-level statements (const/function) are
427
+ * not preserved.
428
+ */
429
+ userTypes: string[];
430
+ }
431
+ /**
432
+ * Marker function name -> ContainerKind for the top-level wrappers.
433
+ * Used by Pass 2 to recognise the outer-decl markers emitted by the
434
+ * preprocessor's signature-wrap step.
435
+ */
436
+ export declare const CONTAINER_MARKERS: Record<string, ContainerKind>;
437
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAIvF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,eAAe,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M,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAiB3D,CAAA"}
@@ -0,0 +1,35 @@
1
+ // Reactra AST node interfaces — Compiler v2 §3 (AST Node Catalogue).
2
+ //
3
+ // These are *annotations* attached to the underlying Babel AST during
4
+ // Pass 2 (extraction) and used by Passes 3–9. Each node holds:
5
+ // - the metadata extracted from the marker call (name, initializer, …)
6
+ // - a reference back to the Babel CallExpression so later passes can
7
+ // mutate or rewrite the original node in place.
8
+ //
9
+ // Owner spec: reactra-compiler-spec.md §3.
10
+ /** The in-scope binding name of a field entry — the rename target, else the field itself. */
11
+ export const fieldLocal = (f) => (typeof f === "string" ? f : f.local);
12
+ /**
13
+ * Marker function name -> ContainerKind for the top-level wrappers.
14
+ * Used by Pass 2 to recognise the outer-decl markers emitted by the
15
+ * preprocessor's signature-wrap step.
16
+ */
17
+ export const CONTAINER_MARKERS = {
18
+ __reactra_component__: "component",
19
+ __reactra_service__: "service",
20
+ __reactra_service_scoped__: "service",
21
+ __reactra_service_server__: "service",
22
+ __reactra_route_store__: "route-store",
23
+ __reactra_route_store_subtree__: "route-store",
24
+ __reactra_route_store_keyed__: "route-store",
25
+ __reactra_session_store__: "session-store",
26
+ __reactra_export_store__: "export-store",
27
+ /**
28
+ * DSL v2 — `export app store X { … }` (lifetime word is `app`, separate from
29
+ * `export`). Safe-default: maps to the existing `"export-store"` kind so sidecar
30
+ * / emit / extraction are byte-identical. The `kind: "export"` emitted value is
31
+ * unchanged (renaming to `"app"` is deferred — see plan §5 G2 note).
32
+ */
33
+ __reactra_app_store__: "export-store",
34
+ };
35
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,sEAAsE;AACtE,+DAA+D;AAC/D,yEAAyE;AACzE,uEAAuE;AACvE,oDAAoD;AACpD,EAAE;AACF,2CAA2C;AAwU3C,6FAA6F;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAa,EAAU,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAqK1F;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkC;IAC9D,qBAAqB,EAAE,WAAW;IAClC,mBAAmB,EAAE,SAAS;IAC9B,0BAA0B,EAAE,SAAS;IACrC,0BAA0B,EAAE,SAAS;IACrC,uBAAuB,EAAE,aAAa;IACtC,+BAA+B,EAAE,aAAa;IAC9C,6BAA6B,EAAE,aAAa;IAC5C,yBAAyB,EAAE,eAAe;IAC1C,wBAAwB,EAAE,cAAc;IACxC;;;;;OAKG;IACH,qBAAqB,EAAE,cAAc;CACtC,CAAA"}
@@ -0,0 +1,18 @@
1
+ import type { ContainerNode } from "../ast/nodes.ts";
2
+ import type { CompilerNativeBehaviour } from "./types.ts";
3
+ export type { BehaviourEmitCtx, CompilerNativeBehaviour } from "./types.ts";
4
+ /**
5
+ * The compiler-native behaviours, keyed by `uses` name. Grow this map as native
6
+ * behaviours ship. Plugin/HOF behaviours are NOT in this map (separate, deferred
7
+ * Behaviour Plugin spec).
8
+ */
9
+ export declare const NATIVE_BEHAVIOURS: ReadonlyMap<string, CompilerNativeBehaviour>;
10
+ /**
11
+ * The registered native behaviours a container `uses`, in `uses` source order
12
+ * (Component DSL §9: "instrumentation is layered in source order"). Components
13
+ * only — a store/service carrying a native behaviour is out of Phase-1 scope, so
14
+ * it matches nothing here and the use-site diagnostic in the owner spec applies.
15
+ * Unmatched `uses` names are not returned; Pass 9 warns them inert.
16
+ */
17
+ export declare const matchedNativeBehaviours: (c: ContainerNode) => CompilerNativeBehaviour[];
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/behaviours/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAGzD,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAE3E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAGzE,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,GAAG,aAAa,KAAG,uBAAuB,EAQjF,CAAA"}
@@ -0,0 +1,36 @@
1
+ // @reactra/babel-plugin — compiler-native behaviour registry.
2
+ //
3
+ // Owner spec: reactra-compiler-spec.md §4 Pass 9.1. Maps each `uses` name to the
4
+ // `CompilerNativeBehaviour` that knows how to instrument it. Pass 9 dispatches
5
+ // through this table; a name absent from it stays a code-less `BHV` inert
6
+ // advisory (NOT a silent drop — architect condition 3 / today's BUG-3 path).
7
+ import { replayableBehaviour } from "./replayable.js";
8
+ import { undoableBehaviour } from "./undoable.js";
9
+ /**
10
+ * The compiler-native behaviours, keyed by `uses` name. Grow this map as native
11
+ * behaviours ship. Plugin/HOF behaviours are NOT in this map (separate, deferred
12
+ * Behaviour Plugin spec).
13
+ */
14
+ export const NATIVE_BEHAVIOURS = new Map([
15
+ [undoableBehaviour.name, undoableBehaviour],
16
+ [replayableBehaviour.name, replayableBehaviour],
17
+ ]);
18
+ /**
19
+ * The registered native behaviours a container `uses`, in `uses` source order
20
+ * (Component DSL §9: "instrumentation is layered in source order"). Components
21
+ * only — a store/service carrying a native behaviour is out of Phase-1 scope, so
22
+ * it matches nothing here and the use-site diagnostic in the owner spec applies.
23
+ * Unmatched `uses` names are not returned; Pass 9 warns them inert.
24
+ */
25
+ export const matchedNativeBehaviours = (c) => {
26
+ if (c.kind !== "component")
27
+ return [];
28
+ const out = [];
29
+ for (const name of c.uses?.names ?? []) {
30
+ const b = NATIVE_BEHAVIOURS.get(name);
31
+ if (b)
32
+ out.push(b);
33
+ }
34
+ return out;
35
+ };
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/behaviours/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,0EAA0E;AAC1E,6EAA6E;AAG7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAIjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAiD,IAAI,GAAG,CAAC;IACrF,CAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAC3C,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC;CAChD,CAAC,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAgB,EAA6B,EAAE;IACrF,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,EAAE,CAAA;IACrC,MAAM,GAAG,GAA8B,EAAE,CAAA;IACzC,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;QACvC,MAAM,CAAC,GAAG,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACrC,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { ContainerNode, FileGraph } from "../ast/nodes.ts";
2
+ /** First-party plugin behaviours — DSL vocabulary with a compiler-constant import path (§3 row 2). */
3
+ export declare const FIRST_PARTY_PLUGINS: ReadonlySet<string>;
4
+ /**
5
+ * Binding names introduced by the file's top-level VALUE imports — named,
6
+ * default, and namespace forms; `import type` lines are skipped (a type can't
7
+ * wrap a component). Regex over the preserved user-import lines is sufficient:
8
+ * Pass 2 stores them verbatim and they are single statements by construction.
9
+ */
10
+ export declare const importedBindingNames: (userImports: readonly string[]) => Set<string>;
11
+ /** A resolved plugin behaviour: the wrap identifier + whether it auto-imports. */
12
+ export interface ResolvedPlugin {
13
+ name: string;
14
+ firstParty: boolean;
15
+ }
16
+ /**
17
+ * Resolve a component's plugin-class `uses` names (everything not in the
18
+ * native registry), in source order (Behaviour Plugin §3). Throws R045 for a
19
+ * name that is neither first-party nor bound by a value import in the file.
20
+ */
21
+ export declare const resolvePluginBehaviours: (c: ContainerNode, graph: FileGraph) => ResolvedPlugin[];
22
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/behaviours/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG/D,sGAAsG;AACtG,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAIlD,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,aAAa,SAAS,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,CAsB/E,CAAA;AAED,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAI,GAAG,aAAa,EAAE,OAAO,SAAS,KAAG,cAAc,EAe1F,CAAA"}