@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.
- 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 +876 -120
- package/dist/cli/index.mjs +219 -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/package.json +2 -2
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-CIESM3BP.mjs";
|
|
4
|
+
|
|
5
|
+
// src/cli/engine-binary.ts
|
|
6
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, chmodSync, createWriteStream, copyFileSync } from "fs";
|
|
7
|
+
import { join, resolve } from "path";
|
|
8
|
+
import { homedir, platform, arch } from "os";
|
|
9
|
+
import { pipeline } from "stream/promises";
|
|
10
|
+
import { spawn as nodeSpawn, execSync } from "child_process";
|
|
11
|
+
var MMRC_BIN_DIR = join(homedir(), ".mmrc", "bin");
|
|
12
|
+
var BINARY_NAME = platform() === "win32" ? "mm-api.exe" : "mm-api";
|
|
13
|
+
var MANAGED_BINARY_PATH = join(MMRC_BIN_DIR, BINARY_NAME);
|
|
14
|
+
var VERSION_FILE_PATH = join(MMRC_BIN_DIR, "mm-api.version");
|
|
15
|
+
var METADATA_PATH = join(MMRC_BIN_DIR, "mm-api.json");
|
|
16
|
+
var GITHUB_RELEASE_BASE = "https://github.com/dev-nested/mm-app/releases/download";
|
|
17
|
+
var PROJECT_SEARCH_PATHS = [
|
|
18
|
+
"engine/target/release/mm-server",
|
|
19
|
+
"engine/target/debug/mm-server",
|
|
20
|
+
"mm-core/target/release/mm-server",
|
|
21
|
+
"mm-core/target/debug/mm-server",
|
|
22
|
+
"target/release/mm-server",
|
|
23
|
+
"target/debug/mm-server"
|
|
24
|
+
];
|
|
25
|
+
function detectPlatform() {
|
|
26
|
+
const os = platform();
|
|
27
|
+
const a = arch();
|
|
28
|
+
let triple;
|
|
29
|
+
let releasePlatform = null;
|
|
30
|
+
if (os === "linux" && a === "x64") {
|
|
31
|
+
triple = "x86_64-unknown-linux-gnu";
|
|
32
|
+
releasePlatform = "linux-x64";
|
|
33
|
+
} else if (os === "linux" && a === "arm64") {
|
|
34
|
+
triple = "aarch64-unknown-linux-gnu";
|
|
35
|
+
releasePlatform = "linux-arm64";
|
|
36
|
+
} else if (os === "darwin" && a === "x64") {
|
|
37
|
+
triple = "x86_64-apple-darwin";
|
|
38
|
+
releasePlatform = "darwin-x64";
|
|
39
|
+
} else if (os === "darwin" && a === "arm64") {
|
|
40
|
+
triple = "aarch64-apple-darwin";
|
|
41
|
+
releasePlatform = "darwin-arm64";
|
|
42
|
+
} else if (os === "win32" && a === "x64") {
|
|
43
|
+
triple = "x86_64-pc-windows-msvc";
|
|
44
|
+
releasePlatform = "windows-x64";
|
|
45
|
+
} else {
|
|
46
|
+
triple = `${a}-unknown-${os}`;
|
|
47
|
+
}
|
|
48
|
+
return { os, arch: a, triple, releasePlatform };
|
|
49
|
+
}
|
|
50
|
+
function getCachedVersion() {
|
|
51
|
+
try {
|
|
52
|
+
if (existsSync(VERSION_FILE_PATH)) {
|
|
53
|
+
return readFileSync(VERSION_FILE_PATH, "utf-8").trim();
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
function setCachedVersion(version) {
|
|
60
|
+
mkdirSync(MMRC_BIN_DIR, { recursive: true });
|
|
61
|
+
writeFileSync(VERSION_FILE_PATH, version, "utf-8");
|
|
62
|
+
}
|
|
63
|
+
function readMetadata() {
|
|
64
|
+
try {
|
|
65
|
+
if (!existsSync(METADATA_PATH)) return null;
|
|
66
|
+
return JSON.parse(readFileSync(METADATA_PATH, "utf-8"));
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function writeMetadata(meta) {
|
|
72
|
+
mkdirSync(MMRC_BIN_DIR, { recursive: true });
|
|
73
|
+
writeFileSync(METADATA_PATH, JSON.stringify(meta, null, 2), "utf-8");
|
|
74
|
+
}
|
|
75
|
+
async function verifyBinary(binaryPath) {
|
|
76
|
+
if (!existsSync(binaryPath)) {
|
|
77
|
+
return { ok: false, error: `Binary not found at ${binaryPath}` };
|
|
78
|
+
}
|
|
79
|
+
return new Promise((resolve2) => {
|
|
80
|
+
try {
|
|
81
|
+
const proc = nodeSpawn(binaryPath, ["--version"], {
|
|
82
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
83
|
+
timeout: 1e4
|
|
84
|
+
});
|
|
85
|
+
let stdout = "";
|
|
86
|
+
let stderr = "";
|
|
87
|
+
proc.stdout?.on("data", (d) => {
|
|
88
|
+
stdout += d.toString();
|
|
89
|
+
});
|
|
90
|
+
proc.stderr?.on("data", (d) => {
|
|
91
|
+
stderr += d.toString();
|
|
92
|
+
});
|
|
93
|
+
proc.on("error", (err) => {
|
|
94
|
+
resolve2({ ok: false, error: `Failed to execute: ${err.message}` });
|
|
95
|
+
});
|
|
96
|
+
proc.on("close", (code) => {
|
|
97
|
+
if (code === 0) {
|
|
98
|
+
const output = stdout.trim() || stderr.trim();
|
|
99
|
+
const version = output.replace(/^mm[-_](?:server|api)\s*/i, "").trim() || "unknown";
|
|
100
|
+
resolve2({ ok: true, version });
|
|
101
|
+
} else {
|
|
102
|
+
resolve2({ ok: false, error: `Exited with code ${code}. ${stderr.trim()}` });
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} catch (e) {
|
|
106
|
+
resolve2({ ok: false, error: `Spawn failed: ${e instanceof Error ? e.message : String(e)}` });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async function healthCheck(url, timeoutMs = 5e3) {
|
|
111
|
+
try {
|
|
112
|
+
const resp = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
|
|
113
|
+
if (resp.ok) {
|
|
114
|
+
const data = await resp.json();
|
|
115
|
+
return { ok: true, version: data.version, db: data.database };
|
|
116
|
+
}
|
|
117
|
+
return { ok: resp.status < 500 };
|
|
118
|
+
} catch {
|
|
119
|
+
return { ok: false };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function getEngineStatus(explicitPath) {
|
|
123
|
+
const plat = detectPlatform();
|
|
124
|
+
const resolution = findEngineBinary(explicitPath);
|
|
125
|
+
const meta = readMetadata();
|
|
126
|
+
let version = null;
|
|
127
|
+
let verified = false;
|
|
128
|
+
if (resolution.path) {
|
|
129
|
+
const verify = await verifyBinary(resolution.path);
|
|
130
|
+
if (verify.ok) {
|
|
131
|
+
version = verify.version ?? null;
|
|
132
|
+
verified = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
installed: resolution.path !== null,
|
|
137
|
+
path: resolution.path,
|
|
138
|
+
source: resolution.source,
|
|
139
|
+
version,
|
|
140
|
+
platform: plat,
|
|
141
|
+
metadata: meta,
|
|
142
|
+
verified
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async function installEngine(options) {
|
|
146
|
+
const { force = false, preferBuild = false, version = "latest", cwd, prompt, fetch: fetchFn } = options ?? {};
|
|
147
|
+
const plat = detectPlatform();
|
|
148
|
+
if (!force && existsSync(MANAGED_BINARY_PATH)) {
|
|
149
|
+
const meta = readMetadata();
|
|
150
|
+
if (meta?.verified) {
|
|
151
|
+
console.error(`[mmrc] Found cached binary (${meta.version}, ${meta.platform})`);
|
|
152
|
+
}
|
|
153
|
+
const verify = await verifyBinary(MANAGED_BINARY_PATH);
|
|
154
|
+
if (verify.ok) {
|
|
155
|
+
console.error(`[mmrc] Cached binary verified: ${verify.version}`);
|
|
156
|
+
return { path: MANAGED_BINARY_PATH, source: "managed" };
|
|
157
|
+
}
|
|
158
|
+
console.error("[mmrc] Cached binary failed verification \u2014 reinstalling.");
|
|
159
|
+
}
|
|
160
|
+
if (preferBuild) {
|
|
161
|
+
return await installViaBuild(plat, version, cwd, prompt);
|
|
162
|
+
}
|
|
163
|
+
if (plat.releasePlatform) {
|
|
164
|
+
const dl = await downloadBinary({ version, platform: plat.releasePlatform, fetch: fetchFn });
|
|
165
|
+
if (dl.success) {
|
|
166
|
+
console.error("[mmrc] Verifying downloaded binary...");
|
|
167
|
+
const verify = await verifyBinary(dl.path);
|
|
168
|
+
if (verify.ok) {
|
|
169
|
+
console.error(`[mmrc] Verification passed: ${verify.version}`);
|
|
170
|
+
writeMetadata({
|
|
171
|
+
version: verify.version ?? version,
|
|
172
|
+
platform: plat.releasePlatform,
|
|
173
|
+
triple: plat.triple,
|
|
174
|
+
downloadedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
175
|
+
verified: true,
|
|
176
|
+
source: "download",
|
|
177
|
+
path: dl.path
|
|
178
|
+
});
|
|
179
|
+
return { path: dl.path, source: "downloaded" };
|
|
180
|
+
}
|
|
181
|
+
console.error(`[mmrc] Binary verification FAILED: ${verify.error}`);
|
|
182
|
+
console.error("");
|
|
183
|
+
console.error(` Platform: ${plat.releasePlatform} (${plat.triple})`);
|
|
184
|
+
console.error(" This usually means:");
|
|
185
|
+
console.error(" - Wrong architecture (e.g., ARM binary on x86)");
|
|
186
|
+
console.error(" - Missing shared libraries (try: ldd " + dl.path + ")");
|
|
187
|
+
console.error(" - Glibc version mismatch");
|
|
188
|
+
console.error("");
|
|
189
|
+
console.error("[mmrc] Falling back to build from source...\n");
|
|
190
|
+
} else {
|
|
191
|
+
console.error(`[mmrc] Download failed: ${dl.error}`);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
console.error(`[mmrc] No pre-built binary for ${plat.os}/${plat.arch}.`);
|
|
195
|
+
}
|
|
196
|
+
return await installViaBuild(plat, version, cwd, prompt);
|
|
197
|
+
}
|
|
198
|
+
async function installViaBuild(plat, version, cwd, prompt) {
|
|
199
|
+
if (!hasCargoInstalled()) {
|
|
200
|
+
console.error("[mmrc] Rust toolchain not found (cargo not in PATH).");
|
|
201
|
+
console.error("");
|
|
202
|
+
if (platform() === "win32") {
|
|
203
|
+
console.error(" Install Rust from https://rustup.rs");
|
|
204
|
+
} else {
|
|
205
|
+
console.error(" Install Rust:");
|
|
206
|
+
console.error(' curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh');
|
|
207
|
+
}
|
|
208
|
+
console.error("");
|
|
209
|
+
console.error(" Then restart your shell and run: mmrc engine build");
|
|
210
|
+
return { path: null, source: "not-found" };
|
|
211
|
+
}
|
|
212
|
+
const built = await buildFromSource({ cwd, prompt });
|
|
213
|
+
if (!built) return { path: null, source: "not-found" };
|
|
214
|
+
console.error("[mmrc] Verifying built binary...");
|
|
215
|
+
const verify = await verifyBinary(built);
|
|
216
|
+
if (verify.ok) {
|
|
217
|
+
console.error(`[mmrc] Build verified: ${verify.version}`);
|
|
218
|
+
writeMetadata({
|
|
219
|
+
version: verify.version ?? version,
|
|
220
|
+
platform: plat.releasePlatform ?? `${plat.os}-${plat.arch}`,
|
|
221
|
+
triple: plat.triple,
|
|
222
|
+
downloadedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
223
|
+
verified: true,
|
|
224
|
+
source: "build",
|
|
225
|
+
path: built
|
|
226
|
+
});
|
|
227
|
+
return { path: built, source: "built" };
|
|
228
|
+
}
|
|
229
|
+
console.error(`[mmrc] Built binary also failed verification: ${verify.error}`);
|
|
230
|
+
return { path: null, source: "not-found" };
|
|
231
|
+
}
|
|
232
|
+
function buildDownloadUrl(version, releasePlatform) {
|
|
233
|
+
const tag = version.startsWith("v") ? version : `v${version}`;
|
|
234
|
+
return `${GITHUB_RELEASE_BASE}/${tag}/mm-api-${releasePlatform}`;
|
|
235
|
+
}
|
|
236
|
+
async function downloadBinary(options) {
|
|
237
|
+
const plat = options.platform ?? detectPlatform().releasePlatform;
|
|
238
|
+
const dest = options.dest ?? MANAGED_BINARY_PATH;
|
|
239
|
+
const fetchFn = options.fetch ?? globalThis.fetch;
|
|
240
|
+
if (!plat) {
|
|
241
|
+
return { success: false, path: dest, error: "Unsupported platform for pre-built binaries" };
|
|
242
|
+
}
|
|
243
|
+
const url = buildDownloadUrl(options.version, plat);
|
|
244
|
+
console.error(`[mmrc] Downloading mm-api ${options.version} for ${plat}...`);
|
|
245
|
+
console.error(`[mmrc] ${url}`);
|
|
246
|
+
try {
|
|
247
|
+
const response = await fetchFn(url, { redirect: "follow" });
|
|
248
|
+
if (!response.ok) {
|
|
249
|
+
return {
|
|
250
|
+
success: false,
|
|
251
|
+
path: dest,
|
|
252
|
+
error: `HTTP ${response.status}: ${response.statusText} (${url})`
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
mkdirSync(MMRC_BIN_DIR, { recursive: true });
|
|
256
|
+
const body = response.body;
|
|
257
|
+
if (!body) {
|
|
258
|
+
return { success: false, path: dest, error: "Empty response body" };
|
|
259
|
+
}
|
|
260
|
+
const fileStream = createWriteStream(dest);
|
|
261
|
+
await pipeline(body, fileStream);
|
|
262
|
+
chmodSync(dest, 493);
|
|
263
|
+
setCachedVersion(options.version);
|
|
264
|
+
console.error(`[mmrc] Downloaded to ${dest}`);
|
|
265
|
+
return { success: true, path: dest };
|
|
266
|
+
} catch (err) {
|
|
267
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
268
|
+
return { success: false, path: dest, error: message };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function hasCargoInstalled() {
|
|
272
|
+
try {
|
|
273
|
+
execSync("cargo --version", { encoding: "utf-8", timeout: 5e3, stdio: "pipe" });
|
|
274
|
+
return true;
|
|
275
|
+
} catch {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function askUser(question) {
|
|
280
|
+
const readline = __require("readline");
|
|
281
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
282
|
+
return new Promise((resolve2) => {
|
|
283
|
+
rl.question(question, (answer) => {
|
|
284
|
+
rl.close();
|
|
285
|
+
resolve2(answer.trim().toLowerCase());
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async function buildFromSource(options) {
|
|
290
|
+
const promptFn = options?.prompt ?? askUser;
|
|
291
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
292
|
+
if (hasCargoInstalled()) {
|
|
293
|
+
const answer = await promptFn("[mmrc] No pre-built binary available. Build from source? (y/n) ");
|
|
294
|
+
if (answer !== "y" && answer !== "yes") return null;
|
|
295
|
+
} else {
|
|
296
|
+
const answer = await promptFn(
|
|
297
|
+
"[mmrc] No pre-built binary available and Rust is not installed.\n Install Rust and build from source? (y/n) "
|
|
298
|
+
);
|
|
299
|
+
if (answer !== "y" && answer !== "yes") return null;
|
|
300
|
+
console.error("[mmrc] Installing Rust via rustup...");
|
|
301
|
+
try {
|
|
302
|
+
execSync('curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y', {
|
|
303
|
+
stdio: "inherit",
|
|
304
|
+
cwd,
|
|
305
|
+
timeout: 3e5
|
|
306
|
+
});
|
|
307
|
+
const cargoEnv = join(homedir(), ".cargo", "env");
|
|
308
|
+
if (existsSync(cargoEnv)) {
|
|
309
|
+
execSync(`. ${cargoEnv}`, { stdio: "pipe" });
|
|
310
|
+
}
|
|
311
|
+
} catch (err) {
|
|
312
|
+
console.error("[mmrc] Failed to install Rust:", err instanceof Error ? err.message : err);
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
console.error("[mmrc] Building mm-api from source (this may take a few minutes)...");
|
|
317
|
+
try {
|
|
318
|
+
execSync("cargo build --release -p mm-api", {
|
|
319
|
+
stdio: "inherit",
|
|
320
|
+
cwd,
|
|
321
|
+
timeout: 6e5
|
|
322
|
+
});
|
|
323
|
+
} catch (err) {
|
|
324
|
+
console.error("[mmrc] Build failed:", err instanceof Error ? err.message : err);
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
const candidates = [
|
|
328
|
+
join(cwd, "mm-core", "target", "release", "mm-server"),
|
|
329
|
+
join(cwd, "target", "release", "mm-server")
|
|
330
|
+
];
|
|
331
|
+
for (const p of candidates) {
|
|
332
|
+
if (existsSync(p)) {
|
|
333
|
+
mkdirSync(MMRC_BIN_DIR, { recursive: true });
|
|
334
|
+
copyFileSync(p, MANAGED_BINARY_PATH);
|
|
335
|
+
chmodSync(MANAGED_BINARY_PATH, 493);
|
|
336
|
+
console.error(`[mmrc] Installed to ${MANAGED_BINARY_PATH}`);
|
|
337
|
+
return MANAGED_BINARY_PATH;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
console.error("[mmrc] Build completed but binary not found in expected locations.");
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
function findEngineBinary(explicitPath, cwd) {
|
|
344
|
+
const workDir = cwd ?? process.cwd();
|
|
345
|
+
if (explicitPath) {
|
|
346
|
+
if (existsSync(explicitPath)) {
|
|
347
|
+
return { path: explicitPath, source: "explicit" };
|
|
348
|
+
}
|
|
349
|
+
return { path: null, source: "not-found" };
|
|
350
|
+
}
|
|
351
|
+
if (existsSync(MANAGED_BINARY_PATH)) {
|
|
352
|
+
return { path: MANAGED_BINARY_PATH, source: "managed" };
|
|
353
|
+
}
|
|
354
|
+
for (const rel of PROJECT_SEARCH_PATHS) {
|
|
355
|
+
const abs = resolve(workDir, rel);
|
|
356
|
+
if (existsSync(abs)) {
|
|
357
|
+
return { path: abs, source: "project" };
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
try {
|
|
361
|
+
const cmd = platform() === "win32" ? "where mm-server 2>nul || where mm-api 2>nul" : "which mm-server 2>/dev/null || which mm-api 2>/dev/null";
|
|
362
|
+
const result = execSync(cmd, { encoding: "utf-8", timeout: 5e3 }).trim();
|
|
363
|
+
if (result) {
|
|
364
|
+
return { path: result.split("\n")[0], source: "path" };
|
|
365
|
+
}
|
|
366
|
+
} catch {
|
|
367
|
+
}
|
|
368
|
+
return { path: null, source: "not-found" };
|
|
369
|
+
}
|
|
370
|
+
async function ensureEngineBinary(options) {
|
|
371
|
+
const found = findEngineBinary(options?.explicitPath, options?.cwd);
|
|
372
|
+
if (found.path) return found;
|
|
373
|
+
const plat = detectPlatform();
|
|
374
|
+
const version = options?.version ?? "latest";
|
|
375
|
+
if (plat.releasePlatform) {
|
|
376
|
+
const result = await downloadBinary({
|
|
377
|
+
version,
|
|
378
|
+
platform: plat.releasePlatform,
|
|
379
|
+
fetch: options?.fetch
|
|
380
|
+
});
|
|
381
|
+
if (result.success) {
|
|
382
|
+
return { path: result.path, source: "downloaded" };
|
|
383
|
+
}
|
|
384
|
+
console.error(`[mmrc] Download failed: ${result.error}`);
|
|
385
|
+
} else {
|
|
386
|
+
console.error(`[mmrc] No pre-built binary for ${plat.os}/${plat.arch}`);
|
|
387
|
+
}
|
|
388
|
+
if (!options?.nonInteractive) {
|
|
389
|
+
const built = await buildFromSource({
|
|
390
|
+
prompt: options?.prompt,
|
|
391
|
+
cwd: options?.cwd
|
|
392
|
+
});
|
|
393
|
+
if (built) {
|
|
394
|
+
return { path: built, source: "built" };
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return { path: null, source: "not-found" };
|
|
398
|
+
}
|
|
399
|
+
function printInstallGuide() {
|
|
400
|
+
const plat = detectPlatform();
|
|
401
|
+
console.error("[mmrc] MindMatrix engine binary not found.\n");
|
|
402
|
+
console.error("The engine binary (mm-api) is required for local development.");
|
|
403
|
+
console.error("Choose one of the following options:\n");
|
|
404
|
+
console.error(" 1. Auto-download (recommended):");
|
|
405
|
+
console.error(" mmrc dev # auto-downloads the binary");
|
|
406
|
+
console.error("");
|
|
407
|
+
console.error(" 2. Build from source (requires Rust toolchain):");
|
|
408
|
+
console.error(' curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh');
|
|
409
|
+
console.error(" cargo build --release -p mm-api");
|
|
410
|
+
console.error("");
|
|
411
|
+
console.error(" 3. Download manually:");
|
|
412
|
+
if (plat.releasePlatform) {
|
|
413
|
+
console.error(` curl -L -o ~/.mmrc/bin/mm-api \\`);
|
|
414
|
+
console.error(` ${GITHUB_RELEASE_BASE}/v0.1.0/mm-api-${plat.releasePlatform}`);
|
|
415
|
+
console.error(` chmod +x ~/.mmrc/bin/mm-api`);
|
|
416
|
+
} else {
|
|
417
|
+
console.error(` # No pre-built binary for ${plat.triple} \u2014 build from source`);
|
|
418
|
+
}
|
|
419
|
+
console.error("");
|
|
420
|
+
console.error(" 4. Use a remote backend instead of local:");
|
|
421
|
+
console.error(" mmrc dev --api-url https://dev.mindmatrix.club/api/v1");
|
|
422
|
+
console.error("");
|
|
423
|
+
}
|
|
424
|
+
function requireEngineBinary(explicitPath) {
|
|
425
|
+
const result = findEngineBinary(explicitPath);
|
|
426
|
+
if (!result.path) {
|
|
427
|
+
printInstallGuide();
|
|
428
|
+
process.exit(1);
|
|
429
|
+
}
|
|
430
|
+
return result.path;
|
|
431
|
+
}
|
|
432
|
+
export {
|
|
433
|
+
GITHUB_RELEASE_BASE,
|
|
434
|
+
MANAGED_BINARY_PATH,
|
|
435
|
+
METADATA_PATH,
|
|
436
|
+
VERSION_FILE_PATH,
|
|
437
|
+
askUser,
|
|
438
|
+
buildDownloadUrl,
|
|
439
|
+
buildFromSource,
|
|
440
|
+
detectPlatform,
|
|
441
|
+
downloadBinary,
|
|
442
|
+
ensureEngineBinary,
|
|
443
|
+
findEngineBinary,
|
|
444
|
+
getCachedVersion,
|
|
445
|
+
getEngineStatus,
|
|
446
|
+
hasCargoInstalled,
|
|
447
|
+
healthCheck,
|
|
448
|
+
installEngine,
|
|
449
|
+
printInstallGuide,
|
|
450
|
+
readMetadata,
|
|
451
|
+
requireEngineBinary,
|
|
452
|
+
setCachedVersion,
|
|
453
|
+
verifyBinary,
|
|
454
|
+
writeMetadata
|
|
455
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -13736,6 +13736,10 @@ async function build(options = {}) {
|
|
|
13736
13736
|
definitions: [],
|
|
13737
13737
|
errorDetails: typeErrors
|
|
13738
13738
|
};
|
|
13739
|
+
} else if (output.includes("not the tsc command") || output.includes("Cannot find module") || output.includes("ERR_MODULE_NOT_FOUND") || output.includes("command not found")) {
|
|
13740
|
+
console.warn(`[mindmatrix-react] TypeScript not installed \u2014 skipping type check.`);
|
|
13741
|
+
console.warn(` Run \`npm install\` to enable type checking, or use --skip-type-check.
|
|
13742
|
+
`);
|
|
13739
13743
|
} else {
|
|
13740
13744
|
console.error(`
|
|
13741
13745
|
[mindmatrix-react] Type check failed:
|
|
@@ -14470,6 +14474,33 @@ function broadcast(clients, data) {
|
|
|
14470
14474
|
}
|
|
14471
14475
|
}
|
|
14472
14476
|
async function createDevServer(options = {}) {
|
|
14477
|
+
const { existsSync: existsSync3 } = await import("fs");
|
|
14478
|
+
const { resolve: resolve3 } = await import("path");
|
|
14479
|
+
const nodeModulesPath = resolve3(process.cwd(), "node_modules");
|
|
14480
|
+
if (!existsSync3(nodeModulesPath)) {
|
|
14481
|
+
console.error(`
|
|
14482
|
+
[mmrc] Error: Dependencies not installed.
|
|
14483
|
+
`);
|
|
14484
|
+
console.error(` Run one of these in your project directory first:
|
|
14485
|
+
`);
|
|
14486
|
+
console.error(` npm install`);
|
|
14487
|
+
console.error(` pnpm install`);
|
|
14488
|
+
console.error(` yarn install
|
|
14489
|
+
`);
|
|
14490
|
+
process.exit(1);
|
|
14491
|
+
}
|
|
14492
|
+
try {
|
|
14493
|
+
await import("vite");
|
|
14494
|
+
} catch {
|
|
14495
|
+
console.error(`
|
|
14496
|
+
[mmrc] Error: 'vite' is not installed.
|
|
14497
|
+
`);
|
|
14498
|
+
console.error(` Install it:
|
|
14499
|
+
`);
|
|
14500
|
+
console.error(` npm install -D vite
|
|
14501
|
+
`);
|
|
14502
|
+
process.exit(1);
|
|
14503
|
+
}
|
|
14473
14504
|
const {
|
|
14474
14505
|
port = 5199,
|
|
14475
14506
|
src = "src/workflows",
|
|
@@ -14531,6 +14562,45 @@ async function createDevServer(options = {}) {
|
|
|
14531
14562
|
}
|
|
14532
14563
|
const pluginOpts = { mode, include, outDir, seedOnCompile: seed, apiUrl, authToken: token };
|
|
14533
14564
|
const proxyTarget = apiUrl.replace(/\/api\/v1\/?$/, "") || apiUrl;
|
|
14565
|
+
const devPlayerPlugin = {
|
|
14566
|
+
name: "mindmatrix-dev-player",
|
|
14567
|
+
resolveId(id) {
|
|
14568
|
+
if (id === "virtual:mm-dev-player") return "\0virtual:mm-dev-player";
|
|
14569
|
+
return null;
|
|
14570
|
+
},
|
|
14571
|
+
load(id) {
|
|
14572
|
+
if (id !== "\0virtual:mm-dev-player") return null;
|
|
14573
|
+
return `
|
|
14574
|
+
import React from 'react';
|
|
14575
|
+
import { createRoot } from 'react-dom/client';
|
|
14576
|
+
import { DevPlayer } from '@mmapp/react/player';
|
|
14577
|
+
|
|
14578
|
+
const tree = window.__MM_DEV_TREE__ || { type: 'Text', props: { children: 'No tree loaded. Compile a workflow to see the preview.' } };
|
|
14579
|
+
const scopes = window.__MM_DEV_SCOPES__ || {};
|
|
14580
|
+
|
|
14581
|
+
function App() {
|
|
14582
|
+
const [currentTree, setTree] = React.useState(tree);
|
|
14583
|
+
const [currentScopes, setScopes] = React.useState(scopes);
|
|
14584
|
+
|
|
14585
|
+
React.useEffect(() => {
|
|
14586
|
+
const ws = new WebSocket('ws://' + location.host + '/__mm_dev');
|
|
14587
|
+
ws.onmessage = (ev) => {
|
|
14588
|
+
try {
|
|
14589
|
+
const msg = JSON.parse(ev.data);
|
|
14590
|
+
if (msg.type === 'workflow:compiled' && msg.tree) setTree(msg.tree);
|
|
14591
|
+
if (msg.type === 'workflow:compiled' && msg.scopes) setScopes(msg.scopes);
|
|
14592
|
+
} catch {}
|
|
14593
|
+
};
|
|
14594
|
+
return () => ws.close();
|
|
14595
|
+
}, []);
|
|
14596
|
+
|
|
14597
|
+
return React.createElement(DevPlayer, { tree: currentTree, scopes: currentScopes, title: document.title || 'MindMatrix Dev' });
|
|
14598
|
+
}
|
|
14599
|
+
|
|
14600
|
+
createRoot(document.getElementById('root')).render(React.createElement(App));
|
|
14601
|
+
`;
|
|
14602
|
+
}
|
|
14603
|
+
};
|
|
14534
14604
|
let deployInFlight = false;
|
|
14535
14605
|
const compileDeployPlugin = {
|
|
14536
14606
|
name: "mindmatrix-dev-compile-deploy",
|
|
@@ -14575,6 +14645,7 @@ async function createDevServer(options = {}) {
|
|
|
14575
14645
|
plugins: [
|
|
14576
14646
|
mindmatrixReact(pluginOpts),
|
|
14577
14647
|
compileDeployPlugin,
|
|
14648
|
+
devPlayerPlugin,
|
|
14578
14649
|
{ name: "mindmatrix-error-overlay", configureServer(server) {
|
|
14579
14650
|
server.middlewares.use(errorOverlayMiddleware());
|
|
14580
14651
|
} }
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-XDVM4YHX.mjs";
|
|
22
22
|
import {
|
|
23
23
|
createDevServer
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-UBDNXVL2.mjs";
|
|
25
25
|
import "./chunk-BZEXUPDH.mjs";
|
|
26
26
|
import {
|
|
27
27
|
buildEnvelope
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
} from "./chunk-ABYPKRSB.mjs";
|
|
32
32
|
import {
|
|
33
33
|
build
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-DNWDIPH2.mjs";
|
|
35
35
|
import {
|
|
36
36
|
computeEnvelopeId,
|
|
37
37
|
createSourceEnvelope,
|