@myop/cli 0.1.23 β†’ 0.1.24

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