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

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-NUPJYPFU.mjs → chunk-6LAII7OP.mjs} +79 -1
  2. package/dist/{chunk-GVCJJX7E.mjs → chunk-FPAMQXKB.mjs} +14 -18
  3. package/dist/cli/index.js +175 -35
  4. package/dist/cli/index.mjs +55 -8
  5. package/dist/dev-server.js +16 -28
  6. package/dist/dev-server.mjs +1 -1
  7. package/dist/index.js +16 -28
  8. package/dist/index.mjs +1 -1
  9. package/dist/{init-2CRSUGV5.mjs → init-CJCDWI33.mjs} +119 -0
  10. package/package.json +2 -2
  11. package/dist/chunk-26U577GB.mjs +0 -3465
  12. package/dist/chunk-2FBDFAX6.mjs +0 -2362
  13. package/dist/chunk-2L4QSMXG.mjs +0 -175
  14. package/dist/chunk-2REDFOER.mjs +0 -931
  15. package/dist/chunk-3USIFFE4.mjs +0 -2190
  16. package/dist/chunk-45YMGEVT.mjs +0 -186
  17. package/dist/chunk-46YKSHQR.mjs +0 -175
  18. package/dist/chunk-4FN2AISW.mjs +0 -148
  19. package/dist/chunk-4OPI5L7G.mjs +0 -2593
  20. package/dist/chunk-4RYTKOOJ.mjs +0 -186
  21. package/dist/chunk-4XHK6FWL.mjs +0 -2058
  22. package/dist/chunk-52XHYD2V.mjs +0 -214
  23. package/dist/chunk-5FTDWKHH.mjs +0 -244
  24. package/dist/chunk-5GUFFFGL.mjs +0 -148
  25. package/dist/chunk-5RKTOVR5.mjs +0 -244
  26. package/dist/chunk-5VNJ7C6N.mjs +0 -154
  27. package/dist/chunk-5YDMOO4X.mjs +0 -214
  28. package/dist/chunk-64ZWEMLJ.mjs +0 -148
  29. package/dist/chunk-6CQOAAMV.mjs +0 -1803
  30. package/dist/chunk-6SEVAAVT.mjs +0 -3516
  31. package/dist/chunk-6XP4KSWQ.mjs +0 -2190
  32. package/dist/chunk-6YLR5ZDA.mjs +0 -2829
  33. package/dist/chunk-72QWL54I.mjs +0 -175
  34. package/dist/chunk-7B4TRI7C.mjs +0 -4835
  35. package/dist/chunk-7JRAEFRB.mjs +0 -7510
  36. package/dist/chunk-7ZKGHTNB.mjs +0 -4952
  37. package/dist/chunk-AOGY2GK6.mjs +0 -3292
  38. package/dist/chunk-AXXUXRNA.mjs +0 -1434
  39. package/dist/chunk-CHLVKMQW.mjs +0 -175
  40. package/dist/chunk-CKGOZAB7.mjs +0 -939
  41. package/dist/chunk-D34RAZUX.mjs +0 -2223
  42. package/dist/chunk-DE3ZGQAC.mjs +0 -148
  43. package/dist/chunk-DMCY3BBG.mjs +0 -1933
  44. package/dist/chunk-DPIK3PJS.mjs +0 -244
  45. package/dist/chunk-E5IVH4RE.mjs +0 -186
  46. package/dist/chunk-E6FZNUR5.mjs +0 -4953
  47. package/dist/chunk-EJRBDQDP.mjs +0 -2607
  48. package/dist/chunk-ELO4TXJL.mjs +0 -186
  49. package/dist/chunk-EO6SYNCG.mjs +0 -175
  50. package/dist/chunk-EQGA6A6D.mjs +0 -121
  51. package/dist/chunk-EY2CSXYA.mjs +0 -822
  52. package/dist/chunk-FIQ65CDR.mjs +0 -925
  53. package/dist/chunk-FKRO52XH.mjs +0 -3446
  54. package/dist/chunk-FL4YAKU6.mjs +0 -4941
  55. package/dist/chunk-FOZXJFAR.mjs +0 -186
  56. package/dist/chunk-FX6URXWN.mjs +0 -186
  57. package/dist/chunk-FYT47UBU.mjs +0 -5076
  58. package/dist/chunk-G7SMOWOL.mjs +0 -828
  59. package/dist/chunk-GCLGPOJZ.mjs +0 -148
  60. package/dist/chunk-GGB4G5YY.mjs +0 -175
  61. package/dist/chunk-GXB4JOP7.mjs +0 -5072
  62. package/dist/chunk-HFXOUMTD.mjs +0 -175
  63. package/dist/chunk-HLRGCCIL.mjs +0 -4839
  64. package/dist/chunk-HOIUP6IF.mjs +0 -690
  65. package/dist/chunk-HRYR54PT.mjs +0 -175
  66. package/dist/chunk-HWIZ47US.mjs +0 -214
  67. package/dist/chunk-I3AU7GRD.mjs +0 -120
  68. package/dist/chunk-IB7MNPQL.mjs +0 -4953
  69. package/dist/chunk-ICSIHQCG.mjs +0 -148
  70. package/dist/chunk-ILFGMUVD.mjs +0 -1933
  71. package/dist/chunk-IPTX5MJU.mjs +0 -3223
  72. package/dist/chunk-ITGUSH2Z.mjs +0 -2783
  73. package/dist/chunk-IXHBCAMF.mjs +0 -3306
  74. package/dist/chunk-J7JUAHS4.mjs +0 -186
  75. package/dist/chunk-J7TWJ3TM.mjs +0 -2784
  76. package/dist/chunk-JDPLDGVF.mjs +0 -4810
  77. package/dist/chunk-JLA5VNQ3.mjs +0 -186
  78. package/dist/chunk-JQLWFCTM.mjs +0 -214
  79. package/dist/chunk-K53XP2DL.mjs +0 -148
  80. package/dist/chunk-K5HX2SVL.mjs +0 -1902
  81. package/dist/chunk-KFGYOOVS.mjs +0 -214
  82. package/dist/chunk-KFJJCQAL.mjs +0 -148
  83. package/dist/chunk-KFVVOS5N.mjs +0 -925
  84. package/dist/chunk-KJUIIEQE.mjs +0 -186
  85. package/dist/chunk-KNWTHRVQ.mjs +0 -175
  86. package/dist/chunk-KSG4XSZF.mjs +0 -175
  87. package/dist/chunk-L2OZ4CDV.mjs +0 -113
  88. package/dist/chunk-LF5N6DOU.mjs +0 -175
  89. package/dist/chunk-LJQCM2IM.mjs +0 -214
  90. package/dist/chunk-MIZV3TAN.mjs +0 -3293
  91. package/dist/chunk-NKKLQE5V.mjs +0 -148
  92. package/dist/chunk-NOW23XFZ.mjs +0 -186
  93. package/dist/chunk-NRXQKQ74.mjs +0 -148
  94. package/dist/chunk-NTB7OEX2.mjs +0 -2918
  95. package/dist/chunk-NW6555WJ.mjs +0 -186
  96. package/dist/chunk-O4AUS7EU.mjs +0 -148
  97. package/dist/chunk-OMZE6VLQ.mjs +0 -214
  98. package/dist/chunk-OPJKP747.mjs +0 -7506
  99. package/dist/chunk-OWI6XWCD.mjs +0 -3375
  100. package/dist/chunk-P4BR7WVO.mjs +0 -2190
  101. package/dist/chunk-PRUMNNDI.mjs +0 -3192
  102. package/dist/chunk-QQHVYH2X.mjs +0 -244
  103. package/dist/chunk-QTBD5B3F.mjs +0 -148
  104. package/dist/chunk-R57T26RR.mjs +0 -734
  105. package/dist/chunk-S5QLWLLT.mjs +0 -186
  106. package/dist/chunk-SCWGT2FY.mjs +0 -2190
  107. package/dist/chunk-SKSDPPNT.mjs +0 -3788
  108. package/dist/chunk-SMKJUSB3.mjs +0 -2190
  109. package/dist/chunk-SP2YUS33.mjs +0 -186
  110. package/dist/chunk-SU4E6E7B.mjs +0 -3153
  111. package/dist/chunk-SYUUKW5A.mjs +0 -3379
  112. package/dist/chunk-THFYE5ZX.mjs +0 -244
  113. package/dist/chunk-UBDNXVL2.mjs +0 -801
  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
