@myop/cli 0.1.19 β†’ 0.1.21

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