@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
@@ -589,10 +589,10 @@ async function createDevServer(options = {}) {
589
589
  }
590
590
  const {
591
591
  port = 5199,
592
- src = "src/workflows",
592
+ src = ".",
593
593
  mode = "infer",
594
- include = ["**/*.workflow.tsx"],
595
- outDir = "dist/workflows",
594
+ include = ["models/**/*.ts", "app/**/*.tsx", "**/*.workflow.tsx"],
595
+ outDir = "dist",
596
596
  seed = false,
597
597
  apiUrl: rawApiUrl = "auto",
598
598
  authToken: explicitToken,
@@ -687,6 +687,74 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
687
687
  `;
688
688
  }
689
689
  };
690
+ const devHtml = `<!DOCTYPE html>
691
+ <html lang="en">
692
+ <head>
693
+ <meta charset="UTF-8">
694
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
695
+ <title>MindMatrix Dev</title>
696
+ <style>
697
+ * { margin: 0; padding: 0; box-sizing: border-box; }
698
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #fafafa; color: #111; }
699
+ #root { min-height: 100vh; }
700
+ .mm-loading { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex-direction: column; gap: 12px; }
701
+ .mm-loading h1 { font-size: 20px; font-weight: 600; color: #333; }
702
+ .mm-loading p { color: #888; font-size: 14px; }
703
+ </style>
704
+ </head>
705
+ <body>
706
+ <div id="root">
707
+ <div class="mm-loading">
708
+ <h1>MindMatrix Dev</h1>
709
+ <p>Loading...</p>
710
+ </div>
711
+ </div>
712
+ <script type="module">
713
+ import React from 'react';
714
+ import { createRoot } from 'react-dom/client';
715
+
716
+ function App() {
717
+ const [data, setData] = React.useState({ definitions: [], instances: [] });
718
+ const [error, setError] = React.useState(null);
719
+
720
+ React.useEffect(() => {
721
+ fetch('/api/v1/workflow/definitions')
722
+ .then(r => r.ok ? r.json() : Promise.reject('API ' + r.status))
723
+ .then(defs => setData(d => ({ ...d, definitions: Array.isArray(defs) ? defs : defs.data || [] })))
724
+ .catch(e => setError(String(e)));
725
+ }, []);
726
+
727
+ if (error) return React.createElement('div', { style: { padding: 40 } },
728
+ React.createElement('h1', null, 'MindMatrix Dev'),
729
+ React.createElement('p', { style: { color: '#c00', marginTop: 8 } }, 'API Error: ' + error),
730
+ React.createElement('p', { style: { color: '#888', marginTop: 8 } }, 'The engine is running but the API returned an error. This may be an auth issue in SQLite mode.')
731
+ );
732
+
733
+ return React.createElement('div', { style: { padding: 40, maxWidth: 800 } },
734
+ React.createElement('h1', { style: { marginBottom: 16 } }, 'MindMatrix Dev'),
735
+ React.createElement('p', { style: { color: '#666', marginBottom: 24 } },
736
+ data.definitions.length + ' definition(s) deployed'),
737
+ data.definitions.map((def, i) =>
738
+ React.createElement('div', { key: i, style: { border: '1px solid #ddd', borderRadius: 8, padding: 16, marginBottom: 12, background: '#fff' } },
739
+ React.createElement('h3', { style: { marginBottom: 4 } }, def.name || def.slug || 'Unnamed'),
740
+ React.createElement('p', { style: { color: '#888', fontSize: 13 } },
741
+ 'slug: ' + (def.slug || '?') + ' | states: ' + (def.states?.length || 0) + ' | fields: ' + (def.fields?.length || 0))
742
+ )
743
+ ),
744
+ data.definitions.length === 0 && React.createElement('p', { style: { color: '#888' } },
745
+ 'No definitions deployed yet. Edit your model files and save \u2014 mmrc dev will auto-compile and deploy.')
746
+ );
747
+ }
748
+
749
+ createRoot(document.getElementById('root')).render(React.createElement(App));
750
+ </script>
751
+ </body>
752
+ </html>`;
753
+ const { mkdtempSync, writeFileSync } = await import("fs");
754
+ const { join } = await import("path");
755
+ const { tmpdir } = await import("os");
756
+ const devRoot = mkdtempSync(join(tmpdir(), "mm-dev-"));
757
+ writeFileSync(join(devRoot, "index.html"), devHtml, "utf-8");
690
758
  let deployInFlight = false;
691
759
  const compileDeployPlugin = {
692
760
  name: "mindmatrix-dev-compile-deploy",
@@ -717,11 +785,16 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
717
785
  }
718
786
  };
719
787
  const viteConfig = {
720
- root: process.cwd(),
788
+ // Physical index.html lives in a temp dir so Vite serves it natively.
789
+ root: devRoot,
790
+ // Pre-bundle React so Vite doesn't warn about missing entry point.
791
+ optimizeDeps: { include: ["react", "react-dom/client"] },
721
792
  server: {
722
793
  port,
723
794
  open,
724
795
  host: true,
796
+ // Allow serving files from the real project directory (fs.allow).
797
+ fs: { allow: [devRoot, process.cwd(), ".."] },
725
798
  proxy: {
726
799
  "/api": { target: proxyTarget, changeOrigin: true, secure: true, ws: true },
727
800
  "/health": { target: proxyTarget, changeOrigin: true, secure: true },
@@ -792,6 +865,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
792
865
  if (localServer) {
793
866
  await localServer.close();
794
867
  }
868
+ try {
869
+ const { rmSync } = await import("fs");
870
+ rmSync(devRoot, { recursive: true, force: true });
871
+ } catch {
872
+ }
795
873
  }
796
874
  };
797
875
  }
@@ -752,25 +752,21 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
752
752
  </html>`;
753
753
  const htmlPlugin = {
754
754
  name: "mindmatrix-dev-html",
755
- // Return a function from configureServer → runs as POST-middleware,
756
- // after Vite's built-in static file serving and SPA fallback.
757
755
  configureServer(server) {
758
- return () => {
759
- server.middlewares.use(async (req, res, next) => {
760
- const url = req.url ?? "";
761
- if (url !== "/" && url !== "/index.html" && !url.startsWith("/?")) return next();
762
- const accept = req.headers?.accept ?? "";
763
- if (!accept.includes("text/html")) return next();
764
- try {
765
- const transformed = await server.transformIndexHtml(url, devHtml);
766
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
767
- res.end(transformed);
768
- } catch (e) {
769
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
770
- res.end(devHtml);
771
- }
772
- });
773
- };
756
+ server.middlewares.use(async (req, res, next) => {
757
+ const url = req.url ?? "";
758
+ if (url !== "/" && url !== "/index.html" && !url.startsWith("/?") && !url.startsWith("/index.html?")) return next();
759
+ const accept = req.headers?.accept ?? "";
760
+ if (!accept.includes("text/html") && !accept.includes("*/*")) return next();
761
+ try {
762
+ const transformed = await server.transformIndexHtml(url, devHtml);
763
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
764
+ res.end(transformed);
765
+ } catch {
766
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
767
+ res.end(devHtml);
768
+ }
769
+ });
774
770
  }
775
771
  };
776
772
  let deployInFlight = false;
@@ -687,6 +687,63 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
687
687
  `;
688
688
  }
689
689
  };
690
+ const devHtml = `<!DOCTYPE html>
691
+ <html lang="en">
692
+ <head>
693
+ <meta charset="UTF-8">
694
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
695
+ <title>MindMatrix Dev</title>
696
+ <style>
697
+ * { margin: 0; padding: 0; box-sizing: border-box; }
698
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #fafafa; color: #111; }
699
+ #root { min-height: 100vh; }
700
+ .mm-loading { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex-direction: column; gap: 12px; }
701
+ .mm-loading h1 { font-size: 20px; font-weight: 600; color: #333; }
702
+ .mm-loading p { color: #888; font-size: 14px; }
703
+ </style>
704
+ </head>
705
+ <body>
706
+ <div id="root">
707
+ <div class="mm-loading">
708
+ <h1>MindMatrix Dev</h1>
709
+ <p>Loading...</p>
710
+ </div>
711
+ </div>
712
+ <script>
713
+ async function render() {
714
+ const root = document.getElementById('root');
715
+ try {
716
+ const res = await fetch('/api/v1/workflow/definitions');
717
+ const json = await res.json();
718
+ const items = json.items || json.data || [];
719
+ let html = '<div style="padding:40px;max-width:960px;margin:0 auto;font-family:-apple-system,BlinkMacSystemFont,sans-serif">';
720
+ html += '<h1 style="margin-bottom:8px">MindMatrix Dev</h1>';
721
+ html += '<p style="color:#666;margin-bottom:24px">' + items.length + ' definition(s) deployed</p>';
722
+ if (items.length === 0) {
723
+ html += '<div style="text-align:center;padding:60px 20px;color:#888"><p>No definitions yet.</p><p style="margin-top:8px;font-size:13px">Edit your model files and save.</p></div>';
724
+ }
725
+ for (const def of items) {
726
+ html += '<div style="border:1px solid #e0e0e0;border-radius:8px;padding:16px;margin-bottom:12px;background:#fff">';
727
+ html += '<h3 style="margin-bottom:4px">' + (def.name || def.slug || 'Unnamed') + '</h3>';
728
+ html += '<p style="color:#888;font-size:13px">slug: ' + (def.slug || '?') + ' | states: ' + (def.states?.length || 0) + ' | fields: ' + (def.fields?.length || 0) + '</p>';
729
+ html += '</div>';
730
+ }
731
+ html += '</div>';
732
+ root.innerHTML = html;
733
+ } catch (e) {
734
+ root.innerHTML = '<div style="padding:40px"><h1>MindMatrix Dev</h1><p style="color:#c00;margin-top:8px">API Error: ' + e.message + '</p></div>';
735
+ }
736
+ }
737
+ render();
738
+ setInterval(render, 3000);
739
+ </script>
740
+ </body>
741
+ </html>`;
742
+ const { mkdtempSync, writeFileSync } = await import("fs");
743
+ const { join } = await import("path");
744
+ const { tmpdir } = await import("os");
745
+ const devRoot = mkdtempSync(join(tmpdir(), "mm-dev-"));
746
+ writeFileSync(join(devRoot, "index.html"), devHtml, "utf-8");
690
747
  let deployInFlight = false;
691
748
  const compileDeployPlugin = {
692
749
  name: "mindmatrix-dev-compile-deploy",
@@ -717,11 +774,16 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
717
774
  }
718
775
  };
719
776
  const viteConfig = {
720
- root: process.cwd(),
777
+ // Physical index.html lives in a temp dir so Vite serves it natively.
778
+ root: devRoot,
779
+ // Pre-bundle React so Vite doesn't warn about missing entry point.
780
+ optimizeDeps: { include: ["react", "react-dom/client"] },
721
781
  server: {
722
782
  port,
723
783
  open,
724
784
  host: true,
785
+ // Allow serving files from the real project directory (fs.allow).
786
+ fs: { allow: [devRoot, process.cwd(), ".."] },
725
787
  proxy: {
726
788
  "/api": { target: proxyTarget, changeOrigin: true, secure: true, ws: true },
727
789
  "/health": { target: proxyTarget, changeOrigin: true, secure: true },
@@ -792,6 +854,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
792
854
  if (localServer) {
793
855
  await localServer.close();
794
856
  }
857
+ try {
858
+ const { rmSync } = await import("fs");
859
+ rmSync(devRoot, { recursive: true, force: true });
860
+ } catch {
861
+ }
795
862
  }
796
863
  };
797
864
  }
package/dist/cli/index.js CHANGED
@@ -15906,70 +15906,41 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
15906
15906
  <p>Loading...</p>
15907
15907
  </div>
15908
15908
  </div>
15909
- <script type="module">
15910
- import React from 'react';
15911
- import { createRoot } from 'react-dom/client';
15912
-
15913
- function App() {
15914
- const [data, setData] = React.useState({ definitions: [], instances: [] });
15915
- const [error, setError] = React.useState(null);
15916
-
15917
- React.useEffect(() => {
15918
- fetch('/api/v1/workflow/definitions')
15919
- .then(r => r.ok ? r.json() : Promise.reject('API ' + r.status))
15920
- .then(defs => setData(d => ({ ...d, definitions: Array.isArray(defs) ? defs : defs.data || [] })))
15921
- .catch(e => setError(String(e)));
15922
- }, []);
15923
-
15924
- if (error) return React.createElement('div', { style: { padding: 40 } },
15925
- React.createElement('h1', null, 'MindMatrix Dev'),
15926
- React.createElement('p', { style: { color: '#c00', marginTop: 8 } }, 'API Error: ' + error),
15927
- React.createElement('p', { style: { color: '#888', marginTop: 8 } }, 'The engine is running but the API returned an error. This may be an auth issue in SQLite mode.')
15928
- );
15929
-
15930
- return React.createElement('div', { style: { padding: 40, maxWidth: 800 } },
15931
- React.createElement('h1', { style: { marginBottom: 16 } }, 'MindMatrix Dev'),
15932
- React.createElement('p', { style: { color: '#666', marginBottom: 24 } },
15933
- data.definitions.length + ' definition(s) deployed'),
15934
- data.definitions.map((def, i) =>
15935
- React.createElement('div', { key: i, style: { border: '1px solid #ddd', borderRadius: 8, padding: 16, marginBottom: 12, background: '#fff' } },
15936
- React.createElement('h3', { style: { marginBottom: 4 } }, def.name || def.slug || 'Unnamed'),
15937
- React.createElement('p', { style: { color: '#888', fontSize: 13 } },
15938
- 'slug: ' + (def.slug || '?') + ' | states: ' + (def.states?.length || 0) + ' | fields: ' + (def.fields?.length || 0))
15939
- )
15940
- ),
15941
- data.definitions.length === 0 && React.createElement('p', { style: { color: '#888' } },
15942
- 'No definitions deployed yet. Edit your model files and save \u2014 mmrc dev will auto-compile and deploy.')
15943
- );
15909
+ <script>
15910
+ async function render() {
15911
+ const root = document.getElementById('root');
15912
+ try {
15913
+ const res = await fetch('/api/v1/workflow/definitions');
15914
+ const json = await res.json();
15915
+ const items = json.items || json.data || [];
15916
+ let html = '<div style="padding:40px;max-width:960px;margin:0 auto;font-family:-apple-system,BlinkMacSystemFont,sans-serif">';
15917
+ html += '<h1 style="margin-bottom:8px">MindMatrix Dev</h1>';
15918
+ html += '<p style="color:#666;margin-bottom:24px">' + items.length + ' definition(s) deployed</p>';
15919
+ if (items.length === 0) {
15920
+ html += '<div style="text-align:center;padding:60px 20px;color:#888"><p>No definitions yet.</p><p style="margin-top:8px;font-size:13px">Edit your model files and save.</p></div>';
15921
+ }
15922
+ for (const def of items) {
15923
+ html += '<div style="border:1px solid #e0e0e0;border-radius:8px;padding:16px;margin-bottom:12px;background:#fff">';
15924
+ html += '<h3 style="margin-bottom:4px">' + (def.name || def.slug || 'Unnamed') + '</h3>';
15925
+ html += '<p style="color:#888;font-size:13px">slug: ' + (def.slug || '?') + ' | states: ' + (def.states?.length || 0) + ' | fields: ' + (def.fields?.length || 0) + '</p>';
15926
+ html += '</div>';
15927
+ }
15928
+ html += '</div>';
15929
+ root.innerHTML = html;
15930
+ } catch (e) {
15931
+ root.innerHTML = '<div style="padding:40px"><h1>MindMatrix Dev</h1><p style="color:#c00;margin-top:8px">API Error: ' + e.message + '</p></div>';
15932
+ }
15944
15933
  }
15945
-
15946
- createRoot(document.getElementById('root')).render(React.createElement(App));
15934
+ render();
15935
+ setInterval(render, 3000);
15947
15936
  </script>
15948
15937
  </body>
15949
15938
  </html>`;
15950
- const htmlPlugin = {
15951
- name: "mindmatrix-dev-html",
15952
- // Return a function from configureServer → runs as POST-middleware,
15953
- // after Vite's built-in static file serving and SPA fallback.
15954
- configureServer(server) {
15955
- return () => {
15956
- server.middlewares.use(async (req, res, next) => {
15957
- const url = req.url ?? "";
15958
- if (url !== "/" && url !== "/index.html" && !url.startsWith("/?")) return next();
15959
- const accept = req.headers?.accept ?? "";
15960
- if (!accept.includes("text/html")) return next();
15961
- try {
15962
- const transformed = await server.transformIndexHtml(url, devHtml);
15963
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
15964
- res.end(transformed);
15965
- } catch (e) {
15966
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
15967
- res.end(devHtml);
15968
- }
15969
- });
15970
- };
15971
- }
15972
- };
15939
+ const { mkdtempSync, writeFileSync: writeFileSync10 } = await import("fs");
15940
+ const { join: join8 } = await import("path");
15941
+ const { tmpdir } = await import("os");
15942
+ const devRoot = mkdtempSync(join8(tmpdir(), "mm-dev-"));
15943
+ writeFileSync10(join8(devRoot, "index.html"), devHtml, "utf-8");
15973
15944
  let deployInFlight = false;
15974
15945
  const compileDeployPlugin = {
15975
15946
  name: "mindmatrix-dev-compile-deploy",
@@ -16000,14 +15971,16 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
16000
15971
  }
16001
15972
  };
16002
15973
  const viteConfig = {
16003
- root: process.cwd(),
16004
- // 'custom' suppresses "Could not auto-determine entry point" warning
16005
- // since we serve a virtual index.html via the htmlPlugin.
16006
- appType: "custom",
15974
+ // Physical index.html lives in a temp dir so Vite serves it natively.
15975
+ root: devRoot,
15976
+ // Pre-bundle React so Vite doesn't warn about missing entry point.
15977
+ optimizeDeps: { include: ["react", "react-dom/client"] },
16007
15978
  server: {
16008
15979
  port,
16009
15980
  open,
16010
15981
  host: true,
15982
+ // Allow serving files from the real project directory (fs.allow).
15983
+ fs: { allow: [devRoot, process.cwd(), ".."] },
16011
15984
  proxy: {
16012
15985
  "/api": { target: proxyTarget, changeOrigin: true, secure: true, ws: true },
16013
15986
  "/health": { target: proxyTarget, changeOrigin: true, secure: true },
@@ -16015,7 +15988,6 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
16015
15988
  }
16016
15989
  },
16017
15990
  plugins: [
16018
- htmlPlugin,
16019
15991
  mindmatrixReact(pluginOpts),
16020
15992
  compileDeployPlugin,
16021
15993
  devPlayerPlugin,
@@ -16079,6 +16051,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
16079
16051
  if (localServer) {
16080
16052
  await localServer.close();
16081
16053
  }
16054
+ try {
16055
+ const { rmSync } = await import("fs");
16056
+ rmSync(devRoot, { recursive: true, force: true });
16057
+ } catch {
16058
+ }
16082
16059
  }
16083
16060
  };
16084
16061
  }
@@ -16389,6 +16366,110 @@ export default defineBlueprint({
16389
16366
  });
16390
16367
  `;
16391
16368
  }
16369
+ function generateIndexHtml(name) {
16370
+ const title = toTitleCase(name);
16371
+ return `<!DOCTYPE html>
16372
+ <html lang="en">
16373
+ <head>
16374
+ <meta charset="UTF-8">
16375
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16376
+ <title>${title} \u2014 MindMatrix Dev</title>
16377
+ <style>
16378
+ * { margin: 0; padding: 0; box-sizing: border-box; }
16379
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #fafafa; color: #111; }
16380
+ #root { min-height: 100vh; padding: 40px; max-width: 960px; margin: 0 auto; }
16381
+ h1 { font-size: 24px; margin-bottom: 8px; }
16382
+ .subtitle { color: #666; margin-bottom: 24px; }
16383
+ .card { border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px; margin-bottom: 12px; background: #fff; }
16384
+ .card h3 { font-size: 16px; margin-bottom: 4px; }
16385
+ .card .meta { color: #888; font-size: 13px; }
16386
+ .badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
16387
+ .badge-state { background: #e3f2fd; color: #1565c0; }
16388
+ .empty { text-align: center; padding: 60px 20px; color: #888; }
16389
+ .error { color: #c62828; background: #ffebee; padding: 16px; border-radius: 8px; margin-bottom: 16px; }
16390
+ .actions { display: flex; gap: 8px; margin-top: 8px; }
16391
+ .btn { padding: 6px 12px; border-radius: 4px; border: 1px solid #ddd; background: #fff; cursor: pointer; font-size: 13px; }
16392
+ .btn:hover { background: #f5f5f5; }
16393
+ .btn-primary { background: #1976d2; color: #fff; border-color: #1976d2; }
16394
+ .btn-primary:hover { background: #1565c0; }
16395
+ </style>
16396
+ </head>
16397
+ <body>
16398
+ <div id="root">
16399
+ <h1>${title}</h1>
16400
+ <p class="subtitle">Loading...</p>
16401
+ </div>
16402
+ <script type="module">
16403
+ const API = '/api/v1';
16404
+
16405
+ async function api(path, opts) {
16406
+ const res = await fetch(API + path, {
16407
+ headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer dev-local' },
16408
+ ...opts,
16409
+ });
16410
+ return res.json();
16411
+ }
16412
+
16413
+ async function render() {
16414
+ const root = document.getElementById('root');
16415
+ try {
16416
+ const defs = await api('/workflow/definitions');
16417
+ const items = defs.items || defs.data || [];
16418
+
16419
+ let html = '<h1>${title}</h1>';
16420
+ html += '<p class="subtitle">' + items.length + ' definition(s) deployed</p>';
16421
+
16422
+ if (items.length === 0) {
16423
+ html += '<div class="empty"><p>No definitions deployed yet.</p><p style="margin-top:8px;font-size:13px">Edit your model files and save \u2014 mmrc dev will auto-compile and deploy.</p></div>';
16424
+ }
16425
+
16426
+ for (const def of items) {
16427
+ const states = def.states || [];
16428
+ const fields = def.fields || [];
16429
+ const transitions = def.transitions || [];
16430
+ html += '<div class="card">';
16431
+ html += '<h3>' + (def.name || def.slug || 'Unnamed') + '</h3>';
16432
+ html += '<p class="meta">' + states.length + ' states \xB7 ' + fields.length + ' fields \xB7 ' + transitions.length + ' transitions</p>';
16433
+ html += '<div class="actions">';
16434
+ html += '<button class="btn btn-primary" onclick="createInstance(\\'' + def.slug + '\\')">+ Create Instance</button>';
16435
+ html += '</div>';
16436
+ html += '</div>';
16437
+ }
16438
+
16439
+ // Show instances
16440
+ const instances = await api('/workflow/instances');
16441
+ const instItems = instances.items || instances.data || [];
16442
+ if (instItems.length > 0) {
16443
+ html += '<h2 style="margin-top:32px;margin-bottom:12px">Instances (' + instItems.length + ')</h2>';
16444
+ for (const inst of instItems) {
16445
+ html += '<div class="card">';
16446
+ html += '<h3>' + (inst.definition_slug || '?') + ' <span class="badge badge-state">' + (inst.current_state || inst.state || '?') + '</span></h3>';
16447
+ html += '<p class="meta">ID: ' + inst.id + '</p>';
16448
+ html += '</div>';
16449
+ }
16450
+ }
16451
+
16452
+ root.innerHTML = html;
16453
+ } catch (e) {
16454
+ root.innerHTML = '<h1>${title}</h1><div class="error">API Error: ' + e.message + '</div>';
16455
+ }
16456
+ }
16457
+
16458
+ window.createInstance = async function(slug) {
16459
+ await api('/workflow/instances', {
16460
+ method: 'POST',
16461
+ body: JSON.stringify({ definition_slug: slug, state_data: { title: 'New Item', priority: 'medium' } }),
16462
+ });
16463
+ render();
16464
+ };
16465
+
16466
+ render();
16467
+ // Auto-refresh every 3 seconds
16468
+ setInterval(render, 3000);
16469
+ </script>
16470
+ </body>
16471
+ </html>`;
16472
+ }
16392
16473
  function generateModel(name) {
16393
16474
  const modelSlug = `${name}-item`;
16394
16475
  const pascal = toPascalCase2(name);
@@ -16716,6 +16797,7 @@ async function init(options) {
16716
16797
  ["mm.config.ts", generateMmConfig2(name, options)],
16717
16798
  ["mmrc.config.ts", generateMmrcConfig2()],
16718
16799
  [".gitignore", generateGitignore()],
16800
+ ["index.html", generateIndexHtml(name)],
16719
16801
  ["models/item.ts", generateModel(name)],
16720
16802
  ["app/layout.tsx", generateLayout(name)],
16721
16803
  ["app/page.tsx", generatePage(name)]
@@ -19383,7 +19465,7 @@ async function main() {
19383
19465
  const open = hasFlag("--open") || devCfg.open === true;
19384
19466
  const apiPort = getFlag("--api-port") ? parseInt(getFlag("--api-port"), 10) : 4200;
19385
19467
  let engineProcess = null;
19386
- if (isLocal) {
19468
+ if (isLocal && hasFlag("--local")) {
19387
19469
  const { findEngineBinary: findEngineBinary2, installEngine: installEngine2, verifyBinary: verifyBinary2 } = await Promise.resolve().then(() => (init_engine_binary(), engine_binary_exports));
19388
19470
  let resolution = findEngineBinary2(getFlag("--binary"));
19389
19471
  if (resolution.path) {
@@ -19408,15 +19490,62 @@ async function main() {
19408
19490
  console.log("[mmrc] Dev server will connect to a remote API or start in-memory mode.");
19409
19491
  console.log("[mmrc] (For full local mode: `mmrc engine install` or `mmrc engine build`)\n");
19410
19492
  } else {
19493
+ try {
19494
+ const { execSync: ex } = require("child_process");
19495
+ const pid = ex(`lsof -ti :${apiPort} 2>/dev/null`, { encoding: "utf-8" }).trim();
19496
+ if (pid) {
19497
+ console.log(`[mmrc] Killing stale process on port ${apiPort} (PID ${pid})`);
19498
+ ex(`kill -9 ${pid}`, { stdio: "ignore" });
19499
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms));
19500
+ await wait(1e3);
19501
+ }
19502
+ } catch {
19503
+ }
19504
+ console.log(`[mmrc] Starting local PostgreSQL via Docker...`);
19505
+ try {
19506
+ const { execSync: execS } = require("child_process");
19507
+ const running = execS("docker ps -q -f name=mm-dev-pg", { encoding: "utf-8" }).trim();
19508
+ if (!running) {
19509
+ execS("docker run -d --name mm-dev-pg -p 5433:5432 -e POSTGRES_DB=mm_dev -e POSTGRES_USER=mm -e POSTGRES_PASSWORD=mm -e POSTGRES_HOST_AUTH_METHOD=trust postgres:16-alpine 2>/dev/null || docker start mm-dev-pg 2>/dev/null", { stdio: "pipe" });
19510
+ console.log("[mmrc] PostgreSQL starting (port 5433)...");
19511
+ for (let i = 0; i < 20; i++) {
19512
+ try {
19513
+ execS("docker exec mm-dev-pg pg_isready -U mm 2>/dev/null", { stdio: "pipe" });
19514
+ break;
19515
+ } catch {
19516
+ await new Promise((r) => setTimeout(r, 500));
19517
+ }
19518
+ }
19519
+ }
19520
+ console.log("[mmrc] PostgreSQL ready");
19521
+ } catch (e) {
19522
+ console.log("[mmrc] Docker not available \u2014 using SQLite (some features may be limited)");
19523
+ }
19411
19524
  console.log(`[mmrc] Starting local engine: ${resolution.path} (${resolution.source})`);
19412
19525
  const { spawn: spawnProcess } = require("child_process");
19413
- engineProcess = spawnProcess(resolution.path, ["--dev"], {
19526
+ let dbUrl;
19527
+ try {
19528
+ const { execSync: execS2 } = require("child_process");
19529
+ const pgRunning = execS2("docker ps -q -f name=mm-dev-pg", { encoding: "utf-8" }).trim();
19530
+ if (pgRunning) {
19531
+ dbUrl = "postgres://mm:mm@localhost:5433/mm_dev";
19532
+ }
19533
+ } catch {
19534
+ }
19535
+ const engineArgs = dbUrl ? [] : ["--dev"];
19536
+ const engineEnv = {
19537
+ ...process.env,
19538
+ PORT: String(apiPort),
19539
+ RUST_LOG: "mm_api=info,mm_storage=info",
19540
+ JWT_SECRET: "dev-secret-do-not-use-in-production",
19541
+ MM_DEV_MODE: "1"
19542
+ };
19543
+ if (dbUrl) {
19544
+ engineEnv.DATABASE_URL = dbUrl;
19545
+ }
19546
+ engineProcess = spawnProcess(resolution.path, engineArgs, {
19414
19547
  stdio: ["ignore", "pipe", "pipe"],
19415
- env: {
19416
- ...process.env,
19417
- PORT: String(apiPort),
19418
- RUST_LOG: "mm_api=info,mm_storage=info"
19419
- },
19548
+ env: engineEnv,
19420
19549
  cwd: process.cwd()
19421
19550
  });
19422
19551
  if (engineProcess.stdout) {