@mmapp/react-compiler 0.1.0-alpha.6 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-3UK75242.mjs +17 -0
- package/dist/babel/index.d.mts +2 -2
- package/dist/babel/index.d.ts +2 -2
- package/dist/babel/index.js +5 -5
- package/dist/babel/index.mjs +1 -1
- package/dist/chunk-5FTDWKHH.mjs +244 -0
- package/dist/chunk-7JRAEFRB.mjs +7510 -0
- package/dist/chunk-7T6Q5KAA.mjs +7506 -0
- package/dist/chunk-ABYPKRSB.mjs +215 -0
- package/dist/chunk-BZEXUPDH.mjs +175 -0
- package/dist/chunk-HRYR54PT.mjs +175 -0
- package/dist/chunk-J3M4GUS7.mjs +161 -0
- package/dist/chunk-JRGFBWTN.mjs +2918 -0
- package/dist/chunk-O4AUS7EU.mjs +148 -0
- package/dist/chunk-R2DD5GTY.mjs +186 -0
- package/dist/chunk-UDDTWG5J.mjs +734 -0
- package/dist/chunk-VLTKQDJ3.mjs +244 -0
- package/dist/chunk-WVYY32LD.mjs +939 -0
- package/dist/chunk-XDVM4YHX.mjs +3450 -0
- package/dist/chunk-Z2G5RZ4H.mjs +186 -0
- package/dist/chunk-ZE3KCHBM.mjs +2918 -0
- package/dist/cli/index.js +4350 -3206
- package/dist/cli/index.mjs +77 -179
- package/dist/codemod/cli.js +1 -1
- package/dist/codemod/cli.mjs +1 -1
- package/dist/codemod/index.d.mts +3 -3
- package/dist/codemod/index.d.ts +3 -3
- package/dist/codemod/index.js +1 -1
- package/dist/codemod/index.mjs +1 -1
- package/dist/deploy-YAJGW6II.mjs +9 -0
- package/dist/dev-server-CrQ041KP.d.mts +79 -0
- package/dist/dev-server-CrQ041KP.d.ts +79 -0
- package/dist/dev-server.d.mts +2 -2
- package/dist/dev-server.d.ts +2 -2
- package/dist/dev-server.js +1218 -86
- package/dist/dev-server.mjs +4 -4
- package/dist/envelope-ChEkuHij.d.mts +265 -0
- package/dist/envelope-ChEkuHij.d.ts +265 -0
- package/dist/envelope.d.mts +2 -2
- package/dist/envelope.d.ts +2 -2
- package/dist/envelope.js +5 -5
- package/dist/envelope.mjs +2 -2
- package/dist/index-CEKyyazf.d.mts +104 -0
- package/dist/index-CEKyyazf.d.ts +104 -0
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1266 -342
- package/dist/index.mjs +8 -8
- package/dist/init-7FJENUDK.mjs +407 -0
- package/dist/project-compiler-NNK32MPG.mjs +10 -0
- package/dist/project-compiler-ZB4RUYVL.mjs +10 -0
- package/dist/project-decompiler-U55HQUHW.mjs +7 -0
- package/dist/pull-KOL2QAYQ.mjs +109 -0
- package/dist/seed-KOGEPGOJ.mjs +154 -0
- package/dist/server-VW6UPCHO.mjs +277 -0
- package/dist/testing/index.d.mts +8 -8
- package/dist/testing/index.d.ts +8 -8
- package/dist/testing/index.js +5 -5
- package/dist/testing/index.mjs +1 -1
- package/dist/verify-BYHUKARQ.mjs +1833 -0
- package/dist/verify-OQDEQYMS.mjs +1833 -0
- package/dist/vite/index.d.mts +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +5 -5
- package/dist/vite/index.mjs +2 -2
- package/examples/authentication/main.workflow.tsx +1 -1
- package/examples/authentication/mm.config.ts +1 -1
- package/examples/authentication/pages/LoginPage.tsx +2 -2
- package/examples/authentication/pages/SignupPage.tsx +2 -2
- package/examples/counter.workflow.tsx +1 -1
- package/examples/dashboard.workflow.tsx +1 -1
- package/examples/invoice-approval/actions/invoice.server.ts +1 -1
- package/examples/invoice-approval/main.workflow.tsx +1 -1
- package/examples/invoice-approval/mm.config.ts +1 -1
- package/examples/invoice-approval/pages/InvoiceDetailPage.tsx +1 -1
- package/examples/invoice-approval/pages/InvoiceFormPage.tsx +1 -1
- package/examples/invoice-approval/pages/InvoiceListPage.tsx +1 -1
- package/examples/todo-app.workflow.tsx +1 -1
- package/examples/uber-app/actions/matching.server.ts +1 -1
- package/examples/uber-app/actions/notifications.server.ts +1 -1
- package/examples/uber-app/actions/payments.server.ts +1 -1
- package/examples/uber-app/actions/pricing.server.ts +1 -1
- package/examples/uber-app/app/admin/analytics.tsx +2 -2
- package/examples/uber-app/app/admin/fleet.tsx +2 -2
- package/examples/uber-app/app/admin/surge-pricing.tsx +2 -2
- package/examples/uber-app/app/driver/dashboard.tsx +2 -2
- package/examples/uber-app/app/driver/earnings.tsx +2 -2
- package/examples/uber-app/app/driver/navigation.tsx +2 -2
- package/examples/uber-app/app/driver/ride-acceptance.tsx +2 -2
- package/examples/uber-app/app/rider/home.tsx +2 -2
- package/examples/uber-app/app/rider/payment-methods.tsx +2 -2
- package/examples/uber-app/app/rider/ride-history.tsx +2 -2
- package/examples/uber-app/app/rider/ride-tracking.tsx +2 -2
- package/examples/uber-app/components/DriverCard.tsx +1 -1
- package/examples/uber-app/components/MapView.tsx +3 -3
- package/examples/uber-app/components/RatingStars.tsx +2 -2
- package/examples/uber-app/components/RideCard.tsx +1 -1
- package/examples/uber-app/mm.config.ts +1 -1
- package/examples/uber-app/workflows/dispute-resolution.workflow.tsx +2 -2
- package/examples/uber-app/workflows/driver-onboarding.workflow.tsx +2 -2
- package/examples/uber-app/workflows/payment-processing.workflow.tsx +2 -2
- package/examples/uber-app/workflows/ride-request.workflow.tsx +2 -2
- package/package.json +9 -13
package/dist/dev-server.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDevServer
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-UDDTWG5J.mjs";
|
|
4
|
+
import "./chunk-BZEXUPDH.mjs";
|
|
5
|
+
import "./chunk-VLTKQDJ3.mjs";
|
|
6
6
|
import "./chunk-5M7DKKBC.mjs";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-7T6Q5KAA.mjs";
|
|
8
8
|
import "./chunk-CIESM3BP.mjs";
|
|
9
9
|
export {
|
|
10
10
|
createDevServer
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { IRWorkflowDefinition } from '@mmapp/player-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* File System Tree — generates a manifest of project files with roles and hashes.
|
|
5
|
+
*
|
|
6
|
+
* The fs.tree is the first component of the source envelope.
|
|
7
|
+
* It maps every source file to its role in the workflow project.
|
|
8
|
+
*
|
|
9
|
+
* Roles:
|
|
10
|
+
* - view-entry: .workflow.tsx files (main workflow components)
|
|
11
|
+
* - model: models/*.ts files (workflow definitions)
|
|
12
|
+
* - server-action: *.server.ts files (backend action handlers)
|
|
13
|
+
* - layout: layout.tsx files (route layout boundaries)
|
|
14
|
+
* - page: page.tsx files (route page components)
|
|
15
|
+
* - config: mm.config.ts, blueprint.config.ts
|
|
16
|
+
* - component: regular .tsx components used by workflows
|
|
17
|
+
* - asset: static assets (images, styles, etc.)
|
|
18
|
+
* - unknown: unclassified files
|
|
19
|
+
*/
|
|
20
|
+
type FileRole = 'view-entry' | 'model' | 'server-action' | 'layout' | 'page' | 'config' | 'component' | 'test' | 'asset' | 'unknown';
|
|
21
|
+
interface FsTreeEntry {
|
|
22
|
+
/** Relative path from project root. */
|
|
23
|
+
path: string;
|
|
24
|
+
/** File role in the workflow project. */
|
|
25
|
+
role: FileRole;
|
|
26
|
+
/** SHA-256 content hash. */
|
|
27
|
+
hash: string;
|
|
28
|
+
/** File size in bytes. */
|
|
29
|
+
size: number;
|
|
30
|
+
/** Last modified timestamp. */
|
|
31
|
+
mtime: string;
|
|
32
|
+
/** Workflow slug (for view-entry and model files). */
|
|
33
|
+
slug?: string;
|
|
34
|
+
}
|
|
35
|
+
interface FsTree {
|
|
36
|
+
/** fs.tree format version. */
|
|
37
|
+
version: 1;
|
|
38
|
+
/** Project root directory (absolute). */
|
|
39
|
+
root: string;
|
|
40
|
+
/** Timestamp when the tree was generated. */
|
|
41
|
+
generatedAt: string;
|
|
42
|
+
/** File entries. */
|
|
43
|
+
entries: FsTreeEntry[];
|
|
44
|
+
/** Summary statistics. */
|
|
45
|
+
summary: {
|
|
46
|
+
totalFiles: number;
|
|
47
|
+
byRole: Record<FileRole, number>;
|
|
48
|
+
totalSize: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Determines the role of a file based on its path and naming convention.
|
|
53
|
+
*/
|
|
54
|
+
declare function detectFileRole(relativePath: string): FileRole;
|
|
55
|
+
/**
|
|
56
|
+
* Generates an FsTree from a list of file paths.
|
|
57
|
+
*/
|
|
58
|
+
declare function generateFsTree(files: string[], rootDir: string): FsTree;
|
|
59
|
+
/**
|
|
60
|
+
* Filters an FsTree to only include specific roles.
|
|
61
|
+
*/
|
|
62
|
+
declare function filterByRole(tree: FsTree, roles: FileRole[]): FsTreeEntry[];
|
|
63
|
+
/**
|
|
64
|
+
* Finds changed files between two FsTree snapshots.
|
|
65
|
+
*/
|
|
66
|
+
declare function diffFsTrees(before: FsTree, after: FsTree): {
|
|
67
|
+
added: FsTreeEntry[];
|
|
68
|
+
removed: FsTreeEntry[];
|
|
69
|
+
modified: FsTreeEntry[];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Source Envelope — bundles compiled workflows with source metadata.
|
|
74
|
+
*
|
|
75
|
+
* A source envelope is the unit of deployment. It contains:
|
|
76
|
+
* 1. All compiled workflow definitions (IR)
|
|
77
|
+
* 2. File manifest (fs.tree) with content hashes
|
|
78
|
+
* 3. Source bindings (semantic refs ↔ file spans)
|
|
79
|
+
* 4. Deployment metadata (version, timestamp, environment)
|
|
80
|
+
*
|
|
81
|
+
* The envelope enables:
|
|
82
|
+
* - Immutable versioning (content-addressed)
|
|
83
|
+
* - Source-level debugging (map IR back to .tsx source)
|
|
84
|
+
* - Differential deployment (only deploy changed workflows)
|
|
85
|
+
* - P2P sync (envelope is the unit of transfer)
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
interface SourceEnvelope {
|
|
89
|
+
/** Envelope format version. */
|
|
90
|
+
version: 1;
|
|
91
|
+
/** Content-addressed envelope ID (SHA-256 of canonical content). */
|
|
92
|
+
envelopeId: string;
|
|
93
|
+
/** Blueprint slug this envelope belongs to. */
|
|
94
|
+
blueprintSlug: string;
|
|
95
|
+
/** Blueprint version. */
|
|
96
|
+
blueprintVersion: string;
|
|
97
|
+
/** When the envelope was created. */
|
|
98
|
+
createdAt: string;
|
|
99
|
+
/** Deployment target environment. */
|
|
100
|
+
environment?: string;
|
|
101
|
+
/** Compiled workflow definitions. */
|
|
102
|
+
definitions: IRWorkflowDefinition[];
|
|
103
|
+
/** File manifest. */
|
|
104
|
+
fsTree: FsTree;
|
|
105
|
+
/** Source bindings (IR element → source location). */
|
|
106
|
+
sourceBindings: SourceBinding[];
|
|
107
|
+
/** Deployment metadata. */
|
|
108
|
+
metadata: EnvelopeMetadata;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Maps an IR element to its source location.
|
|
112
|
+
*/
|
|
113
|
+
interface SourceBinding {
|
|
114
|
+
/** Type of IR element. */
|
|
115
|
+
kind: 'field' | 'state' | 'transition' | 'action' | 'component' | 'grammar-island';
|
|
116
|
+
/** Name/ID of the element. */
|
|
117
|
+
name: string;
|
|
118
|
+
/** Workflow slug this binding belongs to. */
|
|
119
|
+
workflowSlug: string;
|
|
120
|
+
/** Source file path (relative). */
|
|
121
|
+
file: string;
|
|
122
|
+
/** Start line (1-based). */
|
|
123
|
+
startLine: number;
|
|
124
|
+
/** Start column (0-based). */
|
|
125
|
+
startColumn: number;
|
|
126
|
+
/** End line (1-based). */
|
|
127
|
+
endLine?: number;
|
|
128
|
+
/** End column (0-based). */
|
|
129
|
+
endColumn?: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Deployment metadata.
|
|
133
|
+
*/
|
|
134
|
+
interface EnvelopeMetadata {
|
|
135
|
+
/** Total number of workflow definitions. */
|
|
136
|
+
definitionCount: number;
|
|
137
|
+
/** Total number of fields across all definitions. */
|
|
138
|
+
totalFields: number;
|
|
139
|
+
/** Total number of states across all definitions. */
|
|
140
|
+
totalStates: number;
|
|
141
|
+
/** Total number of transitions across all definitions. */
|
|
142
|
+
totalTransitions: number;
|
|
143
|
+
/** Compiler version. */
|
|
144
|
+
compilerVersion: string;
|
|
145
|
+
/** Build mode. */
|
|
146
|
+
mode: 'strict' | 'infer';
|
|
147
|
+
/** Whether any errors were detected. */
|
|
148
|
+
hasErrors: boolean;
|
|
149
|
+
/** Error/warning summary. */
|
|
150
|
+
diagnostics: DiagnosticSummary;
|
|
151
|
+
}
|
|
152
|
+
interface DiagnosticSummary {
|
|
153
|
+
errors: number;
|
|
154
|
+
warnings: number;
|
|
155
|
+
errorCodes: string[];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Creates a source envelope from compiled definitions.
|
|
159
|
+
*/
|
|
160
|
+
declare function createSourceEnvelope(params: {
|
|
161
|
+
blueprintSlug: string;
|
|
162
|
+
blueprintVersion: string;
|
|
163
|
+
definitions: IRWorkflowDefinition[];
|
|
164
|
+
fsTree: FsTree;
|
|
165
|
+
sourceBindings?: SourceBinding[];
|
|
166
|
+
environment?: string;
|
|
167
|
+
mode?: 'strict' | 'infer';
|
|
168
|
+
compilerVersion?: string;
|
|
169
|
+
}): SourceEnvelope;
|
|
170
|
+
/**
|
|
171
|
+
* Computes a content-addressed ID for an envelope.
|
|
172
|
+
* Uses SHA-256 of the canonical JSON (sorted keys, no whitespace).
|
|
173
|
+
*/
|
|
174
|
+
declare function computeEnvelopeId(envelope: SourceEnvelope): string;
|
|
175
|
+
/**
|
|
176
|
+
* Checks if two envelopes have the same content (ignoring timestamps).
|
|
177
|
+
*/
|
|
178
|
+
declare function envelopesEqual(a: SourceEnvelope, b: SourceEnvelope): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Finds definitions that changed between two envelopes.
|
|
181
|
+
*/
|
|
182
|
+
declare function diffEnvelopes(before: SourceEnvelope, after: SourceEnvelope): {
|
|
183
|
+
added: string[];
|
|
184
|
+
removed: string[];
|
|
185
|
+
modified: string[];
|
|
186
|
+
unchanged: string[];
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Envelope Builder — walks a project directory, compiles all .workflow.tsx files,
|
|
191
|
+
* and produces a content-addressed SHA-256 deployment bundle.
|
|
192
|
+
*
|
|
193
|
+
* This is the high-level API that combines:
|
|
194
|
+
* - File discovery (fs-tree)
|
|
195
|
+
* - Compilation (babel plugin)
|
|
196
|
+
* - Source binding extraction
|
|
197
|
+
* - Content-addressed envelope creation
|
|
198
|
+
*
|
|
199
|
+
* Usage:
|
|
200
|
+
* import { buildEnvelope } from '@mmapp/react-compiler';
|
|
201
|
+
* const envelope = await buildEnvelope('./src/workflows', { slug: 'my-app' });
|
|
202
|
+
* // envelope.manifest.hash === 'a1b2c3...' (SHA-256)
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
interface EnvelopeManifest {
|
|
206
|
+
/** Content-addressed SHA-256 hash of the entire envelope. */
|
|
207
|
+
hash: string;
|
|
208
|
+
/** Files included in the envelope (relative paths). */
|
|
209
|
+
files: EnvelopeFile[];
|
|
210
|
+
/** Blueprint version string. */
|
|
211
|
+
version: string;
|
|
212
|
+
/** ISO 8601 timestamp. */
|
|
213
|
+
timestamp: string;
|
|
214
|
+
/** Total compiled definitions. */
|
|
215
|
+
definitionCount: number;
|
|
216
|
+
/** Total compilation errors. */
|
|
217
|
+
errorCount: number;
|
|
218
|
+
}
|
|
219
|
+
interface EnvelopeFile {
|
|
220
|
+
/** Relative path from project root. */
|
|
221
|
+
path: string;
|
|
222
|
+
/** SHA-256 hash of file content. */
|
|
223
|
+
hash: string;
|
|
224
|
+
/** File size in bytes. */
|
|
225
|
+
size: number;
|
|
226
|
+
/** Workflow slug (if this file produced a definition). */
|
|
227
|
+
slug?: string;
|
|
228
|
+
/** Whether compilation succeeded for this file. */
|
|
229
|
+
compiled: boolean;
|
|
230
|
+
}
|
|
231
|
+
interface BuildEnvelopeOptions {
|
|
232
|
+
/** Blueprint slug. Default: basename of projectDir */
|
|
233
|
+
slug?: string;
|
|
234
|
+
/** Blueprint version. Default: '0.1.0' */
|
|
235
|
+
version?: string;
|
|
236
|
+
/** Compilation mode. Default: 'infer' */
|
|
237
|
+
mode?: 'strict' | 'infer';
|
|
238
|
+
/** Glob patterns for files to include. Default: discovers all workflow-related files */
|
|
239
|
+
include?: string[];
|
|
240
|
+
/** Environment tag. Default: undefined */
|
|
241
|
+
environment?: string;
|
|
242
|
+
}
|
|
243
|
+
interface BuildEnvelopeResult {
|
|
244
|
+
/** The complete source envelope. */
|
|
245
|
+
envelope: SourceEnvelope;
|
|
246
|
+
/** Content-addressed manifest for the bundle. */
|
|
247
|
+
manifest: EnvelopeManifest;
|
|
248
|
+
/** Individual file compilation results. */
|
|
249
|
+
files: EnvelopeFile[];
|
|
250
|
+
/** Definitions that compiled successfully. */
|
|
251
|
+
definitions: IRWorkflowDefinition[];
|
|
252
|
+
/** Compilation errors. */
|
|
253
|
+
errors: Array<{
|
|
254
|
+
file: string;
|
|
255
|
+
message: string;
|
|
256
|
+
line?: number;
|
|
257
|
+
}>;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Walk a project directory, compile all workflow files, and produce a
|
|
261
|
+
* content-addressed deployment bundle.
|
|
262
|
+
*/
|
|
263
|
+
declare function buildEnvelope(projectDir: string, options?: BuildEnvelopeOptions): Promise<BuildEnvelopeResult>;
|
|
264
|
+
|
|
265
|
+
export { type BuildEnvelopeOptions as B, type EnvelopeManifest as E, type FileRole as F, type SourceEnvelope as S, type EnvelopeFile as a, buildEnvelope as b, type BuildEnvelopeResult as c, createSourceEnvelope as d, computeEnvelopeId as e, envelopesEqual as f, diffEnvelopes as g, type SourceBinding as h, type EnvelopeMetadata as i, generateFsTree as j, detectFileRole as k, filterByRole as l, diffFsTrees as m, type FsTree as n, type FsTreeEntry as o };
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { IRWorkflowDefinition } from '@mmapp/player-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* File System Tree — generates a manifest of project files with roles and hashes.
|
|
5
|
+
*
|
|
6
|
+
* The fs.tree is the first component of the source envelope.
|
|
7
|
+
* It maps every source file to its role in the workflow project.
|
|
8
|
+
*
|
|
9
|
+
* Roles:
|
|
10
|
+
* - view-entry: .workflow.tsx files (main workflow components)
|
|
11
|
+
* - model: models/*.ts files (workflow definitions)
|
|
12
|
+
* - server-action: *.server.ts files (backend action handlers)
|
|
13
|
+
* - layout: layout.tsx files (route layout boundaries)
|
|
14
|
+
* - page: page.tsx files (route page components)
|
|
15
|
+
* - config: mm.config.ts, blueprint.config.ts
|
|
16
|
+
* - component: regular .tsx components used by workflows
|
|
17
|
+
* - asset: static assets (images, styles, etc.)
|
|
18
|
+
* - unknown: unclassified files
|
|
19
|
+
*/
|
|
20
|
+
type FileRole = 'view-entry' | 'model' | 'server-action' | 'layout' | 'page' | 'config' | 'component' | 'test' | 'asset' | 'unknown';
|
|
21
|
+
interface FsTreeEntry {
|
|
22
|
+
/** Relative path from project root. */
|
|
23
|
+
path: string;
|
|
24
|
+
/** File role in the workflow project. */
|
|
25
|
+
role: FileRole;
|
|
26
|
+
/** SHA-256 content hash. */
|
|
27
|
+
hash: string;
|
|
28
|
+
/** File size in bytes. */
|
|
29
|
+
size: number;
|
|
30
|
+
/** Last modified timestamp. */
|
|
31
|
+
mtime: string;
|
|
32
|
+
/** Workflow slug (for view-entry and model files). */
|
|
33
|
+
slug?: string;
|
|
34
|
+
}
|
|
35
|
+
interface FsTree {
|
|
36
|
+
/** fs.tree format version. */
|
|
37
|
+
version: 1;
|
|
38
|
+
/** Project root directory (absolute). */
|
|
39
|
+
root: string;
|
|
40
|
+
/** Timestamp when the tree was generated. */
|
|
41
|
+
generatedAt: string;
|
|
42
|
+
/** File entries. */
|
|
43
|
+
entries: FsTreeEntry[];
|
|
44
|
+
/** Summary statistics. */
|
|
45
|
+
summary: {
|
|
46
|
+
totalFiles: number;
|
|
47
|
+
byRole: Record<FileRole, number>;
|
|
48
|
+
totalSize: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Determines the role of a file based on its path and naming convention.
|
|
53
|
+
*/
|
|
54
|
+
declare function detectFileRole(relativePath: string): FileRole;
|
|
55
|
+
/**
|
|
56
|
+
* Generates an FsTree from a list of file paths.
|
|
57
|
+
*/
|
|
58
|
+
declare function generateFsTree(files: string[], rootDir: string): FsTree;
|
|
59
|
+
/**
|
|
60
|
+
* Filters an FsTree to only include specific roles.
|
|
61
|
+
*/
|
|
62
|
+
declare function filterByRole(tree: FsTree, roles: FileRole[]): FsTreeEntry[];
|
|
63
|
+
/**
|
|
64
|
+
* Finds changed files between two FsTree snapshots.
|
|
65
|
+
*/
|
|
66
|
+
declare function diffFsTrees(before: FsTree, after: FsTree): {
|
|
67
|
+
added: FsTreeEntry[];
|
|
68
|
+
removed: FsTreeEntry[];
|
|
69
|
+
modified: FsTreeEntry[];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Source Envelope — bundles compiled workflows with source metadata.
|
|
74
|
+
*
|
|
75
|
+
* A source envelope is the unit of deployment. It contains:
|
|
76
|
+
* 1. All compiled workflow definitions (IR)
|
|
77
|
+
* 2. File manifest (fs.tree) with content hashes
|
|
78
|
+
* 3. Source bindings (semantic refs ↔ file spans)
|
|
79
|
+
* 4. Deployment metadata (version, timestamp, environment)
|
|
80
|
+
*
|
|
81
|
+
* The envelope enables:
|
|
82
|
+
* - Immutable versioning (content-addressed)
|
|
83
|
+
* - Source-level debugging (map IR back to .tsx source)
|
|
84
|
+
* - Differential deployment (only deploy changed workflows)
|
|
85
|
+
* - P2P sync (envelope is the unit of transfer)
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
interface SourceEnvelope {
|
|
89
|
+
/** Envelope format version. */
|
|
90
|
+
version: 1;
|
|
91
|
+
/** Content-addressed envelope ID (SHA-256 of canonical content). */
|
|
92
|
+
envelopeId: string;
|
|
93
|
+
/** Blueprint slug this envelope belongs to. */
|
|
94
|
+
blueprintSlug: string;
|
|
95
|
+
/** Blueprint version. */
|
|
96
|
+
blueprintVersion: string;
|
|
97
|
+
/** When the envelope was created. */
|
|
98
|
+
createdAt: string;
|
|
99
|
+
/** Deployment target environment. */
|
|
100
|
+
environment?: string;
|
|
101
|
+
/** Compiled workflow definitions. */
|
|
102
|
+
definitions: IRWorkflowDefinition[];
|
|
103
|
+
/** File manifest. */
|
|
104
|
+
fsTree: FsTree;
|
|
105
|
+
/** Source bindings (IR element → source location). */
|
|
106
|
+
sourceBindings: SourceBinding[];
|
|
107
|
+
/** Deployment metadata. */
|
|
108
|
+
metadata: EnvelopeMetadata;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Maps an IR element to its source location.
|
|
112
|
+
*/
|
|
113
|
+
interface SourceBinding {
|
|
114
|
+
/** Type of IR element. */
|
|
115
|
+
kind: 'field' | 'state' | 'transition' | 'action' | 'component' | 'grammar-island';
|
|
116
|
+
/** Name/ID of the element. */
|
|
117
|
+
name: string;
|
|
118
|
+
/** Workflow slug this binding belongs to. */
|
|
119
|
+
workflowSlug: string;
|
|
120
|
+
/** Source file path (relative). */
|
|
121
|
+
file: string;
|
|
122
|
+
/** Start line (1-based). */
|
|
123
|
+
startLine: number;
|
|
124
|
+
/** Start column (0-based). */
|
|
125
|
+
startColumn: number;
|
|
126
|
+
/** End line (1-based). */
|
|
127
|
+
endLine?: number;
|
|
128
|
+
/** End column (0-based). */
|
|
129
|
+
endColumn?: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Deployment metadata.
|
|
133
|
+
*/
|
|
134
|
+
interface EnvelopeMetadata {
|
|
135
|
+
/** Total number of workflow definitions. */
|
|
136
|
+
definitionCount: number;
|
|
137
|
+
/** Total number of fields across all definitions. */
|
|
138
|
+
totalFields: number;
|
|
139
|
+
/** Total number of states across all definitions. */
|
|
140
|
+
totalStates: number;
|
|
141
|
+
/** Total number of transitions across all definitions. */
|
|
142
|
+
totalTransitions: number;
|
|
143
|
+
/** Compiler version. */
|
|
144
|
+
compilerVersion: string;
|
|
145
|
+
/** Build mode. */
|
|
146
|
+
mode: 'strict' | 'infer';
|
|
147
|
+
/** Whether any errors were detected. */
|
|
148
|
+
hasErrors: boolean;
|
|
149
|
+
/** Error/warning summary. */
|
|
150
|
+
diagnostics: DiagnosticSummary;
|
|
151
|
+
}
|
|
152
|
+
interface DiagnosticSummary {
|
|
153
|
+
errors: number;
|
|
154
|
+
warnings: number;
|
|
155
|
+
errorCodes: string[];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Creates a source envelope from compiled definitions.
|
|
159
|
+
*/
|
|
160
|
+
declare function createSourceEnvelope(params: {
|
|
161
|
+
blueprintSlug: string;
|
|
162
|
+
blueprintVersion: string;
|
|
163
|
+
definitions: IRWorkflowDefinition[];
|
|
164
|
+
fsTree: FsTree;
|
|
165
|
+
sourceBindings?: SourceBinding[];
|
|
166
|
+
environment?: string;
|
|
167
|
+
mode?: 'strict' | 'infer';
|
|
168
|
+
compilerVersion?: string;
|
|
169
|
+
}): SourceEnvelope;
|
|
170
|
+
/**
|
|
171
|
+
* Computes a content-addressed ID for an envelope.
|
|
172
|
+
* Uses SHA-256 of the canonical JSON (sorted keys, no whitespace).
|
|
173
|
+
*/
|
|
174
|
+
declare function computeEnvelopeId(envelope: SourceEnvelope): string;
|
|
175
|
+
/**
|
|
176
|
+
* Checks if two envelopes have the same content (ignoring timestamps).
|
|
177
|
+
*/
|
|
178
|
+
declare function envelopesEqual(a: SourceEnvelope, b: SourceEnvelope): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Finds definitions that changed between two envelopes.
|
|
181
|
+
*/
|
|
182
|
+
declare function diffEnvelopes(before: SourceEnvelope, after: SourceEnvelope): {
|
|
183
|
+
added: string[];
|
|
184
|
+
removed: string[];
|
|
185
|
+
modified: string[];
|
|
186
|
+
unchanged: string[];
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Envelope Builder — walks a project directory, compiles all .workflow.tsx files,
|
|
191
|
+
* and produces a content-addressed SHA-256 deployment bundle.
|
|
192
|
+
*
|
|
193
|
+
* This is the high-level API that combines:
|
|
194
|
+
* - File discovery (fs-tree)
|
|
195
|
+
* - Compilation (babel plugin)
|
|
196
|
+
* - Source binding extraction
|
|
197
|
+
* - Content-addressed envelope creation
|
|
198
|
+
*
|
|
199
|
+
* Usage:
|
|
200
|
+
* import { buildEnvelope } from '@mmapp/react-compiler';
|
|
201
|
+
* const envelope = await buildEnvelope('./src/workflows', { slug: 'my-app' });
|
|
202
|
+
* // envelope.manifest.hash === 'a1b2c3...' (SHA-256)
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
interface EnvelopeManifest {
|
|
206
|
+
/** Content-addressed SHA-256 hash of the entire envelope. */
|
|
207
|
+
hash: string;
|
|
208
|
+
/** Files included in the envelope (relative paths). */
|
|
209
|
+
files: EnvelopeFile[];
|
|
210
|
+
/** Blueprint version string. */
|
|
211
|
+
version: string;
|
|
212
|
+
/** ISO 8601 timestamp. */
|
|
213
|
+
timestamp: string;
|
|
214
|
+
/** Total compiled definitions. */
|
|
215
|
+
definitionCount: number;
|
|
216
|
+
/** Total compilation errors. */
|
|
217
|
+
errorCount: number;
|
|
218
|
+
}
|
|
219
|
+
interface EnvelopeFile {
|
|
220
|
+
/** Relative path from project root. */
|
|
221
|
+
path: string;
|
|
222
|
+
/** SHA-256 hash of file content. */
|
|
223
|
+
hash: string;
|
|
224
|
+
/** File size in bytes. */
|
|
225
|
+
size: number;
|
|
226
|
+
/** Workflow slug (if this file produced a definition). */
|
|
227
|
+
slug?: string;
|
|
228
|
+
/** Whether compilation succeeded for this file. */
|
|
229
|
+
compiled: boolean;
|
|
230
|
+
}
|
|
231
|
+
interface BuildEnvelopeOptions {
|
|
232
|
+
/** Blueprint slug. Default: basename of projectDir */
|
|
233
|
+
slug?: string;
|
|
234
|
+
/** Blueprint version. Default: '0.1.0' */
|
|
235
|
+
version?: string;
|
|
236
|
+
/** Compilation mode. Default: 'infer' */
|
|
237
|
+
mode?: 'strict' | 'infer';
|
|
238
|
+
/** Glob patterns for files to include. Default: discovers all workflow-related files */
|
|
239
|
+
include?: string[];
|
|
240
|
+
/** Environment tag. Default: undefined */
|
|
241
|
+
environment?: string;
|
|
242
|
+
}
|
|
243
|
+
interface BuildEnvelopeResult {
|
|
244
|
+
/** The complete source envelope. */
|
|
245
|
+
envelope: SourceEnvelope;
|
|
246
|
+
/** Content-addressed manifest for the bundle. */
|
|
247
|
+
manifest: EnvelopeManifest;
|
|
248
|
+
/** Individual file compilation results. */
|
|
249
|
+
files: EnvelopeFile[];
|
|
250
|
+
/** Definitions that compiled successfully. */
|
|
251
|
+
definitions: IRWorkflowDefinition[];
|
|
252
|
+
/** Compilation errors. */
|
|
253
|
+
errors: Array<{
|
|
254
|
+
file: string;
|
|
255
|
+
message: string;
|
|
256
|
+
line?: number;
|
|
257
|
+
}>;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Walk a project directory, compile all workflow files, and produce a
|
|
261
|
+
* content-addressed deployment bundle.
|
|
262
|
+
*/
|
|
263
|
+
declare function buildEnvelope(projectDir: string, options?: BuildEnvelopeOptions): Promise<BuildEnvelopeResult>;
|
|
264
|
+
|
|
265
|
+
export { type BuildEnvelopeOptions as B, type EnvelopeManifest as E, type FileRole as F, type SourceEnvelope as S, type EnvelopeFile as a, buildEnvelope as b, type BuildEnvelopeResult as c, createSourceEnvelope as d, computeEnvelopeId as e, envelopesEqual as f, diffEnvelopes as g, type SourceBinding as h, type EnvelopeMetadata as i, generateFsTree as j, detectFileRole as k, filterByRole as l, diffFsTrees as m, type FsTree as n, type FsTreeEntry as o };
|
package/dist/envelope.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { B as BuildEnvelopeOptions, c as BuildEnvelopeResult, a as EnvelopeFile, E as EnvelopeManifest, b as buildEnvelope } from './envelope-
|
|
2
|
-
import '@
|
|
1
|
+
export { B as BuildEnvelopeOptions, c as BuildEnvelopeResult, a as EnvelopeFile, E as EnvelopeManifest, b as buildEnvelope } from './envelope-ChEkuHij.mjs';
|
|
2
|
+
import '@mmapp/player-core';
|
package/dist/envelope.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { B as BuildEnvelopeOptions, c as BuildEnvelopeResult, a as EnvelopeFile, E as EnvelopeManifest, b as buildEnvelope } from './envelope-
|
|
2
|
-
import '@
|
|
1
|
+
export { B as BuildEnvelopeOptions, c as BuildEnvelopeResult, a as EnvelopeFile, E as EnvelopeManifest, b as buildEnvelope } from './envelope-ChEkuHij.js';
|
|
2
|
+
import '@mmapp/player-core';
|
package/dist/envelope.js
CHANGED
|
@@ -4228,7 +4228,7 @@ function extractImperativeWorkflow(path, state) {
|
|
|
4228
4228
|
const source = node.source.value;
|
|
4229
4229
|
for (const spec of node.specifiers) {
|
|
4230
4230
|
const localName = spec.local.name;
|
|
4231
|
-
if (source.includes("@mmapp/react") || source.includes("@
|
|
4231
|
+
if (source.includes("@mmapp/react") || source.includes("@mmapp/react")) {
|
|
4232
4232
|
stdLibImports.add(localName);
|
|
4233
4233
|
} else {
|
|
4234
4234
|
importedFns.set(localName, source);
|
|
@@ -5999,7 +5999,7 @@ function extractStaticObj(obj) {
|
|
|
5999
5999
|
}
|
|
6000
6000
|
|
|
6001
6001
|
// src/babel/emitters/pure-form-emitter.ts
|
|
6002
|
-
var import_player_core = require("@
|
|
6002
|
+
var import_player_core = require("@mmapp/player-core");
|
|
6003
6003
|
|
|
6004
6004
|
// src/babel/emitters/experience-transform.ts
|
|
6005
6005
|
function transformToFrontend(node) {
|
|
@@ -7173,7 +7173,7 @@ function createVisitor(options = {}) {
|
|
|
7173
7173
|
if (mode === "strict" && STRICT_BANNED_HOOKS[hookName]) {
|
|
7174
7174
|
const error = {
|
|
7175
7175
|
code: STRICT_BANNED_HOOKS[hookName],
|
|
7176
|
-
message: `${hookName}() is not allowed in strict mode. Use @
|
|
7176
|
+
message: `${hookName}() is not allowed in strict mode. Use @mmapp/react effect hooks instead.`,
|
|
7177
7177
|
line: path.node.loc?.start.line,
|
|
7178
7178
|
column: path.node.loc?.start.column,
|
|
7179
7179
|
severity: "error"
|
|
@@ -7265,12 +7265,12 @@ function createVisitor(options = {}) {
|
|
|
7265
7265
|
}
|
|
7266
7266
|
}
|
|
7267
7267
|
if (mode !== "strict") return;
|
|
7268
|
-
if (source.startsWith("@
|
|
7268
|
+
if (source.startsWith("@mmapp/") || source.startsWith("@mmapp/") || source === "react" || source.startsWith("react/") || source.startsWith(".") || source.startsWith("/")) {
|
|
7269
7269
|
return;
|
|
7270
7270
|
}
|
|
7271
7271
|
const error = {
|
|
7272
7272
|
code: "STRICT_FORBIDDEN_IMPORT",
|
|
7273
|
-
message: `Import from '${source}' is not allowed in strict mode. Only @
|
|
7273
|
+
message: `Import from '${source}' is not allowed in strict mode. Only @mmapp/* and relative imports are permitted.`,
|
|
7274
7274
|
line: path.node.loc?.start.line,
|
|
7275
7275
|
column: path.node.loc?.start.column,
|
|
7276
7276
|
severity: "error"
|
package/dist/envelope.mjs
CHANGED