@mmapp/react-compiler 0.1.0-alpha.15 → 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.
- package/dist/{chunk-NUPJYPFU.mjs → chunk-6LAII7OP.mjs} +79 -1
- package/dist/{chunk-UBDNXVL2.mjs → chunk-FPAMQXKB.mjs} +89 -3
- package/dist/cli/index.js +240 -9
- package/dist/cli/index.mjs +57 -9
- package/dist/dev-server.js +79 -1
- package/dist/dev-server.mjs +1 -1
- package/dist/index.js +79 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-2CRSUGV5.mjs → init-CJCDWI33.mjs} +119 -0
- package/package.json +2 -2
- package/dist/chunk-26U577GB.mjs +0 -3465
- package/dist/chunk-2FBDFAX6.mjs +0 -2362
- package/dist/chunk-2L4QSMXG.mjs +0 -175
- package/dist/chunk-2REDFOER.mjs +0 -931
- package/dist/chunk-3USIFFE4.mjs +0 -2190
- package/dist/chunk-45YMGEVT.mjs +0 -186
- package/dist/chunk-46YKSHQR.mjs +0 -175
- package/dist/chunk-4FN2AISW.mjs +0 -148
- package/dist/chunk-4OPI5L7G.mjs +0 -2593
- package/dist/chunk-4RYTKOOJ.mjs +0 -186
- package/dist/chunk-4XHK6FWL.mjs +0 -2058
- package/dist/chunk-52XHYD2V.mjs +0 -214
- package/dist/chunk-5FTDWKHH.mjs +0 -244
- package/dist/chunk-5GUFFFGL.mjs +0 -148
- package/dist/chunk-5RKTOVR5.mjs +0 -244
- package/dist/chunk-5VNJ7C6N.mjs +0 -154
- package/dist/chunk-5YDMOO4X.mjs +0 -214
- package/dist/chunk-64ZWEMLJ.mjs +0 -148
- package/dist/chunk-6CQOAAMV.mjs +0 -1803
- package/dist/chunk-6SEVAAVT.mjs +0 -3516
- package/dist/chunk-6XP4KSWQ.mjs +0 -2190
- package/dist/chunk-6YLR5ZDA.mjs +0 -2829
- package/dist/chunk-72QWL54I.mjs +0 -175
- package/dist/chunk-7B4TRI7C.mjs +0 -4835
- package/dist/chunk-7JRAEFRB.mjs +0 -7510
- package/dist/chunk-7ZKGHTNB.mjs +0 -4952
- package/dist/chunk-AOGY2GK6.mjs +0 -3292
- package/dist/chunk-AXXUXRNA.mjs +0 -1434
- package/dist/chunk-CHLVKMQW.mjs +0 -175
- package/dist/chunk-CKGOZAB7.mjs +0 -939
- package/dist/chunk-D34RAZUX.mjs +0 -2223
- package/dist/chunk-DE3ZGQAC.mjs +0 -148
- package/dist/chunk-DMCY3BBG.mjs +0 -1933
- package/dist/chunk-DPIK3PJS.mjs +0 -244
- package/dist/chunk-E5IVH4RE.mjs +0 -186
- package/dist/chunk-E6FZNUR5.mjs +0 -4953
- package/dist/chunk-EJRBDQDP.mjs +0 -2607
- package/dist/chunk-ELO4TXJL.mjs +0 -186
- package/dist/chunk-EO6SYNCG.mjs +0 -175
- package/dist/chunk-EQGA6A6D.mjs +0 -121
- package/dist/chunk-EY2CSXYA.mjs +0 -822
- package/dist/chunk-FIQ65CDR.mjs +0 -925
- package/dist/chunk-FKRO52XH.mjs +0 -3446
- package/dist/chunk-FL4YAKU6.mjs +0 -4941
- package/dist/chunk-FOZXJFAR.mjs +0 -186
- package/dist/chunk-FX6URXWN.mjs +0 -186
- package/dist/chunk-FYT47UBU.mjs +0 -5076
- package/dist/chunk-G7SMOWOL.mjs +0 -828
- package/dist/chunk-GCLGPOJZ.mjs +0 -148
- package/dist/chunk-GGB4G5YY.mjs +0 -175
- package/dist/chunk-GXB4JOP7.mjs +0 -5072
- package/dist/chunk-HFXOUMTD.mjs +0 -175
- package/dist/chunk-HLRGCCIL.mjs +0 -4839
- package/dist/chunk-HOIUP6IF.mjs +0 -690
- package/dist/chunk-HRYR54PT.mjs +0 -175
- package/dist/chunk-HWIZ47US.mjs +0 -214
- package/dist/chunk-I3AU7GRD.mjs +0 -120
- package/dist/chunk-IB7MNPQL.mjs +0 -4953
- package/dist/chunk-ICSIHQCG.mjs +0 -148
- package/dist/chunk-ILFGMUVD.mjs +0 -1933
- package/dist/chunk-IPTX5MJU.mjs +0 -3223
- package/dist/chunk-ITGUSH2Z.mjs +0 -2783
- package/dist/chunk-IXHBCAMF.mjs +0 -3306
- package/dist/chunk-J7JUAHS4.mjs +0 -186
- package/dist/chunk-J7TWJ3TM.mjs +0 -2784
- package/dist/chunk-JDPLDGVF.mjs +0 -4810
- package/dist/chunk-JLA5VNQ3.mjs +0 -186
- package/dist/chunk-JQLWFCTM.mjs +0 -214
- package/dist/chunk-K53XP2DL.mjs +0 -148
- package/dist/chunk-K5HX2SVL.mjs +0 -1902
- package/dist/chunk-KFGYOOVS.mjs +0 -214
- package/dist/chunk-KFJJCQAL.mjs +0 -148
- package/dist/chunk-KFVVOS5N.mjs +0 -925
- package/dist/chunk-KJUIIEQE.mjs +0 -186
- package/dist/chunk-KNWTHRVQ.mjs +0 -175
- package/dist/chunk-KSG4XSZF.mjs +0 -175
- package/dist/chunk-L2OZ4CDV.mjs +0 -113
- package/dist/chunk-LF5N6DOU.mjs +0 -175
- package/dist/chunk-LJQCM2IM.mjs +0 -214
- package/dist/chunk-MIZV3TAN.mjs +0 -3293
- package/dist/chunk-NKKLQE5V.mjs +0 -148
- package/dist/chunk-NOW23XFZ.mjs +0 -186
- package/dist/chunk-NRXQKQ74.mjs +0 -148
- package/dist/chunk-NTB7OEX2.mjs +0 -2918
- package/dist/chunk-NW6555WJ.mjs +0 -186
- package/dist/chunk-O4AUS7EU.mjs +0 -148
- package/dist/chunk-OMZE6VLQ.mjs +0 -214
- package/dist/chunk-OPJKP747.mjs +0 -7506
- package/dist/chunk-OWI6XWCD.mjs +0 -3375
- package/dist/chunk-P4BR7WVO.mjs +0 -2190
- package/dist/chunk-PRUMNNDI.mjs +0 -3192
- package/dist/chunk-QQHVYH2X.mjs +0 -244
- package/dist/chunk-QTBD5B3F.mjs +0 -148
- package/dist/chunk-R57T26RR.mjs +0 -734
- package/dist/chunk-S5QLWLLT.mjs +0 -186
- package/dist/chunk-SCWGT2FY.mjs +0 -2190
- package/dist/chunk-SKSDPPNT.mjs +0 -3788
- package/dist/chunk-SMKJUSB3.mjs +0 -2190
- package/dist/chunk-SP2YUS33.mjs +0 -186
- package/dist/chunk-SU4E6E7B.mjs +0 -3153
- package/dist/chunk-SYUUKW5A.mjs +0 -3379
- package/dist/chunk-THFYE5ZX.mjs +0 -244
- package/dist/chunk-UDDTWG5J.mjs +0 -734
- package/dist/chunk-UL2XZEMA.mjs +0 -3128
- package/dist/chunk-VCAY2KGM.mjs +0 -175
- package/dist/chunk-VLTKQDJ3.mjs +0 -244
- package/dist/chunk-WBYMW4NQ.mjs +0 -3450
- package/dist/chunk-WECAV6QB.mjs +0 -148
- package/dist/chunk-WMKBXUCE.mjs +0 -3228
- package/dist/chunk-XAJ5BKKL.mjs +0 -4947
- package/dist/chunk-XG2X7AEA.mjs +0 -175
- package/dist/chunk-XG7Z23NQ.mjs +0 -148
- package/dist/chunk-XMWUHQVV.mjs +0 -939
- package/dist/chunk-XWZAOCQ7.mjs +0 -2607
- package/dist/chunk-XZNEDRGN.mjs +0 -3876
- package/dist/chunk-Y6FXYEAI.mjs +0 -10
- package/dist/chunk-Y6MA7ULW.mjs +0 -148
- package/dist/chunk-YFS6JMYO.mjs +0 -3342
- package/dist/chunk-YMS7Q7LG.mjs +0 -214
- package/dist/chunk-Z2G5RZ4H.mjs +0 -186
- package/dist/chunk-Z6AIQ4KL.mjs +0 -113
- package/dist/chunk-ZA37XTGA.mjs +0 -175
- package/dist/chunk-ZE3KCHBM.mjs +0 -2918
- package/dist/config-PL24KEWL.mjs +0 -219
- package/dist/dev-server-Bs_sz2DG.d.mts +0 -111
- package/dist/dev-server-Bs_sz2DG.d.ts +0 -111
- package/dist/dev-server-CjoufJ-u.d.mts +0 -109
- package/dist/dev-server-CjoufJ-u.d.ts +0 -109
- package/dist/dev-server-RmGHIntF.d.mts +0 -113
- package/dist/dev-server-RmGHIntF.d.ts +0 -113
- package/dist/engine-binary-QQUDACBJ.mjs +0 -455
- package/dist/envelope-DD7v0v6E.d.mts +0 -265
- package/dist/envelope-DD7v0v6E.d.ts +0 -265
- package/dist/envelope-vCVjrHlo.d.mts +0 -265
- package/dist/envelope-vCVjrHlo.d.ts +0 -265
- package/dist/index-B5gSgvnd.d.mts +0 -44
- package/dist/index-B5gSgvnd.d.ts +0 -44
- package/dist/index-Bs0MnR54.d.mts +0 -103
- package/dist/index-Bs0MnR54.d.ts +0 -103
- package/dist/index-DR0nNc_f.d.mts +0 -101
- package/dist/index-DR0nNc_f.d.ts +0 -101
- package/dist/index-revho_gS.d.mts +0 -104
- package/dist/index-revho_gS.d.ts +0 -104
- package/dist/init-7FJENUDK.mjs +0 -407
- package/dist/init-7JQMAAXS.mjs +0 -363
- package/dist/init-DQDX3QK6.mjs +0 -369
- package/dist/init-EHO4VQ22.mjs +0 -369
- package/dist/init-IXEE2RCF.mjs +0 -340
- package/dist/init-UC3FWPIW.mjs +0 -367
- package/dist/init-UNSMVKIK.mjs +0 -366
- package/dist/init-UNV5XIDE.mjs +0 -367
- package/dist/project-compiler-2P4N4DR7.mjs +0 -10
- package/dist/project-compiler-D2LCC27O.mjs +0 -10
- package/dist/project-compiler-EGJUTAJU.mjs +0 -10
- package/dist/project-compiler-EJ3GANJE.mjs +0 -10
- package/dist/project-compiler-LOQKVRZJ.mjs +0 -10
- package/dist/project-compiler-NNK32MPG.mjs +0 -10
- package/dist/project-compiler-OP2VVGJQ.mjs +0 -10
- package/dist/project-compiler-RQ6OQKRM.mjs +0 -10
- package/dist/project-compiler-VFR6CSDX.mjs +0 -10
- package/dist/project-compiler-VWNNCHGO.mjs +0 -10
- package/dist/project-compiler-XVAAU4C5.mjs +0 -10
- package/dist/project-compiler-YES5FGMD.mjs +0 -10
- package/dist/project-compiler-ZKMQDLGU.mjs +0 -10
- package/dist/project-decompiler-5GY2KSG4.mjs +0 -7
- package/dist/project-decompiler-FLXCEJHS.mjs +0 -7
- package/dist/project-decompiler-US7GAVIC.mjs +0 -7
- package/dist/project-decompiler-VLPR22QF.mjs +0 -7
- package/dist/pull-A2QUHW4K.mjs +0 -109
- package/dist/pull-FUS5QYZS.mjs +0 -109
- package/dist/pull-JBEQWVPE.mjs +0 -109
- package/dist/pull-LD5ENLGY.mjs +0 -109
- package/dist/pull-P44LDRWB.mjs +0 -109
- package/dist/verify-BYHUKARQ.mjs +0 -1833
- 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
|
-
|
|
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
|
}
|
|
@@ -589,10 +589,10 @@ async function createDevServer(options = {}) {
|
|
|
589
589
|
}
|
|
590
590
|
const {
|
|
591
591
|
port = 5199,
|
|
592
|
-
src = "
|
|
592
|
+
src = ".",
|
|
593
593
|
mode = "infer",
|
|
594
|
-
include = ["**/*.workflow.tsx"],
|
|
595
|
-
outDir = "dist
|
|
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,88 @@ 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 htmlPlugin = {
|
|
754
|
+
name: "mindmatrix-dev-html",
|
|
755
|
+
configureServer(server) {
|
|
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
|
+
});
|
|
770
|
+
}
|
|
771
|
+
};
|
|
690
772
|
let deployInFlight = false;
|
|
691
773
|
const compileDeployPlugin = {
|
|
692
774
|
name: "mindmatrix-dev-compile-deploy",
|
|
@@ -718,6 +800,9 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
|
718
800
|
};
|
|
719
801
|
const viteConfig = {
|
|
720
802
|
root: process.cwd(),
|
|
803
|
+
// 'custom' suppresses "Could not auto-determine entry point" warning
|
|
804
|
+
// since we serve a virtual index.html via the htmlPlugin.
|
|
805
|
+
appType: "custom",
|
|
721
806
|
server: {
|
|
722
807
|
port,
|
|
723
808
|
open,
|
|
@@ -729,6 +814,7 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
|
729
814
|
}
|
|
730
815
|
},
|
|
731
816
|
plugins: [
|
|
817
|
+
htmlPlugin,
|
|
732
818
|
mindmatrixReact(pluginOpts),
|
|
733
819
|
compileDeployPlugin,
|
|
734
820
|
devPlayerPlugin,
|
package/dist/cli/index.js
CHANGED
|
@@ -15884,6 +15884,74 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
|
15884
15884
|
`;
|
|
15885
15885
|
}
|
|
15886
15886
|
};
|
|
15887
|
+
const devHtml = `<!DOCTYPE html>
|
|
15888
|
+
<html lang="en">
|
|
15889
|
+
<head>
|
|
15890
|
+
<meta charset="UTF-8">
|
|
15891
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
15892
|
+
<title>MindMatrix Dev</title>
|
|
15893
|
+
<style>
|
|
15894
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
15895
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #fafafa; color: #111; }
|
|
15896
|
+
#root { min-height: 100vh; }
|
|
15897
|
+
.mm-loading { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex-direction: column; gap: 12px; }
|
|
15898
|
+
.mm-loading h1 { font-size: 20px; font-weight: 600; color: #333; }
|
|
15899
|
+
.mm-loading p { color: #888; font-size: 14px; }
|
|
15900
|
+
</style>
|
|
15901
|
+
</head>
|
|
15902
|
+
<body>
|
|
15903
|
+
<div id="root">
|
|
15904
|
+
<div class="mm-loading">
|
|
15905
|
+
<h1>MindMatrix Dev</h1>
|
|
15906
|
+
<p>Loading...</p>
|
|
15907
|
+
</div>
|
|
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
|
+
);
|
|
15944
|
+
}
|
|
15945
|
+
|
|
15946
|
+
createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
15947
|
+
</script>
|
|
15948
|
+
</body>
|
|
15949
|
+
</html>`;
|
|
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");
|
|
15887
15955
|
let deployInFlight = false;
|
|
15888
15956
|
const compileDeployPlugin = {
|
|
15889
15957
|
name: "mindmatrix-dev-compile-deploy",
|
|
@@ -15914,11 +15982,16 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
|
15914
15982
|
}
|
|
15915
15983
|
};
|
|
15916
15984
|
const viteConfig = {
|
|
15917
|
-
|
|
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"] },
|
|
15918
15989
|
server: {
|
|
15919
15990
|
port,
|
|
15920
15991
|
open,
|
|
15921
15992
|
host: true,
|
|
15993
|
+
// Allow serving files from the real project directory (fs.allow).
|
|
15994
|
+
fs: { allow: [devRoot, process.cwd(), ".."] },
|
|
15922
15995
|
proxy: {
|
|
15923
15996
|
"/api": { target: proxyTarget, changeOrigin: true, secure: true, ws: true },
|
|
15924
15997
|
"/health": { target: proxyTarget, changeOrigin: true, secure: true },
|
|
@@ -15989,6 +16062,11 @@ createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
|
15989
16062
|
if (localServer) {
|
|
15990
16063
|
await localServer.close();
|
|
15991
16064
|
}
|
|
16065
|
+
try {
|
|
16066
|
+
const { rmSync } = await import("fs");
|
|
16067
|
+
rmSync(devRoot, { recursive: true, force: true });
|
|
16068
|
+
} catch {
|
|
16069
|
+
}
|
|
15992
16070
|
}
|
|
15993
16071
|
};
|
|
15994
16072
|
}
|
|
@@ -16299,6 +16377,110 @@ export default defineBlueprint({
|
|
|
16299
16377
|
});
|
|
16300
16378
|
`;
|
|
16301
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
|
+
}
|
|
16302
16484
|
function generateModel(name) {
|
|
16303
16485
|
const modelSlug = `${name}-item`;
|
|
16304
16486
|
const pascal = toPascalCase2(name);
|
|
@@ -16626,6 +16808,7 @@ async function init(options) {
|
|
|
16626
16808
|
["mm.config.ts", generateMmConfig2(name, options)],
|
|
16627
16809
|
["mmrc.config.ts", generateMmrcConfig2()],
|
|
16628
16810
|
[".gitignore", generateGitignore()],
|
|
16811
|
+
["index.html", generateIndexHtml(name)],
|
|
16629
16812
|
["models/item.ts", generateModel(name)],
|
|
16630
16813
|
["app/layout.tsx", generateLayout(name)],
|
|
16631
16814
|
["app/page.tsx", generatePage(name)]
|
|
@@ -19293,7 +19476,7 @@ async function main() {
|
|
|
19293
19476
|
const open = hasFlag("--open") || devCfg.open === true;
|
|
19294
19477
|
const apiPort = getFlag("--api-port") ? parseInt(getFlag("--api-port"), 10) : 4200;
|
|
19295
19478
|
let engineProcess = null;
|
|
19296
|
-
if (isLocal) {
|
|
19479
|
+
if (isLocal && hasFlag("--local")) {
|
|
19297
19480
|
const { findEngineBinary: findEngineBinary2, installEngine: installEngine2, verifyBinary: verifyBinary2 } = await Promise.resolve().then(() => (init_engine_binary(), engine_binary_exports));
|
|
19298
19481
|
let resolution = findEngineBinary2(getFlag("--binary"));
|
|
19299
19482
|
if (resolution.path) {
|
|
@@ -19318,15 +19501,62 @@ async function main() {
|
|
|
19318
19501
|
console.log("[mmrc] Dev server will connect to a remote API or start in-memory mode.");
|
|
19319
19502
|
console.log("[mmrc] (For full local mode: `mmrc engine install` or `mmrc engine build`)\n");
|
|
19320
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
|
+
}
|
|
19321
19535
|
console.log(`[mmrc] Starting local engine: ${resolution.path} (${resolution.source})`);
|
|
19322
19536
|
const { spawn: spawnProcess } = require("child_process");
|
|
19323
|
-
|
|
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, {
|
|
19324
19558
|
stdio: ["ignore", "pipe", "pipe"],
|
|
19325
|
-
env:
|
|
19326
|
-
...process.env,
|
|
19327
|
-
PORT: String(apiPort),
|
|
19328
|
-
RUST_LOG: "mm_api=info,mm_storage=info"
|
|
19329
|
-
},
|
|
19559
|
+
env: engineEnv,
|
|
19330
19560
|
cwd: process.cwd()
|
|
19331
19561
|
});
|
|
19332
19562
|
if (engineProcess.stdout) {
|
|
@@ -19369,6 +19599,7 @@ async function main() {
|
|
|
19369
19599
|
}
|
|
19370
19600
|
}
|
|
19371
19601
|
const apiUrl = engineProcess ? `http://localhost:${apiPort}/api/v1` : explicitApiUrl || "auto";
|
|
19602
|
+
const resolvedToken = engineProcess ? "dev-local" : authToken;
|
|
19372
19603
|
const { createDevServer: createDevServer2 } = await Promise.resolve().then(() => (init_dev_server(), dev_server_exports));
|
|
19373
19604
|
const server = await createDevServer2({
|
|
19374
19605
|
port,
|
|
@@ -19376,7 +19607,7 @@ async function main() {
|
|
|
19376
19607
|
mode,
|
|
19377
19608
|
seed,
|
|
19378
19609
|
apiUrl,
|
|
19379
|
-
authToken,
|
|
19610
|
+
authToken: resolvedToken,
|
|
19380
19611
|
open
|
|
19381
19612
|
});
|
|
19382
19613
|
const shutdown = async () => {
|
package/dist/cli/index.mjs
CHANGED
|
@@ -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
|
-
|
|
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) {
|
|
@@ -423,6 +470,7 @@ async function main() {
|
|
|
423
470
|
}
|
|
424
471
|
}
|
|
425
472
|
const apiUrl = engineProcess ? `http://localhost:${apiPort}/api/v1` : explicitApiUrl || "auto";
|
|
473
|
+
const resolvedToken = engineProcess ? "dev-local" : authToken;
|
|
426
474
|
const { createDevServer } = await import("../dev-server.mjs");
|
|
427
475
|
const server = await createDevServer({
|
|
428
476
|
port,
|
|
@@ -430,7 +478,7 @@ async function main() {
|
|
|
430
478
|
mode,
|
|
431
479
|
seed,
|
|
432
480
|
apiUrl,
|
|
433
|
-
authToken,
|
|
481
|
+
authToken: resolvedToken,
|
|
434
482
|
open
|
|
435
483
|
});
|
|
436
484
|
const shutdown = async () => {
|
|
@@ -563,7 +611,7 @@ async function main() {
|
|
|
563
611
|
console.error('[mmrc] Error: name is required\n Usage: mmrc init <name> [--description "..."] [--icon "..."] [--author "..."]');
|
|
564
612
|
process.exit(1);
|
|
565
613
|
}
|
|
566
|
-
const { init } = await import("../init-
|
|
614
|
+
const { init } = await import("../init-CJCDWI33.mjs");
|
|
567
615
|
await init({
|
|
568
616
|
name,
|
|
569
617
|
description: getFlag("--description"),
|