@mmapp/react-compiler 0.1.0-alpha.11 → 0.1.0-alpha.13
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-DNWDIPH2.mjs +248 -0
- package/dist/chunk-R57T26RR.mjs +734 -0
- package/dist/chunk-UBDNXVL2.mjs +801 -0
- package/dist/cli/index.js +894 -120
- package/dist/cli/index.mjs +223 -6
- package/dist/config-RVLNOB24.mjs +219 -0
- package/dist/dev-server.js +71 -0
- package/dist/dev-server.mjs +2 -2
- package/dist/engine-binary-QQUDACBJ.mjs +455 -0
- package/dist/index.js +71 -0
- package/dist/index.mjs +2 -2
- package/dist/init-2CRSUGV5.mjs +424 -0
- package/dist/init-DY6SJDRX.mjs +438 -0
- package/package.json +2 -2
package/dist/cli/index.mjs
CHANGED
|
@@ -10,10 +10,12 @@ import {
|
|
|
10
10
|
} from "../chunk-ABYPKRSB.mjs";
|
|
11
11
|
import {
|
|
12
12
|
build
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-DNWDIPH2.mjs";
|
|
14
14
|
import "../chunk-5M7DKKBC.mjs";
|
|
15
15
|
import "../chunk-7T6Q5KAA.mjs";
|
|
16
|
-
import
|
|
16
|
+
import {
|
|
17
|
+
__require
|
|
18
|
+
} from "../chunk-CIESM3BP.mjs";
|
|
17
19
|
|
|
18
20
|
// src/cli/test.ts
|
|
19
21
|
import { glob } from "glob";
|
|
@@ -339,9 +341,89 @@ async function main() {
|
|
|
339
341
|
const src = getFlag("--src") ?? devCfg.src;
|
|
340
342
|
const mode = getFlag("--mode") ?? devCfg.mode;
|
|
341
343
|
const seed = hasFlag("--seed") || devCfg.seed === true;
|
|
342
|
-
const
|
|
344
|
+
const explicitApiUrl = getFlag("--api-url") ?? devCfg.apiUrl;
|
|
345
|
+
const isLocal = hasFlag("--local") || !explicitApiUrl || explicitApiUrl === "local";
|
|
343
346
|
const authToken = getFlag("--token") ?? devCfg.token;
|
|
344
347
|
const open = hasFlag("--open") || devCfg.open === true;
|
|
348
|
+
const apiPort = getFlag("--api-port") ? parseInt(getFlag("--api-port"), 10) : 4200;
|
|
349
|
+
let engineProcess = null;
|
|
350
|
+
if (isLocal) {
|
|
351
|
+
const { findEngineBinary, installEngine, verifyBinary } = await import("../engine-binary-QQUDACBJ.mjs");
|
|
352
|
+
let resolution = findEngineBinary(getFlag("--binary"));
|
|
353
|
+
if (resolution.path) {
|
|
354
|
+
const verify = await verifyBinary(resolution.path);
|
|
355
|
+
if (!verify.ok) {
|
|
356
|
+
console.error(`[mmrc] Binary at ${resolution.path} failed verification: ${verify.error}`);
|
|
357
|
+
console.error("[mmrc] Attempting reinstall...\n");
|
|
358
|
+
resolution = { path: null, source: "not-found" };
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (!resolution.path) {
|
|
362
|
+
const installed = await installEngine({
|
|
363
|
+
force: true,
|
|
364
|
+
version: getFlag("--engine-version") ?? "latest"
|
|
365
|
+
});
|
|
366
|
+
if (installed.path) {
|
|
367
|
+
resolution = installed;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!resolution.path) {
|
|
371
|
+
console.log("[mmrc] No local engine binary available.");
|
|
372
|
+
console.log("[mmrc] Dev server will connect to a remote API or start in-memory mode.");
|
|
373
|
+
console.log("[mmrc] (For full local mode: `mmrc engine install` or `mmrc engine build`)\n");
|
|
374
|
+
} else {
|
|
375
|
+
console.log(`[mmrc] Starting local engine: ${resolution.path} (${resolution.source})`);
|
|
376
|
+
const { spawn: spawnProcess } = __require("child_process");
|
|
377
|
+
engineProcess = spawnProcess(resolution.path, [], {
|
|
378
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
379
|
+
env: {
|
|
380
|
+
...process.env,
|
|
381
|
+
DATABASE_URL: `sqlite://${process.cwd()}/dev.db`,
|
|
382
|
+
JWT_SECRET: "dev-secret-mmrc-local",
|
|
383
|
+
PORT: String(apiPort),
|
|
384
|
+
RUST_LOG: "mm_api=info,mm_storage=info"
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
if (engineProcess.stdout) {
|
|
388
|
+
engineProcess.stdout.on("data", (data) => {
|
|
389
|
+
for (const line of data.toString().split("\n").filter(Boolean)) {
|
|
390
|
+
console.log(` [engine] ${line}`);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (engineProcess.stderr) {
|
|
395
|
+
engineProcess.stderr.on("data", (data) => {
|
|
396
|
+
for (const line of data.toString().split("\n").filter(Boolean)) {
|
|
397
|
+
console.error(` [engine] ${line}`);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
engineProcess.on("error", (err) => {
|
|
402
|
+
console.error(`[mmrc] Engine failed to start: ${err.message}`);
|
|
403
|
+
process.exit(1);
|
|
404
|
+
});
|
|
405
|
+
const healthUrl = `http://localhost:${apiPort}/health`;
|
|
406
|
+
let healthy = false;
|
|
407
|
+
for (let i = 0; i < 30; i++) {
|
|
408
|
+
try {
|
|
409
|
+
const res = await fetch(healthUrl, { signal: AbortSignal.timeout(500) });
|
|
410
|
+
if (res.ok) {
|
|
411
|
+
healthy = true;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
} catch {
|
|
415
|
+
}
|
|
416
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
417
|
+
}
|
|
418
|
+
if (!healthy) {
|
|
419
|
+
console.error("[mmrc] Engine failed to become healthy within 15s.");
|
|
420
|
+
engineProcess.kill();
|
|
421
|
+
process.exit(1);
|
|
422
|
+
}
|
|
423
|
+
console.log(`[mmrc] Engine healthy at http://localhost:${apiPort}`);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
const apiUrl = engineProcess ? `http://localhost:${apiPort}/api/v1` : explicitApiUrl || "auto";
|
|
345
427
|
const { createDevServer } = await import("../dev-server.mjs");
|
|
346
428
|
const server = await createDevServer({
|
|
347
429
|
port,
|
|
@@ -353,6 +435,10 @@ async function main() {
|
|
|
353
435
|
open
|
|
354
436
|
});
|
|
355
437
|
const shutdown = async () => {
|
|
438
|
+
if (engineProcess) {
|
|
439
|
+
console.log("[mmrc] Stopping engine...");
|
|
440
|
+
engineProcess.kill("SIGTERM");
|
|
441
|
+
}
|
|
356
442
|
await server.close();
|
|
357
443
|
process.exit(0);
|
|
358
444
|
};
|
|
@@ -373,7 +459,7 @@ async function main() {
|
|
|
373
459
|
const result = await test({ src });
|
|
374
460
|
if (!result.success) process.exit(1);
|
|
375
461
|
} else if (command === "deploy") {
|
|
376
|
-
const { loadMmrcConfig, resolveTarget } = await import("../config-
|
|
462
|
+
const { loadMmrcConfig, resolveTarget } = await import("../config-RVLNOB24.mjs");
|
|
377
463
|
const mmrcConfig = loadMmrcConfig();
|
|
378
464
|
const targetFlag = getFlag("--target");
|
|
379
465
|
const explicitApiUrl = getFlag("--api-url");
|
|
@@ -478,7 +564,7 @@ async function main() {
|
|
|
478
564
|
console.error('[mmrc] Error: name is required\n Usage: mmrc init <name> [--description "..."] [--icon "..."] [--author "..."]');
|
|
479
565
|
process.exit(1);
|
|
480
566
|
}
|
|
481
|
-
const { init } = await import("../init-
|
|
567
|
+
const { init } = await import("../init-DY6SJDRX.mjs");
|
|
482
568
|
await init({
|
|
483
569
|
name,
|
|
484
570
|
description: getFlag("--description"),
|
|
@@ -538,7 +624,7 @@ async function main() {
|
|
|
538
624
|
}
|
|
539
625
|
} else if (command === "config") {
|
|
540
626
|
const subcommand = args[1];
|
|
541
|
-
const { getConfig, getConfigValue, setConfigValue, flattenConfig, findConfigPath, writeConfigFile } = await import("../config-
|
|
627
|
+
const { getConfig, getConfigValue, setConfigValue, flattenConfig, findConfigPath, writeConfigFile } = await import("../config-RVLNOB24.mjs");
|
|
542
628
|
if (subcommand === "get") {
|
|
543
629
|
const key = args[2];
|
|
544
630
|
if (!key) {
|
|
@@ -607,6 +693,121 @@ async function main() {
|
|
|
607
693
|
console.error(" Usage: mmrc server [start|migrate|init|status|config]");
|
|
608
694
|
process.exit(1);
|
|
609
695
|
}
|
|
696
|
+
} else if (command === "engine") {
|
|
697
|
+
const subcommand = args[1];
|
|
698
|
+
const {
|
|
699
|
+
detectPlatform,
|
|
700
|
+
findEngineBinary,
|
|
701
|
+
getEngineStatus,
|
|
702
|
+
installEngine,
|
|
703
|
+
buildFromSource: _buildFromSource,
|
|
704
|
+
verifyBinary,
|
|
705
|
+
healthCheck,
|
|
706
|
+
readMetadata,
|
|
707
|
+
MANAGED_BINARY_PATH: _MANAGED_BINARY_PATH
|
|
708
|
+
} = await import("../engine-binary-QQUDACBJ.mjs");
|
|
709
|
+
if (subcommand === "status") {
|
|
710
|
+
const status = await getEngineStatus(getFlag("--binary"));
|
|
711
|
+
const plat = detectPlatform();
|
|
712
|
+
console.log("\n MindMatrix Engine Status");
|
|
713
|
+
console.log(" " + "-".repeat(48));
|
|
714
|
+
console.log(` Platform: ${plat.releasePlatform ?? `${plat.os}-${plat.arch}`} (${plat.triple})`);
|
|
715
|
+
console.log(` Installed: ${status.installed ? "yes" : "no"}`);
|
|
716
|
+
if (status.path) {
|
|
717
|
+
console.log(` Path: ${status.path}`);
|
|
718
|
+
console.log(` Source: ${status.source}`);
|
|
719
|
+
}
|
|
720
|
+
console.log(` Verified: ${status.verified ? "yes" : "no"}`);
|
|
721
|
+
if (status.version) {
|
|
722
|
+
console.log(` Version: ${status.version}`);
|
|
723
|
+
}
|
|
724
|
+
const meta = readMetadata();
|
|
725
|
+
if (meta) {
|
|
726
|
+
console.log(` Downloaded: ${meta.downloadedAt}`);
|
|
727
|
+
console.log(` Built via: ${meta.source}`);
|
|
728
|
+
}
|
|
729
|
+
console.log("");
|
|
730
|
+
} else if (subcommand === "install") {
|
|
731
|
+
const force = hasFlag("--force");
|
|
732
|
+
const version = getFlag("--version") ?? "latest";
|
|
733
|
+
const result = await installEngine({ force, version });
|
|
734
|
+
if (!result.path) {
|
|
735
|
+
console.error("[mmrc] Engine installation failed.");
|
|
736
|
+
process.exit(1);
|
|
737
|
+
}
|
|
738
|
+
console.log(`
|
|
739
|
+
[mmrc] Engine installed: ${result.path} (${result.source})`);
|
|
740
|
+
} else if (subcommand === "build") {
|
|
741
|
+
const result = await installEngine({ preferBuild: true, force: true });
|
|
742
|
+
if (!result.path) {
|
|
743
|
+
console.error("[mmrc] Engine build failed.");
|
|
744
|
+
process.exit(1);
|
|
745
|
+
}
|
|
746
|
+
console.log(`
|
|
747
|
+
[mmrc] Engine built and cached: ${result.path}`);
|
|
748
|
+
} else if (subcommand === "update") {
|
|
749
|
+
const version = getFlag("--version") ?? "latest";
|
|
750
|
+
console.log("[mmrc] Checking for engine updates...");
|
|
751
|
+
const result = await installEngine({ force: true, version });
|
|
752
|
+
if (!result.path) {
|
|
753
|
+
console.error("[mmrc] Engine update failed.");
|
|
754
|
+
process.exit(1);
|
|
755
|
+
}
|
|
756
|
+
console.log(`
|
|
757
|
+
[mmrc] Engine updated: ${result.path} (${result.source})`);
|
|
758
|
+
} else if (subcommand === "verify") {
|
|
759
|
+
const resolution = findEngineBinary(getFlag("--binary"));
|
|
760
|
+
if (!resolution.path) {
|
|
761
|
+
console.error("[mmrc] No engine binary found. Run `mmrc engine install` first.");
|
|
762
|
+
process.exit(1);
|
|
763
|
+
}
|
|
764
|
+
console.log(`[mmrc] Verifying binary: ${resolution.path}`);
|
|
765
|
+
const verify = await verifyBinary(resolution.path);
|
|
766
|
+
if (!verify.ok) {
|
|
767
|
+
console.error(`[mmrc] --version check FAILED: ${verify.error}`);
|
|
768
|
+
process.exit(1);
|
|
769
|
+
}
|
|
770
|
+
console.log(`[mmrc] --version check passed: ${verify.version}`);
|
|
771
|
+
const apiPort = getFlag("--port") ? parseInt(getFlag("--port"), 10) : 14200;
|
|
772
|
+
console.log(`[mmrc] Starting engine on port ${apiPort} for health check...`);
|
|
773
|
+
const { spawn } = await import("child_process");
|
|
774
|
+
const proc = spawn(resolution.path, [], {
|
|
775
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
776
|
+
env: {
|
|
777
|
+
...process.env,
|
|
778
|
+
DATABASE_URL: "sqlite://:memory:",
|
|
779
|
+
JWT_SECRET: "verify-test",
|
|
780
|
+
PORT: String(apiPort),
|
|
781
|
+
RUST_LOG: "error"
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
let healthy = false;
|
|
785
|
+
for (let i = 0; i < 20; i++) {
|
|
786
|
+
const h = await healthCheck(`http://localhost:${apiPort}/health`, 1e3);
|
|
787
|
+
if (h.ok) {
|
|
788
|
+
healthy = true;
|
|
789
|
+
console.log(`[mmrc] /health check passed${h.version ? ` (v${h.version})` : ""}${h.db ? ` [${h.db}]` : ""}`);
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
793
|
+
}
|
|
794
|
+
proc.kill("SIGTERM");
|
|
795
|
+
if (!healthy) {
|
|
796
|
+
console.error("[mmrc] /health check FAILED: engine did not become healthy within 10s.");
|
|
797
|
+
process.exit(1);
|
|
798
|
+
}
|
|
799
|
+
console.log("\n[mmrc] All verification checks passed.");
|
|
800
|
+
} else {
|
|
801
|
+
console.error(`[mmrc] Unknown engine subcommand: ${subcommand ?? "(none)"}`);
|
|
802
|
+
console.error(" Usage: mmrc engine [status|install|build|update|verify]");
|
|
803
|
+
console.error("");
|
|
804
|
+
console.error(" status Show installed binary path, version, platform");
|
|
805
|
+
console.error(" install Download or build mm-api binary");
|
|
806
|
+
console.error(" build Explicitly build from source (cargo build --release -p mm-api)");
|
|
807
|
+
console.error(" update Check for newer version and download/build");
|
|
808
|
+
console.error(" verify Run --version and /health check against the binary");
|
|
809
|
+
process.exit(1);
|
|
810
|
+
}
|
|
610
811
|
} else if (command === "version" || command === "-v" || command === "--version" || hasFlag("--version") || hasFlag("-v")) {
|
|
611
812
|
const { readFileSync: readFileSync2 } = await import("fs");
|
|
612
813
|
const { resolve: resolve2, dirname } = await import("path");
|
|
@@ -648,6 +849,7 @@ Commands:
|
|
|
648
849
|
verify Compile + run verification layers (structural, reachability, safety, liveness, etc.)
|
|
649
850
|
deploy Compile + upload workflows to backend DB
|
|
650
851
|
pull Fetch a definition from DB and scaffold local project
|
|
852
|
+
engine Manage the mm-api engine binary (install, build, verify, update)
|
|
651
853
|
|
|
652
854
|
Usage:
|
|
653
855
|
mmrc init <name> [options]
|
|
@@ -710,6 +912,17 @@ Usage:
|
|
|
710
912
|
--token Auth token (or use mmrc login / MMRC_TOKEN env var)
|
|
711
913
|
--out Output directory (default: <slug>/)
|
|
712
914
|
|
|
915
|
+
mmrc engine <subcommand> [options]
|
|
916
|
+
status Show installed binary path, version, platform
|
|
917
|
+
install Download or build mm-api binary (--force to reinstall, --version VER)
|
|
918
|
+
build Explicitly build from source (cargo build --release -p mm-api)
|
|
919
|
+
update Check for newer version and download/build (--version VER)
|
|
920
|
+
verify Run --version and /health check (--binary PATH, --port PORT)
|
|
921
|
+
|
|
922
|
+
Platforms: darwin-arm64, darwin-x64, linux-x64, linux-arm64, windows-x64
|
|
923
|
+
Binary location: ~/.mmrc/bin/mm-api
|
|
924
|
+
Metadata: ~/.mmrc/bin/mm-api.json
|
|
925
|
+
|
|
713
926
|
Token resolution (for deploy/pull):
|
|
714
927
|
1. --token flag (highest priority)
|
|
715
928
|
2. MMRC_TOKEN environment variable
|
|
@@ -733,6 +946,10 @@ Examples:
|
|
|
733
946
|
mmrc build --src src/workflows
|
|
734
947
|
mmrc deploy --build --src . --api-url http://localhost:4200/api/v1
|
|
735
948
|
mmrc pull my-blueprint --out ./my-project
|
|
949
|
+
mmrc engine status
|
|
950
|
+
mmrc engine install
|
|
951
|
+
mmrc engine build
|
|
952
|
+
mmrc engine verify
|
|
736
953
|
`);
|
|
737
954
|
}
|
|
738
955
|
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import "./chunk-CIESM3BP.mjs";
|
|
2
|
+
|
|
3
|
+
// src/cli/config.ts
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
5
|
+
import { resolve, join } from "path";
|
|
6
|
+
var DEFAULT_CONFIG = {
|
|
7
|
+
dev: {
|
|
8
|
+
port: 5199,
|
|
9
|
+
apiPort: 4200,
|
|
10
|
+
db: "sqlite://mm-dev.db",
|
|
11
|
+
redis: "",
|
|
12
|
+
api: "local",
|
|
13
|
+
seed: false,
|
|
14
|
+
open: false
|
|
15
|
+
},
|
|
16
|
+
build: {
|
|
17
|
+
mode: "infer",
|
|
18
|
+
outDir: "dist/workflows",
|
|
19
|
+
skipTypeCheck: false
|
|
20
|
+
},
|
|
21
|
+
test: {
|
|
22
|
+
minCoverage: 80,
|
|
23
|
+
minMutationScore: 60,
|
|
24
|
+
integration: false
|
|
25
|
+
},
|
|
26
|
+
environments: {
|
|
27
|
+
local: { apiUrl: "http://localhost:4200/api/v1" },
|
|
28
|
+
dev: { apiUrl: "https://dev.mindmatrix.club/api/v1" }
|
|
29
|
+
},
|
|
30
|
+
defaultTarget: "local"
|
|
31
|
+
};
|
|
32
|
+
function isPlainObject(val) {
|
|
33
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
34
|
+
}
|
|
35
|
+
function deepMerge(target, source) {
|
|
36
|
+
const result = { ...target };
|
|
37
|
+
for (const key of Object.keys(source)) {
|
|
38
|
+
const srcVal = source[key];
|
|
39
|
+
const tgtVal = target[key];
|
|
40
|
+
if (isPlainObject(srcVal) && isPlainObject(tgtVal)) {
|
|
41
|
+
result[key] = deepMerge(tgtVal, srcVal);
|
|
42
|
+
} else if (srcVal !== void 0) {
|
|
43
|
+
result[key] = srcVal;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
function findConfigPath(startDir) {
|
|
49
|
+
let dir = startDir ?? process.cwd();
|
|
50
|
+
const root = resolve("/");
|
|
51
|
+
while (true) {
|
|
52
|
+
for (const name of ["mmrc.config.ts", "mmrc.config.json"]) {
|
|
53
|
+
const candidate = join(dir, name);
|
|
54
|
+
if (existsSync(candidate)) return candidate;
|
|
55
|
+
}
|
|
56
|
+
const parent = resolve(dir, "..");
|
|
57
|
+
if (parent === dir || parent === root) break;
|
|
58
|
+
dir = parent;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function loadConfigFromFile(configPath) {
|
|
63
|
+
const content = readFileSync(configPath, "utf-8");
|
|
64
|
+
if (configPath.endsWith(".json")) {
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(content);
|
|
67
|
+
} catch {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let js = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(?<![:'"])\/\/.*$/gm, "").replace(/^import\s+.*$/gm, "").replace(/^export\s+default\s+/m, "module.exports = ").replace(/^export\s+/gm, "").replace(/:\s*MmrcConfig/g, "").replace(/as\s+const/g, "").replace(/satisfies\s+\w+/g, "");
|
|
72
|
+
js = `function defineMmrc(c) { return c; }
|
|
73
|
+
${js}`;
|
|
74
|
+
try {
|
|
75
|
+
const m = {};
|
|
76
|
+
const fn = new Function("module", "exports", "require", js);
|
|
77
|
+
fn(m, m, () => ({}));
|
|
78
|
+
const exported = m.exports ?? m;
|
|
79
|
+
return isPlainObject(exported) ? exported : {};
|
|
80
|
+
} catch {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function getConfig(startDir) {
|
|
85
|
+
const configPath = findConfigPath(startDir);
|
|
86
|
+
if (!configPath) return { ...DEFAULT_CONFIG };
|
|
87
|
+
const userConfig = loadConfigFromFile(configPath);
|
|
88
|
+
return deepMerge(DEFAULT_CONFIG, userConfig);
|
|
89
|
+
}
|
|
90
|
+
function getConfigValue(config, key) {
|
|
91
|
+
const parts = key.split(".");
|
|
92
|
+
let current = config;
|
|
93
|
+
for (const part of parts) {
|
|
94
|
+
if (!isPlainObject(current)) return void 0;
|
|
95
|
+
current = current[part];
|
|
96
|
+
}
|
|
97
|
+
return current;
|
|
98
|
+
}
|
|
99
|
+
function setConfigValue(config, key, value) {
|
|
100
|
+
const parts = key.split(".");
|
|
101
|
+
let current = config;
|
|
102
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
103
|
+
const part = parts[i];
|
|
104
|
+
if (!isPlainObject(current[part])) {
|
|
105
|
+
current[part] = {};
|
|
106
|
+
}
|
|
107
|
+
current = current[part];
|
|
108
|
+
}
|
|
109
|
+
const last = parts[parts.length - 1];
|
|
110
|
+
if (value === "true") current[last] = true;
|
|
111
|
+
else if (value === "false") current[last] = false;
|
|
112
|
+
else if (/^\d+$/.test(value)) current[last] = parseInt(value, 10);
|
|
113
|
+
else current[last] = value;
|
|
114
|
+
}
|
|
115
|
+
function flattenConfig(obj, prefix = "") {
|
|
116
|
+
const entries = [];
|
|
117
|
+
if (!isPlainObject(obj)) {
|
|
118
|
+
entries.push([prefix, String(obj)]);
|
|
119
|
+
return entries;
|
|
120
|
+
}
|
|
121
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
122
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
123
|
+
if (isPlainObject(val)) {
|
|
124
|
+
entries.push(...flattenConfig(val, fullKey));
|
|
125
|
+
} else {
|
|
126
|
+
entries.push([fullKey, String(val)]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return entries;
|
|
130
|
+
}
|
|
131
|
+
function writeConfigFile(configPath, config) {
|
|
132
|
+
const json = JSON.stringify(config, null, 2);
|
|
133
|
+
const content = `/**
|
|
134
|
+
* mmrc.config.ts \u2014 MindMatrix React Compiler configuration.
|
|
135
|
+
*
|
|
136
|
+
* Configures the mmrc CLI for local dev, builds, tests, and deploy targets.
|
|
137
|
+
* Edit directly or run \`mmrc config set <key> <value>\`.
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
const config = ${json};
|
|
141
|
+
|
|
142
|
+
export default config;
|
|
143
|
+
`;
|
|
144
|
+
writeFileSync(configPath, content, "utf-8");
|
|
145
|
+
}
|
|
146
|
+
function resolveTarget(targetName, config, fallbackApiUrl) {
|
|
147
|
+
if (!config || !config.environments) {
|
|
148
|
+
return { name: targetName ?? "default", apiUrl: fallbackApiUrl, token: null };
|
|
149
|
+
}
|
|
150
|
+
const name = targetName ?? config.defaultTarget ?? "local";
|
|
151
|
+
const env = config.environments[name];
|
|
152
|
+
if (!env) {
|
|
153
|
+
const available = Object.keys(config.environments).join(", ");
|
|
154
|
+
throw new Error(`Unknown target "${name}". Available environments: ${available}`);
|
|
155
|
+
}
|
|
156
|
+
return { name, apiUrl: env.apiUrl, token: env.token ?? null };
|
|
157
|
+
}
|
|
158
|
+
function generateMmrcConfig() {
|
|
159
|
+
return `/**
|
|
160
|
+
* mmrc.config.ts \u2014 MindMatrix React Compiler configuration.
|
|
161
|
+
*
|
|
162
|
+
* Configures the mmrc CLI for local dev, builds, tests, and deploy targets.
|
|
163
|
+
* Edit directly or run \`mmrc config set <key> <value>\`.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
const config = {
|
|
167
|
+
dev: {
|
|
168
|
+
port: 5199,
|
|
169
|
+
apiPort: 4200,
|
|
170
|
+
db: 'sqlite://mm-dev.db',
|
|
171
|
+
redis: '',
|
|
172
|
+
api: 'https://dev.mindmatrix.club/api/v1',
|
|
173
|
+
seed: false,
|
|
174
|
+
open: false,
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
build: {
|
|
178
|
+
mode: 'infer',
|
|
179
|
+
outDir: 'dist/workflows',
|
|
180
|
+
skipTypeCheck: false,
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
test: {
|
|
184
|
+
minCoverage: 80,
|
|
185
|
+
minMutationScore: 60,
|
|
186
|
+
integration: false,
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
environments: {
|
|
190
|
+
local: { apiUrl: 'http://localhost:4200/api/v1' },
|
|
191
|
+
dev: { apiUrl: 'https://dev.mindmatrix.club/api/v1' },
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
defaultTarget: 'local',
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export default config;
|
|
198
|
+
`;
|
|
199
|
+
}
|
|
200
|
+
function loadMmrcConfig(dir) {
|
|
201
|
+
const path = findConfigPath(dir);
|
|
202
|
+
if (!path) return null;
|
|
203
|
+
const partial = loadConfigFromFile(path);
|
|
204
|
+
return deepMerge(DEFAULT_CONFIG, partial);
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
DEFAULT_CONFIG,
|
|
208
|
+
deepMerge,
|
|
209
|
+
findConfigPath,
|
|
210
|
+
flattenConfig,
|
|
211
|
+
generateMmrcConfig,
|
|
212
|
+
getConfig,
|
|
213
|
+
getConfigValue,
|
|
214
|
+
loadConfigFromFile,
|
|
215
|
+
loadMmrcConfig,
|
|
216
|
+
resolveTarget,
|
|
217
|
+
setConfigValue,
|
|
218
|
+
writeConfigFile
|
|
219
|
+
};
|
package/dist/dev-server.js
CHANGED
|
@@ -11522,6 +11522,10 @@ async function build(options = {}) {
|
|
|
11522
11522
|
definitions: [],
|
|
11523
11523
|
errorDetails: typeErrors
|
|
11524
11524
|
};
|
|
11525
|
+
} else if (output.includes("not the tsc command") || output.includes("Cannot find module") || output.includes("ERR_MODULE_NOT_FOUND") || output.includes("command not found")) {
|
|
11526
|
+
console.warn(`[mindmatrix-react] TypeScript not installed \u2014 skipping type check.`);
|
|
11527
|
+
console.warn(` Run \`npm install\` to enable type checking, or use --skip-type-check.
|
|
11528
|
+
`);
|
|
11525
11529
|
} else {
|
|
11526
11530
|
console.error(`
|
|
11527
11531
|
[mindmatrix-react] Type check failed:
|
|
@@ -12256,6 +12260,33 @@ function broadcast(clients, data) {
|
|
|
12256
12260
|
}
|
|
12257
12261
|
}
|
|
12258
12262
|
async function createDevServer(options = {}) {
|
|
12263
|
+
const { existsSync: existsSync3 } = await import("fs");
|
|
12264
|
+
const { resolve: resolve2 } = await import("path");
|
|
12265
|
+
const nodeModulesPath = resolve2(process.cwd(), "node_modules");
|
|
12266
|
+
if (!existsSync3(nodeModulesPath)) {
|
|
12267
|
+
console.error(`
|
|
12268
|
+
[mmrc] Error: Dependencies not installed.
|
|
12269
|
+
`);
|
|
12270
|
+
console.error(` Run one of these in your project directory first:
|
|
12271
|
+
`);
|
|
12272
|
+
console.error(` npm install`);
|
|
12273
|
+
console.error(` pnpm install`);
|
|
12274
|
+
console.error(` yarn install
|
|
12275
|
+
`);
|
|
12276
|
+
process.exit(1);
|
|
12277
|
+
}
|
|
12278
|
+
try {
|
|
12279
|
+
await import("vite");
|
|
12280
|
+
} catch {
|
|
12281
|
+
console.error(`
|
|
12282
|
+
[mmrc] Error: 'vite' is not installed.
|
|
12283
|
+
`);
|
|
12284
|
+
console.error(` Install it:
|
|
12285
|
+
`);
|
|
12286
|
+
console.error(` npm install -D vite
|
|
12287
|
+
`);
|
|
12288
|
+
process.exit(1);
|
|
12289
|
+
}
|
|
12259
12290
|
const {
|
|
12260
12291
|
port = 5199,
|
|
12261
12292
|
src = "src/workflows",
|
|
@@ -12317,6 +12348,45 @@ async function createDevServer(options = {}) {
|
|
|
12317
12348
|
}
|
|
12318
12349
|
const pluginOpts = { mode, include, outDir, seedOnCompile: seed, apiUrl, authToken: token };
|
|
12319
12350
|
const proxyTarget = apiUrl.replace(/\/api\/v1\/?$/, "") || apiUrl;
|
|
12351
|
+
const devPlayerPlugin = {
|
|
12352
|
+
name: "mindmatrix-dev-player",
|
|
12353
|
+
resolveId(id) {
|
|
12354
|
+
if (id === "virtual:mm-dev-player") return "\0virtual:mm-dev-player";
|
|
12355
|
+
return null;
|
|
12356
|
+
},
|
|
12357
|
+
load(id) {
|
|
12358
|
+
if (id !== "\0virtual:mm-dev-player") return null;
|
|
12359
|
+
return `
|
|
12360
|
+
import React from 'react';
|
|
12361
|
+
import { createRoot } from 'react-dom/client';
|
|
12362
|
+
import { DevPlayer } from '@mmapp/react/player';
|
|
12363
|
+
|
|
12364
|
+
const tree = window.__MM_DEV_TREE__ || { type: 'Text', props: { children: 'No tree loaded. Compile a workflow to see the preview.' } };
|
|
12365
|
+
const scopes = window.__MM_DEV_SCOPES__ || {};
|
|
12366
|
+
|
|
12367
|
+
function App() {
|
|
12368
|
+
const [currentTree, setTree] = React.useState(tree);
|
|
12369
|
+
const [currentScopes, setScopes] = React.useState(scopes);
|
|
12370
|
+
|
|
12371
|
+
React.useEffect(() => {
|
|
12372
|
+
const ws = new WebSocket('ws://' + location.host + '/__mm_dev');
|
|
12373
|
+
ws.onmessage = (ev) => {
|
|
12374
|
+
try {
|
|
12375
|
+
const msg = JSON.parse(ev.data);
|
|
12376
|
+
if (msg.type === 'workflow:compiled' && msg.tree) setTree(msg.tree);
|
|
12377
|
+
if (msg.type === 'workflow:compiled' && msg.scopes) setScopes(msg.scopes);
|
|
12378
|
+
} catch {}
|
|
12379
|
+
};
|
|
12380
|
+
return () => ws.close();
|
|
12381
|
+
}, []);
|
|
12382
|
+
|
|
12383
|
+
return React.createElement(DevPlayer, { tree: currentTree, scopes: currentScopes, title: document.title || 'MindMatrix Dev' });
|
|
12384
|
+
}
|
|
12385
|
+
|
|
12386
|
+
createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
12387
|
+
`;
|
|
12388
|
+
}
|
|
12389
|
+
};
|
|
12320
12390
|
let deployInFlight = false;
|
|
12321
12391
|
const compileDeployPlugin = {
|
|
12322
12392
|
name: "mindmatrix-dev-compile-deploy",
|
|
@@ -12361,6 +12431,7 @@ async function createDevServer(options = {}) {
|
|
|
12361
12431
|
plugins: [
|
|
12362
12432
|
mindmatrixReact(pluginOpts),
|
|
12363
12433
|
compileDeployPlugin,
|
|
12434
|
+
devPlayerPlugin,
|
|
12364
12435
|
{ name: "mindmatrix-error-overlay", configureServer(server) {
|
|
12365
12436
|
server.middlewares.use(errorOverlayMiddleware());
|
|
12366
12437
|
} }
|
package/dist/dev-server.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDevServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UBDNXVL2.mjs";
|
|
4
4
|
import "./chunk-BZEXUPDH.mjs";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-DNWDIPH2.mjs";
|
|
6
6
|
import "./chunk-5M7DKKBC.mjs";
|
|
7
7
|
import "./chunk-7T6Q5KAA.mjs";
|
|
8
8
|
import "./chunk-CIESM3BP.mjs";
|