@myop/cli 0.1.21 → 0.1.23

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 +1198 -899
  2. package/package.json +1 -1
package/dist/myop-cli.js CHANGED
@@ -1,16 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import U from "ora";
3
- import { select as Ee, Separator as ae } from "@inquirer/prompts";
4
- import { Command as Ke, Option as pe } from "commander";
5
- import { execSync as ce, spawn as Xe } from "child_process";
6
- import te from "path";
7
- import B from "fs";
8
- import ve from "crypto";
9
- import Qe from "http";
10
- import { URL as ke, URLSearchParams as Re } from "url";
11
- import Ze from "open";
12
- import qe from "os";
13
- const et = `
2
+ var rt = Object.defineProperty;
3
+ var at = (o, e, t) => e in o ? rt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
4
+ var ue = (o, e, t) => at(o, typeof e != "symbol" ? e + "" : e, t);
5
+ import W from "ora";
6
+ import { select as Je, Separator as Re } from "@inquirer/prompts";
7
+ import { Command as lt, Option as le } from "commander";
8
+ import { execSync as fe, spawn as ct } from "child_process";
9
+ import ee from "path";
10
+ import H from "fs";
11
+ import Ie from "crypto";
12
+ import dt from "http";
13
+ import { URL as ze, URLSearchParams as We } from "url";
14
+ import pt from "open";
15
+ import mt from "os";
16
+ const ut = `
14
17
  Usage: myop [OPTIONS] COMMAND [ARGS]...
15
18
 
16
19
  A powerful command-line interface for managing your Myop projects.
@@ -44,7 +47,7 @@ Examples:
44
47
 
45
48
 
46
49
 
