@myop/cli 0.1.38 β†’ 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/myop-cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
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 = `
2
+ var ut = Object.defineProperty;
3
+ var gt = (o, e, t) => e in o ? ut(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
4
+ var ye = (o, e, t) => gt(o, typeof e != "symbol" ? e + "" : e, t);
5
+ import G from "ora";
6
+ import { select as Ye, Separator as Fe } from "@inquirer/prompts";
7
+ import { Command as ft, Option as me } from "commander";
8
+ import { execSync as q, spawn as ht } from "child_process";
9
+ import H, { join as Oe } from "path";
10
+ import R, { readFileSync as yt } from "fs";
11
+ import Le from "crypto";
12
+ import wt from "http";
13
+ import { URL as Ke, URLSearchParams as Qe } from "url";
14
+ import St from "open";
15
+ import vt from "os";
16
+ const bt = `
17
17
  Usage: myop [OPTIONS] COMMAND [ARGS]...
18
18
 
19
19
  A powerful command-line interface for managing your Myop projects.
@@ -55,81 +55,81 @@ Examples:
55
55
  verbose: !1
56
56
  },
57
57
  myopConfig: null
58
- }, Ye = {
58
+ }, Ze = {
59
59
  name: "πŸ“₯ Install Myop generated dependencies",
60
60
  value: "myopInstall",
61
61
  description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
62
62
  action: async () => {
63
63
  console.info("installing... ");
64
64
  for (const o of y.myopConfig.flows) {
65
- const e = te.join(y.executionPath, "/node_modules/@myop/flow-types/");
65
+ const e = H.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
- }, gt = (o) => {
71
- const e = te.join(y.executionPath, o);
70
+ }, xt = (o) => {
71
+ const e = H.join(y.executionPath, o);
72
72
  console.info(`reading config file from: ${e}`);
73
- const t = D.readFileSync(e, "utf8"), n = JSON.parse(t);
73
+ const t = R.readFileSync(e, "utf8"), n = JSON.parse(t);
74
74
  return console.info("config file loaded, ", n), n;
75
- }, Ne = (o, e) => {
76
- const t = te.join(y.executionPath, o);
75
+ }, Ae = (o, e) => {
76
+ const t = H.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
- D.writeFileSync(t, n), console.info(`config file updated ${n}`);
80
+ R.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
- }, Ke = {
85
+ }, Xe = {
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
- y.myopConfig.flows.includes(o) || y.myopConfig.flows.push(o), Ne(y.options.configPath, y.myopConfig);
90
+ y.myopConfig.flows.includes(o) || y.myopConfig.flows.push(o), Ae(y.options.configPath, y.myopConfig);
91
91
  },
92
92
  action: async () => {
93
93
  }
94
- }, Qe = {
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
- y.myopConfig.flows = y.myopConfig.flows.filter((e) => e !== o), Ne(y.options.configPath, y.myopConfig);
99
+ y.myopConfig.flows = y.myopConfig.flows.filter((e) => e !== o), Ae(y.options.configPath, y.myopConfig);
100
100
  },
101
101
  action: () => {
102
102
  }
103
- }, ht = {
103
+ }, $t = {
104
104
  name: "πŸ‘‹ Quit",
105
105
  value: "quit",
106
106
  description: "Quit and continue coding.",
107
107
  action: () => {
108
108
  process.exit();
109
109
  }
110
- }, yt = {
110
+ }, Ct = {
111
111
  name: "🟒 Create new component",
112
112
  value: "-",
113
113
  disabled: "(not available yet)"
114
- }, wt = {
114
+ }, Mt = {
115
115
  name: "πŸ”΅ Create new experience",
116
116
  value: "-",
117
117
  disabled: "(not available yet)"
118
- }, vt = {
118
+ }, Pt = {
119
119
  name: "🟑 Create new skin",
120
120
  value: "-",
121
121
  disabled: "(not available yet)"
122
- }, bt = {
122
+ }, Tt = {
123
123
  name: "πŸ”΄ Create new flow",
124
124
  value: "-",
125
125
  disabled: "(not available yet)"
126
- }, St = {
126
+ }, Rt = {
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
- }, xt = [St, yt, wt, vt, bt];
132
- function $t(o, e, t, n) {
131
+ }, Et = [Rt, Ct, Mt, Pt, Tt];
132
+ function It(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 Ct(o) {
222
+ function Ot(o) {
223
223
  return o.includes("esbuild") && o.includes("another platform");
224
224
  }
225
- function Mt(o) {
225
+ function kt(o) {
226
226
  return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
227
227
  }
228
- function Pt() {
228
+ function Ft() {
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 Rt(o) {
234
+ function jt(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, (r) => {
240
- if (r) {
241
- console.error("❌ Failed to remove node_modules:", r.message), console.error(`
239
+ o(n, (i) => {
240
+ if (i) {
241
+ console.error("❌ Failed to remove node_modules:", i.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, v) => {
247
+ `), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (s, l, w) => {
248
248
  if (s) {
249
- console.error("❌ npm install failed:", s.message), v && console.error(v), e(!1);
249
+ console.error("❌ npm install failed:", s.message), w && console.error(w), e(!1);
250
250
  return;
251
251
  }
252
252
  console.log(` βœ“ Dependencies reinstalled successfully!
@@ -255,101 +255,101 @@ function Rt(o) {
255
255
  });
256
256
  });
257
257
  }
258
- async function Ze(o, e, t, n, r = {}) {
258
+ async function et(o, e, t, n, i = {}) {
259
259
  const {
260
260
  hasTriedPlatformFix: s = !1,
261
- hasTriedInstall: d = !1,
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
- if (p) {
268
- console.error("❌ Failed to install dependencies:", p.message), f && console.error(f), u({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
261
+ hasTriedInstall: l = !1,
262
+ onRetry: w
263
+ } = i, v = ((o == null ? void 0 : o.message) || "") + (e || "") + (t || "");
264
+ return !s && Ot(v) ? (Ft(), await jt(n) && w ? (console.log(`πŸ”„ Retrying build...
265
+ `), w(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : !l && kt(v) ? (console.log("πŸ“¦ Missing dependencies detected, running npm install..."), new Promise((m) => {
266
+ n("npm install", (d, C, u) => {
267
+ if (d) {
268
+ console.error("❌ Failed to install dependencies:", d.message), u && console.error(u), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
269
269
  return;
270
270
  }
271
- console.log("βœ… Dependencies installed"), v && v(), u({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
271
+ console.log("βœ… Dependencies installed"), w && w(), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
272
272
  });
273
- })) : { handled: !1, hasTriedPlatformFix: s, hasTriedInstall: d };
273
+ })) : { handled: !1, hasTriedPlatformFix: s, hasTriedInstall: l };
274
274
  }
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");
275
+ async function be() {
276
+ const o = await import("fs"), e = await import("path"), { exec: t } = await import("child_process"), n = await import("http"), { createHash: i } = await import("node:crypto");
277
277
  let s;
278
278
  if (import.meta.url.startsWith("file://")) {
279
- const i = new URL(import.meta.url).pathname, l = process.platform === "win32" && i.startsWith("/") ? i.slice(1) : i;
280
- s = e.default.dirname(l);
279
+ const r = new URL(import.meta.url).pathname, c = process.platform === "win32" && r.startsWith("/") ? r.slice(1) : r;
280
+ s = e.default.dirname(c);
281
281
  } else
282
282
  s = e.default.dirname(import.meta.url);
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 = () => {
283
+ const l = e.default.join(s, "commands", "dev", "management-website"), w = o.default.readFileSync(e.default.join(l, "styles.css"), "utf-8"), v = o.default.readFileSync(e.default.join(l, "app.js"), "utf-8"), m = 9292, d = 9293;
284
+ let C = "./dist", u = !1, S = !1, M = !1, T = null;
285
+ const D = () => {
286
286
  try {
287
- const a = o.default.readdirSync(".").filter((i) => !i.endsWith(".html") || i.startsWith(".") ? !1 : o.default.statSync(i).isFile());
287
+ const a = o.default.readdirSync(".").filter((r) => !r.endsWith(".html") || r.startsWith(".") ? !1 : o.default.statSync(r).isFile());
288
288
  if (a.length === 1)
289
289
  return a[0];
290
290
  } catch {
291
291
  }
292
292
  return null;
293
- }, H = () => {
293
+ }, P = () => {
294
294
  try {
295
295
  const a = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
296
296
  return !!(a.scripts && a.scripts.build);
297
297
  } catch {
298
298
  return !1;
299
299
  }
300
- }, g = (a) => {
301
- const i = process.platform;
302
- let l;
303
- i === "darwin" ? l = `open "${a}"` : i === "win32" ? l = `start "" "${a}"` : l = `xdg-open "${a}"`, t(l, (c) => {
300
+ }, x = (a) => {
301
+ const r = process.platform;
302
+ let c;
303
+ r === "darwin" ? c = `open "${a}"` : r === "win32" ? c = `start "" "${a}"` : c = `xdg-open "${a}"`, t(c, (p) => {
304
304
  });
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();
305
+ }, j = /* @__PURE__ */ new Map(), b = y.program.getOptionValue("config") || "./myop.config.json";
306
+ let f, E, _ = !1;
307
+ T = D();
308
+ const B = P();
309
309
  try {
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");
310
+ const a = o.default.readFileSync(b, "utf-8"), r = JSON.parse(a);
311
+ f = r.componentId || "DEV", E = r.componentName || r.name || null, _ = r.HMR === !0, T && !B && (M = !0, _ = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`)), _ && console.log("πŸ”₯ HMR enabled");
312
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));
313
+ T && !B ? (M = !0, f = "DEV", E = e.default.basename(T, ".html"), _ = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`), console.log("πŸ”₯ HMR enabled")) : (console.error("❌ Error reading myop.config.json:", a.message), process.exit(1));
314
314
  }
315
315
  const U = async () => {
316
- if (C !== "DEV" && C !== "NEW")
317
- return C;
316
+ if (f !== "DEV" && f !== "NEW")
317
+ return f;
318
318
  try {
319
- const i = ((await new Promise((m, h) => {
320
- const w = {
319
+ const r = ((await new Promise((g, h) => {
320
+ const $ = {
321
321
  hostname: "localhost",
322
- port: p,
322
+ port: d,
323
323
  path: "/_list",
324
324
  method: "GET",
325
325
  timeout: 1e3
326
- }, R = n.default.request(w, (N) => {
327
- let J = "";
328
- N.on("data", (Z) => J += Z), N.on("end", () => {
326
+ }, O = n.default.request($, (L) => {
327
+ let V = "";
328
+ L.on("data", (te) => V += te), L.on("end", () => {
329
329
  try {
330
- m(JSON.parse(J));
330
+ g(JSON.parse(V));
331
331
  } catch {
332
- m({ components: [] });
332
+ g({ components: [] });
333
333
  }
334
334
  });
335
335
  });
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)
336
+ O.on("error", () => g({ components: [] })), O.on("timeout", () => {
337
+ O.destroy(), g({ components: [] });
338
+ }), O.end();
339
+ })).components || []).map(([g]) => g).filter((g) => g === "DEV" || g === "NEW" || /^DEV\d+$/.test(g) || /^NEW\d+$/.test(g));
340
+ if (r.length === 0)
341
341
  return "DEV1";
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
- return `DEV${Math.max(...l, 0) + 1}`;
342
+ const c = r.map((g) => {
343
+ if (g === "DEV" || g === "NEW") return 1;
344
+ const h = g.match(/^DEV(\d+)$/), $ = g.match(/^NEW(\d+)$/);
345
+ return h ? parseInt(h[1], 10) : $ ? parseInt($[1], 10) : 0;
346
+ }).filter((g) => g > 0);
347
+ return `DEV${Math.max(...c, 0) + 1}`;
348
348
  } catch {
349
349
  return "DEV1";
350
350
  }
351
- }, F = process.cwd(), G = (a) => {
352
- const i = e.default.extname(a).toLowerCase();
351
+ }, k = process.cwd(), z = (a) => {
352
+ const r = e.default.extname(a).toLowerCase();
353
353
  return {
354
354
  ".html": "text/html",
355
355
  ".js": "text/javascript",
@@ -360,336 +360,336 @@ async function _e() {
360
360
  ".gif": "image/gif",
361
361
  ".svg": "image/svg+xml",
362
362
  ".ico": "image/x-icon"
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) => {
363
+ }[r] || "application/octet-stream";
364
+ }, I = /* @__PURE__ */ new Map(), Z = [], se = 50, Y = [], ie = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), lt = (a, r, c) => {
365
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(
366
+ const p = a.url.split("/_hmr/")[1], g = a.headers["sec-websocket-key"], h = i("sha1").update(g + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
367
+ r.write(
368
368
  `HTTP/1.1 101 Switching Protocols\r
369
369
  Upgrade: websocket\r
370
370
  Connection: Upgrade\r
371
371
  Sec-WebSocket-Accept: ${h}\r
372
372
  \r
373
373
  `
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);
374
+ ), ee.has(p) || ee.set(p, /* @__PURE__ */ new Set()), ee.get(p).add(r), console.log(`πŸ”Œ HMR client connected: ${p}`), r.on("close", () => {
375
+ const $ = ee.get(p);
376
+ $ && ($.delete(r), $.size === 0 && ee.delete(p)), console.log(`πŸ”Œ HMR client disconnected: ${p}`);
377
+ }), r.on("error", () => {
378
+ const $ = ee.get(p);
379
+ $ && $.delete(r);
380
380
  });
381
381
  }
382
- }, $e = n.default.createServer((a, i) => {
383
- if (i.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
384
- let l = "";
385
- a.on("data", (c) => l += c), a.on("end", () => {
382
+ }, Ce = n.default.createServer((a, r) => {
383
+ if (r.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
384
+ let c = "";
385
+ a.on("data", (p) => c += p), a.on("end", () => {
386
386
  try {
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
- id: J,
393
- path: Z.path,
394
- name: Z.name
387
+ const { componentId: p, distPath: g, componentName: h, htmlFile: $ } = JSON.parse(c);
388
+ I.set(p, { path: g, name: h || null, htmlFile: $ || null });
389
+ const O = h ? ` (${h})` : "";
390
+ console.log(`βœ… Registered: ${p}${O} -> ${g}${$ ? "/" + $ : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(I.keys()) }));
391
+ const L = Array.from(I.entries()).map(([V, te]) => ({
392
+ id: V,
393
+ path: te.path,
394
+ name: te.name
395
395
  }));
396
- K.forEach((J) => {
396
+ Y.forEach((V) => {
397
397
  try {
398
- J.write(`data: ${JSON.stringify({
398
+ V.write(`data: ${JSON.stringify({
399
399
  type: "components",
400
- components: N
400
+ components: L
401
401
  })}
402
402
 
403
403
  `);
404
404
  } catch {
405
405
  }
406
406
  });
407
- } catch (c) {
408
- i.writeHead(400), i.end(JSON.stringify({ error: c.message }));
407
+ } catch (p) {
408
+ r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
409
409
  }
410
410
  });
411
411
  } else if (a.method === "POST" && a.url === "/_unregister") {
412
- let l = "";
413
- a.on("data", (c) => l += c), a.on("end", () => {
412
+ let c = "";
413
+ a.on("data", (p) => c += p), a.on("end", () => {
414
414
  try {
415
- const { componentId: c } = JSON.parse(l);
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]) => ({
415
+ const { componentId: p } = JSON.parse(c);
416
+ I.delete(p), console.log(`❌ Unregistered: ${p}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
417
+ const g = Array.from(I.entries()).map(([h, $]) => ({
418
418
  id: h,
419
- path: w.path,
420
- name: w.name
419
+ path: $.path,
420
+ name: $.name
421
421
  }));
422
- K.forEach((h) => {
422
+ Y.forEach((h) => {
423
423
  try {
424
424
  h.write(`data: ${JSON.stringify({
425
425
  type: "components",
426
- components: m
426
+ components: g
427
427
  })}
428
428
 
429
429
  `);
430
430
  } catch {
431
431
  }
432
432
  });
433
- } catch (c) {
434
- i.writeHead(400), i.end(JSON.stringify({ error: c.message }));
433
+ } catch (p) {
434
+ r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
435
435
  }
436
436
  });
437
437
  } else if (a.method === "GET" && a.url === "/_list")
438
- i.writeHead(200), i.end(JSON.stringify({ components: Array.from(T.entries()) }));
438
+ r.writeHead(200), r.end(JSON.stringify({ components: Array.from(I.entries()) }));
439
439
  else if (a.method === "POST" && a.url === "/_hmr_notify") {
440
- let l = "";
441
- a.on("data", (c) => l += c), a.on("end", () => {
440
+ let c = "";
441
+ a.on("data", (p) => c += p), a.on("end", () => {
442
442
  try {
443
- const { componentId: c, html: m } = JSON.parse(l), h = Q.get(c);
443
+ const { componentId: p, html: g } = JSON.parse(c), h = ee.get(p);
444
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) => {
445
+ console.log(`πŸ”₯ Notifying ${h.size} HMR client(s) for: ${p}`);
446
+ const $ = JSON.stringify({ type: "update", html: g }), O = Je($);
447
+ h.forEach((L) => {
448
448
  try {
449
- N.write(R);
449
+ L.write(O);
450
450
  } catch {
451
- h.delete(N);
451
+ h.delete(L);
452
452
  }
453
- }), i.writeHead(200), i.end(JSON.stringify({ success: !0, notified: h.size }));
453
+ }), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: h.size }));
454
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 }));
455
+ r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: 0 }));
456
+ } catch (p) {
457
+ r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
458
458
  }
459
459
  });
460
460
  } else
461
- i.writeHead(404), i.end(JSON.stringify({ error: "Not found" }));
462
- }), de = n.default.createServer((a, i) => {
461
+ r.writeHead(404), r.end(JSON.stringify({ error: "Not found" }));
462
+ }), ue = n.default.createServer((a, r) => {
463
463
  if (a.url.includes("..")) {
464
- i.writeHead(403, { "Content-Type": "text/plain" }), i.end("Forbidden");
464
+ r.writeHead(403, { "Content-Type": "text/plain" }), r.end("Forbidden");
465
465
  return;
466
466
  }
467
- const l = new URL(a.url, `http://localhost:${u}`), c = l.pathname, m = c.split("/").filter((A) => A);
468
- if (c.startsWith("/consume")) {
469
- const A = l.searchParams.get("id");
470
- if (!A) {
471
- i.writeHead(400, { "Content-Type": "application/json" }), i.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
467
+ const c = new URL(a.url, `http://localhost:${m}`), p = c.pathname, g = p.split("/").filter((J) => J);
468
+ if (p.startsWith("/consume")) {
469
+ const J = c.searchParams.get("id");
470
+ if (!J) {
471
+ r.writeHead(400, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
472
472
  return;
473
473
  }
474
- const B = T.get(A), z = B ? B.path : null, re = (X) => {
475
- let j = "Unknown", W = "Unknown";
474
+ const W = I.get(J), K = W ? W.path : null, ce = (oe) => {
475
+ let N = "Unknown", Q = "Unknown";
476
476
  if (a.headers.referer || a.headers.referrer) {
477
- const _ = a.headers.referer || a.headers.referrer;
477
+ const A = a.headers.referer || a.headers.referrer;
478
478
  try {
479
- const ne = new URL(_);
480
- j = ne.origin, W = ne.hostname || ne.origin;
479
+ const re = new URL(A);
480
+ N = re.origin, Q = re.hostname || re.origin;
481
481
  } catch {
482
- j = _, W = _;
482
+ N = A, Q = A;
483
483
  }
484
484
  } else if (a.headers.origin)
485
485
  try {
486
- const _ = new URL(a.headers.origin);
487
- j = _.origin, W = _.hostname || _.origin;
486
+ const A = new URL(a.headers.origin);
487
+ N = A.origin, Q = A.hostname || A.origin;
488
488
  } catch {
489
- j = a.headers.origin, W = a.headers.origin;
489
+ N = a.headers.origin, Q = a.headers.origin;
490
490
  }
491
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:", ""));
492
+ const A = a.socket.remoteAddress;
493
+ A === "::1" || A === "::ffff:127.0.0.1" ? (N = "localhost", Q = "localhost (direct)") : (N = A, Q = A.replace("::ffff:", ""));
494
494
  }
495
- const Te = a.headers.referer || a.headers.referrer || j, ue = {
495
+ const Ee = a.headers.referer || a.headers.referrer || N, he = {
496
496
  type: "request",
497
- componentId: A,
497
+ componentId: J,
498
498
  timestamp: Date.now(),
499
- servedLocally: X,
500
- referrer: Te,
501
- origin: j,
502
- originLabel: W
499
+ servedLocally: oe,
500
+ referrer: Ee,
501
+ origin: N,
502
+ originLabel: Q
503
503
  };
504
- oe.has(j) || (oe.set(j, {
505
- url: j,
506
- label: W,
504
+ ie.has(N) || (ie.set(N, {
505
+ url: N,
506
+ label: Q,
507
507
  firstSeen: Date.now(),
508
508
  requestCount: 0
509
- }), K.forEach((_) => {
509
+ }), Y.forEach((A) => {
510
510
  try {
511
- _.write(`data: ${JSON.stringify({
511
+ A.write(`data: ${JSON.stringify({
512
512
  type: "origins",
513
- origins: Array.from(oe.values())
513
+ origins: Array.from(ie.values())
514
514
  })}
515
515
 
516
516
  `);
517
517
  } catch {
518
518
  }
519
519
  }));
520
- const Oe = oe.get(j);
521
- Oe.requestCount++, K.forEach((_) => {
520
+ const Ie = ie.get(N);
521
+ Ie.requestCount++, Y.forEach((A) => {
522
522
  try {
523
- _.write(`data: ${JSON.stringify({
523
+ A.write(`data: ${JSON.stringify({
524
524
  type: "origins",
525
- origins: Array.from(oe.values())
525
+ origins: Array.from(ie.values())
526
526
  })}
527
527
 
528
528
  `);
529
529
  } catch {
530
530
  }
531
- }), Y.push(ue), Y.length > xe && Y.shift(), K.forEach((_) => {
531
+ }), Z.push(he), Z.length > se && Z.shift(), Y.forEach((A) => {
532
532
  try {
533
- _.write(`data: ${JSON.stringify(ue)}
533
+ A.write(`data: ${JSON.stringify(he)}
534
534
 
535
535
  `);
536
536
  } catch {
537
537
  }
538
538
  });
539
539
  };
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) => {
543
- if (j) {
544
- console.log(`❌ File not found: ${X}`), i.writeHead(404, { "Content-Type": "application/json" }), i.end(JSON.stringify({ error: "index.html not found" }));
540
+ if (K) {
541
+ const oe = W.htmlFile ? e.default.join(K, W.htmlFile) : e.default.join(K, "index.html");
542
+ o.default.readFile(oe, "utf-8", (N, Q) => {
543
+ if (N) {
544
+ console.log(`❌ File not found: ${oe}`), r.writeHead(404, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "index.html not found" }));
545
545
  return;
546
546
  }
547
- const Te = Ce(W, A), ue = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Oe = {
547
+ const Ee = Me(Q, J), he = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Ie = {
548
548
  item: {
549
- name: A,
550
- id: A,
549
+ name: J,
550
+ id: J,
551
551
  consume_variant: [
552
552
  {
553
- id: ue,
553
+ id: he,
554
554
  name: "dev version",
555
555
  loader: {
556
556
  type: "HTMLLoader",
557
557
  shadowRootMode: "localFrame",
558
- HTML: Te
558
+ HTML: Ee
559
559
  }
560
560
  }
561
561
  ]
562
562
  }
563
563
  };
564
- console.log(`βœ… Serving consume JSON for: ${A}`), re(!0), i.writeHead(200, {
564
+ console.log(`βœ… Serving consume JSON for: ${J}`), ce(!0), r.writeHead(200, {
565
565
  "Content-Type": "application/json",
566
566
  "Access-Control-Allow-Origin": "*"
567
- }), i.end(JSON.stringify(Oe, null, 2));
567
+ }), r.end(JSON.stringify(Ie, null, 2));
568
568
  });
569
569
  } else {
570
- console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${A}`);
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, {
570
+ console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${J}`);
571
+ const oe = `https://cloud.myop.dev/consume${c.search}`;
572
+ ce(!1), fetch(oe).then((N) => N.text()).then((N) => {
573
+ r.writeHead(200, {
574
574
  "Content-Type": "application/json",
575
575
  "Access-Control-Allow-Origin": "*"
576
- }), i.end(j);
577
- }).catch((j) => {
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" }));
576
+ }), r.end(N);
577
+ }).catch((N) => {
578
+ console.error(`❌ Proxy error: ${N.message}`), r.writeHead(502, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
579
579
  });
580
580
  }
581
581
  return;
582
582
  }
583
- if (c === "/events") {
584
- i.writeHead(200, {
583
+ if (p === "/events") {
584
+ r.writeHead(200, {
585
585
  "Content-Type": "text/event-stream",
586
586
  "Cache-Control": "no-cache",
587
587
  Connection: "keep-alive",
588
588
  "Access-Control-Allow-Origin": "*"
589
- }), K.push(i);
590
- const A = Array.from(T.entries()).map(([B, z]) => ({
591
- id: B,
592
- path: z.path,
593
- name: z.name
589
+ }), Y.push(r);
590
+ const J = Array.from(I.entries()).map(([W, K]) => ({
591
+ id: W,
592
+ path: K.path,
593
+ name: K.name
594
594
  }));
595
- i.write(`data: ${JSON.stringify({
595
+ r.write(`data: ${JSON.stringify({
596
596
  type: "components",
597
- components: A
597
+ components: J
598
598
  })}
599
599
 
600
- `), i.write(`data: ${JSON.stringify({
600
+ `), r.write(`data: ${JSON.stringify({
601
601
  type: "origins",
602
- origins: Array.from(oe.values())
602
+ origins: Array.from(ie.values())
603
603
  })}
604
604
 
605
- `), i.write(`data: ${JSON.stringify({
605
+ `), r.write(`data: ${JSON.stringify({
606
606
  type: "requestLog",
607
- log: Y
607
+ log: Z
608
608
  })}
609
609
 
610
610
  `), a.on("close", () => {
611
- const B = K.indexOf(i);
612
- B !== -1 && K.splice(B, 1);
611
+ const W = Y.indexOf(r);
612
+ W !== -1 && Y.splice(W, 1);
613
613
  });
614
614
  return;
615
615
  }
616
- if (m.length === 0) {
617
- i.writeHead(200, { "Content-Type": "text/html" }), i.end($t(u, p, v, M));
616
+ if (g.length === 0) {
617
+ r.writeHead(200, { "Content-Type": "text/html" }), r.end(It(m, d, w, v));
618
618
  return;
619
619
  }
620
- if (m[0] !== "view") {
621
- i.writeHead(404, { "Content-Type": "text/plain" }), i.end("Not found. Use /view/<componentId>/ to access components.");
620
+ if (g[0] !== "view") {
621
+ r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not found. Use /view/<componentId>/ to access components.");
622
622
  return;
623
623
  }
624
- if (m.length < 2) {
625
- i.writeHead(400, { "Content-Type": "text/plain" }), i.end("Component ID required. Use /view/<componentId>/");
624
+ if (g.length < 2) {
625
+ r.writeHead(400, { "Content-Type": "text/plain" }), r.end("Component ID required. Use /view/<componentId>/");
626
626
  return;
627
627
  }
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}`);
628
+ const h = g[1], $ = I.get(h);
629
+ if (!$) {
630
+ r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${h}`);
631
631
  return;
632
632
  }
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) => {
635
- if (A) {
636
- console.log(`❌ File not found: ${ie}`), i.writeHead(404, { "Content-Type": "text/plain" }), i.end("Not Found");
633
+ const O = $.path, L = g.slice(2), V = $.htmlFile || "index.html", te = L.length === 0 ? V : L.join("/"), le = e.default.join(O, te);
634
+ console.log(`πŸ“₯ Request: ${a.url} -> ${le}`), o.default.readFile(le, (J, W) => {
635
+ if (J) {
636
+ console.log(`❌ File not found: ${le}`), r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not Found");
637
637
  return;
638
638
  }
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);
639
+ const K = z(le);
640
+ console.log(`βœ… Serving: ${le} (${K})`);
641
+ let ce = W;
642
+ if (K === "text/html" && _) {
643
+ const oe = W.toString("utf-8");
644
+ ce = Me(oe, h);
645
645
  }
646
- i.writeHead(200, {
647
- "Content-Type": z,
646
+ r.writeHead(200, {
647
+ "Content-Type": K,
648
648
  "Access-Control-Allow-Origin": "*"
649
- }), i.end(re);
649
+ }), r.end(ce);
650
650
  });
651
- }), Ae = () => new Promise((a, i) => {
652
- const l = x ? e.default.resolve(F) : e.default.resolve(F, S), c = JSON.stringify({
653
- componentId: C,
654
- distPath: l,
655
- componentName: I,
656
- htmlFile: x ? $ : null
657
- }), m = {
651
+ }), Ue = () => new Promise((a, r) => {
652
+ const c = M ? e.default.resolve(k) : e.default.resolve(k, C), p = JSON.stringify({
653
+ componentId: f,
654
+ distPath: c,
655
+ componentName: E,
656
+ htmlFile: M ? T : null
657
+ }), g = {
658
658
  hostname: "localhost",
659
- port: p,
659
+ port: d,
660
660
  path: "/_register",
661
661
  method: "POST",
662
662
  headers: {
663
663
  "Content-Type": "application/json",
664
- "Content-Length": Buffer.byteLength(c)
664
+ "Content-Length": Buffer.byteLength(p)
665
665
  }
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}`));
666
+ }, h = n.default.request(g, ($) => {
667
+ let O = "";
668
+ $.on("data", (L) => O += L), $.on("end", () => {
669
+ $.statusCode === 200 ? a(JSON.parse(O)) : r(new Error(`Registration failed: ${$.statusCode}`));
670
670
  });
671
671
  });
672
- h.on("error", i), h.write(c), h.end();
673
- }), nt = () => new Promise((a, i) => {
674
- const l = JSON.stringify({ componentId: C }), c = {
672
+ h.on("error", r), h.write(p), h.end();
673
+ }), ct = () => new Promise((a, r) => {
674
+ const c = JSON.stringify({ componentId: f }), p = {
675
675
  hostname: "localhost",
676
- port: p,
676
+ port: d,
677
677
  path: "/_unregister",
678
678
  method: "POST",
679
679
  headers: {
680
680
  "Content-Type": "application/json",
681
- "Content-Length": Buffer.byteLength(l)
681
+ "Content-Length": Buffer.byteLength(c)
682
682
  }
683
- }, m = n.default.request(c, (h) => {
683
+ }, g = n.default.request(p, (h) => {
684
684
  a();
685
685
  });
686
- m.on("error", () => a()), m.write(l), m.end();
687
- }), st = (a) => `
686
+ g.on("error", () => a()), g.write(c), g.end();
687
+ }), dt = (a) => `
688
688
  <!-- MYOP HMR -->
689
689
  <script>
690
690
  (function() {
691
691
  const componentId = '${a}';
692
- const wsUrl = 'ws://localhost:${p}/_hmr/' + componentId;
692
+ const wsUrl = 'ws://localhost:${d}/_hmr/' + componentId;
693
693
  let ws;
694
694
  let reconnectAttempts = 0;
695
695
  const maxReconnectAttempts = 10;
@@ -789,251 +789,251 @@ Sec-WebSocket-Accept: ${h}\r
789
789
  connect();
790
790
  })();
791
791
  <\/script>
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;
798
- let c;
799
- return l < 126 ? c = Buffer.concat([
800
- Buffer.from([129, l]),
792
+ `, Me = (a, r) => {
793
+ if (!_) return a;
794
+ const c = dt(r);
795
+ return a.includes("</body>") ? a.replace("</body>", `${c}</body>`) : a.includes("</html>") ? a.replace("</html>", `${c}</html>`) : a + c;
796
+ }, Je = (a) => {
797
+ const r = Buffer.from(a), c = r.length;
798
+ let p;
799
+ return c < 126 ? p = Buffer.concat([
800
+ Buffer.from([129, c]),
801
801
  // FIN + text frame, length
802
- i
803
- ]) : l < 65536 ? c = Buffer.concat([
802
+ r
803
+ ]) : c < 65536 ? p = Buffer.concat([
804
804
  Buffer.from([129, 126]),
805
805
  // FIN + text frame, extended length
806
- Buffer.from([l >> 8, l & 255]),
806
+ Buffer.from([c >> 8, c & 255]),
807
807
  // 16-bit length
808
- i
809
- ]) : c = Buffer.concat([
808
+ r
809
+ ]) : p = Buffer.concat([
810
810
  Buffer.from([129, 127]),
811
811
  // FIN + text frame, extended length
812
- Buffer.from([0, 0, 0, 0, l >> 24, l >> 16 & 255, l >> 8 & 255, l & 255]),
812
+ Buffer.from([0, 0, 0, 0, c >> 24, c >> 16 & 255, c >> 8 & 255, c & 255]),
813
813
  // 64-bit length
814
- i
815
- ]), c;
816
- }, De = () => {
817
- if (!k) return;
818
- const a = x ? $ : e.default.join(S, "index.html");
819
- let i;
814
+ r
815
+ ]), p;
816
+ }, Be = () => {
817
+ if (!_) return;
818
+ const a = M ? T : e.default.join(C, "index.html");
819
+ let r;
820
820
  try {
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);
821
+ const c = o.default.readFileSync(a, "utf-8");
822
+ r = Me(c, f);
823
+ } catch (c) {
824
+ console.error("❌ Failed to read HTML for HMR:", c.message);
825
825
  return;
826
826
  }
827
827
  if (Re) {
828
- const l = Q.get(C);
829
- if (!l || l.size === 0)
828
+ const c = ee.get(f);
829
+ if (!c || c.size === 0)
830
830
  return;
831
- console.log(`πŸ”₯ Notifying ${l.size} HMR client(s)`);
832
- const c = JSON.stringify({
831
+ console.log(`πŸ”₯ Notifying ${c.size} HMR client(s)`);
832
+ const p = JSON.stringify({
833
833
  type: "update",
834
- html: i
835
- }), m = He(c);
836
- l.forEach((h) => {
834
+ html: r
835
+ }), g = Je(p);
836
+ c.forEach((h) => {
837
837
  try {
838
- h.write(m);
838
+ h.write(g);
839
839
  } catch {
840
- l.delete(h);
840
+ c.delete(h);
841
841
  }
842
842
  });
843
843
  } else {
844
- const l = JSON.stringify({
845
- componentId: C,
846
- html: i
847
- }), c = {
844
+ const c = JSON.stringify({
845
+ componentId: f,
846
+ html: r
847
+ }), p = {
848
848
  hostname: "localhost",
849
- port: p,
849
+ port: d,
850
850
  path: "/_hmr_notify",
851
851
  method: "POST",
852
852
  headers: {
853
853
  "Content-Type": "application/json",
854
- "Content-Length": Buffer.byteLength(l)
854
+ "Content-Length": Buffer.byteLength(c)
855
855
  },
856
856
  timeout: 5e3
857
- }, m = n.default.request(c, (h) => {
858
- let w = "";
859
- h.on("data", (R) => w += R), h.on("end", () => {
857
+ }, g = n.default.request(p, (h) => {
858
+ let $ = "";
859
+ h.on("data", (O) => $ += O), h.on("end", () => {
860
860
  try {
861
- const R = JSON.parse(w);
862
- R.notified > 0 && console.log(`πŸ”₯ Notified ${R.notified} HMR client(s) via server`);
861
+ const O = JSON.parse($);
862
+ O.notified > 0 && console.log(`πŸ”₯ Notified ${O.notified} HMR client(s) via server`);
863
863
  } catch {
864
864
  }
865
865
  });
866
866
  });
867
- m.on("error", () => {
868
- }), m.on("timeout", () => {
869
- m.destroy();
870
- }), m.write(l), m.end();
867
+ g.on("error", () => {
868
+ }), g.on("timeout", () => {
869
+ g.destroy();
870
+ }), g.write(c), g.end();
871
871
  }
872
872
  };
873
- let Me = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
- const pe = (a) => {
875
- if (f) {
876
- b = !0;
873
+ let Pe = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
+ const ge = (a) => {
875
+ if (u) {
876
+ S = !0;
877
877
  return;
878
878
  }
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)
879
+ u = !0, console.log(`
880
+ πŸ”¨ Building...`), t("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, c, p) => {
881
+ if (u = !1, r) {
882
+ const g = await et(r, c, p, t, {
883
+ ...Pe,
884
+ onRetry: () => ge(a)
885
885
  });
886
- Me = { ...Me, ...m }, m.handled || (console.error("❌ Build failed:", i.message), c && console.error(c));
886
+ Pe = { ...Pe, ...g }, g.handled || (console.error("❌ Build failed:", r.message), p && console.error(p));
887
887
  } else
888
- console.log("βœ… Build completed"), l && console.log(l), De(), a && a();
889
- b && (b = !1, pe());
888
+ console.log("βœ… Build completed"), c && console.log(c), Be(), a && a();
889
+ S && (S = !1, ge());
890
890
  });
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);
895
- if (c.isDirectory())
896
- c.name !== "node_modules" && c.name !== "dist" && !c.name.startsWith(".") && Pe(m);
897
- else if (c.isFile()) {
898
- const h = e.default.extname(c.name);
891
+ }, ze = /* @__PURE__ */ new Set(), Te = (a) => {
892
+ o.default.readdir(a, { withFileTypes: !0 }, (r, c) => {
893
+ r || (c.forEach((p) => {
894
+ const g = e.default.join(a, p.name);
895
+ if (p.isDirectory())
896
+ p.name !== "node_modules" && p.name !== "dist" && !p.name.startsWith(".") && Te(g);
897
+ else if (p.isFile()) {
898
+ const h = e.default.extname(p.name);
899
899
  if (h === ".js" || h === ".css" || h === ".html")
900
900
  try {
901
- const w = o.default.readFileSync(m, "utf-8");
902
- P.set(m, w);
901
+ const $ = o.default.readFileSync(g, "utf-8");
902
+ j.set(g, $);
903
903
  } catch {
904
904
  }
905
905
  }
906
- }), Ue.has(a) || (Ue.add(a), o.default.watch(a, (c, m) => {
907
- if (!m) return;
908
- const h = e.default.extname(m);
906
+ }), ze.has(a) || (ze.add(a), o.default.watch(a, (p, g) => {
907
+ if (!g) return;
908
+ const h = e.default.extname(g);
909
909
  if (h !== ".js" && h !== ".css" && h !== ".html") return;
910
- const w = e.default.join(a, m);
910
+ const $ = e.default.join(a, g);
911
911
  setTimeout(() => {
912
912
  try {
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());
913
+ const O = o.default.readFileSync($, "utf-8"), L = j.get($);
914
+ O !== L && (j.set($, O), console.log(`πŸ“ File changed: ${$}`), M ? Be() : ge());
915
915
  } catch {
916
916
  }
917
917
  }, 50);
918
918
  })));
919
919
  });
920
- }, Be = (a) => {
920
+ }, We = (a) => {
921
921
  console.log(`
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
922
+ πŸ”¨ Component: ${f}`), M ? (console.log("πŸ“„ No build needed (single HTML file mode)"), Te(k), console.log(`πŸ‘€ Watching ${T} for changes...`), console.log(`Press Ctrl+C to stop
923
+ `), a && a()) : (ge(a), Te(k), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
924
924
  `));
925
- }, it = () => new Promise((a) => {
926
- const i = {
925
+ }, pt = () => new Promise((a) => {
926
+ const r = {
927
927
  hostname: "localhost",
928
- port: p,
928
+ port: d,
929
929
  path: "/_list",
930
930
  method: "GET",
931
931
  timeout: 1e3
932
- }, l = n.default.request(i, (c) => {
932
+ }, c = n.default.request(r, (p) => {
933
933
  a(!0);
934
934
  });
935
- l.on("error", () => a(!1)), l.on("timeout", () => {
936
- l.destroy(), a(!1);
937
- }), l.end();
938
- }), rt = () => new Promise((a) => {
939
- const i = n.default.createServer((l, c) => {
940
- if (c.setHeader("Content-Type", "application/json"), l.method === "POST" && l.url === "/_register") {
941
- let m = "";
942
- l.on("data", (h) => m += h), l.on("end", () => {
935
+ c.on("error", () => a(!1)), c.on("timeout", () => {
936
+ c.destroy(), a(!1);
937
+ }), c.end();
938
+ }), mt = () => new Promise((a) => {
939
+ const r = n.default.createServer((c, p) => {
940
+ if (p.setHeader("Content-Type", "application/json"), c.method === "POST" && c.url === "/_register") {
941
+ let g = "";
942
+ c.on("data", (h) => g += h), c.on("end", () => {
943
943
  try {
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()) }));
944
+ const { componentId: h, distPath: $, componentName: O, htmlFile: L } = JSON.parse(g);
945
+ I.set(h, { path: $, name: O || null, htmlFile: L || null });
946
+ const V = O ? ` (${O})` : "";
947
+ console.log(`βœ… Registered: ${h}${V} -> ${$}${L ? "/" + L : ""}`), p.writeHead(200), p.end(JSON.stringify({ success: !0, registered: Array.from(I.keys()) }));
948
948
  } catch (h) {
949
- c.writeHead(400), c.end(JSON.stringify({ error: h.message }));
949
+ p.writeHead(400), p.end(JSON.stringify({ error: h.message }));
950
950
  }
951
951
  });
952
- } else if (l.method === "POST" && l.url === "/_unregister") {
953
- let m = "";
954
- l.on("data", (h) => m += h), l.on("end", () => {
952
+ } else if (c.method === "POST" && c.url === "/_unregister") {
953
+ let g = "";
954
+ c.on("data", (h) => g += h), c.on("end", () => {
955
955
  try {
956
- const { componentId: h } = JSON.parse(m);
957
- T.delete(h), console.log(`❌ Unregistered: ${h}`), c.writeHead(200), c.end(JSON.stringify({ success: !0 }));
956
+ const { componentId: h } = JSON.parse(g);
957
+ I.delete(h), console.log(`❌ Unregistered: ${h}`), p.writeHead(200), p.end(JSON.stringify({ success: !0 }));
958
958
  } catch (h) {
959
- c.writeHead(400), c.end(JSON.stringify({ error: h.message }));
959
+ p.writeHead(400), p.end(JSON.stringify({ error: h.message }));
960
960
  }
961
961
  });
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" })));
962
+ } else c.method === "GET" && c.url === "/_list" ? (p.writeHead(200), p.end(JSON.stringify({ components: Array.from(I.entries()) }))) : (p.writeHead(404), p.end(JSON.stringify({ error: "Not found" })));
963
963
  });
964
- i.on("error", () => {
964
+ r.on("error", () => {
965
965
  a(!1);
966
- }), i.listen(p, () => {
966
+ }), r.listen(d, () => {
967
967
  console.log(`
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, {
974
- path: l,
975
- name: I,
976
- htmlFile: x ? $ : null
968
+ πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${d}`), ue.on("error", () => {
969
+ r.close(), a(!1);
970
+ }), ue.listen(m, () => {
971
+ console.log(`πŸ“‘ Main server running at http://localhost:${m}`);
972
+ const c = M ? e.default.resolve(k) : e.default.resolve(k, C);
973
+ I.set(f, {
974
+ path: c,
975
+ name: E,
976
+ htmlFile: M ? T : null
977
977
  });
978
- const c = I ? ` (${I})` : "";
979
- console.log(`βœ… Registered component: ${C}${c}`), console.log(`πŸ“‘ Access at: http://localhost:${u}/view/${C}/`), a(!0);
978
+ const p = E ? ` (${E})` : "";
979
+ console.log(`βœ… Registered component: ${f}${p}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), a(!0);
980
980
  });
981
981
  });
982
982
  });
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 () => {
983
+ let fe;
984
+ const Ve = () => {
985
+ fe = setInterval(async () => {
986
+ await pt() || (clearInterval(fe), console.log(`
987
+ ⚠️ Server appears to be down, attempting to take over...`), await mt() ? (console.log("βœ… Successfully took over as server"), Re = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
988
988
  try {
989
- await Ae(), console.log(`βœ… Re-registered component: ${C}`), Je();
990
- } catch (l) {
991
- console.error("❌ Failed to re-register:", l.message);
989
+ await Ue(), console.log(`βœ… Re-registered component: ${f}`), Ve();
990
+ } catch (c) {
991
+ console.error("❌ Failed to re-register:", c.message);
992
992
  }
993
993
  }, 2e3)));
994
994
  }, 3e3);
995
- }, ze = async () => {
995
+ }, Ge = async () => {
996
996
  console.log(`
997
997
 
998
- πŸ›‘ Shutting down...`), me && clearInterval(me), await nt(), process.exit(0);
998
+ πŸ›‘ Shutting down...`), fe && clearInterval(fe), await ct(), process.exit(0);
999
999
  };
1000
- process.on("SIGINT", ze), process.on("SIGTERM", ze);
1000
+ process.on("SIGINT", Ge), process.on("SIGTERM", Ge);
1001
1001
  let Re = !1;
1002
- $e.on("error", async (a) => {
1002
+ Ce.on("error", async (a) => {
1003
1003
  if (a.code === "EADDRINUSE") {
1004
1004
  console.log(`
1005
1005
  πŸ”— Connecting to existing dev server...`);
1006
1006
  try {
1007
- C = await U();
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);
1007
+ f = await U();
1008
+ const r = await Ue();
1009
+ console.log(`βœ… Registered component: ${f}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), console.log(`πŸ“‹ All registered components: ${r.registered.join(", ")}`), We(() => {
1010
+ process.env.MYOP_NO_BROWSER || x(`http://localhost:${m}/view/${f}/`);
1011
+ }), Ve();
1012
+ } catch (r) {
1013
+ console.error("❌ Failed to register component:", r.message), process.exit(1);
1014
1014
  }
1015
1015
  } else
1016
1016
  console.error("❌ Management server error:", a.message), process.exit(1);
1017
- }), $e.on("upgrade", ot), $e.listen(p, async () => {
1017
+ }), Ce.on("upgrade", lt), Ce.listen(d, async () => {
1018
1018
  Re = !0, console.log(`
1019
- πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${p}`), de.on("error", (a) => {
1019
+ πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${d}`), ue.on("error", (a) => {
1020
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, {
1021
+ }), ue.listen(m, async () => {
1022
+ console.log(`πŸ“‘ Main server running at http://localhost:${m}`), (f === "DEV" || f === "NEW") && (f = "DEV1");
1023
+ const a = M ? e.default.resolve(k) : e.default.resolve(k, C);
1024
+ I.set(f, {
1025
1025
  path: a,
1026
- name: I,
1027
- htmlFile: x ? $ : null
1026
+ name: E,
1027
+ htmlFile: M ? T : null
1028
1028
  });
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}/`);
1029
+ const r = E ? ` (${E})` : "";
1030
+ console.log(`βœ… Registered component: ${f}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), We(() => {
1031
+ process.env.MYOP_NO_BROWSER || x(`http://localhost:${m}/view/${f}/`);
1032
1032
  });
1033
1033
  });
1034
1034
  });
1035
1035
  }
1036
- const O = class O {
1036
+ const F = class F {
1037
1037
  constructor(e) {
1038
1038
  this.components = e.map(
1039
1039
  (t) => typeof t == "string" ? { name: t, path: "", id: "" } : t
@@ -1042,7 +1042,7 @@ const O = class O {
1042
1042
  this.logs.set(t.name, []), this.scrollPos.set(t.name, 0), this.statuses.set(t.name, "Initializing..."), this.statusKeys.set(t.name, "initializing");
1043
1043
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
1044
1044
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, this.needsFullRedraw = !0, this.calculateLayout(), this.render();
1045
- }), this.setupKeyboardInput(), process.stdout.write(O.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1045
+ }), this.setupKeyboardInput(), process.stdout.write(F.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1046
1046
  }
1047
1047
  setupKeyboardInput() {
1048
1048
  process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (e) => {
@@ -1073,8 +1073,8 @@ const O = class O {
1073
1073
  this.scrollPos.set(t, 0), this.queueUpdate(t);
1074
1074
  break;
1075
1075
  case "G":
1076
- const r = this.logs.get(t) || [];
1077
- this.scrollPos.set(t, Math.max(0, r.length - this.visibleLogLines)), this.queueUpdate(t);
1076
+ const i = this.logs.get(t) || [];
1077
+ this.scrollPos.set(t, Math.max(0, i.length - this.visibleLogLines)), this.queueUpdate(t);
1078
1078
  break;
1079
1079
  }
1080
1080
  }));
@@ -1083,35 +1083,35 @@ const O = class O {
1083
1083
  const e = this.components.length, t = 38;
1084
1084
  let n;
1085
1085
  this.cols >= t * 3 + 4 ? n = Math.min(e, 3) : this.cols >= t * 2 + 2 ? n = Math.min(e, 2) : n = 1;
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();
1088
- for (let p = 0; p < e; p++) {
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,
1086
+ const i = Math.ceil(e / n), s = Math.floor(this.cols / n), l = 2, v = this.rows - l - 2, m = Math.floor(v / i);
1087
+ this.visibleLogLines = Math.max(2, m - 4), this.layout = { panelsPerRow: n, panelWidth: s, numRows: i, panelHeight: m }, this.panelPositions.clear();
1088
+ for (let d = 0; d < e; d++) {
1089
+ const C = this.components[d], u = Math.floor(d / n), S = d % n;
1090
+ this.panelPositions.set(C.name, {
1091
+ row: l + 1 + u * m,
1092
+ col: S * s + 1,
1093
1093
  width: s,
1094
- height: u
1094
+ height: m
1095
1095
  });
1096
1096
  }
1097
1097
  }
1098
1098
  log(e, t, n = "info") {
1099
- const r = this.logs.get(e) || [], s = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
1099
+ const i = this.logs.get(e) || [], s = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
1100
1100
  hour12: !1,
1101
1101
  hour: "2-digit",
1102
1102
  minute: "2-digit",
1103
1103
  second: "2-digit"
1104
1104
  });
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);
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"), 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);
1106
1106
  }
1107
1107
  setStatus(e, t) {
1108
1108
  let n = "ready";
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);
1109
+ const i = t.toLowerCase();
1110
+ 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);
1111
1111
  }
1112
1112
  scroll(e, t) {
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));
1113
+ const n = this.logs.get(e) || [], i = this.scrollPos.get(e) || 0, s = Math.max(0, n.length - this.visibleLogLines), l = Math.max(0, Math.min(s, i + t));
1114
+ l !== i && (this.scrollPos.set(e, l), this.queueUpdate(e));
1115
1115
  }
1116
1116
  queueUpdate(e) {
1117
1117
  this.pendingUpdates.add(e), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
@@ -1132,71 +1132,71 @@ const O = class O {
1132
1132
  return `${t}:${n.toString().padStart(2, "0")}`;
1133
1133
  }
1134
1134
  updateHeader() {
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);
1135
+ const e = F.C, t = Array.from(this.statusKeys.values()).filter((s) => s === "ready").length, n = this.components.length;
1136
+ let i = `${e.dim}πŸ“‘${e.reset} http://localhost:9292 ${e.gray}|${e.reset} `;
1137
+ 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 += F.ESC.clearLine.slice(0, -1), process.stdout.write(F.ESC.moveTo(2, 1) + i);
1138
1138
  }
1139
1139
  renderPanel(e) {
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);
1148
- let E = `${x}β”‚${t.reset} ${t.dim}${P}${t.reset}`;
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);
1140
+ const t = F.C, n = F.STATUS, i = this.panelPositions.get(e);
1141
+ if (!i) return;
1142
+ const s = this.components.findIndex((U) => U.name === e), l = this.components[s], w = s === this.selectedPanel, v = this.statusKeys.get(e) || "initializing", m = n[v], d = t[m.color], C = this.logs.get(e) || [], u = this.scrollPos.get(e) || 0, S = i.width - 1, M = w ? t.cyan : t.gray, T = [], D = l.name.substring(0, S - 20);
1143
+ let P = `${M}β”Œβ”€${t.reset} ${d}${m.icon}${t.reset} `;
1144
+ P += `${t.bold}${D}${t.reset} ${t.gray}─${t.reset} ${d}${m.label}${t.reset} `;
1145
+ const x = 5 + D.length + m.label.length + 3;
1146
+ P += `${M}${"─".repeat(Math.max(0, S - x))}┐${t.reset}`, T.push(F.ESC.moveTo(i.row, i.col) + P);
1147
+ const j = (l.path || "").substring(0, S - 6);
1148
+ let b = `${M}β”‚${t.reset} ${t.dim}${j}${t.reset}`;
1149
+ b += " ".repeat(Math.max(0, S - j.length - 3)), b += `${M}β”‚${t.reset}`, T.push(F.ESC.moveTo(i.row + 1, i.col) + b);
1150
+ const f = C.length, E = f > this.visibleLogLines ? `${u + 1}-${Math.min(u + this.visibleLogLines, f)}/${f}` : "";
1151
+ let _ = `${M}β”œ${"─".repeat(S - E.length - 4)}${t.reset}`;
1152
+ E && (_ += `${t.dim}${E}${t.reset}`), _ += `${M}${"─".repeat(2)}─${t.reset}`, T.push(F.ESC.moveTo(i.row + 2, i.col) + _);
1153
+ const B = C.slice(u, u + this.visibleLogLines);
1154
1154
  for (let U = 0; U < this.visibleLogLines; U++) {
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));
1155
+ const k = B[U];
1156
+ let z = `${M}β”‚${t.reset}`;
1157
+ if (k) {
1158
+ let I = t.white;
1159
+ k.type === "success" ? I = t.green : k.type === "error" ? I = t.red : k.type === "warning" ? I = t.yellow : k.type === "hmr" ? I = t.magenta : k.type === "change" && (I = t.blue);
1160
+ const Z = k.message.substring(0, S - 12);
1161
+ z += `${t.dim}${k.timestamp}${t.reset} ${I}${Z}${t.reset}`;
1162
+ const se = S - k.timestamp.length - Z.length - 2;
1163
+ z += " ".repeat(Math.max(0, se));
1164
1164
  } else
1165
- G += " ".repeat(b - 2);
1166
- G += `${x}β”‚${t.reset}`, $.push(O.ESC.moveTo(r.row + 3 + U, r.col) + G);
1165
+ z += " ".repeat(S - 2);
1166
+ z += `${M}β”‚${t.reset}`, T.push(F.ESC.moveTo(i.row + 3 + U, i.col) + z);
1167
1167
  }
1168
- $.push(O.ESC.moveTo(r.row + 3 + this.visibleLogLines, r.col) + `${x}β””${"─".repeat(b - 2)}β”˜${t.reset}`), process.stdout.write($.join(""));
1168
+ T.push(F.ESC.moveTo(i.row + 3 + this.visibleLogLines, i.col) + `${M}β””${"─".repeat(S - 2)}β”˜${t.reset}`), process.stdout.write(T.join(""));
1169
1169
  }
1170
1170
  fullRender() {
1171
- const e = O.C;
1172
- process.stdout.write(O.ESC.clearScreen + O.ESC.moveTo(1, 1));
1171
+ const e = F.C;
1172
+ process.stdout.write(F.ESC.clearScreen + F.ESC.moveTo(1, 1));
1173
1173
  const t = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - t.length) / 2);
1174
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();
1175
- for (const r of this.components)
1176
- this.renderPanel(r.name);
1175
+ for (const i of this.components)
1176
+ this.renderPanel(i.name);
1177
1177
  this.renderFooter();
1178
1178
  }
1179
1179
  renderFooter() {
1180
- const e = O.C, t = this.rows - 1;
1180
+ const e = F.C, t = this.rows - 1;
1181
1181
  let n = `${e.gray}`;
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);
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(F.ESC.moveTo(t, 1) + n);
1183
1183
  }
1184
1184
  render() {
1185
1185
  this.needsFullRedraw = !0, this.queueUpdate("__full__");
1186
1186
  }
1187
1187
  clear() {
1188
- this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(O.ESC.clearScreen + O.ESC.moveTo(1, 1) + O.ESC.showCursor);
1188
+ this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(F.ESC.clearScreen + F.ESC.moveTo(1, 1) + F.ESC.showCursor);
1189
1189
  }
1190
1190
  };
1191
1191
  // ANSI escape codes
1192
- fe(O, "ESC", {
1192
+ ye(F, "ESC", {
1193
1193
  moveTo: (e, t) => `\x1B[${e};${t}H`,
1194
1194
  hideCursor: "\x1B[?25l",
1195
1195
  showCursor: "\x1B[?25h",
1196
1196
  clearScreen: "\x1B[2J",
1197
1197
  clearLine: "\x1B[2K"
1198
1198
  }), // Colors
1199
- fe(O, "C", {
1199
+ ye(F, "C", {
1200
1200
  reset: "\x1B[0m",
1201
1201
  bold: "\x1B[1m",
1202
1202
  dim: "\x1B[2m",
@@ -1211,7 +1211,7 @@ fe(O, "C", {
1211
1211
  bgCyan: "\x1B[46m",
1212
1212
  black: "\x1B[30m"
1213
1213
  }), // Status configs
1214
- fe(O, "STATUS", {
1214
+ ye(F, "STATUS", {
1215
1215
  initializing: { icon: "β—”", color: "yellow", label: "Initializing" },
1216
1216
  starting: { icon: "β—‘", color: "yellow", label: "Starting" },
1217
1217
  building: { icon: "⟳", color: "yellow", label: "Building" },
@@ -1224,125 +1224,125 @@ fe(O, "STATUS", {
1224
1224
  warning: { icon: "⚠", color: "yellow", label: "Warning" },
1225
1225
  stopped: { icon: "β– ", color: "gray", label: "Stopped" }
1226
1226
  });
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) => ({
1230
- name: p.name,
1231
- path: p.path,
1232
- id: p.componentId || ""
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, () => {
1227
+ let je = F;
1228
+ async function Nt(o) {
1229
+ const { spawn: e, exec: t } = await import("child_process"), n = await import("path"), i = o.map((d) => ({
1230
+ name: d.name,
1231
+ path: d.path,
1232
+ id: d.componentId || ""
1233
+ })), s = new je(i), l = [], w = (d) => {
1234
+ const C = process.platform;
1235
+ let u;
1236
+ C === "darwin" ? u = `open "${d}"` : C === "win32" ? u = `start "" "${d}"` : u = `xdg-open "${d}"`, t(u, () => {
1237
1237
  });
1238
- }, M = () => {
1238
+ }, v = () => {
1239
1239
  s.clear(), console.log(`
1240
- πŸ›‘ Shutting down all components...`), d.forEach((p) => {
1240
+ πŸ›‘ Shutting down all components...`), l.forEach((d) => {
1241
1241
  try {
1242
- p.kill("SIGTERM");
1242
+ d.kill("SIGTERM");
1243
1243
  } catch {
1244
1244
  }
1245
1245
  }), setTimeout(() => process.exit(0), 500);
1246
1246
  };
1247
- process.on("SIGINT", M), process.on("SIGTERM", M);
1248
- const u = process.argv[1];
1249
- for (let p = 0; p < o.length; p++) {
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),
1247
+ process.on("SIGINT", v), process.on("SIGTERM", v);
1248
+ const m = process.argv[1];
1249
+ for (let d = 0; d < o.length; d++) {
1250
+ const C = o[d], u = C.name;
1251
+ s.setStatus(u, "⏳ Starting..."), s.log(u, `Starting in ${C.path}`);
1252
+ const S = e("node", [m, "dev"], {
1253
+ cwd: n.default.resolve(C.path),
1254
1254
  env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1255
1255
  stdio: ["ignore", "pipe", "pipe"]
1256
1256
  });
1257
- d.push(b);
1258
- let x = "";
1259
- b.stdout.on("data", ($) => {
1260
- x += $.toString();
1261
- const L = x.split(`
1257
+ l.push(S);
1258
+ let M = "";
1259
+ S.stdout.on("data", (T) => {
1260
+ M += T.toString();
1261
+ const D = M.split(`
1262
1262
  `);
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));
1263
+ M = D.pop() || "";
1264
+ for (const P of D) {
1265
+ const x = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
+ x && (x.includes("Registered component") || x.includes("Registered:") ? s.setStatus(u, "βœ… Ready") : x.includes("Building...") || x.includes("Running initial build") ? s.setStatus(u, "πŸ”¨ Building...") : x.includes("Build completed") || x.includes("Build succeeded") ? s.setStatus(u, "βœ… Ready") : x.includes("Build failed") ? s.setStatus(u, "❌ Build Error") : x.includes("File changed") ? (s.setStatus(u, "πŸ“ Changed"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1500)) : x.includes("Notifying") && x.includes("HMR") ? (s.setStatus(u, "πŸ”₯ HMR Update"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)) : x.includes("HMR client connected") && (s.setStatus(u, "πŸ”₯ HMR Connected"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)), !x.includes("Watching") && !x.includes("Press Ctrl+C") && !x.includes("Starting shared") && !x.includes("Management server") && !x.includes("Main server") && !x.includes("Access at:") && !x.includes("No build needed") && s.log(u, x));
1267
1267
  }
1268
- }), b.stderr.on("data", ($) => {
1269
- const L = $.toString().split(`
1268
+ }), S.stderr.on("data", (T) => {
1269
+ const D = T.toString().split(`
1270
1270
  `);
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"));
1271
+ for (const P of D) {
1272
+ const x = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
+ x && (s.log(u, `⚠️ ${x}`), s.setStatus(u, "⚠️ Warning"));
1274
1274
  }
1275
- }), b.on("exit", ($) => {
1276
- $ !== 0 && $ !== null && (s.setStatus(f, `❌ Exited (${$})`), s.log(f, `Process exited with code ${$}`));
1277
- }), p < o.length - 1 && await new Promise(($) => setTimeout($, 500));
1275
+ }), S.on("exit", (T) => {
1276
+ T !== 0 && T !== null && (s.setStatus(u, `❌ Exited (${T})`), s.log(u, `Process exited with code ${T}`));
1277
+ }), d < o.length - 1 && await new Promise((T) => setTimeout(T, 500));
1278
1278
  }
1279
1279
  s.render(), setTimeout(() => {
1280
- v("http://localhost:9292");
1280
+ w("http://localhost:9292");
1281
1281
  }, 2e3);
1282
1282
  }
1283
- const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1283
+ const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1284
1284
  __proto__: null,
1285
- devCommand: _e,
1286
- monorepoDevCommand: Tt
1287
- }, Symbol.toStringTag, { value: "Module" })), Fe = te.join(ut.homedir(), ".myop"), le = te.join(Fe, "credentials.json");
1288
- function Et() {
1289
- D.existsSync(Fe) || D.mkdirSync(Fe, { recursive: !0, mode: 448 });
1285
+ devCommand: be,
1286
+ monorepoDevCommand: Nt
1287
+ }, Symbol.toStringTag, { value: "Module" })), Ne = H.join(vt.homedir(), ".myop"), pe = H.join(Ne, "credentials.json");
1288
+ function Lt() {
1289
+ R.existsSync(Ne) || R.mkdirSync(Ne, { recursive: !0, mode: 448 });
1290
1290
  }
1291
- function ke() {
1291
+ function De() {
1292
1292
  try {
1293
- if (!D.existsSync(le))
1293
+ if (!R.existsSync(pe))
1294
1294
  return null;
1295
- const o = D.readFileSync(le, "utf8");
1295
+ const o = R.readFileSync(pe, "utf8");
1296
1296
  return JSON.parse(o);
1297
1297
  } catch (o) {
1298
1298
  return console.info("Failed to read credentials:", o.message), null;
1299
1299
  }
1300
1300
  }
1301
- function Xe(o) {
1302
- Et();
1301
+ function tt(o) {
1302
+ Lt();
1303
1303
  const e = {
1304
1304
  ...o,
1305
1305
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
1306
1306
  };
1307
- D.writeFileSync(le, JSON.stringify(e, null, 2), {
1307
+ R.writeFileSync(pe, JSON.stringify(e, null, 2), {
1308
1308
  mode: 384
1309
1309
  // Read/write for owner only
1310
1310
  });
1311
1311
  }
1312
- function qe() {
1312
+ function ot() {
1313
1313
  try {
1314
- return D.existsSync(le) && D.unlinkSync(le), !0;
1314
+ return R.existsSync(pe) && R.unlinkSync(pe), !0;
1315
1315
  } catch (o) {
1316
1316
  return console.error("Failed to clear credentials:", o.message), !1;
1317
1317
  }
1318
1318
  }
1319
- function It(o) {
1319
+ function At(o) {
1320
1320
  if (!o || !o.expiresAt)
1321
1321
  return !0;
1322
1322
  const e = 5 * 60 * 1e3, t = new Date(o.expiresAt).getTime();
1323
1323
  return Date.now() > t - e;
1324
1324
  }
1325
- function be() {
1326
- const o = ke();
1325
+ function xe() {
1326
+ const o = De();
1327
1327
  return o ? {
1328
1328
  email: o.userEmail,
1329
1329
  userId: o.userId
1330
1330
  } : null;
1331
1331
  }
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");
1332
+ const ae = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, He = `http://localhost:${Se}/callback`, Dt = "myop-cli";
1333
+ function Ht() {
1334
+ return Le.randomBytes(32).toString("base64url");
1335
1335
  }
1336
- function Nt(o) {
1337
- return je.createHash("sha256").update(o).digest("base64url");
1336
+ function Ut(o) {
1337
+ return Le.createHash("sha256").update(o).digest("base64url");
1338
1338
  }
1339
- async function _t() {
1340
- const o = await fetch(`${se}/oauth/register`, {
1339
+ async function Jt() {
1340
+ const o = await fetch(`${ae}/oauth/register`, {
1341
1341
  method: "POST",
1342
1342
  headers: { "Content-Type": "application/json" },
1343
1343
  body: JSON.stringify({
1344
- client_name: Ft,
1345
- redirect_uris: [Le],
1344
+ client_name: Dt,
1345
+ redirect_uris: [He],
1346
1346
  grant_types: ["authorization_code", "refresh_token"],
1347
1347
  response_types: ["code"]
1348
1348
  })
@@ -1353,8 +1353,8 @@ async function _t() {
1353
1353
  }
1354
1354
  return o.json();
1355
1355
  }
1356
- function ge(o, e, t, n = null) {
1357
- const r = {
1356
+ function we(o, e, t, n = null) {
1357
+ const i = {
1358
1358
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
1359
1359
  <circle cx="12" cy="12" r="10"/>
1360
1360
  <path d="M8 12l2.5 2.5L16 9"/>
@@ -1371,7 +1371,7 @@ function ge(o, e, t, n = null) {
1371
1371
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
1372
1372
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
1373
1373
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
1374
- }, { accent: d, glow: v } = s[o] || s.error;
1374
+ }, { accent: l, glow: w } = s[o] || s.error;
1375
1375
  return `<!DOCTYPE html>
1376
1376
  <html lang="en">
1377
1377
  <head>
@@ -1432,7 +1432,7 @@ function ge(o, e, t, n = null) {
1432
1432
  h1 {
1433
1433
  font-size: 20px;
1434
1434
  font-weight: 500;
1435
- color: ${d};
1435
+ color: ${l};
1436
1436
  margin-bottom: 12px;
1437
1437
  letter-spacing: -0.5px;
1438
1438
  }
@@ -1464,8 +1464,8 @@ function ge(o, e, t, n = null) {
1464
1464
  display: inline-flex;
1465
1465
  align-items: center;
1466
1466
  gap: 8px;
1467
- background: ${v};
1468
- border: 1px solid ${d}33;
1467
+ background: ${w};
1468
+ border: 1px solid ${l}33;
1469
1469
  border-radius: 4px;
1470
1470
  padding: 10px 16px;
1471
1471
  font-size: 12px;
@@ -1502,7 +1502,7 @@ function ge(o, e, t, n = null) {
1502
1502
  <body>
1503
1503
  <div class="container">
1504
1504
  <div class="icon">
1505
- ${r[o] || r.error}
1505
+ ${i[o] || i.error}
1506
1506
  </div>
1507
1507
  <h1>${e}</h1>
1508
1508
  <p class="message">${t}</p>
@@ -1519,23 +1519,23 @@ function ge(o, e, t, n = null) {
1519
1519
  </body>
1520
1520
  </html>`;
1521
1521
  }
1522
- function kt(o) {
1522
+ function Bt(o) {
1523
1523
  return new Promise((e, t) => {
1524
- const n = pt.createServer((r, s) => {
1525
- const d = new Ve(r.url, `http://localhost:${ye}`);
1526
- if (d.pathname === "/callback") {
1527
- const v = d.searchParams.get("code"), M = d.searchParams.get("state"), u = d.searchParams.get("error");
1528
- if (u) {
1529
- s.writeHead(200, { "Content-Type": "text/html" }), s.end(ge(
1524
+ const n = wt.createServer((i, s) => {
1525
+ const l = new Ke(i.url, `http://localhost:${Se}`);
1526
+ if (l.pathname === "/callback") {
1527
+ const w = l.searchParams.get("code"), v = l.searchParams.get("state"), m = l.searchParams.get("error");
1528
+ if (m) {
1529
+ s.writeHead(200, { "Content-Type": "text/html" }), s.end(we(
1530
1530
  "error",
1531
1531
  "Authentication Failed",
1532
1532
  "Unable to complete the authentication process.",
1533
- u
1534
- )), n.close(), t(new Error(`OAuth error: ${u}`));
1533
+ m
1534
+ )), n.close(), t(new Error(`OAuth error: ${m}`));
1535
1535
  return;
1536
1536
  }
1537
- if (M !== o) {
1538
- s.writeHead(400, { "Content-Type": "text/html" }), s.end(ge(
1537
+ if (v !== o) {
1538
+ s.writeHead(400, { "Content-Type": "text/html" }), s.end(we(
1539
1539
  "warning",
1540
1540
  "Security Error",
1541
1541
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
@@ -1543,8 +1543,8 @@ function kt(o) {
1543
1543
  )), n.close(), t(new Error("State mismatch"));
1544
1544
  return;
1545
1545
  }
1546
- if (!v) {
1547
- s.writeHead(400, { "Content-Type": "text/html" }), s.end(ge(
1546
+ if (!w) {
1547
+ s.writeHead(400, { "Content-Type": "text/html" }), s.end(we(
1548
1548
  "error",
1549
1549
  "Missing Authorization Code",
1550
1550
  "No authorization code was received from the server.",
@@ -1552,44 +1552,44 @@ function kt(o) {
1552
1552
  )), n.close(), t(new Error("No authorization code"));
1553
1553
  return;
1554
1554
  }
1555
- s.writeHead(200, { "Content-Type": "text/html" }), s.end(ge(
1555
+ s.writeHead(200, { "Content-Type": "text/html" }), s.end(we(
1556
1556
  "success",
1557
1557
  "Authentication Successful",
1558
1558
  "You have been authenticated successfully. Return to the terminal to continue."
1559
- )), n.close(), e(v);
1559
+ )), n.close(), e(w);
1560
1560
  } else
1561
1561
  s.writeHead(404), s.end("Not found");
1562
1562
  });
1563
- n.listen(ye, () => {
1564
- console.info(`OAuth callback server listening on port ${ye}`);
1563
+ n.listen(Se, () => {
1564
+ console.info(`OAuth callback server listening on port ${Se}`);
1565
1565
  }), setTimeout(() => {
1566
1566
  n.close(), t(new Error("Authentication timed out"));
1567
1567
  }, 5 * 60 * 1e3);
1568
1568
  });
1569
1569
  }
1570
- async function Lt(o, e, t) {
1571
- const n = await fetch(`${se}/oauth/token`, {
1570
+ async function zt(o, e, t) {
1571
+ const n = await fetch(`${ae}/oauth/token`, {
1572
1572
  method: "POST",
1573
1573
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1574
- body: new Ge({
1574
+ body: new Qe({
1575
1575
  grant_type: "authorization_code",
1576
1576
  code: o,
1577
1577
  client_id: e,
1578
- redirect_uri: Le,
1578
+ redirect_uri: He,
1579
1579
  code_verifier: t
1580
1580
  })
1581
1581
  });
1582
1582
  if (!n.ok) {
1583
- const r = await n.json();
1584
- throw new Error(r.error_description || r.error || "Token exchange failed");
1583
+ const i = await n.json();
1584
+ throw new Error(i.error_description || i.error || "Token exchange failed");
1585
1585
  }
1586
1586
  return n.json();
1587
1587
  }
1588
- async function At(o, e) {
1589
- const t = await fetch(`${se}/oauth/token`, {
1588
+ async function Wt(o, e) {
1589
+ const t = await fetch(`${ae}/oauth/token`, {
1590
1590
  method: "POST",
1591
1591
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1592
- body: new Ge({
1592
+ body: new Qe({
1593
1593
  grant_type: "refresh_token",
1594
1594
  refresh_token: o,
1595
1595
  client_id: e
@@ -1601,9 +1601,9 @@ async function At(o, e) {
1601
1601
  }
1602
1602
  return t.json();
1603
1603
  }
1604
- async function Ht(o) {
1605
- var r, s, d;
1606
- const e = await fetch(`${se}/mcp`, {
1604
+ async function Vt(o) {
1605
+ var i, s, l;
1606
+ const e = await fetch(`${ae}/mcp`, {
1607
1607
  method: "POST",
1608
1608
  headers: {
1609
1609
  "Content-Type": "application/json",
@@ -1624,57 +1624,57 @@ async function Ht(o) {
1624
1624
  const t = await e.json();
1625
1625
  if (t.error)
1626
1626
  throw new Error(t.error.message);
1627
- const n = (d = (s = (r = t.result) == null ? void 0 : r.content) == null ? void 0 : s[0]) == null ? void 0 : d.text;
1627
+ const n = (l = (s = (i = t.result) == null ? void 0 : i.content) == null ? void 0 : s[0]) == null ? void 0 : l.text;
1628
1628
  if (n)
1629
1629
  return JSON.parse(n);
1630
1630
  throw new Error("Invalid response from whoami");
1631
1631
  }
1632
- async function ae() {
1633
- const o = V("Starting authentication...").start();
1632
+ async function de() {
1633
+ const o = G("Starting authentication...").start();
1634
1634
  try {
1635
1635
  o.text = "Registering OAuth client...";
1636
- const t = (await _t()).client_id, n = jt(), r = Nt(n), s = je.randomBytes(16).toString("hex");
1636
+ const t = (await Jt()).client_id, n = Ht(), i = Ut(n), s = Le.randomBytes(16).toString("hex");
1637
1637
  o.text = "Waiting for authorization...";
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());
1642
- const M = await d;
1638
+ const l = Bt(s), w = new Ke(`${ae}/oauth/authorize`);
1639
+ w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", t), w.searchParams.set("redirect_uri", He), w.searchParams.set("code_challenge", i), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", s), o.stop(), console.log(`
1640
+ 🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${w.toString()}
1641
+ `), await St(w.toString());
1642
+ const v = await l;
1643
1643
  o.start("Exchanging authorization code...");
1644
- const u = await Lt(M, t, n);
1644
+ const m = await zt(v, t, n);
1645
1645
  o.text = "Getting user info...";
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(),
1646
+ const d = await Vt(m.access_token), C = {
1647
+ accessToken: m.access_token,
1648
+ refreshToken: m.refresh_token,
1649
+ expiresAt: new Date(Date.now() + m.expires_in * 1e3).toISOString(),
1650
1650
  clientId: t,
1651
- userId: p.userId,
1652
- userEmail: p.email
1651
+ userId: d.userId,
1652
+ userEmail: d.email
1653
1653
  };
1654
- return Xe(S), o.succeed(`Authenticated as ${p.email}`), S;
1654
+ return tt(C), o.succeed(`Authenticated as ${d.email}`), C;
1655
1655
  } catch (e) {
1656
1656
  throw o.fail(`Authentication failed: ${e.message}`), e;
1657
1657
  }
1658
1658
  }
1659
- async function et() {
1660
- const o = ke();
1659
+ async function nt() {
1660
+ const o = De();
1661
1661
  if (!o) {
1662
1662
  console.log("Not currently logged in.");
1663
1663
  return;
1664
1664
  }
1665
- qe(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1665
+ ot(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1666
1666
  }
1667
- async function Dt() {
1668
- let o = ke();
1667
+ async function st() {
1668
+ let o = De();
1669
1669
  if (!o)
1670
1670
  return console.log(`Not logged in. Starting authentication...
1671
- `), await ae();
1672
- if (!It(o))
1671
+ `), await de();
1672
+ if (!At(o))
1673
1673
  return o;
1674
1674
  if (o.refreshToken) {
1675
- const e = V("Refreshing access token...").start();
1675
+ const e = G("Refreshing access token...").start();
1676
1676
  try {
1677
- const t = await At(
1677
+ const t = await Wt(
1678
1678
  o.refreshToken,
1679
1679
  o.clientId
1680
1680
  );
@@ -1683,102 +1683,190 @@ async function Dt() {
1683
1683
  accessToken: t.access_token,
1684
1684
  refreshToken: t.refresh_token,
1685
1685
  expiresAt: new Date(Date.now() + t.expires_in * 1e3).toISOString()
1686
- }, Xe(o), e.succeed("Token refreshed"), o;
1686
+ }, tt(o), e.succeed("Token refreshed"), o;
1687
1687
  } catch {
1688
- return e.warn("Token refresh failed, please log in again"), qe(), await ae();
1688
+ return e.warn("Token refresh failed, please log in again"), ot(), await de();
1689
1689
  }
1690
1690
  }
1691
1691
  return console.log(`Session expired. Please log in again.
1692
- `), await ae();
1692
+ `), await de();
1693
+ }
1694
+ function it() {
1695
+ return ae;
1696
+ }
1697
+ const X = "@myop/cli", ke = process.platform === "win32";
1698
+ function Gt() {
1699
+ try {
1700
+ return q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
1701
+ } catch {
1702
+ return "https://registry.npmjs.org/";
1703
+ }
1693
1704
  }
1694
- function Ut() {
1695
- return se;
1705
+ function Yt() {
1706
+ try {
1707
+ return q("npm config get prefix", { encoding: "utf-8" }).trim();
1708
+ } catch {
1709
+ return null;
1710
+ }
1696
1711
  }
1697
- const we = "@myop/cli";
1698
- async function Bt() {
1712
+ async function Kt() {
1699
1713
  try {
1700
- const o = await fetch(`https://registry.npmjs.org/${we}/latest`);
1701
- return o.ok ? (await o.json()).version : null;
1714
+ const o = Gt().replace(/\/$/, ""), e = await fetch(`${o}/${X}/latest`);
1715
+ return e.ok ? (await e.json()).version : null;
1702
1716
  } catch {
1703
1717
  return null;
1704
1718
  }
1705
1719
  }
1706
- function Jt(o, e) {
1720
+ function Qt(o, e) {
1707
1721
  const t = o.split(".").map(Number), n = e.split(".").map(Number);
1708
- for (let r = 0; r < Math.max(t.length, n.length); r++) {
1709
- const s = t[r] || 0, d = n[r] || 0;
1710
- if (s > d) return 1;
1711
- if (s < d) return -1;
1722
+ for (let i = 0; i < Math.max(t.length, n.length); i++) {
1723
+ const s = t[i] || 0, l = n[i] || 0;
1724
+ if (s > l) return 1;
1725
+ if (s < l) return -1;
1712
1726
  }
1713
1727
  return 0;
1714
1728
  }
1715
- async function zt(o) {
1716
- const e = V({
1729
+ async function Zt(o) {
1730
+ const e = G({
1717
1731
  text: "Checking for updates...",
1718
1732
  color: "cyan"
1719
- }).start(), t = await Bt();
1720
- if (e.stop(), !t || Jt(t, o) <= 0)
1733
+ }).start(), t = await Kt();
1734
+ if (e.stop(), !t || Qt(t, o) <= 0)
1721
1735
  return !1;
1722
1736
  console.log(`
1723
1737
  πŸ“¦ New version available: ${o} β†’ ${t}
1724
1738
  `);
1725
1739
  let n;
1726
1740
  try {
1727
- n = await We({
1741
+ n = await Ye({
1728
1742
  message: "Would you like to update now?",
1729
1743
  choices: [
1730
1744
  { name: "Yes, update now", value: !0 },
1731
1745
  { name: "No, continue with current version", value: !1 }
1732
1746
  ]
1733
1747
  });
1734
- } catch (r) {
1735
- throw r.name === "ExitPromptError" && (console.log(`
1748
+ } catch (i) {
1749
+ throw i.name === "ExitPromptError" && (console.log(`
1736
1750
 
1737
1751
  πŸ‘‹ Goodbye!
1738
- `), process.exit(0)), r;
1752
+ `), process.exit(0)), i;
1739
1753
  }
1740
1754
  if (n) {
1741
- const r = V({
1742
- text: `Updating ${we} to v${t}...`,
1755
+ const i = G({
1756
+ text: `Updating ${X} to v${t}...`,
1743
1757
  color: "green"
1744
- }).start();
1758
+ }).start(), s = `npm install -g ${X}@latest`, l = Yt();
1759
+ try {
1760
+ q(s, { stdio: "pipe" }), i.succeed(`Updated to v${t}`);
1761
+ } catch {
1762
+ i.stop(), console.log(`
1763
+ πŸ” Elevated permissions required.
1764
+ `);
1765
+ try {
1766
+ if (ke) {
1767
+ const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${l ? `install -g ${X}@latest --prefix \\"${l}\\"` : `install -g ${X}@latest`}' -Verb RunAs -Wait`;
1768
+ q(`powershell -Command "${d}"`, { stdio: "inherit" });
1769
+ } else {
1770
+ const m = l ? `sudo npm install -g ${X}@latest --prefix "${l}"` : `sudo ${s}`;
1771
+ q(m, { stdio: "inherit" });
1772
+ }
1773
+ console.log(`
1774
+ βœ… Updated to v${t}`);
1775
+ } catch {
1776
+ console.log(`
1777
+ ❌ Update failed`);
1778
+ const d = ke ? `npm install -g ${X}@latest (run as Administrator)` : `sudo npm install -g ${X}@latest`;
1779
+ console.log(`
1780
+ Please run manually: ${d}
1781
+ `), process.exit(1);
1782
+ }
1783
+ }
1784
+ let w = null;
1745
1785
  try {
1746
- return he(`npm install -g ${we}@latest`, { stdio: "pipe" }), r.succeed(`Updated to v${t}`), console.log(`
1747
- πŸ”„ Restarting with new version...
1748
- `), dt("myop", process.argv.slice(2), {
1786
+ let v;
1787
+ l ? v = ke ? Oe(l, "node_modules") : Oe(l, "lib", "node_modules") : v = q("npm root -g", { encoding: "utf-8" }).trim();
1788
+ const m = Oe(v, X, "package.json"), d = yt(m, "utf-8");
1789
+ w = JSON.parse(d).version;
1790
+ } catch {
1791
+ }
1792
+ if (w === t)
1793
+ return console.log(`
1794
+ πŸ”„ Restarting...
1795
+ `), ht(process.argv[0], process.argv.slice(1), {
1749
1796
  stdio: "inherit",
1750
1797
  shell: !0
1751
- }).on("close", (d) => {
1752
- process.exit(d || 0);
1798
+ }).on("close", (m) => {
1799
+ process.exit(m || 0);
1753
1800
  }), !0;
1754
- } catch {
1755
- return r.fail("Update failed"), console.log(`
1756
- You can manually update by running: npm install -g ${we}@latest
1757
- `), !1;
1758
- }
1801
+ console.log(`
1802
+ Please run myop again to use the new version.
1803
+ `), process.exit(0);
1759
1804
  }
1760
1805
  return !1;
1761
1806
  }
1762
- const Wt = (o) => new Promise((e) => setTimeout(e, o)), tt = (o = ".", e = 3, t = 0) => {
1807
+ const Xt = (o) => new Promise((e) => setTimeout(e, o)), qt = () => {
1808
+ let o = new URL(import.meta.url).pathname;
1809
+ process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
1810
+ const e = H.dirname(o);
1811
+ return H.join(e, "skills");
1812
+ }, _e = (o, e) => {
1813
+ R.mkdirSync(e, { recursive: !0 });
1814
+ const t = R.readdirSync(o, { withFileTypes: !0 });
1815
+ for (const n of t) {
1816
+ const i = H.join(o, n.name), s = H.join(e, n.name);
1817
+ n.isDirectory() ? _e(i, s) : R.copyFileSync(i, s);
1818
+ }
1819
+ }, rt = (o) => {
1820
+ const e = qt();
1821
+ if (!R.existsSync(e))
1822
+ return console.info("Skills source directory not found, skipping skills installation"), !1;
1823
+ try {
1824
+ const t = H.join(o, ".agents", "skills");
1825
+ _e(e, t);
1826
+ const n = [".claude", ".cursor", ".gemini", ".junie", ".agent"], i = R.readdirSync(e, { withFileTypes: !0 }).filter((s) => s.isDirectory()).map((s) => s.name);
1827
+ for (const s of n) {
1828
+ const l = H.join(o, s, "skills");
1829
+ R.mkdirSync(l, { recursive: !0 });
1830
+ for (const w of i) {
1831
+ const v = H.join(l, w), m = H.join("..", "..", ".agents", "skills", w);
1832
+ try {
1833
+ R.rmSync(v, { recursive: !0, force: !0 });
1834
+ } catch {
1835
+ }
1836
+ try {
1837
+ R.symlinkSync(m, v, "dir");
1838
+ } catch {
1839
+ _e(
1840
+ H.join(t, w),
1841
+ v
1842
+ );
1843
+ }
1844
+ }
1845
+ }
1846
+ return !0;
1847
+ } catch (t) {
1848
+ return console.info("Failed to install skills:", t.message), !1;
1849
+ }
1850
+ }, at = (o = ".", e = 3, t = 0) => {
1763
1851
  const n = [];
1764
1852
  if (t > e) return n;
1765
1853
  try {
1766
- const r = D.readdirSync(o, { withFileTypes: !0 });
1767
- for (const s of r) {
1768
- const d = te.join(o, s.name);
1854
+ const i = R.readdirSync(o, { withFileTypes: !0 });
1855
+ for (const s of i) {
1856
+ const l = H.join(o, s.name);
1769
1857
  if (s.isDirectory()) {
1770
1858
  if (s.name === "node_modules" || s.name === ".git" || s.name === "dist" || s.name.startsWith("."))
1771
1859
  continue;
1772
- n.push(...tt(d, e, t + 1));
1860
+ n.push(...at(l, e, t + 1));
1773
1861
  } else if (s.name === "myop.config.json")
1774
1862
  try {
1775
- const v = D.readFileSync(d, "utf-8"), M = JSON.parse(v);
1863
+ const w = R.readFileSync(l, "utf-8"), v = JSON.parse(w);
1776
1864
  n.push({
1777
1865
  path: o,
1778
- configPath: d,
1779
- name: M.name || M.componentName || te.basename(o),
1780
- componentId: M.componentId || null,
1781
- config: M
1866
+ configPath: l,
1867
+ name: v.name || v.componentName || H.basename(o),
1868
+ componentId: v.componentId || null,
1869
+ config: v
1782
1870
  });
1783
1871
  } catch {
1784
1872
  }
@@ -1788,7 +1876,7 @@ const Wt = (o) => new Promise((e) => setTimeout(e, o)), tt = (o = ".", e = 3, t
1788
1876
  return n;
1789
1877
  };
1790
1878
  y.executionPath = process.cwd();
1791
- const Se = (o = !1) => {
1879
+ const $e = (o = !1) => {
1792
1880
  const e = y.program.getOptionValue("verbose");
1793
1881
  e || (console.info = () => {
1794
1882
  }), console.info("πŸ“ verbose mode on"), y.options = {
@@ -1796,7 +1884,7 @@ const Se = (o = !1) => {
1796
1884
  verbose: e
1797
1885
  };
1798
1886
  try {
1799
- return y.myopConfig = gt(y.options.configPath), { configFound: !0 };
1887
+ return y.myopConfig = xt(y.options.configPath), { configFound: !0 };
1800
1888
  } catch (t) {
1801
1889
  if (o) {
1802
1890
  console.info(`
@@ -1806,7 +1894,7 @@ const Se = (o = !1) => {
1806
1894
  author: "@myop-cli",
1807
1895
  flows: []
1808
1896
  };
1809
- return Ne(y.options.configPath, n), y.myopConfig = n, { configFound: !0 };
1897
+ return Ae(y.options.configPath, n), y.myopConfig = n, { configFound: !0 };
1810
1898
  } catch {
1811
1899
  return console.info("Error details :", t), { configFound: !1, error: t };
1812
1900
  }
@@ -1815,95 +1903,109 @@ const Se = (o = !1) => {
1815
1903
  }
1816
1904
  };
1817
1905
  [
1818
- new Ee(),
1819
- ...xt
1906
+ new Fe(),
1907
+ ...Et
1820
1908
  ];
1821
- const Vt = "0.1.38";
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"));
1909
+ const eo = "0.1.41";
1910
+ y.program = new ft();
1911
+ y.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(eo);
1912
+ y.program.addOption(new me("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1913
+ y.program.addOption(new me("-h, --help", "Show helpful information"));
1914
+ y.program.addOption(new me("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1915
+ y.program.addOption(new me("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1916
+ y.program.addOption(new me("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
1829
1917
  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();
1918
+ $e(!0), console.info("adding ", o, e, y.options.configPath), o === "flow" && Xe._action(e), process.exit();
1831
1919
  });
1832
1920
  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();
1921
+ $e(), console.info("removing ", o, e, y.options.configPath), o === "flow" && qe._action(e), process.exit();
1834
1922
  });
1835
1923
  y.program.command("install").description("Install Myop assets").action(async () => {
1836
- Se(), await Ye.action();
1924
+ $e(), await Ze.action();
1837
1925
  });
1838
1926
  y.program.command("login").description("Authenticate with Myop platform").action(async () => {
1839
1927
  try {
1840
- await ae();
1928
+ await de();
1841
1929
  } catch (o) {
1842
1930
  console.error("Login failed:", o.message), process.exit(1);
1843
1931
  }
1844
1932
  process.exit(0);
1845
1933
  });
1846
1934
  y.program.command("logout").description("Clear stored credentials").action(async () => {
1847
- await et(), process.exit(0);
1935
+ await nt(), process.exit(0);
1848
1936
  });
1849
1937
  y.program.command("whoami").description("Show current authenticated user").action(async () => {
1850
- const o = be();
1938
+ const o = xe();
1851
1939
  o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1852
1940
  });
1853
1941
  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");
1942
+ var M, T, D, P, x, j;
1943
+ const e = y.program.getOptionValue("config") || "./myop.config.json", t = await import("fs"), { execSync: n } = await import("child_process"), i = await import("path");
1856
1944
  let s = {};
1857
1945
  if (t.existsSync(e))
1858
1946
  try {
1859
- const g = t.readFileSync(e, "utf-8");
1860
- s = JSON.parse(g);
1861
- const P = s.name || s.componentName;
1862
- console.log(`πŸ“‹ Found config: ${P || "Unnamed component"}`), s.componentId && console.log(` Component ID: ${s.componentId}`);
1863
- } catch (g) {
1864
- console.error(`⚠️ Failed to parse ${e}:`, g.message);
1947
+ const b = t.readFileSync(e, "utf-8");
1948
+ s = JSON.parse(b);
1949
+ const f = s.name || s.componentName;
1950
+ console.log(`πŸ“‹ Found config: ${f || "Unnamed component"}`), s.componentId && console.log(` Component ID: ${s.componentId}`);
1951
+ } catch (b) {
1952
+ console.error(`⚠️ Failed to parse ${e}:`, b.message);
1865
1953
  }
1866
1954
  else
1867
1955
  console.log("⚠️ No myop.config.json found. A new component will be created.");
1868
- if (!o.skipBuild) {
1869
- const { exec: g } = await import("child_process");
1870
- let P = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
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) => {
1874
- if (!U) {
1875
- q.succeed("Build completed"), k(!0);
1956
+ let l = null, w = !1;
1957
+ try {
1958
+ const b = JSON.parse(t.readFileSync("package.json", "utf-8"));
1959
+ w = !!(b.scripts && b.scripts.build);
1960
+ } catch {
1961
+ }
1962
+ if (!w) {
1963
+ const b = t.readdirSync(".").filter(
1964
+ (f) => f.endsWith(".html") && !f.startsWith(".") && t.statSync(f).isFile()
1965
+ );
1966
+ b.length === 1 && (l = b[0]);
1967
+ }
1968
+ if (l)
1969
+ console.log(`πŸ“„ Single HTML file mode: ${l} (skipping build)`);
1970
+ else if (!o.skipBuild) {
1971
+ const { exec: b } = await import("child_process");
1972
+ let f = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
1973
+ const E = (B = !1) => new Promise((U) => {
1974
+ const k = G(B ? "Retrying build..." : "Building project...").start();
1975
+ b("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (z, I, Z) => {
1976
+ if (!z) {
1977
+ k.succeed("Build completed"), U(!0);
1876
1978
  return;
1877
1979
  }
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) {
1980
+ if (k.fail("Build failed"), !f.hasTriedPlatformFix && !f.hasTriedInstall) {
1981
+ const se = await et(z, I, Z, b, f);
1982
+ if (f = { ...f, ...se }, se.handled) {
1881
1983
  const Y = await E(!0);
1882
- k(Y);
1984
+ U(Y);
1883
1985
  return;
1884
1986
  }
1885
1987
  }
1886
- console.error(U.message), k(!1);
1988
+ console.error(z.message), U(!1);
1887
1989
  });
1888
1990
  });
1889
1991
  await E() || process.exit(1);
1890
1992
  }
1891
- const d = "./dist/index.html";
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));
1893
- let v;
1993
+ const v = l || "./dist/index.html";
1994
+ t.existsSync(v) || (console.error(`❌ Error: ${v} not found`), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1995
+ let m;
1894
1996
  try {
1895
- v = await Dt();
1896
- } catch (g) {
1897
- console.error("❌ Authentication failed:", g.message), process.exit(1);
1997
+ m = await st();
1998
+ } catch (b) {
1999
+ console.error("❌ Authentication failed:", b.message), process.exit(1);
1898
2000
  }
1899
- const M = Ut();
1900
- let u = V("Requesting upload URL...").start(), p;
2001
+ const d = it();
2002
+ let C = G("Requesting upload URL...").start(), u;
1901
2003
  try {
1902
- const g = await fetch(`${M}/mcp`, {
2004
+ const b = await fetch(`${d}/mcp`, {
1903
2005
  method: "POST",
1904
2006
  headers: {
1905
2007
  "Content-Type": "application/json",
1906
- Authorization: `Bearer ${v.accessToken}`
2008
+ Authorization: `Bearer ${m.accessToken}`
1907
2009
  },
1908
2010
  body: JSON.stringify({
1909
2011
  jsonrpc: "2.0",
@@ -1912,63 +2014,63 @@ y.program.command("sync").description("Build and upload component to Myop platfo
1912
2014
  params: {
1913
2015
  name: "upload_component",
1914
2016
  arguments: {
1915
- name: s.name || s.componentName || r.default.basename(process.cwd()),
2017
+ name: s.name || s.componentName || i.default.basename(process.cwd()),
1916
2018
  componentId: s.componentId || void 0,
1917
2019
  organization: s.organization || void 0
1918
2020
  }
1919
2021
  }
1920
2022
  })
1921
2023
  });
1922
- if (!g.ok)
1923
- throw new Error(`Server returned ${g.status}`);
1924
- const P = await g.json();
1925
- if (P.error)
1926
- throw new Error(P.error.message);
1927
- const E = (x = (b = (f = P.result) == null ? void 0 : f.content) == null ? void 0 : b[0]) == null ? void 0 : x.text;
1928
- if (p = JSON.parse(E), !p.success)
1929
- throw new Error(p.error);
1930
- u.succeed("Upload URL obtained");
1931
- } catch (g) {
1932
- u.fail("Failed to get upload URL"), console.error(" ", g.message), process.exit(1);
1933
- }
1934
- u = V("Uploading component...").start();
2024
+ if (!b.ok)
2025
+ throw new Error(`Server returned ${b.status}`);
2026
+ const f = await b.json();
2027
+ if (f.error)
2028
+ throw new Error(f.error.message);
2029
+ const E = (D = (T = (M = f.result) == null ? void 0 : M.content) == null ? void 0 : T[0]) == null ? void 0 : D.text;
2030
+ if (u = JSON.parse(E), !u.success)
2031
+ throw new Error(u.error);
2032
+ C.succeed("Upload URL obtained");
2033
+ } catch (b) {
2034
+ C.fail("Failed to get upload URL"), console.error(" ", b.message), process.exit(1);
2035
+ }
2036
+ C = G("Uploading component...").start();
1935
2037
  try {
1936
- const g = t.readFileSync(d, "utf-8");
1937
- let P;
1938
- const E = p.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
2038
+ const b = t.readFileSync(v, "utf-8");
2039
+ let f;
2040
+ const E = u.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
1939
2041
  if (E)
1940
- P = E[1];
2042
+ f = E[1];
1941
2043
  else {
1942
- const I = p.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1943
- if (I)
1944
- P = I[1];
2044
+ const B = u.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
2045
+ if (B)
2046
+ f = B[1];
1945
2047
  else
1946
- throw new Error("Could not parse presigned URL from: " + p.curlCommand);
2048
+ throw new Error("Could not parse presigned URL from: " + u.curlCommand);
1947
2049
  }
1948
- console.info("Uploading to:", P.substring(0, 100) + "...");
1949
- const C = await fetch(P, {
2050
+ console.info("Uploading to:", f.substring(0, 100) + "...");
2051
+ const _ = await fetch(f, {
1950
2052
  method: "PUT",
1951
2053
  headers: {
1952
2054
  "Content-Type": "text/html"
1953
2055
  },
1954
- body: g
2056
+ body: b
1955
2057
  });
1956
- if (!C.ok) {
1957
- const I = await C.text();
1958
- throw new Error(`Upload failed with status ${C.status}: ${I}`);
2058
+ if (!_.ok) {
2059
+ const B = await _.text();
2060
+ throw new Error(`Upload failed with status ${_.status}: ${B}`);
1959
2061
  }
1960
- u.succeed("Component uploaded");
1961
- } catch (g) {
1962
- u.fail("Upload failed"), console.error(" ", g.message), g.cause && console.error(" Cause:", g.cause), process.exit(1);
2062
+ C.succeed("Component uploaded");
2063
+ } catch (b) {
2064
+ C.fail("Upload failed"), console.error(" ", b.message), b.cause && console.error(" Cause:", b.cause), process.exit(1);
1963
2065
  }
1964
- u = V("Confirming upload...").start();
2066
+ C = G("Confirming upload...").start();
1965
2067
  let S;
1966
2068
  try {
1967
- const g = await fetch(`${M}/mcp`, {
2069
+ const b = await fetch(`${d}/mcp`, {
1968
2070
  method: "POST",
1969
2071
  headers: {
1970
2072
  "Content-Type": "application/json",
1971
- Authorization: `Bearer ${v.accessToken}`
2073
+ Authorization: `Bearer ${m.accessToken}`
1972
2074
  },
1973
2075
  body: JSON.stringify({
1974
2076
  jsonrpc: "2.0",
@@ -1977,50 +2079,329 @@ y.program.command("sync").description("Build and upload component to Myop platfo
1977
2079
  params: {
1978
2080
  name: "confirm_upload",
1979
2081
  arguments: {
1980
- uploadId: p.uploadId
2082
+ uploadId: u.uploadId
1981
2083
  }
1982
2084
  }
1983
2085
  })
1984
2086
  });
1985
- if (!g.ok)
1986
- throw new Error(`Server returned ${g.status}`);
1987
- const P = await g.json();
1988
- if (P.error)
1989
- throw new Error(P.error.message);
1990
- const E = (H = (L = ($ = P.result) == null ? void 0 : $.content) == null ? void 0 : L[0]) == null ? void 0 : H.text;
2087
+ if (!b.ok)
2088
+ throw new Error(`Server returned ${b.status}`);
2089
+ const f = await b.json();
2090
+ if (f.error)
2091
+ throw new Error(f.error.message);
2092
+ const E = (j = (x = (P = f.result) == null ? void 0 : P.content) == null ? void 0 : x[0]) == null ? void 0 : j.text;
1991
2093
  if (S = JSON.parse(E), !S.success)
1992
2094
  throw new Error(S.error);
1993
- u.succeed("Upload confirmed");
1994
- } catch (g) {
1995
- u.fail("Confirmation failed"), console.error(" ", g.message), process.exit(1);
2095
+ C.succeed("Upload confirmed");
2096
+ } catch (b) {
2097
+ C.fail("Confirmation failed"), console.error(" ", b.message), process.exit(1);
1996
2098
  }
1997
2099
  if (S.isNewComponent || !s.componentId) {
1998
2100
  s.componentId = S.componentId, s.organization = S.orgId, s.name || (s.name = S.componentName);
1999
2101
  try {
2000
2102
  t.writeFileSync(e, JSON.stringify(s, null, 2)), console.log(`
2001
2103
  πŸ“ Updated ${e} with componentId`);
2002
- } catch (g) {
2104
+ } catch (b) {
2003
2105
  console.log(`
2004
- ⚠️ Could not update ${e}: ${g.message}`), console.log(` Please add componentId: "${S.componentId}" manually`);
2106
+ ⚠️ Could not update ${e}: ${b.message}`), console.log(` Please add componentId: "${S.componentId}" manually`);
2005
2107
  }
2006
2108
  }
2007
2109
  console.log(`
2008
2110
  βœ… Sync completed successfully!`), console.log(` Component: ${S.componentName}`), console.log(` Dashboard: ${S.dashboardUrl}`), process.exit(0);
2009
2111
  });
2010
- y.program.command("dev").description("Start development server with file watching").action(_e);
2011
- const Gt = () => {
2112
+ y.program.command("push").description("Upload component to Myop platform").action(async () => {
2113
+ var C, u, S, M, T, D;
2114
+ const o = y.program.getOptionValue("config") || "./myop.config.json";
2115
+ let e = {};
2116
+ if (R.existsSync(o))
2117
+ try {
2118
+ e = JSON.parse(R.readFileSync(o, "utf-8"));
2119
+ } catch (P) {
2120
+ console.error(`⚠️ Failed to parse ${o}:`, P.message);
2121
+ }
2122
+ const t = e.name || e.componentName || H.basename(process.cwd());
2123
+ console.log(`
2124
+ πŸ“‹ Component: ${t}`);
2125
+ let n;
2126
+ const i = R.readdirSync(".").filter(
2127
+ (P) => P.endsWith(".html") && !P.startsWith(".") && R.statSync(P).isFile()
2128
+ );
2129
+ i.length === 1 && !R.existsSync("./dist/index.html") ? n = i[0] : R.existsSync("./dist/index.html") ? n = "./dist/index.html" : i.length === 1 ? n = i[0] : (console.error("❌ No HTML file found to upload."), console.log(" Expected: a single .html file in root or ./dist/index.html"), process.exit(1));
2130
+ const s = R.readFileSync(n, "utf-8");
2131
+ console.log(` File: ${n} (${(s.length / 1024).toFixed(1)} KB)`);
2132
+ let l;
2133
+ try {
2134
+ l = await st();
2135
+ } catch (P) {
2136
+ console.error("❌ Authentication failed:", P.message), process.exit(1);
2137
+ }
2138
+ const w = it();
2139
+ let v = G("Uploading...").start(), m;
2140
+ try {
2141
+ const P = await fetch(`${w}/mcp`, {
2142
+ method: "POST",
2143
+ headers: {
2144
+ "Content-Type": "application/json",
2145
+ Authorization: `Bearer ${l.accessToken}`
2146
+ },
2147
+ body: JSON.stringify({
2148
+ jsonrpc: "2.0",
2149
+ id: 1,
2150
+ method: "tools/call",
2151
+ params: {
2152
+ name: "upload_component",
2153
+ arguments: {
2154
+ name: t,
2155
+ componentId: e.componentId && e.componentId !== "DEV" ? e.componentId : void 0,
2156
+ organization: e.organization || void 0
2157
+ }
2158
+ }
2159
+ })
2160
+ });
2161
+ if (!P.ok)
2162
+ throw new Error(`Server returned ${P.status}`);
2163
+ const x = await P.json();
2164
+ if (x.error)
2165
+ throw new Error(x.error.message);
2166
+ const j = (S = (u = (C = x.result) == null ? void 0 : C.content) == null ? void 0 : u[0]) == null ? void 0 : S.text;
2167
+ if (m = JSON.parse(j), !m.success)
2168
+ throw new Error(m.error);
2169
+ } catch (P) {
2170
+ v.fail("Failed to get upload URL"), console.error(" ", P.message), process.exit(1);
2171
+ }
2172
+ try {
2173
+ let P;
2174
+ const x = m.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
2175
+ if (x)
2176
+ P = x[1];
2177
+ else {
2178
+ const b = m.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
2179
+ if (b)
2180
+ P = b[1];
2181
+ else
2182
+ throw new Error("Could not parse presigned URL");
2183
+ }
2184
+ const j = await fetch(P, {
2185
+ method: "PUT",
2186
+ headers: { "Content-Type": "text/html" },
2187
+ body: s
2188
+ });
2189
+ if (!j.ok) {
2190
+ const b = await j.text();
2191
+ throw new Error(`Upload failed: ${j.status} ${b}`);
2192
+ }
2193
+ } catch (P) {
2194
+ v.fail("Upload failed"), console.error(" ", P.message), process.exit(1);
2195
+ }
2196
+ let d;
2197
+ try {
2198
+ const P = await fetch(`${w}/mcp`, {
2199
+ method: "POST",
2200
+ headers: {
2201
+ "Content-Type": "application/json",
2202
+ Authorization: `Bearer ${l.accessToken}`
2203
+ },
2204
+ body: JSON.stringify({
2205
+ jsonrpc: "2.0",
2206
+ id: 2,
2207
+ method: "tools/call",
2208
+ params: {
2209
+ name: "confirm_upload",
2210
+ arguments: {
2211
+ uploadId: m.uploadId
2212
+ }
2213
+ }
2214
+ })
2215
+ });
2216
+ if (!P.ok)
2217
+ throw new Error(`Server returned ${P.status}`);
2218
+ const x = await P.json();
2219
+ if (x.error)
2220
+ throw new Error(x.error.message);
2221
+ const j = (D = (T = (M = x.result) == null ? void 0 : M.content) == null ? void 0 : T[0]) == null ? void 0 : D.text;
2222
+ if (d = JSON.parse(j), !d.success)
2223
+ throw new Error(d.error);
2224
+ v.succeed("Pushed successfully");
2225
+ } catch (P) {
2226
+ v.fail("Confirmation failed"), console.error(" ", P.message), process.exit(1);
2227
+ }
2228
+ if (d.isNewComponent || !e.componentId || e.componentId === "DEV") {
2229
+ e.componentId = d.componentId, e.organization = d.orgId, e.name || (e.name = d.componentName);
2230
+ try {
2231
+ R.writeFileSync(o, JSON.stringify(e, null, 2));
2232
+ } catch (P) {
2233
+ console.log(`⚠️ Could not update ${o}: ${P.message}`), console.log(` Add componentId: "${d.componentId}" manually`);
2234
+ }
2235
+ }
2236
+ console.log(`
2237
+ ${d.componentName}`), console.log(` ${d.dashboardUrl}
2238
+ `), process.exit(0);
2239
+ });
2240
+ y.program.command("create").description("Create a new Myop HTML component and start dev server").action(async () => {
2241
+ const { input: o } = await import("@inquirer/prompts"), e = await import("fs"), n = (await import("path")).default.basename(process.cwd());
2242
+ let i;
2012
2243
  try {
2013
- he("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2244
+ i = await o({
2245
+ message: "Component name:",
2246
+ default: n
2247
+ });
2248
+ } catch (v) {
2249
+ throw v.name === "ExitPromptError" && (console.log(`
2250
+
2251
+ πŸ‘‹ Goodbye!
2252
+ `), process.exit(0)), v;
2253
+ }
2254
+ (e.existsSync("index.html") || e.existsSync("myop.config.json")) && (console.log(`
2255
+ ⚠️ index.html or myop.config.json already exists in this directory.`), console.log(" Use `myop dev` to start the dev server for an existing component.\n"), process.exit(1));
2256
+ const s = {
2257
+ name: i,
2258
+ componentId: "DEV",
2259
+ type: "html",
2260
+ author: "@myop-cli",
2261
+ HMR: !0
2262
+ };
2263
+ e.writeFileSync("myop.config.json", JSON.stringify(s, null, 2));
2264
+ const l = `<!DOCTYPE html>
2265
+ <html lang="en">
2266
+ <head>
2267
+ <meta charset="UTF-8">
2268
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2269
+ <meta name="myop:size" content='{"width":"100%","height":"100%"}'>
2270
+ <title>${i}</title>
2271
+ <script type="myop/types">
2272
+ // =========================================================================
2273
+ // MYOP COMPONENT TYPE DEFINITIONS
2274
+ // =========================================================================
2275
+
2276
+ /**
2277
+ * Data structure passed to myop_init_interface(data)
2278
+ */
2279
+ interface MyopInitData {
2280
+ title: string;
2281
+ description?: string;
2282
+ }
2283
+
2284
+ /**
2285
+ * Actions and payloads for myop_cta_handler(action, payload)
2286
+ */
2287
+ interface MyopCtaPayloads {
2288
+ 'button-clicked': { label: string };
2289
+ 'size-requested': {
2290
+ width?: number | null;
2291
+ height?: number | null;
2292
+ minWidth?: number | null;
2293
+ maxWidth?: number | null;
2294
+ minHeight?: number | null;
2295
+ maxHeight?: number | null;
2296
+ required?: boolean;
2297
+ };
2298
+ }
2299
+
2300
+ // =========================================================================
2301
+ // DO NOT EDIT BELOW - Standard Myop type declarations
2302
+ // =========================================================================
2303
+
2304
+ declare function myop_init_interface(): MyopInitData;
2305
+ declare function myop_init_interface(data: MyopInitData): void;
2306
+
2307
+ declare function myop_cta_handler<K extends keyof MyopCtaPayloads>(
2308
+ action: K,
2309
+ payload: MyopCtaPayloads[K]
2310
+ ): void;
2311
+ <\/script>
2312
+ <style>
2313
+ * {
2314
+ box-sizing: border-box;
2315
+ margin: 0;
2316
+ padding: 0;
2317
+ }
2318
+
2319
+ html, body {
2320
+ width: 100%;
2321
+ height: 100%;
2322
+ overflow: hidden;
2323
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
2324
+ color: #333;
2325
+ }
2326
+
2327
+ #app-root {
2328
+ width: 100%;
2329
+ height: 100%;
2330
+ display: flex;
2331
+ flex-direction: column;
2332
+ align-items: center;
2333
+ justify-content: center;
2334
+ padding: 24px;
2335
+ }
2336
+
2337
+ h1 {
2338
+ font-size: 24px;
2339
+ margin-bottom: 8px;
2340
+ color: #1a1a1a;
2341
+ }
2342
+
2343
+ p {
2344
+ color: #666;
2345
+ line-height: 1.5;
2346
+ }
2347
+ </style>
2348
+ </head>
2349
+ <body>
2350
+ <div id="app-root">
2351
+ <h1>${i}</h1>
2352
+ <p>Edit index.html to get started</p>
2353
+ </div>
2354
+
2355
+ <script>
2356
+ (function() {
2357
+ var currentState = {};
2358
+
2359
+ function render(data) {
2360
+ currentState = data;
2361
+ var root = document.getElementById('app-root');
2362
+ root.innerHTML =
2363
+ '<h1>' + (data.title || '') + '</h1>' +
2364
+ (data.description ? '<p>' + data.description + '</p>' : '');
2365
+ }
2366
+
2367
+ window.myop_init_interface = function(data) {
2368
+ if (!data) return currentState;
2369
+ render(data);
2370
+ };
2371
+
2372
+ window.myop_cta_handler = function(action_id, payload) {
2373
+ // Will be overridden by host application
2374
+ };
2375
+ })();
2376
+ <\/script>
2377
+
2378
+ <script id="myop_preview">
2379
+ window.myop_init_interface({
2380
+ title: '${i}',
2381
+ description: 'Edit index.html to get started'
2382
+ });
2383
+ <\/script>
2384
+ </body>
2385
+ </html>`;
2386
+ e.writeFileSync("index.html", l);
2387
+ const w = rt(process.cwd());
2388
+ console.log(`
2389
+ βœ… Created ${i}`), console.log(" index.html"), console.log(" myop.config.json"), w && console.log(" .agents/skills/ (AI agent skills)"), console.log(""), await be();
2390
+ });
2391
+ y.program.command("dev").description("Start development server with file watching").action(be);
2392
+ const to = () => {
2393
+ try {
2394
+ q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2014
2395
  } catch {
2015
2396
  return { gitNotInstalled: !0 };
2016
2397
  }
2017
2398
  try {
2018
- he("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2399
+ q("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
2019
2400
  } catch {
2020
2401
  return { notARepo: !0 };
2021
2402
  }
2022
2403
  try {
2023
- const o = he("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
2404
+ const o = q("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
2024
2405
  encoding: "utf-8",
2025
2406
  stdio: ["pipe", "pipe", "pipe"]
2026
2407
  }).trim();
@@ -2031,22 +2412,22 @@ const Gt = () => {
2031
2412
  deletions: 0
2032
2413
  };
2033
2414
  const e = o.split(`
2034
- `), t = e[e.length - 1], n = t.match(/(\d+) insertion/), r = t.match(/(\d+) deletion/), s = t.match(/(\d+) file/);
2415
+ `), t = e[e.length - 1], n = t.match(/(\d+) insertion/), i = t.match(/(\d+) deletion/), s = t.match(/(\d+) file/);
2035
2416
  return {
2036
2417
  files: s ? parseInt(s[1]) : 0,
2037
2418
  insertions: n ? parseInt(n[1]) : 0,
2038
- deletions: r ? parseInt(r[1]) : 0
2419
+ deletions: i ? parseInt(i[1]) : 0
2039
2420
  };
2040
2421
  } catch {
2041
2422
  return null;
2042
2423
  }
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();
2424
+ }, ne = async (o = !1, e = !1) => {
2425
+ var d, C, u;
2426
+ const t = xe(), n = !!(t != null && t.email), i = ((d = y.myopConfig) == null ? void 0 : d.name) || ((C = y.myopConfig) == null ? void 0 : C.componentName), s = (u = y.myopConfig) == null ? void 0 : u.componentId, l = to();
2046
2427
  console.log(`
2047
2428
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Welcome to Myop CLI - Remote UI Made Easy β”‚"), console.log("β”‚ β”‚"), 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("");
2049
- const M = [
2429
+ `), 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"}`), l != null && l.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")) : l != null && l.notARepo ? console.log(" Changes: Not a git repository") : l && (l.insertions > 0 || l.deletions > 0) ? console.log(` Changes: ${l.files} file${l.files !== 1 ? "s" : ""} | \x1B[32m+${l.insertions}\x1B[0m \x1B[31m-${l.deletions}\x1B[0m`) : l && console.log(" Changes: No uncommitted changes"), console.log("");
2430
+ const v = [
2050
2431
  {
2051
2432
  emoji: "πŸš€",
2052
2433
  label: "Initialize new component",
@@ -2056,26 +2437,26 @@ const Gt = () => {
2056
2437
  },
2057
2438
  {
2058
2439
  emoji: "πŸ› οΈ ",
2059
- label: r ? `Start dev mode for "${r}"` : "Start dev mode",
2440
+ label: i ? `Start dev mode for "${i}"` : "Start dev mode",
2060
2441
  value: "dev",
2061
2442
  help: "Starts dev server with HMR for instant preview of changes",
2062
2443
  disabled: o ? !1 : "(no config file)"
2063
2444
  },
2064
2445
  {
2065
2446
  emoji: "πŸ“¦",
2066
- label: r ? `Push "${r}"` : "Push component",
2447
+ label: i ? `Push "${i}"` : "Push component",
2067
2448
  value: "sync",
2068
2449
  help: "Builds project & uploads dist/index.html to Myop",
2069
2450
  disabled: o ? n ? !1 : "(login required)" : "(no config file)"
2070
2451
  }
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
2452
+ ].map((S) => ({
2453
+ name: e && !S.disabled ? `${S.emoji} ${S.label}
2454
+ ${S.help}` : `${S.emoji} ${S.label}`,
2455
+ value: S.value,
2456
+ disabled: S.disabled
2076
2457
  }));
2077
- M.push(
2078
- new Ee(),
2458
+ v.push(
2459
+ new Fe(),
2079
2460
  {
2080
2461
  name: e && n ? `πŸ”“ Logout (${t.email})
2081
2462
  Clears stored credentials from this machine` : e && !n ? `πŸ” Login to Myop
@@ -2086,124 +2467,124 @@ const Gt = () => {
2086
2467
  name: e ? "πŸ“– Hide help" : "πŸ“– Show help",
2087
2468
  value: "help"
2088
2469
  },
2089
- new Ee(),
2470
+ new Fe(),
2090
2471
  {
2091
2472
  name: "πŸ‘‹ Exit",
2092
2473
  value: "exit"
2093
2474
  }
2094
2475
  );
2095
- let u;
2476
+ let m;
2096
2477
  try {
2097
- u = await We({
2478
+ m = await Ye({
2098
2479
  message: "What would you like to do?",
2099
- choices: M
2480
+ choices: v
2100
2481
  });
2101
- } catch (b) {
2102
- throw b.name === "ExitPromptError" && (console.log(`
2482
+ } catch (S) {
2483
+ throw S.name === "ExitPromptError" && (console.log(`
2103
2484
 
2104
2485
  πŸ‘‹ Goodbye!
2105
- `), process.exit(0)), b;
2486
+ `), process.exit(0)), S;
2106
2487
  }
2107
- switch (u) {
2488
+ switch (m) {
2108
2489
  case "init":
2109
- await Zt();
2490
+ await io();
2110
2491
  break;
2111
2492
  case "sync":
2112
2493
  console.log(`
2113
2494
  Running sync...
2114
2495
  `);
2115
- const { execSync: b } = await import("child_process");
2496
+ const { execSync: S } = await import("child_process");
2116
2497
  try {
2117
- b("node " + process.argv[1] + " sync", { stdio: "inherit" });
2498
+ S("node " + process.argv[1] + " sync", { stdio: "inherit" });
2118
2499
  } catch {
2119
2500
  }
2120
- await ee(!0, e);
2501
+ await ne(!0, e);
2121
2502
  break;
2122
2503
  case "dev":
2123
- await _e();
2504
+ await be();
2124
2505
  break;
2125
2506
  case "login":
2126
2507
  try {
2127
- await ae(), console.log(`
2128
- `), await ee(o, e);
2129
- } catch (x) {
2130
- console.error("Login failed:", x.message), await ee(o, e);
2508
+ await de(), console.log(`
2509
+ `), await ne(o, e);
2510
+ } catch (M) {
2511
+ console.error("Login failed:", M.message), await ne(o, e);
2131
2512
  }
2132
2513
  break;
2133
2514
  case "logout":
2134
- await et(), console.log(`
2135
- `), await ee(o, e);
2515
+ await nt(), console.log(`
2516
+ `), await ne(o, e);
2136
2517
  break;
2137
2518
  case "help":
2138
- await ee(o, !e);
2519
+ await ne(o, !e);
2139
2520
  break;
2140
2521
  case "exit":
2141
2522
  process.exit(0);
2142
2523
  }
2143
- }, ve = ".myop-monorepo.json", Yt = () => {
2524
+ }, ve = ".myop-monorepo.json", oo = () => {
2144
2525
  try {
2145
- const o = D.readFileSync(ve, "utf-8");
2526
+ const o = R.readFileSync(ve, "utf-8");
2146
2527
  return JSON.parse(o);
2147
2528
  } catch {
2148
2529
  return null;
2149
2530
  }
2150
- }, Kt = (o) => {
2531
+ }, no = (o) => {
2151
2532
  try {
2152
2533
  const e = {
2153
2534
  selectedComponents: o,
2154
2535
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2155
2536
  };
2156
- D.writeFileSync(ve, JSON.stringify(e, null, 2));
2537
+ R.writeFileSync(ve, JSON.stringify(e, null, 2));
2157
2538
  } catch {
2158
2539
  }
2159
- }, Qt = async () => {
2160
- const o = be(), e = !!(o != null && o.email);
2540
+ }, so = async () => {
2541
+ const o = xe(), e = !!(o != null && o.email);
2161
2542
  console.log(`
2162
2543
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Myop CLI - Monorepo Mode β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2163
2544
  `);
2164
- const t = V("Scanning for components...").start(), n = tt(".");
2545
+ const t = G("Scanning for components...").start(), n = at(".");
2165
2546
  t.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
2166
2547
  `), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
2167
- const r = Yt(), s = (r == null ? void 0 : r.selectedComponents) || [], d = s.length > 0;
2548
+ const i = oo(), s = (i == null ? void 0 : i.selectedComponents) || [], l = s.length > 0;
2168
2549
  console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
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
2550
+ `), n.forEach((u, S) => {
2551
+ const M = u.componentId ? "βœ…" : "βšͺ", T = u.componentId ? u.componentId.substring(0, 8) + "..." : "(not pushed)";
2552
+ console.log(` ${M} ${u.name}`), console.log(` Path: ${u.path}`), console.log(` ID: ${T}`), console.log("");
2553
+ }), console.log(` User: ${e ? o.email : "Not logged in"}`), l && console.log(` πŸ“‹ Using saved selection from ${ve}`), console.log("");
2554
+ const { checkbox: w } = await import("@inquirer/prompts"), v = n.map((u) => ({
2555
+ name: `${u.name} (${u.path})`,
2556
+ value: u.path,
2557
+ checked: l ? s.includes(u.path) : !0
2177
2558
  }));
2178
- let u;
2559
+ let m;
2179
2560
  try {
2180
- u = await v({
2561
+ m = await w({
2181
2562
  message: "Select components to start in dev mode:",
2182
- choices: M
2563
+ choices: v
2183
2564
  });
2184
- } catch (f) {
2185
- throw f.name === "ExitPromptError" && (console.log(`
2565
+ } catch (u) {
2566
+ throw u.name === "ExitPromptError" && (console.log(`
2186
2567
 
2187
2568
  πŸ‘‹ Goodbye!
2188
- `), process.exit(0)), f;
2569
+ `), process.exit(0)), u;
2189
2570
  }
2190
- u.length === 0 && (console.log(`
2571
+ m.length === 0 && (console.log(`
2191
2572
  ⚠️ No components selected.
2192
- `), process.exit(0)), Kt(u), console.log(`
2573
+ `), process.exit(0)), no(m), console.log(`
2193
2574
  πŸ’Ύ Selection saved to ${ve}`);
2194
- const p = n.filter((f) => u.includes(f.path));
2195
- console.log(`πŸš€ Starting dev mode for ${p.length} component${p.length > 1 ? "s" : ""}...
2575
+ const d = n.filter((u) => m.includes(u.path));
2576
+ console.log(`πŸš€ Starting dev mode for ${d.length} component${d.length > 1 ? "s" : ""}...
2196
2577
  `);
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());
2201
- let s, d;
2578
+ const { monorepoDevCommand: C } = await Promise.resolve().then(() => _t);
2579
+ await C(d);
2580
+ }, io = async () => {
2581
+ const { input: o, select: e } = await import("@inquirer/prompts"), t = await import("fs"), n = await import("path"), i = n.default.basename(process.cwd());
2582
+ let s, l;
2202
2583
  try {
2203
2584
  s = await o({
2204
2585
  message: "Component name:",
2205
- default: r
2206
- }), d = await e({
2586
+ default: i
2587
+ }), l = await e({
2207
2588
  message: "Component type:",
2208
2589
  choices: [
2209
2590
  { name: "πŸ“„ HTML", value: "html", description: "Plain HTML/JS/CSS component" },
@@ -2212,22 +2593,22 @@ Running sync...
2212
2593
  { name: "πŸ…°οΈ Angular", value: "angular", disabled: "(coming soon)" }
2213
2594
  ]
2214
2595
  });
2215
- } catch (u) {
2216
- throw u.name === "ExitPromptError" && (console.log(`
2596
+ } catch (m) {
2597
+ throw m.name === "ExitPromptError" && (console.log(`
2217
2598
 
2218
2599
  πŸ‘‹ Goodbye!
2219
- `), process.exit(0)), u;
2600
+ `), process.exit(0)), m;
2220
2601
  }
2221
- const v = {
2602
+ const w = {
2222
2603
  name: s,
2223
- type: d,
2604
+ type: l,
2224
2605
  author: "@myop-cli",
2225
2606
  HMR: !0
2226
- }, M = y.program.getOptionValue("config") || "./myop.config.json";
2607
+ }, v = y.program.getOptionValue("config") || "./myop.config.json";
2227
2608
  try {
2228
- t.writeFileSync(M, JSON.stringify(v, null, 2)), console.log(`
2229
- βœ… Created ${M}`);
2230
- const u = {
2609
+ t.writeFileSync(v, JSON.stringify(w, null, 2)), console.log(`
2610
+ βœ… Created ${v}`);
2611
+ const m = {
2231
2612
  name: s.toLowerCase().replace(/\s+/g, "-"),
2232
2613
  version: "1.0.0",
2233
2614
  type: "module",
@@ -2239,7 +2620,7 @@ Running sync...
2239
2620
  esbuild: "^0.24.0"
2240
2621
  }
2241
2622
  };
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';
2623
+ 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';
2243
2624
  import fs from 'fs';
2244
2625
  import path from 'path';
2245
2626
 
@@ -2319,7 +2700,7 @@ fs.writeFileSync('dist/index.html', html);
2319
2700
  console.log('βœ… Built dist/index.html');
2320
2701
  console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
2321
2702
  `), console.log("βœ… Created build.js");
2322
- const S = `<!DOCTYPE html>
2703
+ const C = `<!DOCTYPE html>
2323
2704
  <html lang="en">
2324
2705
  <head>
2325
2706
  <meta charset="UTF-8">
@@ -2336,8 +2717,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
2336
2717
  </body>
2337
2718
  </html>
2338
2719
  `;
2339
- t.writeFileSync("index.html", S), console.log("βœ… Created index.html");
2340
- const f = `// ${s} - Entry Point
2720
+ t.writeFileSync("index.html", C), console.log("βœ… Created index.html");
2721
+ const u = `// ${s} - Entry Point
2341
2722
  import { init } from './modules/app.js';
2342
2723
  import { setupMyopInterface } from './modules/myop.js';
2343
2724
 
@@ -2346,8 +2727,8 @@ document.addEventListener('DOMContentLoaded', () => {
2346
2727
  setupMyopInterface();
2347
2728
  });
2348
2729
  `;
2349
- t.writeFileSync("src/index.js", f), console.log("βœ… Created src/index.js");
2350
- const b = `// ${s} - Main Application Logic
2730
+ t.writeFileSync("src/index.js", u), console.log("βœ… Created src/index.js");
2731
+ const S = `// ${s} - Main Application Logic
2351
2732
 
2352
2733
  export function init() {
2353
2734
  console.log('${s} loaded');
@@ -2355,7 +2736,7 @@ export function init() {
2355
2736
  // Your component logic here
2356
2737
  }
2357
2738
  `;
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
2739
+ t.writeFileSync("src/modules/app.js", S), console.log("βœ… Created src/modules/app.js"), t.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
2359
2740
 
2360
2741
  export function setupMyopInterface() {
2361
2742
  // Called when host app sends data to this component
@@ -2371,12 +2752,12 @@ export function setupMyopInterface() {
2371
2752
  };
2372
2753
  }
2373
2754
  `), console.log("βœ… Created src/modules/myop.js");
2374
- const $ = `/* ${s} - Styles Entry Point */
2755
+ const T = `/* ${s} - Styles Entry Point */
2375
2756
  /* Add your CSS imports here - they will be auto-bundled */
2376
2757
  @import './main.css';
2377
2758
  `;
2378
- t.writeFileSync("src/styles/index.css", $), console.log("βœ… Created src/styles/index.css");
2379
- const L = `/* ${s} - Main Styles */
2759
+ t.writeFileSync("src/styles/index.css", T), console.log("βœ… Created src/styles/index.css");
2760
+ const D = `/* ${s} - Main Styles */
2380
2761
 
2381
2762
  * {
2382
2763
  box-sizing: border-box;
@@ -2405,16 +2786,18 @@ p {
2405
2786
  line-height: 1.5;
2406
2787
  }
2407
2788
  `;
2408
- t.writeFileSync("src/styles/main.css", L), console.log("βœ… Created src/styles/main.css"), t.writeFileSync(".gitignore", `node_modules/
2789
+ t.writeFileSync("src/styles/main.css", D), console.log("βœ… Created src/styles/main.css"), t.writeFileSync(".gitignore", `node_modules/
2409
2790
  dist/
2410
2791
  .temp-entry.js
2411
2792
  .temp-styles.css
2412
2793
  .DS_Store
2413
2794
  `), console.log("βœ… Created .gitignore");
2414
- const g = await import("./index-DuEoKctW.js").then((E) => E.i), P = process.cwd();
2795
+ const x = rt(process.cwd());
2796
+ x && console.log("βœ… Installed AI agent skills");
2797
+ const j = await import("./index-DuEoKctW.js").then((f) => f.i), b = process.cwd();
2415
2798
  try {
2416
- await g.init({ fs: t, dir: P });
2417
- const E = [
2799
+ await j.init({ fs: t, dir: b });
2800
+ const f = [
2418
2801
  "myop.config.json",
2419
2802
  "package.json",
2420
2803
  "build.js",
@@ -2426,64 +2809,77 @@ dist/
2426
2809
  "src/styles/index.css",
2427
2810
  "src/styles/main.css"
2428
2811
  ];
2429
- for (const C of E)
2430
- await g.add({ fs: t, dir: P, filepath: C });
2431
- await g.commit({
2812
+ if (x) {
2813
+ const E = (_, B) => {
2814
+ try {
2815
+ const U = t.readdirSync(_, { withFileTypes: !0 });
2816
+ for (const k of U) {
2817
+ const z = n.join(_, k.name), I = n.join(B, k.name);
2818
+ k.isDirectory() ? E(z, I) : f.push(I);
2819
+ }
2820
+ } catch {
2821
+ }
2822
+ };
2823
+ E(".agents/skills", ".agents/skills");
2824
+ }
2825
+ for (const E of f)
2826
+ await j.add({ fs: t, dir: b, filepath: E });
2827
+ await j.commit({
2432
2828
  fs: t,
2433
- dir: P,
2829
+ dir: b,
2434
2830
  message: "init",
2435
2831
  author: { name: "myop-cli", email: "cli@myop.dev" }
2436
2832
  }), console.log("βœ… Initialized git repository");
2437
- } catch (E) {
2438
- console.log("⚠️ Failed to initialize git repository:", E.message);
2833
+ } catch (f) {
2834
+ console.log("⚠️ Failed to initialize git repository:", f.message);
2439
2835
  }
2440
2836
  console.log(`
2441
2837
  πŸ“¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
2442
- `), y.myopConfig = v, await ee(!0);
2443
- } catch (u) {
2444
- console.error(`Failed to initialize component: ${u.message}`), process.exit(1);
2838
+ `), y.myopConfig = w, await ne(!0);
2839
+ } catch (m) {
2840
+ console.error(`Failed to initialize component: ${m.message}`), process.exit(1);
2445
2841
  }
2446
2842
  };
2447
2843
  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();
2844
+ if (y.program.getOptionValue("help") && (console.log(bt), process.exit()), y.program.getOptionValue("monorepo")) {
2845
+ await so();
2450
2846
  return;
2451
2847
  }
2452
2848
  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 };
2849
+ const w = await import("fs"), v = y.program.getOptionValue("config") || "./myop.config.json", m = y.program.version(), d = xe();
2850
+ let C = { found: !1 };
2455
2851
  try {
2456
- if (v.existsSync(M)) {
2457
- const b = v.readFileSync(M, "utf-8"), x = JSON.parse(b);
2458
- S = {
2852
+ if (w.existsSync(v)) {
2853
+ const S = w.readFileSync(v, "utf-8"), M = JSON.parse(S);
2854
+ C = {
2459
2855
  found: !0,
2460
- path: M,
2461
- name: x.name || x.componentName || null,
2462
- componentId: x.componentId || null,
2463
- organization: x.organization || null
2856
+ path: v,
2857
+ name: M.name || M.componentName || null,
2858
+ componentId: M.componentId || null,
2859
+ organization: M.organization || null
2464
2860
  };
2465
2861
  }
2466
- } catch (b) {
2467
- S = { found: !1, error: b.message };
2862
+ } catch (S) {
2863
+ C = { found: !1, error: S.message };
2468
2864
  }
2469
- const f = {
2470
- version: u,
2471
- config: S,
2865
+ const u = {
2866
+ version: m,
2867
+ config: C,
2472
2868
  auth: {
2473
- loggedIn: !!(p != null && p.email),
2474
- email: (p == null ? void 0 : p.email) || null
2869
+ loggedIn: !!(d != null && d.email),
2870
+ email: (d == null ? void 0 : d.email) || null
2475
2871
  }
2476
2872
  };
2477
- console.log(JSON.stringify(f, null, 2)), process.exit(0);
2873
+ console.log(JSON.stringify(u, null, 2)), process.exit(0);
2478
2874
  }
2479
- let n = V({
2875
+ let n = G({
2480
2876
  text: "Loading Myop CLI...",
2481
2877
  color: "green"
2482
2878
  }).start();
2483
- const r = Se();
2484
- await Wt(500), n.stop();
2879
+ const i = $e();
2880
+ await Xt(500), n.stop();
2485
2881
  const s = y.program.version();
2486
- await zt(s) || await ee(r.configFound);
2882
+ await Zt(s) || await ne(i.configFound);
2487
2883
  });
2488
2884
  y.program.parse(process.argv);
2489
2885
  y.program.opts();