@myop/cli 0.1.18 β†’ 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/myop-cli.js +570 -575
  2. package/package.json +1 -1
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 Ie, Separator as me } from "@inquirer/prompts";
4
- import { Command as We, Option as ce } from "commander";
5
- import { execSync as re, spawn as Ge } from "child_process";
6
- import Z from "path";
7
- import A from "fs";
8
- import fe from "crypto";
9
- import Ye from "http";
10
- import { URL as je, URLSearchParams as _e } from "url";
11
- import Ke from "open";
12
- import Xe from "os";
13
- const Qe = `
2
+ import P from "ora";
3
+ import { select as Ne, Separator as fe } from "@inquirer/prompts";
4
+ import { Command as Ye, Option as le } from "commander";
5
+ import { execSync as ie, spawn as Ke } from "child_process";
6
+ import q from "path";
7
+ import R from "fs";
8
+ import he from "crypto";
9
+ import Xe from "http";
10
+ import { URL as ke, URLSearchParams as Ee } from "url";
11
+ import Qe from "open";
12
+ import Ze from "os";
13
+ const qe = `
14
14
  Usage: myop [OPTIONS] COMMAND [ARGS]...
15
15
 
16
16
  A powerful command-line interface for managing your Myop projects.
@@ -52,81 +52,81 @@ Examples:
52
52
  verbose: !1
53
53
  },
54
54
  myopConfig: null
55
- }, Pe = {
55
+ }, Te = {
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
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}`);
62
+ const n = q.join(d.executionPath, "/node_modules/@myop/flow-types/");
63
+ console.info(`Generate flow at ${n}`), console.info(`Generated flow at ${n}`);
64
64
  }
65
65
  process.exit();
66
66
  }
67
- }, Ze = (e) => {
68
- const o = Z.join(d.executionPath, e);
69
- console.info(`reading config file from: ${o}`);
70
- const n = A.readFileSync(o, "utf8"), a = JSON.parse(n);
67
+ }, et = (e) => {
68
+ const n = q.join(d.executionPath, e);
69
+ console.info(`reading config file from: ${n}`);
70
+ const s = R.readFileSync(n, "utf8"), a = JSON.parse(s);
71
71
  return console.info("config file loaded, ", a), a;
72
- }, ge = (e, o) => {
73
- const n = Z.join(d.executionPath, e);
74
- console.info(`writing config file to: ${n}`);
72
+ }, ye = (e, n) => {
73
+ const s = q.join(d.executionPath, e);
74
+ console.info(`writing config file to: ${s}`);
75
75
  try {
76
- const a = JSON.stringify(o, null, 2);
77
- A.writeFileSync(n, a), console.info(`config file updated ${a}`);
76
+ const a = JSON.stringify(n, null, 2);
77
+ R.writeFileSync(s, a), console.info(`config file updated ${a}`);
78
78
  } catch (a) {
79
- throw console.info(`error ${a} while writing to ${n}, JSON: ${o}`), console.log(`
80
- ⚠️ Failed write config file to ${n}, for more info use verbose flag`), a;
79
+ throw console.info(`error ${a} while writing to ${s}, JSON: ${n}`), console.log(`
80
+ ⚠️ Failed write config file to ${s}, for more info use verbose flag`), a;
81
81
  }
82
- }, Ee = {
82
+ }, Pe = {
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), ge(d.options.configPath, d.myopConfig);
87
+ d.myopConfig.flows.includes(e) || d.myopConfig.flows.push(e), ye(d.options.configPath, d.myopConfig);
88
88
  },
89
89
  action: async () => {
90
90
  }
91
- }, Ne = {
91
+ }, Re = {
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), ge(d.options.configPath, d.myopConfig);
96
+ d.myopConfig.flows = d.myopConfig.flows.filter((n) => n !== e), ye(d.options.configPath, d.myopConfig);
97
97
  },
98
98
  action: () => {
99
99
  }
100
- }, qe = {
100
+ }, tt = {
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
- }, et = {
107
+ }, ot = {
108
108
  name: "🟒 Create new component",
109
109
  value: "-",
110
110
  disabled: "(not available yet)"
111
- }, tt = {
111
+ }, nt = {
112
112
  name: "πŸ”΅ Create new experience",
113
113
  value: "-",
114
114
  disabled: "(not available yet)"
115
- }, ot = {
115
+ }, st = {
116
116
  name: "🟑 Create new skin",
117
117
  value: "-",
118
118
  disabled: "(not available yet)"
119
- }, nt = {
119
+ }, rt = {
120
120
  name: "πŸ”΄ Create new flow",
121
121
  value: "-",
122
122
  disabled: "(not available yet)"
123
- }, st = {
123
+ }, it = {
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
- }, rt = [st, et, tt, ot, nt];
129
- function it(e, o, n, a) {
128
+ }, at = [it, ot, nt, st, rt];
129
+ function ct(e, n, s, a) {
130
130
  return `<!DOCTYPE html>
131
131
  <html lang="en">
132
132
  <head>
