@mmapp/react-compiler 0.1.0-alpha.7 → 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 +27 -31
- package/dist/babel/index.mjs +1 -1
- package/dist/chunk-7T6Q5KAA.mjs +7506 -0
- package/dist/chunk-ABYPKRSB.mjs +215 -0
- package/dist/chunk-BZEXUPDH.mjs +175 -0
- package/dist/chunk-J3M4GUS7.mjs +161 -0
- package/dist/chunk-JRGFBWTN.mjs +2918 -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/cli/index.js +4372 -3240
- 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 +1240 -120
- 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 +27 -31
- 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 +1512 -600
- package/dist/index.mjs +8 -8
- package/dist/init-7FJENUDK.mjs +407 -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 +27 -31
- package/dist/testing/index.mjs +1 -1
- 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 +27 -31
- 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 +7 -14
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);
|
|
@@ -5998,12 +5998,8 @@ function extractStaticObj(obj) {
|
|
|
5998
5998
|
return result;
|
|
5999
5999
|
}
|
|
6000
6000
|
|
|
6001
|
-
//
|
|
6002
|
-
|
|
6003
|
-
const uniqueTags = [...new Set(tags.filter((t22) => t22 !== primary))];
|
|
6004
|
-
uniqueTags.sort();
|
|
6005
|
-
return [primary, ...uniqueTags];
|
|
6006
|
-
}
|
|
6001
|
+
// src/babel/emitters/pure-form-emitter.ts
|
|
6002
|
+
var import_player_core = require("@mmapp/player-core");
|
|
6007
6003
|
|
|
6008
6004
|
// src/babel/emitters/experience-transform.ts
|
|
6009
6005
|
function transformToFrontend(node) {
|
|
@@ -6396,7 +6392,7 @@ function liftAction(action) {
|
|
|
6396
6392
|
}
|
|
6397
6393
|
return {
|
|
6398
6394
|
slug: action.id,
|
|
6399
|
-
category: normalizeCategory("expression", "mutation", action.type),
|
|
6395
|
+
category: (0, import_player_core.normalizeCategory)("expression", "mutation", action.type),
|
|
6400
6396
|
parts: parts.length > 0 ? parts : void 0
|
|
6401
6397
|
};
|
|
6402
6398
|
}
|
|
@@ -6426,7 +6422,7 @@ function liftSchedule(during) {
|
|
|
6426
6422
|
for (const action of during.actions) {
|
|
6427
6423
|
parts.push({
|
|
6428
6424
|
slug: "do",
|
|
6429
|
-
category: normalizeCategory("expression", "mutation", action.type),
|
|
6425
|
+
category: (0, import_player_core.normalizeCategory)("expression", "mutation", action.type),
|
|
6430
6426
|
parts: Object.entries(action.config || {}).map(([key, value]) => ({
|
|
6431
6427
|
slug: key,
|
|
6432
6428
|
category: ["atom"],
|
|
@@ -6436,7 +6432,7 @@ function liftSchedule(during) {
|
|
|
6436
6432
|
}
|
|
6437
6433
|
return {
|
|
6438
6434
|
slug: during.id,
|
|
6439
|
-
category: normalizeCategory("schedule", during.type),
|
|
6435
|
+
category: (0, import_player_core.normalizeCategory)("schedule", during.type),
|
|
6440
6436
|
parts
|
|
6441
6437
|
};
|
|
6442
6438
|
}
|
|
@@ -6449,14 +6445,14 @@ function liftState(state) {
|
|
|
6449
6445
|
if (state.on_enter && state.on_enter.length > 0) {
|
|
6450
6446
|
parts.push({
|
|
6451
6447
|
slug: "on_enter",
|
|
6452
|
-
category: normalizeCategory("expression", "sequence"),
|
|
6448
|
+
category: (0, import_player_core.normalizeCategory)("expression", "sequence"),
|
|
6453
6449
|
parts: state.on_enter.map(liftAction)
|
|
6454
6450
|
});
|
|
6455
6451
|
}
|
|
6456
6452
|
if (state.on_exit && state.on_exit.length > 0) {
|
|
6457
6453
|
parts.push({
|
|
6458
6454
|
slug: "on_exit",
|
|
6459
|
-
category: normalizeCategory("expression", "sequence"),
|
|
6455
|
+
category: (0, import_player_core.normalizeCategory)("expression", "sequence"),
|
|
6460
6456
|
parts: state.on_exit.map(liftAction)
|
|
6461
6457
|
});
|
|
6462
6458
|
}
|
|
@@ -6467,7 +6463,7 @@ function liftState(state) {
|
|
|
6467
6463
|
}
|
|
6468
6464
|
return {
|
|
6469
6465
|
slug: state.name,
|
|
6470
|
-
category: normalizeCategory("state", ...tags),
|
|
6466
|
+
category: (0, import_player_core.normalizeCategory)("state", ...tags),
|
|
6471
6467
|
parts: parts.length > 0 ? parts : void 0
|
|
6472
6468
|
};
|
|
6473
6469
|
}
|
|
@@ -6490,17 +6486,17 @@ function liftTransition(transition) {
|
|
|
6490
6486
|
if (transition.actions && transition.actions.length > 0) {
|
|
6491
6487
|
parts.push({
|
|
6492
6488
|
slug: "actions",
|
|
6493
|
-
category: normalizeCategory("expression", "sequence"),
|
|
6489
|
+
category: (0, import_player_core.normalizeCategory)("expression", "sequence"),
|
|
6494
6490
|
parts: transition.actions.map(liftAction)
|
|
6495
6491
|
});
|
|
6496
6492
|
}
|
|
6497
6493
|
if (transition.conditions && transition.conditions.length > 0) {
|
|
6498
6494
|
parts.push({
|
|
6499
6495
|
slug: "conditions",
|
|
6500
|
-
category: normalizeCategory("expression", "guard"),
|
|
6496
|
+
category: (0, import_player_core.normalizeCategory)("expression", "guard"),
|
|
6501
6497
|
parts: transition.conditions.map((c, i) => ({
|
|
6502
6498
|
slug: `condition_${i}`,
|
|
6503
|
-
category: normalizeCategory("expression", c.type || "condition"),
|
|
6499
|
+
category: (0, import_player_core.normalizeCategory)("expression", c.type || "condition"),
|
|
6504
6500
|
parts: c.expression ? [{ slug: c.expression, category: ["binding"] }] : void 0
|
|
6505
6501
|
}))
|
|
6506
6502
|
});
|
|
@@ -6539,7 +6535,7 @@ function liftField(field) {
|
|
|
6539
6535
|
}
|
|
6540
6536
|
return {
|
|
6541
6537
|
slug: field.name,
|
|
6542
|
-
category: normalizeCategory("field", field.type),
|
|
6538
|
+
category: (0, import_player_core.normalizeCategory)("field", field.type),
|
|
6543
6539
|
parts: parts.length > 0 ? parts : void 0
|
|
6544
6540
|
};
|
|
6545
6541
|
}
|
|
@@ -6562,20 +6558,20 @@ function liftView(node) {
|
|
|
6562
6558
|
if (match) {
|
|
6563
6559
|
parts.push({
|
|
6564
6560
|
slug: key,
|
|
6565
|
-
category: normalizeCategory("expression", "effect", "transition"),
|
|
6561
|
+
category: (0, import_player_core.normalizeCategory)("expression", "effect", "transition"),
|
|
6566
6562
|
parts: [{ slug: match[1], category: ["ref"] }]
|
|
6567
6563
|
});
|
|
6568
6564
|
} else {
|
|
6569
6565
|
parts.push({
|
|
6570
6566
|
slug: key,
|
|
6571
|
-
category: normalizeCategory("expression", "binding"),
|
|
6567
|
+
category: (0, import_player_core.normalizeCategory)("expression", "binding"),
|
|
6572
6568
|
parts: [{ slug: String(expr), category: ["binding"] }]
|
|
6573
6569
|
});
|
|
6574
6570
|
}
|
|
6575
6571
|
} else {
|
|
6576
6572
|
parts.push({
|
|
6577
6573
|
slug: key,
|
|
6578
|
-
category: normalizeCategory("expression", "binding"),
|
|
6574
|
+
category: (0, import_player_core.normalizeCategory)("expression", "binding"),
|
|
6579
6575
|
parts: [{ slug: String(expr), category: ["binding"] }]
|
|
6580
6576
|
});
|
|
6581
6577
|
}
|
|
@@ -6586,20 +6582,20 @@ function liftView(node) {
|
|
|
6586
6582
|
if (eqMatch) {
|
|
6587
6583
|
parts.push({
|
|
6588
6584
|
slug: "visible_when",
|
|
6589
|
-
category: normalizeCategory("expression", "guard"),
|
|
6585
|
+
category: (0, import_player_core.normalizeCategory)("expression", "guard"),
|
|
6590
6586
|
parts: [{
|
|
6591
6587
|
slug: "body",
|
|
6592
|
-
category: normalizeCategory("expression", "eq"),
|
|
6588
|
+
category: (0, import_player_core.normalizeCategory)("expression", "eq"),
|
|
6593
6589
|
parts: [
|
|
6594
|
-
{ slug: "lhs", category: normalizeCategory("expression", "path"), parts: [{ slug: eqMatch[1], category: ["binding"] }] },
|
|
6595
|
-
{ slug: "rhs", category: normalizeCategory("expression", "literal"), parts: [{ slug: eqMatch[2], category: ["literal"] }] }
|
|
6590
|
+
{ slug: "lhs", category: (0, import_player_core.normalizeCategory)("expression", "path"), parts: [{ slug: eqMatch[1], category: ["binding"] }] },
|
|
6591
|
+
{ slug: "rhs", category: (0, import_player_core.normalizeCategory)("expression", "literal"), parts: [{ slug: eqMatch[2], category: ["literal"] }] }
|
|
6596
6592
|
]
|
|
6597
6593
|
}]
|
|
6598
6594
|
});
|
|
6599
6595
|
} else {
|
|
6600
6596
|
parts.push({
|
|
6601
6597
|
slug: "visible_when",
|
|
6602
|
-
category: normalizeCategory("expression", "guard"),
|
|
6598
|
+
category: (0, import_player_core.normalizeCategory)("expression", "guard"),
|
|
6603
6599
|
parts: [{ slug: node.visible_when, category: ["binding"] }]
|
|
6604
6600
|
});
|
|
6605
6601
|
}
|
|
@@ -6611,7 +6607,7 @@ function liftView(node) {
|
|
|
6611
6607
|
}
|
|
6612
6608
|
return {
|
|
6613
6609
|
slug: node.id,
|
|
6614
|
-
category: normalizeCategory("view", componentTag),
|
|
6610
|
+
category: (0, import_player_core.normalizeCategory)("view", componentTag),
|
|
6615
6611
|
parts: parts.length > 0 ? parts : void 0
|
|
6616
6612
|
};
|
|
6617
6613
|
}
|
|
@@ -6632,7 +6628,7 @@ function emitCanonical(extracted, sourceFilename) {
|
|
|
6632
6628
|
}
|
|
6633
6629
|
parts.push({
|
|
6634
6630
|
slug: "manifest",
|
|
6635
|
-
category: normalizeCategory("meta", "manifest"),
|
|
6631
|
+
category: (0, import_player_core.normalizeCategory)("meta", "manifest"),
|
|
6636
6632
|
parts: [
|
|
6637
6633
|
{
|
|
6638
6634
|
slug: "workflows",
|
|
@@ -6653,7 +6649,7 @@ function emitCanonical(extracted, sourceFilename) {
|
|
|
6653
6649
|
let categoryArray;
|
|
6654
6650
|
if (category.includes("/")) {
|
|
6655
6651
|
const [primary, ...tags] = category.split("/");
|
|
6656
|
-
categoryArray = normalizeCategory(primary, ...tags);
|
|
6652
|
+
categoryArray = (0, import_player_core.normalizeCategory)(primary, ...tags);
|
|
6657
6653
|
} else {
|
|
6658
6654
|
categoryArray = [category];
|
|
6659
6655
|
}
|
|
@@ -7177,7 +7173,7 @@ function createVisitor(options = {}) {
|
|
|
7177
7173
|
if (mode === "strict" && STRICT_BANNED_HOOKS[hookName]) {
|
|
7178
7174
|
const error = {
|
|
7179
7175
|
code: STRICT_BANNED_HOOKS[hookName],
|
|
7180
|
-
message: `${hookName}() is not allowed in strict mode. Use @
|
|
7176
|
+
message: `${hookName}() is not allowed in strict mode. Use @mmapp/react effect hooks instead.`,
|
|
7181
7177
|
line: path.node.loc?.start.line,
|
|
7182
7178
|
column: path.node.loc?.start.column,
|
|
7183
7179
|
severity: "error"
|
|
@@ -7269,12 +7265,12 @@ function createVisitor(options = {}) {
|
|
|
7269
7265
|
}
|
|
7270
7266
|
}
|
|
7271
7267
|
if (mode !== "strict") return;
|
|
7272
|
-
if (source.startsWith("@
|
|
7268
|
+
if (source.startsWith("@mmapp/") || source.startsWith("@mmapp/") || source === "react" || source.startsWith("react/") || source.startsWith(".") || source.startsWith("/")) {
|
|
7273
7269
|
return;
|
|
7274
7270
|
}
|
|
7275
7271
|
const error = {
|
|
7276
7272
|
code: "STRICT_FORBIDDEN_IMPORT",
|
|
7277
|
-
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.`,
|
|
7278
7274
|
line: path.node.loc?.start.line,
|
|
7279
7275
|
column: path.node.loc?.start.column,
|
|
7280
7276
|
severity: "error"
|
package/dist/envelope.mjs
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as _babel_traverse from '@babel/traverse';
|
|
2
|
+
import { IRActionDefinition, IRFieldDefinition, IRStateDefinition, IRTransitionDefinition, IROnEventSubscription, IRExperienceNode, IRGrammarIsland, CompilerErrorCode } from '@mmapp/player-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Change Extractor — extracts useOnChange calls and converts them to field watcher metadata.
|
|
6
|
+
*
|
|
7
|
+
* INPUT:
|
|
8
|
+
* useOnChange('status', (newVal, oldVal) => {
|
|
9
|
+
* console.log(`Status changed from ${oldVal} to ${newVal}`);
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* OUTPUT (stored in compilerState metadata.fieldWatchers[]):
|
|
13
|
+
* {
|
|
14
|
+
* id: "watcher_1",
|
|
15
|
+
* field: "status",
|
|
16
|
+
* actions: [{ id: "auto_N", type: "log_event", mode: "auto", config: { message: "..." } }]
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface FieldWatcher {
|
|
21
|
+
id: string;
|
|
22
|
+
field: string;
|
|
23
|
+
actions: IRActionDefinition[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Transition Effect Extractor — extracts useOnTransition calls.
|
|
28
|
+
*
|
|
29
|
+
* INPUT:
|
|
30
|
+
* useOnTransition(({ from, to }) => {
|
|
31
|
+
* console.log(`Transitioned from ${from} to ${to}`);
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* OUTPUT (stored in compilerState metadata.transitionEffects[]):
|
|
35
|
+
* {
|
|
36
|
+
* id: "transition_effect_1",
|
|
37
|
+
* actions: [{ id: "auto_N", type: "log_event", mode: "auto", config: { message: "..." } }]
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
interface TransitionEffect {
|
|
42
|
+
id: string;
|
|
43
|
+
actions: IRActionDefinition[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Internal types for the compiler state and extracted data.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
interface ExtractedWorkflow {
|
|
51
|
+
slug: string;
|
|
52
|
+
name: string;
|
|
53
|
+
version: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
category: string;
|
|
56
|
+
fields: IRFieldDefinition[];
|
|
57
|
+
states: Map<string, IRStateDefinition>;
|
|
58
|
+
transitions: IRTransitionDefinition[];
|
|
59
|
+
events: IROnEventSubscription[];
|
|
60
|
+
experience?: IRExperienceNode;
|
|
61
|
+
fieldWatchers?: FieldWatcher[];
|
|
62
|
+
transitionEffects?: TransitionEffect[];
|
|
63
|
+
grammarIslands?: IRGrammarIsland[];
|
|
64
|
+
errors?: ReactCompilerError[];
|
|
65
|
+
warnings?: ReactCompilerError[];
|
|
66
|
+
/** Extra metadata from model files (runtime, fieldOptions, etc.) */
|
|
67
|
+
extraMetadata?: Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
interface CompilerState {
|
|
70
|
+
fields: IRFieldDefinition[];
|
|
71
|
+
states: Map<string, IRStateDefinition>;
|
|
72
|
+
transitions: IRTransitionDefinition[];
|
|
73
|
+
events: IROnEventSubscription[];
|
|
74
|
+
experience?: IRExperienceNode;
|
|
75
|
+
actionCounter: number;
|
|
76
|
+
metadata: {
|
|
77
|
+
slug?: string;
|
|
78
|
+
name?: string;
|
|
79
|
+
version?: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
category?: string;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
};
|
|
84
|
+
errors?: ReactCompilerError[];
|
|
85
|
+
warnings?: ReactCompilerError[];
|
|
86
|
+
}
|
|
87
|
+
interface CompilerOptions {
|
|
88
|
+
mode?: 'strict' | 'infer';
|
|
89
|
+
filename?: string;
|
|
90
|
+
}
|
|
91
|
+
interface ReactCompilerError {
|
|
92
|
+
code: CompilerErrorCode;
|
|
93
|
+
message: string;
|
|
94
|
+
line?: number;
|
|
95
|
+
column?: number;
|
|
96
|
+
severity: 'error' | 'warning';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare function babelPlugin(api: any, options?: CompilerOptions): {
|
|
100
|
+
name: string;
|
|
101
|
+
visitor: _babel_traverse.Visitor;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export { type CompilerState as C, type ExtractedWorkflow as E, type ReactCompilerError as R, type CompilerOptions as a, babelPlugin as b };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as _babel_traverse from '@babel/traverse';
|
|
2
|
+
import { IRActionDefinition, IRFieldDefinition, IRStateDefinition, IRTransitionDefinition, IROnEventSubscription, IRExperienceNode, IRGrammarIsland, CompilerErrorCode } from '@mmapp/player-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Change Extractor — extracts useOnChange calls and converts them to field watcher metadata.
|
|
6
|
+
*
|
|
7
|
+
* INPUT:
|
|
8
|
+
* useOnChange('status', (newVal, oldVal) => {
|
|
9
|
+
* console.log(`Status changed from ${oldVal} to ${newVal}`);
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* OUTPUT (stored in compilerState metadata.fieldWatchers[]):
|
|
13
|
+
* {
|
|
14
|
+
* id: "watcher_1",
|
|
15
|
+
* field: "status",
|
|
16
|
+
* actions: [{ id: "auto_N", type: "log_event", mode: "auto", config: { message: "..." } }]
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface FieldWatcher {
|
|
21
|
+
id: string;
|
|
22
|
+
field: string;
|
|
23
|
+
actions: IRActionDefinition[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Transition Effect Extractor — extracts useOnTransition calls.
|
|
28
|
+
*
|
|
29
|
+
* INPUT:
|
|
30
|
+
* useOnTransition(({ from, to }) => {
|
|
31
|
+
* console.log(`Transitioned from ${from} to ${to}`);
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* OUTPUT (stored in compilerState metadata.transitionEffects[]):
|
|
35
|
+
* {
|
|
36
|
+
* id: "transition_effect_1",
|
|
37
|
+
* actions: [{ id: "auto_N", type: "log_event", mode: "auto", config: { message: "..." } }]
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
interface TransitionEffect {
|
|
42
|
+
id: string;
|
|
43
|
+
actions: IRActionDefinition[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Internal types for the compiler state and extracted data.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
interface ExtractedWorkflow {
|
|
51
|
+
slug: string;
|
|
52
|
+
name: string;
|
|
53
|
+
version: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
category: string;
|
|
56
|
+
fields: IRFieldDefinition[];
|
|
57
|
+
states: Map<string, IRStateDefinition>;
|
|
58
|
+
transitions: IRTransitionDefinition[];
|
|
59
|
+
events: IROnEventSubscription[];
|
|
60
|
+
experience?: IRExperienceNode;
|
|
61
|
+
fieldWatchers?: FieldWatcher[];
|
|
62
|
+
transitionEffects?: TransitionEffect[];
|
|
63
|
+
grammarIslands?: IRGrammarIsland[];
|
|
64
|
+
errors?: ReactCompilerError[];
|
|
65
|
+
warnings?: ReactCompilerError[];
|
|
66
|
+
/** Extra metadata from model files (runtime, fieldOptions, etc.) */
|
|
67
|
+
extraMetadata?: Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
interface CompilerState {
|
|
70
|
+
fields: IRFieldDefinition[];
|
|
71
|
+
states: Map<string, IRStateDefinition>;
|
|
72
|
+
transitions: IRTransitionDefinition[];
|
|
73
|
+
events: IROnEventSubscription[];
|
|
74
|
+
experience?: IRExperienceNode;
|
|
75
|
+
actionCounter: number;
|
|
76
|
+
metadata: {
|
|
77
|
+
slug?: string;
|
|
78
|
+
name?: string;
|
|
79
|
+
version?: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
category?: string;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
};
|
|
84
|
+
errors?: ReactCompilerError[];
|
|
85
|
+
warnings?: ReactCompilerError[];
|
|
86
|
+
}
|
|
87
|
+
interface CompilerOptions {
|
|
88
|
+
mode?: 'strict' | 'infer';
|
|
89
|
+
filename?: string;
|
|
90
|
+
}
|
|
91
|
+
interface ReactCompilerError {
|
|
92
|
+
code: CompilerErrorCode;
|
|
93
|
+
message: string;
|
|
94
|
+
line?: number;
|
|
95
|
+
column?: number;
|
|
96
|
+
severity: 'error' | 'warning';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare function babelPlugin(api: any, options?: CompilerOptions): {
|
|
100
|
+
name: string;
|
|
101
|
+
visitor: _babel_traverse.Visitor;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export { type CompilerState as C, type ExtractedWorkflow as E, type ReactCompilerError as R, type CompilerOptions as a, babelPlugin as b };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { E as ExtractedWorkflow, C as CompilerState, a as CompilerOptions } from './index-
|
|
2
|
-
export { R as ReactCompilerError, b as babelPlugin } from './index-
|
|
1
|
+
import { E as ExtractedWorkflow, C as CompilerState, a as CompilerOptions } from './index-CEKyyazf.mjs';
|
|
2
|
+
export { R as ReactCompilerError, b as babelPlugin } from './index-CEKyyazf.mjs';
|
|
3
3
|
import { NodePath, Visitor } from '@babel/traverse';
|
|
4
4
|
import * as t from '@babel/types';
|
|
5
|
-
import { IRWorkflowDefinition, PureFormWorkflow, IRDataSource, IRExperienceNode as IRExperienceNode$1 } from '@
|
|
6
|
-
export { B as BuildOptions, d as BuildResult, a as DevServerInstance, D as DevServerOptions, b as build, c as createDevServer } from './dev-server-
|
|
7
|
-
import { F as FileRole } from './envelope-
|
|
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-
|
|
5
|
+
import { IRWorkflowDefinition, PureFormWorkflow, IRDataSource, IRExperienceNode as IRExperienceNode$1 } from '@mmapp/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-CrQ041KP.mjs';
|
|
7
|
+
import { F as FileRole } from './envelope-ChEkuHij.mjs';
|
|
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-ChEkuHij.mjs';
|
|
9
9
|
import 'vite';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -425,7 +425,7 @@ declare function decompile(definition: DecompilerInput, options?: DecompileOptio
|
|
|
425
425
|
* - useQuery/useMutation data sources
|
|
426
426
|
* - JSX return tree from experience nodes
|
|
427
427
|
* - @workflow JSDoc header
|
|
428
|
-
* - Proper imports from @
|
|
428
|
+
* - Proper imports from @mmapp/react
|
|
429
429
|
*
|
|
430
430
|
* @param definition - The IR workflow definition (with optional experience tree).
|
|
431
431
|
* @param options - Decompile options (componentName, includeAnnotation, etc.).
|
|
@@ -499,7 +499,7 @@ declare function extractComputed(path: NodePath<t.CallExpression>, state: any):
|
|
|
499
499
|
/**
|
|
500
500
|
* Babel Visitor — main AST traversal logic for extracting workflow definitions.
|
|
501
501
|
*
|
|
502
|
-
* Handles all @
|
|
502
|
+
* Handles all @mmapp/react hooks:
|
|
503
503
|
* - useState → fields
|
|
504
504
|
* - useOnEnter / useOnExit → state enter/exit actions
|
|
505
505
|
* - useTransition → transitions
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { E as ExtractedWorkflow, C as CompilerState, a as CompilerOptions } from './index-
|
|
2
|
-
export { R as ReactCompilerError, b as babelPlugin } from './index-
|
|
1
|
+
import { E as ExtractedWorkflow, C as CompilerState, a as CompilerOptions } from './index-CEKyyazf.js';
|
|
2
|
+
export { R as ReactCompilerError, b as babelPlugin } from './index-CEKyyazf.js';
|
|
3
3
|
import { NodePath, Visitor } from '@babel/traverse';
|
|
4
4
|
import * as t from '@babel/types';
|
|
5
|
-
import { IRWorkflowDefinition, PureFormWorkflow, IRDataSource, IRExperienceNode as IRExperienceNode$1 } from '@
|
|
6
|
-
export { B as BuildOptions, d as BuildResult, a as DevServerInstance, D as DevServerOptions, b as build, c as createDevServer } from './dev-server-
|
|
7
|
-
import { F as FileRole } from './envelope-
|
|
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-
|
|
5
|
+
import { IRWorkflowDefinition, PureFormWorkflow, IRDataSource, IRExperienceNode as IRExperienceNode$1 } from '@mmapp/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-CrQ041KP.js';
|
|
7
|
+
import { F as FileRole } from './envelope-ChEkuHij.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-ChEkuHij.js';
|
|
9
9
|
import 'vite';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -425,7 +425,7 @@ declare function decompile(definition: DecompilerInput, options?: DecompileOptio
|
|
|
425
425
|
* - useQuery/useMutation data sources
|
|
426
426
|
* - JSX return tree from experience nodes
|
|
427
427
|
* - @workflow JSDoc header
|
|
428
|
-
* - Proper imports from @
|
|
428
|
+
* - Proper imports from @mmapp/react
|
|
429
429
|
*
|
|
430
430
|
* @param definition - The IR workflow definition (with optional experience tree).
|
|
431
431
|
* @param options - Decompile options (componentName, includeAnnotation, etc.).
|
|
@@ -499,7 +499,7 @@ declare function extractComputed(path: NodePath<t.CallExpression>, state: any):
|
|
|
499
499
|
/**
|
|
500
500
|
* Babel Visitor — main AST traversal logic for extracting workflow definitions.
|
|
501
501
|
*
|
|
502
|
-
* Handles all @
|
|
502
|
+
* Handles all @mmapp/react hooks:
|
|
503
503
|
* - useState → fields
|
|
504
504
|
* - useOnEnter / useOnExit → state enter/exit actions
|
|
505
505
|
* - useTransition → transitions
|