@myop/cli 0.1.53 β†’ 0.1.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/myop-cli.js +1019 -916
  2. package/package.json +1 -1
package/dist/myop-cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
- var St = Object.defineProperty;
3
- var xt = (o, t, e) => t in o ? St(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
4
- var we = (o, t, e) => xt(o, typeof t != "symbol" ? t + "" : t, e);
5
- import V from "ora";
6
- import { select as ot, Separator as De } from "@inquirer/prompts";
7
- import { Command as bt, Option as ue } from "commander";
8
- import { execSync as Q, spawn as $t } from "child_process";
9
- import N, { join as _e } from "path";
10
- import P, { readFileSync as Ct } from "fs";
11
- import Be from "crypto";
12
- import Mt from "http";
13
- import { URL as nt, URLSearchParams as st } from "url";
14
- import Pt from "open";
15
- import it from "os";
16
- const Et = `
2
+ var bt = Object.defineProperty;
3
+ var Ct = (o, t, e) => t in o ? bt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
4
+ var ve = (o, t, e) => Ct(o, typeof t != "symbol" ? t + "" : t, e);
5
+ import z from "ora";
6
+ import { select as st, Separator as Le } from "@inquirer/prompts";
7
+ import { Command as Pt, Option as fe } from "commander";
8
+ import { execSync as Q, spawn as Mt } from "child_process";
9
+ import R, { join as je } from "path";
10
+ import C, { readFileSync as Et } from "fs";
11
+ import ze from "crypto";
12
+ import It from "http";
13
+ import { URL as it, URLSearchParams as rt } from "url";
14
+ import Ot from "open";
15
+ import at from "os";
16
+ const kt = `
17
17
  Usage: myop [OPTIONS] COMMAND [ARGS]...
18
18
 
19
19
  A powerful command-line interface for managing your Myop projects.
@@ -55,81 +55,81 @@ Examples:
55
55
  verbose: !1
56
56
  },
57
57
  myopConfig: null
58
- }, rt = {
58
+ }, lt = {
59
59
  name: "πŸ“₯ Install Myop generated dependencies",
60
60
  value: "myopInstall",
61
61
  description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
62
62
  action: async () => {
63
63
  console.info("installing... ");
64
64
  for (const o of v.myopConfig.flows) {
65
- const t = N.join(v.executionPath, "/node_modules/@myop/flow-types/");
65
+ const t = R.join(v.executionPath, "/node_modules/@myop/flow-types/");
66
66
  console.info(`Generate flow at ${t}`), console.info(`Generated flow at ${t}`);
67
67
  }
68
68
  process.exit();
69
69
  }
70
- }, Ot = (o) => {
71
- const t = N.join(v.executionPath, o);
70
+ }, Rt = (o) => {
71
+ const t = R.join(v.executionPath, o);
72
72
  console.info(`reading config file from: ${t}`);
73
- const e = P.readFileSync(t, "utf8"), n = JSON.parse(e);
73
+ const e = C.readFileSync(t, "utf8"), n = JSON.parse(e);
74
74
  return console.info("config file loaded, ", n), n;
75
- }, Je = (o, t) => {
76
- const e = N.join(v.executionPath, o);
75
+ }, We = (o, t) => {
76
+ const e = R.join(v.executionPath, o);
77
77
  console.info(`writing config file to: ${e}`);
78
78
  try {
79
79
  const n = JSON.stringify(t, null, 2);
80
- P.writeFileSync(e, n), console.info(`config file updated ${n}`);
80
+ C.writeFileSync(e, n), console.info(`config file updated ${n}`);
81
81
  } catch (n) {
82
82
  throw console.info(`error ${n} while writing to ${e}, JSON: ${t}`), console.log(`
83
83
  ⚠️ Failed write config file to ${e}, for more info use verbose flag`), n;
84
84
  }
85
- }, at = {
85
+ }, ct = {
86
86
  name: "🌟 Add flow definition to your project",
87
87
  value: "addFlow",
88
88
  description: "Adds flow to yours myop.config.json",
89
89
  _action: (o) => {
90
- v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), Je(v.options.configPath, v.myopConfig);
90
+ v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), We(v.options.configPath, v.myopConfig);
91
91
  },
92
92
  action: async () => {
93
93
  }
94
- }, lt = {
94
+ }, dt = {
95
95
  name: "🚫 Remove flow definition from your project",
96
96
  value: "removeFlow",
97
97
  description: "Removes flow to yours myop.config.json",
98
98
  _action: (o) => {
99
- v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), Je(v.options.configPath, v.myopConfig);
99
+ v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), We(v.options.configPath, v.myopConfig);
100
100
  },
101
101
  action: () => {
102
102
  }
103
- }, It = {
103
+ }, _t = {
104
104
  name: "πŸ‘‹ Quit",
105
105
  value: "quit",
106
106
  description: "Quit and continue coding.",
107
107
  action: () => {
108
108
  process.exit();
109
109
  }
110
- }, kt = {
110
+ }, Nt = {
111
111
  name: "🟒 Create new component",
112
112
  value: "-",
113
113
  disabled: "(not available yet)"
114
- }, Rt = {
114
+ }, Tt = {
115
115
  name: "πŸ”΅ Create new experience",
116
116
  value: "-",
117
117
  disabled: "(not available yet)"
118
- }, Nt = {
118
+ }, Ft = {
119
119
  name: "🟑 Create new skin",
120
120
  value: "-",
121
121
  disabled: "(not available yet)"
122
- }, Tt = {
122
+ }, jt = {
123
123
  name: "πŸ”΄ Create new flow",
124
124
  value: "-",
125
125
  disabled: "(not available yet)"
126
- }, _t = {
126
+ }, At = {
127
127
  name: "πŸ†• Define new custom Myop message",
128
128
  value: "generateMyopMessage",
129
129
  description: "️Help you creates the right structure for a new Myop message, including types and handlers.",
130
130
  disabled: "(not available yet)"
131
- }, Ft = [_t, kt, Rt, Nt, Tt];
132
- function jt(o, t, e, n) {
131
+ }, Dt = [At, Nt, Tt, Ft, jt];
132
+ function Lt(o, t, e, n) {
133
133
  return `<!DOCTYPE html>
134
134
  <html lang="en">
135
135
  <head>
@@ -219,19 +219,19 @@ ${n}
219
219
  </body>
220
220
  </html>`;
221
221
  }