@@ -134,7 +134,7 @@ function it(e, o, n, a) {
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
- ${n}
137
+ ${s}
138
138
  </style>
139
139
  </head>
140
140
  <body>
@@ -143,7 +143,7 @@ ${n}
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: ${n}</span>
147
147
  </div>
148
148
  </div>
149
149
 
@@ -216,27 +216,32 @@ ${a}
216
216
  </body>
217
217
  </html>`;
218
218
  }
219
- async function ke() {
220
- const e = await import("fs"), o = await import("path"), { exec: n } = await import("child_process"), a = await import("http"), { createHash: f } = await import("node:crypto");
219
+ async function Fe() {
220
+ const e = await import("fs"), n = await import("path"), { exec: s } = await import("child_process"), a = await import("http"), { createHash: f } = await import("node:crypto");
221
221
  let c;
222
222
  if (import.meta.url.startsWith("file://")) {
223
223
  const t = new URL(import.meta.url).pathname, r = process.platform === "win32" && t.startsWith("/") ? t.slice(1) : t;
224
- c = o.default.dirname(r);
224
+ c = n.default.dirname(r);
225
225
  } 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, S = "./dist";
228
- let j = !1, v = !1;
229
- const k = /* @__PURE__ */ new Map(), z = d.program.getOptionValue("config") || "./myop.config.json";
230
- let x, E, h = !1;
226
+ c = n.default.dirname(import.meta.url);
227
+ const u = n.default.join(c, "commands", "dev", "management-website"), w = e.default.readFileSync(n.default.join(u, "styles.css"), "utf-8"), O = e.default.readFileSync(n.default.join(u, "app.js"), "utf-8"), m = 9292, y = 9293, b = "./dist";
228
+ let I = !1, v = !1;
229
+ const E = (o) => {
230
+ const t = process.platform;
231
+ let r;
232
+ t === "darwin" ? r = `open "${o}"` : t === "win32" ? r = `start "" "${o}"` : r = `xdg-open "${o}"`, s(r, (i) => {
233
+ });
234
+ }, F = /* @__PURE__ */ new Map(), W = d.program.getOptionValue("config") || "./myop.config.json";
235
+ let S, h, C = !1;
231
236
  try {
232
- const s = e.default.readFileSync(z, "utf-8"), t = JSON.parse(s);
233
- x = t.componentId || "DEV", E = t.componentName || t.name || null, h = t.HMR === !0, h && console.log("πŸ”₯ HMR enabled");
234
- } catch (s) {
235
- console.error("❌ Error reading myop.config.json:", s.message), process.exit(1);
237
+ const o = e.default.readFileSync(W, "utf-8"), t = JSON.parse(o);
238
+ S = t.componentId || "DEV", h = t.componentName || t.name || null, C = t.HMR === !0, C && console.log("πŸ”₯ HMR enabled");
239
+ } catch (o) {
240
+ console.error("❌ Error reading myop.config.json:", o.message), process.exit(1);
236
241
  }
237
- const $ = async () => {
238
- if (x !== "DEV" && x !== "NEW")
239
- return x;
242
+ const A = async () => {
243
+ if (S !== "DEV" && S !== "NEW")
244
+ return S;
240
245
  try {
241
246
  const t = ((await new Promise((l, p) => {
242
247
  const g = {
@@ -245,19 +250,19 @@ async function ke() {
245
250
  path: "/_list",
246
251
  method: "GET",
247
252
  timeout: 1e3
248
- }, M = a.default.request(g, (_) => {
249
- let H = "";
250
- _.on("data", (L) => H += L), _.on("end", () => {
253
+ }, x = a.default.request(g, (N) => {
254
+ let L = "";
255
+ N.on("data", (J) => L += J), N.on("end", () => {
251
256
  try {
252
- l(JSON.parse(H));
257
+ l(JSON.parse(L));
253
258
  } catch {
254
259
  l({ components: [] });
255
260
  }
256
261
  });
257
262
  });
258
- M.on("error", () => l({ components: [] })), M.on("timeout", () => {
259
- M.destroy(), l({ components: [] });
260
- }), M.end();
263
+ x.on("error", () => l({ components: [] })), x.on("timeout", () => {
264
+ x.destroy(), l({ components: [] });
265
+ }), x.end();
261
266
  })).components || []).map(([l]) => l).filter((l) => l === "DEV" || l === "NEW" || /^DEV\d+$/.test(l) || /^NEW\d+$/.test(l));
262
267
  if (t.length === 0)
263
268
  return "DEV1";
@@ -270,8 +275,8 @@ async function ke() {
270
275
  } catch {
271
276
  return "DEV1";
272
277
  }
273
- }, N = process.cwd(), K = (s) => {
274
- const t = o.default.extname(s).toLowerCase();
278
+ }, D = process.cwd(), V = (o) => {
279
+ const t = n.default.extname(o).toLowerCase();
275
280
  return {
276
281
  ".html": "text/html",
277
282
  ".js": "text/javascript",
@@ -283,9 +288,9 @@ async function ke() {
283
288
  ".svg": "image/svg+xml",
284
289
  ".ico": "image/x-icon"
285
290
  }[t] || "application/octet-stream";
286
- }, b = /* @__PURE__ */ new Map(), q = [], Ae = 50, D = [], V = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), De = (s, t, r) => {
287
- if (s.url.startsWith("/_hmr/")) {
288
- const i = s.url.split("/_hmr/")[1], l = s.headers["sec-websocket-key"], p = f("sha1").update(l + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
291
+ }, j = /* @__PURE__ */ new Map(), ee = [], Le = 50, H = [], G = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map(), Je = (o, t, r) => {
292
+ if (o.url.startsWith("/_hmr/")) {
293
+ const i = o.url.split("/_hmr/")[1], l = o.headers["sec-websocket-key"], p = f("sha1").update(l + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
289
294
  t.write(
290
295
  `HTTP/1.1 101 Switching Protocols\r
291
296
  Upgrade: websocket\r
@@ -293,33 +298,33 @@ Connection: Upgrade\r
293
298
  Sec-WebSocket-Accept: ${p}\r
294
299
  \r
295
300
  `
296
- ), U.has(i) || U.set(i, /* @__PURE__ */ new Set()), U.get(i).add(t), console.log(`πŸ”Œ HMR client connected: ${i}`), t.on("close", () => {
297
- const g = U.get(i);
298
- g && (g.delete(t), g.size === 0 && U.delete(i)), console.log(`πŸ”Œ HMR client disconnected: ${i}`);
301
+ ), B.has(i) || B.set(i, /* @__PURE__ */ new Set()), B.get(i).add(t), console.log(`πŸ”Œ HMR client connected: ${i}`), t.on("close", () => {
302
+ const g = B.get(i);
303
+ g && (g.delete(t), g.size === 0 && B.delete(i)), console.log(`πŸ”Œ HMR client disconnected: ${i}`);
299
304
  }), t.on("error", () => {
300
- const g = U.get(i);
305
+ const g = B.get(i);
301
306
  g && g.delete(t);
302
307
  });
303
308
  }
304
- }, de = a.default.createServer((s, t) => {
305
- if (t.setHeader("Content-Type", "application/json"), s.method === "POST" && s.url === "/_register") {
309
+ }, pe = a.default.createServer((o, t) => {
310
+ if (t.setHeader("Content-Type", "application/json"), o.method === "POST" && o.url === "/_register") {
306
311
  let r = "";
307
- s.on("data", (i) => r += i), s.on("end", () => {
312
+ o.on("data", (i) => r += i), o.on("end", () => {
308
313
  try {
309
314
  const { componentId: i, distPath: l, componentName: p } = JSON.parse(r);
310
- b.set(i, { path: l, name: p || null });
315
+ j.set(i, { path: l, name: p || null });
311
316
  const g = p ? ` (${p})` : "";
312
- console.log(`βœ… Registered: ${i}${g} -> ${l}`), t.writeHead(200), t.end(JSON.stringify({ success: !0, registered: Array.from(b.keys()) }));
313
- const M = Array.from(b.entries()).map(([_, H]) => ({
314
- id: _,
315
- path: H.path,
316
- name: H.name
317
+ console.log(`βœ… Registered: ${i}${g} -> ${l}`), t.writeHead(200), t.end(JSON.stringify({ success: !0, registered: Array.from(j.keys()) }));
318
+ const x = Array.from(j.entries()).map(([N, L]) => ({
319
+ id: N,
320
+ path: L.path,
321
+ name: L.name
317
322
  }));
318
- D.forEach((_) => {
323
+ H.forEach((N) => {
319
324
  try {
320
- _.write(`data: ${JSON.stringify({
325
+ N.write(`data: ${JSON.stringify({
321
326
  type: "components",
322
- components: M
327
+ components: x
323
328
  })}
324
329
 
325
330
  `);
@@ -330,18 +335,18 @@ Sec-WebSocket-Accept: ${p}\r
330
335
  t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
331
336
  }
332
337
  });
333
- } else if (s.method === "POST" && s.url === "/_unregister") {
338
+ } else if (o.method === "POST" && o.url === "/_unregister") {
334
339
  let r = "";
335
- s.on("data", (i) => r += i), s.on("end", () => {
340
+ o.on("data", (i) => r += i), o.on("end", () => {
336
341
  try {
337
342
  const { componentId: i } = JSON.parse(r);
338
- b.delete(i), console.log(`❌ Unregistered: ${i}`), t.writeHead(200), t.end(JSON.stringify({ success: !0 }));
339
- const l = Array.from(b.entries()).map(([p, g]) => ({
343
+ j.delete(i), console.log(`❌ Unregistered: ${i}`), t.writeHead(200), t.end(JSON.stringify({ success: !0 }));
344
+ const l = Array.from(j.entries()).map(([p, g]) => ({
340
345
  id: p,
341
346
  path: g.path,
342
347
  name: g.name
343
348
  }));
344
- D.forEach((p) => {
349
+ H.forEach((p) => {
345
350
  try {
346
351
  p.write(`data: ${JSON.stringify({
347
352
  type: "components",
@@ -356,124 +361,124 @@ Sec-WebSocket-Accept: ${p}\r
356
361
  t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
357
362
  }
358
363
  });
359
- } else s.method === "GET" && s.url === "/_list" ? (t.writeHead(200), t.end(JSON.stringify({ components: Array.from(b.entries()) }))) : (t.writeHead(404), t.end(JSON.stringify({ error: "Not found" })));
360
- }), ee = a.default.createServer((s, t) => {
361
- if (s.url.includes("..")) {
364
+ } else o.method === "GET" && o.url === "/_list" ? (t.writeHead(200), t.end(JSON.stringify({ components: Array.from(j.entries()) }))) : (t.writeHead(404), t.end(JSON.stringify({ error: "Not found" })));
365
+ }), te = a.default.createServer((o, t) => {
366
+ if (o.url.includes("..")) {
362
367
  t.writeHead(403, { "Content-Type": "text/plain" }), t.end("Forbidden");
363
368
  return;
364
369
  }
365
- const r = new URL(s.url, `http://localhost:${u}`), i = r.pathname, l = i.split("/").filter((P) => P);
370
+ const r = new URL(o.url, `http://localhost:${m}`), i = r.pathname, l = i.split("/").filter((_) => _);
366
371
  if (i.startsWith("/consume")) {
367
- const P = r.searchParams.get("id");
368
- if (!P) {
372
+ const _ = r.searchParams.get("id");
373
+ if (!_) {
369
374
  t.writeHead(400, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
370
375
  return;
371
376
  }
372
- const R = b.get(P), J = R ? R.path : null, Oe = (W) => {
373
- let C = "Unknown", T = "Unknown";
374
- if (s.headers.referer || s.headers.referrer) {
375
- const O = s.headers.referer || s.headers.referrer;
377
+ const T = j.get(_), U = T ? T.path : null, _e = (Y) => {
378
+ let $ = "Unknown", k = "Unknown";
379
+ if (o.headers.referer || o.headers.referrer) {
380
+ const M = o.headers.referer || o.headers.referrer;
376
381
  try {
377
- const G = new URL(O);
378
- C = G.origin, T = G.hostname || G.origin;
382
+ const K = new URL(M);
383
+ $ = K.origin, k = K.hostname || K.origin;
379
384
  } catch {
380
- C = O, T = O;
385
+ $ = M, k = M;
381
386
  }
382
- } else if (s.headers.origin)
387
+ } else if (o.headers.origin)
383
388
  try {
384
- const O = new URL(s.headers.origin);
385
- C = O.origin, T = O.hostname || O.origin;
389
+ const M = new URL(o.headers.origin);
390
+ $ = M.origin, k = M.hostname || M.origin;
386
391
  } catch {
387
- C = s.headers.origin, T = s.headers.origin;
392
+ $ = o.headers.origin, k = o.headers.origin;
388
393
  }
389
- else if (s.socket.remoteAddress) {
390
- const O = s.socket.remoteAddress;
391
- O === "::1" || O === "::ffff:127.0.0.1" ? (C = "localhost", T = "localhost (direct)") : (C = O, T = O.replace("::ffff:", ""));
394
+ else if (o.socket.remoteAddress) {
395
+ const M = o.socket.remoteAddress;
396
+ M === "::1" || M === "::ffff:127.0.0.1" ? ($ = "localhost", k = "localhost (direct)") : ($ = M, k = M.replace("::ffff:", ""));
392
397
  }
393
- const pe = s.headers.referer || s.headers.referrer || C, ne = {
398
+ const me = o.headers.referer || o.headers.referrer || $, se = {
394
399
  type: "request",
395
- componentId: P,
400
+ componentId: _,
396
401
  timestamp: Date.now(),
397
- servedLocally: W,
398
- referrer: pe,
399
- origin: C,
400
- originLabel: T
402
+ servedLocally: Y,
403
+ referrer: me,
404
+ origin: $,
405
+ originLabel: k
401
406
  };
402
- V.has(C) || (V.set(C, {
403
- url: C,
404
- label: T,
407
+ G.has($) || (G.set($, {
408
+ url: $,
409
+ label: k,
405
410
  firstSeen: Date.now(),
406
411
  requestCount: 0
407
- }), D.forEach((O) => {
412
+ }), H.forEach((M) => {
408
413
  try {
409
- O.write(`data: ${JSON.stringify({
414
+ M.write(`data: ${JSON.stringify({
410
415
  type: "origins",
411
- origins: Array.from(V.values())
416
+ origins: Array.from(G.values())
412
417
  })}
413
418
 
414
419
  `);
415
420
  } catch {
416
421
  }
417
422
  }));
418
- const Ve = V.get(C);
419
- Ve.requestCount++, D.forEach((O) => {
423
+ const ue = G.get($);
424
+ ue.requestCount++, H.forEach((M) => {
420
425
  try {
421
- O.write(`data: ${JSON.stringify({
426
+ M.write(`data: ${JSON.stringify({
422
427
  type: "origins",
423
- origins: Array.from(V.values())
428
+ origins: Array.from(G.values())
424
429
  })}
425
430
 
426
431
  `);
427
432
  } catch {
428
433
  }
429
- }), q.push(ne), q.length > Ae && q.shift(), D.forEach((O) => {
434
+ }), ee.push(se), ee.length > Le && ee.shift(), H.forEach((M) => {
430
435
  try {
431
- O.write(`data: ${JSON.stringify(ne)}
436
+ M.write(`data: ${JSON.stringify(se)}
432
437
 
433
438
  `);
434
439
  } catch {
435
440
  }
436
441
  });
437
442
  };
438
- if (J) {
439
- const W = o.default.join(J, "index.html");
440
- e.default.readFile(W, "utf-8", (C, T) => {
441
- if (C) {
442
- console.log(`❌ File not found: ${W}`), t.writeHead(404, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "index.html not found" }));
443
+ if (U) {
444
+ const Y = n.default.join(U, "index.html");
445
+ e.default.readFile(Y, "utf-8", ($, k) => {
446
+ if ($) {
447
+ console.log(`❌ File not found: ${Y}`), t.writeHead(404, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "index.html not found" }));
443
448
  return;
444
449
  }
445
- const pe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ne = {
450
+ const me = xe(k, _), se = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ue = {
446
451
  item: {
447
- name: P,
448
- id: P,
452
+ name: _,
453
+ id: _,
449
454
  consume_variant: [
450
455
  {
451
- id: pe,
456
+ id: se,
452
457
  name: "dev version",
453
458
  loader: {
454
459
  type: "HTMLLoader",
455
460
  shadowRootMode: "localFrame",
456
- HTML: T
461
+ HTML: me
457
462
  }
458
463
  }
459
464
  ]
460
465
  }
461
466
  };
462
- console.log(`βœ… Serving consume JSON for: ${P}`), Oe(!0), t.writeHead(200, {
467
+ console.log(`βœ… Serving consume JSON for: ${_}`), _e(!0), t.writeHead(200, {
463
468
  "Content-Type": "application/json",
464
469
  "Access-Control-Allow-Origin": "*"
465
- }), t.end(JSON.stringify(ne, null, 2));
470
+ }), t.end(JSON.stringify(ue, null, 2));
466
471
  });
467
472
  } else {
468
- console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${P}`);
469
- const W = `https://cloud.myop.dev/consume${r.search}`;
470
- Oe(!1), fetch(W).then((C) => C.text()).then((C) => {
473
+ console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${_}`);
474
+ const Y = `https://cloud.myop.dev/consume${r.search}`;
475
+ _e(!1), fetch(Y).then(($) => $.text()).then(($) => {
471
476
  t.writeHead(200, {
472
477
  "Content-Type": "application/json",
473
478
  "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" }));
479
+ }), t.end($);
480
+ }).catch(($) => {
481
+ console.error(`❌ Proxy error: ${$.message}`), t.writeHead(502, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
477
482
  });
478
483
  }
479
484
  return;
@@ -484,35 +489,35 @@ Sec-WebSocket-Accept: ${p}\r
484
489
  "Cache-Control": "no-cache",
485
490
  Connection: "keep-alive",
486
491
  "Access-Control-Allow-Origin": "*"
487
- }), D.push(t);
488
- const P = Array.from(b.entries()).map(([R, J]) => ({
489
- id: R,
490
- path: J.path,
491
- name: J.name
492
+ }), H.push(t);
493
+ const _ = Array.from(j.entries()).map(([T, U]) => ({
494
+ id: T,
495
+ path: U.path,
496
+ name: U.name
492
497
  }));
493
498
  t.write(`data: ${JSON.stringify({
494
499
  type: "components",
495
- components: P
500
+ components: _
496
501
  })}
497
502
 
498
503
  `), t.write(`data: ${JSON.stringify({
499
504
  type: "origins",
500
- origins: Array.from(V.values())
505
+ origins: Array.from(G.values())
501
506
  })}
502
507
 
503
508
  `), t.write(`data: ${JSON.stringify({
504
509
  type: "requestLog",
505
- log: q
510
+ log: ee
506
511
  })}
507
512
 
508
- `), s.on("close", () => {
509
- const R = D.indexOf(t);
510
- R !== -1 && D.splice(R, 1);
513
+ `), o.on("close", () => {
514
+ const T = H.indexOf(t);
515
+ T !== -1 && H.splice(T, 1);
511
516
  });
512
517
  return;
513
518
  }
514
519
  if (l.length === 0) {
515
- t.writeHead(200, { "Content-Type": "text/html" }), t.end(it(u, y, w, I));
520
+ t.writeHead(200, { "Content-Type": "text/html" }), t.end(ct(m, y, w, O));
516
521
  return;
517
522
  }
518
523
  if (l[0] !== "view") {
@@ -523,28 +528,28 @@ Sec-WebSocket-Accept: ${p}\r
523
528
  t.writeHead(400, { "Content-Type": "text/plain" }), t.end("Component ID required. Use /view/<componentId>/");
524
529
  return;
525
530
  }
526
- const p = l[1], g = b.get(p);
531
+ const p = l[1], g = j.get(p);
527
532
  if (!g) {
528
533
  t.writeHead(404, { "Content-Type": "text/plain" }), t.end(`Component not found: ${p}`);
529
534
  return;
530
535
  }
531
- const M = g.path, _ = l.slice(2), H = _.length === 0 ? "index.html" : _.join("/"), L = o.default.join(M, H);
532
- console.log(`πŸ“₯ Request: ${s.url} -> ${L}`), e.default.readFile(L, (P, R) => {
533
- if (P) {
534
- console.log(`❌ File not found: ${L}`), t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Not Found");
536
+ const x = g.path, N = l.slice(2), L = N.length === 0 ? "index.html" : N.join("/"), J = n.default.join(x, L);
537
+ console.log(`πŸ“₯ Request: ${o.url} -> ${J}`), e.default.readFile(J, (_, T) => {
538
+ if (_) {
539
+ console.log(`❌ File not found: ${J}`), t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Not Found");
535
540
  return;
536
541
  }
537
- const J = K(L);
538
- console.log(`βœ… Serving: ${L} (${J})`), t.writeHead(200, {
539
- "Content-Type": J,
542
+ const U = V(J);
543
+ console.log(`βœ… Serving: ${J} (${U})`), t.writeHead(200, {
544
+ "Content-Type": U,
540
545
  "Access-Control-Allow-Origin": "*"
541
- }), t.end(R);
546
+ }), t.end(T);
542
547
  });
543
- }), ve = () => new Promise((s, t) => {
548
+ }), be = () => new Promise((o, t) => {
544
549
  const r = JSON.stringify({
545
- componentId: x,
546
- distPath: o.default.resolve(N, S),
547
- componentName: E
550
+ componentId: S,
551
+ distPath: n.default.resolve(D, b),
552
+ componentName: h
548
553
  }), i = {
549
554
  hostname: "localhost",
550
555
  port: y,
@@ -556,13 +561,13 @@ Sec-WebSocket-Accept: ${p}\r
556
561
  }
557
562
  }, l = a.default.request(i, (p) => {
558
563
  let g = "";
559
- p.on("data", (M) => g += M), p.on("end", () => {
560
- p.statusCode === 200 ? s(JSON.parse(g)) : t(new Error(`Registration failed: ${p.statusCode}`));
564
+ p.on("data", (x) => g += x), p.on("end", () => {
565
+ p.statusCode === 200 ? o(JSON.parse(g)) : t(new Error(`Registration failed: ${p.statusCode}`));
561
566
  });
562
567
  });
563
568
  l.on("error", t), l.write(r), l.end();
564
- }), He = () => new Promise((s, t) => {
565
- const r = JSON.stringify({ componentId: x }), i = {
569
+ }), Ue = () => new Promise((o, t) => {
570
+ const r = JSON.stringify({ componentId: S }), i = {
566
571
  hostname: "localhost",
567
572
  port: y,
568
573
  path: "/_unregister",
@@ -572,23 +577,14 @@ Sec-WebSocket-Accept: ${p}\r
572
577
  "Content-Length": Buffer.byteLength(r)
573
578
  }
574
579
  }, l = a.default.request(i, (p) => {
575
- s();
580
+ o();
576
581
  });
577
- l.on("error", () => s()), l.write(r), l.end();
578
- }), Le = () => {
579
- if (!h) return;
580
- const s = o.default.join(S, "index.html");
581
- try {
582
- let t = e.default.readFileSync(s, "utf-8");
583
- if (t.includes("<!-- MYOP HMR -->")) {
584
- const i = t.indexOf("<!-- MYOP HMR -->"), l = t.indexOf("<\/script>", i) + 9;
585
- t = t.slice(0, i) + t.slice(l);
586
- }
587
- const r = `
582
+ l.on("error", () => o()), l.write(r), l.end();
583
+ }), Be = (o) => `
588
584
  <!-- MYOP HMR -->
589
585
  <script>
590
586
  (function() {
591
- const componentId = '${x}';
587
+ const componentId = '${o}';
592
588
  const wsUrl = 'ws://localhost:${y}/_hmr/' + componentId;
593
589
  let ws;
594
590
  let reconnectAttempts = 0;
@@ -689,13 +685,12 @@ Sec-WebSocket-Accept: ${p}\r
689
685
  connect();
690
686
  })();
691
687
  <\/script>
692
- `;
693
- t.includes("</body>") ? t = t.replace("</body>", `${r}</body>`) : t.includes("</html>") ? t = t.replace("</html>", `${r}</html>`) : t += r, e.default.writeFileSync(s, t, "utf-8"), console.log("πŸ”₯ HMR script injected");
694
- } catch (t) {
695
- console.error("❌ Failed to inject HMR script:", t.message);
696
- }
697
- }, Je = (s) => {
698
- const t = Buffer.from(s), r = t.length;
688
+ `, xe = (o, t) => {
689
+ if (!C) return o;
690
+ const r = Be(t);
691
+ return o.includes("</body>") ? o.replace("</body>", `${r}</body>`) : o.includes("</html>") ? o.replace("</html>", `${r}</html>`) : o + r;
692
+ }, ze = (o) => {
693
+ const t = Buffer.from(o), r = t.length;
699
694
  let i;
700
695
  return r < 126 ? i = Buffer.concat([
701
696
  Buffer.from([129, r]),
@@ -714,89 +709,84 @@ Sec-WebSocket-Accept: ${p}\r
714
709
  // 64-bit length
715
710
  t
716
711
  ]), i;
717
- }, Ue = () => {
718
- if (!h) return;
719
- const s = U.get(x);
720
- if (!s || s.size === 0)
712
+ }, We = () => {
713
+ if (!C) return;
714
+ const o = B.get(S);
715
+ if (!o || o.size === 0)
721
716
  return;
722
- console.log(`πŸ”₯ Notifying ${s.size} HMR client(s)`);
723
- const t = o.default.join(S, "index.html");
717
+ console.log(`πŸ”₯ Notifying ${o.size} HMR client(s)`);
718
+ const t = n.default.join(b, "index.html");
724
719
  try {
725
- let r = e.default.readFileSync(t, "utf-8");
726
- if (r.includes("<!-- MYOP HMR -->")) {
727
- const p = r.indexOf("<!-- MYOP HMR -->"), g = r.indexOf("<\/script>", p) + 9;
728
- r = r.slice(0, p) + r.slice(g);
729
- }
730
- const i = JSON.stringify({
720
+ const r = e.default.readFileSync(t, "utf-8"), i = xe(r, S), l = JSON.stringify({
731
721
  type: "update",
732
- html: r
733
- }), l = Je(i);
734
- s.forEach((p) => {
722
+ html: i
723
+ }), p = ze(l);
724
+ o.forEach((g) => {
735
725
  try {
736
- p.write(l);
726
+ g.write(p);
737
727
  } catch {
738
- s.delete(p);
728
+ o.delete(g);
739
729
  }
740
730
  });
741
731
  } catch (r) {
742
732
  console.error("❌ Failed to read HTML for HMR:", r.message);
743
733
  }
744
734
  };
745
- let xe = !1;
746
- const te = () => {
747
- if (j) {
735
+ let Ce = !1;
736
+ const oe = (o) => {
737
+ if (I) {
748
738
  v = !0;
749
739
  return;
750
740
  }
751
- j = !0, console.log(`
752
- πŸ”¨ Building...`), n("npm run build", (s, t, r) => {
753
- if (j = !1, s) {
754
- const i = s.message + (r || "");
755
- if (!xe && i.includes("ERR_MODULE_NOT_FOUND") && i.includes("esbuild")) {
756
- xe = !0, console.log("πŸ“¦ Missing dependencies detected, running npm install..."), n("npm install", (l, p, g) => {
757
- l ? (console.error("❌ Failed to install dependencies:", l.message), g && console.error(g)) : (console.log("βœ… Dependencies installed"), te());
741
+ I = !0, console.log(`
742
+ πŸ”¨ Building...`), s("npm run build", (t, r, i) => {
743
+ if (I = !1, t) {
744
+ const l = t.message + (i || "");
745
+ if (!Ce && l.includes("ERR_MODULE_NOT_FOUND") && l.includes("esbuild")) {
746
+ Ce = !0, console.log("πŸ“¦ Missing dependencies detected, running npm install..."), s("npm install", (p, g, x) => {
747
+ p ? (console.error("❌ Failed to install dependencies:", p.message), x && console.error(x)) : (console.log("βœ… Dependencies installed"), oe(o));
758
748
  });
759
749
  return;
760
750
  }
761
- console.error("❌ Build failed:", s.message), r && console.error(r);
751
+ console.error("❌ Build failed:", t.message), i && console.error(i);
762
752
  } else
763
- console.log("βœ… Build completed"), t && console.log(t), Le(), Ue();
764
- v && (v = !1, te());
753
+ console.log("βœ… Build completed"), r && console.log(r), We(), o && o();
754
+ v && (v = !1, oe());
765
755
  });
766
- }, Se = /* @__PURE__ */ new Set(), be = (s) => {
767
- e.default.readdir(s, { withFileTypes: !0 }, (t, r) => {
756
+ }, $e = /* @__PURE__ */ new Set(), Me = (o) => {
757
+ e.default.readdir(o, { withFileTypes: !0 }, (t, r) => {
768
758
  t || (r.forEach((i) => {
769
- const l = o.default.join(s, i.name);
759
+ const l = n.default.join(o, i.name);
770
760
  if (i.isDirectory())
771
- i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") && be(l);
761
+ i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") && Me(l);
772
762
  else if (i.isFile()) {
773
- const p = o.default.extname(i.name);
763
+ const p = n.default.extname(i.name);
774
764
  if (p === ".js" || p === ".css" || p === ".html")
775
765
  try {
776
766
  const g = e.default.readFileSync(l, "utf-8");
777
- k.set(l, g);
767
+ F.set(l, g);
778
768
  } catch {
779
769
  }
780
770
  }
781
- }), Se.has(s) || (Se.add(s), e.default.watch(s, (i, l) => {
771
+ }), $e.has(o) || ($e.add(o), e.default.watch(o, (i, l) => {
782
772
  if (!l) return;
783
- const p = o.default.extname(l);
773
+ const p = n.default.extname(l);
784
774
  if (p !== ".js" && p !== ".css" && p !== ".html") return;
785
- const g = o.default.join(s, l);
775
+ const g = n.default.join(o, l);
786
776
  setTimeout(() => {
787
777
  try {
788
- const M = e.default.readFileSync(g, "utf-8"), _ = k.get(g);
789
- M !== _ && (k.set(g, M), console.log(`πŸ“ File changed: ${g}`), te());
778
+ const x = e.default.readFileSync(g, "utf-8"), N = F.get(g);
779
+ x !== N && (F.set(g, x), console.log(`πŸ“ File changed: ${g}`), oe());
790
780
  } catch {
791
781
  }
792
782
  }, 50);
793
783
  })));
794
784
  });
795
- }, Ce = () => {
785
+ }, Oe = (o) => {
796
786
  console.log(`
797
- πŸ”¨ Component: ${x}`), te(), be(N), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
787
+ πŸ”¨ Component: ${S}`), oe(o), Me(D), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
798
788
  `);
799
- }, Be = () => new Promise((s) => {
789
+ }, Ve = () => new Promise((o) => {
800
790
  const t = {
801
791
  hostname: "localhost",
802
792
  port: y,
@@ -804,21 +794,21 @@ Sec-WebSocket-Accept: ${p}\r
804
794
  method: "GET",
805
795
  timeout: 1e3
806
796
  }, r = a.default.request(t, (i) => {
807
- s(!0);
797
+ o(!0);
808
798
  });
809
- r.on("error", () => s(!1)), r.on("timeout", () => {
810
- r.destroy(), s(!1);
799
+ r.on("error", () => o(!1)), r.on("timeout", () => {
800
+ r.destroy(), o(!1);
811
801
  }), r.end();
812
- }), ze = () => new Promise((s) => {
802
+ }), Ge = () => new Promise((o) => {
813
803
  const t = a.default.createServer((r, i) => {
814
804
  if (i.setHeader("Content-Type", "application/json"), r.method === "POST" && r.url === "/_register") {
815
805
  let l = "";
816
806
  r.on("data", (p) => l += p), r.on("end", () => {
817
807
  try {
818
- const { componentId: p, distPath: g, componentName: M } = JSON.parse(l);
819
- b.set(p, { path: g, name: M || null });
820
- const _ = M ? ` (${M})` : "";
821
- console.log(`βœ… Registered: ${p}${_} -> ${g}`), i.writeHead(200), i.end(JSON.stringify({ success: !0, registered: Array.from(b.keys()) }));
808
+ const { componentId: p, distPath: g, componentName: x } = JSON.parse(l);
809
+ j.set(p, { path: g, name: x || null });
810
+ const N = x ? ` (${x})` : "";
811
+ console.log(`βœ… Registered: ${p}${N} -> ${g}`), i.writeHead(200), i.end(JSON.stringify({ success: !0, registered: Array.from(j.keys()) }));
822
812
  } catch (p) {
823
813
  i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
824
814
  }
@@ -828,143 +818,147 @@ Sec-WebSocket-Accept: ${p}\r
828
818
  r.on("data", (p) => l += p), r.on("end", () => {
829
819
  try {
830
820
  const { componentId: p } = JSON.parse(l);
831
- b.delete(p), console.log(`❌ Unregistered: ${p}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
821
+ j.delete(p), console.log(`❌ Unregistered: ${p}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
832
822
  } catch (p) {
833
823
  i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
834
824
  }
835
825
  });
836
- } else r.method === "GET" && r.url === "/_list" ? (i.writeHead(200), i.end(JSON.stringify({ components: Array.from(b.entries()) }))) : (i.writeHead(404), i.end(JSON.stringify({ error: "Not found" })));
826
+ } else r.method === "GET" && r.url === "/_list" ? (i.writeHead(200), i.end(JSON.stringify({ components: Array.from(j.entries()) }))) : (i.writeHead(404), i.end(JSON.stringify({ error: "Not found" })));
837
827
  });
838
828
  t.on("error", () => {
839
- s(!1);
829
+ o(!1);
840
830
  }), t.listen(y, () => {
841
831
  console.log(`
842
- πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${y}`), ee.on("error", () => {
843
- t.close(), s(!1);
844
- }), ee.listen(u, () => {
845
- console.log(`πŸ“‘ Main server running at http://localhost:${u}`), b.set(x, {
846
- path: o.default.resolve(N, S),
847
- name: E
832
+ πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${y}`), te.on("error", () => {
833
+ t.close(), o(!1);
834
+ }), te.listen(m, () => {
835
+ console.log(`πŸ“‘ Main server running at http://localhost:${m}`), j.set(S, {
836
+ path: n.default.resolve(D, b),
837
+ name: h
848
838
  });
849
- const r = E ? ` (${E})` : "";
850
- console.log(`βœ… Registered component: ${x}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${u}/view/${x}/`), s(!0);
839
+ const r = h ? ` (${h})` : "";
840
+ console.log(`βœ… Registered component: ${S}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${S}/`), o(!0);
851
841
  });
852
842
  });
853
843
  });
854
- let oe;
855
- const $e = () => {
856
- oe = setInterval(async () => {
857
- await Be() || (clearInterval(oe), console.log(`
858
- ⚠️ Server appears to be down, attempting to take over...`), await ze() ? console.log("βœ… Successfully took over as server") : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
844
+ let ne;
845
+ const Ie = () => {
846
+ ne = setInterval(async () => {
847
+ await Ve() || (clearInterval(ne), console.log(`
848
+ ⚠️ Server appears to be down, attempting to take over...`), await Ge() ? console.log("βœ… Successfully took over as server") : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
859
849
  try {
860
- await ve(), console.log(`βœ… Re-registered component: ${x}`), $e();
850
+ await be(), console.log(`βœ… Re-registered component: ${S}`), Ie();
861
851
  } catch (r) {
862
852
  console.error("❌ Failed to re-register:", r.message);
863
853
  }
864
854
  }, 2e3)));
865
855
  }, 3e3);
866
- }, Me = async () => {
856
+ }, je = async () => {
867
857
  console.log(`
868
858
 
869
- πŸ›‘ Shutting down...`), oe && clearInterval(oe), await He(), process.exit(0);
859
+ πŸ›‘ Shutting down...`), ne && clearInterval(ne), await Ue(), process.exit(0);
870
860
  };
871
- process.on("SIGINT", Me), process.on("SIGTERM", Me), de.on("error", async (s) => {
872
- if (s.code === "EADDRINUSE") {
861
+ process.on("SIGINT", je), process.on("SIGTERM", je), pe.on("error", async (o) => {
862
+ if (o.code === "EADDRINUSE") {
873
863
  console.log(`
874
864
  πŸ”— Connecting to existing dev server...`);
875
865
  try {
876
- x = await $();
877
- const t = await ve();
878
- console.log(`βœ… Registered component: ${x}`), console.log(`πŸ“‘ Access at: http://localhost:${u}/view/${x}/`), console.log(`πŸ“‹ All registered components: ${t.registered.join(", ")}`), Ce(), $e();
866
+ S = await A();
867
+ const t = await be();
868
+ console.log(`βœ… Registered component: ${S}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${S}/`), console.log(`πŸ“‹ All registered components: ${t.registered.join(", ")}`), Oe(() => {
869
+ E(`http://localhost:${m}/view/${S}/`);
870
+ }), Ie();
879
871
  } catch (t) {
880
872
  console.error("❌ Failed to register component:", t.message), process.exit(1);
881
873
  }
882
874
  } else
883
- console.error("❌ Management server error:", s.message), process.exit(1);
884
- }), de.on("upgrade", De), de.listen(y, async () => {
875
+ console.error("❌ Management server error:", o.message), process.exit(1);
876
+ }), pe.on("upgrade", Je), pe.listen(y, async () => {
885
877
  console.log(`
886
- πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${y}`), ee.on("error", (s) => {
887
- console.error("❌ Main server error:", s.message), process.exit(1);
888
- }), ee.listen(u, async () => {
889
- console.log(`πŸ“‘ Main server running at http://localhost:${u}`), (x === "DEV" || x === "NEW") && (x = "DEV1"), b.set(x, {
890
- path: o.default.resolve(N, S),
891
- name: E
878
+ πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${y}`), te.on("error", (o) => {
879
+ console.error("❌ Main server error:", o.message), process.exit(1);
880
+ }), te.listen(m, async () => {
881
+ console.log(`πŸ“‘ Main server running at http://localhost:${m}`), (S === "DEV" || S === "NEW") && (S = "DEV1"), j.set(S, {
882
+ path: n.default.resolve(D, b),
883
+ name: h
884
+ });
885
+ const o = h ? ` (${h})` : "";
886
+ console.log(`βœ… Registered component: ${S}${o}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${S}/`), Oe(() => {
887
+ E(`http://localhost:${m}/view/${S}/`);
892
888
  });
893
- const s = E ? ` (${E})` : "";
894
- console.log(`βœ… Registered component: ${x}${s}`), console.log(`πŸ“‘ Access at: http://localhost:${u}/view/${x}/`), Ce();
895
889
  });
896
890
  });
897
891
  }
898
- const ue = Z.join(Xe.homedir(), ".myop"), Q = Z.join(ue, "credentials.json");
899
- function at() {
900
- A.existsSync(ue) || A.mkdirSync(ue, { recursive: !0, mode: 448 });
892
+ const ge = q.join(Ze.homedir(), ".myop"), Z = q.join(ge, "credentials.json");
893
+ function lt() {
894
+ R.existsSync(ge) || R.mkdirSync(ge, { recursive: !0, mode: 448 });
901
895
  }
902
- function he() {
896
+ function we() {
903
897
  try {
904
- if (!A.existsSync(Q))
898
+ if (!R.existsSync(Z))
905
899
  return null;
906
- const e = A.readFileSync(Q, "utf8");
900
+ const e = R.readFileSync(Z, "utf8");
907
901
  return JSON.parse(e);
908
902
  } catch (e) {
909
903
  return console.info("Failed to read credentials:", e.message), null;
910
904
  }
911
905
  }
912
- function Te(e) {
913
- at();
914
- const o = {
906
+ function Ae(e) {
907
+ lt();
908
+ const n = {
915
909
  ...e,
916
910
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
917
911
  };
918
- A.writeFileSync(Q, JSON.stringify(o, null, 2), {
912
+ R.writeFileSync(Z, JSON.stringify(n, null, 2), {
919
913
  mode: 384
920
914
  // Read/write for owner only
921
915
  });
922
916
  }
923
- function Re() {
917
+ function De() {
924
918
  try {
925
- return A.existsSync(Q) && A.unlinkSync(Q), !0;
919
+ return R.existsSync(Z) && R.unlinkSync(Z), !0;
926
920
  } catch (e) {
927
921
  return console.error("Failed to clear credentials:", e.message), !1;
928
922
  }
929
923
  }
930
- function ct(e) {
924
+ function dt(e) {
931
925
  if (!e || !e.expiresAt)
932
926
  return !0;
933
- const o = 5 * 60 * 1e3, n = new Date(e.expiresAt).getTime();
934
- return Date.now() > n - o;
927
+ const n = 5 * 60 * 1e3, s = new Date(e.expiresAt).getTime();
928
+ return Date.now() > s - n;
935
929
  }
936
- function ye() {
937
- const e = he();
930
+ function ve() {
931
+ const e = we();
938
932
  return e ? {
939
933
  email: e.userEmail,
940
934
  userId: e.userId
941
935
  } : null;
942
936
  }
943
- const Y = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", ie = 19284, we = `http://localhost:${ie}/callback`, lt = "myop-cli";
944
- function dt() {
945
- return fe.randomBytes(32).toString("base64url");
937
+ const X = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", ae = 19284, Se = `http://localhost:${ae}/callback`, pt = "myop-cli";
938
+ function mt() {
939
+ return he.randomBytes(32).toString("base64url");
946
940
  }
947
- function pt(e) {
948
- return fe.createHash("sha256").update(e).digest("base64url");
941
+ function ut(e) {
942
+ return he.createHash("sha256").update(e).digest("base64url");
949
943
  }
950
- async function mt() {
951
- const e = await fetch(`${Y}/oauth/register`, {
944
+ async function ft() {
945
+ const e = await fetch(`${X}/oauth/register`, {
952
946
  method: "POST",
953
947
  headers: { "Content-Type": "application/json" },
954
948
  body: JSON.stringify({
955
- client_name: lt,
956
- redirect_uris: [we],
949
+ client_name: pt,
950
+ redirect_uris: [Se],
957
951
  grant_types: ["authorization_code", "refresh_token"],
958
952
  response_types: ["code"]
959
953
  })
960
954
  });
961
955
  if (!e.ok) {
962
- const o = await e.text();
963
- throw new Error(`Failed to register client: ${o}`);
956
+ const n = await e.text();
957
+ throw new Error(`Failed to register client: ${n}`);
964
958
  }
965
959
  return e.json();
966
960
  }
967
- function se(e, o, n, a = null) {
961
+ function re(e, n, s, a = null) {
968
962
  const f = {
969
963
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
970
964
  <circle cx="12" cy="12" r="10"/>
@@ -982,13 +976,13 @@ function se(e, o, n, a = null) {
982
976
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
983
977
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
984
978
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
985
- }, { accent: m, glow: w } = c[e] || c.error;
979
+ }, { accent: u, glow: w } = c[e] || c.error;
986
980
  return `<!DOCTYPE html>
987
981
  <html lang="en">
988
982
  <head>
989
983
  <meta charset="UTF-8">
990
984
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
991
- <title>myop-cli | ${o}</title>
985
+ <title>myop-cli | ${n}</title>
992
986
  <style>
993
987
  * {
994
988
  margin: 0;
@@ -1043,7 +1037,7 @@ function se(e, o, n, a = null) {
1043
1037
  h1 {
1044
1038
  font-size: 20px;
1045
1039
  font-weight: 500;
1046
- color: ${m};
1040
+ color: ${u};
1047
1041
  margin-bottom: 12px;
1048
1042
  letter-spacing: -0.5px;
1049
1043
  }
@@ -1076,7 +1070,7 @@ function se(e, o, n, a = null) {
1076
1070
  align-items: center;
1077
1071
  gap: 8px;
1078
1072
  background: ${w};
1079
- border: 1px solid ${m}33;
1073
+ border: 1px solid ${u}33;
1080
1074
  border-radius: 4px;
1081
1075
  padding: 10px 16px;
1082
1076
  font-size: 12px;
@@ -1115,8 +1109,8 @@ function se(e, o, n, a = null) {
1115
1109
  <div class="icon">
1116
1110
  ${f[e] || f.error}
1117
1111
  </div>
1118
- <h1>${o}</h1>
1119
- <p class="message">${n}</p>
1112
+ <h1>${n}</h1>
1113
+ <p class="message">${s}</p>
1120
1114
  ${a ? `<div class="details"><code>Error:</code> ${a}</div>` : ""}
1121
1115
  <div class="hint">
1122
1116
  <span>Press</span>
@@ -1130,64 +1124,64 @@ function se(e, o, n, a = null) {
1130
1124
  </body>
1131
1125
  </html>`;
1132
1126
  }
1133
- function ut(e) {
1134
- return new Promise((o, n) => {
1135
- const a = Ye.createServer((f, c) => {
1136
- const m = new je(f.url, `http://localhost:${ie}`);
1137
- if (m.pathname === "/callback") {
1138
- const w = m.searchParams.get("code"), I = m.searchParams.get("state"), u = m.searchParams.get("error");
1139
- if (u) {
1140
- c.writeHead(200, { "Content-Type": "text/html" }), c.end(se(
1127
+ function gt(e) {
1128
+ return new Promise((n, s) => {
1129
+ const a = Xe.createServer((f, c) => {
1130
+ const u = new ke(f.url, `http://localhost:${ae}`);
1131
+ if (u.pathname === "/callback") {
1132
+ const w = u.searchParams.get("code"), O = u.searchParams.get("state"), m = u.searchParams.get("error");
1133
+ if (m) {
1134
+ c.writeHead(200, { "Content-Type": "text/html" }), c.end(re(
1141
1135
  "error",
1142
1136
  "Authentication Failed",
1143
1137
  "Unable to complete the authentication process.",
1144
- u
1145
- )), a.close(), n(new Error(`OAuth error: ${u}`));
1138
+ m
1139
+ )), a.close(), s(new Error(`OAuth error: ${m}`));
1146
1140
  return;
1147
1141
  }
1148
- if (I !== e) {
1149
- c.writeHead(400, { "Content-Type": "text/html" }), c.end(se(
1142
+ if (O !== e) {
1143
+ c.writeHead(400, { "Content-Type": "text/html" }), c.end(re(
1150
1144
  "warning",
1151
1145
  "Security Error",
1152
1146
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
1153
1147
  "state_mismatch"
1154
- )), a.close(), n(new Error("State mismatch"));
1148
+ )), a.close(), s(new Error("State mismatch"));
1155
1149
  return;
1156
1150
  }
1157
1151
  if (!w) {
1158
- c.writeHead(400, { "Content-Type": "text/html" }), c.end(se(
1152
+ c.writeHead(400, { "Content-Type": "text/html" }), c.end(re(
1159
1153
  "error",
1160
1154
  "Missing Authorization Code",
1161
1155
  "No authorization code was received from the server.",
1162
1156
  "missing_code"
1163
- )), a.close(), n(new Error("No authorization code"));
1157
+ )), a.close(), s(new Error("No authorization code"));
1164
1158
  return;
1165
1159
  }
1166
- c.writeHead(200, { "Content-Type": "text/html" }), c.end(se(
1160
+ c.writeHead(200, { "Content-Type": "text/html" }), c.end(re(
1167
1161
  "success",
1168
1162
  "Authentication Successful",
1169
1163
  "You have been authenticated successfully. Return to the terminal to continue."
1170
- )), a.close(), o(w);
1164
+ )), a.close(), n(w);
1171
1165
  } else
1172
1166
  c.writeHead(404), c.end("Not found");
1173
1167
  });
1174
- a.listen(ie, () => {
1175
- console.info(`OAuth callback server listening on port ${ie}`);
1168
+ a.listen(ae, () => {
1169
+ console.info(`OAuth callback server listening on port ${ae}`);
1176
1170
  }), setTimeout(() => {
1177
- a.close(), n(new Error("Authentication timed out"));
1171
+ a.close(), s(new Error("Authentication timed out"));
1178
1172
  }, 5 * 60 * 1e3);
1179
1173
  });
1180
1174
  }
1181
- async function ft(e, o, n) {
1182
- const a = await fetch(`${Y}/oauth/token`, {
1175
+ async function ht(e, n, s) {
1176
+ const a = await fetch(`${X}/oauth/token`, {
1183
1177
  method: "POST",
1184
1178
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1185
- body: new _e({
1179
+ body: new Ee({
1186
1180
  grant_type: "authorization_code",
1187
1181
  code: e,
1188
- client_id: o,
1189
- redirect_uri: we,
1190
- code_verifier: n
1182
+ client_id: n,
1183
+ redirect_uri: Se,
1184
+ code_verifier: s
1191
1185
  })
1192
1186
  });
1193
1187
  if (!a.ok) {
@@ -1196,25 +1190,25 @@ async function ft(e, o, n) {
1196
1190
  }
1197
1191
  return a.json();
1198
1192
  }
1199
- async function gt(e, o) {
1200
- const n = await fetch(`${Y}/oauth/token`, {
1193
+ async function yt(e, n) {
1194
+ const s = await fetch(`${X}/oauth/token`, {
1201
1195
  method: "POST",
1202
1196
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1203
- body: new _e({
1197
+ body: new Ee({
1204
1198
  grant_type: "refresh_token",
1205
1199
  refresh_token: e,
1206
- client_id: o
1200
+ client_id: n
1207
1201
  })
1208
1202
  });
1209
- if (!n.ok) {
1210
- const a = await n.json();
1203
+ if (!s.ok) {
1204
+ const a = await s.json();
1211
1205
  throw new Error(a.error_description || a.error || "Token refresh failed");
1212
1206
  }
1213
- return n.json();
1207
+ return s.json();
1214
1208
  }
1215
- async function ht(e) {
1216
- var f, c, m;
1217
- const o = await fetch(`${Y}/mcp`, {
1209
+ async function wt(e) {
1210
+ var f, c, u;
1211
+ const n = await fetch(`${X}/mcp`, {
1218
1212
  method: "POST",
1219
1213
  headers: {
1220
1214
  "Content-Type": "application/json",
@@ -1230,112 +1224,112 @@ async function ht(e) {
1230
1224
  }
1231
1225
  })
1232
1226
  });
1233
- if (!o.ok)
1227
+ if (!n.ok)
1234
1228
  throw new Error("Failed to get user info");
1235
- const n = await o.json();
1236
- if (n.error)
1237
- throw new Error(n.error.message);
1238
- const a = (m = (c = (f = n.result) == null ? void 0 : f.content) == null ? void 0 : c[0]) == null ? void 0 : m.text;
1229
+ const s = await n.json();
1230
+ if (s.error)
1231
+ throw new Error(s.error.message);
1232
+ const a = (u = (c = (f = s.result) == null ? void 0 : f.content) == null ? void 0 : c[0]) == null ? void 0 : u.text;
1239
1233
  if (a)
1240
1234
  return JSON.parse(a);
1241
1235
  throw new Error("Invalid response from whoami");
1242
1236
  }
1243
- async function X() {
1244
- const e = F("Starting authentication...").start();
1237
+ async function Q() {
1238
+ const e = P("Starting authentication...").start();
1245
1239
  try {
1246
1240
  e.text = "Registering OAuth client...";
1247
- const n = (await mt()).client_id, a = dt(), f = pt(a), c = fe.randomBytes(16).toString("hex");
1241
+ const s = (await ft()).client_id, a = mt(), f = ut(a), c = he.randomBytes(16).toString("hex");
1248
1242
  e.text = "Waiting for authorization...";
1249
- const m = ut(c), w = new je(`${Y}/oauth/authorize`);
1250
- w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", n), w.searchParams.set("redirect_uri", we), w.searchParams.set("code_challenge", f), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", c), e.stop(), console.log(`
1243
+ const u = gt(c), w = new ke(`${X}/oauth/authorize`);
1244
+ w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", s), w.searchParams.set("redirect_uri", Se), w.searchParams.set("code_challenge", f), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", c), e.stop(), console.log(`
1251
1245
  🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${w.toString()}
1252
- `), await Ke(w.toString());
1253
- const I = await m;
1246
+ `), await Qe(w.toString());
1247
+ const O = await u;
1254
1248
  e.start("Exchanging authorization code...");
1255
- const u = await ft(I, n, a);
1249
+ const m = await ht(O, s, a);
1256
1250
  e.text = "Getting user info...";
1257
- const y = await ht(u.access_token), S = {
1258
- accessToken: u.access_token,
1259
- refreshToken: u.refresh_token,
1260
- expiresAt: new Date(Date.now() + u.expires_in * 1e3).toISOString(),
1261
- clientId: n,
1251
+ const y = await wt(m.access_token), b = {
1252
+ accessToken: m.access_token,
1253
+ refreshToken: m.refresh_token,
1254
+ expiresAt: new Date(Date.now() + m.expires_in * 1e3).toISOString(),
1255
+ clientId: s,
1262
1256
  userId: y.userId,
1263
1257
  userEmail: y.email
1264
1258
  };
1265
- return Te(S), e.succeed(`Authenticated as ${y.email}`), S;
1266
- } catch (o) {
1267
- throw e.fail(`Authentication failed: ${o.message}`), o;
1259
+ return Ae(b), e.succeed(`Authenticated as ${y.email}`), b;
1260
+ } catch (n) {
1261
+ throw e.fail(`Authentication failed: ${n.message}`), n;
1268
1262
  }
1269
1263
  }
1270
- async function Fe() {
1271
- const e = he();
1264
+ async function He() {
1265
+ const e = we();
1272
1266
  if (!e) {
1273
1267
  console.log("Not currently logged in.");
1274
1268
  return;
1275
1269
  }
1276
- Re(), console.log(`βœ… Logged out (was: ${e.userEmail})`);
1270
+ De(), console.log(`βœ… Logged out (was: ${e.userEmail})`);
1277
1271
  }
1278
- async function yt() {
1279
- let e = he();
1272
+ async function vt() {
1273
+ let e = we();
1280
1274
  if (!e)
1281
1275
  return console.log(`Not logged in. Starting authentication...
1282
- `), await X();
1283
- if (!ct(e))
1276
+ `), await Q();
1277
+ if (!dt(e))
1284
1278
  return e;
1285
1279
  if (e.refreshToken) {
1286
- const o = F("Refreshing access token...").start();
1280
+ const n = P("Refreshing access token...").start();
1287
1281
  try {
1288
- const n = await gt(
1282
+ const s = await yt(
1289
1283
  e.refreshToken,
1290
1284
  e.clientId
1291
1285
  );
1292
1286
  return e = {
1293
1287
  ...e,
1294
- accessToken: n.access_token,
1295
- refreshToken: n.refresh_token,
1296
- expiresAt: new Date(Date.now() + n.expires_in * 1e3).toISOString()
1297
- }, Te(e), o.succeed("Token refreshed"), e;
1288
+ accessToken: s.access_token,
1289
+ refreshToken: s.refresh_token,
1290
+ expiresAt: new Date(Date.now() + s.expires_in * 1e3).toISOString()
1291
+ }, Ae(e), n.succeed("Token refreshed"), e;
1298
1292
  } catch {
1299
- return o.warn("Token refresh failed, please log in again"), Re(), await X();
1293
+ return n.warn("Token refresh failed, please log in again"), De(), await Q();
1300
1294
  }
1301
1295
  }
1302
1296
  return console.log(`Session expired. Please log in again.
1303
- `), await X();
1297
+ `), await Q();
1304
1298
  }
1305
- function wt() {
1306
- return Y;
1299
+ function St() {
1300
+ return X;
1307
1301
  }
1308
- const ae = "@myop/cli";
1309
- async function vt() {
1302
+ const ce = "@myop/cli";
1303
+ async function bt() {
1310
1304
  try {
1311
- const e = await fetch(`https://registry.npmjs.org/${ae}/latest`);
1305
+ const e = await fetch(`https://registry.npmjs.org/${ce}/latest`);
1312
1306
  return e.ok ? (await e.json()).version : null;
1313
1307
  } catch {
1314
1308
  return null;
1315
1309
  }
1316
1310
  }
1317
- function xt(e, o) {
1318
- const n = e.split(".").map(Number), a = o.split(".").map(Number);
1319
- for (let f = 0; f < Math.max(n.length, a.length); f++) {
1320
- const c = n[f] || 0, m = a[f] || 0;
1321
- if (c > m) return 1;
1322
- if (c < m) return -1;
1311
+ function xt(e, n) {
1312
+ const s = e.split(".").map(Number), a = n.split(".").map(Number);
1313
+ for (let f = 0; f < Math.max(s.length, a.length); f++) {
1314
+ const c = s[f] || 0, u = a[f] || 0;
1315
+ if (c > u) return 1;
1316
+ if (c < u) return -1;
1323
1317
  }
1324
1318
  return 0;
1325
1319
  }
1326
- async function St(e) {
1327
- const o = F({
1320
+ async function Ct(e) {
1321
+ const n = P({
1328
1322
  text: "Checking for updates...",
1329
1323
  color: "cyan"
1330
- }).start(), n = await vt();
1331
- if (o.stop(), !n || xt(n, e) <= 0)
1324
+ }).start(), s = await bt();
1325
+ if (n.stop(), !s || xt(s, e) <= 0)
1332
1326
  return !1;
1333
1327
  console.log(`
1334
- πŸ“¦ New version available: ${e} β†’ ${n}
1328
+ πŸ“¦ New version available: ${e} β†’ ${s}
1335
1329
  `);
1336
1330
  let a;
1337
1331
  try {
1338
- a = await Ie({
1332
+ a = await Ne({
1339
1333
  message: "Would you like to update now?",
1340
1334
  choices: [
1341
1335
  { name: "Yes, update now", value: !0 },
@@ -1349,39 +1343,39 @@ async function St(e) {
1349
1343
  `), process.exit(0)), f;
1350
1344
  }
1351
1345
  if (a) {
1352
- const f = F({
1353
- text: `Updating ${ae} to v${n}...`,
1346
+ const f = P({
1347
+ text: `Updating ${ce} to v${s}...`,
1354
1348
  color: "green"
1355
1349
  }).start();
1356
1350
  try {
1357
- return re(`npm install -g ${ae}@latest`, { stdio: "pipe" }), f.succeed(`Updated to v${n}`), console.log(`
1351
+ return ie(`npm install -g ${ce}@latest`, { stdio: "pipe" }), f.succeed(`Updated to v${s}`), console.log(`
1358
1352
  πŸ”„ Restarting with new version...
1359
- `), Ge("myop", process.argv.slice(2), {
1353
+ `), Ke("myop", process.argv.slice(2), {
1360
1354
  stdio: "inherit",
1361
1355
  shell: !0
1362
- }).on("close", (m) => {
1363
- process.exit(m || 0);
1356
+ }).on("close", (u) => {
1357
+ process.exit(u || 0);
1364
1358
  }), !0;
1365
1359
  } catch {
1366
1360
  return f.fail("Update failed"), console.log(`
1367
- You can manually update by running: npm install -g ${ae}@latest
1361
+ You can manually update by running: npm install -g ${ce}@latest
1368
1362
  `), !1;
1369
1363
  }
1370
1364
  }
1371
1365
  return !1;
1372
1366
  }
1373
- const bt = (e) => new Promise((o) => setTimeout(o, e));
1367
+ const $t = (e) => new Promise((n) => setTimeout(n, e));
1374
1368
  d.executionPath = process.cwd();
1375
- const le = (e = !1) => {
1376
- const o = d.program.getOptionValue("verbose");
1377
- o || (console.info = () => {
1369
+ const de = (e = !1) => {
1370
+ const n = d.program.getOptionValue("verbose");
1371
+ n || (console.info = () => {
1378
1372
  }), console.info("πŸ“ verbose mode on"), d.options = {
1379
1373
  configPath: d.program.getOptionValue("config"),
1380
- verbose: o
1374
+ verbose: n
1381
1375
  };
1382
1376
  try {
1383
- return d.myopConfig = Ze(d.options.configPath), { configFound: !0 };
1384
- } catch (n) {
1377
+ return d.myopConfig = et(d.options.configPath), { configFound: !0 };
1378
+ } catch (s) {
1385
1379
  if (e) {
1386
1380
  console.info(`
1387
1381
  ⚠️ failed read config file from ${d.options.configPath}, trying to create new one`);
@@ -1390,84 +1384,84 @@ const le = (e = !1) => {
1390
1384
  author: "@myop-cli",
1391
1385
  flows: []
1392
1386
  };
1393
- return ge(d.options.configPath, a), d.myopConfig = a, { configFound: !0 };
1387
+ return ye(d.options.configPath, a), d.myopConfig = a, { configFound: !0 };
1394
1388
  } catch {
1395
- return console.info("Error details :", n), { configFound: !1, error: n };
1389
+ return console.info("Error details :", s), { configFound: !1, error: s };
1396
1390
  }
1397
1391
  } else
1398
- return console.info("Error details :", n), { configFound: !1, error: n };
1392
+ return console.info("Error details :", s), { configFound: !1, error: s };
1399
1393
  }
1400
1394
  };
1401
1395
  [
1402
- new me(),
1403
- ...rt
1396
+ new fe(),
1397
+ ...at
1404
1398
  ];
1405
- const Ct = "0.1.18";
1406
- d.program = new We();
1407
- d.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(Ct);
1408
- d.program.addOption(new ce("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1409
- d.program.addOption(new ce("-h, --help", "Show helpful information"));
1410
- d.program.addOption(new ce("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1411
- d.program.addOption(new ce("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1412
- d.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((e, o) => {
1413
- le(!0), console.info("adding ", e, o, d.options.configPath), e === "flow" && Ee._action(o), process.exit();
1399
+ const Mt = "0.1.20";
1400
+ d.program = new Ye();
1401
+ d.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(Mt);
1402
+ d.program.addOption(new le("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1403
+ d.program.addOption(new le("-h, --help", "Show helpful information"));
1404
+ d.program.addOption(new le("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1405
+ d.program.addOption(new le("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1406
+ d.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((e, n) => {
1407
+ de(!0), console.info("adding ", e, n, d.options.configPath), e === "flow" && Pe._action(n), process.exit();
1414
1408
  });
1415
- d.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((e, o) => {
1416
- le(), console.info("removing ", e, o, d.options.configPath), e === "flow" && Ne._action(o), process.exit();
1409
+ d.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((e, n) => {
1410
+ de(), console.info("removing ", e, n, d.options.configPath), e === "flow" && Re._action(n), process.exit();
1417
1411
  });
1418
1412
  d.program.command("install").description("Install Myop assets").action(async () => {
1419
- le(), await Pe.action();
1413
+ de(), await Te.action();
1420
1414
  });
1421
1415
  d.program.command("login").description("Authenticate with Myop platform").action(async () => {
1422
1416
  try {
1423
- await X();
1417
+ await Q();
1424
1418
  } catch (e) {
1425
1419
  console.error("Login failed:", e.message), process.exit(1);
1426
1420
  }
1427
1421
  process.exit(0);
1428
1422
  });
1429
1423
  d.program.command("logout").description("Clear stored credentials").action(async () => {
1430
- await Fe(), process.exit(0);
1424
+ await He(), process.exit(0);
1431
1425
  });
1432
1426
  d.program.command("whoami").description("Show current authenticated user").action(async () => {
1433
- const e = ye();
1427
+ const e = ve();
1434
1428
  e && e.email ? console.log(`Logged in as: ${e.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1435
1429
  });
1436
1430
  d.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (e) => {
1437
- var j, v, k, z, x, E;
1438
- const o = d.program.getOptionValue("config") || "./myop.config.json", n = await import("fs"), { execSync: a } = await import("child_process"), f = await import("path");
1431
+ var I, v, E, F, W, S;
1432
+ const n = d.program.getOptionValue("config") || "./myop.config.json", s = await import("fs"), { execSync: a } = await import("child_process"), f = await import("path");
1439
1433
  let c = {};
1440
- if (n.existsSync(o))
1434
+ if (s.existsSync(n))
1441
1435
  try {
1442
- const h = n.readFileSync(o, "utf-8");
1436
+ const h = s.readFileSync(n, "utf-8");
1443
1437
  c = JSON.parse(h);
1444
- const $ = c.name || c.componentName;
1445
- console.log(`πŸ“‹ Found config: ${$ || "Unnamed component"}`), c.componentId && console.log(` Component ID: ${c.componentId}`);
1438
+ const C = c.name || c.componentName;
1439
+ console.log(`πŸ“‹ Found config: ${C || "Unnamed component"}`), c.componentId && console.log(` Component ID: ${c.componentId}`);
1446
1440
  } catch (h) {
1447
- console.error(`⚠️ Failed to parse ${o}:`, h.message);
1441
+ console.error(`⚠️ Failed to parse ${n}:`, h.message);
1448
1442
  }
1449
1443
  else
1450
1444
  console.log("⚠️ No myop.config.json found. A new component will be created.");
1451
1445
  if (!e.skipBuild) {
1452
- const h = F("Building project...").start();
1446
+ const h = P("Building project...").start();
1453
1447
  try {
1454
1448
  a("npm run build", { stdio: "pipe" }), h.succeed("Build completed");
1455
- } catch ($) {
1456
- h.fail("Build failed"), console.error($.message), process.exit(1);
1449
+ } catch (C) {
1450
+ h.fail("Build failed"), console.error(C.message), process.exit(1);
1457
1451
  }
1458
1452
  }
1459
- const m = "./dist/index.html";
1460
- 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));
1453
+ const u = "./dist/index.html";
1454
+ s.existsSync(u) || (console.error("❌ Error: ./dist/index.html not found"), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1461
1455
  let w;
1462
1456
  try {
1463
- w = await yt();
1457
+ w = await vt();
1464
1458
  } catch (h) {
1465
1459
  console.error("❌ Authentication failed:", h.message), process.exit(1);
1466
1460
  }
1467
- const I = wt();
1468
- let u = F("Requesting upload URL...").start(), y;
1461
+ const O = St();
1462
+ let m = P("Requesting upload URL...").start(), y;
1469
1463
  try {
1470
- const h = await fetch(`${I}/mcp`, {
1464
+ const h = await fetch(`${O}/mcp`, {
1471
1465
  method: "POST",
1472
1466
  headers: {
1473
1467
  "Content-Type": "application/json",
@@ -1489,50 +1483,50 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1489
1483
  });
1490
1484
  if (!h.ok)
1491
1485
  throw new Error(`Server returned ${h.status}`);
1492
- const $ = await h.json();
1493
- if ($.error)
1494
- throw new Error($.error.message);
1495
- const N = (k = (v = (j = $.result) == null ? void 0 : j.content) == null ? void 0 : v[0]) == null ? void 0 : k.text;
1496
- if (y = JSON.parse(N), !y.success)
1486
+ const C = await h.json();
1487
+ if (C.error)
1488
+ throw new Error(C.error.message);
1489
+ const A = (E = (v = (I = C.result) == null ? void 0 : I.content) == null ? void 0 : v[0]) == null ? void 0 : E.text;
1490
+ if (y = JSON.parse(A), !y.success)
1497
1491
  throw new Error(y.error);
1498
- u.succeed("Upload URL obtained");
1492
+ m.succeed("Upload URL obtained");
1499
1493
  } catch (h) {
1500
- u.fail("Failed to get upload URL"), console.error(" ", h.message), process.exit(1);
1494
+ m.fail("Failed to get upload URL"), console.error(" ", h.message), process.exit(1);
1501
1495
  }
1502
- u = F("Uploading component...").start();
1496
+ m = P("Uploading component...").start();
1503
1497
  try {
1504
- const h = n.readFileSync(m, "utf-8");
1505
- let $;
1506
- const N = y.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
1507
- if (N)
1508
- $ = N[1];
1498
+ const h = s.readFileSync(u, "utf-8");
1499
+ let C;
1500
+ const A = y.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
1501
+ if (A)
1502
+ C = A[1];
1509
1503
  else {
1510
- const b = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1511
- if (b)
1512
- $ = b[1];
1504
+ const V = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1505
+ if (V)
1506
+ C = V[1];
1513
1507
  else
1514
1508
  throw new Error("Could not parse presigned URL from: " + y.curlCommand);
1515
1509
  }
1516
- console.info("Uploading to:", $.substring(0, 100) + "...");
1517
- const K = await fetch($, {
1510
+ console.info("Uploading to:", C.substring(0, 100) + "...");
1511
+ const D = await fetch(C, {
1518
1512
  method: "PUT",
1519
1513
  headers: {
1520
1514
  "Content-Type": "text/html"
1521
1515
  },
1522
1516
  body: h
1523
1517
  });
1524
- if (!K.ok) {
1525
- const b = await K.text();
1526
- throw new Error(`Upload failed with status ${K.status}: ${b}`);
1518
+ if (!D.ok) {
1519
+ const V = await D.text();
1520
+ throw new Error(`Upload failed with status ${D.status}: ${V}`);
1527
1521
  }
1528
- u.succeed("Component uploaded");
1522
+ m.succeed("Component uploaded");
1529
1523
  } catch (h) {
1530
- u.fail("Upload failed"), console.error(" ", h.message), h.cause && console.error(" Cause:", h.cause), process.exit(1);
1524
+ m.fail("Upload failed"), console.error(" ", h.message), h.cause && console.error(" Cause:", h.cause), process.exit(1);
1531
1525
  }
1532
- u = F("Confirming upload...").start();
1533
- let S;
1526
+ m = P("Confirming upload...").start();
1527
+ let b;
1534
1528
  try {
1535
- const h = await fetch(`${I}/mcp`, {
1529
+ const h = await fetch(`${O}/mcp`, {
1536
1530
  method: "POST",
1537
1531
  headers: {
1538
1532
  "Content-Type": "application/json",
@@ -1552,43 +1546,43 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1552
1546
  });
1553
1547
  if (!h.ok)
1554
1548
  throw new Error(`Server returned ${h.status}`);
1555
- const $ = await h.json();
1556
- if ($.error)
1557
- throw new Error($.error.message);
1558
- const N = (E = (x = (z = $.result) == null ? void 0 : z.content) == null ? void 0 : x[0]) == null ? void 0 : E.text;
1559
- if (S = JSON.parse(N), !S.success)
1560
- throw new Error(S.error);
1561
- u.succeed("Upload confirmed");
1549
+ const C = await h.json();
1550
+ if (C.error)
1551
+ throw new Error(C.error.message);
1552
+ const A = (S = (W = (F = C.result) == null ? void 0 : F.content) == null ? void 0 : W[0]) == null ? void 0 : S.text;
1553
+ if (b = JSON.parse(A), !b.success)
1554
+ throw new Error(b.error);
1555
+ m.succeed("Upload confirmed");
1562
1556
  } catch (h) {
1563
- u.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
1557
+ m.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
1564
1558
  }
1565
- if (S.isNewComponent || !c.componentId) {
1566
- c.componentId = S.componentId, c.organization = S.orgId, c.name || (c.name = S.componentName);
1559
+ if (b.isNewComponent || !c.componentId) {
1560
+ c.componentId = b.componentId, c.organization = b.orgId, c.name || (c.name = b.componentName);
1567
1561
  try {
1568
- n.writeFileSync(o, JSON.stringify(c, null, 2)), console.log(`
1569
- πŸ“ Updated ${o} with componentId`);
1562
+ s.writeFileSync(n, JSON.stringify(c, null, 2)), console.log(`
1563
+ πŸ“ Updated ${n} with componentId`);
1570
1564
  } catch (h) {
1571
1565
  console.log(`
1572
- ⚠️ Could not update ${o}: ${h.message}`), console.log(` Please add componentId: "${S.componentId}" manually`);
1566
+ ⚠️ Could not update ${n}: ${h.message}`), console.log(` Please add componentId: "${b.componentId}" manually`);
1573
1567
  }
1574
1568
  }
1575
1569
  console.log(`
1576
- βœ… Sync completed successfully!`), console.log(` Component: ${S.componentName}`), console.log(` Dashboard: ${S.dashboardUrl}`), process.exit(0);
1570
+ βœ… Sync completed successfully!`), console.log(` Component: ${b.componentName}`), console.log(` Dashboard: ${b.dashboardUrl}`), process.exit(0);
1577
1571
  });
1578
- d.program.command("dev").description("Start development server with file watching").action(ke);
1579
- const $t = () => {
1572
+ d.program.command("dev").description("Start development server with file watching").action(Fe);
1573
+ const Ot = () => {
1580
1574
  try {
1581
- re("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1575
+ ie("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1582
1576
  } catch {
1583
1577
  return { gitNotInstalled: !0 };
1584
1578
  }
1585
1579
  try {
1586
- re("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1580
+ ie("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1587
1581
  } catch {
1588
1582
  return { notARepo: !0 };
1589
1583
  }
1590
1584
  try {
1591
- const e = re("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
1585
+ const e = ie("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
1592
1586
  encoding: "utf-8",
1593
1587
  stdio: ["pipe", "pipe", "pipe"]
1594
1588
  }).trim();
@@ -1598,8 +1592,8 @@ const $t = () => {
1598
1592
  insertions: 0,
1599
1593
  deletions: 0
1600
1594
  };
1601
- const o = e.split(`
1602
- `), n = o[o.length - 1], a = n.match(/(\d+) insertion/), f = n.match(/(\d+) deletion/), c = n.match(/(\d+) file/);
1595
+ const n = e.split(`
1596
+ `), s = n[n.length - 1], a = s.match(/(\d+) insertion/), f = s.match(/(\d+) deletion/), c = s.match(/(\d+) file/);
1603
1597
  return {
1604
1598
  files: c ? parseInt(c[1]) : 0,
1605
1599
  insertions: a ? parseInt(a[1]) : 0,
@@ -1608,13 +1602,13 @@ const $t = () => {
1608
1602
  } catch {
1609
1603
  return null;
1610
1604
  }
1611
- }, B = async (e = !1, o = !1) => {
1612
- var y, S, j;
1613
- const n = ye(), a = !!(n != null && n.email), f = ((y = d.myopConfig) == null ? void 0 : y.name) || ((S = d.myopConfig) == null ? void 0 : S.componentName), c = (j = d.myopConfig) == null ? void 0 : j.componentId, m = $t();
1605
+ }, z = async (e = !1, n = !1) => {
1606
+ var y, b, I;
1607
+ const s = ve(), a = !!(s != null && s.email), f = ((y = d.myopConfig) == null ? void 0 : y.name) || ((b = d.myopConfig) == null ? void 0 : b.componentName), c = (I = d.myopConfig) == null ? void 0 : I.componentId, u = Ot();
1614
1608
  console.log(`
1615
1609
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Welcome to Myop CLI - Remote UI Made Easy β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1616
- `), 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: ${a ? 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("");
1617
- const I = [
1610
+ `), 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: ${a ? s.email : "Not logged in"}`), u != null && u.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")) : u != null && u.notARepo ? console.log(" Changes: Not a git repository") : u && (u.insertions > 0 || u.deletions > 0) ? console.log(` Changes: ${u.files} file${u.files !== 1 ? "s" : ""} | \x1B[32m+${u.insertions}\x1B[0m \x1B[31m-${u.deletions}\x1B[0m`) : u && console.log(" Changes: No uncommitted changes"), console.log("");
1611
+ const O = [
1618
1612
  {
1619
1613
  emoji: "πŸš€",
1620
1614
  label: "Initialize new component",
@@ -1622,49 +1616,49 @@ const $t = () => {
1622
1616
  help: "Creates myop.config.json in current directory",
1623
1617
  disabled: e ? "(config already exists)" : !1
1624
1618
  },
1625
- {
1626
- emoji: "πŸ“¦",
1627
- label: f ? `Push "${f}"` : "Push component",
1628
- value: "sync",
1629
- help: "Builds project & uploads dist/index.html to Myop",
1630
- disabled: e ? a ? !1 : "(login required)" : "(no config file)"
1631
- },
1632
1619
  {
1633
1620
  emoji: "πŸ› οΈ ",
1634
1621
  label: f ? `Start dev mode for "${f}"` : "Start dev mode",
1635
1622
  value: "dev",
1636
1623
  help: "Starts dev server with HMR for instant preview of changes",
1637
1624
  disabled: e ? !1 : "(no config file)"
1625
+ },
1626
+ {
1627
+ emoji: "πŸ“¦",
1628
+ label: f ? `Push "${f}"` : "Push component",
1629
+ value: "sync",
1630
+ help: "Builds project & uploads dist/index.html to Myop",
1631
+ disabled: e ? a ? !1 : "(login required)" : "(no config file)"
1638
1632
  }
1639
1633
  ].map((v) => ({
1640
- name: o && !v.disabled ? `${v.emoji} ${v.label}
1634
+ name: n && !v.disabled ? `${v.emoji} ${v.label}
1641
1635
  ${v.help}` : `${v.emoji} ${v.label}`,
1642
1636
  value: v.value,
1643
1637
  disabled: v.disabled
1644
1638
  }));
1645
- I.push(
1646
- new me(),
1639
+ O.push(
1640
+ new fe(),
1647
1641
  {
1648
- name: o && a ? `πŸ”“ Logout (${n.email})
1649
- Clears stored credentials from this machine` : o && !a ? `πŸ” Login to Myop
1650
- Opens browser to authenticate with Myop` : a ? `πŸ”“ Logout (${n.email})` : "πŸ” Login to Myop",
1642
+ name: n && a ? `πŸ”“ Logout (${s.email})
1643
+ Clears stored credentials from this machine` : n && !a ? `πŸ” Login to Myop
1644
+ Opens browser to authenticate with Myop` : a ? `πŸ”“ Logout (${s.email})` : "πŸ” Login to Myop",
1651
1645
  value: a ? "logout" : "login"
1652
1646
  },
1653
1647
  {
1654
- name: o ? "πŸ“– Hide help" : "πŸ“– Show help",
1648
+ name: n ? "πŸ“– Hide help" : "πŸ“– Show help",
1655
1649
  value: "help"
1656
1650
  },
1657
- new me(),
1651
+ new fe(),
1658
1652
  {
1659
1653
  name: "πŸ‘‹ Exit",
1660
1654
  value: "exit"
1661
1655
  }
1662
1656
  );
1663
- let u;
1657
+ let m;
1664
1658
  try {
1665
- u = await Ie({
1659
+ m = await Ne({
1666
1660
  message: "What would you like to do?",
1667
- choices: I
1661
+ choices: O
1668
1662
  });
1669
1663
  } catch (v) {
1670
1664
  throw v.name === "ExitPromptError" && (console.log(`
@@ -1672,9 +1666,9 @@ const $t = () => {
1672
1666
  πŸ‘‹ Goodbye!
1673
1667
  `), process.exit(0)), v;
1674
1668
  }
1675
- switch (u) {
1669
+ switch (m) {
1676
1670
  case "init":
1677
- await Mt();
1671
+ await It();
1678
1672
  break;
1679
1673
  case "sync":
1680
1674
  console.log(`
@@ -1685,37 +1679,37 @@ Running sync...
1685
1679
  v("node " + process.argv[1] + " sync", { stdio: "inherit" });
1686
1680
  } catch {
1687
1681
  }
1688
- await B(!0, o);
1682
+ await z(!0, n);
1689
1683
  break;
1690
1684
  case "dev":
1691
- await ke();
1685
+ await Fe();
1692
1686
  break;
1693
1687
  case "login":
1694
1688
  try {
1695
- await X(), console.log(`
1696
- `), await B(e, o);
1697
- } catch (k) {
1698
- console.error("Login failed:", k.message), await B(e, o);
1689
+ await Q(), console.log(`
1690
+ `), await z(e, n);
1691
+ } catch (E) {
1692
+ console.error("Login failed:", E.message), await z(e, n);
1699
1693
  }
1700
1694
  break;
1701
1695
  case "logout":
1702
- await Fe(), console.log(`
1703
- `), await B(e, o);
1696
+ await He(), console.log(`
1697
+ `), await z(e, n);
1704
1698
  break;
1705
1699
  case "help":
1706
- await B(e, !o);
1700
+ await z(e, !n);
1707
1701
  break;
1708
1702
  case "exit":
1709
1703
  process.exit(0);
1710
1704
  }
1711
- }, Mt = async () => {
1712
- const { input: e, select: o } = await import("@inquirer/prompts"), n = await import("fs"), f = (await import("path")).default.basename(process.cwd());
1713
- let c, m;
1705
+ }, It = async () => {
1706
+ const { input: e, select: n } = await import("@inquirer/prompts"), s = await import("fs"), f = (await import("path")).default.basename(process.cwd());
1707
+ let c, u;
1714
1708
  try {
1715
1709
  c = await e({
1716
1710
  message: "Component name:",
1717
1711
  default: f
1718
- }), m = await o({
1712
+ }), u = await n({
1719
1713
  message: "Component type:",
1720
1714
  choices: [
1721
1715
  { name: "πŸ“„ HTML", value: "html", description: "Plain HTML/JS/CSS component" },
@@ -1724,21 +1718,22 @@ Running sync...
1724
1718
  { name: "πŸ…°οΈ Angular", value: "angular", disabled: "(coming soon)" }
1725
1719
  ]
1726
1720
  });
1727
- } catch (u) {
1728
- throw u.name === "ExitPromptError" && (console.log(`
1721
+ } catch (m) {
1722
+ throw m.name === "ExitPromptError" && (console.log(`
1729
1723
 
1730
1724
  πŸ‘‹ Goodbye!
1731
- `), process.exit(0)), u;
1725
+ `), process.exit(0)), m;
1732
1726
  }
1733
1727
  const w = {
1734
1728
  name: c,
1735
- type: m,
1736
- author: "@myop-cli"
1737
- }, I = d.program.getOptionValue("config") || "./myop.config.json";
1729
+ type: u,
1730
+ author: "@myop-cli",
1731
+ HMR: !0
1732
+ }, O = d.program.getOptionValue("config") || "./myop.config.json";
1738
1733
  try {
1739
- n.writeFileSync(I, JSON.stringify(w, null, 2)), console.log(`
1740
- βœ… Created ${I}`);
1741
- const u = {
1734
+ s.writeFileSync(O, JSON.stringify(w, null, 2)), console.log(`
1735
+ βœ… Created ${O}`);
1736
+ const m = {
1742
1737
  name: c.toLowerCase().replace(/\s+/g, "-"),
1743
1738
  version: "1.0.0",
1744
1739
  type: "module",
@@ -1750,7 +1745,7 @@ Running sync...
1750
1745
  esbuild: "^0.24.0"
1751
1746
  }
1752
1747
  };
1753
- n.writeFileSync("package.json", JSON.stringify(u, 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';
1748
+ s.writeFileSync("package.json", JSON.stringify(m, 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';
1754
1749
  import fs from 'fs';
1755
1750
  import path from 'path';
1756
1751
 
@@ -1830,7 +1825,7 @@ fs.writeFileSync('dist/index.html', html);
1830
1825
  console.log('βœ… Built dist/index.html');
1831
1826
  console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
1832
1827
  `), console.log("βœ… Created build.js");
1833
- const S = `<!DOCTYPE html>
1828
+ const b = `<!DOCTYPE html>
1834
1829
  <html lang="en">
1835
1830
  <head>
1836
1831
  <meta charset="UTF-8">
@@ -1847,8 +1842,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
1847
1842
  </body>
1848
1843
  </html>
1849
1844
  `;
1850
- n.writeFileSync("index.html", S), console.log("βœ… Created index.html");
1851
- const j = `// ${c} - Entry Point
1845
+ s.writeFileSync("index.html", b), console.log("βœ… Created index.html");
1846
+ const I = `// ${c} - Entry Point
1852
1847
  import { init } from './modules/app.js';
1853
1848
  import { setupMyopInterface } from './modules/myop.js';
1854
1849
 
@@ -1857,7 +1852,7 @@ document.addEventListener('DOMContentLoaded', () => {
1857
1852
  setupMyopInterface();
1858
1853
  });
1859
1854
  `;
1860
- n.writeFileSync("src/index.js", j), console.log("βœ… Created src/index.js");
1855
+ s.writeFileSync("src/index.js", I), console.log("βœ… Created src/index.js");
1861
1856
  const v = `// ${c} - Main Application Logic
1862
1857
 
1863
1858
  export function init() {
@@ -1866,7 +1861,7 @@ export function init() {
1866
1861
  // Your component logic here
1867
1862
  }
1868
1863
  `;
1869
- n.writeFileSync("src/modules/app.js", v), console.log("βœ… Created src/modules/app.js"), n.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
1864
+ 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
1870
1865
 
1871
1866
  export function setupMyopInterface() {
1872
1867
  // Called when host app sends data to this component
@@ -1882,12 +1877,12 @@ export function setupMyopInterface() {
1882
1877
  };
1883
1878
  }
1884
1879
  `), console.log("βœ… Created src/modules/myop.js");
1885
- const z = `/* ${c} - Styles Entry Point */
1880
+ const F = `/* ${c} - Styles Entry Point */
1886
1881
  /* Add your CSS imports here - they will be auto-bundled */
1887
1882
  @import './main.css';
1888
1883
  `;
1889
- n.writeFileSync("src/styles/index.css", z), console.log("βœ… Created src/styles/index.css");
1890
- const x = `/* ${c} - Main Styles */
1884
+ s.writeFileSync("src/styles/index.css", F), console.log("βœ… Created src/styles/index.css");
1885
+ const W = `/* ${c} - Main Styles */
1891
1886
 
1892
1887
  * {
1893
1888
  box-sizing: border-box;
@@ -1916,20 +1911,20 @@ p {
1916
1911
  line-height: 1.5;
1917
1912
  }
1918
1913
  `;
1919
- n.writeFileSync("src/styles/main.css", x), console.log("βœ… Created src/styles/main.css"), console.log(`
1914
+ s.writeFileSync("src/styles/main.css", W), console.log("βœ… Created src/styles/main.css"), console.log(`
1920
1915
  πŸ“¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
1921
- `), d.myopConfig = w, await B(!0);
1922
- } catch (u) {
1923
- console.error(`Failed to initialize component: ${u.message}`), process.exit(1);
1916
+ `), d.myopConfig = w, await z(!0);
1917
+ } catch (m) {
1918
+ console.error(`Failed to initialize component: ${m.message}`), process.exit(1);
1924
1919
  }
1925
1920
  };
1926
1921
  d.program.command("default", { isDefault: !0 }).action(async () => {
1927
- if (d.program.getOptionValue("help") && (console.log(Qe), process.exit()), d.program.getOptionValue("ci")) {
1928
- const m = await import("fs"), w = d.program.getOptionValue("config") || "./myop.config.json", I = d.program.version(), u = ye();
1922
+ if (d.program.getOptionValue("help") && (console.log(qe), process.exit()), d.program.getOptionValue("ci")) {
1923
+ const u = await import("fs"), w = d.program.getOptionValue("config") || "./myop.config.json", O = d.program.version(), m = ve();
1929
1924
  let y = { found: !1 };
1930
1925
  try {
1931
- if (m.existsSync(w)) {
1932
- const j = m.readFileSync(w, "utf-8"), v = JSON.parse(j);
1926
+ if (u.existsSync(w)) {
1927
+ const I = u.readFileSync(w, "utf-8"), v = JSON.parse(I);
1933
1928
  y = {
1934
1929
  found: !0,
1935
1930
  path: w,
@@ -1938,27 +1933,27 @@ d.program.command("default", { isDefault: !0 }).action(async () => {
1938
1933
  organization: v.organization || null
1939
1934
  };
1940
1935
  }
1941
- } catch (j) {
1942
- y = { found: !1, error: j.message };
1936
+ } catch (I) {
1937
+ y = { found: !1, error: I.message };
1943
1938
  }
1944
- const S = {
1945
- version: I,
1939
+ const b = {
1940
+ version: O,
1946
1941
  config: y,
1947
1942
  auth: {
1948
- loggedIn: !!(u != null && u.email),
1949
- email: (u == null ? void 0 : u.email) || null
1943
+ loggedIn: !!(m != null && m.email),
1944
+ email: (m == null ? void 0 : m.email) || null
1950
1945
  }
1951
1946
  };
1952
- console.log(JSON.stringify(S, null, 2)), process.exit(0);
1947
+ console.log(JSON.stringify(b, null, 2)), process.exit(0);
1953
1948
  }
1954
- let n = F({
1949
+ let s = P({
1955
1950
  text: "Loading Myop CLI...",
1956
1951
  color: "green"
1957
1952
  }).start();
1958
- const a = le();
1959
- await bt(500), n.stop();
1953
+ const a = de();
1954
+ await $t(500), s.stop();
1960
1955
  const f = d.program.version();
1961
- await St(f) || await B(a.configFound);
1956
+ await Ct(f) || await z(a.configFound);
1962
1957
  });
1963
1958
  d.program.parse(process.argv);
1964
1959
  d.program.opts();