@@ -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;
package/dist/cli/index.js CHANGED
@@ -15947,29 +15947,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
15947
15947
  </script>
15948
15948
  </body>
15949
15949
  </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
- };
15950
+ const { mkdtempSync, writeFileSync: writeFileSync10 } = await import("fs");
15951
+ const { join: join8 } = await import("path");
15952
+ const { tmpdir } = await import("os");
15953
+ const devRoot = mkdtempSync(join8(tmpdir(), "mm-dev-"));
15954
+ writeFileSync10(join8(devRoot, "index.html"), devHtml, "utf-8");
15973
15955
  let deployInFlight = false;
15974
15956
  const compileDeployPlugin = {
15975
15957
  name: "mindmatrix-dev-compile-deploy",
@@ -16000,14 +15982,16 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
16000
15982
  }
16001
15983
  };
16002
15984
  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",
15985
+ // Physical index.html lives in a temp dir so Vite serves it natively.
15986
+ root: devRoot,
15987
+ // Pre-bundle React so Vite doesn't warn about missing entry point.
15988
+ optimizeDeps: { include: ["react", "react-dom/client"] },
16007
15989
  server: {
16008
15990
  port,
16009
15991
  open,
16010
15992
  host: true,
15993
+ // Allow serving files from the real project directory (fs.allow).
15994
+ fs: { allow: [devRoot, process.cwd(), ".."] },
16011
15995
  proxy: {
16012
15996
  "/api": { target: proxyTarget, changeOrigin: true, secure: true, ws: true },
16013
15997
  "/health": { target: proxyTarget, changeOrigin: true, secure: true },
@@ -16015,7 +15999,6 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
16015
15999
  }
16016
16000
  },
