@myop/cli 0.1.48 β†’ 0.1.50

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