@mmapp/react-compiler 0.1.0-alpha.16 → 0.1.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/{chunk-UBDNXVL2.mjs → chunk-6LAII7OP.mjs} +82 -4
  2. package/dist/{chunk-GVCJJX7E.mjs → chunk-FPAMQXKB.mjs} +14 -18
  3. package/dist/{chunk-NUPJYPFU.mjs → chunk-GMW45YVD.mjs} +68 -1
  4. package/dist/cli/index.js +201 -72
  5. package/dist/cli/index.mjs +55 -8
  6. package/dist/dev-server.js +42 -65
  7. package/dist/dev-server.mjs +1 -1
  8. package/dist/index.js +42 -65
  9. package/dist/index.mjs +1 -1
  10. package/dist/{init-2CRSUGV5.mjs → init-CJCDWI33.mjs} +119 -0
  11. package/package.json +2 -2
  12. package/dist/chunk-26U577GB.mjs +0 -3465
  13. package/dist/chunk-2FBDFAX6.mjs +0 -2362
  14. package/dist/chunk-2L4QSMXG.mjs +0 -175
  15. package/dist/chunk-2REDFOER.mjs +0 -931
  16. package/dist/chunk-3USIFFE4.mjs +0 -2190
  17. package/dist/chunk-45YMGEVT.mjs +0 -186
  18. package/dist/chunk-46YKSHQR.mjs +0 -175
  19. package/dist/chunk-4FN2AISW.mjs +0 -148
  20. package/dist/chunk-4OPI5L7G.mjs +0 -2593
  21. package/dist/chunk-4RYTKOOJ.mjs +0 -186
  22. package/dist/chunk-4XHK6FWL.mjs +0 -2058
  23. package/dist/chunk-52XHYD2V.mjs +0 -214
  24. package/dist/chunk-5FTDWKHH.mjs +0 -244
  25. package/dist/chunk-5GUFFFGL.mjs +0 -148
  26. package/dist/chunk-5RKTOVR5.mjs +0 -244
  27. package/dist/chunk-5VNJ7C6N.mjs +0 -154
  28. package/dist/chunk-5YDMOO4X.mjs +0 -214
  29. package/dist/chunk-64ZWEMLJ.mjs +0 -148
  30. package/dist/chunk-6CQOAAMV.mjs +0 -1803
  31. package/dist/chunk-6SEVAAVT.mjs +0 -3516
  32. package/dist/chunk-6XP4KSWQ.mjs +0 -2190
  33. package/dist/chunk-6YLR5ZDA.mjs +0 -2829
  34. package/dist/chunk-72QWL54I.mjs +0 -175
  35. package/dist/chunk-7B4TRI7C.mjs +0 -4835
  36. package/dist/chunk-7JRAEFRB.mjs +0 -7510
  37. package/dist/chunk-7ZKGHTNB.mjs +0 -4952
  38. package/dist/chunk-AOGY2GK6.mjs +0 -3292
  39. package/dist/chunk-AXXUXRNA.mjs +0 -1434
  40. package/dist/chunk-CHLVKMQW.mjs +0 -175
  41. package/dist/chunk-CKGOZAB7.mjs +0 -939
  42. package/dist/chunk-D34RAZUX.mjs +0 -2223
  43. package/dist/chunk-DE3ZGQAC.mjs +0 -148
  44. package/dist/chunk-DMCY3BBG.mjs +0 -1933
  45. package/dist/chunk-DPIK3PJS.mjs +0 -244
  46. package/dist/chunk-E5IVH4RE.mjs +0 -186
  47. package/dist/chunk-E6FZNUR5.mjs +0 -4953
  48. package/dist/chunk-EJRBDQDP.mjs +0 -2607
  49. package/dist/chunk-ELO4TXJL.mjs +0 -186
  50. package/dist/chunk-EO6SYNCG.mjs +0 -175
  51. package/dist/chunk-EQGA6A6D.mjs +0 -121
  52. package/dist/chunk-EY2CSXYA.mjs +0 -822
  53. package/dist/chunk-FIQ65CDR.mjs +0 -925
  54. package/dist/chunk-FKRO52XH.mjs +0 -3446
  55. package/dist/chunk-FL4YAKU6.mjs +0 -4941
  56. package/dist/chunk-FOZXJFAR.mjs +0 -186
  57. package/dist/chunk-FX6URXWN.mjs +0 -186
  58. package/dist/chunk-FYT47UBU.mjs +0 -5076
  59. package/dist/chunk-G7SMOWOL.mjs +0 -828
  60. package/dist/chunk-GCLGPOJZ.mjs +0 -148
  61. package/dist/chunk-GGB4G5YY.mjs +0 -175
  62. package/dist/chunk-GXB4JOP7.mjs +0 -5072
  63. package/dist/chunk-HFXOUMTD.mjs +0 -175
  64. package/dist/chunk-HLRGCCIL.mjs +0 -4839
  65. package/dist/chunk-HOIUP6IF.mjs +0 -690
  66. package/dist/chunk-HRYR54PT.mjs +0 -175
  67. package/dist/chunk-HWIZ47US.mjs +0 -214
  68. package/dist/chunk-I3AU7GRD.mjs +0 -120
  69. package/dist/chunk-IB7MNPQL.mjs +0 -4953
  70. package/dist/chunk-ICSIHQCG.mjs +0 -148
  71. package/dist/chunk-ILFGMUVD.mjs +0 -1933
  72. package/dist/chunk-IPTX5MJU.mjs +0 -3223
  73. package/dist/chunk-ITGUSH2Z.mjs +0 -2783
  74. package/dist/chunk-IXHBCAMF.mjs +0 -3306
  75. package/dist/chunk-J7JUAHS4.mjs +0 -186
  76. package/dist/chunk-J7TWJ3TM.mjs +0 -2784
  77. package/dist/chunk-JDPLDGVF.mjs +0 -4810
  78. package/dist/chunk-JLA5VNQ3.mjs +0 -186
  79. package/dist/chunk-JQLWFCTM.mjs +0 -214
  80. package/dist/chunk-K53XP2DL.mjs +0 -148
  81. package/dist/chunk-K5HX2SVL.mjs +0 -1902
  82. package/dist/chunk-KFGYOOVS.mjs +0 -214
  83. package/dist/chunk-KFJJCQAL.mjs +0 -148
  84. package/dist/chunk-KFVVOS5N.mjs +0 -925
  85. package/dist/chunk-KJUIIEQE.mjs +0 -186
  86. package/dist/chunk-KNWTHRVQ.mjs +0 -175
  87. package/dist/chunk-KSG4XSZF.mjs +0 -175
  88. package/dist/chunk-L2OZ4CDV.mjs +0 -113
  89. package/dist/chunk-LF5N6DOU.mjs +0 -175
  90. package/dist/chunk-LJQCM2IM.mjs +0 -214
  91. package/dist/chunk-MIZV3TAN.mjs +0 -3293
  92. package/dist/chunk-NKKLQE5V.mjs +0 -148
  93. package/dist/chunk-NOW23XFZ.mjs +0 -186
  94. package/dist/chunk-NRXQKQ74.mjs +0 -148
  95. package/dist/chunk-NTB7OEX2.mjs +0 -2918
  96. package/dist/chunk-NW6555WJ.mjs +0 -186
  97. package/dist/chunk-O4AUS7EU.mjs +0 -148
  98. package/dist/chunk-OMZE6VLQ.mjs +0 -214
  99. package/dist/chunk-OPJKP747.mjs +0 -7506
  100. package/dist/chunk-OWI6XWCD.mjs +0 -3375
  101. package/dist/chunk-P4BR7WVO.mjs +0 -2190
  102. package/dist/chunk-PRUMNNDI.mjs +0 -3192
  103. package/dist/chunk-QQHVYH2X.mjs +0 -244
  104. package/dist/chunk-QTBD5B3F.mjs +0 -148
  105. package/dist/chunk-R57T26RR.mjs +0 -734
  106. package/dist/chunk-S5QLWLLT.mjs +0 -186
  107. package/dist/chunk-SCWGT2FY.mjs +0 -2190
  108. package/dist/chunk-SKSDPPNT.mjs +0 -3788
  109. package/dist/chunk-SMKJUSB3.mjs +0 -2190
  110. package/dist/chunk-SP2YUS33.mjs +0 -186
  111. package/dist/chunk-SU4E6E7B.mjs +0 -3153
  112. package/dist/chunk-SYUUKW5A.mjs +0 -3379
  113. package/dist/chunk-THFYE5ZX.mjs +0 -244
  114. package/dist/chunk-UDDTWG5J.mjs +0 -734
  115. package/dist/chunk-UL2XZEMA.mjs +0 -3128
  116. package/dist/chunk-VCAY2KGM.mjs +0 -175
  117. package/dist/chunk-VLTKQDJ3.mjs +0 -244
  118. package/dist/chunk-WBYMW4NQ.mjs +0 -3450
  119. package/dist/chunk-WECAV6QB.mjs +0 -148
  120. package/dist/chunk-WMKBXUCE.mjs +0 -3228
  121. package/dist/chunk-XAJ5BKKL.mjs +0 -4947
  122. package/dist/chunk-XG2X7AEA.mjs +0 -175
  123. package/dist/chunk-XG7Z23NQ.mjs +0 -148
  124. package/dist/chunk-XMWUHQVV.mjs +0 -939
  125. package/dist/chunk-XWZAOCQ7.mjs +0 -2607
  126. package/dist/chunk-XZNEDRGN.mjs +0 -3876
  127. package/dist/chunk-Y6FXYEAI.mjs +0 -10
  128. package/dist/chunk-Y6MA7ULW.mjs +0 -148
  129. package/dist/chunk-YFS6JMYO.mjs +0 -3342
  130. package/dist/chunk-YMS7Q7LG.mjs +0 -214
  131. package/dist/chunk-Z2G5RZ4H.mjs +0 -186
  132. package/dist/chunk-Z6AIQ4KL.mjs +0 -113
  133. package/dist/chunk-ZA37XTGA.mjs +0 -175
  134. package/dist/chunk-ZE3KCHBM.mjs +0 -2918
  135. package/dist/config-PL24KEWL.mjs +0 -219
  136. package/dist/dev-server-Bs_sz2DG.d.mts +0 -111
  137. package/dist/dev-server-Bs_sz2DG.d.ts +0 -111
  138. package/dist/dev-server-CjoufJ-u.d.mts +0 -109
  139. package/dist/dev-server-CjoufJ-u.d.ts +0 -109
  140. package/dist/dev-server-RmGHIntF.d.mts +0 -113
  141. package/dist/dev-server-RmGHIntF.d.ts +0 -113
  142. package/dist/engine-binary-QQUDACBJ.mjs +0 -455
  143. package/dist/envelope-DD7v0v6E.d.mts +0 -265
  144. package/dist/envelope-DD7v0v6E.d.ts +0 -265
  145. package/dist/envelope-vCVjrHlo.d.mts +0 -265
  146. package/dist/envelope-vCVjrHlo.d.ts +0 -265
  147. package/dist/index-B5gSgvnd.d.mts +0 -44
  148. package/dist/index-B5gSgvnd.d.ts +0 -44
  149. package/dist/index-Bs0MnR54.d.mts +0 -103
  150. package/dist/index-Bs0MnR54.d.ts +0 -103
  151. package/dist/index-DR0nNc_f.d.mts +0 -101
  152. package/dist/index-DR0nNc_f.d.ts +0 -101
  153. package/dist/index-revho_gS.d.mts +0 -104
  154. package/dist/index-revho_gS.d.ts +0 -104
  155. package/dist/init-7FJENUDK.mjs +0 -407
  156. package/dist/init-7JQMAAXS.mjs +0 -363
  157. package/dist/init-DQDX3QK6.mjs +0 -369
  158. package/dist/init-EHO4VQ22.mjs +0 -369
  159. package/dist/init-IXEE2RCF.mjs +0 -340
  160. package/dist/init-UC3FWPIW.mjs +0 -367
  161. package/dist/init-UNSMVKIK.mjs +0 -366
  162. package/dist/init-UNV5XIDE.mjs +0 -367
  163. package/dist/project-compiler-2P4N4DR7.mjs +0 -10
  164. package/dist/project-compiler-D2LCC27O.mjs +0 -10
  165. package/dist/project-compiler-EGJUTAJU.mjs +0 -10
  166. package/dist/project-compiler-EJ3GANJE.mjs +0 -10
  167. package/dist/project-compiler-LOQKVRZJ.mjs +0 -10
  168. package/dist/project-compiler-NNK32MPG.mjs +0 -10
  169. package/dist/project-compiler-OP2VVGJQ.mjs +0 -10
  170. package/dist/project-compiler-RQ6OQKRM.mjs +0 -10
  171. package/dist/project-compiler-VFR6CSDX.mjs +0 -10
  172. package/dist/project-compiler-VWNNCHGO.mjs +0 -10
  173. package/dist/project-compiler-XVAAU4C5.mjs +0 -10
  174. package/dist/project-compiler-YES5FGMD.mjs +0 -10
  175. package/dist/project-compiler-ZKMQDLGU.mjs +0 -10
  176. package/dist/project-decompiler-5GY2KSG4.mjs +0 -7
  177. package/dist/project-decompiler-FLXCEJHS.mjs +0 -7
  178. package/dist/project-decompiler-US7GAVIC.mjs +0 -7
  179. package/dist/project-decompiler-VLPR22QF.mjs +0 -7
  180. package/dist/pull-A2QUHW4K.mjs +0 -109
  181. package/dist/pull-FUS5QYZS.mjs +0 -109
  182. package/dist/pull-JBEQWVPE.mjs +0 -109
  183. package/dist/pull-LD5ENLGY.mjs +0 -109
  184. package/dist/pull-P44LDRWB.mjs +0 -109
  185. package/dist/verify-BYHUKARQ.mjs +0 -1833
  186. package/dist/verify-SEIXUGN4.mjs +0 -1833