16017
16001
  plugins: [
16018
- htmlPlugin,
16019
16002
  mindmatrixReact(pluginOpts),
16020
16003
  compileDeployPlugin,
16021
16004
  devPlayerPlugin,
@@ -16079,6 +16062,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
16079
16062
  if (localServer) {
16080
16063
  await localServer.close();
16081
16064
  }
16065
+ try {
16066
+ const { rmSync } = await import("fs");
16067
+ rmSync(devRoot, { recursive: true, force: true });
16068
+ } catch {
16069
+ }
16082
16070
  }
16083
16071
  };
16084
16072
  }
@@ -16389,6 +16377,110 @@ export default defineBlueprint({
16389
16377
  });
16390
16378
  `;
16391
16379
  }
16380
+ function generateIndexHtml(name) {
16381
+ const title = toTitleCase(name);
16382
+ return `<!DOCTYPE html>
16383
+ <html lang="en">
16384
+ <head>
16385
+ <meta charset="UTF-8">
16386
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16387
+ <title>${title} \u2014 MindMatrix Dev</title>
16388
+ <style>
16389
+ * { margin: 0; padding: 0; box-sizing: border-box; }
16390
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #fafafa; color: #111; }
16391
+ #root { min-height: 100vh; padding: 40px; max-width: 960px; margin: 0 auto; }
16392
+ h1 { font-size: 24px; margin-bottom: 8px; }
16393
+ .subtitle { color: #666; margin-bottom: 24px; }
16394
+ .card { border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px; margin-bottom: 12px; background: #fff; }
16395
+ .card h3 { font-size: 16px; margin-bottom: 4px; }
16396
+ .card .meta { color: #888; font-size: 13px; }
16397
+ .badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
16398
+ .badge-state { background: #e3f2fd; color: #1565c0; }
16399
+ .empty { text-align: center; padding: 60px 20px; color: #888; }
16400
+ .error { color: #c62828; background: #ffebee; padding: 16px; border-radius: 8px; margin-bottom: 16px; }
16401
+ .actions { display: flex; gap: 8px; margin-top: 8px; }
16402
+ .btn { padding: 6px 12px; border-radius: 4px; border: 1px solid #ddd; background: #fff; cursor: pointer; font-size: 13px; }
16403
+ .btn:hover { background: #f5f5f5; }
16404
+ .btn-primary { background: #1976d2; color: #fff; border-color: #1976d2; }
16405
+ .btn-primary:hover { background: #1565c0; }
16406
+ </style>
16407
+ </head>
16408
+ <body>
16409
+ <div id="root">
16410
+ <h1>${title}</h1>
16411
+ <p class="subtitle">Loading...</p>
16412
+ </div>
16413
+ <script type="module">
16414
+ const API = '/api/v1';
16415
+
16416
+ async function api(path, opts) {
16417
+ const res = await fetch(API + path, {
16418
+ headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer dev-local' },
16419
+ ...opts,
16420
+ });
16421
+ return res.json();
16422
+ }
16423
+
16424
+ async function render() {
16425
+ const root = document.getElementById('root');
16426
+ try {
16427
+ const defs = await api('/workflow/definitions');
16428
+ const items = defs.items || defs.data || [];
16429
+
16430
+ let html = '<h1>${title}</h1>';
16431
+ html += '<p class="subtitle">' + items.length + ' definition(s) deployed</p>';
16432
+
16433
+ if (items.length === 0) {
16434
+ 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>';
16435
+ }
16436
+
16437
+ for (const def of items) {
16438
+ const states = def.states || [];
16439
+ const fields = def.fields || [];
16440
+ const transitions = def.transitions || [];
16441
+ html += '<div class="card">';
16442
+ html += '<h3>' + (def.name || def.slug || 'Unnamed') + '</h3>';
16443
+ html += '<p class="meta">' + states.length + ' states \xB7 ' + fields.length + ' fields \xB7 ' + transitions.length + ' transitions</p>';
16444
+ html += '<div class="actions">';
16445
+ html += '<button class="btn btn-primary" onclick="createInstance(\\'' + def.slug + '\\')">+ Create Instance</button>';
16446
+ html += '</div>';
16447
+ html += '</div>';
16448
+ }
16449
+
16450
+ // Show instances
16451
+ const instances = await api('/workflow/instances');
16452
+ const instItems = instances.items || instances.data || [];
16453
+ if (instItems.length > 0) {
16454
+ html += '<h2 style="margin-top:32px;margin-bottom:12px">Instances (' + instItems.length + ')</h2>';
16455
+ for (const inst of instItems) {
16456
+ html += '<div class="card">';
16457
+ html += '<h3>' + (inst.definition_slug || '?') + ' <span class="badge badge-state">' + (inst.current_state || inst.state || '?') + '</span></h3>';
16458
+ html += '<p class="meta">ID: ' + inst.id + '</p>';
16459
+ html += '</div>';
16460
+ }
16461
+ }
16462
+
16463
+ root.innerHTML = html;
16464
+ } catch (e) {
16465
+ root.innerHTML = '<h1>${title}</h1><div class="error">API Error: ' + e.message + '</div>';
16466
+ }
16467
+ }
16468
+
16469
+ window.createInstance = async function(slug) {
16470
+ await api('/workflow/instances', {
16471
+ method: 'POST',
16472
+ body: JSON.stringify({ definition_slug: slug, state_data: { title: 'New Item', priority: 'medium' } }),
16473
+ });
16474
+ render();
16475
+ };
16476
+
16477
+ render();
16478
+ // Auto-refresh every 3 seconds
16479
+ setInterval(render, 3000);
16480
+ </script>
16481
+ </body>
16482
+ </html>`;
16483
+ }
16392
16484
  function generateModel(name) {
16393
16485
  const modelSlug = `${name}-item`;
16394
16486
  const pascal = toPascalCase2(name);
@@ -16716,6 +16808,7 @@ async function init(options) {
16716
16808
  ["mm.config.ts", generateMmConfig2(name, options)],
16717
16809
  ["mmrc.config.ts", generateMmrcConfig2()],
16718
16810
  [".gitignore", generateGitignore()],
16811
+ ["index.html", generateIndexHtml(name)],
16719
16812
  ["models/item.ts", generateModel(name)],
16720
16813
  ["app/layout.tsx", generateLayout(name)],
16721
16814
  ["app/page.tsx", generatePage(name)]
@@ -19383,7 +19476,7 @@ async function main() {
19383
19476
  const open = hasFlag("--open") || devCfg.open === true;
19384
19477
  const apiPort = getFlag("--api-port") ? parseInt(getFlag("--api-port"), 10) : 4200;
19385
19478
  let engineProcess = null;
19386
- if (isLocal) {
19479
+ if (isLocal && hasFlag("--local")) {
19387
19480
  const { findEngineBinary: findEngineBinary2, installEngine: installEngine2, verifyBinary: verifyBinary2 } = await Promise.resolve().then(() => (init_engine_binary(), engine_binary_exports));
19388
19481
  let resolution = findEngineBinary2(getFlag("--binary"));
19389
19482
  if (resolution.path) {
@@ -19408,15 +19501,62 @@ async function main() {
19408
19501
  console.log("[mmrc] Dev server will connect to a remote API or start in-memory mode.");
19409
19502
  console.log("[mmrc] (For full local mode: `mmrc engine install` or `mmrc engine build`)\n");
19410
19503
  } else {
19504
+ try {
19505
+ const { execSync: ex } = require("child_process");
19506
+ const pid = ex(`lsof -ti :${apiPort} 2>/dev/null`, { encoding: "utf-8" }).trim();
19507
+ if (pid) {
19508
+ console.log(`[mmrc] Killing stale process on port ${apiPort} (PID ${pid})`);
19509
+ ex(`kill -9 ${pid}`, { stdio: "ignore" });
19510
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms));
19511
+ await wait(1e3);
19512
+ }
19513
+ } catch {
19514
+ }
19515
+ console.log(`[mmrc] Starting local PostgreSQL via Docker...`);
19516
+ try {
19517
+ const { execSync: execS } = require("child_process");
19518
+ const running = execS("docker ps -q -f name=mm-dev-pg", { encoding: "utf-8" }).trim();
19519
+ if (!running) {
19520
+ 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" });
19521
+ console.log("[mmrc] PostgreSQL starting (port 5433)...");
19522
+ for (let i = 0; i < 20; i++) {
19523
+ try {
19524
+ execS("docker exec mm-dev-pg pg_isready -U mm 2>/dev/null", { stdio: "pipe" });
19525
+ break;
19526
+ } catch {
19527
+ await new Promise((r) => setTimeout(r, 500));
19528
+ }
19529
+ }
19530
+ }
19531
+ console.log("[mmrc] PostgreSQL ready");
19532
+ } catch (e) {
19533
+ console.log("[mmrc] Docker not available \u2014 using SQLite (some features may be limited)");
19534
+ }
19411
19535
  console.log(`[mmrc] Starting local engine: ${resolution.path} (${resolution.source})`);
19412
19536
  const { spawn: spawnProcess } = require("child_process");
19413
- engineProcess = spawnProcess(resolution.path, ["--dev"], {
19537
+ let dbUrl;
19538
+ try {
19539
+ const { execSync: execS2 } = require("child_process");
19540
+ const pgRunning = execS2("docker ps -q -f name=mm-dev-pg", { encoding: "utf-8" }).trim();
19541
+ if (pgRunning) {
19542
+ dbUrl = "postgres://mm:mm@localhost:5433/mm_dev";
19543
+ }
19544
+ } catch {
19545
+ }
19546
+ const engineArgs = dbUrl ? [] : ["--dev"];
19547
+ const engineEnv = {
19548
+ ...process.env,
19549
+ PORT: String(apiPort),
19550
+ RUST_LOG: "mm_api=info,mm_storage=info",
19551
+ JWT_SECRET: "dev-secret-do-not-use-in-production",
19552
+ MM_DEV_MODE: "1"
19553
+ };
19554
+ if (dbUrl) {
19555
+ engineEnv.DATABASE_URL = dbUrl;
19556
+ }
19557
+ engineProcess = spawnProcess(resolution.path, engineArgs, {
19414
19558
  stdio: ["ignore", "pipe", "pipe"],
19415
- env: {
19416
- ...process.env,
19417
- PORT: String(apiPort),
19418
- RUST_LOG: "mm_api=info,mm_storage=info"
19419
- },
19559
+ env: engineEnv,
19420
19560
  cwd: process.cwd()
19421
19561
  });
19422
19562
  if (engineProcess.stdout) {
@@ -347,7 +347,7 @@ async function main() {
347
347
  const open = hasFlag("--open") || devCfg.open === true;
348
348
  const apiPort = getFlag("--api-port") ? parseInt(getFlag("--api-port"), 10) : 4200;
349
349
  let engineProcess = null;
350
- if (isLocal) {
350
+ if (isLocal && hasFlag("--local")) {
351
351
  const { findEngineBinary, installEngine, verifyBinary } = await import("../engine-binary-FKTZAR56.mjs");
352
352
  let resolution = findEngineBinary(getFlag("--binary"));
353
353
  if (resolution.path) {
@@ -372,15 +372,62 @@ async function main() {
372
372
  console.log("[mmrc] Dev server will connect to a remote API or start in-memory mode.");
373
373
  console.log("[mmrc] (For full local mode: `mmrc engine install` or `mmrc engine build`)\n");
374
374
  } else {
375
+ try {
376
+ const { execSync: ex } = __require("child_process");
377
+ const pid = ex(`lsof -ti :${apiPort} 2>/dev/null`, { encoding: "utf-8" }).trim();
378
+ if (pid) {
379
+ console.log(`[mmrc] Killing stale process on port ${apiPort} (PID ${pid})`);
380
+ ex(`kill -9 ${pid}`, { stdio: "ignore" });
381
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms));
382
+ await wait(1e3);
383
+ }
384
+ } catch {
385
+ }
386
+ console.log(`[mmrc] Starting local PostgreSQL via Docker...`);
387
+ try {
388
+ const { execSync: execS } = __require("child_process");
389
+ const running = execS("docker ps -q -f name=mm-dev-pg", { encoding: "utf-8" }).trim();
390
+ if (!running) {
391
+ 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" });
392
+ console.log("[mmrc] PostgreSQL starting (port 5433)...");
393
+ for (let i = 0; i < 20; i++) {
394
+ try {
395
+ execS("docker exec mm-dev-pg pg_isready -U mm 2>/dev/null", { stdio: "pipe" });
396
+ break;
397
+ } catch {
398
+ await new Promise((r) => setTimeout(r, 500));
399
+ }
400
+ }
401
+ }
402
+ console.log("[mmrc] PostgreSQL ready");
403
+ } catch (e) {
404
+ console.log("[mmrc] Docker not available \u2014 using SQLite (some features may be limited)");
405
+ }
375
406
  console.log(`[mmrc] Starting local engine: ${resolution.path} (${resolution.source})`);
376
407
  const { spawn: spawnProcess } = __require("child_process");
377
- engineProcess = spawnProcess(resolution.path, ["--dev"], {
408
+ let dbUrl;
409
+ try {
410
+ const { execSync: execS2 } = __require("child_process");
411
+ const pgRunning = execS2("docker ps -q -f name=mm-dev-pg", { encoding: "utf-8" }).trim();
412
+ if (pgRunning) {
413
+ dbUrl = "postgres://mm:mm@localhost:5433/mm_dev";
414
+ }
415
+ } catch {
416
+ }
417
+ const engineArgs = dbUrl ? [] : ["--dev"];
418
+ const engineEnv = {
419
+ ...process.env,
420
+ PORT: String(apiPort),
421
+ RUST_LOG: "mm_api=info,mm_storage=info",
422
+ JWT_SECRET: "dev-secret-do-not-use-in-production",
423
+ MM_DEV_MODE: "1"
424
+ };
425
+ if (dbUrl) {
426
+ engineEnv.DATABASE_URL = dbUrl;
427
+ }
428
+ engineProcess = spawnProcess(resolution.path, engineArgs, {
378
429
  stdio: ["ignore", "pipe", "pipe"],
379
- env: {
380
- ...process.env,
381
- PORT: String(apiPort),
382
- RUST_LOG: "mm_api=info,mm_storage=info"
383
- },
430
+ env: engineEnv,
384
431
  cwd: process.cwd()
385
432
  });
386
433
  if (engineProcess.stdout) {
@@ -564,7 +611,7 @@ async function main() {
564
611
  console.error('[mmrc] Error: name is required\n Usage: mmrc init <name> [--description "..."] [--icon "..."] [--author "..."]');
565
612
  process.exit(1);
566
613
  }
567
- const { init } = await import("../init-DY6SJDRX.mjs");
614
+ const { init } = await import("../init-CJCDWI33.mjs");
568
615
  await init({
569
616
  name,
570
617
  description: getFlag("--description"),
@@ -12450,29 +12450,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
12450
12450
  </script>
12451
12451
  </body>
12452
12452
  </html>`;
12453
- const htmlPlugin = {
12454
- name: "mindmatrix-dev-html",
12455
- // Return a function from configureServer → runs as POST-middleware,
12456
- // after Vite's built-in static file serving and SPA fallback.
12457
- configureServer(server) {
12458
- return () => {
12459
- server.middlewares.use(async (req, res, next) => {
12460
- const url = req.url ?? "";
12461
- if (url !== "/" && url !== "/index.html" && !url.startsWith("/?")) return next();
12462
- const accept = req.headers?.accept ?? "";
12463
- if (!accept.includes("text/html")) return next();
12464
- try {
12465
- const transformed = await server.transformIndexHtml(url, devHtml);
12466
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
12467
- res.end(transformed);
12468
- } catch (e) {
12469
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
12470
- res.end(devHtml);
12471
- }
12472
- });
12473
- };
12474
- }
12475
- };
12453
+ const { mkdtempSync, writeFileSync: writeFileSync5 } = await import("fs");
12454
+ const { join: join4 } = await import("path");
12455
+ const { tmpdir } = await import("os");
12456
+ const devRoot = mkdtempSync(join4(tmpdir(), "mm-dev-"));
12457
+ writeFileSync5(join4(devRoot, "index.html"), devHtml, "utf-8");
12476
12458
  let deployInFlight = false;
12477
12459
  const compileDeployPlugin = {
12478
12460
  name: "mindmatrix-dev-compile-deploy",
@@ -12503,14 +12485,16 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
12503
12485
  }
12504
12486
  };
12505
12487
  const viteConfig = {
12506
- root: process.cwd(),
12507
- // 'custom' suppresses "Could not auto-determine entry point" warning
12508
- // since we serve a virtual index.html via the htmlPlugin.
12509
- appType: "custom",
12488
+ // Physical index.html lives in a temp dir so Vite serves it natively.
12489
+ root: devRoot,
12490
+ // Pre-bundle React so Vite doesn't warn about missing entry point.
12491
+ optimizeDeps: { include: ["react", "react-dom/client"] },
12510
12492
  server: {
12511
12493
  port,
12512
12494
  open,
12513
12495
  host: true,
12496
+ // Allow serving files from the real project directory (fs.allow).
12497
+ fs: { allow: [devRoot, process.cwd(), ".."] },
12514
12498
  proxy: {
12515
12499
  "/api": { target: proxyTarget, changeOrigin: true, secure: true, ws: true },
12516
12500
  "/health": { target: proxyTarget, changeOrigin: true, secure: true },
@@ -12518,7 +12502,6 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
12518
12502
  }
12519
12503
  },
12520
12504
  plugins: [
12521
- htmlPlugin,
12522
12505
  mindmatrixReact(pluginOpts),
12523
12506
  compileDeployPlugin,
12524
12507
  devPlayerPlugin,
@@ -12582,6 +12565,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
12582
12565
  if (localServer) {
12583
12566
  await localServer.close();
12584
12567
  }
12568
+ try {
12569
+ const { rmSync } = await import("fs");
12570
+ rmSync(devRoot, { recursive: true, force: true });
12571
+ } catch {
12572
+ }
12585
12573
  }
12586
12574
  };
12587
12575
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createDevServer
3
- } from "./chunk-GVCJJX7E.mjs";
3
+ } from "./chunk-6LAII7OP.mjs";
4
4
  import "./chunk-BZEXUPDH.mjs";
5
5
  import "./chunk-DNWDIPH2.mjs";
6
6
  import "./chunk-5M7DKKBC.mjs";
package/dist/index.js CHANGED
@@ -14664,29 +14664,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
14664
14664
  </script>
14665
14665
  </body>
14666
14666
  </html>`;
14667
- const htmlPlugin = {
14668
- name: "mindmatrix-dev-html",
14669
- // Return a function from configureServer → runs as POST-middleware,
14670
- // after Vite's built-in static file serving and SPA fallback.
14671
- configureServer(server) {
14672
- return () => {
14673
- server.middlewares.use(async (req, res, next) => {
14674
- const url = req.url ?? "";
14675
- if (url !== "/" && url !== "/index.html" && !url.startsWith("/?")) return next();
14676
- const accept = req.headers?.accept ?? "";
14677
- if (!accept.includes("text/html")) return next();
14678
- try {
14679
- const transformed = await server.transformIndexHtml(url, devHtml);
14680
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
14681
- res.end(transformed);
14682
- } catch (e) {
14683
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
14684
- res.end(devHtml);
14685
- }
14686
- });
14687
- };
14688
- }
14689
- };
14667
+ const { mkdtempSync, writeFileSync: writeFileSync5 } = await import("fs");
14668
+ const { join: join4 } = await import("path");
14669
+ const { tmpdir } = await import("os");
14670
+ const devRoot = mkdtempSync(join4(tmpdir(), "mm-dev-"));
14671
+ writeFileSync5(join4(devRoot, "index.html"), devHtml, "utf-8");
14690
14672
  let deployInFlight = false;
14691
14673
  const compileDeployPlugin = {
14692
14674
  name: "mindmatrix-dev-compile-deploy",
@@ -14717,14 +14699,16 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
14717
14699
  }
14718
14700
  };
14719
14701
  const viteConfig = {
14720
- root: process.cwd(),
14721
- // 'custom' suppresses "Could not auto-determine entry point" warning
14722
- // since we serve a virtual index.html via the htmlPlugin.
14723
- appType: "custom",
14702
+ // Physical index.html lives in a temp dir so Vite serves it natively.
14703
+ root: devRoot,
14704
+ // Pre-bundle React so Vite doesn't warn about missing entry point.
14705
+ optimizeDeps: { include: ["react", "react-dom/client"] },
14724
14706
  server: {
14725
14707
  port,
14726
14708
  open,
14727
14709
  host: true,
14710
+ // Allow serving files from the real project directory (fs.allow).
14711
+ fs: { allow: [devRoot, process.cwd(), ".."] },
14728
14712
  proxy: {
14729
14713
  "/api": { target: proxyTarget, changeOrigin: true, secure: true, ws: true },
14730
14714
  "/health": { target: proxyTarget, changeOrigin: true, secure: true },
@@ -14732,7 +14716,6 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
14732
14716
  }
14733
14717
  },
14734
14718
  plugins: [
14735
- htmlPlugin,
14736
14719
  mindmatrixReact(pluginOpts),
14737
14720
  compileDeployPlugin,
14738
14721
  devPlayerPlugin,
@@ -14796,6 +14779,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
14796
14779
  if (localServer) {
14797
14780
  await localServer.close();
14798
14781
  }
14782
+ try {
14783
+ const { rmSync } = await import("fs");
14784
+ rmSync(devRoot, { recursive: true, force: true });
14785
+ } catch {
14786
+ }
14799
14787
  }
14800
14788
  };
14801
14789
  }