@mmapp/react-compiler 0.1.0-alpha.10 → 0.1.0-alpha.12

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.
@@ -10,10 +10,12 @@ import {
10
10
  } from "../chunk-ABYPKRSB.mjs";
11
11
  import {
12
12
  build
13
- } from "../chunk-VLTKQDJ3.mjs";
13
+ } from "../chunk-DNWDIPH2.mjs";
14
14
  import "../chunk-5M7DKKBC.mjs";
15
15
  import "../chunk-7T6Q5KAA.mjs";
16
- import "../chunk-CIESM3BP.mjs";
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,85 @@ 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 apiUrl = hasFlag("--local") ? "local" : getFlag("--api-url") ?? devCfg.apiUrl;
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
+ console.error("[mmrc] Could not obtain a working engine binary.");
368
+ process.exit(1);
369
+ }
370
+ resolution = installed;
371
+ }
372
+ console.log(`[mmrc] Starting local engine: ${resolution.path} (${resolution.source})`);
373
+ const { spawn: spawnProcess } = __require("child_process");
374
+ engineProcess = spawnProcess(resolution.path, [], {
375
+ stdio: ["ignore", "pipe", "pipe"],
376
+ env: {
377
+ ...process.env,
378
+ DATABASE_URL: `sqlite://${process.cwd()}/dev.db`,
379
+ JWT_SECRET: "dev-secret-mmrc-local",
380
+ PORT: String(apiPort),
381
+ RUST_LOG: "mm_api=info,mm_storage=info"
382
+ }
383
+ });
384
+ if (engineProcess.stdout) {
385
+ engineProcess.stdout.on("data", (data) => {
386
+ for (const line of data.toString().split("\n").filter(Boolean)) {
387
+ console.log(` [engine] ${line}`);
388
+ }
389
+ });
390
+ }
391
+ if (engineProcess.stderr) {
392
+ engineProcess.stderr.on("data", (data) => {
393
+ for (const line of data.toString().split("\n").filter(Boolean)) {
394
+ console.error(` [engine] ${line}`);
395
+ }
396
+ });
397
+ }
398
+ engineProcess.on("error", (err) => {
399
+ console.error(`[mmrc] Engine failed to start: ${err.message}`);
400
+ process.exit(1);
401
+ });
402
+ const healthUrl = `http://localhost:${apiPort}/health`;
403
+ let healthy = false;
404
+ for (let i = 0; i < 30; i++) {
405
+ try {
406
+ const res = await fetch(healthUrl, { signal: AbortSignal.timeout(500) });
407
+ if (res.ok) {
408
+ healthy = true;
409
+ break;
410
+ }
411
+ } catch {
412
+ }
413
+ await new Promise((r) => setTimeout(r, 500));
414
+ }
415
+ if (!healthy) {
416
+ console.error("[mmrc] Engine failed to become healthy within 15s.");
417
+ engineProcess.kill();
418
+ process.exit(1);
419
+ }
420
+ console.log(`[mmrc] Engine healthy at http://localhost:${apiPort}`);
421
+ }
422
+ const apiUrl = isLocal ? `http://localhost:${apiPort}/api/v1` : explicitApiUrl;
345
423
  const { createDevServer } = await import("../dev-server.mjs");