222
- function Dt(o) {
222
+ function Ut(o) {
223
223
  return o.includes("esbuild") && o.includes("another platform");
224
224
  }
225
- function At(o) {
225
+ function Ht(o) {
226
226
  return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
227
227
  }
228
- function Lt() {
228
+ function Bt() {
229
229
  console.error(`
230
230
  ❌ esbuild platform mismatch detected!`), console.error(" Your node_modules contains esbuild binaries for a different OS."), console.error(`
231
231
  This usually happens when node_modules is copied between different`), console.error(` operating systems (e.g., Windows β†’ Mac, or Mac β†’ Linux).
232
232
  `);
233
233
  }
234
- function Ut(o) {
234
+ function Jt(o) {
235
235
  return new Promise((t) => {
236
236
  console.log(`πŸ”§ Attempting to fix: removing node_modules and reinstalling...
237
237
  `);
@@ -244,9 +244,9 @@ function Ut(o) {
244
244
  return;
245
245
  }
246
246
  console.log(" βœ“ Removed node_modules"), console.log(` ⏳ Running npm install...
247
- `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, d, g) => {
247
+ `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, r, p) => {
248
248
  if (i) {
249
- console.error("❌ npm install failed:", i.message), g && console.error(g), t(!1);
249
+ console.error("❌ npm install failed:", i.message), p && console.error(p), t(!1);
250
250
  return;
251
251
  }
252
252
  console.log(` βœ“ Dependencies reinstalled successfully!
@@ -255,79 +255,79 @@ function Ut(o) {
255
255
  });
256
256
  });
257
257
  }
258
- async function ct(o, t, e, n, s = {}) {
258
+ async function pt(o, t, e, n, s = {}) {
259
259
  const {
260
260
  hasTriedPlatformFix: i = !1,
261
- hasTriedInstall: d = !1,
262
- onRetry: g
263
- } = s, h = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
264
- return !i && Dt(h) ? (Lt(), await Ut(n) && g ? (console.log(`πŸ”„ Retrying build...
265
- `), g(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && At(h) ? (console.log("πŸ“¦ Missing dependencies detected, running npm install..."), new Promise((l) => {
266
- n("npm install", (c, y, S) => {
267
- if (c) {
268
- console.error("❌ Failed to install dependencies:", c.message), S && console.error(S), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
261
+ hasTriedInstall: r = !1,
262
+ onRetry: p
263
+ } = s, m = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
264
+ return !i && Ut(m) ? (Bt(), await Jt(n) && p ? (console.log(`πŸ”„ Retrying build...
265
+ `), p(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : !r && Ht(m) ? (console.log("πŸ“¦ Missing dependencies detected, running npm install..."), new Promise((l) => {
266
+ n("npm install", (d, y, S) => {
267
+ if (d) {
268
+ console.error("❌ Failed to install dependencies:", d.message), S && console.error(S), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
269
269
  return;
270
270
  }
271
- console.log("βœ… Dependencies installed"), g && g(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
271
+ console.log("βœ… Dependencies installed"), p && p(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
272
272
  });
273
- })) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: d };
273
+ })) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: r };
274
274
  }
275
- async function be() {
275
+ async function Ce() {
276
276
  const o = await import("fs"), t = await import("path"), { exec: e } = await import("child_process"), n = await import("http"), { createHash: s } = await import("node:crypto");
277
277
  let i;
278
278
  if (import.meta.url.startsWith("file://")) {
279
- const r = new URL(import.meta.url).pathname, m = process.platform === "win32" && r.startsWith("/") ? r.slice(1) : r;
280
- i = t.default.dirname(m);
279
+ const a = new URL(import.meta.url).pathname, f = process.platform === "win32" && a.startsWith("/") ? a.slice(1) : a;
280
+ i = t.default.dirname(f);
281
281
  } else
282
282
  i = t.default.dirname(import.meta.url);
283
- const d = t.default.join(i, "commands", "dev", "management-website"), g = o.default.readFileSync(t.default.join(d, "styles.css"), "utf-8"), h = o.default.readFileSync(t.default.join(d, "app.js"), "utf-8"), l = 9292, c = 9293;
284
- let y = "./dist", S = !1, x = !1, u = !1, p = null;
283
+ const r = t.default.join(i, "commands", "dev", "management-website"), p = o.default.readFileSync(t.default.join(r, "styles.css"), "utf-8"), m = o.default.readFileSync(t.default.join(r, "app.js"), "utf-8"), l = 9292, d = 9293;
284
+ let y = "./dist", S = !1, x = !1, g = !1, u = null;
285
285
  const E = () => {
286
286
  try {
287
- const a = o.default.readdirSync(".").filter((r) => !r.endsWith(".html") || r.startsWith(".") ? !1 : o.default.statSync(r).isFile());
288
- if (a.length === 1)
289
- return a[0];
287
+ const c = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
288
+ if (c.length === 1)
289
+ return c[0];
290
290
  } catch {
291
291
  }
292
292
  return null;
293
- }, I = () => {
293
+ }, O = () => {
294
294
  try {
295
- const a = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
296
- return !!(a.scripts && a.scripts.build);
295
+ const c = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
296
+ return !!(c.scripts && c.scripts.build);
297
297
  } catch {
298
298
  return !1;
299
299
  }
300
- }, $ = (a) => {
301
- const r = process.platform;
302
- let m;
303
- r === "darwin" ? m = `open "${a}"` : r === "win32" ? m = `start "" "${a}"` : m = `xdg-open "${a}"`, e(m, (f) => {
300
+ }, b = (c) => {
301
+ const a = process.platform;
302
+ let f;
303
+ a === "darwin" ? f = `open "${c}"` : a === "win32" ? f = `start "" "${c}"` : f = `xdg-open "${c}"`, e(f, (h) => {
304
304
  });
305
- }, C = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
306
- let M, R, k = !1;
307
- p = E();
308
- const L = I();
305
+ }, P = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
306
+ let M, _, k = !1;
307
+ u = E();
308
+ const L = O();
309
309
  try {
310
- const a = o.default.readFileSync(j, "utf-8"), r = JSON.parse(a);
311
- M = r.componentId || "DEV", R = r.componentName || r.name || null, k = r.HMR === !0, p && !L && (u = !0, k = !0, console.log(`πŸ“„ Single HTML file mode: ${p}`)), k && console.log("πŸ”₯ HMR enabled");
312
- } catch (a) {
313
- p && !L ? (u = !0, M = "DEV", R = t.default.basename(p, ".html"), k = !0, console.log(`πŸ“„ Single HTML file mode: ${p}`), console.log("πŸ”₯ HMR enabled")) : (console.error("❌ Error reading myop.config.json:", a.message), process.exit(1));
310
+ const c = o.default.readFileSync(j, "utf-8"), a = JSON.parse(c);
311
+ M = a.componentId || "DEV", _ = a.componentName || a.name || null, k = a.HMR === !0, u && !L && (g = !0, k = !0, console.log(`πŸ“„ Single HTML file mode: ${u}`)), k && console.log("πŸ”₯ HMR enabled");
312
+ } catch (c) {
313
+ u && !L ? (g = !0, M = "DEV", _ = t.default.basename(u, ".html"), k = !0, console.log(`πŸ“„ Single HTML file mode: ${u}`), console.log("πŸ”₯ HMR enabled")) : (console.error("❌ Error reading myop.config.json:", c.message), process.exit(1));
314
314
  }
315
- const A = async () => {
315
+ const D = async () => {
316
316
  if (M !== "DEV" && M !== "NEW")
317
317
  return M;
318
318
  try {
319
- const r = ((await new Promise((w, b) => {
320
- const O = {
319
+ const a = ((await new Promise((w, $) => {
320
+ const I = {
321
321
  hostname: "localhost",
322
- port: c,
322
+ port: d,
323
323
  path: "/_list",
324
324
  method: "GET",
325
325
  timeout: 1e3
326
- }, F = n.default.request(O, (H) => {
327
- let G = "";
328
- H.on("data", (ee) => G += ee), H.on("end", () => {
326
+ }, F = n.default.request(I, (H) => {
327
+ let Y = "";
328
+ H.on("data", (ee) => Y += ee), H.on("end", () => {
329
329
  try {
330
- w(JSON.parse(G));
330
+ w(JSON.parse(Y));
331
331
  } catch {
332
332
  w({ components: [] });
333
333
  }
@@ -337,19 +337,19 @@ async function be() {
337
337
  F.destroy(), w({ components: [] });
338
338
  }), F.end();
339
339
  })).components || []).map(([w]) => w).filter((w) => w === "DEV" || w === "NEW" || /^DEV\d+$/.test(w) || /^NEW\d+$/.test(w));
340
- if (r.length === 0)
340
+ if (a.length === 0)
341
341
  return "DEV1";
342
- const m = r.map((w) => {
342
+ const f = a.map((w) => {
343
343
  if (w === "DEV" || w === "NEW") return 1;
344
- const b = w.match(/^DEV(\d+)$/), O = w.match(/^NEW(\d+)$/);
345
- return b ? parseInt(b[1], 10) : O ? parseInt(O[1], 10) : 0;
344
+ const $ = w.match(/^DEV(\d+)$/), I = w.match(/^NEW(\d+)$/);
345
+ return $ ? parseInt($[1], 10) : I ? parseInt(I[1], 10) : 0;
346
346
  }).filter((w) => w > 0);
347
- return `DEV${Math.max(...m, 0) + 1}`;
347
+ return `DEV${Math.max(...f, 0) + 1}`;
348
348
  } catch {
349
349
  return "DEV1";
350
350
  }
351
- }, _ = process.cwd(), z = (a) => {
352
- const r = t.default.extname(a).toLowerCase();
351
+ }, T = process.cwd(), W = (c) => {
352
+ const a = t.default.extname(c).toLowerCase();
353
353
  return {
354
354
  ".html": "text/html",
355
355
  ".js": "text/javascript",
@@ -360,42 +360,42 @@ async function be() {
360
360
  ".gif": "image/gif",
361
361
  ".svg": "image/svg+xml",
362
362
  ".ico": "image/x-icon"
363
- }[r] || "application/octet-stream";
364
- }, T = /* @__PURE__ */ new Map(), oe = [], Pe = 50, X = [], se = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), ft = (a, r, m) => {
365
- if (a.url.startsWith("/_hmr/")) {
366
- const f = a.url.split("/_hmr/")[1], w = a.headers["sec-websocket-key"], b = s("sha1").update(w + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
367
- r.write(
363
+ }[a] || "application/octet-stream";
364
+ }, N = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (c, a, f) => {
365
+ if (c.url.startsWith("/_hmr/")) {
366
+ const h = c.url.split("/_hmr/")[1], w = c.headers["sec-websocket-key"], $ = s("sha1").update(w + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
367
+ a.write(
368
368
  `HTTP/1.1 101 Switching Protocols\r
369
369
  Upgrade: websocket\r
370
370
  Connection: Upgrade\r
371
- Sec-WebSocket-Accept: ${b}\r
371
+ Sec-WebSocket-Accept: ${$}\r
372
372
  \r
373
373
  `
374
- ), q.has(f) || q.set(f, /* @__PURE__ */ new Set()), q.get(f).add(r), console.log(`πŸ”Œ HMR client connected: ${f}`), r.on("close", () => {
375
- const O = q.get(f);
376
- O && (O.delete(r), O.size === 0 && q.delete(f)), console.log(`πŸ”Œ HMR client disconnected: ${f}`);
377
- }), r.on("error", () => {
378
- const O = q.get(f);
379
- O && O.delete(r);
374
+ ), X.has(h) || X.set(h, /* @__PURE__ */ new Set()), X.get(h).add(a), console.log(`πŸ”Œ HMR client connected: ${h}`), a.on("close", () => {
375
+ const I = X.get(h);
376
+ I && (I.delete(a), I.size === 0 && X.delete(h)), console.log(`πŸ”Œ HMR client disconnected: ${h}`);
377
+ }), a.on("error", () => {
378
+ const I = X.get(h);
379
+ I && I.delete(a);
380
380
  });
381
381
  }
382
- }, Ee = n.default.createServer((a, r) => {
383
- if (r.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
384
- let m = "";
385
- a.on("data", (f) => m += f), a.on("end", () => {
382
+ }, Oe = n.default.createServer((c, a) => {
383
+ if (a.setHeader("Content-Type", "application/json"), c.method === "POST" && c.url === "/_register") {
384
+ let f = "";
385
+ c.on("data", (h) => f += h), c.on("end", () => {
386
386
  try {
387
- const { componentId: f, distPath: w, componentName: b, htmlFile: O } = JSON.parse(m);
388
- T.set(f, { path: w, name: b || null, htmlFile: O || null });
389
- const F = b ? ` (${b})` : "";
390
- console.log(`βœ… Registered: ${f}${F} -> ${w}${O ? "/" + O : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
391
- const H = Array.from(T.entries()).map(([G, ee]) => ({
392
- id: G,
387
+ const { componentId: h, distPath: w, componentName: $, htmlFile: I } = JSON.parse(f);
388
+ N.set(h, { path: w, name: $ || null, htmlFile: I || null });
389
+ const F = $ ? ` (${$})` : "";
390
+ console.log(`βœ… Registered: ${h}${F} -> ${w}${I ? "/" + I : ""}`), a.writeHead(200), a.end(JSON.stringify({ success: !0, registered: Array.from(N.keys()) }));
391
+ const H = Array.from(N.entries()).map(([Y, ee]) => ({
392
+ id: Y,
393
393
  path: ee.path,
394
394
  name: ee.name
395
395
  }));
396
- X.forEach((G) => {
396
+ q.forEach((Y) => {
397
397
  try {
398
- G.write(`data: ${JSON.stringify({
398
+ Y.write(`data: ${JSON.stringify({
399
399
  type: "components",
400
400
  components: H
401
401
  })}
@@ -404,24 +404,24 @@ Sec-WebSocket-Accept: ${b}\r
404
404
  } catch {
405
405
  }
406
406
  });
407
- } catch (f) {
408
- r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
407
+ } catch (h) {
408
+ a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
409
409
  }
410
410
  });
411
- } else if (a.method === "POST" && a.url === "/_unregister") {
412
- let m = "";
413
- a.on("data", (f) => m += f), a.on("end", () => {
411
+ } else if (c.method === "POST" && c.url === "/_unregister") {
412
+ let f = "";
413
+ c.on("data", (h) => f += h), c.on("end", () => {
414
414
  try {
415
- const { componentId: f } = JSON.parse(m);
416
- T.delete(f), console.log(`❌ Unregistered: ${f}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
417
- const w = Array.from(T.entries()).map(([b, O]) => ({
418
- id: b,
419
- path: O.path,
420
- name: O.name
415
+ const { componentId: h } = JSON.parse(f);
416
+ N.delete(h), console.log(`❌ Unregistered: ${h}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
417
+ const w = Array.from(N.entries()).map(([$, I]) => ({
418
+ id: $,
419
+ path: I.path,
420
+ name: I.name
421
421
  }));
422
- X.forEach((b) => {
422
+ q.forEach(($) => {
423
423
  try {
424
- b.write(`data: ${JSON.stringify({
424
+ $.write(`data: ${JSON.stringify({
425
425
  type: "components",
426
426
  components: w
427
427
  })}
@@ -430,74 +430,74 @@ Sec-WebSocket-Accept: ${b}\r
430
430
  } catch {
431
431
  }
432
432
  });
433
- } catch (f) {
434
- r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
433
+ } catch (h) {
434
+ a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
435
435
  }
436
436
  });
437
- } else if (a.method === "GET" && a.url === "/_list")
438
- r.writeHead(200), r.end(JSON.stringify({ components: Array.from(T.entries()) }));
439
- else if (a.method === "POST" && a.url === "/_hmr_notify") {
440
- let m = "";
441
- a.on("data", (f) => m += f), a.on("end", () => {
437
+ } else if (c.method === "GET" && c.url === "/_list")
438
+ a.writeHead(200), a.end(JSON.stringify({ components: Array.from(N.entries()) }));
439
+ else if (c.method === "POST" && c.url === "/_hmr_notify") {
440
+ let f = "";
441
+ c.on("data", (h) => f += h), c.on("end", () => {
442
442
  try {
443
- const { componentId: f, html: w } = JSON.parse(m), b = q.get(f);
444
- if (b && b.size > 0) {
445
- console.log(`πŸ”₯ Notifying ${b.size} HMR client(s) for: ${f}`);
446
- const O = JSON.stringify({ type: "update", html: w }), F = Qe(O);
447
- b.forEach((H) => {
443
+ const { componentId: h, html: w } = JSON.parse(f), $ = X.get(h);
444
+ if ($ && $.size > 0) {
445
+ console.log(`πŸ”₯ Notifying ${$.size} HMR client(s) for: ${h}`);
446
+ const I = JSON.stringify({ type: "update", html: w }), F = qe(I);
447
+ $.forEach((H) => {
448
448
  try {
449
449
  H.write(F);
450
450
  } catch {
451
- b.delete(H);
451
+ $.delete(H);
452
452
  }
453
- }), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: b.size }));
453
+ }), a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: $.size }));
454
454
  } else
455
- r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: 0 }));
456
- } catch (f) {
457
- r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
455
+ a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: 0 }));
456
+ } catch (h) {
457
+ a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
458
458
  }
459
459
  });
460
460
  } else
461
- r.writeHead(404), r.end(JSON.stringify({ error: "Not found" }));
462
- }), ge = n.default.createServer((a, r) => {
463
- if (a.url.includes("..")) {
464
- r.writeHead(403, { "Content-Type": "text/plain" }), r.end("Forbidden");
461
+ a.writeHead(404), a.end(JSON.stringify({ error: "Not found" }));
462
+ }), ge = n.default.createServer((c, a) => {
463
+ if (c.url.includes("..")) {
464
+ a.writeHead(403, { "Content-Type": "text/plain" }), a.end("Forbidden");
465
465
  return;
466
466
  }
467
- const m = new URL(a.url, `http://localhost:${l}`), f = m.pathname, w = f.split("/").filter((J) => J);
468
- if (f.startsWith("/consume")) {
469
- const J = m.searchParams.get("id");
467
+ const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname, w = h.split("/").filter((J) => J);
468
+ if (h.startsWith("/consume")) {
469
+ const J = f.searchParams.get("id");
470
470
  if (!J) {
471
- r.writeHead(400, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
471
+ a.writeHead(400, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
472
472
  return;
473
473
  }
474
- const W = T.get(J), Y = W ? W.path : null, de = (te) => {
474
+ const V = N.get(J), G = V ? V.path : null, de = (te) => {
475
475
  let U = "Unknown", K = "Unknown";
476
- if (a.headers.referer || a.headers.referrer) {
477
- const B = a.headers.referer || a.headers.referrer;
476
+ if (c.headers.referer || c.headers.referrer) {
477
+ const B = c.headers.referer || c.headers.referrer;
478
478
  try {
479
479
  const ie = new URL(B);
480
480
  U = ie.origin, K = ie.hostname || ie.origin;
481
481
  } catch {
482
482
  U = B, K = B;
483
483
  }
484
- } else if (a.headers.origin)
484
+ } else if (c.headers.origin)
485
485
  try {
486
- const B = new URL(a.headers.origin);
486
+ const B = new URL(c.headers.origin);
487
487
  U = B.origin, K = B.hostname || B.origin;
488
488
  } catch {
489
- U = a.headers.origin, K = a.headers.origin;
489
+ U = c.headers.origin, K = c.headers.origin;
490
490
  }
491
- else if (a.socket.remoteAddress) {
492
- const B = a.socket.remoteAddress;
491
+ else if (c.socket.remoteAddress) {
492
+ const B = c.socket.remoteAddress;
493
493
  B === "::1" || B === "::ffff:127.0.0.1" ? (U = "localhost", K = "localhost (direct)") : (U = B, K = B.replace("::ffff:", ""));
494
494
  }
495
- const Ne = a.headers.referer || a.headers.referrer || U, ye = {
495
+ const Te = c.headers.referer || c.headers.referrer || U, we = {
496
496
  type: "request",
497
497
  componentId: J,
498
498
  timestamp: Date.now(),
499
499
  servedLocally: te,
500
- referrer: Ne,
500
+ referrer: Te,
501
501
  origin: U,
502
502
  originLabel: K
503
503
  };
@@ -506,7 +506,7 @@ Sec-WebSocket-Accept: ${b}\r
506
506
  label: K,
507
507
  firstSeen: Date.now(),
508
508
  requestCount: 0
509
- }), X.forEach((B) => {
509
+ }), q.forEach((B) => {
510
510
  try {
511
511
  B.write(`data: ${JSON.stringify({
512
512
  type: "origins",
@@ -517,8 +517,8 @@ Sec-WebSocket-Accept: ${b}\r
517
517
  } catch {
518
518
  }
519
519
  }));
520
- const Te = se.get(U);
521
- Te.requestCount++, X.forEach((B) => {
520
+ const Fe = se.get(U);
521
+ Fe.requestCount++, q.forEach((B) => {
522
522
  try {
523
523
  B.write(`data: ${JSON.stringify({
524
524
  type: "origins",
@@ -528,168 +528,168 @@ Sec-WebSocket-Accept: ${b}\r
528
528
  `);
529
529
  } catch {
530
530
  }
531
- }), oe.push(ye), oe.length > Pe && oe.shift(), X.forEach((B) => {
531
+ }), oe.push(we), oe.length > Ie && oe.shift(), q.forEach((B) => {
532
532
  try {
533
- B.write(`data: ${JSON.stringify(ye)}
533
+ B.write(`data: ${JSON.stringify(we)}
534
534
 
535
535
  `);
536
536
  } catch {
537
537
  }
538
538
  });
539
539
  };
540
- if (Y) {
541
- const te = W.htmlFile ? t.default.join(Y, W.htmlFile) : t.default.join(Y, "index.html");
540
+ if (G) {
541
+ const te = V.htmlFile ? t.default.join(G, V.htmlFile) : t.default.join(G, "index.html");
542
542
  o.default.readFile(te, "utf-8", (U, K) => {
543
543
  if (U) {
544
- console.log(`❌ File not found: ${te}`), r.writeHead(404, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "index.html not found" }));
544
+ console.log(`❌ File not found: ${te}`), a.writeHead(404, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "index.html not found" }));
545
545
  return;
546
546
  }
547
- const Ne = Oe(K, J), ye = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Te = {
547
+ const Te = ke(K, J), we = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Fe = {
548
548
  item: {
549
549
  name: J,
550
550
  id: J,
551
551
  consume_variant: [
552
552
  {
553
- id: ye,
553
+ id: we,
554
554
  name: "dev version",
555
555
  loader: {
556
556
  type: "HTMLLoader",
557
557
  shadowRootMode: "localFrame",
558
- HTML: Ne
558
+ HTML: Te
559
559
  }
560
560
  }
561
561
  ]
562
562
  }
563
563
  };
564
- console.log(`βœ… Serving consume JSON for: ${J}`), de(!0), r.writeHead(200, {
564
+ console.log(`βœ… Serving consume JSON for: ${J}`), de(!0), a.writeHead(200, {
565
565
  "Content-Type": "application/json",
566
566
  "Access-Control-Allow-Origin": "*"
567
- }), r.end(JSON.stringify(Te, null, 2));
567
+ }), a.end(JSON.stringify(Fe, null, 2));
568
568
  });
569
569
  } else {
570
570
  console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${J}`);
571
- const te = `https://cloud.myop.dev/consume${m.search}`;
571
+ const te = `https://cloud.myop.dev/consume${f.search}`;
572
572
  de(!1), fetch(te).then((U) => U.text()).then((U) => {
573
- r.writeHead(200, {
573
+ a.writeHead(200, {
574
574
  "Content-Type": "application/json",
575
575
  "Access-Control-Allow-Origin": "*"
576
- }), r.end(U);
576
+ }), a.end(U);
577
577
  }).catch((U) => {
578
- console.error(`❌ Proxy error: ${U.message}`), r.writeHead(502, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
578
+ console.error(`❌ Proxy error: ${U.message}`), a.writeHead(502, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
579
579
  });
580
580
  }
581
581
  return;
582
582
  }
583
- if (f === "/events") {
584
- r.writeHead(200, {
583
+ if (h === "/events") {
584
+ a.writeHead(200, {
585
585
  "Content-Type": "text/event-stream",
586
586
  "Cache-Control": "no-cache",
587
587
  Connection: "keep-alive",
588
588
  "Access-Control-Allow-Origin": "*"
589
- }), X.push(r);
590
- const J = Array.from(T.entries()).map(([W, Y]) => ({
591
- id: W,
592
- path: Y.path,
593
- name: Y.name
589
+ }), q.push(a);
590
+ const J = Array.from(N.entries()).map(([V, G]) => ({
591
+ id: V,
592
+ path: G.path,
593
+ name: G.name
594
594
  }));
595
- r.write(`data: ${JSON.stringify({
595
+ a.write(`data: ${JSON.stringify({
596
596
  type: "components",
597
597
  components: J
598
598
  })}
599
599
 
600
- `), r.write(`data: ${JSON.stringify({
600
+ `), a.write(`data: ${JSON.stringify({
601
601
  type: "origins",
602
602
  origins: Array.from(se.values())
603
603
  })}
604
604
 
605
- `), r.write(`data: ${JSON.stringify({
605
+ `), a.write(`data: ${JSON.stringify({
606
606
  type: "requestLog",
607
607
  log: oe
608
608
  })}
609
609
 
610
- `), a.on("close", () => {
611
- const W = X.indexOf(r);
612
- W !== -1 && X.splice(W, 1);
610
+ `), c.on("close", () => {
611
+ const V = q.indexOf(a);
612
+ V !== -1 && q.splice(V, 1);
613
613
  });
614
614
  return;
615
615
  }
616
616
  if (w.length === 0) {
617
- r.writeHead(200, { "Content-Type": "text/html" }), r.end(jt(l, c, g, h));
617
+ a.writeHead(200, { "Content-Type": "text/html" }), a.end(Lt(l, d, p, m));
618
618
  return;
619
619
  }
620
620
  if (w[0] !== "view") {
621
- r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not found. Use /view/<componentId>/ to access components.");
621
+ a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not found. Use /view/<componentId>/ to access components.");
622
622
  return;
623
623
  }
624
624
  if (w.length < 2) {
625
- r.writeHead(400, { "Content-Type": "text/plain" }), r.end("Component ID required. Use /view/<componentId>/");
625
+ a.writeHead(400, { "Content-Type": "text/plain" }), a.end("Component ID required. Use /view/<componentId>/");
626
626
  return;
627
627
  }
628
- const b = w[1], O = T.get(b);
629
- if (!O) {
630
- r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${b}`);
628
+ const $ = w[1], I = N.get($);
629
+ if (!I) {
630
+ a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${$}`);
631
631
  return;
632
632
  }
633
- const F = O.path, H = w.slice(2), G = O.htmlFile || "index.html", ee = H.length === 0 ? G : H.join("/"), ce = t.default.join(F, ee);
634
- console.log(`πŸ“₯ Request: ${a.url} -> ${ce}`), o.default.readFile(ce, (J, W) => {
633
+ const F = I.path, H = w.slice(2), Y = I.htmlFile || "index.html", ee = H.length === 0 ? Y : H.join("/"), ce = t.default.join(F, ee);
634
+ console.log(`πŸ“₯ Request: ${c.url} -> ${ce}`), o.default.readFile(ce, (J, V) => {
635
635
  if (J) {
636
- console.log(`❌ File not found: ${ce}`), r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not Found");
636
+ console.log(`❌ File not found: ${ce}`), a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not Found");
637
637
  return;
638
638
  }
639
- const Y = z(ce);
640
- console.log(`βœ… Serving: ${ce} (${Y})`);
641
- let de = W;
642
- if (Y === "text/html" && k) {
643
- const te = W.toString("utf-8");
644
- de = Oe(te, b);
639
+ const G = W(ce);
640
+ console.log(`βœ… Serving: ${ce} (${G})`);
641
+ let de = V;
642
+ if (G === "text/html" && k) {
643
+ const te = V.toString("utf-8");
644
+ de = ke(te, $);
645
645
  }
646
- r.writeHead(200, {
647
- "Content-Type": Y,
646
+ a.writeHead(200, {
647
+ "Content-Type": G,
648
648
  "Access-Control-Allow-Origin": "*"
649
- }), r.end(de);
649
+ }), a.end(de);
650
650
  });
651
- }), Ke = () => new Promise((a, r) => {
652
- const m = u ? t.default.resolve(_) : t.default.resolve(_, y), f = JSON.stringify({
651
+ }), Ze = () => new Promise((c, a) => {
652
+ const f = g ? t.default.resolve(T) : t.default.resolve(T, y), h = JSON.stringify({
653
653
  componentId: M,
654
- distPath: m,
655
- componentName: R,
656
- htmlFile: u ? p : null
654
+ distPath: f,
655
+ componentName: _,
656
+ htmlFile: g ? u : null
657
657
  }), w = {
658
658
  hostname: "localhost",
659
- port: c,
659
+ port: d,
660
660
  path: "/_register",
661
661
  method: "POST",
662
662
  headers: {
663
663
  "Content-Type": "application/json",
664
- "Content-Length": Buffer.byteLength(f)
664
+ "Content-Length": Buffer.byteLength(h)
665
665
  }
666
- }, b = n.default.request(w, (O) => {
666
+ }, $ = n.default.request(w, (I) => {
667
667
  let F = "";
668
- O.on("data", (H) => F += H), O.on("end", () => {
669
- O.statusCode === 200 ? a(JSON.parse(F)) : r(new Error(`Registration failed: ${O.statusCode}`));
668
+ I.on("data", (H) => F += H), I.on("end", () => {
669
+ I.statusCode === 200 ? c(JSON.parse(F)) : a(new Error(`Registration failed: ${I.statusCode}`));
670
670
  });
671
671
  });
672
- b.on("error", r), b.write(f), b.end();
673
- }), ht = () => new Promise((a, r) => {
674
- const m = JSON.stringify({ componentId: M }), f = {
672
+ $.on("error", a), $.write(h), $.end();
673
+ }), vt = () => new Promise((c, a) => {
674
+ const f = JSON.stringify({ componentId: M }), h = {
675
675
  hostname: "localhost",
676
- port: c,
676
+ port: d,
677
677
  path: "/_unregister",
678
678
  method: "POST",
679
679
  headers: {
680
680
  "Content-Type": "application/json",
681
- "Content-Length": Buffer.byteLength(m)
681
+ "Content-Length": Buffer.byteLength(f)
682
682
  }
683
- }, w = n.default.request(f, (b) => {
684
- a();
683
+ }, w = n.default.request(h, ($) => {
684
+ c();
685
685
  });
686
- w.on("error", () => a()), w.write(m), w.end();
687
- }), yt = (a) => `
686
+ w.on("error", () => c()), w.write(f), w.end();
687
+ }), St = (c) => `
688
688
  <!-- MYOP HMR -->
689
689
  <script>
690
690
  (function() {
691
- const componentId = '${a}';
692
- const wsUrl = 'ws://localhost:${c}/_hmr/' + componentId;
691
+ const componentId = '${c}';
692
+ const wsUrl = 'ws://localhost:${d}/_hmr/' + componentId;
693
693
  let ws;
694
694
  let reconnectAttempts = 0;
695
695
  const maxReconnectAttempts = 10;
@@ -789,76 +789,76 @@ Sec-WebSocket-Accept: ${b}\r
789
789
  connect();
790
790
  })();
791
791
  <\/script>
792
- `, Oe = (a, r) => {
793
- if (!k) return a;
794
- const m = yt(r);
795
- return a.includes("</body>") ? a.replace("</body>", `${m}</body>`) : a.includes("</html>") ? a.replace("</html>", `${m}</html>`) : a + m;
796
- }, Qe = (a) => {
797
- const r = Buffer.from(a), m = r.length;
798
- let f;
799
- return m < 126 ? f = Buffer.concat([
800
- Buffer.from([129, m]),
792
+ `, ke = (c, a) => {
793
+ if (!k) return c;
794
+ const f = St(a);
795
+ return c.includes("</body>") ? c.replace("</body>", `${f}</body>`) : c.includes("</html>") ? c.replace("</html>", `${f}</html>`) : c + f;
796
+ }, qe = (c) => {
797
+ const a = Buffer.from(c), f = a.length;
798
+ let h;
799
+ return f < 126 ? h = Buffer.concat([
800
+ Buffer.from([129, f]),
801
801
  // FIN + text frame, length
802
- r
803
- ]) : m < 65536 ? f = Buffer.concat([
802
+ a
803
+ ]) : f < 65536 ? h = Buffer.concat([
804
804
  Buffer.from([129, 126]),
805
805
  // FIN + text frame, extended length
806
- Buffer.from([m >> 8, m & 255]),
806
+ Buffer.from([f >> 8, f & 255]),
807
807
  // 16-bit length
808
- r
809
- ]) : f = Buffer.concat([
808
+ a
809
+ ]) : h = Buffer.concat([
810
810
  Buffer.from([129, 127]),
811
811
  // FIN + text frame, extended length
812
- Buffer.from([0, 0, 0, 0, m >> 24, m >> 16 & 255, m >> 8 & 255, m & 255]),
812
+ Buffer.from([0, 0, 0, 0, f >> 24, f >> 16 & 255, f >> 8 & 255, f & 255]),
813
813
  // 64-bit length
814
- r
815
- ]), f;
816
- }, Ze = () => {
814
+ a
815
+ ]), h;
816
+ }, Xe = () => {
817
817
  if (!k) return;
818
- const a = u ? p : t.default.join(y, "index.html");
819
- let r;
818
+ const c = g ? u : t.default.join(y, "index.html");
819
+ let a;
820
820
  try {
821
- const m = o.default.readFileSync(a, "utf-8");
822
- r = Oe(m, M);
823
- } catch (m) {
824
- console.error("❌ Failed to read HTML for HMR:", m.message);
821
+ const f = o.default.readFileSync(c, "utf-8");
822
+ a = ke(f, M);
823
+ } catch (f) {
824
+ console.error("❌ Failed to read HTML for HMR:", f.message);
825
825
  return;
826
826
  }
827
- if (Re) {
828
- const m = q.get(M);
829
- if (!m || m.size === 0)
827
+ if (Ne) {
828
+ const f = X.get(M);
829
+ if (!f || f.size === 0)
830
830
  return;
831
- console.log(`πŸ”₯ Notifying ${m.size} HMR client(s)`);
832
- const f = JSON.stringify({
831
+ console.log(`πŸ”₯ Notifying ${f.size} HMR client(s)`);
832
+ const h = JSON.stringify({
833
833
  type: "update",
834
- html: r
835
- }), w = Qe(f);
836
- m.forEach((b) => {
834
+ html: a
835
+ }), w = qe(h);
836
+ f.forEach(($) => {
837
837
  try {
838
- b.write(w);
838
+ $.write(w);
839
839
  } catch {
840
- m.delete(b);
840
+ f.delete($);
841
841
  }
842
842
  });
843
843
  } else {
844
- const m = JSON.stringify({
844
+ const f = JSON.stringify({
845
845
  componentId: M,
846
- html: r
847
- }), f = {
846
+ html: a
847
+ }), h = {
848
848
  hostname: "localhost",
849
- port: c,
849
+ port: d,
850
850
  path: "/_hmr_notify",
851
851
  method: "POST",
852
852
  headers: {
853
853
  "Content-Type": "application/json",
854
- "Content-Length": Buffer.byteLength(m)
854
+ "Content-Length": Buffer.byteLength(f)
855
855
  },
856
856
  timeout: 5e3
857
- }, w = n.default.request(f, (b) => {
858
- let O = "";
859
- b.on("data", (F) => O += F), b.on("end", () => {
857
+ }, w = n.default.request(h, ($) => {
858
+ let I = "";
859
+ $.on("data", (F) => I += F), $.on("end", () => {
860
860
  try {
861
- const F = JSON.parse(O);
861
+ const F = JSON.parse(I);
862
862
  F.notified > 0 && console.log(`πŸ”₯ Notified ${F.notified} HMR client(s) via server`);
863
863
  } catch {
864
864
  }
@@ -867,173 +867,173 @@ Sec-WebSocket-Accept: ${b}\r
867
867
  w.on("error", () => {
868
868
  }), w.on("timeout", () => {
869
869
  w.destroy();
870
- }), w.write(m), w.end();
870
+ }), w.write(f), w.end();
871
871
  }
872
872
  };
873
- let Ie = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
- const fe = (a) => {
873
+ let Re = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
+ const he = (c) => {
875
875
  if (S) {
876
876
  x = !0;
877
877
  return;
878
878
  }
879
879
  S = !0, console.log(`
880
- πŸ”¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, m, f) => {
881
- if (S = !1, r) {
882
- const w = await ct(r, m, f, e, {
883
- ...Ie,
884
- onRetry: () => fe(a)
880
+ πŸ”¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (a, f, h) => {
881
+ if (S = !1, a) {
882
+ const w = await pt(a, f, h, e, {
883
+ ...Re,
884
+ onRetry: () => he(c)
885
885
  });
886
- Ie = { ...Ie, ...w }, w.handled || (console.error("❌ Build failed:", r.message), f && console.error(f));
886
+ Re = { ...Re, ...w }, w.handled || (console.error("❌ Build failed:", a.message), h && console.error(h));
887
887
  } else
888
- console.log("βœ… Build completed"), m && console.log(m), Ze(), a && a();
889
- x && (x = !1, fe());
888
+ console.log("βœ… Build completed"), f && console.log(f), Xe(), c && c();
889
+ x && (x = !1, he());
890
890
  });
891
- }, Xe = /* @__PURE__ */ new Set(), ke = (a) => {
892
- o.default.readdir(a, { withFileTypes: !0 }, (r, m) => {
893
- r || (m.forEach((f) => {
894
- const w = t.default.join(a, f.name);
895
- if (f.isDirectory())
896
- f.name !== "node_modules" && f.name !== "dist" && !f.name.startsWith(".") && ke(w);
897
- else if (f.isFile()) {
898
- const b = t.default.extname(f.name);
899
- if (b === ".js" || b === ".css" || b === ".html")
891
+ }, et = /* @__PURE__ */ new Set(), _e = (c) => {
892
+ o.default.readdir(c, { withFileTypes: !0 }, (a, f) => {
893
+ a || (f.forEach((h) => {
894
+ const w = t.default.join(c, h.name);
895
+ if (h.isDirectory())
896
+ h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(w);
897
+ else if (h.isFile()) {
898
+ const $ = t.default.extname(h.name);
899
+ if ($ === ".js" || $ === ".css" || $ === ".html")
900
900
  try {
901
- const O = o.default.readFileSync(w, "utf-8");
902
- C.set(w, O);
901
+ const I = o.default.readFileSync(w, "utf-8");
902
+ P.set(w, I);
903
903
  } catch {
904
904
  }
905
905
  }
906
- }), Xe.has(a) || (Xe.add(a), o.default.watch(a, (f, w) => {
906
+ }), et.has(c) || (et.add(c), o.default.watch(c, (h, w) => {
907
907
  if (!w) return;
908
- const b = t.default.extname(w);
909
- if (b !== ".js" && b !== ".css" && b !== ".html") return;
910
- const O = t.default.join(a, w);
908
+ const $ = t.default.extname(w);
909
+ if ($ !== ".js" && $ !== ".css" && $ !== ".html") return;
910
+ const I = t.default.join(c, w);
911
911
  setTimeout(() => {
912
912
  try {
913
- const F = o.default.readFileSync(O, "utf-8"), H = C.get(O);
914
- F !== H && (C.set(O, F), console.log(`πŸ“ File changed: ${O}`), u ? Ze() : fe());
913
+ const F = o.default.readFileSync(I, "utf-8"), H = P.get(I);
914
+ F !== H && (P.set(I, F), console.log(`πŸ“ File changed: ${I}`), g ? Xe() : he());
915
915
  } catch {
916
916
  }
917
917
  }, 50);
918
918
  })));
919
919
  });
920
- }, qe = (a) => {
920
+ }, tt = (c) => {
921
921
  console.log(`
922
- πŸ”¨ Component: ${M}`), u ? (console.log("πŸ“„ No build needed (single HTML file mode)"), ke(_), console.log(`πŸ‘€ Watching ${p} for changes...`), console.log(`Press Ctrl+C to stop
923
- `), a && a()) : (fe(a), ke(_), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
922
+ πŸ”¨ Component: ${M}`), g ? (console.log("πŸ“„ No build needed (single HTML file mode)"), _e(T), console.log(`πŸ‘€ Watching ${u} for changes...`), console.log(`Press Ctrl+C to stop
923
+ `), c && c()) : (he(c), _e(T), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
924
924
  `));
925
- }, wt = () => new Promise((a) => {
926
- const r = {
925
+ }, xt = () => new Promise((c) => {
926
+ const a = {
927
927
  hostname: "localhost",
928
- port: c,
928
+ port: d,
929
929
  path: "/_list",
930
930
  method: "GET",
931
931
  timeout: 1e3
932
- }, m = n.default.request(r, (f) => {
933
- a(!0);
932
+ }, f = n.default.request(a, (h) => {
933
+ c(!0);
934
934
  });
935
- m.on("error", () => a(!1)), m.on("timeout", () => {
936
- m.destroy(), a(!1);
937
- }), m.end();
938
- }), vt = () => new Promise((a) => {
939
- const r = n.default.createServer((m, f) => {
940
- if (f.setHeader("Content-Type", "application/json"), m.method === "POST" && m.url === "/_register") {
935
+ f.on("error", () => c(!1)), f.on("timeout", () => {
936
+ f.destroy(), c(!1);
937
+ }), f.end();
938
+ }), $t = () => new Promise((c) => {
939
+ const a = n.default.createServer((f, h) => {
940
+ if (h.setHeader("Content-Type", "application/json"), f.method === "POST" && f.url === "/_register") {
941
941
  let w = "";
942
- m.on("data", (b) => w += b), m.on("end", () => {
942
+ f.on("data", ($) => w += $), f.on("end", () => {
943
943
  try {
944
- const { componentId: b, distPath: O, componentName: F, htmlFile: H } = JSON.parse(w);
945
- T.set(b, { path: O, name: F || null, htmlFile: H || null });
946
- const G = F ? ` (${F})` : "";
947
- console.log(`βœ… Registered: ${b}${G} -> ${O}${H ? "/" + H : ""}`), f.writeHead(200), f.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
948
- } catch (b) {
949
- f.writeHead(400), f.end(JSON.stringify({ error: b.message }));
944
+ const { componentId: $, distPath: I, componentName: F, htmlFile: H } = JSON.parse(w);
945
+ N.set($, { path: I, name: F || null, htmlFile: H || null });
946
+ const Y = F ? ` (${F})` : "";
947
+ console.log(`βœ… Registered: ${$}${Y} -> ${I}${H ? "/" + H : ""}`), h.writeHead(200), h.end(JSON.stringify({ success: !0, registered: Array.from(N.keys()) }));
948
+ } catch ($) {
949
+ h.writeHead(400), h.end(JSON.stringify({ error: $.message }));
950
950
  }
951
951
  });
952
- } else if (m.method === "POST" && m.url === "/_unregister") {
952
+ } else if (f.method === "POST" && f.url === "/_unregister") {
953
953
  let w = "";
954
- m.on("data", (b) => w += b), m.on("end", () => {
954
+ f.on("data", ($) => w += $), f.on("end", () => {
955
955
  try {
956
- const { componentId: b } = JSON.parse(w);
957
- T.delete(b), console.log(`❌ Unregistered: ${b}`), f.writeHead(200), f.end(JSON.stringify({ success: !0 }));
958
- } catch (b) {
959
- f.writeHead(400), f.end(JSON.stringify({ error: b.message }));
956
+ const { componentId: $ } = JSON.parse(w);
957
+ N.delete($), console.log(`❌ Unregistered: ${$}`), h.writeHead(200), h.end(JSON.stringify({ success: !0 }));
958
+ } catch ($) {
959
+ h.writeHead(400), h.end(JSON.stringify({ error: $.message }));
960
960
  }
961
961
  });
962
- } else m.method === "GET" && m.url === "/_list" ? (f.writeHead(200), f.end(JSON.stringify({ components: Array.from(T.entries()) }))) : (f.writeHead(404), f.end(JSON.stringify({ error: "Not found" })));
962
+ } else f.method === "GET" && f.url === "/_list" ? (h.writeHead(200), h.end(JSON.stringify({ components: Array.from(N.entries()) }))) : (h.writeHead(404), h.end(JSON.stringify({ error: "Not found" })));
963
963
  });
964
- r.on("error", () => {
965
- a(!1);
966
- }), r.listen(c, () => {
964
+ a.on("error", () => {
965
+ c(!1);
966
+ }), a.listen(d, () => {
967
967
  console.log(`
968
- πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${c}`), ge.on("error", () => {
969
- r.close(), a(!1);
968
+ πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${d}`), ge.on("error", () => {
969
+ a.close(), c(!1);
970
970
  }), ge.listen(l, () => {
971
971
  console.log(`πŸ“‘ Main server running at http://localhost:${l}`);
972
- const m = u ? t.default.resolve(_) : t.default.resolve(_, y);
973
- T.set(M, {
974
- path: m,
975
- name: R,
976
- htmlFile: u ? p : null
972
+ const f = g ? t.default.resolve(T) : t.default.resolve(T, y);
973
+ N.set(M, {
974
+ path: f,
975
+ name: _,
976
+ htmlFile: g ? u : null
977
977
  });
978
- const f = R ? ` (${R})` : "";
979
- console.log(`βœ… Registered component: ${M}${f}`), console.log(`πŸ“‘ Access at: http://localhost:${l}/view/${M}/`), a(!0);
978
+ const h = _ ? ` (${_})` : "";
979
+ console.log(`βœ… Registered component: ${M}${h}`), console.log(`πŸ“‘ Access at: http://localhost:${l}/view/${M}/`), c(!0);
980
980
  });
981
981
  });
982
982
  });
983
- let he;
984
- const et = () => {
985
- he = setInterval(async () => {
986
- await wt() || (clearInterval(he), console.log(`
987
- ⚠️ Server appears to be down, attempting to take over...`), await vt() ? (console.log("βœ… Successfully took over as server"), Re = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
983
+ let ye;
984
+ const ot = () => {
985
+ ye = setInterval(async () => {
986
+ await xt() || (clearInterval(ye), console.log(`
987
+ ⚠️ Server appears to be down, attempting to take over...`), await $t() ? (console.log("βœ… Successfully took over as server"), Ne = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
988
988
  try {
989
- await Ke(), console.log(`βœ… Re-registered component: ${M}`), et();
990
- } catch (m) {
991
- console.error("❌ Failed to re-register:", m.message);
989
+ await Ze(), console.log(`βœ… Re-registered component: ${M}`), ot();
990
+ } catch (f) {
991
+ console.error("❌ Failed to re-register:", f.message);
992
992
  }
993
993
  }, 2e3)));
994
994
  }, 3e3);
995
- }, tt = async () => {
995
+ }, nt = async () => {
996
996
  console.log(`
997
997
 
998
- πŸ›‘ Shutting down...`), he && clearInterval(he), await ht(), process.exit(0);
998
+ πŸ›‘ Shutting down...`), ye && clearInterval(ye), await vt(), process.exit(0);
999
999
  };
1000
- process.on("SIGINT", tt), process.on("SIGTERM", tt);
1001
- let Re = !1;
1002
- Ee.on("error", async (a) => {
1003
- if (a.code === "EADDRINUSE") {
1000
+ process.on("SIGINT", nt), process.on("SIGTERM", nt);
1001
+ let Ne = !1;
1002
+ Oe.on("error", async (c) => {
1003
+ if (c.code === "EADDRINUSE") {
1004
1004
  console.log(`
1005
1005
  πŸ”— Connecting to existing dev server...`);
1006
1006
  try {
1007
- M = await A();
1008
- const r = await Ke();
1009
- console.log(`βœ… Registered component: ${M}`), console.log(`πŸ“‘ Access at: http://localhost:${l}/view/${M}/`), console.log(`πŸ“‹ All registered components: ${r.registered.join(", ")}`), qe(() => {
1010
- process.env.MYOP_NO_BROWSER || $(`http://localhost:${l}/view/${M}/`);
1011
- }), et();
1012
- } catch (r) {
1013
- console.error("❌ Failed to register component:", r.message), process.exit(1);
1007
+ M = await D();
1008
+ const a = await Ze();
1009
+ console.log(`βœ… Registered component: ${M}`), console.log(`πŸ“‘ Access at: http://localhost:${l}/view/${M}/`), console.log(`πŸ“‹ All registered components: ${a.registered.join(", ")}`), tt(() => {
1010
+ process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${M}/`);
1011
+ }), ot();
1012
+ } catch (a) {
1013
+ console.error("❌ Failed to register component:", a.message), process.exit(1);
1014
1014
  }
1015
1015
  } else
1016
- console.error("❌ Management server error:", a.message), process.exit(1);
1017
- }), Ee.on("upgrade", ft), Ee.listen(c, async () => {
1018
- Re = !0, console.log(`
1019
- πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${c}`), ge.on("error", (a) => {
1020
- console.error("❌ Main server error:", a.message), process.exit(1);
1016
+ console.error("❌ Management server error:", c.message), process.exit(1);
1017
+ }), Oe.on("upgrade", wt), Oe.listen(d, async () => {
1018
+ Ne = !0, console.log(`
1019
+ πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${d}`), ge.on("error", (c) => {
1020
+ console.error("❌ Main server error:", c.message), process.exit(1);
1021
1021
  }), ge.listen(l, async () => {
1022
1022
  console.log(`πŸ“‘ Main server running at http://localhost:${l}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
1023
- const a = u ? t.default.resolve(_) : t.default.resolve(_, y);
1024
- T.set(M, {
1025
- path: a,
1026
- name: R,
1027
- htmlFile: u ? p : null
1023
+ const c = g ? t.default.resolve(T) : t.default.resolve(T, y);
1024
+ N.set(M, {
1025
+ path: c,
1026
+ name: _,
1027
+ htmlFile: g ? u : null
1028
1028
  });
1029
- const r = R ? ` (${R})` : "";
1030
- console.log(`βœ… Registered component: ${M}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${l}/view/${M}/`), qe(() => {
1031
- process.env.MYOP_NO_BROWSER || $(`http://localhost:${l}/view/${M}/`);
1029
+ const a = _ ? ` (${_})` : "";
1030
+ console.log(`βœ… Registered component: ${M}${a}`), console.log(`πŸ“‘ Access at: http://localhost:${l}/view/${M}/`), tt(() => {
1031
+ process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${M}/`);
1032
1032
  });
1033
1033
  });
1034
1034
  });
1035
1035
  }
1036
- const D = class D {
1036
+ const A = class A {
1037
1037
  constructor(t) {
1038
1038
  this.components = t.map(
1039
1039
  (e) => typeof e == "string" ? { name: e, path: "", id: "" } : e
@@ -1042,7 +1042,7 @@ const D = class D {
1042
1042
  this.logs.set(e.name, []), this.scrollPos.set(e.name, 0), this.statuses.set(e.name, "Initializing..."), this.statusKeys.set(e.name, "initializing");
1043
1043
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
1044
1044
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, this.needsFullRedraw = !0, this.calculateLayout(), this.render();
1045
- }), this.setupKeyboardInput(), process.stdout.write(D.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1045
+ }), this.setupKeyboardInput(), process.stdout.write(A.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1046
1046
  }
1047
1047
  setupKeyboardInput() {
1048
1048
  process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (t) => {
@@ -1083,12 +1083,12 @@ const D = class D {
1083
1083
  const t = this.components.length, e = 38;
1084
1084
  let n;
1085
1085
  this.cols >= e * 3 + 4 ? n = Math.min(t, 3) : this.cols >= e * 2 + 2 ? n = Math.min(t, 2) : n = 1;
1086
- const s = Math.ceil(t / n), i = Math.floor(this.cols / n), d = 2, h = this.rows - d - 2, l = Math.floor(h / s);
1086
+ const s = Math.ceil(t / n), i = Math.floor(this.cols / n), r = 2, m = this.rows - r - 2, l = Math.floor(m / s);
1087
1087
  this.visibleLogLines = Math.max(2, l - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: l }, this.panelPositions.clear();
1088
- for (let c = 0; c < t; c++) {
1089
- const y = this.components[c], S = Math.floor(c / n), x = c % n;
1088
+ for (let d = 0; d < t; d++) {
1089
+ const y = this.components[d], S = Math.floor(d / n), x = d % n;
1090
1090
  this.panelPositions.set(y.name, {
1091
- row: d + 1 + S * l,
1091
+ row: r + 1 + S * l,
1092
1092
  col: x * i + 1,
1093
1093
  width: i,
1094
1094
  height: l
@@ -1110,8 +1110,8 @@ const D = class D {
1110
1110
  s.includes("initializing") || s.includes("⏳") ? n = "initializing" : s.includes("starting") ? n = "starting" : s.includes("building") || s.includes("πŸ”¨") ? n = "building" : s.includes("ready") || s.includes("βœ…") ? n = "ready" : s.includes("changed") || s.includes("πŸ“") ? n = "changed" : s.includes("hmr") ? n = "hmr_update" : s.includes("πŸ”₯") ? n = "hmr" : s.includes("error") || s.includes("❌") ? n = "error" : s.includes("warning") || s.includes("⚠") ? n = "warning" : (s.includes("stopped") || s.includes("exited")) && (n = "stopped"), this.statuses.set(t, e), this.statusKeys.set(t, n), this.queueUpdate(t);
1111
1111
  }
1112
1112
  scroll(t, e) {
1113
- const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines), d = Math.max(0, Math.min(i, s + e));
1114
- d !== s && (this.scrollPos.set(t, d), this.queueUpdate(t));
1113
+ const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines), r = Math.max(0, Math.min(i, s + e));
1114
+ r !== s && (this.scrollPos.set(t, r), this.queueUpdate(t));
1115
1115
  }
1116
1116
  queueUpdate(t) {
1117
1117
  this.pendingUpdates.add(t), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
@@ -1132,44 +1132,44 @@ const D = class D {
1132
1132
  return `${e}:${n.toString().padStart(2, "0")}`;
1133
1133
  }
1134
1134
  updateHeader() {
1135
- const t = D.C, e = Array.from(this.statusKeys.values()).filter((i) => i === "ready").length, n = this.components.length;
1135
+ const t = A.C, e = Array.from(this.statusKeys.values()).filter((i) => i === "ready").length, n = this.components.length;
1136
1136
  let s = `${t.dim}πŸ“‘${t.reset} http://localhost:9292 ${t.gray}|${t.reset} `;
1137
- s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `⏱ ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s += D.ESC.clearLine.slice(0, -1), process.stdout.write(D.ESC.moveTo(2, 1) + s);
1137
+ s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `⏱ ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s += A.ESC.clearLine.slice(0, -1), process.stdout.write(A.ESC.moveTo(2, 1) + s);
1138
1138
  }
1139
1139
  renderPanel(t) {
1140
- const e = D.C, n = D.STATUS, s = this.panelPositions.get(t);
1140
+ const e = A.C, n = A.STATUS, s = this.panelPositions.get(t);
1141
1141
  if (!s) return;
1142
- const i = this.components.findIndex((A) => A.name === t), d = this.components[i], g = i === this.selectedPanel, h = this.statusKeys.get(t) || "initializing", l = n[h], c = e[l.color], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, x = s.width - 1, u = g ? e.cyan : e.gray, p = [], E = d.name.substring(0, x - 20);
1143
- let I = `${u}β”Œβ”€${e.reset} ${c}${l.icon}${e.reset} `;
1144
- I += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${c}${l.label}${e.reset} `;
1145
- const $ = 5 + E.length + l.label.length + 3;
1146
- I += `${u}${"─".repeat(Math.max(0, x - $))}┐${e.reset}`, p.push(D.ESC.moveTo(s.row, s.col) + I);
1147
- const C = (d.path || "").substring(0, x - 6);
1148
- let j = `${u}β”‚${e.reset} ${e.dim}${C}${e.reset}`;
1149
- j += " ".repeat(Math.max(0, x - C.length - 3)), j += `${u}β”‚${e.reset}`, p.push(D.ESC.moveTo(s.row + 1, s.col) + j);
1150
- const M = y.length, R = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
1151
- let k = `${u}β”œ${"─".repeat(x - R.length - 4)}${e.reset}`;
1152
- R && (k += `${e.dim}${R}${e.reset}`), k += `${u}${"─".repeat(2)}─${e.reset}`, p.push(D.ESC.moveTo(s.row + 2, s.col) + k);
1142
+ const i = this.components.findIndex((D) => D.name === t), r = this.components[i], p = i === this.selectedPanel, m = this.statusKeys.get(t) || "initializing", l = n[m], d = e[l.color], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, x = s.width - 1, g = p ? e.cyan : e.gray, u = [], E = r.name.substring(0, x - 20);
1143
+ let O = `${g}β”Œβ”€${e.reset} ${d}${l.icon}${e.reset} `;
1144
+ O += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${d}${l.label}${e.reset} `;
1145
+ const b = 5 + E.length + l.label.length + 3;
1146
+ O += `${g}${"─".repeat(Math.max(0, x - b))}┐${e.reset}`, u.push(A.ESC.moveTo(s.row, s.col) + O);
1147
+ const P = (r.path || "").substring(0, x - 6);
1148
+ let j = `${g}β”‚${e.reset} ${e.dim}${P}${e.reset}`;
1149
+ j += " ".repeat(Math.max(0, x - P.length - 3)), j += `${g}β”‚${e.reset}`, u.push(A.ESC.moveTo(s.row + 1, s.col) + j);
1150
+ const M = y.length, _ = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
1151
+ let k = `${g}β”œ${"─".repeat(x - _.length - 4)}${e.reset}`;
1152
+ _ && (k += `${e.dim}${_}${e.reset}`), k += `${g}${"─".repeat(2)}─${e.reset}`, u.push(A.ESC.moveTo(s.row + 2, s.col) + k);
1153
1153
  const L = y.slice(S, S + this.visibleLogLines);
1154
- for (let A = 0; A < this.visibleLogLines; A++) {
1155
- const _ = L[A];
1156
- let z = `${u}β”‚${e.reset}`;
1157
- if (_) {
1158
- let T = e.white;
1159
- _.type === "success" ? T = e.green : _.type === "error" ? T = e.red : _.type === "warning" ? T = e.yellow : _.type === "hmr" ? T = e.magenta : _.type === "change" && (T = e.blue);
1160
- const oe = _.message.substring(0, x - 12);
1161
- z += `${e.dim}${_.timestamp}${e.reset} ${T}${oe}${e.reset}`;
1162
- const Pe = x - _.timestamp.length - oe.length - 2;
1163
- z += " ".repeat(Math.max(0, Pe));
1154
+ for (let D = 0; D < this.visibleLogLines; D++) {
1155
+ const T = L[D];
1156
+ let W = `${g}β”‚${e.reset}`;
1157
+ if (T) {
1158
+ let N = e.white;
1159
+ T.type === "success" ? N = e.green : T.type === "error" ? N = e.red : T.type === "warning" ? N = e.yellow : T.type === "hmr" ? N = e.magenta : T.type === "change" && (N = e.blue);
1160
+ const oe = T.message.substring(0, x - 12);
1161
+ W += `${e.dim}${T.timestamp}${e.reset} ${N}${oe}${e.reset}`;
1162
+ const Ie = x - T.timestamp.length - oe.length - 2;
1163
+ W += " ".repeat(Math.max(0, Ie));
1164
1164
  } else
1165
- z += " ".repeat(x - 2);
1166
- z += `${u}β”‚${e.reset}`, p.push(D.ESC.moveTo(s.row + 3 + A, s.col) + z);
1165
+ W += " ".repeat(x - 2);
1166
+ W += `${g}β”‚${e.reset}`, u.push(A.ESC.moveTo(s.row + 3 + D, s.col) + W);
1167
1167
  }
1168
- p.push(D.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${u}β””${"─".repeat(x - 2)}β”˜${e.reset}`), process.stdout.write(p.join(""));
1168
+ u.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}β””${"─".repeat(x - 2)}β”˜${e.reset}`), process.stdout.write(u.join(""));
1169
1169
  }
1170
1170
  fullRender() {
1171
- const t = D.C;
1172
- process.stdout.write(D.ESC.clearScreen + D.ESC.moveTo(1, 1));
1171
+ const t = A.C;
1172
+ process.stdout.write(A.ESC.clearScreen + A.ESC.moveTo(1, 1));
1173
1173
  const e = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - e.length) / 2);
1174
1174
  process.stdout.write(`${t.cyan}${"━".repeat(n)}${t.bold}${t.bgCyan}${t.black}${e}${t.reset}${t.cyan}${"━".repeat(this.cols - n - e.length)}${t.reset}`), this.updateHeader();
1175
1175
  for (const s of this.components)
@@ -1177,26 +1177,26 @@ const D = class D {
1177
1177
  this.renderFooter();
1178
1178
  }
1179
1179
  renderFooter() {
1180
- const t = D.C, e = this.rows - 1;
1180
+ const t = A.C, e = this.rows - 1;
1181
1181
  let n = `${t.gray}`;
1182
- n += `${t.green}●${t.gray} Ready `, n += `${t.yellow}⟳${t.gray} Building `, n += `${t.magenta}⚑${t.gray} HMR `, n += `${t.red}βœ–${t.gray} Error `, n += `${t.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(D.ESC.moveTo(e, 1) + n);
1182
+ n += `${t.green}●${t.gray} Ready `, n += `${t.yellow}⟳${t.gray} Building `, n += `${t.magenta}⚑${t.gray} HMR `, n += `${t.red}βœ–${t.gray} Error `, n += `${t.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(A.ESC.moveTo(e, 1) + n);
1183
1183
  }
1184
1184
  render() {
1185
1185
  this.needsFullRedraw = !0, this.queueUpdate("__full__");
1186
1186
  }
1187
1187
  clear() {
1188
- this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(D.ESC.clearScreen + D.ESC.moveTo(1, 1) + D.ESC.showCursor);
1188
+ this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(A.ESC.clearScreen + A.ESC.moveTo(1, 1) + A.ESC.showCursor);
1189
1189
  }
1190
1190
  };
1191
1191
  // ANSI escape codes
1192
- we(D, "ESC", {
1192
+ ve(A, "ESC", {
1193
1193
  moveTo: (t, e) => `\x1B[${t};${e}H`,
1194
1194
  hideCursor: "\x1B[?25l",
1195
1195
  showCursor: "\x1B[?25h",
1196
1196
  clearScreen: "\x1B[2J",
1197
1197
  clearLine: "\x1B[2K"
1198
1198
  }), // Colors
1199
- we(D, "C", {
1199
+ ve(A, "C", {
1200
1200
  reset: "\x1B[0m",
1201
1201
  bold: "\x1B[1m",
1202
1202
  dim: "\x1B[2m",
@@ -1211,7 +1211,7 @@ we(D, "C", {
1211
1211
  bgCyan: "\x1B[46m",
1212
1212
  black: "\x1B[30m"
1213
1213
  }), // Status configs
1214
- we(D, "STATUS", {
1214
+ ve(A, "STATUS", {
1215
1215
  initializing: { icon: "β—”", color: "yellow", label: "Initializing" },
1216
1216
  starting: { icon: "β—‘", color: "yellow", label: "Starting" },
1217
1217
  building: { icon: "⟳", color: "yellow", label: "Building" },
@@ -1224,125 +1224,227 @@ we(D, "STATUS", {
1224
1224
  warning: { icon: "⚠", color: "yellow", label: "Warning" },
1225
1225
  stopped: { icon: "β– ", color: "gray", label: "Stopped" }
1226
1226
  });
1227
- let Ae = D;
1228
- async function Ht(o) {
1229
- const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((c) => ({
1230
- name: c.name,
1231
- path: c.path,
1232
- id: c.componentId || ""
1233
- })), i = new Ae(s), d = [], g = (c) => {
1227
+ let Ue = A;
1228
+ async function zt(o) {
1229
+ const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((d) => ({
1230
+ name: d.name,
1231
+ path: d.path,
1232
+ id: d.componentId || ""
1233
+ })), i = new Ue(s), r = [], p = (d) => {
1234
1234
  const y = process.platform;
1235
1235
  let S;
1236
- y === "darwin" ? S = `open "${c}"` : y === "win32" ? S = `start "" "${c}"` : S = `xdg-open "${c}"`, e(S, () => {
1236
+ y === "darwin" ? S = `open "${d}"` : y === "win32" ? S = `start "" "${d}"` : S = `xdg-open "${d}"`, e(S, () => {
1237
1237
  });
1238
- }, h = () => {
1238
+ }, m = () => {
1239
1239
  i.clear(), console.log(`
1240
- πŸ›‘ Shutting down all components...`), d.forEach((c) => {
1240
+ πŸ›‘ Shutting down all components...`), r.forEach((d) => {
1241
1241
  try {
1242
- c.kill("SIGTERM");
1242
+ d.kill("SIGTERM");
1243
1243
  } catch {
1244
1244
  }
1245
1245
  }), setTimeout(() => process.exit(0), 500);
1246
1246
  };
1247
- process.on("SIGINT", h), process.on("SIGTERM", h);
1247
+ process.on("SIGINT", m), process.on("SIGTERM", m);
1248
1248
  const l = process.argv[1];
1249
- for (let c = 0; c < o.length; c++) {
1250
- const y = o[c], S = y.name;
1249
+ for (let d = 0; d < o.length; d++) {
1250
+ const y = o[d], S = y.name;
1251
1251
  i.setStatus(S, "⏳ Starting..."), i.log(S, `Starting in ${y.path}`);
1252
1252
  const x = t("node", [l, "dev"], {
1253
1253
  cwd: n.default.resolve(y.path),
1254
1254
  env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1255
1255
  stdio: ["ignore", "pipe", "pipe"]
1256
1256
  });
1257
- d.push(x);
1258
- let u = "";
1259
- x.stdout.on("data", (p) => {
1260
- u += p.toString();
1261
- const E = u.split(`
1257
+ r.push(x);
1258
+ let g = "";
1259
+ x.stdout.on("data", (u) => {
1260
+ g += u.toString();
1261
+ const E = g.split(`
1262
1262
  `);
1263
- u = E.pop() || "";
1264
- for (const I of E) {
1265
- const $ = I.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
- $ && ($.includes("Registered component") || $.includes("Registered:") ? i.setStatus(S, "βœ… Ready") : $.includes("Building...") || $.includes("Running initial build") ? i.setStatus(S, "πŸ”¨ Building...") : $.includes("Build completed") || $.includes("Build succeeded") ? i.setStatus(S, "βœ… Ready") : $.includes("Build failed") ? i.setStatus(S, "❌ Build Error") : $.includes("File changed") ? (i.setStatus(S, "πŸ“ Changed"), setTimeout(() => i.setStatus(S, "βœ… Ready"), 1500)) : $.includes("Notifying") && $.includes("HMR") ? (i.setStatus(S, "πŸ”₯ HMR Update"), setTimeout(() => i.setStatus(S, "βœ… Ready"), 1e3)) : $.includes("HMR client connected") && (i.setStatus(S, "πŸ”₯ HMR Connected"), setTimeout(() => i.setStatus(S, "βœ… Ready"), 1e3)), !$.includes("Watching") && !$.includes("Press Ctrl+C") && !$.includes("Starting shared") && !$.includes("Management server") && !$.includes("Main server") && !$.includes("Access at:") && !$.includes("No build needed") && i.log(S, $));
1263
+ g = E.pop() || "";
1264
+ for (const O of E) {
1265
+ const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
+ b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(S, "βœ… Ready") : b.includes("Building...") || b.includes("Running initial build") ? i.setStatus(S, "πŸ”¨ Building...") : b.includes("Build completed") || b.includes("Build succeeded") ? i.setStatus(S, "βœ… Ready") : b.includes("Build failed") ? i.setStatus(S, "❌ Build Error") : b.includes("File changed") ? (i.setStatus(S, "πŸ“ Changed"), setTimeout(() => i.setStatus(S, "βœ… Ready"), 1500)) : b.includes("Notifying") && b.includes("HMR") ? (i.setStatus(S, "πŸ”₯ HMR Update"), setTimeout(() => i.setStatus(S, "βœ… Ready"), 1e3)) : b.includes("HMR client connected") && (i.setStatus(S, "πŸ”₯ HMR Connected"), setTimeout(() => i.setStatus(S, "βœ… Ready"), 1e3)), !b.includes("Watching") && !b.includes("Press Ctrl+C") && !b.includes("Starting shared") && !b.includes("Management server") && !b.includes("Main server") && !b.includes("Access at:") && !b.includes("No build needed") && i.log(S, b));
1267
1267
  }
1268
- }), x.stderr.on("data", (p) => {
1269
- const E = p.toString().split(`
1268
+ }), x.stderr.on("data", (u) => {
1269
+ const E = u.toString().split(`
1270
1270
  `);
1271
- for (const I of E) {
1272
- const $ = I.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
- $ && (i.log(S, `⚠️ ${$}`), i.setStatus(S, "⚠️ Warning"));
1271
+ for (const O of E) {
1272
+ const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
+ b && (i.log(S, `⚠️ ${b}`), i.setStatus(S, "⚠️ Warning"));
1274
1274
  }
1275
- }), x.on("exit", (p) => {
1276
- p !== 0 && p !== null && (i.setStatus(S, `❌ Exited (${p})`), i.log(S, `Process exited with code ${p}`));
1277
- }), c < o.length - 1 && await new Promise((p) => setTimeout(p, 500));
1275
+ }), x.on("exit", (u) => {
1276
+ u !== 0 && u !== null && (i.setStatus(S, `❌ Exited (${u})`), i.log(S, `Process exited with code ${u}`));
1277
+ }), d < o.length - 1 && await new Promise((u) => setTimeout(u, 500));
1278
1278
  }
1279
1279
  i.render(), setTimeout(() => {
1280
- g("http://localhost:9292");
1280
+ p("http://localhost:9292");
1281
1281
  }, 2e3);
1282
1282
  }
1283
- const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1283
+ const Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1284
1284
  __proto__: null,
1285
- devCommand: be,
1286
- monorepoDevCommand: Ht
1287
- }, Symbol.toStringTag, { value: "Module" })), Le = N.join(it.homedir(), ".myop"), me = N.join(Le, "credentials.json");
1288
- function Jt() {
1289
- P.existsSync(Le) || P.mkdirSync(Le, { recursive: !0, mode: 448 });
1285
+ devCommand: Ce,
1286
+ monorepoDevCommand: zt
1287
+ }, Symbol.toStringTag, { value: "Module" })), Vt = "https://cloud.myop.dev";
1288
+ async function mt(o, t) {
1289
+ const e = await fetch(o, {
1290
+ headers: { Authorization: `Bearer ${t}` }
1291
+ });
1292
+ if (!e.ok) {
1293
+ const n = await e.text();
1294
+ throw new Error(`${e.status}: ${n}`);
1295
+ }
1296
+ return e.json();
1297
+ }
1298
+ function pe(o, t, e) {
1299
+ const n = R.resolve(R.join(o, t)), s = R.resolve(o);
1300
+ if (!n.startsWith(s + R.sep))
1301
+ throw new Error(`Invalid path: "${t}" escapes output directory`);
1302
+ C.mkdirSync(R.dirname(n), { recursive: !0 }), C.writeFileSync(n, JSON.stringify(e, null, 2));
1303
+ }
1304
+ async function $e(o, t, e, n) {
1305
+ return mt(
1306
+ `${o}/export?componentId=${encodeURIComponent(e)}&env=${encodeURIComponent(n)}`,
1307
+ t
1308
+ );
1309
+ }
1310
+ async function Yt(o, t, e, n) {
1311
+ let s = 0;
1312
+ const i = /* @__PURE__ */ new Set();
1313
+ for (const r of n) {
1314
+ const { componentId: p, environment: m } = r;
1315
+ if (!(!p || !m)) {
1316
+ try {
1317
+ const l = await $e(o, t, p, m);
1318
+ pe(e, `components/${p}/${m}.json`, l), s++;
1319
+ } catch (l) {
1320
+ console.warn(` Warning: ${p}/${m}: ${l.message}`);
1321
+ }
1322
+ if (!i.has(p)) {
1323
+ i.add(p);
1324
+ try {
1325
+ const l = await $e(o, t, p, "preview");
1326
+ pe(e, `components/${p}/preview.json`, l), s++;
1327
+ } catch {
1328
+ }
1329
+ }
1330
+ }
1331
+ }
1332
+ return s;
1333
+ }
1334
+ async function Gt(o, t, e) {
1335
+ const n = await mt(`${o}/export`, t);
1336
+ pe(e, "manifest.json", n);
1337
+ let s = 0, i = 0;
1338
+ for (const r of n.components || []) {
1339
+ for (const p of r.environments || [])
1340
+ try {
1341
+ const m = await $e(o, t, r.id, p);
1342
+ pe(e, `components/${r.id}/${p}.json`, m), s++;
1343
+ } catch (m) {
1344
+ console.warn(` Warning: ${r.id}/${p}: ${m.message}`), i++;
1345
+ }
1346
+ try {
1347
+ const p = await $e(o, t, r.id, "preview");
1348
+ pe(e, `components/${r.id}/preview.json`, p), s++;
1349
+ } catch {
1350
+ }
1351
+ }
1352
+ return { manifest: n, fileCount: s, errorCount: i };
1353
+ }
1354
+ function Kt() {
1355
+ v.program.command("export").description("Export components as static JSON for self-hosting").option("-k, --api-key <key>", "Myop API key (or set MYOP_API_KEY env var)").option("-o, --output <dir>", "Output directory", "./myop-static").option("-u, --url <url>", "Myop API URL (or set MYOP_API_URL env var)").option("--releases <json>", "JSON array of releases for incremental sync (from webhook payload)").option("--component <id>", "Single component ID for incremental sync").option("--env <env>", "Environment for single component sync (used with --component)").action(async (o) => {
1356
+ var i;
1357
+ const t = o.apiKey || process.env.MYOP_API_KEY, e = o.url || process.env.MYOP_API_URL || Vt, n = o.output || process.env.OUTPUT_DIR || "./myop-static";
1358
+ t || (console.error("Error: API key required. Use --api-key or set MYOP_API_KEY env var."), console.error("Create one at: Dashboard > Rollout Settings > Self-Hosting > API Keys"), process.exit(1));
1359
+ let s = null;
1360
+ if (o.releases)
1361
+ try {
1362
+ s = JSON.parse(o.releases), Array.isArray(s) || (s = s.releases || [s]);
1363
+ } catch {
1364
+ console.error("Error: --releases must be valid JSON"), process.exit(1);
1365
+ }
1366
+ else o.component && o.env && (s = [{ componentId: o.component, environment: o.env }]);
1367
+ if (s) {
1368
+ const r = z(`Incremental export: ${s.length} component(s)...`).start();
1369
+ try {
1370
+ const p = await Yt(e, t, n, s);
1371
+ r.succeed(`Incremental export done. ${p} file(s) written to ${n}/`);
1372
+ } catch (p) {
1373
+ r.fail(`Export failed: ${p.message}`), process.exit(1);
1374
+ }
1375
+ } else {
1376
+ const r = z(`Full export from ${e}...`).start();
1377
+ try {
1378
+ const { manifest: p, fileCount: m, errorCount: l } = await Gt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
1379
+ r.succeed(
1380
+ `Full export done. ${m} file(s) from ${d} component(s) written to ${n}/`
1381
+ ), l > 0 && console.warn(` ${l} file(s) failed.`);
1382
+ } catch (p) {
1383
+ r.fail(`Export failed: ${p.message}`), process.exit(1);
1384
+ }
1385
+ }
1386
+ process.exit(0);
1387
+ });
1290
1388
  }
1291
- function ze() {
1389
+ const He = R.join(at.homedir(), ".myop"), ue = R.join(He, "credentials.json");
1390
+ function Qt() {
1391
+ C.existsSync(He) || C.mkdirSync(He, { recursive: !0, mode: 448 });
1392
+ }
1393
+ function Ve() {
1292
1394
  try {
1293
- if (!P.existsSync(me))
1395
+ if (!C.existsSync(ue))
1294
1396
  return null;
1295
- const o = P.readFileSync(me, "utf8");
1397
+ const o = C.readFileSync(ue, "utf8");
1296
1398
  return JSON.parse(o);
1297
1399
  } catch (o) {
1298
1400
  return console.info("Failed to read credentials:", o.message), null;
1299
1401
  }
1300
1402
  }
1301
- function dt(o) {
1302
- Jt();
1403
+ function ut(o) {
1404
+ Qt();
1303
1405
  const t = {
1304
1406
  ...o,
1305
1407
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
1306
1408
  };
1307
- P.writeFileSync(me, JSON.stringify(t, null, 2), {
1409
+ C.writeFileSync(ue, JSON.stringify(t, null, 2), {
1308
1410
  mode: 384
1309
1411
  // Read/write for owner only
1310
1412
  });
1311
1413
  }
1312
- function pt() {
1414
+ function ft() {
1313
1415
  try {
1314
- return P.existsSync(me) && P.unlinkSync(me), !0;
1416
+ return C.existsSync(ue) && C.unlinkSync(ue), !0;
1315
1417
  } catch (o) {
1316
1418
  return console.error("Failed to clear credentials:", o.message), !1;
1317
1419
  }
1318
1420
  }
1319
- function zt(o) {
1421
+ function Zt(o) {
1320
1422
  if (!o || !o.expiresAt)
1321
1423
  return !0;
1322
1424
  const t = 5 * 60 * 1e3, e = new Date(o.expiresAt).getTime();
1323
1425
  return Date.now() > e - t;
1324
1426
  }
1325
- function $e() {
1326
- const o = ze();
1427
+ function Pe() {
1428
+ const o = Ve();
1327
1429
  return o ? {
1328
1430
  email: o.userEmail,
1329
1431
  userId: o.userId
1330
1432
  } : null;
1331
1433
  }
1332
- const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, We = `http://localhost:${Se}/callback`, Wt = "myop-cli";
1333
- function Vt() {
1334
- return Be.randomBytes(32).toString("base64url");
1434
+ const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", xe = 19284, Ye = `http://localhost:${xe}/callback`, qt = "myop-cli";
1435
+ function Xt() {
1436
+ return ze.randomBytes(32).toString("base64url");
1335
1437
  }
1336
- function Gt(o) {
1337
- return Be.createHash("sha256").update(o).digest("base64url");
1438
+ function eo(o) {
1439
+ return ze.createHash("sha256").update(o).digest("base64url");
1338
1440
  }
1339
- async function Yt() {
1441
+ async function to() {
1340
1442
  const o = await fetch(`${le}/oauth/register`, {
1341
1443
  method: "POST",
1342
1444
  headers: { "Content-Type": "application/json" },
1343
1445
  body: JSON.stringify({
1344
- client_name: Wt,
1345
- redirect_uris: [We],
1446
+ client_name: qt,
1447
+ redirect_uris: [Ye],
1346
1448
  grant_types: ["authorization_code", "refresh_token"],
1347
1449
  response_types: ["code"]
1348
1450
  })
@@ -1353,7 +1455,7 @@ async function Yt() {
1353
1455
  }
1354
1456
  return o.json();
1355
1457
  }
1356
- function ve(o, t, e, n = null) {
1458
+ function Se(o, t, e, n = null) {
1357
1459
  const s = {
1358
1460
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
1359
1461
  <circle cx="12" cy="12" r="10"/>
@@ -1371,7 +1473,7 @@ function ve(o, t, e, n = null) {
1371
1473
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
1372
1474
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
1373
1475
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
1374
- }, { accent: d, glow: g } = i[o] || i.error;
1476
+ }, { accent: r, glow: p } = i[o] || i.error;
1375
1477
  return `<!DOCTYPE html>
1376
1478
  <html lang="en">
1377
1479
  <head>
@@ -1432,7 +1534,7 @@ function ve(o, t, e, n = null) {
1432
1534
  h1 {
1433
1535
  font-size: 20px;
1434
1536
  font-weight: 500;
1435
- color: ${d};
1537
+ color: ${r};
1436
1538
  margin-bottom: 12px;
1437
1539
  letter-spacing: -0.5px;
1438
1540
  }
@@ -1464,8 +1566,8 @@ function ve(o, t, e, n = null) {
1464
1566
  display: inline-flex;
1465
1567
  align-items: center;
1466
1568
  gap: 8px;
1467
- background: ${g};
1468
- border: 1px solid ${d}33;
1569
+ background: ${p};
1570
+ border: 1px solid ${r}33;
1469
1571
  border-radius: 4px;
1470
1572
  padding: 10px 16px;
1471
1573
  font-size: 12px;
@@ -1519,14 +1621,14 @@ function ve(o, t, e, n = null) {
1519
1621
  </body>
1520
1622
  </html>`;
1521
1623
  }
1522
- function Kt(o) {
1624
+ function oo(o) {
1523
1625
  return new Promise((t, e) => {
1524
- const n = Mt.createServer((s, i) => {
1525
- const d = new nt(s.url, `http://localhost:${Se}`);
1526
- if (d.pathname === "/callback") {
1527
- const g = d.searchParams.get("code"), h = d.searchParams.get("state"), l = d.searchParams.get("error");
1626
+ const n = It.createServer((s, i) => {
1627
+ const r = new it(s.url, `http://localhost:${xe}`);
1628
+ if (r.pathname === "/callback") {
1629
+ const p = r.searchParams.get("code"), m = r.searchParams.get("state"), l = r.searchParams.get("error");
1528
1630
  if (l) {
1529
- i.writeHead(200, { "Content-Type": "text/html" }), i.end(ve(
1631
+ i.writeHead(200, { "Content-Type": "text/html" }), i.end(Se(
1530
1632
  "error",
1531
1633
  "Authentication Failed",
1532
1634
  "Unable to complete the authentication process.",
@@ -1534,8 +1636,8 @@ function Kt(o) {
1534
1636
  )), n.close(), e(new Error(`OAuth error: ${l}`));
1535
1637
  return;
1536
1638
  }
1537
- if (h !== o) {
1538
- i.writeHead(400, { "Content-Type": "text/html" }), i.end(ve(
1639
+ if (m !== o) {
1640
+ i.writeHead(400, { "Content-Type": "text/html" }), i.end(Se(
1539
1641
  "warning",
1540
1642
  "Security Error",
1541
1643
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
@@ -1543,8 +1645,8 @@ function Kt(o) {
1543
1645
  )), n.close(), e(new Error("State mismatch"));
1544
1646
  return;
1545
1647
  }
1546
- if (!g) {
1547
- i.writeHead(400, { "Content-Type": "text/html" }), i.end(ve(
1648
+ if (!p) {
1649
+ i.writeHead(400, { "Content-Type": "text/html" }), i.end(Se(
1548
1650
  "error",
1549
1651
  "Missing Authorization Code",
1550
1652
  "No authorization code was received from the server.",
@@ -1552,30 +1654,30 @@ function Kt(o) {
1552
1654
  )), n.close(), e(new Error("No authorization code"));
1553
1655
  return;
1554
1656
  }
1555
- i.writeHead(200, { "Content-Type": "text/html" }), i.end(ve(
1657
+ i.writeHead(200, { "Content-Type": "text/html" }), i.end(Se(
1556
1658
  "success",
1557
1659
  "Authentication Successful",
1558
1660
  "You have been authenticated successfully. Return to the terminal to continue."
1559
- )), n.close(), t(g);
1661
+ )), n.close(), t(p);
1560
1662
  } else
1561
1663
  i.writeHead(404), i.end("Not found");
1562
1664
  });
1563
- n.listen(Se, () => {
1564
- console.info(`OAuth callback server listening on port ${Se}`);
1665
+ n.listen(xe, () => {
1666
+ console.info(`OAuth callback server listening on port ${xe}`);
1565
1667
  }), setTimeout(() => {
1566
1668
  n.close(), e(new Error("Authentication timed out"));
1567
1669
  }, 5 * 60 * 1e3);
1568
1670
  });
1569
1671
  }
1570
- async function Qt(o, t, e) {
1672
+ async function no(o, t, e) {
1571
1673
  const n = await fetch(`${le}/oauth/token`, {
1572
1674
  method: "POST",
1573
1675
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1574
- body: new st({
1676
+ body: new rt({
1575
1677
  grant_type: "authorization_code",
1576
1678
  code: o,
1577
1679
  client_id: t,
1578
- redirect_uri: We,
1680
+ redirect_uri: Ye,
1579
1681
  code_verifier: e
1580
1682
  })
1581
1683
  });
@@ -1585,11 +1687,11 @@ async function Qt(o, t, e) {
1585
1687
  }
1586
1688
  return n.json();
1587
1689
  }
1588
- async function Zt(o, t) {
1690
+ async function so(o, t) {
1589
1691
  const e = await fetch(`${le}/oauth/token`, {
1590
1692
  method: "POST",
1591
1693
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1592
- body: new st({
1694
+ body: new rt({
1593
1695
  grant_type: "refresh_token",
1594
1696
  refresh_token: o,
1595
1697
  client_id: t
@@ -1601,8 +1703,8 @@ async function Zt(o, t) {
1601
1703
  }
1602
1704
  return e.json();
1603
1705
  }
1604
- async function Xt(o) {
1605
- var s, i, d;
1706
+ async function io(o) {
1707
+ var s, i, r;
1606
1708
  const t = await fetch(`${le}/mcp`, {
1607
1709
  method: "POST",
1608
1710
  headers: {
@@ -1624,62 +1726,62 @@ async function Xt(o) {
1624
1726
  const e = await t.json();
1625
1727
  if (e.error)
1626
1728
  throw new Error(e.error.message);
1627
- const n = (d = (i = (s = e.result) == null ? void 0 : s.content) == null ? void 0 : i[0]) == null ? void 0 : d.text;
1729
+ const n = (r = (i = (s = e.result) == null ? void 0 : s.content) == null ? void 0 : i[0]) == null ? void 0 : r.text;
1628
1730
  if (n)
1629
1731
  return JSON.parse(n);
1630
1732
  throw new Error("Invalid response from whoami");
1631
1733
  }
1632
- async function pe() {
1633
- const o = V("Starting authentication...").start();
1734
+ async function me() {
1735
+ const o = z("Starting authentication...").start();
1634
1736
  try {
1635
1737
  o.text = "Registering OAuth client...";
1636
- const e = (await Yt()).client_id, n = Vt(), s = Gt(n), i = Be.randomBytes(16).toString("hex");
1738
+ const e = (await to()).client_id, n = Xt(), s = eo(n), i = ze.randomBytes(16).toString("hex");
1637
1739
  o.text = "Waiting for authorization...";
1638
- const d = Kt(i), g = new nt(`${le}/oauth/authorize`);
1639
- g.searchParams.set("response_type", "code"), g.searchParams.set("client_id", e), g.searchParams.set("redirect_uri", We), g.searchParams.set("code_challenge", s), g.searchParams.set("code_challenge_method", "S256"), g.searchParams.set("state", i), o.stop(), console.log(`
1640
- 🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${g.toString()}
1641
- `), await Pt(g.toString());
1642
- const h = await d;
1740
+ const r = oo(i), p = new it(`${le}/oauth/authorize`);
1741
+ p.searchParams.set("response_type", "code"), p.searchParams.set("client_id", e), p.searchParams.set("redirect_uri", Ye), p.searchParams.set("code_challenge", s), p.searchParams.set("code_challenge_method", "S256"), p.searchParams.set("state", i), o.stop(), console.log(`
1742
+ 🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${p.toString()}
1743
+ `), await Ot(p.toString());
1744
+ const m = await r;
1643
1745
  o.start("Exchanging authorization code...");
1644
- const l = await Qt(h, e, n);
1746
+ const l = await no(m, e, n);
1645
1747
  o.text = "Getting user info...";
1646
- const c = await Xt(l.access_token), y = {
1748
+ const d = await io(l.access_token), y = {
1647
1749
  accessToken: l.access_token,
1648
1750
  refreshToken: l.refresh_token,
1649
1751
  expiresAt: new Date(Date.now() + l.expires_in * 1e3).toISOString(),
1650
1752
  clientId: e,
1651
- userId: c.userId,
1652
- userEmail: c.email
1753
+ userId: d.userId,
1754
+ userEmail: d.email
1653
1755
  };
1654
- return dt(y), o.succeed(`Authenticated as ${c.email}`), y;
1756
+ return ut(y), o.succeed(`Authenticated as ${d.email}`), y;
1655
1757
  } catch (t) {
1656
1758
  throw o.fail(`Authentication failed: ${t.message}`), t;
1657
1759
  }
1658
1760
  }
1659
- async function mt() {
1660
- const o = ze();
1761
+ async function gt() {
1762
+ const o = Ve();
1661
1763
  if (!o) {
1662
1764
  console.log("Not currently logged in.");
1663
1765
  return;
1664
1766
  }
1665
- pt(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1767
+ ft(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1666
1768
  }
1667
- function qt(o) {
1769
+ function ro(o) {
1668
1770
  var e, n;
1669
1771
  const t = (o == null ? void 0 : o.message) || "";
1670
1772
  return t.includes("ECONNREFUSED") || t.includes("ENOTFOUND") || t.includes("ETIMEDOUT") || t.includes("fetch failed") || t.includes("network") || (o == null ? void 0 : o.code) === "ECONNREFUSED" || ((e = o == null ? void 0 : o.cause) == null ? void 0 : e.code) === "ECONNREFUSED" || ((n = o == null ? void 0 : o.cause) == null ? void 0 : n.code) === "ENOTFOUND";
1671
1773
  }
1672
- async function Ve() {
1673
- let o = ze();
1774
+ async function Ge() {
1775
+ let o = Ve();
1674
1776
  if (!o)
1675
1777
  return console.log(`Not logged in. Starting authentication...
1676
- `), await pe();
1677
- if (!zt(o))
1778
+ `), await me();
1779
+ if (!Zt(o))
1678
1780
  return o;
1679
1781
  if (o.refreshToken) {
1680
- const t = V("Refreshing access token...").start();
1782
+ const t = z("Refreshing access token...").start();
1681
1783
  try {
1682
- const e = await Zt(
1784
+ const e = await so(
1683
1785
  o.refreshToken,
1684
1786
  o.clientId
1685
1787
  );
@@ -1688,64 +1790,64 @@ async function Ve() {
1688
1790
  accessToken: e.access_token,
1689
1791
  refreshToken: e.refresh_token,
1690
1792
  expiresAt: new Date(Date.now() + e.expires_in * 1e3).toISOString()
1691
- }, dt(o), t.succeed("Token refreshed"), o;
1793
+ }, ut(o), t.succeed("Token refreshed"), o;
1692
1794
  } catch (e) {
1693
- if (qt(e))
1795
+ if (ro(e))
1694
1796
  throw t.fail("Network error during token refresh"), e;
1695
- return t.warn("Token refresh failed, please log in again"), pt(), await pe();
1797
+ return t.warn("Token refresh failed, please log in again"), ft(), await me();
1696
1798
  }
1697
1799
  }
1698
1800
  return console.log(`Session expired. Please log in again.
1699
- `), await pe();
1801
+ `), await me();
1700
1802
  }
1701
- function Ce() {
1803
+ function Me() {
1702
1804
  return le;
1703
1805
  }
1704
- const Z = "@myop/cli", Fe = process.platform === "win32";
1705
- function eo() {
1806
+ const Z = "@myop/cli", Ae = process.platform === "win32";
1807
+ function ao() {
1706
1808
  try {
1707
1809
  return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
1708
1810
  } catch {
1709
1811
  return "https://registry.npmjs.org/";
1710
1812
  }
1711
1813
  }
1712
- function to() {
1814
+ function lo() {
1713
1815
  try {
1714
1816
  return Q("npm config get prefix", { encoding: "utf-8" }).trim();
1715
1817
  } catch {
1716
1818
  return null;
1717
1819
  }
1718
1820
  }
1719
- async function oo() {
1821
+ async function co() {
1720
1822
  try {
1721
- const o = eo().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
1823
+ const o = ao().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
1722
1824
  return t.ok ? (await t.json()).version : null;
1723
1825
  } catch {
1724
1826
  return null;
1725
1827
  }
1726
1828
  }
1727
- function no(o, t) {
1829
+ function po(o, t) {
1728
1830
  const e = o.split(".").map(Number), n = t.split(".").map(Number);
1729
1831
  for (let s = 0; s < Math.max(e.length, n.length); s++) {
1730
- const i = e[s] || 0, d = n[s] || 0;
1731
- if (i > d) return 1;
1732
- if (i < d) return -1;
1832
+ const i = e[s] || 0, r = n[s] || 0;
1833
+ if (i > r) return 1;
1834
+ if (i < r) return -1;
1733
1835
  }
1734
1836
  return 0;
1735
1837
  }
1736
- async function so(o) {
1737
- const t = V({
1838
+ async function mo(o) {
1839
+ const t = z({
1738
1840
  text: "Checking for updates...",
1739
1841
  color: "cyan"
1740
- }).start(), e = await oo();
1741
- if (t.stop(), !e || no(e, o) <= 0)
1842
+ }).start(), e = await co();
1843
+ if (t.stop(), !e || po(e, o) <= 0)
1742
1844
  return !1;
1743
1845
  console.log(`
1744
1846
  πŸ“¦ New version available: ${o} β†’ ${e}
1745
1847
  `);
1746
1848
  let n;
1747
1849
  try {
1748
- n = await ot({
1850
+ n = await st({
1749
1851
  message: "Would you like to update now?",
1750
1852
  choices: [
1751
1853
  { name: "Yes, update now", value: !0 },
@@ -1759,10 +1861,10 @@ async function so(o) {
1759
1861
  `), process.exit(0)), s;
1760
1862
  }
1761
1863
  if (n) {
1762
- const s = V({
1864
+ const s = z({
1763
1865
  text: `Updating ${Z} to v${e}...`,
1764
1866
  color: "green"
1765
- }).start(), i = `npm install -g ${Z}@latest`, d = to();
1867
+ }).start(), i = `npm install -g ${Z}@latest`, r = lo();
1766
1868
  try {
1767
1869
  Q(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
1768
1870
  } catch {
@@ -1770,11 +1872,11 @@ async function so(o) {
1770
1872
  πŸ” Elevated permissions required.
1771
1873
  `);
1772
1874
  try {
1773
- if (Fe) {
1774
- const c = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${d ? `install -g ${Z}@latest --prefix \\"${d}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
1775
- Q(`powershell -Command "${c}"`, { stdio: "inherit" });
1875
+ if (Ae) {
1876
+ const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${r ? `install -g ${Z}@latest --prefix \\"${r}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
1877
+ Q(`powershell -Command "${d}"`, { stdio: "inherit" });
1776
1878
  } else {
1777
- const l = d ? `sudo npm install -g ${Z}@latest --prefix "${d}"` : `sudo ${i}`;
1879
+ const l = r ? `sudo npm install -g ${Z}@latest --prefix "${r}"` : `sudo ${i}`;
1778
1880
  Q(l, { stdio: "inherit" });
1779
1881
  }
1780
1882
  console.log(`
@@ -1782,24 +1884,24 @@ async function so(o) {
1782
1884
  } catch {
1783
1885
  console.log(`
1784
1886
  ❌ Update failed`);
1785
- const c = Fe ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
1887
+ const d = Ae ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
1786
1888
  console.log(`
1787
- Please run manually: ${c}
1889
+ Please run manually: ${d}
1788
1890
  `), process.exit(1);
1789
1891
  }
1790
1892
  }
1791
- let g = null;
1893
+ let p = null;
1792
1894
  try {
1793
- let h;
1794
- d ? h = Fe ? _e(d, "node_modules") : _e(d, "lib", "node_modules") : h = Q("npm root -g", { encoding: "utf-8" }).trim();
1795
- const l = _e(h, Z, "package.json"), c = Ct(l, "utf-8");
1796
- g = JSON.parse(c).version;
1895
+ let m;
1896
+ r ? m = Ae ? je(r, "node_modules") : je(r, "lib", "node_modules") : m = Q("npm root -g", { encoding: "utf-8" }).trim();
1897
+ const l = je(m, Z, "package.json"), d = Et(l, "utf-8");
1898
+ p = JSON.parse(d).version;
1797
1899
  } catch {
1798
1900
  }
1799
- if (g === e)
1901
+ if (p === e)
1800
1902
  return console.log(`
1801
1903
  πŸ”„ Restarting...
1802
- `), $t(process.argv[0], process.argv.slice(1), {
1904
+ `), Mt(process.argv[0], process.argv.slice(1), {
1803
1905
  stdio: "inherit",
1804
1906
  shell: !0
1805
1907
  }).on("close", (l) => {
@@ -1811,35 +1913,35 @@ Please run myop again to use the new version.
1811
1913
  }
1812
1914
  return !1;
1813
1915
  }
1814
- const Ue = N.join(it.homedir(), ".myop"), He = N.join(Ue, "preferences.json");
1815
- function io() {
1816
- P.existsSync(Ue) || P.mkdirSync(Ue, { recursive: !0, mode: 448 });
1916
+ const Be = R.join(at.homedir(), ".myop"), Je = R.join(Be, "preferences.json");
1917
+ function uo() {
1918
+ C.existsSync(Be) || C.mkdirSync(Be, { recursive: !0, mode: 448 });
1817
1919
  }
1818
- function ut() {
1920
+ function ht() {
1819
1921
  try {
1820
- if (!P.existsSync(He))
1922
+ if (!C.existsSync(Je))
1821
1923
  return {};
1822
- const o = P.readFileSync(He, "utf8");
1924
+ const o = C.readFileSync(Je, "utf8");
1823
1925
  return JSON.parse(o);
1824
1926
  } catch {
1825
1927
  return {};
1826
1928
  }
1827
1929
  }
1828
- function ro(o) {
1829
- io();
1830
- const e = { ...ut(), ...o };
1831
- P.writeFileSync(He, JSON.stringify(e, null, 2), {
1930
+ function fo(o) {
1931
+ uo();
1932
+ const e = { ...ht(), ...o };
1933
+ C.writeFileSync(Je, JSON.stringify(e, null, 2), {
1832
1934
  mode: 384
1833
1935
  });
1834
1936
  }
1835
- function ao() {
1836
- return ut().defaultOrganization || null;
1937
+ function go() {
1938
+ return ht().defaultOrganization || null;
1837
1939
  }
1838
- function je({ id: o, name: t }) {
1839
- ro({ defaultOrganization: { id: o, name: t } });
1940
+ function De({ id: o, name: t }) {
1941
+ fo({ defaultOrganization: { id: o, name: t } });
1840
1942
  }
1841
- async function lo(o, t, e, n = {}) {
1842
- var g, h, l;
1943
+ async function ho(o, t, e, n = {}) {
1944
+ var p, m, l;
1843
1945
  const s = await fetch(`${o}/mcp`, {
1844
1946
  method: "POST",
1845
1947
  headers: {
@@ -1861,12 +1963,12 @@ async function lo(o, t, e, n = {}) {
1861
1963
  const i = await s.json();
1862
1964
  if (i.error)
1863
1965
  throw new Error(i.error.message || "MCP error");
1864
- const d = (l = (h = (g = i.result) == null ? void 0 : g.content) == null ? void 0 : h[0]) == null ? void 0 : l.text;
1865
- if (!d)
1966
+ const r = (l = (m = (p = i.result) == null ? void 0 : p.content) == null ? void 0 : m[0]) == null ? void 0 : l.text;
1967
+ if (!r)
1866
1968
  throw new Error(`No content returned from ${e}`);
1867
- return JSON.parse(d);
1969
+ return JSON.parse(r);
1868
1970
  }
1869
- const co = (o) => new Promise((t) => setTimeout(t, o));
1971
+ const yo = (o) => new Promise((t) => setTimeout(t, o));
1870
1972
  function re(o) {
1871
1973
  var e, n;
1872
1974
  const t = (o == null ? void 0 : o.message) || "";
@@ -1877,57 +1979,57 @@ function ae(o) {
1877
1979
  This usually happens in sandboxed environments (Claude Web, containers)`), console.error(` where outbound HTTP is restricted.
1878
1980
  `), console.error(" [MYOP_MCP_FALLBACK] Use Myop MCP tools instead:"), console.error(o === "push" ? " - Use the upload_component MCP tool with htmlContent parameter" : o === "pull" ? " - Use the get_component MCP tool" : " - Use list_organizations + list_components MCP tools"), console.error(" - Do NOT use presigned URL / curl flow β€” same network restrictions apply"), console.error("");
1879
1981
  }
1880
- const po = () => {
1982
+ const wo = () => {
1881
1983
  let o = new URL(import.meta.url).pathname;
1882
1984
  process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
1883
- const t = N.dirname(o);
1884
- return N.join(t, "skills");
1885
- }, mo = (o) => {
1985
+ const t = R.dirname(o);
1986
+ return R.join(t, "skills");
1987
+ }, vo = (o) => {
1886
1988
  try {
1887
- const t = N.join(o, "package.json");
1888
- if (!P.existsSync(t)) return [];
1889
- const e = JSON.parse(P.readFileSync(t, "utf-8"));
1989
+ const t = R.join(o, "package.json");
1990
+ if (!C.existsSync(t)) return [];
1991
+ const e = JSON.parse(C.readFileSync(t, "utf-8"));
1890
1992
  return Object.keys({ ...e.dependencies, ...e.devDependencies });
1891
1993
  } catch {
1892
1994
  return [];
1893
1995
  }
1894
- }, Ge = async (o) => {
1895
- const t = po();
1896
- if (!P.existsSync(t))
1996
+ }, Ke = async (o) => {
1997
+ const t = wo();
1998
+ if (!C.existsSync(t))
1897
1999
  return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
1898
2000
  try {
1899
- const e = mo(o), n = ["myop-cli", "myop-component"], s = [
2001
+ const e = vo(o), n = ["myop-cli", "myop-component"], s = [
1900
2002
  { deps: ["@myop/react", "react"], skill: "myop-react-host" },
1901
2003
  { deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
1902
2004
  { deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
1903
2005
  { deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
1904
- ], i = s.filter(({ deps: l }) => l.some((c) => e.includes(c))).map(({ skill: l }) => l), d = s.flatMap(({ deps: l }) => l.filter((c) => e.includes(c)));
2006
+ ], i = s.filter(({ deps: l }) => l.some((d) => e.includes(d))).map(({ skill: l }) => l), r = s.flatMap(({ deps: l }) => l.filter((d) => e.includes(d)));
1905
2007
  i.length > 0 ? n.push(...i) : n.push(...s.map((l) => l.skill));
1906
- const g = n.map((l) => `--skill ${l}`).join(" "), h = `npx -y skills add "${t}" ${g} --agent '*' --copy -y`;
1907
- return Q(h, { cwd: o, stdio: "pipe" }), { success: !0, detected: d, skillNames: n };
2008
+ const p = n.map((l) => `--skill ${l}`).join(" "), m = `npx -y skills add "${t}" ${p} --agent '*' --copy -y`;
2009
+ return Q(m, { cwd: o, stdio: "pipe" }), { success: !0, detected: r, skillNames: n };
1908
2010
  } catch (e) {
1909
2011
  return console.info("Failed to install skills:", e.message), { success: !1 };
1910
2012
  }
1911
- }, Ye = (o = ".", t = 3, e = 0) => {
2013
+ }, Qe = (o = ".", t = 3, e = 0) => {
1912
2014
  const n = [];
1913
2015
  if (e > t) return n;
1914
2016
  try {
1915
- const s = P.readdirSync(o, { withFileTypes: !0 });
2017
+ const s = C.readdirSync(o, { withFileTypes: !0 });
1916
2018
  for (const i of s) {
1917
- const d = N.join(o, i.name);
2019
+ const r = R.join(o, i.name);
1918
2020
  if (i.isDirectory()) {
1919
2021
  if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
1920
2022
  continue;
1921
- n.push(...Ye(d, t, e + 1));
2023
+ n.push(...Qe(r, t, e + 1));
1922
2024
  } else if (i.name === "myop.config.json")
1923
2025
  try {
1924
- const g = P.readFileSync(d, "utf-8"), h = JSON.parse(g);
2026
+ const p = C.readFileSync(r, "utf-8"), m = JSON.parse(p);
1925
2027
  n.push({
1926
2028
  path: o,
1927
- configPath: d,
1928
- name: h.name || h.componentName || N.basename(o),
1929
- componentId: h.componentId || null,
1930
- config: h
2029
+ configPath: r,
2030
+ name: m.name || m.componentName || R.basename(o),
2031
+ componentId: m.componentId || null,
2032
+ config: m
1931
2033
  });
1932
2034
  } catch {
1933
2035
  }
@@ -1937,7 +2039,7 @@ const po = () => {
1937
2039
  return n;
1938
2040
  };
1939
2041
  v.executionPath = process.cwd();
1940
- const Me = (o = !1) => {
2042
+ const Ee = (o = !1) => {
1941
2043
  const t = v.program.getOptionValue("verbose");
1942
2044
  t || (console.info = () => {
1943
2045
  }), console.info("πŸ“ verbose mode on"), v.options = {
@@ -1945,7 +2047,7 @@ const Me = (o = !1) => {
1945
2047
  verbose: t
1946
2048
  };
1947
2049
  try {
1948
- return v.myopConfig = Ot(v.options.configPath), { configFound: !0 };
2050
+ return v.myopConfig = Rt(v.options.configPath), { configFound: !0 };
1949
2051
  } catch (e) {
1950
2052
  if (o) {
1951
2053
  console.info(`
@@ -1955,7 +2057,7 @@ const Me = (o = !1) => {
1955
2057
  author: "@myop-cli",
1956
2058
  flows: []
1957
2059
  };
1958
- return Je(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
2060
+ return We(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
1959
2061
  } catch {
1960
2062
  return console.info("Error details :", e), { configFound: !1, error: e };
1961
2063
  }
@@ -1964,39 +2066,39 @@ const Me = (o = !1) => {
1964
2066
  }
1965
2067
  };
1966
2068
  [
1967
- new De(),
1968
- ...Ft
2069
+ new Le(),
2070
+ ...Dt
1969
2071
  ];
1970
- const uo = "0.1.53";
1971
- v.program = new bt();
1972
- v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(uo);
1973
- v.program.addOption(new ue("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1974
- v.program.addOption(new ue("-h, --help", "Show helpful information"));
1975
- v.program.addOption(new ue("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1976
- v.program.addOption(new ue("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1977
- v.program.addOption(new ue("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
2072
+ const So = "0.1.54";
2073
+ v.program = new Pt();
2074
+ v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(So);
2075
+ v.program.addOption(new fe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
2076
+ v.program.addOption(new fe("-h, --help", "Show helpful information"));
2077
+ v.program.addOption(new fe("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
2078
+ v.program.addOption(new fe("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
2079
+ v.program.addOption(new fe("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
1978
2080
  v.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, t) => {
1979
- Me(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && at._action(t), process.exit();
2081
+ Ee(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && ct._action(t), process.exit();
1980
2082
  });
1981
2083
  v.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, t) => {
1982
- Me(), console.info("removing ", o, t, v.options.configPath), o === "flow" && lt._action(t), process.exit();
2084
+ Ee(), console.info("removing ", o, t, v.options.configPath), o === "flow" && dt._action(t), process.exit();
1983
2085
  });
1984
2086
  v.program.command("install").description("Install Myop assets").action(async () => {
1985
- Me(), await rt.action();
2087
+ Ee(), await lt.action();
1986
2088
  });
1987
2089
  v.program.command("login").description("Authenticate with Myop platform").action(async () => {
1988
2090
  try {
1989
- await pe();
2091
+ await me();
1990
2092
  } catch (o) {
1991
2093
  console.error("Login failed:", o.message), process.exit(1);
1992
2094
  }
1993
2095
  process.exit(0);
1994
2096
  });
1995
2097
  v.program.command("logout").description("Clear stored credentials").action(async () => {
1996
- await mt(), process.exit(0);
2098
+ await gt(), process.exit(0);
1997
2099
  });
1998
2100
  v.program.command("whoami").description("Show current authenticated user").action(async () => {
1999
- const o = $e();
2101
+ const o = Pe();
2000
2102
  o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
2001
2103
  });
2002
2104
  v.program.command("sync").description('[deprecated] Use "myop push" instead').option("--skip-build", "Skip the build step").action(async () => {
@@ -2011,85 +2113,85 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
2011
2113
  process.exit(0);
2012
2114
  });
2013
2115
  v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
2014
- var S, x, u;
2116
+ var S, x, g;
2015
2117
  const t = v.program.getOptionValue("config") || "./myop.config.json";
2016
2118
  let e = {};
2017
- if (P.existsSync(t))
2119
+ if (C.existsSync(t))
2018
2120
  try {
2019
- e = JSON.parse(P.readFileSync(t, "utf-8"));
2020
- } catch (p) {
2021
- console.error(`⚠️ Failed to parse ${t}:`, p.message);
2121
+ e = JSON.parse(C.readFileSync(t, "utf-8"));
2122
+ } catch (u) {
2123
+ console.error(`⚠️ Failed to parse ${t}:`, u.message);
2022
2124
  }
2023
2125
  o && (e.componentId = o);
2024
- const n = e.name || e.componentName || N.basename(process.cwd());
2126
+ const n = e.name || e.componentName || R.basename(process.cwd());
2025
2127
  console.log(`
2026
2128
  πŸ“‹ Component: ${n}`);
2027
2129
  let s = null, i = !1;
2028
2130
  try {
2029
- const p = JSON.parse(P.readFileSync("package.json", "utf-8"));
2030
- i = !!(p.scripts && p.scripts.build);
2131
+ const u = JSON.parse(C.readFileSync("package.json", "utf-8"));
2132
+ i = !!(u.scripts && u.scripts.build);
2031
2133
  } catch {
2032
2134
  }
2033
2135
  if (!i) {
2034
- const p = P.readdirSync(".").filter(
2035
- (E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
2136
+ const u = C.readdirSync(".").filter(
2137
+ (E) => E.endsWith(".html") && !E.startsWith(".") && C.statSync(E).isFile()
2036
2138
  );
2037
- p.length === 1 && (s = p[0]);
2139
+ u.length === 1 && (s = u[0]);
2038
2140
  }
2039
2141
  if (s)
2040
2142
  console.log(` Single file: ${s} (skipping build)`);
2041
2143
  else if (i) {
2042
- const { exec: p } = await import("child_process");
2144
+ const { exec: u } = await import("child_process");
2043
2145
  let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
2044
- const I = (C = !1) => new Promise((j) => {
2045
- const M = V(C ? "Retrying build..." : "Building project...").start();
2046
- p("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (R, k, L) => {
2047
- if (!R) {
2146
+ const O = (P = !1) => new Promise((j) => {
2147
+ const M = z(P ? "Retrying build..." : "Building project...").start();
2148
+ u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (_, k, L) => {
2149
+ if (!_) {
2048
2150
  M.succeed("Build completed"), j(!0);
2049
2151
  return;
2050
2152
  }
2051
2153
  if (M.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
2052
- const A = await ct(R, k, L, p, E);
2053
- if (E = { ...E, ...A }, A.handled) {
2054
- const _ = await I(!0);
2055
- j(_);
2154
+ const D = await pt(_, k, L, u, E);
2155
+ if (E = { ...E, ...D }, D.handled) {
2156
+ const T = await O(!0);
2157
+ j(T);
2056
2158
  return;
2057
2159
  }
2058
2160
  }
2059
- console.error(R.message), j(!1);
2161
+ console.error(_.message), j(!1);
2060
2162
  });
2061
2163
  });
2062
- await I() || process.exit(1);
2164
+ await O() || process.exit(1);
2063
2165
  }
2064
- let d;
2166
+ let r;
2065
2167
  if (s)
2066
- d = s;
2067
- else if (P.existsSync("./dist/index.html"))
2068
- d = "./dist/index.html";
2168
+ r = s;
2169
+ else if (C.existsSync("./dist/index.html"))
2170
+ r = "./dist/index.html";
2069
2171
  else {
2070
- const p = P.readdirSync(".").filter(
2071
- (E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
2172
+ const u = C.readdirSync(".").filter(
2173
+ (E) => E.endsWith(".html") && !E.startsWith(".") && C.statSync(E).isFile()
2072
2174
  );
2073
- p.length === 1 ? d = p[0] : (console.error("❌ No HTML file found to upload."), console.log(" Expected: a single .html file in root or ./dist/index.html"), process.exit(1));
2175
+ u.length === 1 ? r = u[0] : (console.error("❌ No HTML file found to upload."), console.log(" Expected: a single .html file in root or ./dist/index.html"), process.exit(1));
2074
2176
  }
2075
- const g = P.readFileSync(d, "utf-8");
2076
- console.log(` File: ${d} (${(g.length / 1024).toFixed(1)} KB)`);
2077
- let h;
2177
+ const p = C.readFileSync(r, "utf-8");
2178
+ console.log(` File: ${r} (${(p.length / 1024).toFixed(1)} KB)`);
2179
+ let m;
2078
2180
  try {
2079
- h = await Ve();
2080
- } catch (p) {
2081
- re(p) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("❌ Authentication failed:", p.message), console.error(`
2181
+ m = await Ge();
2182
+ } catch (u) {
2183
+ re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("❌ Authentication failed:", u.message), console.error(`
2082
2184
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2083
2185
  `)), process.exit(1);
2084
2186
  }
2085
- const l = Ce();
2086
- let c = V("Uploading...").start(), y;
2187
+ const l = Me();
2188
+ let d = z("Uploading...").start(), y;
2087
2189
  try {
2088
- const p = await fetch(`${l}/mcp`, {
2190
+ const u = await fetch(`${l}/mcp`, {
2089
2191
  method: "POST",
2090
2192
  headers: {
2091
2193
  "Content-Type": "application/json",
2092
- Authorization: `Bearer ${h.accessToken}`
2194
+ Authorization: `Bearer ${m.accessToken}`
2093
2195
  },
2094
2196
  body: JSON.stringify({
2095
2197
  jsonrpc: "2.0",
@@ -2101,29 +2203,29 @@ v.program.command("push").description("Upload component to Myop platform").argum
2101
2203
  name: n,
2102
2204
  componentId: e.componentId && e.componentId !== "DEV" ? e.componentId : void 0,
2103
2205
  organization: e.organization || void 0,
2104
- htmlContent: g
2206
+ htmlContent: p
2105
2207
  }
2106
2208
  }
2107
2209
  })
2108
2210
  });
2109
- if (!p.ok)
2110
- throw new Error(`Server returned ${p.status}`);
2111
- const E = await p.json();
2211
+ if (!u.ok)
2212
+ throw new Error(`Server returned ${u.status}`);
2213
+ const E = await u.json();
2112
2214
  if (E.error)
2113
2215
  throw new Error(E.error.message);
2114
- const I = (u = (x = (S = E.result) == null ? void 0 : S.content) == null ? void 0 : x[0]) == null ? void 0 : u.text;
2115
- if (y = JSON.parse(I), !y.success)
2216
+ const O = (g = (x = (S = E.result) == null ? void 0 : S.content) == null ? void 0 : x[0]) == null ? void 0 : g.text;
2217
+ if (y = JSON.parse(O), !y.success)
2116
2218
  throw new Error(y.error);
2117
- c.succeed("Pushed successfully");
2118
- } catch (p) {
2119
- c.fail("Upload failed"), re(p) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : console.error(" ", p.message), process.exit(1);
2219
+ d.succeed("Pushed successfully");
2220
+ } catch (u) {
2221
+ d.fail("Upload failed"), re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : console.error(" ", u.message), process.exit(1);
2120
2222
  }
2121
2223
  if (y.isNewComponent || !e.componentId || e.componentId === "DEV") {
2122
2224
  e.componentId = y.componentId, e.organization = y.orgId, e.name || (e.name = y.componentName);
2123
2225
  try {
2124
- P.writeFileSync(t, JSON.stringify(e, null, 2));
2125
- } catch (p) {
2126
- console.log(`⚠️ Could not update ${t}: ${p.message}`), console.log(` Add componentId: "${y.componentId}" manually`);
2226
+ C.writeFileSync(t, JSON.stringify(e, null, 2));
2227
+ } catch (u) {
2228
+ console.log(`⚠️ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${y.componentId}" manually`);
2127
2229
  }
2128
2230
  }
2129
2231
  console.log(`
@@ -2131,12 +2233,12 @@ v.program.command("push").description("Upload component to Myop platform").argum
2131
2233
  `), process.exit(0);
2132
2234
  });
2133
2235
  v.program.command("pull").description("Download component HTML from Myop platform").argument("[componentId]", "Component ID to pull (overrides myop.config.json)").option("-o, --output <path>", "Output file path (default: index.html or dist/index.html)").option("-e, --env <environment>", "Pull the variant released to this environment (e.g., staging, production)").action(async (o, t) => {
2134
- var p, E, I;
2236
+ var u, E, O;
2135
2237
  const e = v.program.getOptionValue("config") || "./myop.config.json";
2136
2238
  let n = {};
2137
- if (P.existsSync(e))
2239
+ if (C.existsSync(e))
2138
2240
  try {
2139
- n = JSON.parse(P.readFileSync(e, "utf-8"));
2241
+ n = JSON.parse(C.readFileSync(e, "utf-8"));
2140
2242
  } catch {
2141
2243
  }
2142
2244
  const s = o || n.componentId;
@@ -2144,22 +2246,22 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2144
2246
  const i = n.name || n.componentName || s;
2145
2247
  console.log(`
2146
2248
  πŸ“₯ Pulling: ${i}`), console.log(` ID: ${s}`), t.env && console.log(` Environment: ${t.env}`);
2147
- let d;
2249
+ let r;
2148
2250
  try {
2149
- d = await Ve();
2150
- } catch ($) {
2151
- re($) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("❌ Authentication failed:", $.message), console.error(`
2251
+ r = await Ge();
2252
+ } catch (b) {
2253
+ re(b) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("❌ Authentication failed:", b.message), console.error(`
2152
2254
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2153
2255
  `)), process.exit(1);
2154
2256
  }
2155
- const g = Ce(), h = V("Fetching component...").start();
2257
+ const p = Me(), m = z("Fetching component...").start();
2156
2258
  let l;
2157
2259
  try {
2158
- const $ = await fetch(`${g}/mcp`, {
2260
+ const b = await fetch(`${p}/mcp`, {
2159
2261
  method: "POST",
2160
2262
  headers: {
2161
2263
  "Content-Type": "application/json",
2162
- Authorization: `Bearer ${d.accessToken}`
2264
+ Authorization: `Bearer ${r.accessToken}`
2163
2265
  },
2164
2266
  body: JSON.stringify({
2165
2267
  jsonrpc: "2.0",
@@ -2171,33 +2273,33 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2171
2273
  }
2172
2274
  })
2173
2275
  });
2174
- if (!$.ok)
2175
- throw new Error(`Server returned ${$.status}`);
2176
- const C = await $.json();
2177
- if (C.error)
2178
- throw new Error(C.error.message);
2179
- const j = (I = (E = (p = C.result) == null ? void 0 : p.content) == null ? void 0 : E[0]) == null ? void 0 : I.text;
2180
- l = JSON.parse(j), !l.success && !l.html && (h.fail("Failed to fetch component"), console.error(" ", l.error || "No HTML content returned"), l.message && console.error(" ", l.message), process.exit(1)), h.succeed("Component fetched");
2181
- } catch ($) {
2182
- h.fail("Failed to fetch component"), re($) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : console.error(" ", $.message), process.exit(1);
2183
- }
2184
- let c = t.output;
2185
- c || (P.existsSync("./dist/index.html") ? c = "./dist/index.html" : c = "./index.html");
2186
- const y = l.htmlContent || l.html, S = N.dirname(c);
2187
- S && !P.existsSync(S) && P.mkdirSync(S, { recursive: !0 }), P.writeFileSync(c, y), console.log(` Saved to: ${c} (${(y.length / 1024).toFixed(1)} KB)`);
2188
- const x = P.existsSync(e);
2189
- let u = !1;
2190
- if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, u = !0), !n.name && l.name && (n.name = l.name, u = !0)) : (n = {
2191
- name: l.name || N.basename(process.cwd()),
2276
+ if (!b.ok)
2277
+ throw new Error(`Server returned ${b.status}`);
2278
+ const P = await b.json();
2279
+ if (P.error)
2280
+ throw new Error(P.error.message);
2281
+ const j = (O = (E = (u = P.result) == null ? void 0 : u.content) == null ? void 0 : E[0]) == null ? void 0 : O.text;
2282
+ l = JSON.parse(j), !l.success && !l.html && (m.fail("Failed to fetch component"), console.error(" ", l.error || "No HTML content returned"), l.message && console.error(" ", l.message), process.exit(1)), m.succeed("Component fetched");
2283
+ } catch (b) {
2284
+ m.fail("Failed to fetch component"), re(b) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : console.error(" ", b.message), process.exit(1);
2285
+ }
2286
+ let d = t.output;
2287
+ d || (C.existsSync("./dist/index.html") ? d = "./dist/index.html" : d = "./index.html");
2288
+ const y = l.htmlContent || l.html, S = R.dirname(d);
2289
+ S && !C.existsSync(S) && C.mkdirSync(S, { recursive: !0 }), C.writeFileSync(d, y), console.log(` Saved to: ${d} (${(y.length / 1024).toFixed(1)} KB)`);
2290
+ const x = C.existsSync(e);
2291
+ let g = !1;
2292
+ if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && l.name && (n.name = l.name, g = !0)) : (n = {
2293
+ name: l.name || R.basename(process.cwd()),
2192
2294
  componentId: s,
2193
2295
  type: "html",
2194
2296
  author: "@myop-cli",
2195
2297
  HMR: !0
2196
- }, u = !0), u)
2298
+ }, g = !0), g)
2197
2299
  try {
2198
- P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${x ? "Updated" : "Created"} ${e}`);
2199
- } catch ($) {
2200
- console.log(` ⚠️ Could not write ${e}: ${$.message}`);
2300
+ C.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${x ? "Updated" : "Created"} ${e}`);
2301
+ } catch (b) {
2302
+ console.log(` ⚠️ Could not write ${e}: ${b.message}`);
2201
2303
  }
2202
2304
  console.log(`
2203
2305
  βœ… Pull completed!
@@ -2207,95 +2309,95 @@ v.program.command("list").description("Browse and pull/push remote components").
2207
2309
  const { search: t, select: e } = await import("@inquirer/prompts");
2208
2310
  let n;
2209
2311
  try {
2210
- n = await Ve();
2211
- } catch (u) {
2212
- re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("❌ Authentication failed:", u.message), console.error(`
2312
+ n = await Ge();
2313
+ } catch (g) {
2314
+ re(g) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("❌ Authentication failed:", g.message), console.error(`
2213
2315
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2214
2316
  `)), process.exit(1);
2215
2317
  }
2216
- const s = Ce(), i = (u, p) => lo(s, n.accessToken, u, p);
2217
- let d = V("Loading organizations...").start(), g;
2318
+ const s = Me(), i = (g, u) => ho(s, n.accessToken, g, u);
2319
+ let r = z("Loading organizations...").start(), p;
2218
2320
  try {
2219
- const u = await i("list_organizations");
2220
- if (g = u.organizations || u, !Array.isArray(g))
2321
+ const g = await i("list_organizations");
2322
+ if (p = g.organizations || g, !Array.isArray(p))
2221
2323
  throw new Error("Unexpected response from list_organizations");
2222
- } catch (u) {
2223
- d.fail("Failed to load organizations"), re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : console.error(" ", u.message), process.exit(1);
2324
+ } catch (g) {
2325
+ r.fail("Failed to load organizations"), re(g) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : console.error(" ", g.message), process.exit(1);
2224
2326
  }
2225
- g.length === 0 && (d.fail("No organizations found for this account"), process.exit(1)), d.stop();
2226
- let h, l;
2327
+ p.length === 0 && (r.fail("No organizations found for this account"), process.exit(1)), r.stop();
2328
+ let m, l;
2227
2329
  if (o.org) {
2228
- const u = g.find((p) => p.id === o.org || p._id === o.org);
2229
- u || (console.error(`Organization "${o.org}" not found. Available:`), g.forEach((p) => console.log(` ${p.id || p._id} ${p.name}`)), process.exit(1)), h = u.id || u._id, l = u.name, je({ id: h, name: l });
2330
+ const g = p.find((u) => u.id === o.org || u._id === o.org);
2331
+ g || (console.error(`Organization "${o.org}" not found. Available:`), p.forEach((u) => console.log(` ${u.id || u._id} ${u.name}`)), process.exit(1)), m = g.id || g._id, l = g.name, De({ id: m, name: l });
2230
2332
  } else {
2231
- const u = ao();
2232
- if (u && g.find((p) => (p.id || p._id) === u.id))
2233
- h = u.id, l = u.name;
2234
- else if (g.length === 1)
2235
- h = g[0].id || g[0]._id, l = g[0].name, je({ id: h, name: l });
2333
+ const g = go();
2334
+ if (g && p.find((u) => (u.id || u._id) === g.id))
2335
+ m = g.id, l = g.name;
2336
+ else if (p.length === 1)
2337
+ m = p[0].id || p[0]._id, l = p[0].name, De({ id: m, name: l });
2236
2338
  else
2237
2339
  try {
2238
- const p = await e({
2340
+ const u = await e({
2239
2341
  message: "Select an organization:",
2240
- choices: g.map((E) => ({
2342
+ choices: p.map((E) => ({
2241
2343
  name: E.name,
2242
2344
  value: { id: E.id || E._id, name: E.name }
2243
2345
  }))
2244
2346
  });
2245
- h = p.id, l = p.name, je({ id: h, name: l });
2246
- } catch (p) {
2247
- throw p.name === "ExitPromptError" && (console.log(`
2347
+ m = u.id, l = u.name, De({ id: m, name: l });
2348
+ } catch (u) {
2349
+ throw u.name === "ExitPromptError" && (console.log(`
2248
2350
 
2249
2351
  πŸ‘‹ Goodbye!
2250
- `), process.exit(0)), p;
2352
+ `), process.exit(0)), u;
2251
2353
  }
2252
2354
  }
2253
- console.log(` Using organization: ${l}`), d = V("Loading components...").start();
2254
- let c;
2355
+ console.log(` Using organization: ${l}`), r = z("Loading components...").start();
2356
+ let d;
2255
2357
  try {
2256
- const u = await i("list_components", { organizationId: h });
2257
- if (c = u.components || u, !Array.isArray(c))
2358
+ const g = await i("list_components", { organizationId: m });
2359
+ if (d = g.components || g, !Array.isArray(d))
2258
2360
  throw new Error("Unexpected response from list_components");
2259
- } catch (u) {
2260
- d.fail("Failed to load components"), console.error(" ", u.message), process.exit(1);
2361
+ } catch (g) {
2362
+ r.fail("Failed to load components"), console.error(" ", g.message), process.exit(1);
2261
2363
  }
2262
- d.stop(), c.length === 0 && (console.log(` No components found in this organization.
2263
- `), process.exit(0)), console.log(` ${l} - ${c.length} component(s)
2364
+ r.stop(), d.length === 0 && (console.log(` No components found in this organization.
2365
+ `), process.exit(0)), console.log(` ${l} - ${d.length} component(s)
2264
2366
  `);
2265
2367
  const y = [];
2266
2368
  for (; ; ) {
2267
- const u = `[Done - pull/push ${y.length} selected]`, p = "__done__", E = new Set(y.map((C) => C.id || C._id || C.componentId));
2268
- let I;
2369
+ const g = `[Done - pull/push ${y.length} selected]`, u = "__done__", E = new Set(y.map((P) => P.id || P._id || P.componentId));
2370
+ let O;
2269
2371
  try {
2270
- I = await t({
2372
+ O = await t({
2271
2373
  message: "Search & select components:",
2272
- source: (C) => {
2273
- const j = (C || "").toLowerCase(), M = c.filter((k) => {
2374
+ source: (P) => {
2375
+ const j = (P || "").toLowerCase(), M = d.filter((k) => {
2274
2376
  const L = k.id || k._id || k.componentId;
2275
2377
  return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
2276
- }), R = [
2277
- { name: u, value: p }
2378
+ }), _ = [
2379
+ { name: g, value: u }
2278
2380
  ];
2279
2381
  for (const k of M) {
2280
- const L = k.id || k._id || k.componentId, A = L ? L.substring(0, 8) + "..." : "";
2281
- R.push({
2282
- name: `${k.name} (${A})`,
2382
+ const L = k.id || k._id || k.componentId, D = L ? L.substring(0, 8) + "..." : "";
2383
+ _.push({
2384
+ name: `${k.name} (${D})`,
2283
2385
  value: L
2284
2386
  });
2285
2387
  }
2286
- return R;
2388
+ return _;
2287
2389
  }
2288
2390
  });
2289
- } catch (C) {
2290
- throw C.name === "ExitPromptError" && (console.log(`
2391
+ } catch (P) {
2392
+ throw P.name === "ExitPromptError" && (console.log(`
2291
2393
 
2292
2394
  πŸ‘‹ Goodbye!
2293
- `), process.exit(0)), C;
2395
+ `), process.exit(0)), P;
2294
2396
  }
2295
- if (I === p)
2397
+ if (O === u)
2296
2398
  break;
2297
- const $ = c.find((C) => (C.id || C._id || C.componentId) === I);
2298
- $ && (y.push($), console.log(` + ${$.name}`));
2399
+ const b = d.find((P) => (P.id || P._id || P.componentId) === O);
2400
+ b && (y.push(b), console.log(` + ${b.name}`));
2299
2401
  }
2300
2402
  y.length === 0 && (console.log(` No components selected.
2301
2403
  `), process.exit(0));
@@ -2309,87 +2411,87 @@ v.program.command("list").description("Browse and pull/push remote components").
2309
2411
  { name: "Cancel", value: "cancel" }
2310
2412
  ]
2311
2413
  });
2312
- } catch (u) {
2313
- throw u.name === "ExitPromptError" && (console.log(`
2414
+ } catch (g) {
2415
+ throw g.name === "ExitPromptError" && (console.log(`
2314
2416
 
2315
2417
  πŸ‘‹ Goodbye!
2316
- `), process.exit(0)), u;
2418
+ `), process.exit(0)), g;
2317
2419
  }
2318
2420
  S === "cancel" && (console.log(` Cancelled.
2319
2421
  `), process.exit(0));
2320
- const x = (u) => u.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
2422
+ const x = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
2321
2423
  if (S === "pull") {
2322
2424
  console.log(`
2323
2425
  Pulling ${y.length} components...
2324
2426
  `);
2325
- const u = await Promise.all(y.map(async (I) => {
2326
- const $ = I.id || I._id || I.componentId;
2427
+ const g = await Promise.all(y.map(async (O) => {
2428
+ const b = O.id || O._id || O.componentId;
2327
2429
  try {
2328
- const C = await i("get_component", { componentId: $ }), j = x(I.name);
2329
- P.mkdirSync(j, { recursive: !0 });
2330
- const M = C.htmlContent || C.html;
2430
+ const P = await i("get_component", { componentId: b }), j = x(O.name);
2431
+ C.mkdirSync(j, { recursive: !0 });
2432
+ const M = P.htmlContent || P.html;
2331
2433
  if (!M)
2332
2434
  throw new Error("No HTML content returned");
2333
- return P.writeFileSync(N.join(j, "index.html"), M), P.writeFileSync(N.join(j, "myop.config.json"), JSON.stringify({
2334
- name: I.name,
2335
- componentId: $,
2336
- organization: h,
2435
+ return C.writeFileSync(R.join(j, "index.html"), M), C.writeFileSync(R.join(j, "myop.config.json"), JSON.stringify({
2436
+ name: O.name,
2437
+ componentId: b,
2438
+ organization: m,
2337
2439
  type: "html",
2338
2440
  author: "@myop-cli",
2339
2441
  HMR: !0
2340
- }, null, 2)), { name: I.name, status: "ok", dir: j };
2341
- } catch (C) {
2342
- return { name: I.name, status: "failed", error: C.message };
2442
+ }, null, 2)), { name: O.name, status: "ok", dir: j };
2443
+ } catch (P) {
2444
+ return { name: O.name, status: "failed", error: P.message };
2343
2445
  }
2344
2446
  }));
2345
- let p = 0, E = 0;
2346
- for (const I of u)
2347
- I.status === "ok" ? (console.log(` \x1B[32mβœ”\x1B[0m ${I.name} -> ./${I.dir}/`), p++) : (console.log(` \x1B[31mβœ–\x1B[0m ${I.name} - ${I.error}`), E++);
2447
+ let u = 0, E = 0;
2448
+ for (const O of g)
2449
+ O.status === "ok" ? (console.log(` \x1B[32mβœ”\x1B[0m ${O.name} -> ./${O.dir}/`), u++) : (console.log(` \x1B[31mβœ–\x1B[0m ${O.name} - ${O.error}`), E++);
2348
2450
  console.log(`
2349
- Done! Pulled ${p} component${p !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
2451
+ Done! Pulled ${u} component${u !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
2350
2452
  `);
2351
2453
  } else if (S === "push") {
2352
2454
  console.log(`
2353
2455
  Pushing ${y.length} components...
2354
2456
  `);
2355
- const u = Ye(".", 3), p = await Promise.all(y.map(async (C) => {
2356
- const j = C.id || C._id || C.componentId, M = u.find((R) => R.componentId === j);
2457
+ const g = Qe(".", 3), u = await Promise.all(y.map(async (P) => {
2458
+ const j = P.id || P._id || P.componentId, M = g.find((_) => _.componentId === j);
2357
2459
  if (!M)
2358
- return { name: C.name, status: "skipped", reason: "no local match" };
2460
+ return { name: P.name, status: "skipped", reason: "no local match" };
2359
2461
  try {
2360
- let R;
2462
+ let _;
2361
2463
  const k = M.path;
2362
- if (P.existsSync(N.join(k, "dist", "index.html")))
2363
- R = N.join(k, "dist", "index.html");
2464
+ if (C.existsSync(R.join(k, "dist", "index.html")))
2465
+ _ = R.join(k, "dist", "index.html");
2364
2466
  else {
2365
- const z = P.readdirSync(k).filter(
2366
- (T) => T.endsWith(".html") && !T.startsWith(".") && P.statSync(N.join(k, T)).isFile()
2467
+ const W = C.readdirSync(k).filter(
2468
+ (N) => N.endsWith(".html") && !N.startsWith(".") && C.statSync(R.join(k, N)).isFile()
2367
2469
  );
2368
- if (z.length === 1)
2369
- R = N.join(k, z[0]);
2370
- else if (z.includes("index.html"))
2371
- R = N.join(k, "index.html");
2470
+ if (W.length === 1)
2471
+ _ = R.join(k, W[0]);
2472
+ else if (W.includes("index.html"))
2473
+ _ = R.join(k, "index.html");
2372
2474
  else
2373
2475
  throw new Error("No HTML file found");
2374
2476
  }
2375
- const L = P.readFileSync(R, "utf-8"), A = M.name || C.name, _ = await i("upload_component", {
2376
- name: A,
2477
+ const L = C.readFileSync(_, "utf-8"), D = M.name || P.name, T = await i("upload_component", {
2478
+ name: D,
2377
2479
  componentId: j,
2378
- organization: h,
2480
+ organization: m,
2379
2481
  htmlContent: L
2380
2482
  });
2381
- if (!_.success)
2382
- throw new Error(_.error || "Upload failed");
2383
- return { name: A, status: "ok" };
2384
- } catch (R) {
2385
- return { name: C.name, status: "failed", error: R.message };
2483
+ if (!T.success)
2484
+ throw new Error(T.error || "Upload failed");
2485
+ return { name: D, status: "ok" };
2486
+ } catch (_) {
2487
+ return { name: P.name, status: "failed", error: _.message };
2386
2488
  }
2387
2489
  }));
2388
- let E = 0, I = 0, $ = 0;
2389
- for (const C of p)
2390
- C.status === "ok" ? (console.log(` \x1B[32mβœ”\x1B[0m ${C.name}`), E++) : C.status === "skipped" ? (console.log(` \x1B[33m⊘\x1B[0m ${C.name} (${C.reason})`), I++) : (console.log(` \x1B[31mβœ–\x1B[0m ${C.name} - ${C.error}`), $++);
2490
+ let E = 0, O = 0, b = 0;
2491
+ for (const P of u)
2492
+ P.status === "ok" ? (console.log(` \x1B[32mβœ”\x1B[0m ${P.name}`), E++) : P.status === "skipped" ? (console.log(` \x1B[33m⊘\x1B[0m ${P.name} (${P.reason})`), O++) : (console.log(` \x1B[31mβœ–\x1B[0m ${P.name} - ${P.error}`), b++);
2391
2493
  console.log(`
2392
- Done! Pushed ${E}${I ? `, skipped ${I}` : ""}${$ ? `, ${$} failed` : ""}.
2494
+ Done! Pushed ${E}${O ? `, skipped ${O}` : ""}${b ? `, ${b} failed` : ""}.
2393
2495
  `);
2394
2496
  }
2395
2497
  process.exit(0);
@@ -2402,11 +2504,11 @@ v.program.command("create").description("Create a new Myop HTML component and st
2402
2504
  message: "Component name:",
2403
2505
  default: n
2404
2506
  });
2405
- } catch (h) {
2406
- throw h.name === "ExitPromptError" && (console.log(`
2507
+ } catch (m) {
2508
+ throw m.name === "ExitPromptError" && (console.log(`
2407
2509
 
2408
2510
  πŸ‘‹ Goodbye!
2409
- `), process.exit(0)), h;
2511
+ `), process.exit(0)), m;
2410
2512
  }
2411
2513
  (t.existsSync("index.html") || t.existsSync("myop.config.json")) && (console.log(`
2412
2514
  ⚠️ index.html or myop.config.json already exists in this directory.`), console.log(" Use `myop dev` to start the dev server for an existing component.\n"), process.exit(1));
@@ -2418,7 +2520,7 @@ v.program.command("create").description("Create a new Myop HTML component and st
2418
2520
  HMR: !0
2419
2521
  };
2420
2522
  t.writeFileSync("myop.config.json", JSON.stringify(i, null, 2));
2421
- const d = `<!DOCTYPE html>
2523
+ const r = `<!DOCTYPE html>
2422
2524
  <html lang="en">
2423
2525
  <head>
2424
2526
  <meta charset="UTF-8">
@@ -2540,24 +2642,24 @@ v.program.command("create").description("Create a new Myop HTML component and st
2540
2642
  <\/script>
2541
2643
  </body>
2542
2644
  </html>`;
2543
- t.writeFileSync("index.html", d);
2544
- const g = await Ge(process.cwd());
2645
+ t.writeFileSync("index.html", r);
2646
+ const p = await Ke(process.cwd());
2545
2647
  console.log(`
2546
- βœ… Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), g.success && console.log(" AI agent skills installed"), console.log(""), await be();
2648
+ βœ… Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), p.success && console.log(" AI agent skills installed"), console.log(""), await Ce();
2547
2649
  });
2548
- v.program.command("dev").description("Start development server with file watching").action(be);
2549
- const gt = async () => {
2550
- const o = process.cwd(), t = V("Installing AI agent skills...").start(), e = await Ge(o);
2650
+ v.program.command("dev").description("Start development server with file watching").action(Ce);
2651
+ const yt = async () => {
2652
+ const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Ke(o);
2551
2653
  e.success ? (t.succeed("AI agent skills installed"), e.detected.length > 0 && console.log(` Detected: ${e.detected.join(", ")}`), console.log(` Skills: ${e.skillNames.join(", ")}`)) : t.fail("Failed to install skills"), process.exit(e.success ? 0 : 1);
2552
2654
  };
2553
- v.program.command("skill").description("Install or update AI agent skills in the current directory").action(gt);
2554
- v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(gt);
2655
+ v.program.command("skill").description("Install or update AI agent skills in the current directory").action(yt);
2656
+ v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(yt);
2555
2657
  v.program.command("mcp").description("Configure Myop MCP server for your AI coding assistant").action(async () => {
2556
- const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = Ce() + "/mcp", i = [
2658
+ const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = Me() + "/mcp", i = [
2557
2659
  {
2558
2660
  name: "Claude Code",
2559
2661
  value: "claude",
2560
- configPath: N.join(n, ".claude.json"),
2662
+ configPath: R.join(n, ".claude.json"),
2561
2663
  getEntry: () => ({ type: "http", url: s }),
2562
2664
  nextSteps: [
2563
2665
  "Restart Claude Code to pick up the new MCP config.",
@@ -2569,7 +2671,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2569
2671
  {
2570
2672
  name: "Cursor",
2571
2673
  value: "cursor",
2572
- configPath: N.join(n, ".cursor", "mcp.json"),
2674
+ configPath: R.join(n, ".cursor", "mcp.json"),
2573
2675
  getEntry: () => ({ url: s }),
2574
2676
  nextSteps: [
2575
2677
  'Go to Cursor Settings > Tools & MCP to verify "myop" appears.',
@@ -2582,7 +2684,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2582
2684
  {
2583
2685
  name: "Windsurf",
2584
2686
  value: "windsurf",
2585
- configPath: N.join(n, ".codeium", "windsurf", "mcp_config.json"),
2687
+ configPath: R.join(n, ".codeium", "windsurf", "mcp_config.json"),
2586
2688
  getEntry: () => ({ url: s }),
2587
2689
  nextSteps: [
2588
2690
  "Open Cascade and click the hammer icon (top-right) to see MCP servers.",
@@ -2594,7 +2696,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2594
2696
  {
2595
2697
  name: "VS Code (GitHub Copilot)",
2596
2698
  value: "vscode",
2597
- configPath: process.platform === "darwin" ? N.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? N.join(process.env.APPDATA || N.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : N.join(n, ".config", "Code", "User", "mcp.json"),
2699
+ configPath: process.platform === "darwin" ? R.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? R.join(process.env.APPDATA || R.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : R.join(n, ".config", "Code", "User", "mcp.json"),
2598
2700
  getEntry: () => ({ type: "http", url: s }),
2599
2701
  nextSteps: [
2600
2702
  "Requires VS Code 1.99+ and GitHub Copilot extension.",
@@ -2609,33 +2711,33 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2609
2711
  console.log(`
2610
2712
  Configure Myop MCP server for your AI coding assistant.
2611
2713
  `);
2612
- let d;
2714
+ let r;
2613
2715
  try {
2614
- d = await o({
2716
+ r = await o({
2615
2717
  message: "Select your AI coding assistant:",
2616
- choices: i.map((c) => ({ name: c.name, value: c.value }))
2718
+ choices: i.map((d) => ({ name: d.name, value: d.value }))
2617
2719
  });
2618
- } catch (c) {
2619
- throw c.name === "ExitPromptError" && (console.log(`
2720
+ } catch (d) {
2721
+ throw d.name === "ExitPromptError" && (console.log(`
2620
2722
 
2621
2723
  πŸ‘‹ Goodbye!
2622
- `), process.exit(0)), c;
2724
+ `), process.exit(0)), d;
2623
2725
  }
2624
- const g = i.find((c) => c.value === d);
2625
- let h = {};
2726
+ const p = i.find((d) => d.value === r);
2727
+ let m = {};
2626
2728
  try {
2627
- const c = P.readFileSync(g.configPath, "utf-8");
2628
- h = JSON.parse(c);
2729
+ const d = C.readFileSync(p.configPath, "utf-8");
2730
+ m = JSON.parse(d);
2629
2731
  } catch {
2630
2732
  }
2631
- h.mcpServers || (h.mcpServers = {});
2632
- const l = h.mcpServers.myop;
2733
+ m.mcpServers || (m.mcpServers = {});
2734
+ const l = m.mcpServers.myop;
2633
2735
  if (l && l.url === s) {
2634
2736
  console.log(`
2635
- Myop MCP is already configured for ${g.name}.`), console.log(` Config: ${g.configPath}`), console.log(`
2737
+ Myop MCP is already configured for ${p.name}.`), console.log(` Config: ${p.configPath}`), console.log(`
2636
2738
  \x1B[1mNext steps:\x1B[0m`);
2637
- for (const c of g.nextSteps)
2638
- console.log(` ${c}`);
2739
+ for (const d of p.nextSteps)
2740
+ console.log(` ${d}`);
2639
2741
  console.log(""), process.exit(0);
2640
2742
  }
2641
2743
  if (l) {
@@ -2643,18 +2745,18 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2643
2745
  Myop MCP is already configured (URL: ${l.url}).`);
2644
2746
  try {
2645
2747
  await t({ message: "Update to latest URL?", default: !0 }) || process.exit(0);
2646
- } catch (c) {
2647
- throw c.name === "ExitPromptError" && process.exit(0), c;
2748
+ } catch (d) {
2749
+ throw d.name === "ExitPromptError" && process.exit(0), d;
2648
2750
  }
2649
2751
  }
2650
- h.mcpServers.myop = g.getEntry(), P.mkdirSync(N.dirname(g.configPath), { recursive: !0 }), P.writeFileSync(g.configPath, JSON.stringify(h, null, 2)), console.log(`
2651
- \x1B[32mβœ”\x1B[0m Myop MCP configured for ${g.name}`), console.log(` Config: ${g.configPath}`), console.log(` Server: ${s}`), console.log(`
2752
+ m.mcpServers.myop = p.getEntry(), C.mkdirSync(R.dirname(p.configPath), { recursive: !0 }), C.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
2753
+ \x1B[32mβœ”\x1B[0m Myop MCP configured for ${p.name}`), console.log(` Config: ${p.configPath}`), console.log(` Server: ${s}`), console.log(`
2652
2754
  \x1B[1mNext steps:\x1B[0m`);
2653
- for (const c of g.nextSteps)
2654
- console.log(` ${c}`);
2755
+ for (const d of p.nextSteps)
2756
+ console.log(` ${d}`);
2655
2757
  console.log(""), process.exit(0);
2656
2758
  });
2657
- const go = () => {
2759
+ const xo = () => {
2658
2760
  try {
2659
2761
  Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2660
2762
  } catch {
@@ -2687,12 +2789,12 @@ const go = () => {
2687
2789
  return null;
2688
2790
  }
2689
2791
  }, ne = async (o = !1, t = !1) => {
2690
- var c, y, S;
2691
- const e = $e(), n = !!(e != null && e.email), s = ((c = v.myopConfig) == null ? void 0 : c.name) || ((y = v.myopConfig) == null ? void 0 : y.componentName), i = (S = v.myopConfig) == null ? void 0 : S.componentId, d = go();
2792
+ var d, y, S;
2793
+ const e = Pe(), n = !!(e != null && e.email), s = ((d = v.myopConfig) == null ? void 0 : d.name) || ((y = v.myopConfig) == null ? void 0 : y.componentName), i = (S = v.myopConfig) == null ? void 0 : S.componentId, r = xo();
2692
2794
  console.log(`
2693
2795
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Welcome to Myop CLI - Remote UI Made Easy β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2694
- `), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`), d != null && d.gitNotInstalled ? (console.log(" Changes: Git not installed"), console.log(" Install: https://git-scm.com/downloads"), console.log(" Mac: brew install git | Windows: https://gitforwindows.org")) : d != null && d.notARepo ? console.log(" Changes: Not a git repository") : d && (d.insertions > 0 || d.deletions > 0) ? console.log(` Changes: ${d.files} file${d.files !== 1 ? "s" : ""} | \x1B[32m+${d.insertions}\x1B[0m \x1B[31m-${d.deletions}\x1B[0m`) : d && console.log(" Changes: No uncommitted changes"), console.log("");
2695
- const h = [
2796
+ `), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`), r != null && r.gitNotInstalled ? (console.log(" Changes: Git not installed"), console.log(" Install: https://git-scm.com/downloads"), console.log(" Mac: brew install git | Windows: https://gitforwindows.org")) : r != null && r.notARepo ? console.log(" Changes: Not a git repository") : r && (r.insertions > 0 || r.deletions > 0) ? console.log(` Changes: ${r.files} file${r.files !== 1 ? "s" : ""} | \x1B[32m+${r.insertions}\x1B[0m \x1B[31m-${r.deletions}\x1B[0m`) : r && console.log(" Changes: No uncommitted changes"), console.log("");
2797
+ const m = [
2696
2798
  {
2697
2799
  emoji: "πŸš€",
2698
2800
  label: "Initialize new component",
@@ -2720,8 +2822,8 @@ const go = () => {
2720
2822
  value: x.value,
2721
2823
  disabled: x.disabled
2722
2824
  }));
2723
- h.push(
2724
- new De(),
2825
+ m.push(
2826
+ new Le(),
2725
2827
  {
2726
2828
  name: t && n ? `πŸ”“ Logout (${e.email})
2727
2829
  Clears stored credentials from this machine` : t && !n ? `πŸ” Login to Myop
@@ -2732,7 +2834,7 @@ const go = () => {
2732
2834
  name: t ? "πŸ“– Hide help" : "πŸ“– Show help",
2733
2835
  value: "help"
2734
2836
  },
2735
- new De(),
2837
+ new Le(),
2736
2838
  {
2737
2839
  name: "πŸ‘‹ Exit",
2738
2840
  value: "exit"
@@ -2740,9 +2842,9 @@ const go = () => {
2740
2842
  );
2741
2843
  let l;
2742
2844
  try {
2743
- l = await ot({
2845
+ l = await st({
2744
2846
  message: "What would you like to do?",
2745
- choices: h
2847
+ choices: m
2746
2848
  });
2747
2849
  } catch (x) {
2748
2850
  throw x.name === "ExitPromptError" && (console.log(`
@@ -2752,7 +2854,7 @@ const go = () => {
2752
2854
  }
2753
2855
  switch (l) {
2754
2856
  case "init":
2755
- await wo();
2857
+ await Po();
2756
2858
  break;
2757
2859
  case "sync":
2758
2860
  console.log(`
@@ -2766,18 +2868,18 @@ Pushing component...
2766
2868
  await ne(!0, t);
2767
2869
  break;
2768
2870
  case "dev":
2769
- await be();
2871
+ await Ce();
2770
2872
  break;
2771
2873
  case "login":
2772
2874
  try {
2773
- await pe(), console.log(`
2875
+ await me(), console.log(`
2774
2876
  `), await ne(o, t);
2775
- } catch (u) {
2776
- console.error("Login failed:", u.message), await ne(o, t);
2877
+ } catch (g) {
2878
+ console.error("Login failed:", g.message), await ne(o, t);
2777
2879
  }
2778
2880
  break;
2779
2881
  case "logout":
2780
- await mt(), console.log(`
2882
+ await gt(), console.log(`
2781
2883
  `), await ne(o, t);
2782
2884
  break;
2783
2885
  case "help":
@@ -2786,48 +2888,48 @@ Pushing component...
2786
2888
  case "exit":
2787
2889
  process.exit(0);
2788
2890
  }
2789
- }, xe = ".myop-monorepo.json", fo = () => {
2891
+ }, be = ".myop-monorepo.json", $o = () => {
2790
2892
  try {
2791
- const o = P.readFileSync(xe, "utf-8");
2893
+ const o = C.readFileSync(be, "utf-8");
2792
2894
  return JSON.parse(o);
2793
2895
  } catch {
2794
2896
  return null;
2795
2897
  }
2796
- }, ho = (o) => {
2898
+ }, bo = (o) => {
2797
2899
  try {
2798
2900
  const t = {
2799
2901
  selectedComponents: o,
2800
2902
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2801
2903
  };
2802
- P.writeFileSync(xe, JSON.stringify(t, null, 2));
2904
+ C.writeFileSync(be, JSON.stringify(t, null, 2));
2803
2905
  } catch {
2804
2906
  }
2805
- }, yo = async () => {
2806
- const o = $e(), t = !!(o != null && o.email);
2907
+ }, Co = async () => {
2908
+ const o = Pe(), t = !!(o != null && o.email);
2807
2909
  console.log(`
2808
2910
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Myop CLI - Monorepo Mode β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2809
2911
  `);
2810
- const e = V("Scanning for components...").start(), n = Ye(".");
2912
+ const e = z("Scanning for components...").start(), n = Qe(".");
2811
2913
  e.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
2812
2914
  `), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
2813
- const s = fo(), i = (s == null ? void 0 : s.selectedComponents) || [], d = i.length > 0;
2915
+ const s = $o(), i = (s == null ? void 0 : s.selectedComponents) || [], r = i.length > 0;
2814
2916
  console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
2815
2917
  `), n.forEach((y, S) => {
2816
- const x = y.componentId ? "βœ…" : "βšͺ", u = y.componentId ? y.componentId.substring(0, 8) + "..." : "(not pushed)";
2817
- console.log(` ${x} ${y.name}`), console.log(` Path: ${y.path}`), console.log(` ID: ${u}`), console.log("");
2818
- }), console.log(` User: ${t ? o.email : "Not logged in"}`), d && console.log(` πŸ“‹ Using saved selection from ${xe}`), console.log("");
2819
- const g = v.program.getOptionValue("ci");
2820
- let h;
2821
- if (g)
2822
- d ? (h = i, console.log(` πŸ€– CI mode: using saved selection (${h.length} components)`)) : (h = n.map((y) => y.path), console.log(` πŸ€– CI mode: no saved selection, using all ${h.length} components`));
2918
+ const x = y.componentId ? "βœ…" : "βšͺ", g = y.componentId ? y.componentId.substring(0, 8) + "..." : "(not pushed)";
2919
+ console.log(` ${x} ${y.name}`), console.log(` Path: ${y.path}`), console.log(` ID: ${g}`), console.log("");
2920
+ }), console.log(` User: ${t ? o.email : "Not logged in"}`), r && console.log(` πŸ“‹ Using saved selection from ${be}`), console.log("");
2921
+ const p = v.program.getOptionValue("ci");
2922
+ let m;
2923
+ if (p)
2924
+ r ? (m = i, console.log(` πŸ€– CI mode: using saved selection (${m.length} components)`)) : (m = n.map((y) => y.path), console.log(` πŸ€– CI mode: no saved selection, using all ${m.length} components`));
2823
2925
  else {
2824
2926
  const { checkbox: y } = await import("@inquirer/prompts"), S = n.map((x) => ({
2825
2927
  name: `${x.name} (${x.path})`,
2826
2928
  value: x.path,
2827
- checked: d ? i.includes(x.path) : !0
2929
+ checked: r ? i.includes(x.path) : !0
2828
2930
  }));
2829
2931
  try {
2830
- h = await y({
2932
+ m = await y({
2831
2933
  message: "Select components to start in dev mode:",
2832
2934
  choices: S
2833
2935
  });
@@ -2838,23 +2940,23 @@ Pushing component...
2838
2940
  `), process.exit(0)), x;
2839
2941
  }
2840
2942
  }
2841
- h.length === 0 && (console.log(`
2943
+ m.length === 0 && (console.log(`
2842
2944
  ⚠️ No components selected.
2843
- `), process.exit(0)), g || (ho(h), console.log(`
2844
- πŸ’Ύ Selection saved to ${xe}`));
2845
- const l = n.filter((y) => h.includes(y.path));
2945
+ `), process.exit(0)), p || (bo(m), console.log(`
2946
+ πŸ’Ύ Selection saved to ${be}`));
2947
+ const l = n.filter((y) => m.includes(y.path));
2846
2948
  console.log(`πŸš€ Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
2847
2949
  `);
2848
- const { monorepoDevCommand: c } = await Promise.resolve().then(() => Bt);
2849
- await c(l);
2850
- }, wo = async () => {
2950
+ const { monorepoDevCommand: d } = await Promise.resolve().then(() => Wt);
2951
+ await d(l);
2952
+ }, Po = async () => {
2851
2953
  const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
2852
- let i, d;
2954
+ let i, r;
2853
2955
  try {
2854
2956
  i = await o({
2855
2957
  message: "Component name:",
2856
2958
  default: s
2857
- }), d = await t({
2959
+ }), r = await t({
2858
2960
  message: "Component type:",
2859
2961
  choices: [
2860
2962
  { name: "πŸ“„ HTML", value: "html", description: "Plain HTML/JS/CSS component" },
@@ -2869,15 +2971,15 @@ Pushing component...
2869
2971
  πŸ‘‹ Goodbye!
2870
2972
  `), process.exit(0)), l;
2871
2973
  }
2872
- const g = {
2974
+ const p = {
2873
2975
  name: i,
2874
- type: d,
2976
+ type: r,
2875
2977
  author: "@myop-cli",
2876
2978
  HMR: !0
2877
- }, h = v.program.getOptionValue("config") || "./myop.config.json";
2979
+ }, m = v.program.getOptionValue("config") || "./myop.config.json";
2878
2980
  try {
2879
- e.writeFileSync(h, JSON.stringify(g, null, 2)), console.log(`
2880
- βœ… Created ${h}`);
2981
+ e.writeFileSync(m, JSON.stringify(p, null, 2)), console.log(`
2982
+ βœ… Created ${m}`);
2881
2983
  const l = {
2882
2984
  name: i.toLowerCase().replace(/\s+/g, "-"),
2883
2985
  version: "1.0.0",
@@ -3022,11 +3124,11 @@ export function setupMyopInterface() {
3022
3124
  };
3023
3125
  }
3024
3126
  `), console.log("βœ… Created src/modules/myop.js");
3025
- const p = `/* ${i} - Styles Entry Point */
3127
+ const u = `/* ${i} - Styles Entry Point */
3026
3128
  /* Add your CSS imports here - they will be auto-bundled */
3027
3129
  @import './main.css';
3028
3130
  `;
3029
- e.writeFileSync("src/styles/index.css", p), console.log("βœ… Created src/styles/index.css");
3131
+ e.writeFileSync("src/styles/index.css", u), console.log("βœ… Created src/styles/index.css");
3030
3132
  const E = `/* ${i} - Main Styles */
3031
3133
 
3032
3134
  * {
@@ -3062,11 +3164,11 @@ dist/
3062
3164
  .temp-styles.css
3063
3165
  .DS_Store
3064
3166
  `), console.log("βœ… Created .gitignore");
3065
- const $ = await Ge(process.cwd());
3066
- $.success && console.log("βœ… Installed AI agent skills");
3067
- const C = await import("./index-DuEoKctW.js").then((M) => M.i), j = process.cwd();
3167
+ const b = await Ke(process.cwd());
3168
+ b.success && console.log("βœ… Installed AI agent skills");
3169
+ const P = await import("./index-DuEoKctW.js").then((M) => M.i), j = process.cwd();
3068
3170
  try {
3069
- await C.init({ fs: e, dir: j });
3171
+ await P.init({ fs: e, dir: j });
3070
3172
  const M = [
3071
3173
  "myop.config.json",
3072
3174
  "package.json",
@@ -3079,13 +3181,13 @@ dist/
3079
3181
  "src/styles/index.css",
3080
3182
  "src/styles/main.css"
3081
3183
  ];
3082
- if ($.success) {
3083
- const R = (k, L) => {
3184
+ if (b.success) {
3185
+ const _ = (k, L) => {
3084
3186
  try {
3085
- const A = e.readdirSync(k, { withFileTypes: !0 });
3086
- for (const _ of A) {
3087
- const z = n.join(k, _.name), T = n.join(L, _.name);
3088
- _.isDirectory() ? R(z, T) : M.push(T);
3187
+ const D = e.readdirSync(k, { withFileTypes: !0 });
3188
+ for (const T of D) {
3189
+ const W = n.join(k, T.name), N = n.join(L, T.name);
3190
+ T.isDirectory() ? _(W, N) : M.push(N);
3089
3191
  }
3090
3192
  } catch {
3091
3193
  }
@@ -3094,15 +3196,15 @@ dist/
3094
3196
  const k = e.readdirSync(".", { withFileTypes: !0 });
3095
3197
  for (const L of k)
3096
3198
  if (L.isDirectory() && L.name.startsWith(".")) {
3097
- const A = n.join(L.name, "skills");
3098
- e.existsSync(A) && R(A, A);
3199
+ const D = n.join(L.name, "skills");
3200
+ e.existsSync(D) && _(D, D);
3099
3201
  }
3100
3202
  } catch {
3101
3203
  }
3102
3204
  }
3103
- for (const R of M)
3104
- await C.add({ fs: e, dir: j, filepath: R });
3105
- await C.commit({
3205
+ for (const _ of M)
3206
+ await P.add({ fs: e, dir: j, filepath: _ });
3207
+ await P.commit({
3106
3208
  fs: e,
3107
3209
  dir: j,
3108
3210
  message: "init",
@@ -3113,28 +3215,28 @@ dist/
3113
3215
  }
3114
3216
  console.log(`
3115
3217
  πŸ“¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
3116
- `), v.myopConfig = g, await ne(!0);
3218
+ `), v.myopConfig = p, await ne(!0);
3117
3219
  } catch (l) {
3118
3220
  console.error(`Failed to initialize component: ${l.message}`), process.exit(1);
3119
3221
  }
3120
3222
  };
3121
3223
  v.program.command("default", { isDefault: !0 }).action(async () => {
3122
- if (v.program.getOptionValue("help") && (console.log(Et), process.exit()), v.program.getOptionValue("monorepo")) {
3123
- await yo();
3224
+ if (v.program.getOptionValue("help") && (console.log(kt), process.exit()), v.program.getOptionValue("monorepo")) {
3225
+ await Co();
3124
3226
  return;
3125
3227
  }
3126
3228
  if (v.program.getOptionValue("ci")) {
3127
- const g = await import("fs"), h = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), c = $e();
3229
+ const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), d = Pe();
3128
3230
  let y = { found: !1 };
3129
3231
  try {
3130
- if (g.existsSync(h)) {
3131
- const x = g.readFileSync(h, "utf-8"), u = JSON.parse(x);
3232
+ if (p.existsSync(m)) {
3233
+ const x = p.readFileSync(m, "utf-8"), g = JSON.parse(x);
3132
3234
  y = {
3133
3235
  found: !0,
3134
- path: h,
3135
- name: u.name || u.componentName || null,
3136
- componentId: u.componentId || null,
3137
- organization: u.organization || null
3236
+ path: m,
3237
+ name: g.name || g.componentName || null,
3238
+ componentId: g.componentId || null,
3239
+ organization: g.organization || null
3138
3240
  };
3139
3241
  }
3140
3242
  } catch (x) {
@@ -3144,20 +3246,21 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
3144
3246
  version: l,
3145
3247
  config: y,
3146
3248
  auth: {
3147
- loggedIn: !!(c != null && c.email),
3148
- email: (c == null ? void 0 : c.email) || null
3249
+ loggedIn: !!(d != null && d.email),
3250
+ email: (d == null ? void 0 : d.email) || null
3149
3251
  }
3150
3252
  };
3151
3253
  console.log(JSON.stringify(S, null, 2)), process.exit(0);
3152
3254
  }
3153
- let n = V({
3255
+ let n = z({
3154
3256
  text: "Loading Myop CLI...",
3155
3257
  color: "green"
3156
3258
  }).start();
3157
- const s = Me();
3158
- await co(500), n.stop();
3259
+ const s = Ee();
3260
+ await yo(500), n.stop();
3159
3261
  const i = v.program.version();
3160
- await so(i) || await ne(s.configFound);
3262
+ await mo(i) || await ne(s.configFound);
3161
3263
  });
3264
+ Kt();
3162
3265
  v.program.parse(process.argv);
3163
3266
  v.program.opts();