47
- `, f = {
50
+ `, h = {
48
51
  program: null,
49
52
  executionPath: "",
50
53
  options: {
@@ -52,89 +55,89 @@ Examples:
52
55
  verbose: !1
53
56
  },
54
57
  myopConfig: null
55
- }, Ne = {
58
+ }, Ve = {
56
59
  name: "📥 Install Myop generated dependencies",
57
60
  value: "myopInstall",
58
61
  description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
59
62
  action: async () => {
60
63
  console.info("installing... ");
61
- for (const e of f.myopConfig.flows) {
62
- const t = te.join(f.executionPath, "/node_modules/@myop/flow-types/");
63
- console.info(`Generate flow at ${t}`), console.info(`Generated flow at ${t}`);
64
+ for (const o of h.myopConfig.flows) {
65
+ const e = ee.join(h.executionPath, "/node_modules/@myop/flow-types/");
66
+ console.info(`Generate flow at ${e}`), console.info(`Generated flow at ${e}`);
64
67
  }
65
68
  process.exit();
66
69
  }
67
- }, tt = (e) => {
68
- const t = te.join(f.executionPath, e);
69
- console.info(`reading config file from: ${t}`);
70
- const n = B.readFileSync(t, "utf8"), r = JSON.parse(n);
71
- return console.info("config file loaded, ", r), r;
72
- }, Se = (e, t) => {
73
- const n = te.join(f.executionPath, e);
74
- console.info(`writing config file to: ${n}`);
70
+ }, gt = (o) => {
71
+ const e = ee.join(h.executionPath, o);
72
+ console.info(`reading config file from: ${e}`);
73
+ const t = H.readFileSync(e, "utf8"), n = JSON.parse(t);
74
+ return console.info("config file loaded, ", n), n;
75
+ }, Oe = (o, e) => {
76
+ const t = ee.join(h.executionPath, o);
77
+ console.info(`writing config file to: ${t}`);
75
78
  try {
76
- const r = JSON.stringify(t, null, 2);
77
- B.writeFileSync(n, r), console.info(`config file updated ${r}`);
78
- } catch (r) {
79
- throw console.info(`error ${r} while writing to ${n}, JSON: ${t}`), console.log(`
80
- ⚠️ Failed write config file to ${n}, for more info use verbose flag`), r;
79
+ const n = JSON.stringify(e, null, 2);
80
+ H.writeFileSync(t, n), console.info(`config file updated ${n}`);
81
+ } catch (n) {
82
+ throw console.info(`error ${n} while writing to ${t}, JSON: ${e}`), console.log(`
83
+ ⚠️ Failed write config file to ${t}, for more info use verbose flag`), n;
81
84
  }
82
- }, Fe = {
85
+ }, Ge = {
83
86
  name: "🌟 Add flow definition to your project",
84
87
  value: "addFlow",
85
88
  description: "Adds flow to yours myop.config.json",
86
- _action: (e) => {
87
- f.myopConfig.flows.includes(e) || f.myopConfig.flows.push(e), Se(f.options.configPath, f.myopConfig);
89
+ _action: (o) => {
90
+ h.myopConfig.flows.includes(o) || h.myopConfig.flows.push(o), Oe(h.options.configPath, h.myopConfig);
88
91
  },
89
92
  action: async () => {
90
93
  }
91
- }, Ae = {
94
+ }, Ye = {
92
95
  name: "🚫 Remove flow definition from your project",
93
96
  value: "removeFlow",
94
97
  description: "Removes flow to yours myop.config.json",
95
- _action: (e) => {
96
- f.myopConfig.flows = f.myopConfig.flows.filter((t) => t !== e), Se(f.options.configPath, f.myopConfig);
98
+ _action: (o) => {
99
+ h.myopConfig.flows = h.myopConfig.flows.filter((e) => e !== o), Oe(h.options.configPath, h.myopConfig);
97
100
  },
98
101
  action: () => {
99
102
  }
100
- }, ot = {
103
+ }, ft = {
101
104
  name: "👋 Quit",
102
105
  value: "quit",
103
106
  description: "Quit and continue coding.",
104
107
  action: () => {
105
108
  process.exit();
106
109
  }
107
- }, nt = {
110
+ }, ht = {
108
111
  name: "🟢 Create new component",
109
112
  value: "-",
110
113
  disabled: "(not available yet)"
111
- }, st = {
114
+ }, yt = {
112
115
  name: "🔵 Create new experience",
113
116
  value: "-",
114
117
  disabled: "(not available yet)"
115
- }, rt = {
118
+ }, wt = {
116
119
  name: "🟡 Create new skin",
117
120
  value: "-",
118
121
  disabled: "(not available yet)"
119
- }, it = {
122
+ }, vt = {
120
123
  name: "🔴 Create new flow",
121
124
  value: "-",
122
125
  disabled: "(not available yet)"
123
- }, at = {
126
+ }, bt = {
124
127
  name: "🆕 Define new custom Myop message",
125
128
  value: "generateMyopMessage",
126
129
  description: "️Help you creates the right structure for a new Myop message, including types and handlers.",
127
130
  disabled: "(not available yet)"
128
- }, ct = [at, nt, st, rt, it];
129
- function lt(e, t, n, r) {
131
+ }, St = [bt, ht, yt, wt, vt];
132
+ function xt(o, e, t, n) {
130
133
  return `<!DOCTYPE html>
131
134
  <html lang="en">
132
135
  <head>
133
136
  <meta charset="UTF-8">
134
137
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
135
- <title>Myop DevTools - localhost:${e}</title>
138
+ <title>Myop DevTools - localhost:${o}</title>
136
139
  <style>
137
- ${n}
140
+ ${t}
138
141
  </style>
139
142
  </head>
140
143
  <body>
@@ -142,8 +145,8 @@ ${n}
142
145
  <div class="toolbar">
143
146
  <div class="toolbar-title">Myop DevTools</div>
144
147
  <div class="toolbar-info">
145
- <span><div class="status-dot"></div> localhost:${e}</span>
146
- <span>Management: ${t}</span>
148
+ <span><div class="status-dot"></div> localhost:${o}</span>
149
+ <span>Management: ${e}</span>
147
150
  </div>
148
151
  </div>
149
152
 
@@ -209,127 +212,144 @@ ${n}
209
212
 
210
213
  <script>
211
214
  // Inject PORT as a global variable for the app to use
212
- window.PORT = ${e};
215
+ window.PORT = ${o};
213
216
 
214
- ${r}
217
+ ${n}
215
218
  <\/script>
216
219
  </body>
217
220
  </html>`;
218
221
  }
219
- function dt(e) {
220
- return e.includes("esbuild") && e.includes("another platform");
222
+ function $t(o) {
223
+ return o.includes("esbuild") && o.includes("another platform");
221
224
  }
222
- function pt(e) {
223
- return e.includes("ERR_MODULE_NOT_FOUND") && e.includes("esbuild");
225
+ function Ct(o) {
226
+ return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
224
227
  }
225
- function mt() {
228
+ function Mt() {
226
229
  console.error(`
227
230
  ❌ esbuild platform mismatch detected!`), console.error(" Your node_modules contains esbuild binaries for a different OS."), console.error(`
228
231
  This usually happens when node_modules is copied between different`), console.error(` operating systems (e.g., Windows → Mac, or Mac → Linux).
229
232
  `);
230
233
  }
231
- function ut(e) {
232
- return new Promise((t) => {
234
+ function Pt(o) {
235
+ return new Promise((e) => {
233
236
  console.log(`🔧 Attempting to fix: removing node_modules and reinstalling...
234
237
  `);
235
- const r = process.platform === "win32" ? "rmdir /s /q node_modules" : "rm -rf node_modules";
236
- e(r, (p) => {
237
- if (p) {
238
- console.error("❌ Failed to remove node_modules:", p.message), console.error(`
239
- Please run manually:`), console.error(` \x1B[36m${r} && npm install\x1B[0m
240
- `), t(!1);
238
+ const n = process.platform === "win32" ? "rmdir /s /q node_modules" : "rm -rf node_modules";
239
+ o(n, (i) => {
240
+ if (i) {
241
+ console.error("❌ Failed to remove node_modules:", i.message), console.error(`
242
+ Please run manually:`), console.error(` \x1B[36m${n} && npm install\x1B[0m
243
+ `), e(!1);
241
244
  return;
242
245
  }
243
246
  console.log(" ✓ Removed node_modules"), console.log(` ⏳ Running npm install...
244
- `), e("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, m, y) => {
245
- if (i) {
246
- console.error("❌ npm install failed:", i.message), y && console.error(y), t(!1);
247
+ `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (s, d, w) => {
248
+ if (s) {
249
+ console.error("❌ npm install failed:", s.message), w && console.error(w), e(!1);
247
250
  return;
248
251
  }
249
252
  console.log(` ✓ Dependencies reinstalled successfully!
250
- `), t(!0);
253
+ `), e(!0);
251
254
  });
252
255
  });
253
256
  });
254
257
  }
255
- async function De(e, t, n, r, p = {}) {
258
+ async function Ke(o, e, t, n, i = {}) {
256
259
  const {
257
- hasTriedPlatformFix: i = !1,
258
- hasTriedInstall: m = !1,
259
- onRetry: y
260
- } = p, $ = ((e == null ? void 0 : e.message) || "") + (t || "") + (n || "");
261
- return !i && dt($) ? (mt(), await ut(r) && y ? (console.log(`🔄 Retrying build...
262
- `), y(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: m }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: m }) : !m && pt($) ? (console.log("📦 Missing dependencies detected, running npm install..."), new Promise((d) => {
263
- r("npm install", (v, x, j) => {
264
- if (v) {
265
- console.error("❌ Failed to install dependencies:", v.message), j && console.error(j), d({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
260
+ hasTriedPlatformFix: s = !1,
261
+ hasTriedInstall: d = !1,
262
+ onRetry: w
263
+ } = i, M = ((o == null ? void 0 : o.message) || "") + (e || "") + (t || "");
264
+ return !s && $t(M) ? (Mt(), await Pt(n) && w ? (console.log(`🔄 Retrying build...
265
+ `), w(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && Ct(M) ? (console.log("📦 Missing dependencies detected, running npm install..."), new Promise((m) => {
266
+ n("npm install", (p, b, u) => {
267
+ if (p) {
268
+ console.error("❌ Failed to install dependencies:", p.message), u && console.error(u), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
266
269
  return;
267
270
  }
268
- console.log("✅ Dependencies installed"), y && y(), d({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
271
+ console.log("✅ Dependencies installed"), w && w(), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
269
272
  });
270
- })) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: m };
273
+ })) : { handled: !1, hasTriedPlatformFix: s, hasTriedInstall: d };
271
274
  }
272
- async function Le() {
273
- const e = await import("fs"), t = await import("path"), { exec: n } = await import("child_process"), r = await import("http"), { createHash: p } = await import("node:crypto");
274
- let i;
275
+ async function Fe() {
276
+ const o = await import("fs"), e = await import("path"), { exec: t } = await import("child_process"), n = await import("http"), { createHash: i } = await import("node:crypto");
277
+ let s;
275
278
  if (import.meta.url.startsWith("file://")) {
276
- const o = new URL(import.meta.url).pathname, a = process.platform === "win32" && o.startsWith("/") ? o.slice(1) : o;
277
- i = t.default.dirname(a);
279
+ const a = new URL(import.meta.url).pathname, l = process.platform === "win32" && a.startsWith("/") ? a.slice(1) : a;
280
+ s = e.default.dirname(l);
278
281
  } else
279
- i = t.default.dirname(import.meta.url);
280
- const m = t.default.join(i, "commands", "dev", "management-website"), y = e.default.readFileSync(t.default.join(m, "styles.css"), "utf-8"), $ = e.default.readFileSync(t.default.join(m, "app.js"), "utf-8"), d = 9292, v = 9293, x = "./dist";
281
- let j = !1, C = !1;
282
- const N = (s) => {
283
- const o = process.platform;
284
- let a;
285
- o === "darwin" ? a = `open "${s}"` : o === "win32" ? a = `start "" "${s}"` : a = `xdg-open "${s}"`, n(a, (c) => {
282
+ s = e.default.dirname(import.meta.url);
283
+ const d = e.default.join(s, "commands", "dev", "management-website"), w = o.default.readFileSync(e.default.join(d, "styles.css"), "utf-8"), M = o.default.readFileSync(e.default.join(d, "app.js"), "utf-8"), m = 9292, p = 9293;
284
+ let b = "./dist", u = !1, v = !1, x = !1, $ = null;
285
+ const _ = () => {
286
+ try {
287
+ const r = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
288
+ if (r.length === 1)
289
+ return r[0];
290
+ } catch {
291
+ }
292
+ return null;
293
+ }, D = () => {
294
+ try {
295
+ const r = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
296
+ return !!(r.scripts && r.scripts.build);
297
+ } catch {
298
+ return !1;
299
+ }
300
+ }, g = (r) => {
301
+ const a = process.platform;
302
+ let l;
303
+ a === "darwin" ? l = `open "${r}"` : a === "win32" ? l = `start "" "${r}"` : l = `xdg-open "${r}"`, t(l, (c) => {
286
304
  });
287
- }, F = /* @__PURE__ */ new Map(), _ = f.program.getOptionValue("config") || "./myop.config.json";
288
- let S, u, h = !1;
305
+ }, P = /* @__PURE__ */ new Map(), E = h.program.getOptionValue("config") || "./myop.config.json";
306
+ let C, I, L = !1;
307
+ $ = _();
308
+ const Z = D();
289
309
  try {
290
- const s = e.default.readFileSync(_, "utf-8"), o = JSON.parse(s);
291
- S = o.componentId || "DEV", u = o.componentName || o.name || null, h = o.HMR === !0, h && console.log("🔥 HMR enabled");
292
- } catch (s) {
293
- console.error("❌ Error reading myop.config.json:", s.message), process.exit(1);
310
+ const r = o.default.readFileSync(E, "utf-8"), a = JSON.parse(r);
311
+ C = a.componentId || "DEV", I = a.componentName || a.name || null, L = a.HMR === !0, $ && !Z && (x = !0, L = !0, console.log(`📄 Single HTML file mode: ${$}`)), L && console.log("🔥 HMR enabled");
312
+ } catch (r) {
313
+ $ && !Z ? (x = !0, C = "DEV", I = e.default.basename($, ".html"), L = !0, console.log(`📄 Single HTML file mode: ${$}`), console.log("🔥 HMR enabled")) : (console.error("❌ Error reading myop.config.json:", r.message), process.exit(1));
294
314
  }
295
- const b = async () => {
296
- if (S !== "DEV" && S !== "NEW")
297
- return S;
315
+ const U = async () => {
316
+ if (C !== "DEV" && C !== "NEW")
317
+ return C;
298
318
  try {
299
- const o = ((await new Promise((l, g) => {
300
- const w = {
319
+ const a = ((await new Promise((f, y) => {
320
+ const S = {
301
321
  hostname: "localhost",
302
- port: v,
322
+ port: p,
303
323
  path: "/_list",
304
324
  method: "GET",
305
325
  timeout: 1e3
306
- }, I = r.default.request(w, (R) => {
307
- let V = "";
308
- R.on("data", (G) => V += G), R.on("end", () => {
326
+ }, F = n.default.request(S, (N) => {
327
+ let J = "";
328
+ N.on("data", (Q) => J += Q), N.on("end", () => {
309
329
  try {
310
- l(JSON.parse(V));
330
+ f(JSON.parse(J));
311
331
  } catch {
312
- l({ components: [] });
332
+ f({ components: [] });
313
333
  }
314
334
  });
315
335
  });
316
- I.on("error", () => l({ components: [] })), I.on("timeout", () => {
317
- I.destroy(), l({ components: [] });
318
- }), I.end();
319
- })).components || []).map(([l]) => l).filter((l) => l === "DEV" || l === "NEW" || /^DEV\d+$/.test(l) || /^NEW\d+$/.test(l));
320
- if (o.length === 0)
336
+ F.on("error", () => f({ components: [] })), F.on("timeout", () => {
337
+ F.destroy(), f({ components: [] });
338
+ }), F.end();
339
+ })).components || []).map(([f]) => f).filter((f) => f === "DEV" || f === "NEW" || /^DEV\d+$/.test(f) || /^NEW\d+$/.test(f));
340
+ if (a.length === 0)
321
341
  return "DEV1";
322
- const a = o.map((l) => {
323
- if (l === "DEV" || l === "NEW") return 1;
324
- const g = l.match(/^DEV(\d+)$/), w = l.match(/^NEW(\d+)$/);
325
- return g ? parseInt(g[1], 10) : w ? parseInt(w[1], 10) : 0;
326
- }).filter((l) => l > 0);
327
- return `DEV${Math.max(...a, 0) + 1}`;
342
+ const l = a.map((f) => {
343
+ if (f === "DEV" || f === "NEW") return 1;
344
+ const y = f.match(/^DEV(\d+)$/), S = f.match(/^NEW(\d+)$/);
345
+ return y ? parseInt(y[1], 10) : S ? parseInt(S[1], 10) : 0;
346
+ }).filter((f) => f > 0);
347
+ return `DEV${Math.max(...l, 0) + 1}`;
328
348
  } catch {
329
349
  return "DEV1";
330
350
  }
331
- }, k = process.cwd(), A = (s) => {
332
- const o = t.default.extname(s).toLowerCase();
351
+ }, O = process.cwd(), V = (r) => {
352
+ const a = e.default.extname(r).toLowerCase();
333
353
  return {
334
354
  ".html": "text/html",
335
355
  ".js": "text/javascript",
@@ -340,44 +360,44 @@ async function Le() {
340
360
  ".gif": "image/gif",
341
361
  ".svg": "image/svg+xml",
342
362
  ".ico": "image/x-icon"
343
- }[o] || "application/octet-stream";
344
- }, M = /* @__PURE__ */ new Map(), O = [], z = 50, D = [], W = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map(), ue = (s, o, a) => {
345
- if (s.url.startsWith("/_hmr/")) {
346
- const c = s.url.split("/_hmr/")[1], l = s.headers["sec-websocket-key"], g = p("sha1").update(l + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
347
- o.write(
363
+ }[a] || "application/octet-stream";
364
+ }, R = /* @__PURE__ */ new Map(), G = [], Se = 50, K = [], te = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), et = (r, a, l) => {
365
+ if (r.url.startsWith("/_hmr/")) {
366
+ const c = r.url.split("/_hmr/")[1], f = r.headers["sec-websocket-key"], y = i("sha1").update(f + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
367
+ a.write(
348
368
  `HTTP/1.1 101 Switching Protocols\r
349
369
  Upgrade: websocket\r
350
370
  Connection: Upgrade\r
351
- Sec-WebSocket-Accept: ${g}\r
371
+ Sec-WebSocket-Accept: ${y}\r
352
372
  \r
353
373
  `
354
- ), L.has(c) || L.set(c, /* @__PURE__ */ new Set()), L.get(c).add(o), console.log(`🔌 HMR client connected: ${c}`), o.on("close", () => {
355
- const w = L.get(c);
356
- w && (w.delete(o), w.size === 0 && L.delete(c)), console.log(`🔌 HMR client disconnected: ${c}`);
357
- }), o.on("error", () => {
358
- const w = L.get(c);
359
- w && w.delete(o);
374
+ ), X.has(c) || X.set(c, /* @__PURE__ */ new Set()), X.get(c).add(a), console.log(`🔌 HMR client connected: ${c}`), a.on("close", () => {
375
+ const S = X.get(c);
376
+ S && (S.delete(a), S.size === 0 && X.delete(c)), console.log(`🔌 HMR client disconnected: ${c}`);
377
+ }), a.on("error", () => {
378
+ const S = X.get(c);
379
+ S && S.delete(a);
360
380
  });
361
381
  }
362
- }, fe = r.default.createServer((s, o) => {
363
- if (o.setHeader("Content-Type", "application/json"), s.method === "POST" && s.url === "/_register") {
364
- let a = "";
365
- s.on("data", (c) => a += c), s.on("end", () => {
382
+ }, xe = n.default.createServer((r, a) => {
383
+ if (a.setHeader("Content-Type", "application/json"), r.method === "POST" && r.url === "/_register") {
384
+ let l = "";
385
+ r.on("data", (c) => l += c), r.on("end", () => {
366
386
  try {
367
- const { componentId: c, distPath: l, componentName: g } = JSON.parse(a);
368
- M.set(c, { path: l, name: g || null });
369
- const w = g ? ` (${g})` : "";
370
- console.log(`✅ Registered: ${c}${w} -> ${l}`), o.writeHead(200), o.end(JSON.stringify({ success: !0, registered: Array.from(M.keys()) }));
371
- const I = Array.from(M.entries()).map(([R, V]) => ({
372
- id: R,
373
- path: V.path,
374
- name: V.name
387
+ const { componentId: c, distPath: f, componentName: y, htmlFile: S } = JSON.parse(l);
388
+ R.set(c, { path: f, name: y || null, htmlFile: S || null });
389
+ const F = y ? ` (${y})` : "";
390
+ console.log(`✅ Registered: ${c}${F} -> ${f}${S ? "/" + S : ""}`), a.writeHead(200), a.end(JSON.stringify({ success: !0, registered: Array.from(R.keys()) }));
391
+ const N = Array.from(R.entries()).map(([J, Q]) => ({
392
+ id: J,
393
+ path: Q.path,
394
+ name: Q.name
375
395
  }));
376
- D.forEach((R) => {
396
+ K.forEach((J) => {
377
397
  try {
378
- R.write(`data: ${JSON.stringify({
398
+ J.write(`data: ${JSON.stringify({
379
399
  type: "components",
380
- components: I
400
+ components: N
381
401
  })}
382
402
 
383
403
  `);
@@ -385,25 +405,25 @@ Sec-WebSocket-Accept: ${g}\r
385
405
  }
386
406
  });
387
407
  } catch (c) {
388
- o.writeHead(400), o.end(JSON.stringify({ error: c.message }));
408
+ a.writeHead(400), a.end(JSON.stringify({ error: c.message }));
389
409
  }
390
410
  });
391
- } else if (s.method === "POST" && s.url === "/_unregister") {
392
- let a = "";
393
- s.on("data", (c) => a += c), s.on("end", () => {
411
+ } else if (r.method === "POST" && r.url === "/_unregister") {
412
+ let l = "";
413
+ r.on("data", (c) => l += c), r.on("end", () => {
394
414
  try {
395
- const { componentId: c } = JSON.parse(a);
396
- M.delete(c), console.log(`❌ Unregistered: ${c}`), o.writeHead(200), o.end(JSON.stringify({ success: !0 }));
397
- const l = Array.from(M.entries()).map(([g, w]) => ({
398
- id: g,
399
- path: w.path,
400
- name: w.name
415
+ const { componentId: c } = JSON.parse(l);
416
+ R.delete(c), console.log(`❌ Unregistered: ${c}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
417
+ const f = Array.from(R.entries()).map(([y, S]) => ({
418
+ id: y,
419
+ path: S.path,
420
+ name: S.name
401
421
  }));
402
- D.forEach((g) => {
422
+ K.forEach((y) => {
403
423
  try {
404
- g.write(`data: ${JSON.stringify({
424
+ y.write(`data: ${JSON.stringify({
405
425
  type: "components",
406
- components: l
426
+ components: f
407
427
  })}
408
428
 
409
429
  `);
@@ -411,82 +431,82 @@ Sec-WebSocket-Accept: ${g}\r
411
431
  }
412
432
  });
413
433
  } catch (c) {
414
- o.writeHead(400), o.end(JSON.stringify({ error: c.message }));
434
+ a.writeHead(400), a.end(JSON.stringify({ error: c.message }));
415
435
  }
416
436
  });
417
- } else s.method === "GET" && s.url === "/_list" ? (o.writeHead(200), o.end(JSON.stringify({ components: Array.from(M.entries()) }))) : (o.writeHead(404), o.end(JSON.stringify({ error: "Not found" })));
418
- }), oe = r.default.createServer((s, o) => {
419
- if (s.url.includes("..")) {
420
- o.writeHead(403, { "Content-Type": "text/plain" }), o.end("Forbidden");
437
+ } else r.method === "GET" && r.url === "/_list" ? (a.writeHead(200), a.end(JSON.stringify({ components: Array.from(R.entries()) }))) : (a.writeHead(404), a.end(JSON.stringify({ error: "Not found" })));
438
+ }), ce = n.default.createServer((r, a) => {
439
+ if (r.url.includes("..")) {
440
+ a.writeHead(403, { "Content-Type": "text/plain" }), a.end("Forbidden");
421
441
  return;
422
442
  }
423
- const a = new URL(s.url, `http://localhost:${d}`), c = a.pathname, l = c.split("/").filter((E) => E);
443
+ const l = new URL(r.url, `http://localhost:${m}`), c = l.pathname, f = c.split("/").filter((A) => A);
424
444
  if (c.startsWith("/consume")) {
425
- const E = a.searchParams.get("id");
426
- if (!E) {
427
- o.writeHead(400, { "Content-Type": "application/json" }), o.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
445
+ const A = l.searchParams.get("id");
446
+ if (!A) {
447
+ a.writeHead(400, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
428
448
  return;
429
449
  }
430
- const J = M.get(E), Y = J ? J.path : null, Oe = (X) => {
431
- let T = "Unknown", H = "Unknown";
432
- if (s.headers.referer || s.headers.referrer) {
433
- const P = s.headers.referer || s.headers.referrer;
450
+ const B = R.get(A), Y = B ? B.path : null, Be = (oe) => {
451
+ let j = "Unknown", z = "Unknown";
452
+ if (r.headers.referer || r.headers.referrer) {
453
+ const k = r.headers.referer || r.headers.referrer;
434
454
  try {
435
- const Q = new URL(P);
436
- T = Q.origin, H = Q.hostname || Q.origin;
455
+ const ne = new URL(k);
456
+ j = ne.origin, z = ne.hostname || ne.origin;
437
457
  } catch {
438
- T = P, H = P;
458
+ j = k, z = k;
439
459
  }
440
- } else if (s.headers.origin)
460
+ } else if (r.headers.origin)
441
461
  try {
442
- const P = new URL(s.headers.origin);
443
- T = P.origin, H = P.hostname || P.origin;
462
+ const k = new URL(r.headers.origin);
463
+ j = k.origin, z = k.hostname || k.origin;
444
464
  } catch {
445
- T = s.headers.origin, H = s.headers.origin;
465
+ j = r.headers.origin, z = r.headers.origin;
446
466
  }
447
- else if (s.socket.remoteAddress) {
448
- const P = s.socket.remoteAddress;
449
- P === "::1" || P === "::ffff:127.0.0.1" ? (T = "localhost", H = "localhost (direct)") : (T = P, H = P.replace("::ffff:", ""));
467
+ else if (r.socket.remoteAddress) {
468
+ const k = r.socket.remoteAddress;
469
+ k === "::1" || k === "::ffff:127.0.0.1" ? (j = "localhost", z = "localhost (direct)") : (j = k, z = k.replace("::ffff:", ""));
450
470
  }
451
- const he = s.headers.referer || s.headers.referrer || T, re = {
471
+ const Me = r.headers.referer || r.headers.referrer || j, me = {
452
472
  type: "request",
453
- componentId: E,
473
+ componentId: A,
454
474
  timestamp: Date.now(),
455
- servedLocally: X,
456
- referrer: he,
457
- origin: T,
458
- originLabel: H
475
+ servedLocally: oe,
476
+ referrer: Me,
477
+ origin: j,
478
+ originLabel: z
459
479
  };
460
- W.has(T) || (W.set(T, {
461
- url: T,
462
- label: H,
480
+ te.has(j) || (te.set(j, {
481
+ url: j,
482
+ label: z,
463
483
  firstSeen: Date.now(),
464
484
  requestCount: 0
465
- }), D.forEach((P) => {
485
+ }), K.forEach((k) => {
466
486
  try {
467
- P.write(`data: ${JSON.stringify({
487
+ k.write(`data: ${JSON.stringify({
468
488
  type: "origins",
469
- origins: Array.from(W.values())
489
+ origins: Array.from(te.values())
470
490
  })}
471
491
 
472
492
  `);
473
493
  } catch {
474
494
  }
475
495
  }));
476
- const ye = W.get(T);
477
- ye.requestCount++, D.forEach((P) => {
496
+ const Pe = te.get(j);
497
+ Pe.requestCount++, K.forEach((k) => {
478
498
  try {
479
- P.write(`data: ${JSON.stringify({
499
+ k.write(`data: ${JSON.stringify({
480
500
  type: "origins",
481
- origins: Array.from(W.values())
501
+ origins: Array.from(te.values())
482
502
  })}
483
503
 
484
504
  `);
485
505
  } catch {
486
506
  }
487
- }), O.push(re), O.length > z && O.shift(), D.forEach((P) => {
507
+ }), G.push(me), G.length > Se && G.shift(), K.forEach((k) => {
488
508
  try {
489
- P.write(`data: ${JSON.stringify(re)}
509
+ k.write(`data: ${JSON.stringify(me)}
490
510
 
491
511
  `);
492
512
  } catch {
@@ -494,151 +514,152 @@ Sec-WebSocket-Accept: ${g}\r
494
514
  });
495
515
  };
496
516
  if (Y) {
497
- const X = t.default.join(Y, "index.html");
498
- e.default.readFile(X, "utf-8", (T, H) => {
499
- if (T) {
500
- console.log(`❌ File not found: ${X}`), o.writeHead(404, { "Content-Type": "application/json" }), o.end(JSON.stringify({ error: "index.html not found" }));
517
+ const oe = B.htmlFile ? e.default.join(Y, B.htmlFile) : e.default.join(Y, "index.html");
518
+ o.default.readFile(oe, "utf-8", (j, z) => {
519
+ if (j) {
520
+ console.log(`❌ File not found: ${oe}`), a.writeHead(404, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "index.html not found" }));
501
521
  return;
502
522
  }
503
- const he = Me(H, E), re = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ye = {
523
+ const Me = _e(z, A), me = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Pe = {
504
524
  item: {
505
- name: E,
506
- id: E,
525
+ name: A,
526
+ id: A,
507
527
  consume_variant: [
508
528
  {
509
- id: re,
529
+ id: me,
510
530
  name: "dev version",
511
531
  loader: {
512
532
  type: "HTMLLoader",
513
533
  shadowRootMode: "localFrame",
514
- HTML: he
534
+ HTML: Me
515
535
  }
516
536
  }
517
537
  ]
518
538
  }
519
539
  };
520
- console.log(`✅ Serving consume JSON for: ${E}`), Oe(!0), o.writeHead(200, {
540
+ console.log(`✅ Serving consume JSON for: ${A}`), Be(!0), a.writeHead(200, {
521
541
  "Content-Type": "application/json",
522
542
  "Access-Control-Allow-Origin": "*"
523
- }), o.end(JSON.stringify(ye, null, 2));
543
+ }), a.end(JSON.stringify(Pe, null, 2));
524
544
  });
525
545
  } else {
526
- console.log(`📡 Proxying consume request to cloud.myop.dev for: ${E}`);
527
- const X = `https://cloud.myop.dev/consume${a.search}`;
528
- Oe(!1), fetch(X).then((T) => T.text()).then((T) => {
529
- o.writeHead(200, {
546
+ console.log(`📡 Proxying consume request to cloud.myop.dev for: ${A}`);
547
+ const oe = `https://cloud.myop.dev/consume${l.search}`;
548
+ Be(!1), fetch(oe).then((j) => j.text()).then((j) => {
549
+ a.writeHead(200, {
530
550
  "Content-Type": "application/json",
531
551
  "Access-Control-Allow-Origin": "*"
532
- }), o.end(T);
533
- }).catch((T) => {
534
- console.error(`❌ Proxy error: ${T.message}`), o.writeHead(502, { "Content-Type": "application/json" }), o.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
552
+ }), a.end(j);
553
+ }).catch((j) => {
554
+ console.error(`❌ Proxy error: ${j.message}`), a.writeHead(502, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
535
555
  });
536
556
  }
537
557
  return;
538
558
  }
539
559
  if (c === "/events") {
540
- o.writeHead(200, {
560
+ a.writeHead(200, {
541
561
  "Content-Type": "text/event-stream",
542
562
  "Cache-Control": "no-cache",
543
563
  Connection: "keep-alive",
544
564
  "Access-Control-Allow-Origin": "*"
545
- }), D.push(o);
546
- const E = Array.from(M.entries()).map(([J, Y]) => ({
547
- id: J,
565
+ }), K.push(a);
566
+ const A = Array.from(R.entries()).map(([B, Y]) => ({
567
+ id: B,
548
568
  path: Y.path,
549
569
  name: Y.name
550
570
  }));
551
- o.write(`data: ${JSON.stringify({
571
+ a.write(`data: ${JSON.stringify({
552
572
  type: "components",
553
- components: E
573
+ components: A
554
574
  })}
555
575
 
556
- `), o.write(`data: ${JSON.stringify({
576
+ `), a.write(`data: ${JSON.stringify({
557
577
  type: "origins",
558
- origins: Array.from(W.values())
578
+ origins: Array.from(te.values())
559
579
  })}
560
580
 
561
- `), o.write(`data: ${JSON.stringify({
581
+ `), a.write(`data: ${JSON.stringify({
562
582
  type: "requestLog",
563
- log: O
583
+ log: G
564
584
  })}
565
585
 
566
- `), s.on("close", () => {
567
- const J = D.indexOf(o);
568
- J !== -1 && D.splice(J, 1);
586
+ `), r.on("close", () => {
587
+ const B = K.indexOf(a);
588
+ B !== -1 && K.splice(B, 1);
569
589
  });
570
590
  return;
571
591
  }
572
- if (l.length === 0) {
573
- o.writeHead(200, { "Content-Type": "text/html" }), o.end(lt(d, v, y, $));
592
+ if (f.length === 0) {
593
+ a.writeHead(200, { "Content-Type": "text/html" }), a.end(xt(m, p, w, M));
574
594
  return;
575
595
  }
576
- if (l[0] !== "view") {
577
- o.writeHead(404, { "Content-Type": "text/plain" }), o.end("Not found. Use /view/<componentId>/ to access components.");
596
+ if (f[0] !== "view") {
597
+ a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not found. Use /view/<componentId>/ to access components.");
578
598
  return;
579
599
  }
580
- if (l.length < 2) {
581
- o.writeHead(400, { "Content-Type": "text/plain" }), o.end("Component ID required. Use /view/<componentId>/");
600
+ if (f.length < 2) {
601
+ a.writeHead(400, { "Content-Type": "text/plain" }), a.end("Component ID required. Use /view/<componentId>/");
582
602
  return;
583
603
  }
584
- const g = l[1], w = M.get(g);
585
- if (!w) {
586
- o.writeHead(404, { "Content-Type": "text/plain" }), o.end(`Component not found: ${g}`);
604
+ const y = f[1], S = R.get(y);
605
+ if (!S) {
606
+ a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${y}`);
587
607
  return;
588
608
  }
589
- const I = w.path, R = l.slice(2), V = R.length === 0 ? "index.html" : R.join("/"), G = t.default.join(I, V);
590
- console.log(`📥 Request: ${s.url} -> ${G}`), e.default.readFile(G, (E, J) => {
591
- if (E) {
592
- console.log(`❌ File not found: ${G}`), o.writeHead(404, { "Content-Type": "text/plain" }), o.end("Not Found");
609
+ const F = S.path, N = f.slice(2), J = S.htmlFile || "index.html", Q = N.length === 0 ? J : N.join("/"), ie = e.default.join(F, Q);
610
+ console.log(`📥 Request: ${r.url} -> ${ie}`), o.default.readFile(ie, (A, B) => {
611
+ if (A) {
612
+ console.log(`❌ File not found: ${ie}`), a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not Found");
593
613
  return;
594
614
  }
595
- const Y = A(G);
596
- console.log(`✅ Serving: ${G} (${Y})`), o.writeHead(200, {
615
+ const Y = V(ie);
616
+ console.log(`✅ Serving: ${ie} (${Y})`), a.writeHead(200, {
597
617
  "Content-Type": Y,
598
618
  "Access-Control-Allow-Origin": "*"
599
- }), o.end(J);
619
+ }), a.end(B);
600
620
  });
601
- }), $e = () => new Promise((s, o) => {
602
- const a = JSON.stringify({
603
- componentId: S,
604
- distPath: t.default.resolve(k, x),
605
- componentName: u
606
- }), c = {
621
+ }), Ne = () => new Promise((r, a) => {
622
+ const l = x ? e.default.resolve(O) : e.default.resolve(O, b), c = JSON.stringify({
623
+ componentId: C,
624
+ distPath: l,
625
+ componentName: I,
626
+ htmlFile: x ? $ : null
627
+ }), f = {
607
628
  hostname: "localhost",
608
- port: v,
629
+ port: p,
609
630
  path: "/_register",
610
631
  method: "POST",
611
632
  headers: {
612
633
  "Content-Type": "application/json",
613
- "Content-Length": Buffer.byteLength(a)
634
+ "Content-Length": Buffer.byteLength(c)
614
635
  }
615
- }, l = r.default.request(c, (g) => {
616
- let w = "";
617
- g.on("data", (I) => w += I), g.on("end", () => {
618
- g.statusCode === 200 ? s(JSON.parse(w)) : o(new Error(`Registration failed: ${g.statusCode}`));
636
+ }, y = n.default.request(f, (S) => {
637
+ let F = "";
638
+ S.on("data", (N) => F += N), S.on("end", () => {
639
+ S.statusCode === 200 ? r(JSON.parse(F)) : a(new Error(`Registration failed: ${S.statusCode}`));
619
640
  });
620
641
  });
621
- l.on("error", o), l.write(a), l.end();
622
- }), Be = () => new Promise((s, o) => {
623
- const a = JSON.stringify({ componentId: S }), c = {
642
+ y.on("error", a), y.write(c), y.end();
643
+ }), tt = () => new Promise((r, a) => {
644
+ const l = JSON.stringify({ componentId: C }), c = {
624
645
  hostname: "localhost",
625
- port: v,
646
+ port: p,
626
647
  path: "/_unregister",
627
648
  method: "POST",
628
649
  headers: {
629
650
  "Content-Type": "application/json",
630
- "Content-Length": Buffer.byteLength(a)
651
+ "Content-Length": Buffer.byteLength(l)
631
652
  }
632
- }, l = r.default.request(c, (g) => {
633
- s();
653
+ }, f = n.default.request(c, (y) => {
654
+ r();
634
655
  });
635
- l.on("error", () => s()), l.write(a), l.end();
636
- }), ze = (s) => `
656
+ f.on("error", () => r()), f.write(l), f.end();
657
+ }), ot = (r) => `
637
658
  <!-- MYOP HMR -->
638
659
  <script>
639
660
  (function() {
640
- const componentId = '${s}';
641
- const wsUrl = 'ws://localhost:${v}/_hmr/' + componentId;
661
+ const componentId = '${r}';
662
+ const wsUrl = 'ws://localhost:${p}/_hmr/' + componentId;
642
663
  let ws;
643
664
  let reconnectAttempts = 0;
644
665
  const maxReconnectAttempts = 10;
@@ -738,278 +759,536 @@ Sec-WebSocket-Accept: ${g}\r
738
759
  connect();
739
760
  })();
740
761
  <\/script>
741
- `, Me = (s, o) => {
742
- if (!h) return s;
743
- const a = ze(o);
744
- return s.includes("</body>") ? s.replace("</body>", `${a}</body>`) : s.includes("</html>") ? s.replace("</html>", `${a}</html>`) : s + a;
745
- }, We = (s) => {
746
- const o = Buffer.from(s), a = o.length;
762
+ `, _e = (r, a) => {
763
+ if (!L) return r;
764
+ const l = ot(a);
765
+ return r.includes("</body>") ? r.replace("</body>", `${l}</body>`) : r.includes("</html>") ? r.replace("</html>", `${l}</html>`) : r + l;
766
+ }, nt = (r) => {
767
+ const a = Buffer.from(r), l = a.length;
747
768
  let c;
748
- return a < 126 ? c = Buffer.concat([
749
- Buffer.from([129, a]),
769
+ return l < 126 ? c = Buffer.concat([
770
+ Buffer.from([129, l]),
750
771
  // FIN + text frame, length
751
- o
752
- ]) : a < 65536 ? c = Buffer.concat([
772
+ a
773
+ ]) : l < 65536 ? c = Buffer.concat([
753
774
  Buffer.from([129, 126]),
754
775
  // FIN + text frame, extended length
755
- Buffer.from([a >> 8, a & 255]),
776
+ Buffer.from([l >> 8, l & 255]),
756
777
  // 16-bit length
757
- o
778
+ a
758
779
  ]) : c = Buffer.concat([
759
780
  Buffer.from([129, 127]),
760
781
  // FIN + text frame, extended length
761
- Buffer.from([0, 0, 0, 0, a >> 24, a >> 16 & 255, a >> 8 & 255, a & 255]),
782
+ Buffer.from([0, 0, 0, 0, l >> 24, l >> 16 & 255, l >> 8 & 255, l & 255]),
762
783
  // 64-bit length
763
- o
784
+ a
764
785
  ]), c;
765
- }, Ve = () => {
766
- if (!h) return;
767
- const s = L.get(S);
768
- if (!s || s.size === 0)
786
+ }, Le = () => {
787
+ if (!L) return;
788
+ const r = X.get(C);
789
+ if (!r || r.size === 0)
769
790
  return;
770
- console.log(`🔥 Notifying ${s.size} HMR client(s)`);
771
- const o = t.default.join(x, "index.html");
791
+ console.log(`🔥 Notifying ${r.size} HMR client(s)`);
792
+ const a = x ? $ : e.default.join(b, "index.html");
772
793
  try {
773
- const a = e.default.readFileSync(o, "utf-8"), c = Me(a, S), l = JSON.stringify({
794
+ const l = o.default.readFileSync(a, "utf-8"), c = _e(l, C), f = JSON.stringify({
774
795
  type: "update",
775
796
  html: c
776
- }), g = We(l);
777
- s.forEach((w) => {
797
+ }), y = nt(f);
798
+ r.forEach((S) => {
778
799
  try {
779
- w.write(g);
800
+ S.write(y);
780
801
  } catch {
781
- s.delete(w);
802
+ r.delete(S);
782
803
  }
783
804
  });
784
- } catch (a) {
785
- console.error("❌ Failed to read HTML for HMR:", a.message);
805
+ } catch (l) {
806
+ console.error("❌ Failed to read HTML for HMR:", l.message);
786
807
  }
787
808
  };
788
- let ge = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
789
- const ne = (s) => {
790
- if (j) {
791
- C = !0;
809
+ let $e = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
810
+ const de = (r) => {
811
+ if (u) {
812
+ v = !0;
792
813
  return;
793
814
  }
794
- j = !0, console.log(`
795
- 🔨 Building...`), n("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (o, a, c) => {
796
- if (j = !1, o) {
797
- const l = await De(o, a, c, n, {
798
- ...ge,
799
- onRetry: () => ne(s)
815
+ u = !0, console.log(`
816
+ 🔨 Building...`), t("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (a, l, c) => {
817
+ if (u = !1, a) {
818
+ const f = await Ke(a, l, c, t, {
819
+ ...$e,
820
+ onRetry: () => de(r)
800
821
  });
801
- ge = { ...ge, ...l }, l.handled || (console.error("❌ Build failed:", o.message), c && console.error(c));
822
+ $e = { ...$e, ...f }, f.handled || (console.error("❌ Build failed:", a.message), c && console.error(c));
802
823
  } else
803
- console.log("✅ Build completed"), a && console.log(a), Ve(), s && s();
804
- C && (C = !1, ne());
824
+ console.log("✅ Build completed"), l && console.log(l), Le(), r && r();
825
+ v && (v = !1, de());
805
826
  });
806
- }, Te = /* @__PURE__ */ new Set(), je = (s) => {
807
- e.default.readdir(s, { withFileTypes: !0 }, (o, a) => {
808
- o || (a.forEach((c) => {
809
- const l = t.default.join(s, c.name);
827
+ }, Ae = /* @__PURE__ */ new Set(), Ce = (r) => {
828
+ o.default.readdir(r, { withFileTypes: !0 }, (a, l) => {
829
+ a || (l.forEach((c) => {
830
+ const f = e.default.join(r, c.name);
810
831
  if (c.isDirectory())
811
- c.name !== "node_modules" && c.name !== "dist" && !c.name.startsWith(".") && je(l);
832
+ c.name !== "node_modules" && c.name !== "dist" && !c.name.startsWith(".") && Ce(f);
812
833
  else if (c.isFile()) {
813
- const g = t.default.extname(c.name);
814
- if (g === ".js" || g === ".css" || g === ".html")
834
+ const y = e.default.extname(c.name);
835
+ if (y === ".js" || y === ".css" || y === ".html")
815
836
  try {
816
- const w = e.default.readFileSync(l, "utf-8");
817
- F.set(l, w);
837
+ const S = o.default.readFileSync(f, "utf-8");
838
+ P.set(f, S);
818
839
  } catch {
819
840
  }
820
841
  }
821
- }), Te.has(s) || (Te.add(s), e.default.watch(s, (c, l) => {
822
- if (!l) return;
823
- const g = t.default.extname(l);
824
- if (g !== ".js" && g !== ".css" && g !== ".html") return;
825
- const w = t.default.join(s, l);
842
+ }), Ae.has(r) || (Ae.add(r), o.default.watch(r, (c, f) => {
843
+ if (!f) return;
844
+ const y = e.default.extname(f);
845
+ if (y !== ".js" && y !== ".css" && y !== ".html") return;
846
+ const S = e.default.join(r, f);
826
847
  setTimeout(() => {
827
848
  try {
828
- const I = e.default.readFileSync(w, "utf-8"), R = F.get(w);
829
- I !== R && (F.set(w, I), console.log(`📝 File changed: ${w}`), ne());
849
+ const F = o.default.readFileSync(S, "utf-8"), N = P.get(S);
850
+ F !== N && (P.set(S, F), console.log(`📝 File changed: ${S}`), x ? Le() : de());
830
851
  } catch {
831
852
  }
832
853
  }, 50);
833
854
  })));
834
855
  });
835
- }, Ie = (s) => {
856
+ }, De = (r) => {
836
857
  console.log(`
837
- 🔨 Component: ${S}`), ne(s), je(k), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
838
- `);
839
- }, Ge = () => new Promise((s) => {
840
- const o = {
858
+ 🔨 Component: ${C}`), x ? (console.log("📄 No build needed (single HTML file mode)"), Ce(O), console.log(`👀 Watching ${$} for changes...`), console.log(`Press Ctrl+C to stop
859
+ `), r && r()) : (de(r), Ce(O), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
860
+ `));
861
+ }, st = () => new Promise((r) => {
862
+ const a = {
841
863
  hostname: "localhost",
842
- port: v,
864
+ port: p,
843
865
  path: "/_list",
844
866
  method: "GET",
845
867
  timeout: 1e3
846
- }, a = r.default.request(o, (c) => {
847
- s(!0);
868
+ }, l = n.default.request(a, (c) => {
869
+ r(!0);
848
870
  });
849
- a.on("error", () => s(!1)), a.on("timeout", () => {
850
- a.destroy(), s(!1);
851
- }), a.end();
852
- }), Ye = () => new Promise((s) => {
853
- const o = r.default.createServer((a, c) => {
854
- if (c.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
855
- let l = "";
856
- a.on("data", (g) => l += g), a.on("end", () => {
871
+ l.on("error", () => r(!1)), l.on("timeout", () => {
872
+ l.destroy(), r(!1);
873
+ }), l.end();
874
+ }), it = () => new Promise((r) => {
875
+ const a = n.default.createServer((l, c) => {
876
+ if (c.setHeader("Content-Type", "application/json"), l.method === "POST" && l.url === "/_register") {
877
+ let f = "";
878
+ l.on("data", (y) => f += y), l.on("end", () => {
857
879
  try {
858
- const { componentId: g, distPath: w, componentName: I } = JSON.parse(l);
859
- M.set(g, { path: w, name: I || null });
860
- const R = I ? ` (${I})` : "";
861
- console.log(`✅ Registered: ${g}${R} -> ${w}`), c.writeHead(200), c.end(JSON.stringify({ success: !0, registered: Array.from(M.keys()) }));
862
- } catch (g) {
863
- c.writeHead(400), c.end(JSON.stringify({ error: g.message }));
880
+ const { componentId: y, distPath: S, componentName: F, htmlFile: N } = JSON.parse(f);
881
+ R.set(y, { path: S, name: F || null, htmlFile: N || null });
882
+ const J = F ? ` (${F})` : "";
883
+ console.log(`✅ Registered: ${y}${J} -> ${S}${N ? "/" + N : ""}`), c.writeHead(200), c.end(JSON.stringify({ success: !0, registered: Array.from(R.keys()) }));
884
+ } catch (y) {
885
+ c.writeHead(400), c.end(JSON.stringify({ error: y.message }));
864
886
  }
865
887
  });
866
- } else if (a.method === "POST" && a.url === "/_unregister") {
867
- let l = "";
868
- a.on("data", (g) => l += g), a.on("end", () => {
888
+ } else if (l.method === "POST" && l.url === "/_unregister") {
889
+ let f = "";
890
+ l.on("data", (y) => f += y), l.on("end", () => {
869
891
  try {
870
- const { componentId: g } = JSON.parse(l);
871
- M.delete(g), console.log(`❌ Unregistered: ${g}`), c.writeHead(200), c.end(JSON.stringify({ success: !0 }));
872
- } catch (g) {
873
- c.writeHead(400), c.end(JSON.stringify({ error: g.message }));
892
+ const { componentId: y } = JSON.parse(f);
893
+ R.delete(y), console.log(`❌ Unregistered: ${y}`), c.writeHead(200), c.end(JSON.stringify({ success: !0 }));
894
+ } catch (y) {
895
+ c.writeHead(400), c.end(JSON.stringify({ error: y.message }));
874
896
  }
875
897
  });
876
- } else a.method === "GET" && a.url === "/_list" ? (c.writeHead(200), c.end(JSON.stringify({ components: Array.from(M.entries()) }))) : (c.writeHead(404), c.end(JSON.stringify({ error: "Not found" })));
898
+ } else l.method === "GET" && l.url === "/_list" ? (c.writeHead(200), c.end(JSON.stringify({ components: Array.from(R.entries()) }))) : (c.writeHead(404), c.end(JSON.stringify({ error: "Not found" })));
877
899
  });
878
- o.on("error", () => {
879
- s(!1);
880
- }), o.listen(v, () => {
900
+ a.on("error", () => {
901
+ r(!1);
902
+ }), a.listen(p, () => {
881
903
  console.log(`
882
- 🔄 Taking over as server...`), console.log(`📡 Management server on port ${v}`), oe.on("error", () => {
883
- o.close(), s(!1);
884
- }), oe.listen(d, () => {
885
- console.log(`📡 Main server running at http://localhost:${d}`), M.set(S, {
886
- path: t.default.resolve(k, x),
887
- name: u
904
+ 🔄 Taking over as server...`), console.log(`📡 Management server on port ${p}`), ce.on("error", () => {
905
+ a.close(), r(!1);
906
+ }), ce.listen(m, () => {
907
+ console.log(`📡 Main server running at http://localhost:${m}`);
908
+ const l = x ? e.default.resolve(O) : e.default.resolve(O, b);
909
+ R.set(C, {
910
+ path: l,
911
+ name: I,
912
+ htmlFile: x ? $ : null
888
913
  });
889
- const a = u ? ` (${u})` : "";
890
- console.log(`✅ Registered component: ${S}${a}`), console.log(`📡 Access at: http://localhost:${d}/view/${S}/`), s(!0);
914
+ const c = I ? ` (${I})` : "";
915
+ console.log(`✅ Registered component: ${C}${c}`), console.log(`📡 Access at: http://localhost:${m}/view/${C}/`), r(!0);
891
916
  });
892
917
  });
893
918
  });
894
- let se;
895
- const _e = () => {
896
- se = setInterval(async () => {
897
- await Ge() || (clearInterval(se), console.log(`
898
- ⚠️ Server appears to be down, attempting to take over...`), await Ye() ? console.log("✅ Successfully took over as server") : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
919
+ let pe;
920
+ const He = () => {
921
+ pe = setInterval(async () => {
922
+ await st() || (clearInterval(pe), console.log(`
923
+ ⚠️ Server appears to be down, attempting to take over...`), await it() ? console.log("✅ Successfully took over as server") : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
899
924
  try {
900
- await $e(), console.log(`✅ Re-registered component: ${S}`), _e();
901
- } catch (a) {
902
- console.error("❌ Failed to re-register:", a.message);
925
+ await Ne(), console.log(`✅ Re-registered component: ${C}`), He();
926
+ } catch (l) {
927
+ console.error("❌ Failed to re-register:", l.message);
903
928
  }
904
929
  }, 2e3)));
905
930
  }, 3e3);
906
- }, Pe = async () => {
931
+ }, Ue = async () => {
907
932
  console.log(`
908
933
 
909
- 🛑 Shutting down...`), se && clearInterval(se), await Be(), process.exit(0);
934
+ 🛑 Shutting down...`), pe && clearInterval(pe), await tt(), process.exit(0);
910
935
  };
911
- process.on("SIGINT", Pe), process.on("SIGTERM", Pe), fe.on("error", async (s) => {
912
- if (s.code === "EADDRINUSE") {
936
+ process.on("SIGINT", Ue), process.on("SIGTERM", Ue), xe.on("error", async (r) => {
937
+ if (r.code === "EADDRINUSE") {
913
938
  console.log(`
914
939
  🔗 Connecting to existing dev server...`);
915
940
  try {
916
- S = await b();
917
- const o = await $e();
918
- console.log(`✅ Registered component: ${S}`), console.log(`📡 Access at: http://localhost:${d}/view/${S}/`), console.log(`📋 All registered components: ${o.registered.join(", ")}`), Ie(() => {
919
- N(`http://localhost:${d}/view/${S}/`);
920
- }), _e();
921
- } catch (o) {
922
- console.error("❌ Failed to register component:", o.message), process.exit(1);
941
+ C = await U();
942
+ const a = await Ne();
943
+ console.log(`✅ Registered component: ${C}`), console.log(`📡 Access at: http://localhost:${m}/view/${C}/`), console.log(`📋 All registered components: ${a.registered.join(", ")}`), De(() => {
944
+ process.env.MYOP_NO_BROWSER || g(`http://localhost:${m}/view/${C}/`);
945
+ }), He();
946
+ } catch (a) {
947
+ console.error("❌ Failed to register component:", a.message), process.exit(1);
923
948
  }
924
949
  } else
925
- console.error("❌ Management server error:", s.message), process.exit(1);
926
- }), fe.on("upgrade", ue), fe.listen(v, async () => {
950
+ console.error("❌ Management server error:", r.message), process.exit(1);
951
+ }), xe.on("upgrade", et), xe.listen(p, async () => {
927
952
  console.log(`
928
- 🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${v}`), oe.on("error", (s) => {
929
- console.error("❌ Main server error:", s.message), process.exit(1);
930
- }), oe.listen(d, async () => {
931
- console.log(`📡 Main server running at http://localhost:${d}`), (S === "DEV" || S === "NEW") && (S = "DEV1"), M.set(S, {
932
- path: t.default.resolve(k, x),
933
- name: u
953
+ 🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${p}`), ce.on("error", (r) => {
954
+ console.error("❌ Main server error:", r.message), process.exit(1);
955
+ }), ce.listen(m, async () => {
956
+ console.log(`📡 Main server running at http://localhost:${m}`), (C === "DEV" || C === "NEW") && (C = "DEV1");
957
+ const r = x ? e.default.resolve(O) : e.default.resolve(O, b);
958
+ R.set(C, {
959
+ path: r,
960
+ name: I,
961
+ htmlFile: x ? $ : null
934
962
  });
935
- const s = u ? ` (${u})` : "";
936
- console.log(`✅ Registered component: ${S}${s}`), console.log(`📡 Access at: http://localhost:${d}/view/${S}/`), Ie(() => {
937
- N(`http://localhost:${d}/view/${S}/`);
963
+ const a = I ? ` (${I})` : "";
964
+ console.log(`✅ Registered component: ${C}${a}`), console.log(`📡 Access at: http://localhost:${m}/view/${C}/`), De(() => {
965
+ process.env.MYOP_NO_BROWSER || g(`http://localhost:${m}/view/${C}/`);
938
966
  });
939
967
  });
940
968
  });
941
969
  }
942
- const we = te.join(qe.homedir(), ".myop"), ee = te.join(we, "credentials.json");
943
- function ft() {
944
- B.existsSync(we) || B.mkdirSync(we, { recursive: !0, mode: 448 });
970
+ const T = class T {
971
+ constructor(e) {
972
+ this.components = e.map(
973
+ (t) => typeof t == "string" ? { name: t, path: "", id: "" } : t
974
+ ), this.logs = /* @__PURE__ */ new Map(), this.scrollPos = /* @__PURE__ */ new Map(), this.statuses = /* @__PURE__ */ new Map(), this.statusKeys = /* @__PURE__ */ new Map(), this.panelPositions = /* @__PURE__ */ new Map(), this.needsFullRedraw = !0, this.pendingUpdates = /* @__PURE__ */ new Set(), this.renderQueued = !1, this.startTime = Date.now(), this.visibleLogLines = 8, this.selectedPanel = 0;
975
+ for (const t of this.components)
976
+ this.logs.set(t.name, []), this.scrollPos.set(t.name, 0), this.statuses.set(t.name, "Initializing..."), this.statusKeys.set(t.name, "initializing");
977
+ this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
978
+ this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, this.needsFullRedraw = !0, this.calculateLayout(), this.render();
979
+ }), this.setupKeyboardInput(), process.stdout.write(T.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
980
+ }
981
+ setupKeyboardInput() {
982
+ process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (e) => {
983
+ var n;
984
+ e === "" && (this.clear(), process.exit());
985
+ const t = (n = this.components[this.selectedPanel]) == null ? void 0 : n.name;
986
+ if (t)
987
+ switch (e) {
988
+ case "\x1B[A":
989
+ this.scroll(t, -1);
990
+ break;
991
+ case "\x1B[B":
992
+ this.scroll(t, 1);
993
+ break;
994
+ case "\x1B[C":
995
+ this.selectedPanel = (this.selectedPanel + 1) % this.components.length, this.needsFullRedraw = !0, this.render();
996
+ break;
997
+ case "\x1B[D":
998
+ this.selectedPanel = (this.selectedPanel - 1 + this.components.length) % this.components.length, this.needsFullRedraw = !0, this.render();
999
+ break;
1000
+ case "\x1B[5~":
1001
+ this.scroll(t, -this.visibleLogLines);
1002
+ break;
1003
+ case "\x1B[6~":
1004
+ this.scroll(t, this.visibleLogLines);
1005
+ break;
1006
+ case "g":
1007
+ this.scrollPos.set(t, 0), this.queueUpdate(t);
1008
+ break;
1009
+ case "G":
1010
+ const i = this.logs.get(t) || [];
1011
+ this.scrollPos.set(t, Math.max(0, i.length - this.visibleLogLines)), this.queueUpdate(t);
1012
+ break;
1013
+ }
1014
+ }));
1015
+ }
1016
+ calculateLayout() {
1017
+ const e = this.components.length, t = 38;
1018
+ let n;
1019
+ this.cols >= t * 3 + 4 ? n = Math.min(e, 3) : this.cols >= t * 2 + 2 ? n = Math.min(e, 2) : n = 1;
1020
+ const i = Math.ceil(e / n), s = Math.floor(this.cols / n), d = 2, M = this.rows - d - 2, m = Math.floor(M / i);
1021
+ this.visibleLogLines = Math.max(2, m - 4), this.layout = { panelsPerRow: n, panelWidth: s, numRows: i, panelHeight: m }, this.panelPositions.clear();
1022
+ for (let p = 0; p < e; p++) {
1023
+ const b = this.components[p], u = Math.floor(p / n), v = p % n;
1024
+ this.panelPositions.set(b.name, {
1025
+ row: d + 1 + u * m,
1026
+ col: v * s + 1,
1027
+ width: s,
1028
+ height: m
1029
+ });
1030
+ }
1031
+ }
1032
+ log(e, t, n = "info") {
1033
+ const i = this.logs.get(e) || [], s = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
1034
+ hour12: !1,
1035
+ hour: "2-digit",
1036
+ minute: "2-digit",
1037
+ second: "2-digit"
1038
+ });
1039
+ t.includes("✅") || t.includes("completed") ? n = "success" : t.includes("❌") || t.includes("failed") ? n = "error" : t.includes("⚠") ? n = "warning" : t.includes("🔥") || t.includes("HMR") ? n = "hmr" : (t.includes("📝") || t.includes("changed")) && (n = "change"), i.push({ timestamp: s, message: t.replace(/[✅❌⚠🔥📝🔨]/g, "").trim(), type: n }), this.logs.set(e, i), i.length > this.visibleLogLines && this.scrollPos.set(e, i.length - this.visibleLogLines), this.queueUpdate(e);
1040
+ }
1041
+ setStatus(e, t) {
1042
+ let n = "ready";
1043
+ const i = t.toLowerCase();
1044
+ i.includes("initializing") || i.includes("⏳") ? n = "initializing" : i.includes("starting") ? n = "starting" : i.includes("building") || i.includes("🔨") ? n = "building" : i.includes("ready") || i.includes("✅") ? n = "ready" : i.includes("changed") || i.includes("📝") ? n = "changed" : i.includes("hmr") ? n = "hmr_update" : i.includes("🔥") ? n = "hmr" : i.includes("error") || i.includes("❌") ? n = "error" : i.includes("warning") || i.includes("⚠") ? n = "warning" : (i.includes("stopped") || i.includes("exited")) && (n = "stopped"), this.statuses.set(e, t), this.statusKeys.set(e, n), this.queueUpdate(e);
1045
+ }
1046
+ scroll(e, t) {
1047
+ const n = this.logs.get(e) || [], i = this.scrollPos.get(e) || 0, s = Math.max(0, n.length - this.visibleLogLines), d = Math.max(0, Math.min(s, i + t));
1048
+ d !== i && (this.scrollPos.set(e, d), this.queueUpdate(e));
1049
+ }
1050
+ queueUpdate(e) {
1051
+ this.pendingUpdates.add(e), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
1052
+ this.renderQueued = !1, this.flushUpdates();
1053
+ }));
1054
+ }
1055
+ flushUpdates() {
1056
+ if (this.needsFullRedraw) {
1057
+ this.fullRender(), this.needsFullRedraw = !1, this.pendingUpdates.clear();
1058
+ return;
1059
+ }
1060
+ for (const e of this.pendingUpdates)
1061
+ this.renderPanel(e);
1062
+ this.pendingUpdates.clear();
1063
+ }
1064
+ getUptime() {
1065
+ const e = Math.floor((Date.now() - this.startTime) / 1e3), t = Math.floor(e / 60), n = e % 60;
1066
+ return `${t}:${n.toString().padStart(2, "0")}`;
1067
+ }
1068
+ updateHeader() {
1069
+ const e = T.C, t = Array.from(this.statusKeys.values()).filter((s) => s === "ready").length, n = this.components.length;
1070
+ let i = `${e.dim}📡${e.reset} http://localhost:9292 ${e.gray}|${e.reset} `;
1071
+ i += `${e.green}${t}${e.reset}/${n} ready ${e.gray}|${e.reset} `, i += `⏱ ${this.getUptime()} ${e.gray}|${e.reset} `, i += `Press ${e.yellow}Ctrl+C${e.reset} to stop`, i += T.ESC.clearLine.slice(0, -1), process.stdout.write(T.ESC.moveTo(2, 1) + i);
1072
+ }
1073
+ renderPanel(e) {
1074
+ const t = T.C, n = T.STATUS, i = this.panelPositions.get(e);
1075
+ if (!i) return;
1076
+ const s = this.components.findIndex((U) => U.name === e), d = this.components[s], w = s === this.selectedPanel, M = this.statusKeys.get(e) || "initializing", m = n[M], p = t[m.color], b = this.logs.get(e) || [], u = this.scrollPos.get(e) || 0, v = i.width - 1, x = w ? t.cyan : t.gray, $ = [], _ = d.name.substring(0, v - 20);
1077
+ let D = `${x}┌─${t.reset} ${p}${m.icon}${t.reset} `;
1078
+ D += `${t.bold}${_}${t.reset} ${t.gray}─${t.reset} ${p}${m.label}${t.reset} `;
1079
+ const g = 5 + _.length + m.label.length + 3;
1080
+ D += `${x}${"─".repeat(Math.max(0, v - g))}┐${t.reset}`, $.push(T.ESC.moveTo(i.row, i.col) + D);
1081
+ const P = (d.path || "").substring(0, v - 6);
1082
+ let E = `${x}│${t.reset} ${t.dim}${P}${t.reset}`;
1083
+ E += " ".repeat(Math.max(0, v - P.length - 3)), E += `${x}│${t.reset}`, $.push(T.ESC.moveTo(i.row + 1, i.col) + E);
1084
+ const C = b.length, I = C > this.visibleLogLines ? `${u + 1}-${Math.min(u + this.visibleLogLines, C)}/${C}` : "";
1085
+ let L = `${x}├${"─".repeat(v - I.length - 4)}${t.reset}`;
1086
+ I && (L += `${t.dim}${I}${t.reset}`), L += `${x}${"─".repeat(2)}┤${t.reset}`, $.push(T.ESC.moveTo(i.row + 2, i.col) + L);
1087
+ const Z = b.slice(u, u + this.visibleLogLines);
1088
+ for (let U = 0; U < this.visibleLogLines; U++) {
1089
+ const O = Z[U];
1090
+ let V = `${x}│${t.reset}`;
1091
+ if (O) {
1092
+ let R = t.white;
1093
+ O.type === "success" ? R = t.green : O.type === "error" ? R = t.red : O.type === "warning" ? R = t.yellow : O.type === "hmr" ? R = t.magenta : O.type === "change" && (R = t.blue);
1094
+ const G = O.message.substring(0, v - 12);
1095
+ V += `${t.dim}${O.timestamp}${t.reset} ${R}${G}${t.reset}`;
1096
+ const Se = v - O.timestamp.length - G.length - 2;
1097
+ V += " ".repeat(Math.max(0, Se));
1098
+ } else
1099
+ V += " ".repeat(v - 2);
1100
+ V += `${x}│${t.reset}`, $.push(T.ESC.moveTo(i.row + 3 + U, i.col) + V);
1101
+ }
1102
+ $.push(T.ESC.moveTo(i.row + 3 + this.visibleLogLines, i.col) + `${x}└${"─".repeat(v - 2)}┘${t.reset}`), process.stdout.write($.join(""));
1103
+ }
1104
+ fullRender() {
1105
+ const e = T.C;
1106
+ process.stdout.write(T.ESC.clearScreen + T.ESC.moveTo(1, 1));
1107
+ const t = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - t.length) / 2);
1108
+ process.stdout.write(`${e.cyan}${"━".repeat(n)}${e.bold}${e.bgCyan}${e.black}${t}${e.reset}${e.cyan}${"━".repeat(this.cols - n - t.length)}${e.reset}`), this.updateHeader();
1109
+ for (const i of this.components)
1110
+ this.renderPanel(i.name);
1111
+ this.renderFooter();
1112
+ }
1113
+ renderFooter() {
1114
+ const e = T.C, t = this.rows - 1;
1115
+ let n = `${e.gray}`;
1116
+ n += `${e.green}●${e.gray} Ready `, n += `${e.yellow}⟳${e.gray} Building `, n += `${e.magenta}⚡${e.gray} HMR `, n += `${e.red}✖${e.gray} Error `, n += `${e.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${e.reset}`, process.stdout.write(T.ESC.moveTo(t, 1) + n);
1117
+ }
1118
+ render() {
1119
+ this.needsFullRedraw = !0, this.queueUpdate("__full__");
1120
+ }
1121
+ clear() {
1122
+ this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(T.ESC.clearScreen + T.ESC.moveTo(1, 1) + T.ESC.showCursor);
1123
+ }
1124
+ };
1125
+ // ANSI escape codes
1126
+ ue(T, "ESC", {
1127
+ moveTo: (e, t) => `\x1B[${e};${t}H`,
1128
+ hideCursor: "\x1B[?25l",
1129
+ showCursor: "\x1B[?25h",
1130
+ clearScreen: "\x1B[2J",
1131
+ clearLine: "\x1B[2K"
1132
+ }), // Colors
1133
+ ue(T, "C", {
1134
+ reset: "\x1B[0m",
1135
+ bold: "\x1B[1m",
1136
+ dim: "\x1B[2m",
1137
+ red: "\x1B[31m",
1138
+ green: "\x1B[32m",
1139
+ yellow: "\x1B[33m",
1140
+ blue: "\x1B[34m",
1141
+ magenta: "\x1B[35m",
1142
+ cyan: "\x1B[36m",
1143
+ white: "\x1B[37m",
1144
+ gray: "\x1B[90m",
1145
+ bgCyan: "\x1B[46m",
1146
+ black: "\x1B[30m"
1147
+ }), // Status configs
1148
+ ue(T, "STATUS", {
1149
+ initializing: { icon: "◔", color: "yellow", label: "Initializing" },
1150
+ starting: { icon: "◑", color: "yellow", label: "Starting" },
1151
+ building: { icon: "⟳", color: "yellow", label: "Building" },
1152
+ ready: { icon: "●", color: "green", label: "Ready" },
1153
+ changed: { icon: "○", color: "blue", label: "Changed" },
1154
+ hmr: { icon: "⚡", color: "magenta", label: "HMR" },
1155
+ hmr_update: { icon: "⚡", color: "magenta", label: "HMR Update" },
1156
+ hmr_connected: { icon: "⚡", color: "magenta", label: "HMR" },
1157
+ error: { icon: "✖", color: "red", label: "Error" },
1158
+ warning: { icon: "⚠", color: "yellow", label: "Warning" },
1159
+ stopped: { icon: "■", color: "gray", label: "Stopped" }
1160
+ });
1161
+ let Te = T;
1162
+ async function Rt(o) {
1163
+ const { spawn: e, exec: t } = await import("child_process"), n = await import("path"), i = o.map((p) => ({
1164
+ name: p.name,
1165
+ path: p.path,
1166
+ id: p.componentId || ""
1167
+ })), s = new Te(i), d = [], w = (p) => {
1168
+ const b = process.platform;
1169
+ let u;
1170
+ b === "darwin" ? u = `open "${p}"` : b === "win32" ? u = `start "" "${p}"` : u = `xdg-open "${p}"`, t(u, () => {
1171
+ });
1172
+ }, M = () => {
1173
+ s.clear(), console.log(`
1174
+ 🛑 Shutting down all components...`), d.forEach((p) => {
1175
+ try {
1176
+ p.kill("SIGTERM");
1177
+ } catch {
1178
+ }
1179
+ }), setTimeout(() => process.exit(0), 500);
1180
+ };
1181
+ process.on("SIGINT", M), process.on("SIGTERM", M);
1182
+ const m = process.argv[1];
1183
+ for (let p = 0; p < o.length; p++) {
1184
+ const b = o[p], u = b.name;
1185
+ s.setStatus(u, "⏳ Starting..."), s.log(u, `Starting in ${b.path}`);
1186
+ const v = e("node", [m, "dev"], {
1187
+ cwd: n.default.resolve(b.path),
1188
+ env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1189
+ stdio: ["ignore", "pipe", "pipe"]
1190
+ });
1191
+ d.push(v);
1192
+ let x = "";
1193
+ v.stdout.on("data", ($) => {
1194
+ x += $.toString();
1195
+ const _ = x.split(`
1196
+ `);
1197
+ x = _.pop() || "";
1198
+ for (const D of _) {
1199
+ const g = D.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1200
+ g && (g.includes("Registered component") || g.includes("Registered:") ? s.setStatus(u, "✅ Ready") : g.includes("Building...") || g.includes("Running initial build") ? s.setStatus(u, "🔨 Building...") : g.includes("Build completed") || g.includes("Build succeeded") ? s.setStatus(u, "✅ Ready") : g.includes("Build failed") ? s.setStatus(u, "❌ Build Error") : g.includes("File changed") ? (s.setStatus(u, "📝 Changed"), setTimeout(() => s.setStatus(u, "✅ Ready"), 1500)) : g.includes("Notifying") && g.includes("HMR") ? (s.setStatus(u, "🔥 HMR Update"), setTimeout(() => s.setStatus(u, "✅ Ready"), 1e3)) : g.includes("HMR client connected") && (s.setStatus(u, "🔥 HMR Connected"), setTimeout(() => s.setStatus(u, "✅ Ready"), 1e3)), !g.includes("Watching") && !g.includes("Press Ctrl+C") && !g.includes("Starting shared") && !g.includes("Management server") && !g.includes("Main server") && !g.includes("Access at:") && !g.includes("No build needed") && s.log(u, g));
1201
+ }
1202
+ }), v.stderr.on("data", ($) => {
1203
+ const _ = $.toString().split(`
1204
+ `);
1205
+ for (const D of _) {
1206
+ const g = D.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1207
+ g && (s.log(u, `⚠️ ${g}`), s.setStatus(u, "⚠️ Warning"));
1208
+ }
1209
+ }), v.on("exit", ($) => {
1210
+ $ !== 0 && $ !== null && (s.setStatus(u, `❌ Exited (${$})`), s.log(u, `Process exited with code ${$}`));
1211
+ }), p < o.length - 1 && await new Promise(($) => setTimeout($, 500));
1212
+ }
1213
+ s.render(), setTimeout(() => {
1214
+ w("http://localhost:9292");
1215
+ }, 2e3);
945
1216
  }
946
- function be() {
1217
+ const Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1218
+ __proto__: null,
1219
+ devCommand: Fe,
1220
+ monorepoDevCommand: Rt
1221
+ }, Symbol.toStringTag, { value: "Module" })), Ee = ee.join(mt.homedir(), ".myop"), ae = ee.join(Ee, "credentials.json");
1222
+ function Et() {
1223
+ H.existsSync(Ee) || H.mkdirSync(Ee, { recursive: !0, mode: 448 });
1224
+ }
1225
+ function je() {
947
1226
  try {
948
- if (!B.existsSync(ee))
1227
+ if (!H.existsSync(ae))
949
1228
  return null;
950
- const e = B.readFileSync(ee, "utf8");
951
- return JSON.parse(e);
952
- } catch (e) {
953
- return console.info("Failed to read credentials:", e.message), null;
1229
+ const o = H.readFileSync(ae, "utf8");
1230
+ return JSON.parse(o);
1231
+ } catch (o) {
1232
+ return console.info("Failed to read credentials:", o.message), null;
954
1233
  }
955
1234
  }
956
- function He(e) {
957
- ft();
958
- const t = {
959
- ...e,
1235
+ function Qe(o) {
1236
+ Et();
1237
+ const e = {
1238
+ ...o,
960
1239
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
961
1240
  };
962
- B.writeFileSync(ee, JSON.stringify(t, null, 2), {
1241
+ H.writeFileSync(ae, JSON.stringify(e, null, 2), {
963
1242
  mode: 384
964
1243
  // Read/write for owner only
965
1244
  });
966
1245
  }
967
- function Je() {
1246
+ function Ze() {
968
1247
  try {
969
- return B.existsSync(ee) && B.unlinkSync(ee), !0;
970
- } catch (e) {
971
- return console.error("Failed to clear credentials:", e.message), !1;
1248
+ return H.existsSync(ae) && H.unlinkSync(ae), !0;
1249
+ } catch (o) {
1250
+ return console.error("Failed to clear credentials:", o.message), !1;
972
1251
  }
973
1252
  }
974
- function gt(e) {
975
- if (!e || !e.expiresAt)
1253
+ function It(o) {
1254
+ if (!o || !o.expiresAt)
976
1255
  return !0;
977
- const t = 5 * 60 * 1e3, n = new Date(e.expiresAt).getTime();
978
- return Date.now() > n - t;
1256
+ const e = 5 * 60 * 1e3, t = new Date(o.expiresAt).getTime();
1257
+ return Date.now() > t - e;
979
1258
  }
980
- function xe() {
981
- const e = be();
982
- return e ? {
983
- email: e.userEmail,
984
- userId: e.userId
1259
+ function ve() {
1260
+ const o = je();
1261
+ return o ? {
1262
+ email: o.userEmail,
1263
+ userId: o.userId
985
1264
  } : null;
986
1265
  }
987
- const Z = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", le = 19284, Ce = `http://localhost:${le}/callback`, ht = "myop-cli";
988
- function yt() {
989
- return ve.randomBytes(32).toString("base64url");
1266
+ const se = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", he = 19284, ke = `http://localhost:${he}/callback`, Ot = "myop-cli";
1267
+ function Ft() {
1268
+ return Ie.randomBytes(32).toString("base64url");
990
1269
  }
991
- function wt(e) {
992
- return ve.createHash("sha256").update(e).digest("base64url");
1270
+ function jt(o) {
1271
+ return Ie.createHash("sha256").update(o).digest("base64url");
993
1272
  }
994
- async function vt() {
995
- const e = await fetch(`${Z}/oauth/register`, {
1273
+ async function kt() {
1274
+ const o = await fetch(`${se}/oauth/register`, {
996
1275
  method: "POST",
997
1276
  headers: { "Content-Type": "application/json" },
998
1277
  body: JSON.stringify({
999
- client_name: ht,
1000
- redirect_uris: [Ce],
1278
+ client_name: Ot,
1279
+ redirect_uris: [ke],
1001
1280
  grant_types: ["authorization_code", "refresh_token"],
1002
1281
  response_types: ["code"]
1003
1282
  })
1004
1283
  });
1005
- if (!e.ok) {
1006
- const t = await e.text();
1007
- throw new Error(`Failed to register client: ${t}`);
1284
+ if (!o.ok) {
1285
+ const e = await o.text();
1286
+ throw new Error(`Failed to register client: ${e}`);
1008
1287
  }
1009
- return e.json();
1288
+ return o.json();
1010
1289
  }
1011
- function ie(e, t, n, r = null) {
1012
- const p = {
1290
+ function ge(o, e, t, n = null) {
1291
+ const i = {
1013
1292
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
1014
1293
  <circle cx="12" cy="12" r="10"/>
1015
1294
  <path d="M8 12l2.5 2.5L16 9"/>
@@ -1022,17 +1301,17 @@ function ie(e, t, n, r = null) {
1022
1301
  <path d="M12 2L2 22h20L12 2z"/>
1023
1302
  <path d="M12 9v4M12 17h.01"/>
1024
1303
  </svg>`
1025
- }, i = {
1304
+ }, s = {
1026
1305
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
1027
1306
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
1028
1307
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
1029
- }, { accent: m, glow: y } = i[e] || i.error;
1308
+ }, { accent: d, glow: w } = s[o] || s.error;
1030
1309
  return `<!DOCTYPE html>
1031
1310
  <html lang="en">
1032
1311
  <head>
1033
1312
  <meta charset="UTF-8">
1034
1313
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
1035
- <title>myop-cli | ${t}</title>
1314
+ <title>myop-cli | ${e}</title>
1036
1315
  <style>
1037
1316
  * {
1038
1317
  margin: 0;
@@ -1087,7 +1366,7 @@ function ie(e, t, n, r = null) {
1087
1366
  h1 {
1088
1367
  font-size: 20px;
1089
1368
  font-weight: 500;
1090
- color: ${m};
1369
+ color: ${d};
1091
1370
  margin-bottom: 12px;
1092
1371
  letter-spacing: -0.5px;
1093
1372
  }
@@ -1119,8 +1398,8 @@ function ie(e, t, n, r = null) {
1119
1398
  display: inline-flex;
1120
1399
  align-items: center;
1121
1400
  gap: 8px;
1122
- background: ${y};
1123
- border: 1px solid ${m}33;
1401
+ background: ${w};
1402
+ border: 1px solid ${d}33;
1124
1403
  border-radius: 4px;
1125
1404
  padding: 10px 16px;
1126
1405
  font-size: 12px;
@@ -1157,11 +1436,11 @@ function ie(e, t, n, r = null) {
1157
1436
  <body>
1158
1437
  <div class="container">
1159
1438
  <div class="icon">
1160
- ${p[e] || p.error}
1439
+ ${i[o] || i.error}
1161
1440
  </div>
1162
- <h1>${t}</h1>
1163
- <p class="message">${n}</p>
1164
- ${r ? `<div class="details"><code>Error:</code> ${r}</div>` : ""}
1441
+ <h1>${e}</h1>
1442
+ <p class="message">${t}</p>
1443
+ ${n ? `<div class="details"><code>Error:</code> ${n}</div>` : ""}
1165
1444
  <div class="hint">
1166
1445
  <span>Press</span>
1167
1446
  <kbd>⌘</kbd><kbd>W</kbd>
@@ -1174,95 +1453,95 @@ function ie(e, t, n, r = null) {
1174
1453
  </body>
1175
1454
  </html>`;
1176
1455
  }
1177
- function St(e) {
1178
- return new Promise((t, n) => {
1179
- const r = Qe.createServer((p, i) => {
1180
- const m = new ke(p.url, `http://localhost:${le}`);
1181
- if (m.pathname === "/callback") {
1182
- const y = m.searchParams.get("code"), $ = m.searchParams.get("state"), d = m.searchParams.get("error");
1183
- if (d) {
1184
- i.writeHead(200, { "Content-Type": "text/html" }), i.end(ie(
1456
+ function Nt(o) {
1457
+ return new Promise((e, t) => {
1458
+ const n = dt.createServer((i, s) => {
1459
+ const d = new ze(i.url, `http://localhost:${he}`);
1460
+ if (d.pathname === "/callback") {
1461
+ const w = d.searchParams.get("code"), M = d.searchParams.get("state"), m = d.searchParams.get("error");
1462
+ if (m) {
1463
+ s.writeHead(200, { "Content-Type": "text/html" }), s.end(ge(
1185
1464
  "error",
1186
1465
  "Authentication Failed",
1187
1466
  "Unable to complete the authentication process.",
1188
- d
1189
- )), r.close(), n(new Error(`OAuth error: ${d}`));
1467
+ m
1468
+ )), n.close(), t(new Error(`OAuth error: ${m}`));
1190
1469
  return;
1191
1470
  }
1192
- if ($ !== e) {
1193
- i.writeHead(400, { "Content-Type": "text/html" }), i.end(ie(
1471
+ if (M !== o) {
1472
+ s.writeHead(400, { "Content-Type": "text/html" }), s.end(ge(
1194
1473
  "warning",
1195
1474
  "Security Error",
1196
1475
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
1197
1476
  "state_mismatch"
1198
- )), r.close(), n(new Error("State mismatch"));
1477
+ )), n.close(), t(new Error("State mismatch"));
1199
1478
  return;
1200
1479
  }
1201
- if (!y) {
1202
- i.writeHead(400, { "Content-Type": "text/html" }), i.end(ie(
1480
+ if (!w) {
1481
+ s.writeHead(400, { "Content-Type": "text/html" }), s.end(ge(
1203
1482
  "error",
1204
1483
  "Missing Authorization Code",
1205
1484
  "No authorization code was received from the server.",
1206
1485
  "missing_code"
1207
- )), r.close(), n(new Error("No authorization code"));
1486
+ )), n.close(), t(new Error("No authorization code"));
1208
1487
  return;
1209
1488
  }
1210
- i.writeHead(200, { "Content-Type": "text/html" }), i.end(ie(
1489
+ s.writeHead(200, { "Content-Type": "text/html" }), s.end(ge(
1211
1490
  "success",
1212
1491
  "Authentication Successful",
1213
1492
  "You have been authenticated successfully. Return to the terminal to continue."
1214
- )), r.close(), t(y);
1493
+ )), n.close(), e(w);
1215
1494
  } else
1216
- i.writeHead(404), i.end("Not found");
1495
+ s.writeHead(404), s.end("Not found");
1217
1496
  });
1218
- r.listen(le, () => {
1219
- console.info(`OAuth callback server listening on port ${le}`);
1497
+ n.listen(he, () => {
1498
+ console.info(`OAuth callback server listening on port ${he}`);
1220
1499
  }), setTimeout(() => {
1221
- r.close(), n(new Error("Authentication timed out"));
1500
+ n.close(), t(new Error("Authentication timed out"));
1222
1501
  }, 5 * 60 * 1e3);
1223
1502
  });
1224
1503
  }
1225
- async function bt(e, t, n) {
1226
- const r = await fetch(`${Z}/oauth/token`, {
1504
+ async function _t(o, e, t) {
1505
+ const n = await fetch(`${se}/oauth/token`, {
1227
1506
  method: "POST",
1228
1507
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1229
- body: new Re({
1508
+ body: new We({
1230
1509
  grant_type: "authorization_code",
1231
- code: e,
1232
- client_id: t,
1233
- redirect_uri: Ce,
1234
- code_verifier: n
1510
+ code: o,
1511
+ client_id: e,
1512
+ redirect_uri: ke,
1513
+ code_verifier: t
1235
1514
  })
1236
1515
  });
1237
- if (!r.ok) {
1238
- const p = await r.json();
1239
- throw new Error(p.error_description || p.error || "Token exchange failed");
1516
+ if (!n.ok) {
1517
+ const i = await n.json();
1518
+ throw new Error(i.error_description || i.error || "Token exchange failed");
1240
1519
  }
1241
- return r.json();
1520
+ return n.json();
1242
1521
  }
1243
- async function xt(e, t) {
1244
- const n = await fetch(`${Z}/oauth/token`, {
1522
+ async function Lt(o, e) {
1523
+ const t = await fetch(`${se}/oauth/token`, {
1245
1524
  method: "POST",
1246
1525
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1247
- body: new Re({
1526
+ body: new We({
1248
1527
  grant_type: "refresh_token",
1249
- refresh_token: e,
1250
- client_id: t
1528
+ refresh_token: o,
1529
+ client_id: e
1251
1530
  })
1252
1531
  });
1253
- if (!n.ok) {
1254
- const r = await n.json();
1255
- throw new Error(r.error_description || r.error || "Token refresh failed");
1532
+ if (!t.ok) {
1533
+ const n = await t.json();
1534
+ throw new Error(n.error_description || n.error || "Token refresh failed");
1256
1535
  }
1257
- return n.json();
1536
+ return t.json();
1258
1537
  }
1259
- async function Ct(e) {
1260
- var p, i, m;
1261
- const t = await fetch(`${Z}/mcp`, {
1538
+ async function At(o) {
1539
+ var i, s, d;
1540
+ const e = await fetch(`${se}/mcp`, {
1262
1541
  method: "POST",
1263
1542
  headers: {
1264
1543
  "Content-Type": "application/json",
1265
- Authorization: `Bearer ${e}`
1544
+ Authorization: `Bearer ${o}`
1266
1545
  },
1267
1546
  body: JSON.stringify({
1268
1547
  jsonrpc: "2.0",
@@ -1274,263 +1553,291 @@ async function Ct(e) {
1274
1553
  }
1275
1554
  })
1276
1555
  });
1277
- if (!t.ok)
1556
+ if (!e.ok)
1278
1557
  throw new Error("Failed to get user info");
1279
- const n = await t.json();
1280
- if (n.error)
1281
- throw new Error(n.error.message);
1282
- const r = (m = (i = (p = n.result) == null ? void 0 : p.content) == null ? void 0 : i[0]) == null ? void 0 : m.text;
1283
- if (r)
1284
- return JSON.parse(r);
1558
+ const t = await e.json();
1559
+ if (t.error)
1560
+ throw new Error(t.error.message);
1561
+ const n = (d = (s = (i = t.result) == null ? void 0 : i.content) == null ? void 0 : s[0]) == null ? void 0 : d.text;
1562
+ if (n)
1563
+ return JSON.parse(n);
1285
1564
  throw new Error("Invalid response from whoami");
1286
1565
  }
1287
- async function q() {
1288
- const e = U("Starting authentication...").start();
1566
+ async function re() {
1567
+ const o = W("Starting authentication...").start();
1289
1568
  try {
1290
- e.text = "Registering OAuth client...";
1291
- const n = (await vt()).client_id, r = yt(), p = wt(r), i = ve.randomBytes(16).toString("hex");
1292
- e.text = "Waiting for authorization...";
1293
- const m = St(i), y = new ke(`${Z}/oauth/authorize`);
1294
- y.searchParams.set("response_type", "code"), y.searchParams.set("client_id", n), y.searchParams.set("redirect_uri", Ce), y.searchParams.set("code_challenge", p), y.searchParams.set("code_challenge_method", "S256"), y.searchParams.set("state", i), e.stop(), console.log(`
1295
- 🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${y.toString()}
1296
- `), await Ze(y.toString());
1297
- const $ = await m;
1298
- e.start("Exchanging authorization code...");
1299
- const d = await bt($, n, r);
1300
- e.text = "Getting user info...";
1301
- const v = await Ct(d.access_token), x = {
1302
- accessToken: d.access_token,
1303
- refreshToken: d.refresh_token,
1304
- expiresAt: new Date(Date.now() + d.expires_in * 1e3).toISOString(),
1305
- clientId: n,
1306
- userId: v.userId,
1307
- userEmail: v.email
1569
+ o.text = "Registering OAuth client...";
1570
+ const t = (await kt()).client_id, n = Ft(), i = jt(n), s = Ie.randomBytes(16).toString("hex");
1571
+ o.text = "Waiting for authorization...";
1572
+ const d = Nt(s), w = new ze(`${se}/oauth/authorize`);
1573
+ w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", t), w.searchParams.set("redirect_uri", ke), w.searchParams.set("code_challenge", i), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", s), o.stop(), console.log(`
1574
+ 🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${w.toString()}
1575
+ `), await pt(w.toString());
1576
+ const M = await d;
1577
+ o.start("Exchanging authorization code...");
1578
+ const m = await _t(M, t, n);
1579
+ o.text = "Getting user info...";
1580
+ const p = await At(m.access_token), b = {
1581
+ accessToken: m.access_token,
1582
+ refreshToken: m.refresh_token,
1583
+ expiresAt: new Date(Date.now() + m.expires_in * 1e3).toISOString(),
1584
+ clientId: t,
1585
+ userId: p.userId,
1586
+ userEmail: p.email
1308
1587
  };
1309
- return He(x), e.succeed(`Authenticated as ${v.email}`), x;
1310
- } catch (t) {
1311
- throw e.fail(`Authentication failed: ${t.message}`), t;
1588
+ return Qe(b), o.succeed(`Authenticated as ${p.email}`), b;
1589
+ } catch (e) {
1590
+ throw o.fail(`Authentication failed: ${e.message}`), e;
1312
1591
  }
1313
1592
  }
1314
- async function Ue() {
1315
- const e = be();
1316
- if (!e) {
1593
+ async function Xe() {
1594
+ const o = je();
1595
+ if (!o) {
1317
1596
  console.log("Not currently logged in.");
1318
1597
  return;
1319
1598
  }
1320
- Je(), console.log(`✅ Logged out (was: ${e.userEmail})`);
1599
+ Ze(), console.log(`✅ Logged out (was: ${o.userEmail})`);
1321
1600
  }
1322
- async function $t() {
1323
- let e = be();
1324
- if (!e)
1601
+ async function Dt() {
1602
+ let o = je();
1603
+ if (!o)
1325
1604
  return console.log(`Not logged in. Starting authentication...
1326
- `), await q();
1327
- if (!gt(e))
1328
- return e;
1329
- if (e.refreshToken) {
1330
- const t = U("Refreshing access token...").start();
1605
+ `), await re();
1606
+ if (!It(o))
1607
+ return o;
1608
+ if (o.refreshToken) {
1609
+ const e = W("Refreshing access token...").start();
1331
1610
  try {
1332
- const n = await xt(
1333
- e.refreshToken,
1334
- e.clientId
1611
+ const t = await Lt(
1612
+ o.refreshToken,
1613
+ o.clientId
1335
1614
  );
1336
- return e = {
1337
- ...e,
1338
- accessToken: n.access_token,
1339
- refreshToken: n.refresh_token,
1340
- expiresAt: new Date(Date.now() + n.expires_in * 1e3).toISOString()
1341
- }, He(e), t.succeed("Token refreshed"), e;
1615
+ return o = {
1616
+ ...o,
1617
+ accessToken: t.access_token,
1618
+ refreshToken: t.refresh_token,
1619
+ expiresAt: new Date(Date.now() + t.expires_in * 1e3).toISOString()
1620
+ }, Qe(o), e.succeed("Token refreshed"), o;
1342
1621
  } catch {
1343
- return t.warn("Token refresh failed, please log in again"), Je(), await q();
1622
+ return e.warn("Token refresh failed, please log in again"), Ze(), await re();
1344
1623
  }
1345
1624
  }
1346
1625
  return console.log(`Session expired. Please log in again.
1347
- `), await q();
1626
+ `), await re();
1348
1627
  }
1349
- function Mt() {
1350
- return Z;
1628
+ function Ht() {
1629
+ return se;
1351
1630
  }
1352
- const de = "@myop/cli";
1353
- async function Tt() {
1631
+ const ye = "@myop/cli";
1632
+ async function Ut() {
1354
1633
  try {
1355
- const e = await fetch(`https://registry.npmjs.org/${de}/latest`);
1356
- return e.ok ? (await e.json()).version : null;
1634
+ const o = await fetch(`https://registry.npmjs.org/${ye}/latest`);
1635
+ return o.ok ? (await o.json()).version : null;
1357
1636
  } catch {
1358
1637
  return null;
1359
1638
  }
1360
1639
  }
1361
- function jt(e, t) {
1362
- const n = e.split(".").map(Number), r = t.split(".").map(Number);
1363
- for (let p = 0; p < Math.max(n.length, r.length); p++) {
1364
- const i = n[p] || 0, m = r[p] || 0;
1365
- if (i > m) return 1;
1366
- if (i < m) return -1;
1640
+ function Bt(o, e) {
1641
+ const t = o.split(".").map(Number), n = e.split(".").map(Number);
1642
+ for (let i = 0; i < Math.max(t.length, n.length); i++) {
1643
+ const s = t[i] || 0, d = n[i] || 0;
1644
+ if (s > d) return 1;
1645
+ if (s < d) return -1;
1367
1646
  }
1368
1647
  return 0;
1369
1648
  }
1370
- async function It(e) {
1371
- const t = U({
1649
+ async function Jt(o) {
1650
+ const e = W({
1372
1651
  text: "Checking for updates...",
1373
1652
  color: "cyan"
1374
- }).start(), n = await Tt();
1375
- if (t.stop(), !n || jt(n, e) <= 0)
1653
+ }).start(), t = await Ut();
1654
+ if (e.stop(), !t || Bt(t, o) <= 0)
1376
1655
  return !1;
1377
1656
  console.log(`
1378
- 📦 New version available: ${e} → ${n}
1657
+ 📦 New version available: ${o} → ${t}
1379
1658
  `);
1380
- let r;
1659
+ let n;
1381
1660
  try {
1382
- r = await Ee({
1661
+ n = await Je({
1383
1662
  message: "Would you like to update now?",
1384
1663
  choices: [
1385
1664
  { name: "Yes, update now", value: !0 },
1386
1665
  { name: "No, continue with current version", value: !1 }
1387
1666
  ]
1388
1667
  });
1389
- } catch (p) {
1390
- throw p.name === "ExitPromptError" && (console.log(`
1668
+ } catch (i) {
1669
+ throw i.name === "ExitPromptError" && (console.log(`
1391
1670
 
1392
1671
  👋 Goodbye!
1393
- `), process.exit(0)), p;
1672
+ `), process.exit(0)), i;
1394
1673
  }
1395
- if (r) {
1396
- const p = U({
1397
- text: `Updating ${de} to v${n}...`,
1674
+ if (n) {
1675
+ const i = W({
1676
+ text: `Updating ${ye} to v${t}...`,
1398
1677
  color: "green"
1399
1678
  }).start();
1400
1679
  try {
1401
- return ce(`npm install -g ${de}@latest`, { stdio: "pipe" }), p.succeed(`Updated to v${n}`), console.log(`
1680
+ return fe(`npm install -g ${ye}@latest`, { stdio: "pipe" }), i.succeed(`Updated to v${t}`), console.log(`
1402
1681
  🔄 Restarting with new version...
1403
- `), Xe("myop", process.argv.slice(2), {
1682
+ `), ct("myop", process.argv.slice(2), {
1404
1683
  stdio: "inherit",
1405
1684
  shell: !0
1406
- }).on("close", (m) => {
1407
- process.exit(m || 0);
1685
+ }).on("close", (d) => {
1686
+ process.exit(d || 0);
1408
1687
  }), !0;
1409
1688
  } catch {
1410
- return p.fail("Update failed"), console.log(`
1411
- You can manually update by running: npm install -g ${de}@latest
1689
+ return i.fail("Update failed"), console.log(`
1690
+ You can manually update by running: npm install -g ${ye}@latest
1412
1691
  `), !1;
1413
1692
  }
1414
1693
  }
1415
1694
  return !1;
1416
1695
  }
1417
- const _t = (e) => new Promise((t) => setTimeout(t, e));
1418
- f.executionPath = process.cwd();
1419
- const me = (e = !1) => {
1420
- const t = f.program.getOptionValue("verbose");
1421
- t || (console.info = () => {
1422
- }), console.info("📝 verbose mode on"), f.options = {
1423
- configPath: f.program.getOptionValue("config"),
1424
- verbose: t
1696
+ const zt = (o) => new Promise((e) => setTimeout(e, o)), qe = (o = ".", e = 3, t = 0) => {
1697
+ const n = [];
1698
+ if (t > e) return n;
1699
+ try {
1700
+ const i = H.readdirSync(o, { withFileTypes: !0 });
1701
+ for (const s of i) {
1702
+ const d = ee.join(o, s.name);
1703
+ if (s.isDirectory()) {
1704
+ if (s.name === "node_modules" || s.name === ".git" || s.name === "dist" || s.name.startsWith("."))
1705
+ continue;
1706
+ n.push(...qe(d, e, t + 1));
1707
+ } else if (s.name === "myop.config.json")
1708
+ try {
1709
+ const w = H.readFileSync(d, "utf-8"), M = JSON.parse(w);
1710
+ n.push({
1711
+ path: o,
1712
+ configPath: d,
1713
+ name: M.name || M.componentName || ee.basename(o),
1714
+ componentId: M.componentId || null,
1715
+ config: M
1716
+ });
1717
+ } catch {
1718
+ }
1719
+ }
1720
+ } catch {
1721
+ }
1722
+ return n;
1723
+ };
1724
+ h.executionPath = process.cwd();
1725
+ const be = (o = !1) => {
1726
+ const e = h.program.getOptionValue("verbose");
1727
+ e || (console.info = () => {
1728
+ }), console.info("📝 verbose mode on"), h.options = {
1729
+ configPath: h.program.getOptionValue("config"),
1730
+ verbose: e
1425
1731
  };
1426
1732
  try {
1427
- return f.myopConfig = tt(f.options.configPath), { configFound: !0 };
1428
- } catch (n) {
1429
- if (e) {
1733
+ return h.myopConfig = gt(h.options.configPath), { configFound: !0 };
1734
+ } catch (t) {
1735
+ if (o) {
1430
1736
  console.info(`
1431
- ⚠️ failed read config file from ${f.options.configPath}, trying to create new one`);
1737
+ ⚠️ failed read config file from ${h.options.configPath}, trying to create new one`);
1432
1738
  try {
1433
- const r = {
1739
+ const n = {
1434
1740
  author: "@myop-cli",
1435
1741
  flows: []
1436
1742
  };
1437
- return Se(f.options.configPath, r), f.myopConfig = r, { configFound: !0 };
1743
+ return Oe(h.options.configPath, n), h.myopConfig = n, { configFound: !0 };
1438
1744
  } catch {
1439
- return console.info("Error details :", n), { configFound: !1, error: n };
1745
+ return console.info("Error details :", t), { configFound: !1, error: t };
1440
1746
  }
1441
1747
  } else
1442
- return console.info("Error details :", n), { configFound: !1, error: n };
1748
+ return console.info("Error details :", t), { configFound: !1, error: t };
1443
1749
  }
1444
1750
  };
1445
1751
  [
1446
- new ae(),
1447
- ...ct
1752
+ new Re(),
1753
+ ...St
1448
1754
  ];
1449
- const Pt = "0.1.21";
1450
- f.program = new Ke();
1451
- f.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(Pt);
1452
- f.program.addOption(new pe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1453
- f.program.addOption(new pe("-h, --help", "Show helpful information"));
1454
- f.program.addOption(new pe("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1455
- f.program.addOption(new pe("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1456
- f.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((e, t) => {
1457
- me(!0), console.info("adding ", e, t, f.options.configPath), e === "flow" && Fe._action(t), process.exit();
1755
+ const Wt = "0.1.23";
1756
+ h.program = new lt();
1757
+ h.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(Wt);
1758
+ h.program.addOption(new le("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1759
+ h.program.addOption(new le("-h, --help", "Show helpful information"));
1760
+ h.program.addOption(new le("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1761
+ h.program.addOption(new le("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1762
+ h.program.addOption(new le("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
1763
+ h.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, e) => {
1764
+ be(!0), console.info("adding ", o, e, h.options.configPath), o === "flow" && Ge._action(e), process.exit();
1458
1765
  });
1459
- f.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((e, t) => {
1460
- me(), console.info("removing ", e, t, f.options.configPath), e === "flow" && Ae._action(t), process.exit();
1766
+ h.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, e) => {
1767
+ be(), console.info("removing ", o, e, h.options.configPath), o === "flow" && Ye._action(e), process.exit();
1461
1768
  });
1462
- f.program.command("install").description("Install Myop assets").action(async () => {
1463
- me(), await Ne.action();
1769
+ h.program.command("install").description("Install Myop assets").action(async () => {
1770
+ be(), await Ve.action();
1464
1771
  });
1465
- f.program.command("login").description("Authenticate with Myop platform").action(async () => {
1772
+ h.program.command("login").description("Authenticate with Myop platform").action(async () => {
1466
1773
  try {
1467
- await q();
1468
- } catch (e) {
1469
- console.error("Login failed:", e.message), process.exit(1);
1774
+ await re();
1775
+ } catch (o) {
1776
+ console.error("Login failed:", o.message), process.exit(1);
1470
1777
  }
1471
1778
  process.exit(0);
1472
1779
  });
1473
- f.program.command("logout").description("Clear stored credentials").action(async () => {
1474
- await Ue(), process.exit(0);
1780
+ h.program.command("logout").description("Clear stored credentials").action(async () => {
1781
+ await Xe(), process.exit(0);
1475
1782
  });
1476
- f.program.command("whoami").description("Show current authenticated user").action(async () => {
1477
- const e = xe();
1478
- e && e.email ? console.log(`Logged in as: ${e.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1783
+ h.program.command("whoami").description("Show current authenticated user").action(async () => {
1784
+ const o = ve();
1785
+ o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1479
1786
  });
1480
- f.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (e) => {
1481
- var j, C, N, F, _, S;
1482
- const t = f.program.getOptionValue("config") || "./myop.config.json", n = await import("fs"), { execSync: r } = await import("child_process"), p = await import("path");
1483
- let i = {};
1484
- if (n.existsSync(t))
1787
+ h.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (o) => {
1788
+ var u, v, x, $, _, D;
1789
+ const e = h.program.getOptionValue("config") || "./myop.config.json", t = await import("fs"), { execSync: n } = await import("child_process"), i = await import("path");
1790
+ let s = {};
1791
+ if (t.existsSync(e))
1485
1792
  try {
1486
- const u = n.readFileSync(t, "utf-8");
1487
- i = JSON.parse(u);
1488
- const h = i.name || i.componentName;
1489
- console.log(`📋 Found config: ${h || "Unnamed component"}`), i.componentId && console.log(` Component ID: ${i.componentId}`);
1490
- } catch (u) {
1491
- console.error(`⚠️ Failed to parse ${t}:`, u.message);
1793
+ const g = t.readFileSync(e, "utf-8");
1794
+ s = JSON.parse(g);
1795
+ const P = s.name || s.componentName;
1796
+ console.log(`📋 Found config: ${P || "Unnamed component"}`), s.componentId && console.log(` Component ID: ${s.componentId}`);
1797
+ } catch (g) {
1798
+ console.error(`⚠️ Failed to parse ${e}:`, g.message);
1492
1799
  }
1493
1800
  else
1494
1801
  console.log("⚠️ No myop.config.json found. A new component will be created.");
1495
- if (!e.skipBuild) {
1496
- const { exec: u } = await import("child_process");
1497
- let h = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
1498
- const b = (A = !1) => new Promise((M) => {
1499
- const O = U(A ? "Retrying build..." : "Building project...").start();
1500
- u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (z, D, W) => {
1501
- if (!z) {
1502
- O.succeed("Build completed"), M(!0);
1802
+ if (!o.skipBuild) {
1803
+ const { exec: g } = await import("child_process");
1804
+ let P = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
1805
+ const E = (I = !1) => new Promise((L) => {
1806
+ const Z = W(I ? "Retrying build..." : "Building project...").start();
1807
+ g("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (U, O, V) => {
1808
+ if (!U) {
1809
+ Z.succeed("Build completed"), L(!0);
1503
1810
  return;
1504
1811
  }
1505
- if (O.fail("Build failed"), !h.hasTriedPlatformFix && !h.hasTriedInstall) {
1506
- const L = await De(z, D, W, u, h);
1507
- if (h = { ...h, ...L }, L.handled) {
1508
- const ue = await b(!0);
1509
- M(ue);
1812
+ if (Z.fail("Build failed"), !P.hasTriedPlatformFix && !P.hasTriedInstall) {
1813
+ const R = await Ke(U, O, V, g, P);
1814
+ if (P = { ...P, ...R }, R.handled) {
1815
+ const G = await E(!0);
1816
+ L(G);
1510
1817
  return;
1511
1818
  }
1512
1819
  }
1513
- console.error(z.message), M(!1);
1820
+ console.error(U.message), L(!1);
1514
1821
  });
1515
1822
  });
1516
- await b() || process.exit(1);
1823
+ await E() || process.exit(1);
1517
1824
  }
1518
- const m = "./dist/index.html";
1519
- n.existsSync(m) || (console.error("❌ Error: ./dist/index.html not found"), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1520
- let y;
1825
+ const d = "./dist/index.html";
1826
+ t.existsSync(d) || (console.error("❌ Error: ./dist/index.html not found"), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1827
+ let w;
1521
1828
  try {
1522
- y = await $t();
1523
- } catch (u) {
1524
- console.error("❌ Authentication failed:", u.message), process.exit(1);
1829
+ w = await Dt();
1830
+ } catch (g) {
1831
+ console.error("❌ Authentication failed:", g.message), process.exit(1);
1525
1832
  }
1526
- const $ = Mt();
1527
- let d = U("Requesting upload URL...").start(), v;
1833
+ const M = Ht();
1834
+ let m = W("Requesting upload URL...").start(), p;
1528
1835
  try {
1529
- const u = await fetch(`${$}/mcp`, {
1836
+ const g = await fetch(`${M}/mcp`, {
1530
1837
  method: "POST",
1531
1838
  headers: {
1532
1839
  "Content-Type": "application/json",
1533
- Authorization: `Bearer ${y.accessToken}`
1840
+ Authorization: `Bearer ${w.accessToken}`
1534
1841
  },
1535
1842
  body: JSON.stringify({
1536
1843
  jsonrpc: "2.0",
@@ -1539,63 +1846,63 @@ f.program.command("sync").description("Build and upload component to Myop platfo
1539
1846
  params: {
1540
1847
  name: "upload_component",
1541
1848
  arguments: {
1542
- name: i.name || i.componentName || p.default.basename(process.cwd()),
1543
- componentId: i.componentId || void 0,
1544
- organization: i.organization || void 0
1849
+ name: s.name || s.componentName || i.default.basename(process.cwd()),
1850
+ componentId: s.componentId || void 0,
1851
+ organization: s.organization || void 0
1545
1852
  }
1546
1853
  }
1547
1854
  })
1548
1855
  });
1549
- if (!u.ok)
1550
- throw new Error(`Server returned ${u.status}`);
1551
- const h = await u.json();
1552
- if (h.error)
1553
- throw new Error(h.error.message);
1554
- const b = (N = (C = (j = h.result) == null ? void 0 : j.content) == null ? void 0 : C[0]) == null ? void 0 : N.text;
1555
- if (v = JSON.parse(b), !v.success)
1556
- throw new Error(v.error);
1557
- d.succeed("Upload URL obtained");
1558
- } catch (u) {
1559
- d.fail("Failed to get upload URL"), console.error(" ", u.message), process.exit(1);
1856
+ if (!g.ok)
1857
+ throw new Error(`Server returned ${g.status}`);
1858
+ const P = await g.json();
1859
+ if (P.error)
1860
+ throw new Error(P.error.message);
1861
+ const E = (x = (v = (u = P.result) == null ? void 0 : u.content) == null ? void 0 : v[0]) == null ? void 0 : x.text;
1862
+ if (p = JSON.parse(E), !p.success)
1863
+ throw new Error(p.error);
1864
+ m.succeed("Upload URL obtained");
1865
+ } catch (g) {
1866
+ m.fail("Failed to get upload URL"), console.error(" ", g.message), process.exit(1);
1560
1867
  }
1561
- d = U("Uploading component...").start();
1868
+ m = W("Uploading component...").start();
1562
1869
  try {
1563
- const u = n.readFileSync(m, "utf-8");
1564
- let h;
1565
- const b = v.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
1566
- if (b)
1567
- h = b[1];
1870
+ const g = t.readFileSync(d, "utf-8");
1871
+ let P;
1872
+ const E = p.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
1873
+ if (E)
1874
+ P = E[1];
1568
1875
  else {
1569
- const A = v.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1570
- if (A)
1571
- h = A[1];
1876
+ const I = p.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1877
+ if (I)
1878
+ P = I[1];
1572
1879
  else
1573
- throw new Error("Could not parse presigned URL from: " + v.curlCommand);
1880
+ throw new Error("Could not parse presigned URL from: " + p.curlCommand);
1574
1881
  }
1575
- console.info("Uploading to:", h.substring(0, 100) + "...");
1576
- const k = await fetch(h, {
1882
+ console.info("Uploading to:", P.substring(0, 100) + "...");
1883
+ const C = await fetch(P, {
1577
1884
  method: "PUT",
1578
1885
  headers: {
1579
1886
  "Content-Type": "text/html"
1580
1887
  },
1581
- body: u
1888
+ body: g
1582
1889
  });
1583
- if (!k.ok) {
1584
- const A = await k.text();
1585
- throw new Error(`Upload failed with status ${k.status}: ${A}`);
1890
+ if (!C.ok) {
1891
+ const I = await C.text();
1892
+ throw new Error(`Upload failed with status ${C.status}: ${I}`);
1586
1893
  }
1587
- d.succeed("Component uploaded");
1588
- } catch (u) {
1589
- d.fail("Upload failed"), console.error(" ", u.message), u.cause && console.error(" Cause:", u.cause), process.exit(1);
1894
+ m.succeed("Component uploaded");
1895
+ } catch (g) {
1896
+ m.fail("Upload failed"), console.error(" ", g.message), g.cause && console.error(" Cause:", g.cause), process.exit(1);
1590
1897
  }
1591
- d = U("Confirming upload...").start();
1592
- let x;
1898
+ m = W("Confirming upload...").start();
1899
+ let b;
1593
1900
  try {
1594
- const u = await fetch(`${$}/mcp`, {
1901
+ const g = await fetch(`${M}/mcp`, {
1595
1902
  method: "POST",
1596
1903
  headers: {
1597
1904
  "Content-Type": "application/json",
1598
- Authorization: `Bearer ${y.accessToken}`
1905
+ Authorization: `Bearer ${w.accessToken}`
1599
1906
  },
1600
1907
  body: JSON.stringify({
1601
1908
  jsonrpc: "2.0",
@@ -1604,245 +1911,233 @@ f.program.command("sync").description("Build and upload component to Myop platfo
1604
1911
  params: {
1605
1912
  name: "confirm_upload",
1606
1913
  arguments: {
1607
- uploadId: v.uploadId
1914
+ uploadId: p.uploadId
1608
1915
  }
1609
1916
  }
1610
1917
  })
1611
1918
  });
1612
- if (!u.ok)
1613
- throw new Error(`Server returned ${u.status}`);
1614
- const h = await u.json();
1615
- if (h.error)
1616
- throw new Error(h.error.message);
1617
- const b = (S = (_ = (F = h.result) == null ? void 0 : F.content) == null ? void 0 : _[0]) == null ? void 0 : S.text;
1618
- if (x = JSON.parse(b), !x.success)
1619
- throw new Error(x.error);
1620
- d.succeed("Upload confirmed");
1621
- } catch (u) {
1622
- d.fail("Confirmation failed"), console.error(" ", u.message), process.exit(1);
1919
+ if (!g.ok)
1920
+ throw new Error(`Server returned ${g.status}`);
1921
+ const P = await g.json();
1922
+ if (P.error)
1923
+ throw new Error(P.error.message);
1924
+ const E = (D = (_ = ($ = P.result) == null ? void 0 : $.content) == null ? void 0 : _[0]) == null ? void 0 : D.text;
1925
+ if (b = JSON.parse(E), !b.success)
1926
+ throw new Error(b.error);
1927
+ m.succeed("Upload confirmed");
1928
+ } catch (g) {
1929
+ m.fail("Confirmation failed"), console.error(" ", g.message), process.exit(1);
1623
1930
  }
1624
- if (x.isNewComponent || !i.componentId) {
1625
- i.componentId = x.componentId, i.organization = x.orgId, i.name || (i.name = x.componentName);
1931
+ if (b.isNewComponent || !s.componentId) {
1932
+ s.componentId = b.componentId, s.organization = b.orgId, s.name || (s.name = b.componentName);
1626
1933
  try {
1627
- n.writeFileSync(t, JSON.stringify(i, null, 2)), console.log(`
1628
- 📝 Updated ${t} with componentId`);
1629
- } catch (u) {
1934
+ t.writeFileSync(e, JSON.stringify(s, null, 2)), console.log(`
1935
+ 📝 Updated ${e} with componentId`);
1936
+ } catch (g) {
1630
1937
  console.log(`
1631
- ⚠️ Could not update ${t}: ${u.message}`), console.log(` Please add componentId: "${x.componentId}" manually`);
1938
+ ⚠️ Could not update ${e}: ${g.message}`), console.log(` Please add componentId: "${b.componentId}" manually`);
1632
1939
  }
1633
1940
  }
1634
1941
  console.log(`
1635
- ✅ Sync completed successfully!`), console.log(` Component: ${x.componentName}`), console.log(` Dashboard: ${x.dashboardUrl}`), process.exit(0);
1942
+ ✅ Sync completed successfully!`), console.log(` Component: ${b.componentName}`), console.log(` Dashboard: ${b.dashboardUrl}`), process.exit(0);
1636
1943
  });
1637
- f.program.command("dev").description("Start development server with file watching").action(Le);
1638
- const Ot = () => {
1944
+ h.program.command("dev").description("Start development server with file watching").action(Fe);
1945
+ const Vt = () => {
1639
1946
  try {
1640
- ce("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1947
+ fe("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1641
1948
  } catch {
1642
1949
  return { gitNotInstalled: !0 };
1643
1950
  }
1644
1951
  try {
1645
- ce("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1952
+ fe("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1646
1953
  } catch {
1647
1954
  return { notARepo: !0 };
1648
1955
  }
1649
1956
  try {
1650
- const e = ce("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
1957
+ const o = fe("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
1651
1958
  encoding: "utf-8",
1652
1959
  stdio: ["pipe", "pipe", "pipe"]
1653
1960
  }).trim();
1654
- if (!e)
1961
+ if (!o)
1655
1962
  return {
1656
1963
  files: 0,
1657
1964
  insertions: 0,
1658
1965
  deletions: 0
1659
1966
  };
1660
- const t = e.split(`
1661
- `), n = t[t.length - 1], r = n.match(/(\d+) insertion/), p = n.match(/(\d+) deletion/), i = n.match(/(\d+) file/);
1967
+ const e = o.split(`
1968
+ `), t = e[e.length - 1], n = t.match(/(\d+) insertion/), i = t.match(/(\d+) deletion/), s = t.match(/(\d+) file/);
1662
1969
  return {
1663
- files: i ? parseInt(i[1]) : 0,
1664
- insertions: r ? parseInt(r[1]) : 0,
1665
- deletions: p ? parseInt(p[1]) : 0
1970
+ files: s ? parseInt(s[1]) : 0,
1971
+ insertions: n ? parseInt(n[1]) : 0,
1972
+ deletions: i ? parseInt(i[1]) : 0
1666
1973
  };
1667
1974
  } catch {
1668
1975
  return null;
1669
1976
  }
1670
- }, K = async (e = !1, t = !1) => {
1671
- var v, x, j;
1672
- const n = xe(), r = !!(n != null && n.email), p = ((v = f.myopConfig) == null ? void 0 : v.name) || ((x = f.myopConfig) == null ? void 0 : x.componentName), i = (j = f.myopConfig) == null ? void 0 : j.componentId, m = Ot();
1977
+ }, q = async (o = !1, e = !1) => {
1978
+ var p, b, u;
1979
+ const t = ve(), n = !!(t != null && t.email), i = ((p = h.myopConfig) == null ? void 0 : p.name) || ((b = h.myopConfig) == null ? void 0 : b.componentName), s = (u = h.myopConfig) == null ? void 0 : u.componentId, d = Vt();
1673
1980
  console.log(`
1674
1981
  ┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Welcome to Myop CLI - Remote UI Made Easy │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
1675
- `), e && p ? (console.log(` Component: ${p}`), 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: ${r ? n.email : "Not logged in"}`), m != null && m.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")) : m != null && m.notARepo ? console.log(" Changes: Not a git repository") : m && (m.insertions > 0 || m.deletions > 0) ? console.log(` Changes: ${m.files} file${m.files !== 1 ? "s" : ""} | \x1B[32m+${m.insertions}\x1B[0m \x1B[31m-${m.deletions}\x1B[0m`) : m && console.log(" Changes: No uncommitted changes"), console.log("");
1676
- const $ = [
1982
+ `), o && i ? (console.log(` Component: ${i}`), s ? (console.log(` ID: ${s}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${s}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? t.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("");
1983
+ const M = [
1677
1984
  {
1678
1985
  emoji: "🚀",
1679
1986
  label: "Initialize new component",
1680
1987
  value: "init",
1681
1988
  help: "Creates myop.config.json in current directory",
1682
- disabled: e ? "(config already exists)" : !1
1989
+ disabled: o ? "(config already exists)" : !1
1683
1990
  },
1684
1991
  {
1685
1992
  emoji: "🛠️ ",
1686
- label: p ? `Start dev mode for "${p}"` : "Start dev mode",
1993
+ label: i ? `Start dev mode for "${i}"` : "Start dev mode",
1687
1994
  value: "dev",
1688
1995
  help: "Starts dev server with HMR for instant preview of changes",
1689
- disabled: e ? !1 : "(no config file)"
1996
+ disabled: o ? !1 : "(no config file)"
1690
1997
  },
1691
1998
  {
1692
1999
  emoji: "📦",
1693
- label: p ? `Push "${p}"` : "Push component",
2000
+ label: i ? `Push "${i}"` : "Push component",
1694
2001
  value: "sync",
1695
2002
  help: "Builds project & uploads dist/index.html to Myop",
1696
- disabled: e ? r ? !1 : "(login required)" : "(no config file)"
2003
+ disabled: o ? n ? !1 : "(login required)" : "(no config file)"
1697
2004
  }
1698
- ].map((C) => ({
1699
- name: t && !C.disabled ? `${C.emoji} ${C.label}
1700
- ${C.help}` : `${C.emoji} ${C.label}`,
1701
- value: C.value,
1702
- disabled: C.disabled
2005
+ ].map((v) => ({
2006
+ name: e && !v.disabled ? `${v.emoji} ${v.label}
2007
+ ${v.help}` : `${v.emoji} ${v.label}`,
2008
+ value: v.value,
2009
+ disabled: v.disabled
1703
2010
  }));
1704
- $.push(
1705
- new ae(),
2011
+ M.push(
2012
+ new Re(),
1706
2013
  {
1707
- name: t && r ? `🔓 Logout (${n.email})
1708
- Clears stored credentials from this machine` : t && !r ? `🔐 Login to Myop
1709
- Opens browser to authenticate with Myop` : r ? `🔓 Logout (${n.email})` : "🔐 Login to Myop",
1710
- value: r ? "logout" : "login"
2014
+ name: e && n ? `🔓 Logout (${t.email})
2015
+ Clears stored credentials from this machine` : e && !n ? `🔐 Login to Myop
2016
+ Opens browser to authenticate with Myop` : n ? `🔓 Logout (${t.email})` : "🔐 Login to Myop",
2017
+ value: n ? "logout" : "login"
1711
2018
  },
1712
2019
  {
1713
- name: t ? "📖 Hide help" : "📖 Show help",
2020
+ name: e ? "📖 Hide help" : "📖 Show help",
1714
2021
  value: "help"
1715
2022
  },
1716
- new ae(),
1717
- {
1718
- name: "🐛 [DEV] - git push",
1719
- value: "dev-git-push",
1720
- disabled: e ? !1 : "(no config file)"
1721
- },
1722
- new ae(),
2023
+ new Re(),
1723
2024
  {
1724
2025
  name: "👋 Exit",
1725
2026
  value: "exit"
1726
2027
  }
1727
2028
  );
1728
- let d;
2029
+ let m;
1729
2030
  try {
1730
- d = await Ee({
2031
+ m = await Je({
1731
2032
  message: "What would you like to do?",
1732
- choices: $
2033
+ choices: M
1733
2034
  });
1734
- } catch (C) {
1735
- throw C.name === "ExitPromptError" && (console.log(`
2035
+ } catch (v) {
2036
+ throw v.name === "ExitPromptError" && (console.log(`
1736
2037
 
1737
2038
  👋 Goodbye!
1738
- `), process.exit(0)), C;
2039
+ `), process.exit(0)), v;
1739
2040
  }
1740
- switch (d) {
2041
+ switch (m) {
1741
2042
  case "init":
1742
- await kt();
2043
+ await Qt();
1743
2044
  break;
1744
2045
  case "sync":
1745
2046
  console.log(`
1746
2047
  Running sync...
1747
2048
  `);
1748
- const { execSync: C } = await import("child_process");
2049
+ const { execSync: v } = await import("child_process");
1749
2050
  try {
1750
- C("node " + process.argv[1] + " sync", { stdio: "inherit" });
2051
+ v("node " + process.argv[1] + " sync", { stdio: "inherit" });
1751
2052
  } catch {
1752
2053
  }
1753
- await K(!0, t);
2054
+ await q(!0, e);
1754
2055
  break;
1755
2056
  case "dev":
1756
- await Le();
2057
+ await Fe();
1757
2058
  break;
1758
2059
  case "login":
1759
2060
  try {
1760
- await q(), console.log(`
1761
- `), await K(e, t);
1762
- } catch (N) {
1763
- console.error("Login failed:", N.message), await K(e, t);
2061
+ await re(), console.log(`
2062
+ `), await q(o, e);
2063
+ } catch (x) {
2064
+ console.error("Login failed:", x.message), await q(o, e);
1764
2065
  }
1765
2066
  break;
1766
2067
  case "logout":
1767
- await Ue(), console.log(`
1768
- `), await K(e, t);
2068
+ await Xe(), console.log(`
2069
+ `), await q(o, e);
1769
2070
  break;
1770
2071
  case "help":
1771
- await K(e, !t);
1772
- break;
1773
- case "dev-git-push":
1774
- await Et(), await K(e, t);
2072
+ await q(o, !e);
1775
2073
  break;
1776
2074
  case "exit":
1777
2075
  process.exit(0);
1778
2076
  }
1779
- }, Et = async () => {
1780
- const e = await import("fs"), t = await import("path"), n = await import("./index-DuEoKctW.js").then((p) => p.i), r = process.cwd();
2077
+ }, we = ".myop-monorepo.json", Gt = () => {
2078
+ try {
2079
+ const o = H.readFileSync(we, "utf-8");
2080
+ return JSON.parse(o);
2081
+ } catch {
2082
+ return null;
2083
+ }
2084
+ }, Yt = (o) => {
2085
+ try {
2086
+ const e = {
2087
+ selectedComponents: o,
2088
+ lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2089
+ };
2090
+ H.writeFileSync(we, JSON.stringify(e, null, 2));
2091
+ } catch {
2092
+ }
2093
+ }, Kt = async () => {
2094
+ const o = ve(), e = !!(o != null && o.email);
1781
2095
  console.log(`
1782
- 🐛 [DEV] Git Push
2096
+ ┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Myop CLI - Monorepo Mode │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
1783
2097
  `);
2098
+ const t = W("Scanning for components...").start(), n = qe(".");
2099
+ t.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
2100
+ `), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
2101
+ const i = Gt(), s = (i == null ? void 0 : i.selectedComponents) || [], d = s.length > 0;
2102
+ console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
2103
+ `), n.forEach((u, v) => {
2104
+ const x = u.componentId ? "✅" : "⚪", $ = u.componentId ? u.componentId.substring(0, 8) + "..." : "(not pushed)";
2105
+ console.log(` ${x} ${u.name}`), console.log(` Path: ${u.path}`), console.log(` ID: ${$}`), console.log("");
2106
+ }), console.log(` User: ${e ? o.email : "Not logged in"}`), d && console.log(` 📋 Using saved selection from ${we}`), console.log("");
2107
+ const { checkbox: w } = await import("@inquirer/prompts"), M = n.map((u) => ({
2108
+ name: `${u.name} (${u.path})`,
2109
+ value: u.path,
2110
+ checked: d ? s.includes(u.path) : !0
2111
+ }));
2112
+ let m;
1784
2113
  try {
1785
- if (!e.existsSync(t.default.join(r, ".git"))) {
1786
- console.log(" No .git directory found. Run init first.");
1787
- return;
1788
- }
1789
- console.log("📁 Staging all files...");
1790
- const p = await n.statusMatrix({ fs: e.default, dir: r });
1791
- for (const [_, S, u, h] of p)
1792
- S === u && u === h || (u === 0 ? (await n.remove({ fs: e.default, dir: r, filepath: _ }), console.log(` - Removed: ${_}`)) : u !== h && (await n.add({ fs: e.default, dir: r, filepath: _ }), console.log(` + Added: ${_}`)));
1793
- console.log(`
1794
- 📝 Creating commit...`);
1795
- const i = await n.commit({
1796
- fs: e.default,
1797
- dir: r,
1798
- message: `dev-push ${(/* @__PURE__ */ new Date()).toISOString()}`,
1799
- author: { name: "myop-cli", email: "cli@myop.dev" }
2114
+ m = await w({
2115
+ message: "Select components to start in dev mode:",
2116
+ choices: M
1800
2117
  });
1801
- console.log(` Commit: ${i.slice(0, 7)}`), console.log(`
1802
- 📦 Creating tar archive of .git...`);
1803
- const m = t.default.join(r, ".git"), y = [], $ = async (_, S) => {
1804
- const u = t.default.relative(S, _), h = e.statSync(_), b = Buffer.alloc(512), k = u.length > 99 ? u.slice(-99) : u;
1805
- b.write(k, 0, 100), b.write(h.mode.toString(8).padStart(7, "0") + " ", 100, 8), b.write("0000000 ", 108, 8), b.write("0000000 ", 116, 8);
1806
- const A = h.isDirectory() ? 0 : h.size;
1807
- b.write(A.toString(8).padStart(11, "0") + " ", 124, 12), b.write(Math.floor(h.mtime.getTime() / 1e3).toString(8).padStart(11, "0") + " ", 136, 12), b.write(" ", 148, 8), b.write(h.isDirectory() ? "5" : "0", 156, 1);
1808
- let M = 0;
1809
- for (let O = 0; O < 512; O++)
1810
- M += b[O];
1811
- if (b.write(M.toString(8).padStart(6, "0") + "\0 ", 148, 8), y.push(b), !h.isDirectory()) {
1812
- const O = e.readFileSync(_);
1813
- y.push(O);
1814
- const z = 512 - O.length % 512;
1815
- z < 512 && y.push(Buffer.alloc(z));
1816
- }
1817
- }, d = async (_, S) => {
1818
- const u = e.readdirSync(_, { withFileTypes: !0 });
1819
- for (const h of u) {
1820
- const b = t.default.join(_, h.name);
1821
- h.isDirectory() ? (await $(b, S), await d(b, S)) : await $(b, S);
1822
- }
1823
- };
1824
- await d(m, r), y.push(Buffer.alloc(1024));
1825
- const v = Buffer.concat(y);
1826
- console.log(` Tar size: ${v.length} bytes`), console.log(`
1827
- 🗜️ Compressing with lzma...`);
1828
- const { createRequire: x } = await import("module"), N = await x(import.meta.url)("lzma-native").compress(v, { preset: 9 });
1829
- console.log(` Compressed size: ${N.length} bytes`), console.log(`
1830
- 📤 Output (base64):
1831
- `);
1832
- const F = N.toString("base64");
1833
- console.log(F), console.log(`
1834
- ✅ Done! (${F.length} characters)`);
1835
- } catch (p) {
1836
- console.error("❌ Error:", p.message);
2118
+ } catch (u) {
2119
+ throw u.name === "ExitPromptError" && (console.log(`
2120
+
2121
+ 👋 Goodbye!
2122
+ `), process.exit(0)), u;
1837
2123
  }
1838
- }, kt = async () => {
1839
- const { input: e, select: t } = await import("@inquirer/prompts"), n = await import("fs"), p = (await import("path")).default.basename(process.cwd());
1840
- let i, m;
2124
+ m.length === 0 && (console.log(`
2125
+ ⚠️ No components selected.
2126
+ `), process.exit(0)), Yt(m), console.log(`
2127
+ 💾 Selection saved to ${we}`);
2128
+ const p = n.filter((u) => m.includes(u.path));
2129
+ console.log(`🚀 Starting dev mode for ${p.length} component${p.length > 1 ? "s" : ""}...
2130
+ `);
2131
+ const { monorepoDevCommand: b } = await Promise.resolve().then(() => Tt);
2132
+ await b(p);
2133
+ }, Qt = async () => {
2134
+ const { input: o, select: e } = await import("@inquirer/prompts"), t = await import("fs"), i = (await import("path")).default.basename(process.cwd());
2135
+ let s, d;
1841
2136
  try {
1842
- i = await e({
2137
+ s = await o({
1843
2138
  message: "Component name:",
1844
- default: p
1845
- }), m = await t({
2139
+ default: i
2140
+ }), d = await e({
1846
2141
  message: "Component type:",
1847
2142
  choices: [
1848
2143
  { name: "📄 HTML", value: "html", description: "Plain HTML/JS/CSS component" },
@@ -1851,23 +2146,23 @@ Running sync...
1851
2146
  { name: "🅰️ Angular", value: "angular", disabled: "(coming soon)" }
1852
2147
  ]
1853
2148
  });
1854
- } catch (d) {
1855
- throw d.name === "ExitPromptError" && (console.log(`
2149
+ } catch (m) {
2150
+ throw m.name === "ExitPromptError" && (console.log(`
1856
2151
 
1857
2152
  👋 Goodbye!
1858
- `), process.exit(0)), d;
2153
+ `), process.exit(0)), m;
1859
2154
  }
1860
- const y = {
1861
- name: i,
1862
- type: m,
2155
+ const w = {
2156
+ name: s,
2157
+ type: d,
1863
2158
  author: "@myop-cli",
1864
2159
  HMR: !0
1865
- }, $ = f.program.getOptionValue("config") || "./myop.config.json";
2160
+ }, M = h.program.getOptionValue("config") || "./myop.config.json";
1866
2161
  try {
1867
- n.writeFileSync($, JSON.stringify(y, null, 2)), console.log(`
1868
- ✅ Created ${$}`);
1869
- const d = {
1870
- name: i.toLowerCase().replace(/\s+/g, "-"),
2162
+ t.writeFileSync(M, JSON.stringify(w, null, 2)), console.log(`
2163
+ ✅ Created ${M}`);
2164
+ const m = {
2165
+ name: s.toLowerCase().replace(/\s+/g, "-"),
1871
2166
  version: "1.0.0",
1872
2167
  type: "module",
1873
2168
  scripts: {
@@ -1878,7 +2173,7 @@ Running sync...
1878
2173
  esbuild: "^0.24.0"
1879
2174
  }
1880
2175
  };
1881
- n.writeFileSync("package.json", JSON.stringify(d, null, 2)), console.log("✅ Created package.json"), n.mkdirSync("src/modules", { recursive: !0 }), n.mkdirSync("src/styles", { recursive: !0 }), n.writeFileSync("build.js", `import * as esbuild from 'esbuild';
2176
+ t.writeFileSync("package.json", JSON.stringify(m, null, 2)), console.log("✅ Created package.json"), t.mkdirSync("src/modules", { recursive: !0 }), t.mkdirSync("src/styles", { recursive: !0 }), t.writeFileSync("build.js", `import * as esbuild from 'esbuild';
1882
2177
  import fs from 'fs';
1883
2178
  import path from 'path';
1884
2179
 
@@ -1958,25 +2253,25 @@ fs.writeFileSync('dist/index.html', html);
1958
2253
  console.log('✅ Built dist/index.html');
1959
2254
  console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
1960
2255
  `), console.log("✅ Created build.js");
1961
- const x = `<!DOCTYPE html>
2256
+ const b = `<!DOCTYPE html>
1962
2257
  <html lang="en">
1963
2258
  <head>
1964
2259
  <meta charset="UTF-8">
1965
2260
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
1966
- <title>${i}</title>
2261
+ <title>${s}</title>
1967
2262
  <link rel="stylesheet" href="./src/styles/index.css">
1968
2263
  </head>
1969
2264
  <body>
1970
2265
  <div id="app">
1971
- <h1>${i}</h1>
2266
+ <h1>${s}</h1>
1972
2267
  <p>Your Myop component is ready!</p>
1973
2268
  </div>
1974
2269
  <script type="module" src="./src/index.js"><\/script>
1975
2270
  </body>
1976
2271
  </html>
1977
2272
  `;
1978
- n.writeFileSync("index.html", x), console.log("✅ Created index.html");
1979
- const j = `// ${i} - Entry Point
2273
+ t.writeFileSync("index.html", b), console.log("✅ Created index.html");
2274
+ const u = `// ${s} - Entry Point
1980
2275
  import { init } from './modules/app.js';
1981
2276
  import { setupMyopInterface } from './modules/myop.js';
1982
2277
 
@@ -1985,16 +2280,16 @@ document.addEventListener('DOMContentLoaded', () => {
1985
2280
  setupMyopInterface();
1986
2281
  });
1987
2282
  `;
1988
- n.writeFileSync("src/index.js", j), console.log("✅ Created src/index.js");
1989
- const C = `// ${i} - Main Application Logic
2283
+ t.writeFileSync("src/index.js", u), console.log("✅ Created src/index.js");
2284
+ const v = `// ${s} - Main Application Logic
1990
2285
 
1991
2286
  export function init() {
1992
- console.log('${i} loaded');
2287
+ console.log('${s} loaded');
1993
2288
 
1994
2289
  // Your component logic here
1995
2290
  }
1996
2291
  `;
1997
- n.writeFileSync("src/modules/app.js", C), console.log("✅ Created src/modules/app.js"), n.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
2292
+ t.writeFileSync("src/modules/app.js", v), console.log("✅ Created src/modules/app.js"), t.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
1998
2293
 
1999
2294
  export function setupMyopInterface() {
2000
2295
  // Called when host app sends data to this component
@@ -2010,12 +2305,12 @@ export function setupMyopInterface() {
2010
2305
  };
2011
2306
  }
2012
2307
  `), console.log("✅ Created src/modules/myop.js");
2013
- const F = `/* ${i} - Styles Entry Point */
2308
+ const $ = `/* ${s} - Styles Entry Point */
2014
2309
  /* Add your CSS imports here - they will be auto-bundled */
2015
2310
  @import './main.css';
2016
2311
  `;
2017
- n.writeFileSync("src/styles/index.css", F), console.log("✅ Created src/styles/index.css");
2018
- const _ = `/* ${i} - Main Styles */
2312
+ t.writeFileSync("src/styles/index.css", $), console.log("✅ Created src/styles/index.css");
2313
+ const _ = `/* ${s} - Main Styles */
2019
2314
 
2020
2315
  * {
2021
2316
  box-sizing: border-box;
@@ -2044,16 +2339,16 @@ p {
2044
2339
  line-height: 1.5;
2045
2340
  }
2046
2341
  `;
2047
- n.writeFileSync("src/styles/main.css", _), console.log("✅ Created src/styles/main.css"), n.writeFileSync(".gitignore", `node_modules/
2342
+ t.writeFileSync("src/styles/main.css", _), console.log("✅ Created src/styles/main.css"), t.writeFileSync(".gitignore", `node_modules/
2048
2343
  dist/
2049
2344
  .temp-entry.js
2050
2345
  .temp-styles.css
2051
2346
  .DS_Store
2052
2347
  `), console.log("✅ Created .gitignore");
2053
- const u = await import("./index-DuEoKctW.js").then((b) => b.i), h = process.cwd();
2348
+ const g = await import("./index-DuEoKctW.js").then((E) => E.i), P = process.cwd();
2054
2349
  try {
2055
- await u.init({ fs: n, dir: h });
2056
- const b = [
2350
+ await g.init({ fs: t, dir: P });
2351
+ const E = [
2057
2352
  "myop.config.json",
2058
2353
  "package.json",
2059
2354
  "build.js",
@@ -2065,60 +2360,64 @@ dist/
2065
2360
  "src/styles/index.css",
2066
2361
  "src/styles/main.css"
2067
2362
  ];
2068
- for (const k of b)
2069
- await u.add({ fs: n, dir: h, filepath: k });
2070
- await u.commit({
2071
- fs: n,
2072
- dir: h,
2363
+ for (const C of E)
2364
+ await g.add({ fs: t, dir: P, filepath: C });
2365
+ await g.commit({
2366
+ fs: t,
2367
+ dir: P,
2073
2368
  message: "init",
2074
2369
  author: { name: "myop-cli", email: "cli@myop.dev" }
2075
2370
  }), console.log("✅ Initialized git repository");
2076
- } catch (b) {
2077
- console.log("⚠️ Failed to initialize git repository:", b.message);
2371
+ } catch (E) {
2372
+ console.log("⚠️ Failed to initialize git repository:", E.message);
2078
2373
  }
2079
2374
  console.log(`
2080
2375
  📦 Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
2081
- `), f.myopConfig = y, await K(!0);
2082
- } catch (d) {
2083
- console.error(`Failed to initialize component: ${d.message}`), process.exit(1);
2376
+ `), h.myopConfig = w, await q(!0);
2377
+ } catch (m) {
2378
+ console.error(`Failed to initialize component: ${m.message}`), process.exit(1);
2084
2379
  }
2085
2380
  };
2086
- f.program.command("default", { isDefault: !0 }).action(async () => {
2087
- if (f.program.getOptionValue("help") && (console.log(et), process.exit()), f.program.getOptionValue("ci")) {
2088
- const m = await import("fs"), y = f.program.getOptionValue("config") || "./myop.config.json", $ = f.program.version(), d = xe();
2089
- let v = { found: !1 };
2381
+ h.program.command("default", { isDefault: !0 }).action(async () => {
2382
+ if (h.program.getOptionValue("help") && (console.log(ut), process.exit()), h.program.getOptionValue("monorepo")) {
2383
+ await Kt();
2384
+ return;
2385
+ }
2386
+ if (h.program.getOptionValue("ci")) {
2387
+ const w = await import("fs"), M = h.program.getOptionValue("config") || "./myop.config.json", m = h.program.version(), p = ve();
2388
+ let b = { found: !1 };
2090
2389
  try {
2091
- if (m.existsSync(y)) {
2092
- const j = m.readFileSync(y, "utf-8"), C = JSON.parse(j);
2093
- v = {
2390
+ if (w.existsSync(M)) {
2391
+ const v = w.readFileSync(M, "utf-8"), x = JSON.parse(v);
2392
+ b = {
2094
2393
  found: !0,
2095
- path: y,
2096
- name: C.name || C.componentName || null,
2097
- componentId: C.componentId || null,
2098
- organization: C.organization || null
2394
+ path: M,
2395
+ name: x.name || x.componentName || null,
2396
+ componentId: x.componentId || null,
2397
+ organization: x.organization || null
2099
2398
  };
2100
2399
  }
2101
- } catch (j) {
2102
- v = { found: !1, error: j.message };
2400
+ } catch (v) {
2401
+ b = { found: !1, error: v.message };
2103
2402
  }
2104
- const x = {
2105
- version: $,
2106
- config: v,
2403
+ const u = {
2404
+ version: m,
2405
+ config: b,
2107
2406
  auth: {
2108
- loggedIn: !!(d != null && d.email),
2109
- email: (d == null ? void 0 : d.email) || null
2407
+ loggedIn: !!(p != null && p.email),
2408
+ email: (p == null ? void 0 : p.email) || null
2110
2409
  }
2111
2410
  };
2112
- console.log(JSON.stringify(x, null, 2)), process.exit(0);
2411
+ console.log(JSON.stringify(u, null, 2)), process.exit(0);
2113
2412
  }
2114
- let n = U({
2413
+ let n = W({
2115
2414
  text: "Loading Myop CLI...",
2116
2415
  color: "green"
2117
2416
  }).start();
2118
- const r = me();
2119
- await _t(500), n.stop();
2120
- const p = f.program.version();
2121
- await It(p) || await K(r.configFound);
2417
+ const i = be();
2418
+ await zt(500), n.stop();
2419
+ const s = h.program.version();
2420
+ await Jt(s) || await q(i.configFound);
2122
2421
  });
2123
- f.program.parse(process.argv);
2124
- f.program.opts();
2422
+ h.program.parse(process.argv);
2423
+ h.program.opts();