346
424
  const server = await createDevServer({
347
425
  port,
@@ -353,6 +431,10 @@ async function main() {
353
431
  open
354
432
  });
355
433
  const shutdown = async () => {
434
+ if (engineProcess) {
435
+ console.log("[mmrc] Stopping engine...");
436
+ engineProcess.kill("SIGTERM");
437
+ }
356
438
  await server.close();
357
439
  process.exit(0);
358
440
  };
@@ -373,7 +455,7 @@ async function main() {
373
455
  const result = await test({ src });
374
456
  if (!result.success) process.exit(1);
375
457
  } else if (command === "deploy") {
376
- const { loadMmrcConfig, resolveTarget } = await import("../config-PL24KEWL.mjs");
458
+ const { loadMmrcConfig, resolveTarget } = await import("../config-RVLNOB24.mjs");
377
459
  const mmrcConfig = loadMmrcConfig();
378
460
  const targetFlag = getFlag("--target");
379
461
  const explicitApiUrl = getFlag("--api-url");
@@ -478,7 +560,7 @@ async function main() {
478
560
  console.error('[mmrc] Error: name is required\n Usage: mmrc init <name> [--description "..."] [--icon "..."] [--author "..."]');
479
561
  process.exit(1);
480
562
  }
481
- const { init } = await import("../init-7FJENUDK.mjs");
563
+ const { init } = await import("../init-2CRSUGV5.mjs");
482
564
  await init({
483
565
  name,
484
566
  description: getFlag("--description"),
@@ -538,7 +620,7 @@ async function main() {
538
620
  }
539
621
  } else if (command === "config") {
540
622
  const subcommand = args[1];
541
- const { getConfig, getConfigValue, setConfigValue, flattenConfig, findConfigPath, writeConfigFile } = await import("../config-PL24KEWL.mjs");
623
+ const { getConfig, getConfigValue, setConfigValue, flattenConfig, findConfigPath, writeConfigFile } = await import("../config-RVLNOB24.mjs");
542
624
  if (subcommand === "get") {
543
625
  const key = args[2];
544
626
  if (!key) {
@@ -607,6 +689,121 @@ async function main() {
607
689
  console.error(" Usage: mmrc server [start|migrate|init|status|config]");
608
690
  process.exit(1);
609
691
  }
692
+ } else if (command === "engine") {
693
+ const subcommand = args[1];
694
+ const {
695
+ detectPlatform,
696
+ findEngineBinary,
697
+ getEngineStatus,
698
+ installEngine,
699
+ buildFromSource: _buildFromSource,
700
+ verifyBinary,
701
+ healthCheck,
702
+ readMetadata,
703
+ MANAGED_BINARY_PATH: _MANAGED_BINARY_PATH
704
+ } = await import("../engine-binary-QQUDACBJ.mjs");
705
+ if (subcommand === "status") {
706
+ const status = await getEngineStatus(getFlag("--binary"));
707
+ const plat = detectPlatform();
708
+ console.log("\n MindMatrix Engine Status");
709
+ console.log(" " + "-".repeat(48));
710
+ console.log(` Platform: ${plat.releasePlatform ?? `${plat.os}-${plat.arch}`} (${plat.triple})`);
711
+ console.log(` Installed: ${status.installed ? "yes" : "no"}`);
712
+ if (status.path) {
713
+ console.log(` Path: ${status.path}`);
714
+ console.log(` Source: ${status.source}`);
715
+ }
716
+ console.log(` Verified: ${status.verified ? "yes" : "no"}`);
717
+ if (status.version) {
718
+ console.log(` Version: ${status.version}`);
719
+ }
720
+ const meta = readMetadata();
721
+ if (meta) {
722
+ console.log(` Downloaded: ${meta.downloadedAt}`);
723
+ console.log(` Built via: ${meta.source}`);
724
+ }
725
+ console.log("");
726
+ } else if (subcommand === "install") {
727
+ const force = hasFlag("--force");
728
+ const version = getFlag("--version") ?? "latest";
729
+ const result = await installEngine({ force, version });
730
+ if (!result.path) {
731
+ console.error("[mmrc] Engine installation failed.");
732
+ process.exit(1);
733
+ }
734
+ console.log(`
735
+ [mmrc] Engine installed: ${result.path} (${result.source})`);
736
+ } else if (subcommand === "build") {
737
+ const result = await installEngine({ preferBuild: true, force: true });
738
+ if (!result.path) {
739
+ console.error("[mmrc] Engine build failed.");
740
+ process.exit(1);
741
+ }
742
+ console.log(`
743
+ [mmrc] Engine built and cached: ${result.path}`);
744
+ } else if (subcommand === "update") {
745
+ const version = getFlag("--version") ?? "latest";
746
+ console.log("[mmrc] Checking for engine updates...");
747
+ const result = await installEngine({ force: true, version });
748
+ if (!result.path) {
749
+ console.error("[mmrc] Engine update failed.");
750
+ process.exit(1);
751
+ }
752
+ console.log(`
753
+ [mmrc] Engine updated: ${result.path} (${result.source})`);
754
+ } else if (subcommand === "verify") {
755
+ const resolution = findEngineBinary(getFlag("--binary"));
756
+ if (!resolution.path) {
757
+ console.error("[mmrc] No engine binary found. Run `mmrc engine install` first.");
758
+ process.exit(1);
759
+ }
760
+ console.log(`[mmrc] Verifying binary: ${resolution.path}`);
761
+ const verify = await verifyBinary(resolution.path);
762
+ if (!verify.ok) {
763
+ console.error(`[mmrc] --version check FAILED: ${verify.error}`);
764
+ process.exit(1);
765
+ }
766
+ console.log(`[mmrc] --version check passed: ${verify.version}`);
767
+ const apiPort = getFlag("--port") ? parseInt(getFlag("--port"), 10) : 14200;
768
+ console.log(`[mmrc] Starting engine on port ${apiPort} for health check...`);
769
+ const { spawn } = await import("child_process");
770
+ const proc = spawn(resolution.path, [], {
771
+ stdio: ["ignore", "pipe", "pipe"],
772
+ env: {
773
+ ...process.env,
774
+ DATABASE_URL: "sqlite://:memory:",
775
+ JWT_SECRET: "verify-test",
776
+ PORT: String(apiPort),
777
+ RUST_LOG: "error"
778
+ }
779
+ });
780
+ let healthy = false;
781
+ for (let i = 0; i < 20; i++) {
782
+ const h = await healthCheck(`http://localhost:${apiPort}/health`, 1e3);
783
+ if (h.ok) {
784
+ healthy = true;
785
+ console.log(`[mmrc] /health check passed${h.version ? ` (v${h.version})` : ""}${h.db ? ` [${h.db}]` : ""}`);
786
+ break;
787
+ }
788
+ await new Promise((r) => setTimeout(r, 500));
789
+ }
790
+ proc.kill("SIGTERM");
791
+ if (!healthy) {
792
+ console.error("[mmrc] /health check FAILED: engine did not become healthy within 10s.");
793
+ process.exit(1);
794
+ }
795
+ console.log("\n[mmrc] All verification checks passed.");
796
+ } else {
797
+ console.error(`[mmrc] Unknown engine subcommand: ${subcommand ?? "(none)"}`);
798
+ console.error(" Usage: mmrc engine [status|install|build|update|verify]");
799
+ console.error("");
800
+ console.error(" status Show installed binary path, version, platform");
801
+ console.error(" install Download or build mm-api binary");
802
+ console.error(" build Explicitly build from source (cargo build --release -p mm-api)");
803
+ console.error(" update Check for newer version and download/build");
804
+ console.error(" verify Run --version and /health check against the binary");
805
+ process.exit(1);
806
+ }
610
807
  } else if (command === "version" || command === "-v" || command === "--version" || hasFlag("--version") || hasFlag("-v")) {
611
808
  const { readFileSync: readFileSync2 } = await import("fs");
612
809
  const { resolve: resolve2, dirname } = await import("path");
@@ -648,6 +845,7 @@ Commands:
648
845
  verify Compile + run verification layers (structural, reachability, safety, liveness, etc.)
649
846
  deploy Compile + upload workflows to backend DB
650
847
  pull Fetch a definition from DB and scaffold local project
848
+ engine Manage the mm-api engine binary (install, build, verify, update)
651
849
 
652
850
  Usage:
653
851
  mmrc init <name> [options]
@@ -710,6 +908,17 @@ Usage:
710
908
  --token Auth token (or use mmrc login / MMRC_TOKEN env var)
711
909
  --out Output directory (default: <slug>/)
712
910
 
911
+ mmrc engine <subcommand> [options]
912
+ status Show installed binary path, version, platform
913
+ install Download or build mm-api binary (--force to reinstall, --version VER)
914
+ build Explicitly build from source (cargo build --release -p mm-api)
915
+ update Check for newer version and download/build (--version VER)
916
+ verify Run --version and /health check (--binary PATH, --port PORT)
917
+
918
+ Platforms: darwin-arm64, darwin-x64, linux-x64, linux-arm64, windows-x64
919
+ Binary location: ~/.mmrc/bin/mm-api
920
+ Metadata: ~/.mmrc/bin/mm-api.json
921
+
713
922
  Token resolution (for deploy/pull):
714
923
  1. --token flag (highest priority)
715
924
  2. MMRC_TOKEN environment variable
@@ -733,6 +942,10 @@ Examples:
733
942
  mmrc build --src src/workflows
734
943
  mmrc deploy --build --src . --api-url http://localhost:4200/api/v1
735
944
  mmrc pull my-blueprint --out ./my-project
945
+ mmrc engine status
946
+ mmrc engine install
947
+ mmrc engine build
948
+ mmrc engine verify
736
949
  `);
737
950
  }
738
951
  }
@@ -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
+ };
@@ -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
  } }
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createDevServer
3
- } from "./chunk-UDDTWG5J.mjs";
3
+ } from "./chunk-UBDNXVL2.mjs";
4
4
  import "./chunk-BZEXUPDH.mjs";
5
- import "./chunk-VLTKQDJ3.mjs";
5
+ import "./chunk-DNWDIPH2.mjs";
6
6
  import "./chunk-5M7DKKBC.mjs";
7
7
  import "./chunk-7T6Q5KAA.mjs";
8
8
  import "./chunk-CIESM3BP.mjs";