@@ -1,265 +0,0 @@
1
- import { IRWorkflowDefinition } from '@mindmatrix/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 '@mindmatrix/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 FsTree 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 FsTreeEntry as n, type FileRole as o };
@@ -1,265 +0,0 @@
1
- import { IRWorkflowDefinition } from '@mindmatrix/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 '@mindmatrix/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 FsTree 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 FsTreeEntry as n, type FileRole as o };
@@ -1,44 +0,0 @@
1
- import * as _babel_traverse from '@babel/traverse';
2
- import { IRFieldDefinition, IRStateDefinition, IRTransitionDefinition, IROnEventSubscription, IRExperienceNode } from '@mindmatrix/player-core';
3
-
4
- /**
5
- * Internal types for the compiler state and extracted data.
6
- */
7
-
8
- interface ExtractedWorkflow {
9
- slug: string;
10
- name: string;
11
- version: string;
12
- description?: string;
13
- category: string;
14
- fields: IRFieldDefinition[];
15
- states: Map<string, IRStateDefinition>;
16
- transitions: IRTransitionDefinition[];
17
- events: IROnEventSubscription[];
18
- experience?: IRExperienceNode;
19
- }
20
- interface CompilerState {
21
- fields: IRFieldDefinition[];
22
- states: Map<string, IRStateDefinition>;
23
- transitions: IRTransitionDefinition[];
24
- events: IROnEventSubscription[];
25
- experience?: IRExperienceNode;
26
- actionCounter: number;
27
- metadata: {
28
- slug?: string;
29
- name?: string;
30
- version?: string;
31
- description?: string;
32
- category?: string;
33
- };
34
- }
35
- interface CompilerOptions {
36
- mode?: 'strict' | 'infer';
37
- }
38
-
39
- declare function babelPlugin(api: any, options?: CompilerOptions): {
40
- name: string;
41
- visitor: _babel_traverse.Visitor;
42
- };
43
-
44
- export { type CompilerState as C, type ExtractedWorkflow as E, type CompilerOptions as a, babelPlugin as b };
@@ -1,44 +0,0 @@
1
- import * as _babel_traverse from '@babel/traverse';
2
- import { IRFieldDefinition, IRStateDefinition, IRTransitionDefinition, IROnEventSubscription, IRExperienceNode } from '@mindmatrix/player-core';
3
-
4
- /**
5
- * Internal types for the compiler state and extracted data.
6
- */
7
-
8
- interface ExtractedWorkflow {
9
- slug: string;
10
- name: string;
11
- version: string;
12
- description?: string;
13
- category: string;
14
- fields: IRFieldDefinition[];
15
- states: Map<string, IRStateDefinition>;
16
- transitions: IRTransitionDefinition[];
17
- events: IROnEventSubscription[];
18
- experience?: IRExperienceNode;
19
- }
20
- interface CompilerState {
21
- fields: IRFieldDefinition[];
22
- states: Map<string, IRStateDefinition>;
23
- transitions: IRTransitionDefinition[];
24
- events: IROnEventSubscription[];
25
- experience?: IRExperienceNode;
26
- actionCounter: number;
27
- metadata: {
28
- slug?: string;
29
- name?: string;
30
- version?: string;
31
- description?: string;
32
- category?: string;
33
- };
34
- }
35
- interface CompilerOptions {
36
- mode?: 'strict' | 'infer';
37
- }
38
-
39
- declare function babelPlugin(api: any, options?: CompilerOptions): {
40
- name: string;
41
- visitor: _babel_traverse.Visitor;
42
- };
43
-
44
- export { type CompilerState as C, type ExtractedWorkflow as E, type CompilerOptions as a, babelPlugin as b };