@mmapp/react-compiler 0.1.0-alpha.19 → 0.1.0-alpha.21

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/envelope.js CHANGED
@@ -1259,7 +1259,14 @@ function jsxToExperienceNode(node) {
1259
1259
  }
1260
1260
  } else if (t6.isIdentifier(expr)) {
1261
1261
  const snakeName = localFieldMap.get(expr.name);
1262
- bindings[attrName] = snakeName ? `$local.${snakeName}` : `$instance.${expr.name}`;
1262
+ const setterField = setterToFieldMap.get(expr.name);
1263
+ if (snakeName) {
1264
+ bindings[attrName] = `$local.${snakeName}`;
1265
+ } else if (setterField) {
1266
+ bindings[attrName] = `$action.setLocal("${setterField}")`;
1267
+ } else {
1268
+ bindings[attrName] = `$instance.${expr.name}`;
1269
+ }
1263
1270
  } else if (isEventHandlerProp(attrName) && (t6.isArrowFunctionExpression(expr) || t6.isFunctionExpression(expr))) {
1264
1271
  const decomposed = decomposeHandlerToSeq(expr);
1265
1272
  if (decomposed) {
@@ -7296,6 +7303,26 @@ function createVisitor(options = {}) {
7296
7303
  const id = path.node.id;
7297
7304
  const init = path.node.init;
7298
7305
  if (t21.isArrayPattern(id)) return;
7306
+ if (t21.isObjectPattern(id) && init && t21.isCallExpression(init) && t21.isIdentifier(init.callee) && init.callee.name === "useQuery") {
7307
+ const slug = resolveSlugArg(init.arguments, state);
7308
+ if (slug) {
7309
+ for (const prop of id.properties) {
7310
+ if (t21.isObjectProperty(prop) && t21.isIdentifier(prop.key) && prop.key.name === "data") {
7311
+ const alias = t21.isIdentifier(prop.value) ? prop.value.name : null;
7312
+ if (alias) {
7313
+ const meta = compilerState.metadata;
7314
+ const dataSources = meta.dataSources;
7315
+ if (dataSources) {
7316
+ const ds = dataSources.find((d) => d.name === slug);
7317
+ if (ds) ds.name = alias;
7318
+ }
7319
+ }
7320
+ break;
7321
+ }
7322
+ }
7323
+ }
7324
+ return;
7325
+ }
7299
7326
  if (!t21.isIdentifier(id) || !init || !t21.isExpression(init)) return;
7300
7327
  const parentFn = path.getFunctionParent();
7301
7328
  if (!parentFn) return;
@@ -7323,10 +7350,7 @@ function createVisitor(options = {}) {
7323
7350
  return;
7324
7351
  }
7325
7352
  if (callee === "useMutation") {
7326
- registerDerivedVar(id.name, t21.memberExpression(
7327
- t21.identifier("$action"),
7328
- t21.identifier("transition")
7329
- ));
7353
+ registerDerivedVar(id.name, t21.identifier("$action"));
7330
7354
  return;
7331
7355
  }
7332
7356
  if (callee === "useServerAction") {
package/dist/envelope.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  buildEnvelope
3
- } from "./chunk-UASOWKDI.mjs";
3
+ } from "./chunk-AIM5FKMV.mjs";
4
4
  import "./chunk-5M7DKKBC.mjs";
5
- import "./chunk-TXONBY6A.mjs";
5
+ import "./chunk-NJNAQF5I.mjs";
6
6
  import "./chunk-CIESM3BP.mjs";
7
7
  export {
8
8
  buildEnvelope
package/dist/index.js CHANGED
@@ -1386,7 +1386,14 @@ function jsxToExperienceNode(node) {
1386
1386
  }
1387
1387
  } else if (t6.isIdentifier(expr)) {
1388
1388
  const snakeName = localFieldMap.get(expr.name);
1389
- bindings[attrName] = snakeName ? `$local.${snakeName}` : `$instance.${expr.name}`;
1389
+ const setterField = setterToFieldMap.get(expr.name);
1390
+ if (snakeName) {
1391
+ bindings[attrName] = `$local.${snakeName}`;
1392
+ } else if (setterField) {
1393
+ bindings[attrName] = `$action.setLocal("${setterField}")`;
1394
+ } else {
1395
+ bindings[attrName] = `$instance.${expr.name}`;
1396
+ }
1390
1397
  } else if (isEventHandlerProp(attrName) && (t6.isArrowFunctionExpression(expr) || t6.isFunctionExpression(expr))) {
1391
1398
  const decomposed = decomposeHandlerToSeq(expr);
1392
1399
  if (decomposed) {
@@ -7536,6 +7543,26 @@ function createVisitor(options = {}) {
7536
7543
  const id = path.node.id;
7537
7544
  const init = path.node.init;
7538
7545
  if (t25.isArrayPattern(id)) return;
7546
+ if (t25.isObjectPattern(id) && init && t25.isCallExpression(init) && t25.isIdentifier(init.callee) && init.callee.name === "useQuery") {
7547
+ const slug = resolveSlugArg(init.arguments, state);
7548
+ if (slug) {
7549
+ for (const prop2 of id.properties) {
7550
+ if (t25.isObjectProperty(prop2) && t25.isIdentifier(prop2.key) && prop2.key.name === "data") {
7551
+ const alias = t25.isIdentifier(prop2.value) ? prop2.value.name : null;
7552
+ if (alias) {
7553
+ const meta = compilerState.metadata;
7554
+ const dataSources = meta.dataSources;
7555
+ if (dataSources) {
7556
+ const ds = dataSources.find((d) => d.name === slug);
7557
+ if (ds) ds.name = alias;
7558
+ }
7559
+ }
7560
+ break;
7561
+ }
7562
+ }
7563
+ }
7564
+ return;
7565
+ }
7539
7566
  if (!t25.isIdentifier(id) || !init || !t25.isExpression(init)) return;
7540
7567
  const parentFn = path.getFunctionParent();
7541
7568
  if (!parentFn) return;
@@ -7563,10 +7590,7 @@ function createVisitor(options = {}) {
7563
7590
  return;
7564
7591
  }
7565
7592
  if (callee === "useMutation") {
7566
- registerDerivedVar(id.name, t25.memberExpression(
7567
- t25.identifier("$action"),
7568
- t25.identifier("transition")
7569
- ));
7593
+ registerDerivedVar(id.name, t25.identifier("$action"));
7570
7594
  return;
7571
7595
  }
7572
7596
  if (callee === "useServerAction") {
@@ -10876,14 +10900,12 @@ async function deploy(options) {
10876
10900
  }
10877
10901
  async function fetchExistingDefinition(apiUrl, token, slug) {
10878
10902
  try {
10879
- const res = await fetch(`${apiUrl}/workflow/definitions?slug=${encodeURIComponent(slug)}`, {
10903
+ const res = await fetch(`${apiUrl}/workflow/definitions/${encodeURIComponent(slug)}`, {
10880
10904
  headers: { Authorization: `Bearer ${token}` }
10881
10905
  });
10882
10906
  if (!res.ok) return null;
10883
- const data = await res.json();
10884
- const definitions = Array.isArray(data) ? data : data.items ?? data.data;
10885
- if (!definitions || definitions.length === 0) return null;
10886
- const def = definitions[0];
10907
+ const def = await res.json();
10908
+ if (!def || !def.id) return null;
10887
10909
  return {
10888
10910
  id: def.id,
10889
10911
  slug: def.slug,
@@ -10901,7 +10923,7 @@ async function createDefinition(apiUrl, token, ir) {
10901
10923
  "Content-Type": "application/json",
10902
10924
  Authorization: `Bearer ${token}`
10903
10925
  },
10904
- body: JSON.stringify(ir)
10926
+ body: JSON.stringify({ ...ir, visibility: "PUBLIC" })
10905
10927
  });
10906
10928
  if (!res.ok) {
10907
10929
  const errorText = await res.text();
@@ -12671,7 +12693,7 @@ function generatePageFile(page, _slug) {
12671
12693
  slug: page.route || "page",
12672
12694
  name: page.componentName,
12673
12695
  version: "1.0.0",
12674
- category: "page",
12696
+ category: "view",
12675
12697
  states: [],
12676
12698
  transitions: [],
12677
12699
  fields: [],
@@ -14287,7 +14309,13 @@ function App() {
14287
14309
  try {
14288
14310
  const res = await fetch(API_BASE + '/workflow/definitions');
14289
14311
  const json = await res.json();
14290
- const items = json.items || json.data || [];
14312
+ const rawItems = json.items || json.data || [];
14313
+ // Flatten: API returns { id, slug, definition: { experience, ... } }
14314
+ // Merge definition fields up to the top level for easier access
14315
+ const items = rawItems.map(d => {
14316
+ const def = d.definition || {};
14317
+ return { ...d, ...def, definition: undefined };
14318
+ });
14291
14319
  // Find the main blueprint definition (has experience tree)
14292
14320
  const main = items.find(d => d.experience && !(Array.isArray(d.category) ? d.category.includes('data') : d.category === 'data')) || items.find(d => d.experience) || items[0];
14293
14321
  if (main?.experience) {
package/dist/index.mjs CHANGED
@@ -13,25 +13,24 @@ import {
13
13
  resolveActionReferences,
14
14
  resolveImport,
15
15
  topologicalSort
16
- } from "./chunk-TK3QMXIP.mjs";
16
+ } from "./chunk-MRCNUYFA.mjs";
17
17
  import {
18
18
  decompile,
19
19
  decompileProject,
20
20
  shouldDecompileAsProject
21
- } from "./chunk-US3AVDAI.mjs";
21
+ } from "./chunk-4FP5DXY4.mjs";
22
22
  import {
23
23
  createDevServer
24
- } from "./chunk-EGKMUEM6.mjs";
25
- import "./chunk-PBRBRKIQ.mjs";
24
+ } from "./chunk-5PM7CGFQ.mjs";
26
25
  import {
27
26
  buildEnvelope
28
- } from "./chunk-UASOWKDI.mjs";
27
+ } from "./chunk-AIM5FKMV.mjs";
29
28
  import {
30
29
  deploy
31
- } from "./chunk-ABYPKRSB.mjs";
30
+ } from "./chunk-XUQ5R6F3.mjs";
32
31
  import {
33
32
  build
34
- } from "./chunk-TRR2NPAV.mjs";
33
+ } from "./chunk-RTAUTGHB.mjs";
35
34
  import {
36
35
  computeEnvelopeId,
37
36
  createSourceEnvelope,
@@ -42,6 +41,7 @@ import {
42
41
  filterByRole,
43
42
  generateFsTree
44
43
  } from "./chunk-5M7DKKBC.mjs";
44
+ import "./chunk-YOVAADAD.mjs";
45
45
  import {
46
46
  babelPlugin,
47
47
  compilerStateToWorkflow,
@@ -57,7 +57,7 @@ import {
57
57
  extractStates,
58
58
  extractTransitions,
59
59
  transformToFrontend
60
- } from "./chunk-TXONBY6A.mjs";
60
+ } from "./chunk-NJNAQF5I.mjs";
61
61
  import "./chunk-CIESM3BP.mjs";
62
62
 
63
63
  // src/babel/emitters/ir-to-tsx-emitter.ts