@mmapp/react-compiler 0.1.0-alpha.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/README.md +107 -0
- package/compile-blueprint-chat.mjs +99 -0
- package/compile-blueprint-glass-console.mjs +98 -0
- package/compile-chat-defs.mjs +92 -0
- package/dist/babel/index.d.mts +3 -0
- package/dist/babel/index.d.ts +3 -0
- package/dist/babel/index.js +4851 -0
- package/dist/babel/index.mjs +7 -0
- package/dist/chunk-26U577GB.mjs +3465 -0
- package/dist/chunk-2FBDFAX6.mjs +2362 -0
- package/dist/chunk-2L4QSMXG.mjs +175 -0
- package/dist/chunk-2REDFOER.mjs +931 -0
- package/dist/chunk-46YKSHQR.mjs +175 -0
- package/dist/chunk-4XHK6FWL.mjs +2058 -0
- package/dist/chunk-5M7DKKBC.mjs +215 -0
- package/dist/chunk-5VNJ7C6N.mjs +154 -0
- package/dist/chunk-6CQOAAMV.mjs +1803 -0
- package/dist/chunk-6SEVAAVT.mjs +3516 -0
- package/dist/chunk-6YLR5ZDA.mjs +2829 -0
- package/dist/chunk-AOGY2GK6.mjs +3292 -0
- package/dist/chunk-AXXUXRNA.mjs +1434 -0
- package/dist/chunk-CHLVKMQW.mjs +175 -0
- package/dist/chunk-CKGOZAB7.mjs +939 -0
- package/dist/chunk-D34RAZUX.mjs +2223 -0
- package/dist/chunk-EQGA6A6D.mjs +121 -0
- package/dist/chunk-EY2CSXYA.mjs +822 -0
- package/dist/chunk-FIQ65CDR.mjs +925 -0
- package/dist/chunk-FOZXJFAR.mjs +186 -0
- package/dist/chunk-FX6URXWN.mjs +186 -0
- package/dist/chunk-G7SMOWOL.mjs +828 -0
- package/dist/chunk-GGB4G5YY.mjs +175 -0
- package/dist/chunk-HLRGCCIL.mjs +4839 -0
- package/dist/chunk-HOIUP6IF.mjs +690 -0
- package/dist/chunk-I3AU7GRD.mjs +120 -0
- package/dist/chunk-ILFGMUVD.mjs +1933 -0
- package/dist/chunk-IPTX5MJU.mjs +3223 -0
- package/dist/chunk-ITGUSH2Z.mjs +2783 -0
- package/dist/chunk-IXHBCAMF.mjs +3306 -0
- package/dist/chunk-J7TWJ3TM.mjs +2784 -0
- package/dist/chunk-JDPLDGVF.mjs +4810 -0
- package/dist/chunk-K53XP2DL.mjs +148 -0
- package/dist/chunk-K5HX2SVL.mjs +1902 -0
- package/dist/chunk-KFGYOOVS.mjs +214 -0
- package/dist/chunk-KFVVOS5N.mjs +925 -0
- package/dist/chunk-L2OZ4CDV.mjs +113 -0
- package/dist/chunk-MIZV3TAN.mjs +3293 -0
- package/dist/chunk-NKKLQE5V.mjs +148 -0
- package/dist/chunk-NOW23XFZ.mjs +186 -0
- package/dist/chunk-NRXQKQ74.mjs +148 -0
- package/dist/chunk-OWI6XWCD.mjs +3375 -0
- package/dist/chunk-PRUMNNDI.mjs +3192 -0
- package/dist/chunk-QTBD5B3F.mjs +148 -0
- package/dist/chunk-SKSDPPNT.mjs +3788 -0
- package/dist/chunk-SP2YUS33.mjs +186 -0
- package/dist/chunk-SU4E6E7B.mjs +3153 -0
- package/dist/chunk-SYUUKW5A.mjs +3379 -0
- package/dist/chunk-UL2XZEMA.mjs +3128 -0
- package/dist/chunk-XMWUHQVV.mjs +939 -0
- package/dist/chunk-XZNEDRGN.mjs +3876 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/chunk-YFS6JMYO.mjs +3342 -0
- package/dist/chunk-Z6AIQ4KL.mjs +113 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +11585 -0
- package/dist/cli/index.mjs +701 -0
- package/dist/codemod/cli.d.mts +1 -0
- package/dist/codemod/cli.d.ts +1 -0
- package/dist/codemod/cli.js +1104 -0
- package/dist/codemod/cli.mjs +157 -0
- package/dist/codemod/index.d.mts +148 -0
- package/dist/codemod/index.d.ts +148 -0
- package/dist/codemod/index.js +981 -0
- package/dist/codemod/index.mjs +25 -0
- package/dist/dev-server-Bs_sz2DG.d.mts +111 -0
- package/dist/dev-server-Bs_sz2DG.d.ts +111 -0
- package/dist/dev-server-CjoufJ-u.d.mts +109 -0
- package/dist/dev-server-CjoufJ-u.d.ts +109 -0
- package/dist/dev-server.d.mts +3 -0
- package/dist/dev-server.d.ts +3 -0
- package/dist/dev-server.js +7603 -0
- package/dist/dev-server.mjs +11 -0
- package/dist/envelope-DD7v0v6E.d.mts +265 -0
- package/dist/envelope-DD7v0v6E.d.ts +265 -0
- package/dist/envelope-vCVjrHlo.d.mts +265 -0
- package/dist/envelope-vCVjrHlo.d.ts +265 -0
- package/dist/envelope.d.mts +2 -0
- package/dist/envelope.d.ts +2 -0
- package/dist/envelope.js +5184 -0
- package/dist/envelope.mjs +9 -0
- package/dist/index-B5gSgvnd.d.mts +44 -0
- package/dist/index-B5gSgvnd.d.ts +44 -0
- package/dist/index-Bs0MnR54.d.mts +103 -0
- package/dist/index-Bs0MnR54.d.ts +103 -0
- package/dist/index-DR0nNc_f.d.mts +101 -0
- package/dist/index-DR0nNc_f.d.ts +101 -0
- package/dist/index-revho_gS.d.mts +104 -0
- package/dist/index-revho_gS.d.ts +104 -0
- package/dist/index.d.mts +1099 -0
- package/dist/index.d.ts +1099 -0
- package/dist/index.js +10162 -0
- package/dist/index.mjs +372 -0
- package/dist/init-IXEE2RCF.mjs +340 -0
- package/dist/project-compiler-EGJUTAJU.mjs +10 -0
- package/dist/project-compiler-VFR6CSDX.mjs +10 -0
- package/dist/project-decompiler-5GY2KSG4.mjs +7 -0
- package/dist/pull-A2QUHW4K.mjs +109 -0
- package/dist/pull-JBEQWVPE.mjs +109 -0
- package/dist/testing/index.d.mts +211 -0
- package/dist/testing/index.d.ts +211 -0
- package/dist/testing/index.js +5106 -0
- package/dist/testing/index.mjs +247 -0
- package/dist/vite/index.d.mts +59 -0
- package/dist/vite/index.d.ts +59 -0
- package/dist/vite/index.js +5023 -0
- package/dist/vite/index.mjs +8 -0
- package/examples/README.md +72 -0
- package/examples/authentication/main.workflow.tsx +139 -0
- package/examples/authentication/mm.config.ts +22 -0
- package/examples/authentication/models/auth.ts +45 -0
- package/examples/authentication/pages/LoginPage.tsx +79 -0
- package/examples/authentication/pages/SignupPage.tsx +87 -0
- package/examples/counter.workflow.tsx +65 -0
- package/examples/dashboard.workflow.tsx +419 -0
- package/examples/invoice-approval/actions/invoice.server.ts +72 -0
- package/examples/invoice-approval/main.workflow.tsx +168 -0
- package/examples/invoice-approval/mm.config.ts +18 -0
- package/examples/invoice-approval/models/invoice.ts +46 -0
- package/examples/invoice-approval/pages/InvoiceDetailPage.tsx +175 -0
- package/examples/invoice-approval/pages/InvoiceFormPage.tsx +198 -0
- package/examples/invoice-approval/pages/InvoiceListPage.tsx +141 -0
- package/examples/todo-app.workflow.tsx +131 -0
- package/examples/uber-app/actions/matching.server.ts +177 -0
- package/examples/uber-app/actions/notifications.server.ts +176 -0
- package/examples/uber-app/actions/payments.server.ts +184 -0
- package/examples/uber-app/actions/pricing.server.ts +176 -0
- package/examples/uber-app/app/admin/analytics.tsx +102 -0
- package/examples/uber-app/app/admin/fleet.tsx +102 -0
- package/examples/uber-app/app/admin/surge-pricing.tsx +95 -0
- package/examples/uber-app/app/driver/dashboard.tsx +87 -0
- package/examples/uber-app/app/driver/earnings.tsx +101 -0
- package/examples/uber-app/app/driver/navigation.tsx +94 -0
- package/examples/uber-app/app/driver/ride-acceptance.tsx +103 -0
- package/examples/uber-app/app/rider/home.tsx +109 -0
- package/examples/uber-app/app/rider/payment-methods.tsx +134 -0
- package/examples/uber-app/app/rider/ride-history.tsx +90 -0
- package/examples/uber-app/app/rider/ride-tracking.tsx +108 -0
- package/examples/uber-app/components/DriverCard.tsx +176 -0
- package/examples/uber-app/components/MapView.tsx +216 -0
- package/examples/uber-app/components/RatingStars.tsx +227 -0
- package/examples/uber-app/components/RideCard.tsx +167 -0
- package/examples/uber-app/mm.config.ts +30 -0
- package/examples/uber-app/models/location.model.ts +70 -0
- package/examples/uber-app/models/payment.model.ts +87 -0
- package/examples/uber-app/models/rating.model.ts +54 -0
- package/examples/uber-app/models/ride.model.ts +118 -0
- package/examples/uber-app/models/user.model.ts +66 -0
- package/examples/uber-app/models/vehicle.model.ts +63 -0
- package/examples/uber-app/tests/payment.test.tsx +129 -0
- package/examples/uber-app/tests/ride-flow.test.tsx +123 -0
- package/examples/uber-app/workflows/dispute-resolution.workflow.tsx +205 -0
- package/examples/uber-app/workflows/driver-onboarding.workflow.tsx +227 -0
- package/examples/uber-app/workflows/payment-processing.workflow.tsx +223 -0
- package/examples/uber-app/workflows/ride-request.workflow.tsx +194 -0
- package/package.json +77 -0
- package/package.json.backup +86 -0
- package/scripts/decompile.ts +226 -0
- package/scripts/seed-auth.ts +267 -0
- package/scripts/seed-uber.ts +248 -0
- package/scripts/validate-uber.ts +119 -0
- package/seed-blueprint-chat.mjs +444 -0
- package/seed-blueprint-glass-console.mjs +445 -0
- package/seed-compiled.mjs +318 -0
- package/src/RoundTripValidator.ts +400 -0
- package/src/__tests__/atom-rendering-coverage.test.ts +680 -0
- package/src/__tests__/auth-module-compilation.test.ts +247 -0
- package/src/__tests__/auth-template-compilation.test.ts +589 -0
- package/src/__tests__/change-extractor.test.ts +142 -0
- package/src/__tests__/cli-pull.test.ts +73 -0
- package/src/__tests__/cli-test.test.ts +72 -0
- package/src/__tests__/component-extractor.test.ts +331 -0
- package/src/__tests__/context-extractor.test.ts +145 -0
- package/src/__tests__/decompiler.test.ts +718 -0
- package/src/__tests__/define-blueprint.test.ts +133 -0
- package/src/__tests__/definition-validator.test.ts +519 -0
- package/src/__tests__/during-extractor.test.ts +152 -0
- package/src/__tests__/effect-extractor.test.ts +107 -0
- package/src/__tests__/event-emission.test.ts +127 -0
- package/src/__tests__/examples.test.ts +236 -0
- package/src/__tests__/full-blueprint-coverage.test.ts +1221 -0
- package/src/__tests__/golden-suite.test.ts +403 -0
- package/src/__tests__/grammar-island-extractor.test.ts +289 -0
- package/src/__tests__/instance-key.test.ts +82 -0
- package/src/__tests__/ir-migration.test.ts +255 -0
- package/src/__tests__/lock-file.test.ts +117 -0
- package/src/__tests__/model-extractor.test.ts +195 -0
- package/src/__tests__/model-field-acl.test.ts +237 -0
- package/src/__tests__/model-hooks.test.ts +130 -0
- package/src/__tests__/model-ref-resolution.test.ts +268 -0
- package/src/__tests__/model-roundtrip.test.ts +502 -0
- package/src/__tests__/model-runtime.test.ts +112 -0
- package/src/__tests__/model-transitions.test.ts +183 -0
- package/src/__tests__/nrt-action-trace.test.ts +391 -0
- package/src/__tests__/pipeline-hardening.test.ts +413 -0
- package/src/__tests__/project-compiler.test.ts +546 -0
- package/src/__tests__/project-decompiler.test.ts +343 -0
- package/src/__tests__/query-compilation.test.ts +145 -0
- package/src/__tests__/round-trip/PLAN.md +158 -0
- package/src/__tests__/round-trip/README.md +52 -0
- package/src/__tests__/round-trip/RESULTS.md +86 -0
- package/src/__tests__/round-trip/fixtures/data-heavy/main.workflow.tsx +55 -0
- package/src/__tests__/round-trip/fixtures/data-heavy/mm.config.ts +11 -0
- package/src/__tests__/round-trip/fixtures/data-heavy/models/contact.ts +54 -0
- package/src/__tests__/round-trip/fixtures/full-workflow/main.workflow.tsx +79 -0
- package/src/__tests__/round-trip/fixtures/full-workflow/mm.config.ts +12 -0
- package/src/__tests__/round-trip/fixtures/full-workflow/models/order.ts +50 -0
- package/src/__tests__/round-trip/fixtures/simple-crud/main.workflow.tsx +25 -0
- package/src/__tests__/round-trip/fixtures/simple-crud/mm.config.ts +11 -0
- package/src/__tests__/round-trip/fixtures/simple-crud/models/task.ts +32 -0
- package/src/__tests__/round-trip/fixtures/view-heavy/main.workflow.tsx +79 -0
- package/src/__tests__/round-trip/fixtures/view-heavy/mm.config.ts +10 -0
- package/src/__tests__/round-trip/round-trip.test.ts +2598 -0
- package/src/__tests__/round-trip-ir.test.ts +300 -0
- package/src/__tests__/round-trip.test.ts +1212 -0
- package/src/__tests__/route-merging.test.ts +372 -0
- package/src/__tests__/router-composition.test.ts +489 -0
- package/src/__tests__/router-extractor.test.ts +176 -0
- package/src/__tests__/server-action-extractor.test.ts +128 -0
- package/src/__tests__/smart-type-inference.test.ts +365 -0
- package/src/__tests__/source-envelope.test.ts +284 -0
- package/src/__tests__/source-fidelity.test.ts +516 -0
- package/src/__tests__/state-extractor.test.ts +115 -0
- package/src/__tests__/strict-mode.test.ts +227 -0
- package/src/__tests__/transition-effect-extractor.test.ts +119 -0
- package/src/__tests__/transition-extractor.test.ts +68 -0
- package/src/__tests__/ts-to-expression.test.ts +462 -0
- package/src/__tests__/type-generator.test.ts +201 -0
- package/src/__tests__/uber-validation.test.ts +502 -0
- package/src/action-compiler.ts +361 -0
- package/src/babel/emitters/experience-transform.ts +199 -0
- package/src/babel/emitters/ir-to-tsx-emitter.ts +110 -0
- package/src/babel/emitters/pure-form-emitter.ts +1023 -0
- package/src/babel/emitters/runtime-glue-emitter.ts +39 -0
- package/src/babel/extractors/change-extractor.ts +199 -0
- package/src/babel/extractors/component-extractor.ts +907 -0
- package/src/babel/extractors/computed-extractor.ts +262 -0
- package/src/babel/extractors/context-extractor.ts +277 -0
- package/src/babel/extractors/during-extractor.ts +295 -0
- package/src/babel/extractors/effect-extractor.ts +340 -0
- package/src/babel/extractors/event-extractor.ts +235 -0
- package/src/babel/extractors/grammar-island-extractor.ts +302 -0
- package/src/babel/extractors/model-extractor.ts +1018 -0
- package/src/babel/extractors/router-extractor.ts +303 -0
- package/src/babel/extractors/server-action-extractor.ts +173 -0
- package/src/babel/extractors/server-action-hook-extractor.ts +72 -0
- package/src/babel/extractors/server-state-extractor.ts +88 -0
- package/src/babel/extractors/state-extractor.ts +214 -0
- package/src/babel/extractors/transition-effect-extractor.ts +176 -0
- package/src/babel/extractors/transition-extractor.ts +143 -0
- package/src/babel/index.ts +24 -0
- package/src/babel/transpilers/ts-to-expression.ts +674 -0
- package/src/babel/visitor.ts +807 -0
- package/src/cli/auth.ts +255 -0
- package/src/cli/build.ts +288 -0
- package/src/cli/deploy.ts +206 -0
- package/src/cli/index.ts +328 -0
- package/src/cli/init.ts +388 -0
- package/src/cli/installer.ts +261 -0
- package/src/cli/lock-file.ts +94 -0
- package/src/cli/mmrc.ts +22 -0
- package/src/cli/pull.ts +172 -0
- package/src/cli/registry-client.ts +175 -0
- package/src/cli/test.ts +397 -0
- package/src/cli/type-generator.ts +243 -0
- package/src/codemod/__tests__/forward.test.ts +239 -0
- package/src/codemod/__tests__/reverse.test.ts +145 -0
- package/src/codemod/__tests__/round-trip.test.ts +137 -0
- package/src/codemod/annotation.ts +97 -0
- package/src/codemod/classify.ts +197 -0
- package/src/codemod/cli.ts +207 -0
- package/src/codemod/control-flow.ts +409 -0
- package/src/codemod/forward.ts +244 -0
- package/src/codemod/import-manager.ts +171 -0
- package/src/codemod/index.ts +120 -0
- package/src/codemod/reverse.ts +197 -0
- package/src/codemod/rules.ts +174 -0
- package/src/codemod/state-transform.ts +126 -0
- package/src/decompiler/ast-builder.ts +538 -0
- package/src/decompiler/config-generator.ts +151 -0
- package/src/decompiler/index.ts +315 -0
- package/src/decompiler/project-decompiler.ts +1776 -0
- package/src/decompiler/project.ts +862 -0
- package/src/decompiler/split-strategy.ts +140 -0
- package/src/decompiler/state-emitter.ts +1053 -0
- package/src/decompiler/sx-emitter.ts +318 -0
- package/src/decompiler/workspace-hydrator.ts +189 -0
- package/src/dev-server.ts +238 -0
- package/src/envelope/fs-tree.ts +217 -0
- package/src/envelope/source-envelope.ts +264 -0
- package/src/envelope.ts +315 -0
- package/src/incremental-compiler.ts +401 -0
- package/src/index.ts +99 -0
- package/src/model-compiler.ts +277 -0
- package/src/project-compiler.ts +1629 -0
- package/src/route-extractor.ts +333 -0
- package/src/testing/index.ts +32 -0
- package/src/testing/snapshot.ts +252 -0
- package/src/testing/test-utils.ts +226 -0
- package/src/types.ts +68 -0
- package/src/vite/index.ts +288 -0
- package/test-compile.mjs +142 -0
- package/tsconfig.json +25 -0
- package/tsup.config.ts +23 -0
- package/vitest.config.ts +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1099 @@
|
|
|
1
|
+
import { E as ExtractedWorkflow, C as CompilerState, a as CompilerOptions } from './index-revho_gS.js';
|
|
2
|
+
export { R as ReactCompilerError, b as babelPlugin } from './index-revho_gS.js';
|
|
3
|
+
import { NodePath, Visitor } from '@babel/traverse';
|
|
4
|
+
import * as t from '@babel/types';
|
|
5
|
+
import { IRWorkflowDefinition, PureFormWorkflow, IRDataSource, IRExperienceNode as IRExperienceNode$1 } from '@mindmatrix/player-core';
|
|
6
|
+
export { B as BuildOptions, d as BuildResult, a as DevServerInstance, D as DevServerOptions, b as build, c as createDevServer } from './dev-server-Bs_sz2DG.js';
|
|
7
|
+
import { F as FileRole } from './envelope-DD7v0v6E.js';
|
|
8
|
+
export { B as BuildEnvelopeOptions, c as BuildEnvelopeResult, a as EnvelopeFile, E as EnvelopeManifest, i as EnvelopeMetadata, n as FsTree, o as FsTreeEntry, h as SourceBinding, S as SourceEnvelope, b as buildEnvelope, e as computeEnvelopeId, d as createSourceEnvelope, k as detectFileRole, g as diffEnvelopes, m as diffFsTrees, f as envelopesEqual, l as filterByRole, j as generateFsTree } from './envelope-DD7v0v6E.js';
|
|
9
|
+
import 'vite';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* State Extractor — extracts useState calls and converts them to IRFieldDefinition.
|
|
13
|
+
*
|
|
14
|
+
* INPUT:
|
|
15
|
+
* const [count, setCount] = useState(0);
|
|
16
|
+
* const [name, setName] = useState('');
|
|
17
|
+
* const [active, setActive] = useState(false);
|
|
18
|
+
* const [items, setItems] = useState<string[]>([]);
|
|
19
|
+
*
|
|
20
|
+
* OUTPUT:
|
|
21
|
+
* [
|
|
22
|
+
* { name: "count", type: "number", default_value: 0 },
|
|
23
|
+
* { name: "name", type: "text", default_value: "" },
|
|
24
|
+
* { name: "active", type: "boolean", default_value: false },
|
|
25
|
+
* { name: "items", type: "json", default_value: [] }
|
|
26
|
+
* ]
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Main extractor function called from the visitor.
|
|
31
|
+
*/
|
|
32
|
+
declare function extractStates(path: NodePath<t.CallExpression>, state: any): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Effect Extractor — extracts useOnEnter, useOnExit calls and converts callback bodies to IRActionDefinition.
|
|
36
|
+
*
|
|
37
|
+
* INPUT:
|
|
38
|
+
* useOnEnter('active', () => {
|
|
39
|
+
* setCount(1);
|
|
40
|
+
* setMemory('entered', true);
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* useOnExit('active', () => {
|
|
44
|
+
* console.log('left active');
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* OUTPUT for state 'active':
|
|
48
|
+
* {
|
|
49
|
+
* on_enter: [
|
|
50
|
+
* { id: "auto_1", type: "set_field", mode: "auto", config: { field: "count", value: 1 } },
|
|
51
|
+
* { id: "auto_2", type: "set_memory", mode: "auto", config: { key: "entered", value: true } }
|
|
52
|
+
* ],
|
|
53
|
+
* on_exit: [
|
|
54
|
+
* { id: "auto_3", type: "log_event", mode: "auto", config: { message: "left active" } }
|
|
55
|
+
* ]
|
|
56
|
+
* }
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Main extractor function called from the visitor.
|
|
61
|
+
*/
|
|
62
|
+
declare function extractEffects(path: NodePath<t.CallExpression>, state: any): void;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Transition Extractor — extracts useTransition calls to build IRTransitionDefinition.
|
|
66
|
+
*
|
|
67
|
+
* INPUT:
|
|
68
|
+
* const submit = useTransition('submit');
|
|
69
|
+
* const cancel = useTransition('cancel');
|
|
70
|
+
*
|
|
71
|
+
* OUTPUT:
|
|
72
|
+
* [
|
|
73
|
+
* { name: "submit", from: [], to: "", actions: [], conditions: [] },
|
|
74
|
+
* { name: "cancel", from: [], to: "", actions: [] }
|
|
75
|
+
* ]
|
|
76
|
+
*
|
|
77
|
+
* Note: The from/to states are inferred during the emitter phase by analyzing state flow.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Main extractor function called from the visitor.
|
|
82
|
+
*
|
|
83
|
+
* Supports two forms:
|
|
84
|
+
* useTransition('submit')
|
|
85
|
+
* useTransition('submit', { from: ['DRAFT'], to: 'SUBMITTED' })
|
|
86
|
+
*/
|
|
87
|
+
declare function extractTransitions(path: NodePath<t.CallExpression>, state: any): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Event Extractor — extracts useOnEvent calls and converts them to IROnEventSubscription.
|
|
91
|
+
*
|
|
92
|
+
* INPUT:
|
|
93
|
+
* useOnEvent('message.received', (event) => {
|
|
94
|
+
* setField('message_count', getField('message_count') + 1);
|
|
95
|
+
* }, { while: 'active' });
|
|
96
|
+
*
|
|
97
|
+
* OUTPUT (added to state 'active' on_event):
|
|
98
|
+
* {
|
|
99
|
+
* match: "message.received",
|
|
100
|
+
* conditions: [],
|
|
101
|
+
* actions: [
|
|
102
|
+
* { type: "set_field", field: "message_count", expression: "message_count + 1" }
|
|
103
|
+
* ]
|
|
104
|
+
* }
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Main extractor function called from the visitor.
|
|
109
|
+
*/
|
|
110
|
+
declare function extractEvents(path: NodePath<t.CallExpression>, state: any): void;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Component Extractor — extracts JSX return value into IRExperienceNode tree.
|
|
114
|
+
*
|
|
115
|
+
* Handles:
|
|
116
|
+
* - JSX elements with identifier and member expression names
|
|
117
|
+
* - Fragments (anonymous containers)
|
|
118
|
+
* - Text content as Text nodes
|
|
119
|
+
* - Expression children ({count}, {status})
|
|
120
|
+
* - Conditional rendering ({show && <X/>}, {cond ? <A/> : <B/>})
|
|
121
|
+
* - List rendering ({items.map(i => <Item/>)})
|
|
122
|
+
* - Spread attributes
|
|
123
|
+
* - visible_when, data-slot special attributes
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Main extractor function called from the visitor.
|
|
128
|
+
*/
|
|
129
|
+
declare function extractComponents(path: NodePath<t.ReturnStatement>, state: any): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Workflow Emitter — assembles extracted pieces into IR, engine-compatible, and canonical outputs.
|
|
133
|
+
*
|
|
134
|
+
* Three output stages:
|
|
135
|
+
* 1. emitIR() → IRWorkflowDefinition (the IR cache)
|
|
136
|
+
* 2. emitWorkflowDefinition() → engine-compatible JSON (state_type, field_type, action_type)
|
|
137
|
+
* 3. emitCanonical() → PureFormWorkflow (canonical tree per 041 protocol)
|
|
138
|
+
* 4. emitCompiledOutput() → { canonical, ir } (combined output)
|
|
139
|
+
*
|
|
140
|
+
* Data flow:
|
|
141
|
+
* CompilerState → compilerStateToWorkflow() → ExtractedWorkflow → emitIR() → IRWorkflowDefinition
|
|
142
|
+
* → emitWorkflowDefinition() → engine-compatible JSON
|
|
143
|
+
* → emitCanonical() → PureFormWorkflow
|
|
144
|
+
*
|
|
145
|
+
* Critical contract: NOTHING extracted may be silently dropped.
|
|
146
|
+
* Every piece of data extracted by the visitor must appear in the output.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Emits IR from extracted workflow data.
|
|
151
|
+
*
|
|
152
|
+
* This is the lowered IR output — everything extracted ends up here.
|
|
153
|
+
* View tree is normalized and emitted as a top-level `view` field
|
|
154
|
+
* (not inside metadata.experience).
|
|
155
|
+
*/
|
|
156
|
+
declare function emitIR(extracted: ExtractedWorkflow): IRWorkflowDefinition;
|
|
157
|
+
/** @deprecated Use emitIR() instead. Kept for backward compatibility. */
|
|
158
|
+
declare const emitPureForm: typeof emitIR;
|
|
159
|
+
/**
|
|
160
|
+
* Emits canonical tree from extracted workflow data.
|
|
161
|
+
*
|
|
162
|
+
* Produces `{ slug, category, parts, metadata }` per 041 protocol.
|
|
163
|
+
* This is the TRUTH. The IR is a derivable cache.
|
|
164
|
+
*/
|
|
165
|
+
declare function emitCanonical(extracted: ExtractedWorkflow, sourceFilename?: string): PureFormWorkflow;
|
|
166
|
+
/**
|
|
167
|
+
* Emits the combined compiled output: canonical tree + lowered IR.
|
|
168
|
+
*/
|
|
169
|
+
declare function emitCompiledOutput(extracted: ExtractedWorkflow, sourceFilename?: string): {
|
|
170
|
+
canonical: PureFormWorkflow;
|
|
171
|
+
ir: IRWorkflowDefinition;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Converts compiler state to ExtractedWorkflow.
|
|
175
|
+
*
|
|
176
|
+
* Critical: must transfer ALL extracted data — nothing may be lost.
|
|
177
|
+
*/
|
|
178
|
+
declare function compilerStateToWorkflow(state: CompilerState, metadata: {
|
|
179
|
+
slug?: string;
|
|
180
|
+
name?: string;
|
|
181
|
+
version?: string;
|
|
182
|
+
description?: string;
|
|
183
|
+
category?: string;
|
|
184
|
+
[key: string]: unknown;
|
|
185
|
+
}): ExtractedWorkflow;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Experience Transform — converts IRExperienceNode to frontend ExperienceNode format.
|
|
189
|
+
*
|
|
190
|
+
* The React compiler emits player-core IR types (IRExperienceNode, IRDataSource).
|
|
191
|
+
* The frontend runtime expects the richer types from experience-tree-types.ts.
|
|
192
|
+
* This transform bridges the gap by:
|
|
193
|
+
*
|
|
194
|
+
* 1. Hoisting legacy config fields (slot, className, displayName) to top-level
|
|
195
|
+
* 2. Mapping IRDataSource → frontend DataSource shape (adding default fields)
|
|
196
|
+
* 3. Recursively transforming the entire node tree
|
|
197
|
+
*
|
|
198
|
+
* This is a pure function with no side effects — safe for tests and caching.
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Extended IR node type — the compiler emits additional fields beyond the
|
|
203
|
+
* base player-core IRExperienceNode. These are consumed by the frontend CTR.
|
|
204
|
+
* We use our own interface to avoid fighting the base type's narrowness.
|
|
205
|
+
*/
|
|
206
|
+
interface IRExperienceNode {
|
|
207
|
+
id: string;
|
|
208
|
+
component?: string;
|
|
209
|
+
config?: Record<string, unknown>;
|
|
210
|
+
bindings?: Record<string, string>;
|
|
211
|
+
children?: IRExperienceNode[];
|
|
212
|
+
dataSources?: IRDataSource[];
|
|
213
|
+
dataScope?: string;
|
|
214
|
+
layout?: string;
|
|
215
|
+
visible_when?: string;
|
|
216
|
+
displayName?: string;
|
|
217
|
+
experienceId?: string;
|
|
218
|
+
slot?: string;
|
|
219
|
+
className?: string;
|
|
220
|
+
style?: Record<string, unknown>;
|
|
221
|
+
overrides?: Record<string, unknown>;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Frontend-compatible ExperienceNode shape.
|
|
225
|
+
* Matches packages/frontend/src/experiences/experience-tree-types.ts.
|
|
226
|
+
* Declared locally to avoid a cross-package import dependency.
|
|
227
|
+
*/
|
|
228
|
+
interface FrontendExperienceNode {
|
|
229
|
+
id: string;
|
|
230
|
+
displayName?: string;
|
|
231
|
+
experienceId?: string;
|
|
232
|
+
component?: string;
|
|
233
|
+
slot?: string;
|
|
234
|
+
dataSources?: FrontendDataSource[];
|
|
235
|
+
dataScope?: string;
|
|
236
|
+
children?: FrontendExperienceNode[];
|
|
237
|
+
config?: Record<string, unknown>;
|
|
238
|
+
layout?: string;
|
|
239
|
+
className?: string;
|
|
240
|
+
style?: Record<string, unknown>;
|
|
241
|
+
overrides?: Record<string, unknown>;
|
|
242
|
+
bindings?: Record<string, string>;
|
|
243
|
+
visible_when?: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Frontend-compatible DataSource — superset of IR DataSource with default fields.
|
|
247
|
+
*/
|
|
248
|
+
interface FrontendDataSource {
|
|
249
|
+
type: 'workflow' | 'api' | 'ref' | 'static';
|
|
250
|
+
name: string;
|
|
251
|
+
[key: string]: unknown;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Transforms an IRExperienceNode tree into frontend-compatible ExperienceNode format.
|
|
255
|
+
*
|
|
256
|
+
* Handles:
|
|
257
|
+
* - Hoisting config.slot → top-level slot (backward compat for old IR)
|
|
258
|
+
* - Hoisting config.className → top-level className
|
|
259
|
+
* - Hoisting config.displayName → top-level displayName
|
|
260
|
+
* - Mapping IRDataSource[] → FrontendDataSource[] with defaults
|
|
261
|
+
* - Recursive child transformation
|
|
262
|
+
*/
|
|
263
|
+
declare function transformToFrontend(node: IRExperienceNode): FrontendExperienceNode;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* project.ts — Multi-file project decompiler.
|
|
267
|
+
*
|
|
268
|
+
* Takes a full IRWorkflowDefinition and produces a project file tree:
|
|
269
|
+
* - main.workflow.tsx (root layout + routing + state machine hooks)
|
|
270
|
+
* - pages/*.tsx (separate page components per route/view)
|
|
271
|
+
* - models/*.ts (TypeScript interfaces from field definitions)
|
|
272
|
+
* - actions/*.server.ts (server action stubs from transition actions)
|
|
273
|
+
* - mm.config.ts (blueprint configuration: defineBlueprint)
|
|
274
|
+
*
|
|
275
|
+
* This is the multi-file counterpart to the single-file decompile() function.
|
|
276
|
+
* It splits complex definitions into cohesive, focused files matching the
|
|
277
|
+
* envelope fs-tree file role conventions (view-entry, page, model, server-action, config).
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/** A single file in the decompiled project. */
|
|
281
|
+
interface ProjectFile {
|
|
282
|
+
/** Relative path from project root (e.g. "main.workflow.tsx"). */
|
|
283
|
+
path: string;
|
|
284
|
+
/** File role matching the envelope fs-tree convention. */
|
|
285
|
+
role: FileRole;
|
|
286
|
+
/** Generated source code. */
|
|
287
|
+
content: string;
|
|
288
|
+
}
|
|
289
|
+
/** Result of decompiling a definition into a multi-file project. */
|
|
290
|
+
interface DecompileProjectResult {
|
|
291
|
+
/** All generated files. */
|
|
292
|
+
files: ProjectFile[];
|
|
293
|
+
/** The main entry file path. */
|
|
294
|
+
entryFile: string;
|
|
295
|
+
/** The slug used for naming. */
|
|
296
|
+
slug: string;
|
|
297
|
+
}
|
|
298
|
+
/** Options for project decompilation. */
|
|
299
|
+
interface DecompileProjectOptions extends DecompileOptions {
|
|
300
|
+
/** Skip generating mm.config.ts. Default: false. */
|
|
301
|
+
skipConfig?: boolean;
|
|
302
|
+
/** Skip generating model files. Default: false. */
|
|
303
|
+
skipModels?: boolean;
|
|
304
|
+
/** Skip generating server action stubs. Default: false. */
|
|
305
|
+
skipActions?: boolean;
|
|
306
|
+
/** Skip splitting pages into separate files. Default: false. */
|
|
307
|
+
skipPages?: boolean;
|
|
308
|
+
/** Skip decompiling child definitions into separate files. Default: false. */
|
|
309
|
+
skipChildren?: boolean;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Decompiles an IR definition into a multi-file project structure.
|
|
313
|
+
*
|
|
314
|
+
* Produces files matching the envelope fs-tree file role conventions:
|
|
315
|
+
* - main.workflow.tsx → view-entry (root layout + state machine)
|
|
316
|
+
* - pages/*.tsx → page (per-route components)
|
|
317
|
+
* - models/<slug>.ts → model (TypeScript interfaces)
|
|
318
|
+
* - actions/<slug>.server.ts → server-action (backend handlers)
|
|
319
|
+
* - mm.config.ts → config (defineBlueprint)
|
|
320
|
+
*
|
|
321
|
+
* For simple definitions (no states/transitions/models), falls back
|
|
322
|
+
* to single-file output in main.workflow.tsx.
|
|
323
|
+
*/
|
|
324
|
+
declare function decompileProject(definition: DecompilerInput, options?: DecompileProjectOptions): DecompileProjectResult;
|
|
325
|
+
/**
|
|
326
|
+
* Returns true if a definition is complex enough to warrant multi-file output.
|
|
327
|
+
*
|
|
328
|
+
* Criteria: has states + transitions + either fields or experience tree.
|
|
329
|
+
*/
|
|
330
|
+
declare function shouldDecompileAsProject(def: IRWorkflowDefinition): boolean;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* IR-to-TSX Decompiler — converts IRWorkflowDefinition back to .workflow.tsx source.
|
|
334
|
+
*
|
|
335
|
+
* This is the inverse of the Babel compiler (extractors + pure-form-emitter).
|
|
336
|
+
* Given an IR tree (from the database, visual editor, or AI agent), it produces
|
|
337
|
+
* valid .workflow.tsx source code that compiles back to an equivalent IR.
|
|
338
|
+
*
|
|
339
|
+
* Architecture (per Appendix H):
|
|
340
|
+
* IRWorkflowDefinition
|
|
341
|
+
* → Import collection
|
|
342
|
+
* → Field declarations (useState)
|
|
343
|
+
* → State effects (useOnEnter/useOnExit)
|
|
344
|
+
* → Transition declarations (useTransition)
|
|
345
|
+
* → JSX return tree (experience → atoms)
|
|
346
|
+
* → Babel AST (t.program)
|
|
347
|
+
* → @babel/generator
|
|
348
|
+
* → .workflow.tsx source string
|
|
349
|
+
*
|
|
350
|
+
* Covers: fields, states (enter/exit/during), transitions (with conditions),
|
|
351
|
+
* experience tree (JSX + sx props + bindings), and all known action types.
|
|
352
|
+
*/
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Decompiler input — an IR definition plus an optional experience tree.
|
|
356
|
+
*
|
|
357
|
+
* The experience tree may come from:
|
|
358
|
+
* - ExtractedWorkflow.experience (compiler internal)
|
|
359
|
+
* - Stored definition metadata
|
|
360
|
+
* - Visual editor BlueprintEditorContext.tree
|
|
361
|
+
*/
|
|
362
|
+
interface DecompilerInput extends IRWorkflowDefinition {
|
|
363
|
+
/** The experience tree to decompile into the JSX return. */
|
|
364
|
+
experience?: IRExperienceNode$1;
|
|
365
|
+
/** Child workflow definitions for multi-workflow blueprints (UBER-SCALE projects). */
|
|
366
|
+
childDefinitions?: IRWorkflowDefinition[];
|
|
367
|
+
}
|
|
368
|
+
interface DecompileOptions {
|
|
369
|
+
/** Override the component function name. Defaults to displayName or pascalCase(slug). */
|
|
370
|
+
componentName?: string;
|
|
371
|
+
/** Include JSDoc workflow annotation. Default: true. */
|
|
372
|
+
includeAnnotation?: boolean;
|
|
373
|
+
/** Emit displayName comments for named nodes. Default: false. */
|
|
374
|
+
emitDisplayNames?: boolean;
|
|
375
|
+
}
|
|
376
|
+
interface DecompileResult {
|
|
377
|
+
/** The generated .workflow.tsx source code. */
|
|
378
|
+
code: string;
|
|
379
|
+
/** List of package specifiers that were imported. */
|
|
380
|
+
imports: string[];
|
|
381
|
+
/** The component function name used. */
|
|
382
|
+
componentName: string;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Decompiles an IR definition into a .workflow.tsx source string.
|
|
386
|
+
*
|
|
387
|
+
* @param definition - The IR workflow definition to decompile.
|
|
388
|
+
* @param options - Optional configuration for the output.
|
|
389
|
+
* @returns The generated source code, imports list, and component name.
|
|
390
|
+
*/
|
|
391
|
+
declare function decompile(definition: DecompilerInput, options?: DecompileOptions): DecompileResult;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* IR-to-TSX Emitter — bridge module that re-exports the decompiler API
|
|
395
|
+
* from the canonical location expected by the investigation doc (Appendix H).
|
|
396
|
+
*
|
|
397
|
+
* The full decompiler implementation lives in packages/react-compiler/src/decompiler/
|
|
398
|
+
* (index.ts, ast-builder.ts, state-emitter.ts, sx-emitter.ts, project.ts).
|
|
399
|
+
*
|
|
400
|
+
* This module provides:
|
|
401
|
+
* - decompileToTSX() — the primary entry point per Appendix H §H.3
|
|
402
|
+
* - All supporting types and sub-emitters
|
|
403
|
+
*
|
|
404
|
+
* Usage:
|
|
405
|
+
* import { decompileToTSX } from './ir-to-tsx-emitter';
|
|
406
|
+
* const result = decompileToTSX(irDefinition, { includeAnnotation: true });
|
|
407
|
+
* console.log(result.code); // valid .workflow.tsx source
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Decompiles an IRWorkflowDefinition to valid .workflow.tsx source code.
|
|
412
|
+
*
|
|
413
|
+
* This is the primary entry point specified in Appendix H §H.3.
|
|
414
|
+
* Uses @babel/types to construct a Babel AST, then @babel/generator to emit code.
|
|
415
|
+
*
|
|
416
|
+
* Emits:
|
|
417
|
+
* - useState for fields
|
|
418
|
+
* - useOnEnter/Exit for state effects
|
|
419
|
+
* - useTransition declarations
|
|
420
|
+
* - useWhileIn for during-actions
|
|
421
|
+
* - useOnEvent subscriptions
|
|
422
|
+
* - useOnChange watchers
|
|
423
|
+
* - useOnTransition effects
|
|
424
|
+
* - useRole declarations
|
|
425
|
+
* - useQuery/useMutation data sources
|
|
426
|
+
* - JSX return tree from experience nodes
|
|
427
|
+
* - @workflow JSDoc header
|
|
428
|
+
* - Proper imports from @mindmatrix/react
|
|
429
|
+
*
|
|
430
|
+
* @param definition - The IR workflow definition (with optional experience tree).
|
|
431
|
+
* @param options - Decompile options (componentName, includeAnnotation, etc.).
|
|
432
|
+
* @returns { code, imports, componentName }
|
|
433
|
+
*/
|
|
434
|
+
declare function decompileToTSX(definition: IRWorkflowDefinition & {
|
|
435
|
+
experience?: IRExperienceNode$1;
|
|
436
|
+
}, options?: DecompileOptions): DecompileResult;
|
|
437
|
+
/**
|
|
438
|
+
* Convenience: checks if a definition needs the experience tree attached.
|
|
439
|
+
*
|
|
440
|
+
* The decompiler expects the experience tree either:
|
|
441
|
+
* 1. As definition.experience (direct on the input)
|
|
442
|
+
* 2. From (definition as any).views?.default (stored IR format)
|
|
443
|
+
* 3. From definition.metadata?.experience (legacy format)
|
|
444
|
+
*
|
|
445
|
+
* This helper normalizes the input.
|
|
446
|
+
*/
|
|
447
|
+
declare function normalizeDecompilerInput(definition: IRWorkflowDefinition): DecompilerInput;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Computed Extractor — extracts useComputed() calls into IRFieldDefinition entries.
|
|
451
|
+
*
|
|
452
|
+
* INPUT:
|
|
453
|
+
* const total = useComputed('line_total', () => quantity * unitPrice, {
|
|
454
|
+
* mode: 'transaction-maintained',
|
|
455
|
+
* deps: ['quantity', 'unit_price'],
|
|
456
|
+
* });
|
|
457
|
+
*
|
|
458
|
+
* OUTPUT (added to compilerState.fields[]):
|
|
459
|
+
* {
|
|
460
|
+
* name: 'line_total',
|
|
461
|
+
* type: 'number', // inferred from return type or default
|
|
462
|
+
* computed: 'quantity * unitPrice',
|
|
463
|
+
* computed_deps: ['quantity', 'unit_price'],
|
|
464
|
+
* computed_mode: 'transaction-maintained',
|
|
465
|
+
* }
|
|
466
|
+
*
|
|
467
|
+
* Supports all three modes:
|
|
468
|
+
* - 'read-time' (RT): computed on every read, no storage
|
|
469
|
+
* - 'transaction-maintained' (TM): recomputed synchronously on dependency change
|
|
470
|
+
* - 'async-materialized' (AM): recomputed asynchronously via background job
|
|
471
|
+
*/
|
|
472
|
+
|
|
473
|
+
interface ComputedFieldExtraction {
|
|
474
|
+
/** The canonical field name (snake_case). */
|
|
475
|
+
name: string;
|
|
476
|
+
/** The variable name in the component (camelCase). */
|
|
477
|
+
varName: string;
|
|
478
|
+
/** The raw expression body as a string. */
|
|
479
|
+
expression: string;
|
|
480
|
+
/** Declared dependencies (from options.deps). */
|
|
481
|
+
deps: string[];
|
|
482
|
+
/** Execution mode. Default: 'read-time'. */
|
|
483
|
+
mode: 'read-time' | 'transaction-maintained' | 'async-materialized';
|
|
484
|
+
/** Inferred field type. */
|
|
485
|
+
type: string;
|
|
486
|
+
/** Staleness config for async-materialized fields. */
|
|
487
|
+
staleness?: string;
|
|
488
|
+
/** Whether RLS staleness is explicitly acceptable. */
|
|
489
|
+
rlsStalenessOk?: boolean;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Extracts useComputed() calls from the AST and adds computed field
|
|
493
|
+
* definitions to the compiler state.
|
|
494
|
+
*
|
|
495
|
+
* Called from the visitor for each CallExpression node.
|
|
496
|
+
*/
|
|
497
|
+
declare function extractComputed(path: NodePath<t.CallExpression>, state: any): void;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Babel Visitor — main AST traversal logic for extracting workflow definitions.
|
|
501
|
+
*
|
|
502
|
+
* Handles all @mindmatrix/react hooks:
|
|
503
|
+
* - useState → fields
|
|
504
|
+
* - useOnEnter / useOnExit → state enter/exit actions
|
|
505
|
+
* - useTransition → transitions
|
|
506
|
+
* - useOnEvent → event subscriptions
|
|
507
|
+
* - useWhileIn → during actions (interval while in state)
|
|
508
|
+
* - useOnChange → field watchers
|
|
509
|
+
* - useOnTransition → transition effects
|
|
510
|
+
*
|
|
511
|
+
* Supports strict/infer mode enforcement.
|
|
512
|
+
*/
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Creates the Babel visitor for the plugin.
|
|
516
|
+
*/
|
|
517
|
+
declare function createVisitor(options?: CompilerOptions): Visitor;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* RoundTripValidator — validates that decompile → recompile produces equivalent IR.
|
|
521
|
+
*
|
|
522
|
+
* Given an IR definition:
|
|
523
|
+
* 1. Decompiles it to .workflow.tsx source code
|
|
524
|
+
* 2. Recompiles that source via the Babel compiler
|
|
525
|
+
* 3. Structurally compares the original and round-tripped IR
|
|
526
|
+
*
|
|
527
|
+
* This validates that the decompiler produces code the compiler can understand,
|
|
528
|
+
* and that no information is silently dropped during the round trip.
|
|
529
|
+
*/
|
|
530
|
+
|
|
531
|
+
interface RoundTripResult {
|
|
532
|
+
/** Whether the round trip preserves all structural data. */
|
|
533
|
+
success: boolean;
|
|
534
|
+
/** The generated TSX source code (intermediate). */
|
|
535
|
+
generatedSource: string;
|
|
536
|
+
/** The original IR. */
|
|
537
|
+
originalIR: IRWorkflowDefinition;
|
|
538
|
+
/** The round-tripped IR (compiled from generated source). */
|
|
539
|
+
roundTrippedIR: IRWorkflowDefinition | null;
|
|
540
|
+
/** List of structural differences found. */
|
|
541
|
+
diffs: RoundTripDiff[];
|
|
542
|
+
}
|
|
543
|
+
interface RoundTripDiff {
|
|
544
|
+
path: string;
|
|
545
|
+
expected: unknown;
|
|
546
|
+
actual: unknown;
|
|
547
|
+
severity: 'error' | 'warning';
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Validates the decompile → compile round trip for a given IR definition.
|
|
551
|
+
*/
|
|
552
|
+
declare function validateRoundTrip(definition: DecompilerInput): RoundTripResult;
|
|
553
|
+
/**
|
|
554
|
+
* Compiles a .workflow.tsx source file and returns the IR.
|
|
555
|
+
* Useful for testing the forward direction independently.
|
|
556
|
+
*/
|
|
557
|
+
declare function compileSource(source: string, filename?: string): IRWorkflowDefinition | null;
|
|
558
|
+
/**
|
|
559
|
+
* Full round-trip from source: compile → decompile → recompile → diff.
|
|
560
|
+
*/
|
|
561
|
+
declare function validateSourceRoundTrip(source: string, filename?: string): RoundTripResult | null;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* CLI Deploy Command — uploads compiled workflow definitions to the backend.
|
|
565
|
+
*
|
|
566
|
+
* Deployment rules:
|
|
567
|
+
* 1. If definition is new → create it
|
|
568
|
+
* 2. If definition exists and has no instances → update in place
|
|
569
|
+
* 3. If definition exists and has instances → create NEW version (immutability)
|
|
570
|
+
*
|
|
571
|
+
* The deploy command checks existing definitions via the API and
|
|
572
|
+
* applies the correct strategy automatically.
|
|
573
|
+
*/
|
|
574
|
+
interface DeployOptions {
|
|
575
|
+
apiUrl: string;
|
|
576
|
+
token: string;
|
|
577
|
+
dir?: string;
|
|
578
|
+
/** Force update even if instances exist (bypasses immutability). */
|
|
579
|
+
force?: boolean;
|
|
580
|
+
/** Dry run — show what would happen without making changes. */
|
|
581
|
+
dryRun?: boolean;
|
|
582
|
+
/** Write deploy report to this file. */
|
|
583
|
+
reportFile?: string;
|
|
584
|
+
}
|
|
585
|
+
interface DeployResult {
|
|
586
|
+
created: string[];
|
|
587
|
+
updated: string[];
|
|
588
|
+
versioned: string[];
|
|
589
|
+
skipped: string[];
|
|
590
|
+
failed: {
|
|
591
|
+
slug: string;
|
|
592
|
+
error: string;
|
|
593
|
+
}[];
|
|
594
|
+
}
|
|
595
|
+
declare function deploy(options: DeployOptions): Promise<DeployResult>;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Model Compiler — standalone module for compiling model files into IR.
|
|
599
|
+
*
|
|
600
|
+
* Extracts TypeScript interfaces from models/*.ts files and produces
|
|
601
|
+
* category='data' IRWorkflowDefinition objects. Handles:
|
|
602
|
+
* - Interface properties → IRFieldDefinition[]
|
|
603
|
+
* - Exported `transitions` arrays/objects → IRTransitionDefinition[]
|
|
604
|
+
* - Exported `fieldOptions` → field enrichment (validation, ACL, computed)
|
|
605
|
+
* - Exported `states` → explicit state declarations
|
|
606
|
+
* - JSDoc @workflow annotations for slug, version, category
|
|
607
|
+
*
|
|
608
|
+
* This module wraps the low-level Babel model-extractor with a clean
|
|
609
|
+
* file-level API for the ProjectCompiler to consume.
|
|
610
|
+
*/
|
|
611
|
+
|
|
612
|
+
interface ModelCompilationResult {
|
|
613
|
+
/** The compiled IR with category='data'. */
|
|
614
|
+
ir: IRWorkflowDefinition;
|
|
615
|
+
/** Interface name extracted from the model file. */
|
|
616
|
+
interfaceName: string;
|
|
617
|
+
/** Field names extracted from the interface. */
|
|
618
|
+
fieldNames: string[];
|
|
619
|
+
/** Transition names extracted from the model. */
|
|
620
|
+
transitionNames: string[];
|
|
621
|
+
/** State names (derived from transitions + explicit declarations). */
|
|
622
|
+
stateNames: string[];
|
|
623
|
+
/** Whether fieldOptions were present and applied. */
|
|
624
|
+
hasFieldOptions: boolean;
|
|
625
|
+
/** Raw field options map (for cross-file enrichment). */
|
|
626
|
+
fieldOptions: Record<string, Record<string, unknown>>;
|
|
627
|
+
}
|
|
628
|
+
interface ModelCompilerOptions {
|
|
629
|
+
/** Compilation mode. Default: 'infer'. */
|
|
630
|
+
mode?: 'strict' | 'infer';
|
|
631
|
+
/** Override the slug (otherwise derived from interface name or @workflow). */
|
|
632
|
+
slugOverride?: string;
|
|
633
|
+
/** Override the category (defaults to 'data'). */
|
|
634
|
+
categoryOverride?: string;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Compiles a single model file (models/*.ts) into an IRWorkflowDefinition
|
|
638
|
+
* with category='data'.
|
|
639
|
+
*/
|
|
640
|
+
declare function compileModel(filename: string, source: string, options?: ModelCompilerOptions): ModelCompilationResult;
|
|
641
|
+
/**
|
|
642
|
+
* Compiles multiple model files and returns all results keyed by filename.
|
|
643
|
+
*/
|
|
644
|
+
declare function compileModels(files: Record<string, string>, options?: ModelCompilerOptions): Map<string, ModelCompilationResult>;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Route Extractor — parses app/ directory structure into a routing table.
|
|
648
|
+
*
|
|
649
|
+
* Supports Next.js-style file-based routing conventions:
|
|
650
|
+
* - app/page.tsx → route '/'
|
|
651
|
+
* - app/rider/home.tsx → route '/rider/home'
|
|
652
|
+
* - app/[id]/page.tsx → route '/:id'
|
|
653
|
+
* - app/layout.tsx → wrapping layout boundary
|
|
654
|
+
* - app/admin/layout.tsx → nested layout boundary
|
|
655
|
+
*
|
|
656
|
+
* Generates a router configuration that maps to IR states and transitions.
|
|
657
|
+
*/
|
|
658
|
+
|
|
659
|
+
interface RouteEntry {
|
|
660
|
+
/** URL path pattern (e.g., '/rider/home', '/chat/:channelId'). */
|
|
661
|
+
path: string;
|
|
662
|
+
/** IR state name (e.g., 'RIDER_HOME', 'CHAT_CHANNELID'). */
|
|
663
|
+
stateName: string;
|
|
664
|
+
/** Source file relative path. */
|
|
665
|
+
sourceFile: string;
|
|
666
|
+
/** Dynamic route parameters. */
|
|
667
|
+
params: string[];
|
|
668
|
+
/** Nearest layout boundary file. */
|
|
669
|
+
layoutBoundary?: string;
|
|
670
|
+
/** Route segment depth (0 = root). */
|
|
671
|
+
depth: number;
|
|
672
|
+
}
|
|
673
|
+
interface LayoutEntry {
|
|
674
|
+
/** Relative path to layout file. */
|
|
675
|
+
sourceFile: string;
|
|
676
|
+
/** Directory this layout covers. */
|
|
677
|
+
directory: string;
|
|
678
|
+
/** Depth in the layout hierarchy. */
|
|
679
|
+
depth: number;
|
|
680
|
+
}
|
|
681
|
+
interface RouteExtractionResult {
|
|
682
|
+
/** All extracted routes. */
|
|
683
|
+
routes: RouteEntry[];
|
|
684
|
+
/** All discovered layout boundaries. */
|
|
685
|
+
layouts: LayoutEntry[];
|
|
686
|
+
/** Generated router workflow IR. */
|
|
687
|
+
routerIR: IRWorkflowDefinition;
|
|
688
|
+
/** Route parameters discovered (for field generation). */
|
|
689
|
+
allParams: string[];
|
|
690
|
+
}
|
|
691
|
+
interface RouteExtractorOptions {
|
|
692
|
+
/** Blueprint slug prefix for the router. */
|
|
693
|
+
slugPrefix?: string;
|
|
694
|
+
/** Root directory name (default: 'app'). */
|
|
695
|
+
rootDir?: string;
|
|
696
|
+
/** Page file naming convention (default: 'page.tsx'). */
|
|
697
|
+
pageFileName?: string;
|
|
698
|
+
/** Layout file naming convention (default: 'layout.tsx'). */
|
|
699
|
+
layoutFileName?: string;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Extracts routes from a set of files in an app/ directory structure.
|
|
703
|
+
*
|
|
704
|
+
* @param files - Record of filename → source code (only app/ files needed)
|
|
705
|
+
* @param options - Extraction options
|
|
706
|
+
* @returns RouteExtractionResult with routes, layouts, and router IR
|
|
707
|
+
*/
|
|
708
|
+
declare function extractRoutes(files: Record<string, string>, options?: RouteExtractorOptions): RouteExtractionResult;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Action Compiler — extracts server action signatures from *.server.ts files.
|
|
712
|
+
*
|
|
713
|
+
* Server action files define backend-side handlers that execute during
|
|
714
|
+
* workflow transitions. This compiler:
|
|
715
|
+
* - Extracts exported function signatures (name, params, async, JSDoc)
|
|
716
|
+
* - Registers actions on the parent blueprint metadata
|
|
717
|
+
* - Maps each action to a Rust execution endpoint
|
|
718
|
+
* - Resolves action references from model hooks and transitions
|
|
719
|
+
*
|
|
720
|
+
* INPUT (actions/pricing.server.ts):
|
|
721
|
+
* export async function calculateEstimatedFare(ctx: TransitionContext): Promise<ActionResult> { ... }
|
|
722
|
+
* export async function calculateActualFare(ctx: TransitionContext): Promise<ActionResult> { ... }
|
|
723
|
+
*
|
|
724
|
+
* OUTPUT:
|
|
725
|
+
* ServerActionRegistration[] with endpoint mappings and parameter metadata
|
|
726
|
+
*/
|
|
727
|
+
interface ServerActionRegistration {
|
|
728
|
+
/** Function name (e.g., 'calculateEstimatedFare'). */
|
|
729
|
+
name: string;
|
|
730
|
+
/** Source file path. */
|
|
731
|
+
sourceFile: string;
|
|
732
|
+
/** Whether the function is async. */
|
|
733
|
+
async: boolean;
|
|
734
|
+
/** Parameter names. */
|
|
735
|
+
params: string[];
|
|
736
|
+
/** TypeScript type of the context parameter. */
|
|
737
|
+
contextType?: string;
|
|
738
|
+
/** JSDoc description. */
|
|
739
|
+
description?: string;
|
|
740
|
+
/** Full function source text (for round-trip preservation). */
|
|
741
|
+
body?: string;
|
|
742
|
+
/** TypeScript return type (e.g., 'Promise<ActionResult>'). */
|
|
743
|
+
returnType?: string;
|
|
744
|
+
/** Generated Rust execution endpoint. */
|
|
745
|
+
endpoint: string;
|
|
746
|
+
/** Action group (derived from filename without .server.ts). */
|
|
747
|
+
group: string;
|
|
748
|
+
/** Fully qualified action ID for blueprint registration. */
|
|
749
|
+
actionId: string;
|
|
750
|
+
}
|
|
751
|
+
interface ActionCompilationResult {
|
|
752
|
+
/** All extracted server actions. */
|
|
753
|
+
actions: ServerActionRegistration[];
|
|
754
|
+
/** Actions grouped by source file. */
|
|
755
|
+
byFile: Map<string, ServerActionRegistration[]>;
|
|
756
|
+
/** Actions grouped by action group. */
|
|
757
|
+
byGroup: Map<string, ServerActionRegistration[]>;
|
|
758
|
+
/** Compilation errors. */
|
|
759
|
+
errors: Array<{
|
|
760
|
+
file: string;
|
|
761
|
+
message: string;
|
|
762
|
+
}>;
|
|
763
|
+
}
|
|
764
|
+
interface ActionCompilerOptions {
|
|
765
|
+
/** Compilation mode. Default: 'infer'. */
|
|
766
|
+
mode?: 'strict' | 'infer';
|
|
767
|
+
/** Blueprint slug (used for endpoint generation). */
|
|
768
|
+
blueprintSlug?: string;
|
|
769
|
+
/** API base path for endpoint generation. Default: '/api/v1/actions'. */
|
|
770
|
+
apiBasePath?: string;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Compiles all server action files and extracts their function signatures.
|
|
774
|
+
*
|
|
775
|
+
* @param files - Record of filename → source (only *.server.ts files)
|
|
776
|
+
* @param options - Compilation options
|
|
777
|
+
* @returns ActionCompilationResult with all registered actions
|
|
778
|
+
*/
|
|
779
|
+
declare function compileActions(files: Record<string, string>, options?: ActionCompilerOptions): ActionCompilationResult;
|
|
780
|
+
/**
|
|
781
|
+
* Resolves action references found in model hooks/transitions to registered actions.
|
|
782
|
+
* Returns a map of action name → ServerActionRegistration.
|
|
783
|
+
*/
|
|
784
|
+
declare function resolveActionReferences(actionNames: string[], registrations: ServerActionRegistration[]): Map<string, ServerActionRegistration | null>;
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Incremental Compiler — content-hash based incremental compilation.
|
|
788
|
+
*
|
|
789
|
+
* Maintains a cache of per-file compilation results (IR + errors) and
|
|
790
|
+
* only recompiles files whose content hash has changed. Merges changed
|
|
791
|
+
* IR into the cached full project IR.
|
|
792
|
+
*
|
|
793
|
+
* Performance target: <200ms for a single-file change in a 30-file project.
|
|
794
|
+
*
|
|
795
|
+
* Architecture:
|
|
796
|
+
* 1. Hash each file's content with djb2 (fast, no crypto overhead)
|
|
797
|
+
* 2. Compare against cached hashes to find dirty files
|
|
798
|
+
* 3. Recompile only dirty files
|
|
799
|
+
* 4. Merge fresh IR with cached IR for unchanged files
|
|
800
|
+
* 5. Rebuild composed result
|
|
801
|
+
*
|
|
802
|
+
* Also tracks dependency edges so that when a model file changes,
|
|
803
|
+
* workflow files that import from it are marked dirty too.
|
|
804
|
+
*/
|
|
805
|
+
interface FileHash {
|
|
806
|
+
/** djb2 hash of the file content. */
|
|
807
|
+
hash: string;
|
|
808
|
+
/** Timestamp of last compilation. */
|
|
809
|
+
compiledAt: number;
|
|
810
|
+
/** File size in characters. */
|
|
811
|
+
size: number;
|
|
812
|
+
}
|
|
813
|
+
interface IncrementalStats {
|
|
814
|
+
/** Total files in cache. */
|
|
815
|
+
totalCached: number;
|
|
816
|
+
/** Files recompiled in last compilation. */
|
|
817
|
+
lastRecompiled: number;
|
|
818
|
+
/** Files served from cache in last compilation. */
|
|
819
|
+
lastCacheHits: number;
|
|
820
|
+
/** Total compilation time in ms for last compile. */
|
|
821
|
+
lastCompileMs: number;
|
|
822
|
+
/** Average per-file compilation time in ms. */
|
|
823
|
+
avgPerFileMs: number;
|
|
824
|
+
/** Cache hit rate (0-1). */
|
|
825
|
+
cacheHitRate: number;
|
|
826
|
+
}
|
|
827
|
+
interface DependencyEdge {
|
|
828
|
+
/** The file that imports. */
|
|
829
|
+
from: string;
|
|
830
|
+
/** The file being imported. */
|
|
831
|
+
to: string;
|
|
832
|
+
}
|
|
833
|
+
interface DirtyFileSet {
|
|
834
|
+
/** Files whose content hash changed. */
|
|
835
|
+
contentChanged: string[];
|
|
836
|
+
/** Files dirty due to dependency on a changed file. */
|
|
837
|
+
dependencyDirty: string[];
|
|
838
|
+
/** Files removed since last compilation. */
|
|
839
|
+
removed: string[];
|
|
840
|
+
/** Files added since last compilation. */
|
|
841
|
+
added: string[];
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Fast content hash using djb2 algorithm.
|
|
845
|
+
* Returns a short base-36 string suitable for cache invalidation.
|
|
846
|
+
*/
|
|
847
|
+
declare function hashContent(content: string): string;
|
|
848
|
+
/**
|
|
849
|
+
* Extracts import paths from a source file using regex.
|
|
850
|
+
* Returns relative import targets (e.g., ['../models/user', './components/Map']).
|
|
851
|
+
*/
|
|
852
|
+
declare function extractImports(source: string): string[];
|
|
853
|
+
/**
|
|
854
|
+
* Resolves a relative import to an absolute filename within the project.
|
|
855
|
+
*/
|
|
856
|
+
declare function resolveImport(fromFile: string, importPath: string, availableFiles: string[]): string | null;
|
|
857
|
+
/**
|
|
858
|
+
* Builds a dependency graph from a set of files.
|
|
859
|
+
* Returns edges and a reverse dependency map (file → dependents).
|
|
860
|
+
*/
|
|
861
|
+
declare function buildDependencyGraph(files: Record<string, string>): {
|
|
862
|
+
edges: DependencyEdge[];
|
|
863
|
+
dependents: Map<string, Set<string>>;
|
|
864
|
+
dependencies: Map<string, Set<string>>;
|
|
865
|
+
};
|
|
866
|
+
/**
|
|
867
|
+
* Given a set of directly changed files, computes the full set of dirty files
|
|
868
|
+
* by following the dependency graph (transitive dependents).
|
|
869
|
+
*/
|
|
870
|
+
declare function computeTransitiveDirtySet(directlyChanged: Set<string>, dependents: Map<string, Set<string>>): Set<string>;
|
|
871
|
+
/**
|
|
872
|
+
* Returns files in compilation order (dependencies first).
|
|
873
|
+
* Uses Kahn's algorithm for topological sorting.
|
|
874
|
+
*/
|
|
875
|
+
declare function topologicalSort(files: string[], dependencies: Map<string, Set<string>>): string[];
|
|
876
|
+
/**
|
|
877
|
+
* Manages file hashes and determines which files need recompilation.
|
|
878
|
+
*/
|
|
879
|
+
declare class IncrementalCache<T> {
|
|
880
|
+
private hashes;
|
|
881
|
+
private results;
|
|
882
|
+
private lastStats;
|
|
883
|
+
/**
|
|
884
|
+
* Determines which files are dirty given current file contents.
|
|
885
|
+
*/
|
|
886
|
+
detectDirtyFiles(files: Record<string, string>, dependents?: Map<string, Set<string>>): DirtyFileSet;
|
|
887
|
+
/**
|
|
888
|
+
* Updates the cache with a compilation result.
|
|
889
|
+
*/
|
|
890
|
+
set(filename: string, source: string, result: T): void;
|
|
891
|
+
/**
|
|
892
|
+
* Gets a cached result.
|
|
893
|
+
*/
|
|
894
|
+
get(filename: string): T | undefined;
|
|
895
|
+
/**
|
|
896
|
+
* Checks if a file is in cache and not dirty.
|
|
897
|
+
*/
|
|
898
|
+
has(filename: string): boolean;
|
|
899
|
+
/**
|
|
900
|
+
* Removes a file from cache.
|
|
901
|
+
*/
|
|
902
|
+
delete(filename: string): void;
|
|
903
|
+
/**
|
|
904
|
+
* Clears all cached data.
|
|
905
|
+
*/
|
|
906
|
+
clear(): void;
|
|
907
|
+
/**
|
|
908
|
+
* Updates stats after a compilation run.
|
|
909
|
+
*/
|
|
910
|
+
updateStats(recompiled: number, cacheHits: number, compileMs: number): void;
|
|
911
|
+
/**
|
|
912
|
+
* Gets compilation statistics.
|
|
913
|
+
*/
|
|
914
|
+
getStats(): IncrementalStats;
|
|
915
|
+
/**
|
|
916
|
+
* Gets all cached filenames.
|
|
917
|
+
*/
|
|
918
|
+
getCachedFiles(): string[];
|
|
919
|
+
/**
|
|
920
|
+
* Gets all cached results.
|
|
921
|
+
*/
|
|
922
|
+
getAllResults(): Map<string, T>;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* ProjectCompiler — multi-file project compilation for UBER-SCALE apps.
|
|
927
|
+
*
|
|
928
|
+
* Takes a Record<string, string> of filename → source code, compiles each
|
|
929
|
+
* file to IR independently, then composes a blueprint with child definitions.
|
|
930
|
+
*
|
|
931
|
+
* Handles:
|
|
932
|
+
* - Multiple .workflow.tsx files → each becomes a child IRWorkflowDefinition
|
|
933
|
+
* - Model files (models/*.ts) → category='data' child definitions
|
|
934
|
+
* - Server action files (*.server.ts) → registered action metadata
|
|
935
|
+
* - Page files (pages/ or app/ dir .tsx) → route table + router workflow child
|
|
936
|
+
* - mm.config.ts → parent blueprint metadata
|
|
937
|
+
* - Cross-file imports (topological sort for compilation order)
|
|
938
|
+
* - Incremental compilation (hash-based, only recompile changed files)
|
|
939
|
+
*
|
|
940
|
+
* Phase 2 enhancements:
|
|
941
|
+
* - Model compilation via model-compiler module
|
|
942
|
+
* - Route extraction via route-extractor module
|
|
943
|
+
* - Action compilation via action-compiler module
|
|
944
|
+
* - Incremental compilation via incremental-compiler module
|
|
945
|
+
* - Cross-file import resolution with data source linking
|
|
946
|
+
*/
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* A resolved module's compilation output, used for route merging.
|
|
950
|
+
* The caller (build tool) compiles each dependency and passes the result here.
|
|
951
|
+
*/
|
|
952
|
+
interface ResolvedModule {
|
|
953
|
+
/** The module's slug (must match the dependency slug in mm.config.ts). */
|
|
954
|
+
slug: string;
|
|
955
|
+
/** The module's compiled route table. */
|
|
956
|
+
routeTable: RouteTableEntry[];
|
|
957
|
+
/** The module's declared routes from its mm.config.ts (if any). */
|
|
958
|
+
manifestRoutes?: Array<{
|
|
959
|
+
path: string;
|
|
960
|
+
label?: string;
|
|
961
|
+
group?: string;
|
|
962
|
+
icon?: string;
|
|
963
|
+
showInNav?: boolean;
|
|
964
|
+
}>;
|
|
965
|
+
}
|
|
966
|
+
interface ProjectCompilerOptions {
|
|
967
|
+
/** Compilation mode: strict or infer. Default: 'infer'. */
|
|
968
|
+
mode?: 'strict' | 'infer';
|
|
969
|
+
/** Enable Phase 2 modules (model-compiler, route-extractor, action-compiler). Default: true. */
|
|
970
|
+
usePhase2Modules?: boolean;
|
|
971
|
+
/** Pre-compiled module results for route merging at compile time. */
|
|
972
|
+
resolvedModules?: ResolvedModule[];
|
|
973
|
+
}
|
|
974
|
+
interface ProjectCompilationResult {
|
|
975
|
+
/** The parent blueprint IRWorkflowDefinition (merged from all files). */
|
|
976
|
+
ir: IRWorkflowDefinition;
|
|
977
|
+
/** Child workflow definitions — one per .workflow.tsx + one per model + router. */
|
|
978
|
+
childDefinitions: IRWorkflowDefinition[];
|
|
979
|
+
/** Per-file IRs keyed by filename. */
|
|
980
|
+
fileIRs: Record<string, IRWorkflowDefinition>;
|
|
981
|
+
/** Route table extracted from pages*.tsx directory structure. */
|
|
982
|
+
routeTable: RouteTableEntry[];
|
|
983
|
+
/** Server actions extracted from *.server.ts files. */
|
|
984
|
+
serverActions: ServerActionEntry[];
|
|
985
|
+
/** Errors from individual file compilations. */
|
|
986
|
+
errors: ProjectCompilationError[];
|
|
987
|
+
/** Warnings from individual file compilations. */
|
|
988
|
+
warnings: ProjectCompilationError[];
|
|
989
|
+
/** Per-page experience trees extracted from app/**\/*.tsx file IRs. */
|
|
990
|
+
pageExperiences: Record<string, IRExperienceNode$1>;
|
|
991
|
+
/** Component definitions captured from components/*.tsx files. */
|
|
992
|
+
componentDefinitions: Record<string, {
|
|
993
|
+
experience: IRExperienceNode$1;
|
|
994
|
+
props: string[];
|
|
995
|
+
}>;
|
|
996
|
+
/** Phase 2: Cross-file import links (importer → imported data sources). */
|
|
997
|
+
importLinks?: ImportLink[];
|
|
998
|
+
/** Phase 2: Model compilation results (if usePhase2Modules enabled). */
|
|
999
|
+
modelResults?: Map<string, ModelCompilationResult>;
|
|
1000
|
+
/** Phase 2: Action compilation result (if usePhase2Modules enabled). */
|
|
1001
|
+
actionResult?: ActionCompilationResult;
|
|
1002
|
+
/** Phase 2: Route extraction result (if usePhase2Modules enabled). */
|
|
1003
|
+
routeResult?: RouteExtractionResult;
|
|
1004
|
+
}
|
|
1005
|
+
interface ProjectCompilationError {
|
|
1006
|
+
file: string;
|
|
1007
|
+
message: string;
|
|
1008
|
+
line?: number;
|
|
1009
|
+
column?: number;
|
|
1010
|
+
/** End line for marker spans (defaults to start line). */
|
|
1011
|
+
endLine?: number;
|
|
1012
|
+
/** End column for marker spans (defaults to start column + token length). */
|
|
1013
|
+
endColumn?: number;
|
|
1014
|
+
severity: 'error' | 'warning';
|
|
1015
|
+
}
|
|
1016
|
+
interface RouteTableEntry {
|
|
1017
|
+
/** Route URL path (e.g., '/rider/home'). */
|
|
1018
|
+
path: string;
|
|
1019
|
+
/** State name derived from the route (e.g., 'RIDER_HOME'). */
|
|
1020
|
+
stateName: string;
|
|
1021
|
+
/** Source file path (e.g., 'pages/rider/home.tsx'). */
|
|
1022
|
+
sourceFile: string;
|
|
1023
|
+
/** Dynamic parameters from [param] segments. */
|
|
1024
|
+
params: string[];
|
|
1025
|
+
/** Module slug if this route was merged from a dependency. */
|
|
1026
|
+
moduleSlug?: string;
|
|
1027
|
+
}
|
|
1028
|
+
interface ServerActionEntry {
|
|
1029
|
+
/** Function name. */
|
|
1030
|
+
name: string;
|
|
1031
|
+
/** Source file path. */
|
|
1032
|
+
sourceFile: string;
|
|
1033
|
+
/** Whether the function is async. */
|
|
1034
|
+
async: boolean;
|
|
1035
|
+
/** Parameter names. */
|
|
1036
|
+
params: string[];
|
|
1037
|
+
/** Description from JSDoc. */
|
|
1038
|
+
description?: string;
|
|
1039
|
+
/** Full function body source text (for round-trip preservation). */
|
|
1040
|
+
body?: string;
|
|
1041
|
+
/** TypeScript return type (e.g., 'Promise<ActionResult>'). */
|
|
1042
|
+
returnType?: string;
|
|
1043
|
+
}
|
|
1044
|
+
/** Phase 2: Cross-file import link metadata. */
|
|
1045
|
+
interface ImportLink {
|
|
1046
|
+
/** The file that imports. */
|
|
1047
|
+
fromFile: string;
|
|
1048
|
+
/** The file being imported. */
|
|
1049
|
+
toFile: string;
|
|
1050
|
+
/** Type of link: 'data-source' for model imports, 'component' for component imports. */
|
|
1051
|
+
linkType: 'data-source' | 'component' | 'action' | 'unknown';
|
|
1052
|
+
/** Imported symbol names. */
|
|
1053
|
+
symbols: string[];
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Compiles a multi-file project into a composed blueprint with child definitions.
|
|
1057
|
+
*
|
|
1058
|
+
* @param files - Record of filename → source code
|
|
1059
|
+
* @param options - Compilation options
|
|
1060
|
+
* @returns Composed result with parent IR, children, routes, actions, errors
|
|
1061
|
+
*/
|
|
1062
|
+
declare function compileProject(files: Record<string, string>, options?: ProjectCompilerOptions): ProjectCompilationResult;
|
|
1063
|
+
/**
|
|
1064
|
+
* Stateful project compiler that caches per-file IR results and only
|
|
1065
|
+
* recompiles files whose content has changed (hash-based invalidation).
|
|
1066
|
+
*
|
|
1067
|
+
* Phase 2 enhancements:
|
|
1068
|
+
* - Uses IncrementalCache from incremental-compiler module
|
|
1069
|
+
* - Dependency-aware invalidation (model change → workflow recompile)
|
|
1070
|
+
* - Compilation statistics tracking
|
|
1071
|
+
*/
|
|
1072
|
+
declare class IncrementalProjectCompiler {
|
|
1073
|
+
private cache;
|
|
1074
|
+
private lastConfig;
|
|
1075
|
+
constructor();
|
|
1076
|
+
/**
|
|
1077
|
+
* Compile a project incrementally — only recompiles changed files.
|
|
1078
|
+
*/
|
|
1079
|
+
compile(files: Record<string, string>, options?: ProjectCompilerOptions): ProjectCompilationResult;
|
|
1080
|
+
/**
|
|
1081
|
+
* Rebuild result from cache without recompiling anything.
|
|
1082
|
+
*/
|
|
1083
|
+
private rebuildFromCache;
|
|
1084
|
+
/** Invalidate a specific file's cache. */
|
|
1085
|
+
invalidate(filename: string): void;
|
|
1086
|
+
/** Invalidate all caches. */
|
|
1087
|
+
invalidateAll(): void;
|
|
1088
|
+
/** Check if a file would need recompilation given its current source. */
|
|
1089
|
+
isDirty(filename: string, source: string): boolean;
|
|
1090
|
+
/** Get list of files currently in cache. */
|
|
1091
|
+
getCachedFiles(): string[];
|
|
1092
|
+
/** Get compilation statistics. */
|
|
1093
|
+
getStats(): {
|
|
1094
|
+
cachedFiles: number;
|
|
1095
|
+
totalHashes: number;
|
|
1096
|
+
} & IncrementalStats;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
export { type ActionCompilationResult, type ActionCompilerOptions, CompilerOptions, CompilerState, type ComputedFieldExtraction, type DecompileOptions, type DecompileProjectOptions, type DecompileProjectResult, type DecompileResult, type DecompilerInput, type DependencyEdge, type DeployOptions, type DeployResult, type DirtyFileSet, ExtractedWorkflow, type FileHash, FileRole, type FrontendDataSource, type FrontendExperienceNode, type ImportLink, IncrementalCache, IncrementalProjectCompiler, type IncrementalStats, type LayoutEntry, type ModelCompilationResult, type ModelCompilerOptions, type ProjectCompilationError, type ProjectCompilationResult, type ProjectCompilerOptions, type ProjectFile, type RoundTripDiff, type RoundTripResult, type RouteEntry, type RouteExtractionResult, type RouteExtractorOptions, type RouteTableEntry, type ServerActionEntry, type ServerActionRegistration, buildDependencyGraph, compileActions, compileModel, compileModels, compileProject, compileSource, compilerStateToWorkflow, computeTransitiveDirtySet, createVisitor, decompile, decompileProject, decompileToTSX, deploy, emitCanonical, emitCompiledOutput, emitIR, emitPureForm, extractComponents, extractComputed, extractEffects, extractEvents, extractImports, extractRoutes, extractStates, extractTransitions, hashContent, normalizeDecompilerInput, resolveActionReferences, resolveImport, shouldDecompileAsProject, topologicalSort, transformToFrontend, validateRoundTrip, validateSourceRoundTrip };
|