@myop/cli 0.1.19 β†’ 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 +591 -581
  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 _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 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
- }, Ee = {
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
- }, 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);
71
- return console.info("config file loaded, ", r), r;
72
- }, he = (e, o) => {
73
- const s = Z.join(d.executionPath, e);
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
+ return console.info("config file loaded, ", a), a;
72
+ }, ye = (e, n) => {
73
+ const s = q.join(d.executionPath, e);
74
74
  console.info(`writing config file to: ${s}`);
75
75
  try {
76
- const r = JSON.stringify(o, null, 2);
77
- A.writeFileSync(s, r), console.info(`config file updated ${r}`);
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;
76
+ const a = JSON.stringify(n, null, 2);
77
+ R.writeFileSync(s, a), console.info(`config file updated ${a}`);
78
+ } catch (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
- }, Te = {
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), he(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
- }, Pe = {
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), he(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
- }, et = {
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
- }, tt = {
107
+ }, ot = {
108
108
  name: "🟒 Create new component",
109
109
  value: "-",
110
110
  disabled: "(not available yet)"
111
- }, ot = {
111
+ }, nt = {
112
112
  name: "πŸ”΅ Create new experience",
113
113
  value: "-",
114
114
  disabled: "(not available yet)"
115
- }, nt = {
115
+ }, st = {
116
116
  name: "🟑 Create new skin",
117
117
  value: "-",
118
118
  disabled: "(not available yet)"
119
- }, st = {
119
+ }, rt = {
120
120
  name: "πŸ”΄ Create new flow",
121
121
  value: "-",
122
122
  disabled: "(not available yet)"
123
- }, rt = {
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
- }, it = [rt, tt, ot, nt, st];
129
- function at(e, o, s, r) {
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>
@@ -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: ${n}</span>
147
147
  </div>
148
148
  </div>
149
149
 
@@ -211,30 +211,35 @@ ${s}
211
211
  // Inject PORT as a global variable for the app to use
212
212
  window.PORT = ${e};
213
213
 
214
- ${r}
214
+ ${a}
215
215
  <\/script>
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");
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
- const t = new URL(import.meta.url).pathname, i = process.platform === "win32" && t.startsWith("/") ? t.slice(1) : t;
224
- c = o.default.dirname(i);
223
+ const t = new URL(import.meta.url).pathname, r = process.platform === "win32" && t.startsWith("/") ? t.slice(1) : t;
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, 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;
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 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);
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 M = async () => {
242
+ const A = async () => {
238
243
  if (S !== "DEV" && S !== "NEW")
239
244
  return S;
240
245
  try {
@@ -245,33 +250,33 @@ async function Re() {
245
250
  path: "/_list",
246
251
  method: "GET",
247
252
  timeout: 1e3
248
- }, $ = r.default.request(g, (N) => {
249
- let H = "";
250
- N.on("data", (L) => H += L), N.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
- $.on("error", () => l({ components: [] })), $.on("timeout", () => {
259
- $.destroy(), l({ components: [] });
260
- }), $.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";
264
- const i = t.map((l) => {
269
+ const r = t.map((l) => {
265
270
  if (l === "DEV" || l === "NEW") return 1;
266
271
  const p = l.match(/^DEV(\d+)$/), g = l.match(/^NEW(\d+)$/);
267
272
  return p ? parseInt(p[1], 10) : g ? parseInt(g[1], 10) : 0;
268
273
  }).filter((l) => l > 0);
269
- return `DEV${Math.max(...i, 0) + 1}`;
274
+ return `DEV${Math.max(...r, 0) + 1}`;
270
275
  } catch {
271
276
  return "DEV1";
272
277
  }
273
- }, E = process.cwd(), K = (n) => {
274
- const t = o.default.extname(n).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 Re() {
283
288
  ".svg": "image/svg+xml",
284
289
  ".ico": "image/x-icon"
285
290
  }[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");
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,55 +298,55 @@ Connection: Upgrade\r
293
298
  Sec-WebSocket-Accept: ${p}\r
294
299
  \r
295
300
  `
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}`);
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(a);
305
+ const g = B.get(i);
301
306
  g && g.delete(t);
302
307
  });
303
308
  }
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", () => {
309
+ }, pe = a.default.createServer((o, t) => {
310
+ if (t.setHeader("Content-Type", "application/json"), o.method === "POST" && o.url === "/_register") {
311
+ let r = "";
312
+ o.on("data", (i) => r += i), o.on("end", () => {
308
313
  try {
309
- const { componentId: a, distPath: l, componentName: p } = JSON.parse(i);
310
- x.set(a, { path: l, name: p || null });
314
+ const { componentId: i, distPath: l, componentName: p } = JSON.parse(r);
315
+ j.set(i, { path: l, name: p || null });
311
316
  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]) => ({
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]) => ({
314
319
  id: N,
315
- path: H.path,
316
- name: H.name
320
+ path: L.path,
321
+ name: L.name
317
322
  }));
318
- D.forEach((N) => {
323
+ H.forEach((N) => {
319
324
  try {
320
325
  N.write(`data: ${JSON.stringify({
321
326
  type: "components",
322
- components: $
327
+ components: x
323
328
  })}
324
329
 
325
330
  `);
326
331
  } catch {
327
332
  }
328
333
  });
329
- } catch (a) {
330
- t.writeHead(400), t.end(JSON.stringify({ error: a.message }));
334
+ } catch (i) {
335
+ t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
331
336
  }
332
337
  });
333
- } else if (n.method === "POST" && n.url === "/_unregister") {
334
- let i = "";
335
- n.on("data", (a) => i += a), n.on("end", () => {
338
+ } else if (o.method === "POST" && o.url === "/_unregister") {
339
+ let r = "";
340
+ o.on("data", (i) => r += i), o.on("end", () => {
336
341
  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]) => ({
342
+ const { componentId: i } = JSON.parse(r);
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",
@@ -352,143 +357,143 @@ Sec-WebSocket-Accept: ${p}\r
352
357
  } catch {
353
358
  }
354
359
  });
355
- } catch (a) {
356
- t.writeHead(400), t.end(JSON.stringify({ error: a.message }));
360
+ } catch (i) {
361
+ t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
357
362
  }
358
363
  });
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("..")) {
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 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");
370
+ const r = new URL(o.url, `http://localhost:${m}`), i = r.pathname, l = i.split("/").filter((_) => _);
371
+ if (i.startsWith("/consume")) {
372
+ const _ = r.searchParams.get("id");
368
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 = 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;
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, P = G.hostname || G.origin;
382
+ const K = new URL(M);
383
+ $ = K.origin, k = K.hostname || K.origin;
379
384
  } catch {
380
- C = O, P = O;
385
+ $ = M, k = M;
381
386
  }
382
- } else if (n.headers.origin)
387
+ } else if (o.headers.origin)
383
388
  try {
384
- const O = new URL(n.headers.origin);
385
- C = O.origin, P = 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 = n.headers.origin, P = n.headers.origin;
392
+ $ = o.headers.origin, k = o.headers.origin;
388
393
  }
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:", ""));
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 = n.headers.referer || n.headers.referrer || C, ne = {
398
+ const me = o.headers.referer || o.headers.referrer || $, se = {
394
399
  type: "request",
395
400
  componentId: _,
396
401
  timestamp: Date.now(),
397
- servedLocally: V,
398
- referrer: pe,
399
- origin: C,
400
- originLabel: P
402
+ servedLocally: Y,
403
+ referrer: me,
404
+ origin: $,
405
+ originLabel: k
401
406
  };
402
- W.has(C) || (W.set(C, {
403
- url: C,
404
- label: P,
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(W.values())
416
+ origins: Array.from(G.values())
412
417
  })}
413
418
 
414
419
  `);
415
420
  } catch {
416
421
  }
417
422
  }));
418
- const me = W.get(C);
419
- me.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(W.values())
428
+ origins: Array.from(G.values())
424
429
  })}
425
430
 
426
431
  `);
427
432
  } catch {
428
433
  }
429
- }), q.push(ne), q.length > He && 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 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" }));
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 = be(P, _), ne = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, me = {
450
+ const me = xe(k, _), se = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ue = {
446
451
  item: {
447
452
  name: _,
448
453
  id: _,
449
454
  consume_variant: [
450
455
  {
451
- id: ne,
456
+ id: se,
452
457
  name: "dev version",
453
458
  loader: {
454
459
  type: "HTMLLoader",
455
460
  shadowRootMode: "localFrame",
456
- HTML: pe
461
+ HTML: me
457
462
  }
458
463
  }
459
464
  ]
460
465
  }
461
466
  };
462
- console.log(`βœ… Serving consume JSON for: ${_}`), je(!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(me, null, 2));
470
+ }), t.end(JSON.stringify(ue, null, 2));
466
471
  });
467
472
  } else {
468
473
  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) => {
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;
480
485
  }
481
- if (a === "/events") {
486
+ if (i === "/events") {
482
487
  t.writeHead(200, {
483
488
  "Content-Type": "text/event-stream",
484
489
  "Cache-Control": "no-cache",
485
490
  Connection: "keep-alive",
486
491
  "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
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",
@@ -497,22 +502,22 @@ Sec-WebSocket-Accept: ${p}\r
497
502
 
498
503
  `), t.write(`data: ${JSON.stringify({
499
504
  type: "origins",
500
- origins: Array.from(W.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
- `), n.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(at(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,63 +528,63 @@ 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 = x.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 $ = 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) => {
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) => {
533
538
  if (_) {
534
- console.log(`❌ File not found: ${L}`), t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Not Found");
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
- }), Se = () => new Promise((n, t) => {
544
- const i = JSON.stringify({
548
+ }), be = () => new Promise((o, t) => {
549
+ const r = JSON.stringify({
545
550
  componentId: S,
546
- distPath: o.default.resolve(E, b),
547
- componentName: k
548
- }), a = {
551
+ distPath: n.default.resolve(D, b),
552
+ componentName: h
553
+ }), i = {
549
554
  hostname: "localhost",
550
555
  port: y,
551
556
  path: "/_register",
552
557
  method: "POST",
553
558
  headers: {
554
559
  "Content-Type": "application/json",
555
- "Content-Length": Buffer.byteLength(i)
560
+ "Content-Length": Buffer.byteLength(r)
556
561
  }
557
- }, l = r.default.request(a, (p) => {
562
+ }, l = a.default.request(i, (p) => {
558
563
  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}`));
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
- l.on("error", t), l.write(i), l.end();
564
- }), Je = () => new Promise((n, t) => {
565
- const i = JSON.stringify({ componentId: S }), a = {
568
+ l.on("error", t), l.write(r), l.end();
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",
569
574
  method: "POST",
570
575
  headers: {
571
576
  "Content-Type": "application/json",
572
- "Content-Length": Buffer.byteLength(i)
577
+ "Content-Length": Buffer.byteLength(r)
573
578
  }
574
- }, l = r.default.request(a, (p) => {
575
- n();
579
+ }, l = a.default.request(i, (p) => {
580
+ o();
576
581
  });
577
- l.on("error", () => n()), l.write(i), l.end();
578
- }), Ue = (n) => `
582
+ l.on("error", () => o()), l.write(r), l.end();
583
+ }), Be = (o) => `
579
584
  <!-- MYOP HMR -->
580
585
  <script>
581
586
  (function() {
582
- const componentId = '${n}';
587
+ const componentId = '${o}';
583
588
  const wsUrl = 'ws://localhost:${y}/_hmr/' + componentId;
584
589
  let ws;
585
590
  let reconnectAttempts = 0;
@@ -680,276 +685,280 @@ Sec-WebSocket-Accept: ${p}\r
680
685
  connect();
681
686
  })();
682
687
  <\/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]),
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;
694
+ let i;
695
+ return r < 126 ? i = Buffer.concat([
696
+ Buffer.from([129, r]),
692
697
  // FIN + text frame, length
693
698
  t
694
- ]) : i < 65536 ? a = Buffer.concat([
699
+ ]) : r < 65536 ? i = Buffer.concat([
695
700
  Buffer.from([129, 126]),
696
701
  // FIN + text frame, extended length
697
- Buffer.from([i >> 8, i & 255]),
702
+ Buffer.from([r >> 8, r & 255]),
698
703
  // 16-bit length
699
704
  t
700
- ]) : a = Buffer.concat([
705
+ ]) : i = Buffer.concat([
701
706
  Buffer.from([129, 127]),
702
707
  // FIN + text frame, extended length
703
- Buffer.from([0, 0, 0, 0, i >> 24, i >> 16 & 255, i >> 8 & 255, i & 255]),
708
+ Buffer.from([0, 0, 0, 0, r >> 24, r >> 16 & 255, r >> 8 & 255, r & 255]),
704
709
  // 64-bit length
705
710
  t
706
- ]), a;
707
- }, ze = () => {
708
- if (!h) return;
709
- const n = U.get(S);
710
- if (!n || n.size === 0)
711
+ ]), i;
712
+ }, We = () => {
713
+ if (!C) return;
714
+ const o = B.get(S);
715
+ if (!o || o.size === 0)
711
716
  return;
712
- console.log(`πŸ”₯ Notifying ${n.size} HMR client(s)`);
713
- const t = o.default.join(b, "index.html");
717
+ console.log(`πŸ”₯ Notifying ${o.size} HMR client(s)`);
718
+ const t = n.default.join(b, "index.html");
714
719
  try {
715
- const i = e.default.readFileSync(t, "utf-8"), a = be(i, S), l = JSON.stringify({
720
+ const r = e.default.readFileSync(t, "utf-8"), i = xe(r, S), l = JSON.stringify({
716
721
  type: "update",
717
- html: a
718
- }), p = Be(l);
719
- n.forEach((g) => {
722
+ html: i
723
+ }), p = ze(l);
724
+ o.forEach((g) => {
720
725
  try {
721
726
  g.write(p);
722
727
  } catch {
723
- n.delete(g);
728
+ o.delete(g);
724
729
  }
725
730
  });
726
- } catch (i) {
727
- console.error("❌ Failed to read HTML for HMR:", i.message);
731
+ } catch (r) {
732
+ console.error("❌ Failed to read HTML for HMR:", r.message);
728
733
  }
729
734
  };
730
- let xe = !1;
731
- const te = () => {
732
- if (j) {
735
+ let Ce = !1;
736
+ const oe = (o) => {
737
+ if (I) {
733
738
  v = !0;
734
739
  return;
735
740
  }
736
- 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());
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));
743
748
  });
744
749
  return;
745
750
  }
746
- console.error("❌ Build failed:", n.message), i && console.error(i);
751
+ console.error("❌ Build failed:", t.message), i && console.error(i);
747
752
  } else
748
- console.log("βœ… Build completed"), t && console.log(t), ze();
749
- v && (v = !1, te());
753
+ console.log("βœ… Build completed"), r && console.log(r), We(), o && o();
754
+ v && (v = !1, oe());
750
755
  });
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);
756
+ }, $e = /* @__PURE__ */ new Set(), Me = (o) => {
757
+ e.default.readdir(o, { withFileTypes: !0 }, (t, r) => {
758
+ t || (r.forEach((i) => {
759
+ const l = n.default.join(o, i.name);
760
+ if (i.isDirectory())
761
+ i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") && Me(l);
762
+ else if (i.isFile()) {
763
+ const p = n.default.extname(i.name);
759
764
  if (p === ".js" || p === ".css" || p === ".html")
760
765
  try {
761
766
  const g = e.default.readFileSync(l, "utf-8");
762
- T.set(l, g);
767
+ F.set(l, g);
763
768
  } catch {
764
769
  }
765
770
  }
766
- }), Ce.has(n) || (Ce.add(n), e.default.watch(n, (a, l) => {
771
+ }), $e.has(o) || ($e.add(o), e.default.watch(o, (i, l) => {
767
772
  if (!l) return;
768
- const p = o.default.extname(l);
773
+ const p = n.default.extname(l);
769
774
  if (p !== ".js" && p !== ".css" && p !== ".html") return;
770
- const g = o.default.join(n, l);
775
+ const g = n.default.join(o, l);
771
776
  setTimeout(() => {
772
777
  try {
773
- const $ = e.default.readFileSync(g, "utf-8"), N = T.get(g);
774
- $ !== N && (T.set(g, $), 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());
775
780
  } catch {
776
781
  }
777
782
  }, 50);
778
783
  })));
779
784
  });
780
- }, Me = () => {
785
+ }, Oe = (o) => {
781
786
  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
787
+ πŸ”¨ Component: ${S}`), oe(o), Me(D), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
783
788
  `);
784
- }, We = () => new Promise((n) => {
789
+ }, Ve = () => new Promise((o) => {
785
790
  const t = {
786
791
  hostname: "localhost",
787
792
  port: y,
788
793
  path: "/_list",
789
794
  method: "GET",
790
795
  timeout: 1e3
791
- }, i = r.default.request(t, (a) => {
792
- n(!0);
796
+ }, r = a.default.request(t, (i) => {
797
+ o(!0);
793
798
  });
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") {
799
+ r.on("error", () => o(!1)), r.on("timeout", () => {
800
+ r.destroy(), o(!1);
801
+ }), r.end();
802
+ }), Ge = () => new Promise((o) => {
803
+ const t = a.default.createServer((r, i) => {
804
+ if (i.setHeader("Content-Type", "application/json"), r.method === "POST" && r.url === "/_register") {
800
805
  let l = "";
801
- i.on("data", (p) => l += p), i.on("end", () => {
806
+ r.on("data", (p) => l += p), r.on("end", () => {
802
807
  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()) }));
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()) }));
807
812
  } catch (p) {
808
- a.writeHead(400), a.end(JSON.stringify({ error: p.message }));
813
+ i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
809
814
  }
810
815
  });
811
- } else if (i.method === "POST" && i.url === "/_unregister") {
816
+ } else if (r.method === "POST" && r.url === "/_unregister") {
812
817
  let l = "";
813
- i.on("data", (p) => l += p), i.on("end", () => {
818
+ r.on("data", (p) => l += p), r.on("end", () => {
814
819
  try {
815
820
  const { componentId: p } = JSON.parse(l);
816
- x.delete(p), console.log(`❌ Unregistered: ${p}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
821
+ j.delete(p), console.log(`❌ Unregistered: ${p}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
817
822
  } catch (p) {
818
- a.writeHead(400), a.end(JSON.stringify({ error: p.message }));
823
+ i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
819
824
  }
820
825
  });
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" })));
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" })));
822
827
  });
823
828
  t.on("error", () => {
824
- n(!1);
829
+ o(!1);
825
830
  }), t.listen(y, () => {
826
831
  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
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
833
838
  });
834
- const i = k ? ` (${k})` : "";
835
- console.log(`βœ… Registered component: ${S}${i}`), console.log(`πŸ“‘ Access at: http://localhost:${u}/view/${S}/`), n(!0);
839
+ const r = h ? ` (${h})` : "";
840
+ console.log(`βœ… Registered component: ${S}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${S}/`), o(!0);
836
841
  });
837
842
  });
838
843
  });
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 () => {
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 () => {
844
849
  try {
845
- await Se(), console.log(`βœ… Re-registered component: ${S}`), Oe();
846
- } catch (i) {
847
- console.error("❌ Failed to re-register:", i.message);
850
+ await be(), console.log(`βœ… Re-registered component: ${S}`), Ie();
851
+ } catch (r) {
852
+ console.error("❌ Failed to re-register:", r.message);
848
853
  }
849
854
  }, 2e3)));
850
855
  }, 3e3);
851
- }, Ie = async () => {
856
+ }, je = async () => {
852
857
  console.log(`
853
858
 
854
- πŸ›‘ Shutting down...`), oe && clearInterval(oe), await Je(), process.exit(0);
859
+ πŸ›‘ Shutting down...`), ne && clearInterval(ne), await Ue(), process.exit(0);
855
860
  };
856
- process.on("SIGINT", Ie), process.on("SIGTERM", Ie), de.on("error", async (n) => {
857
- if (n.code === "EADDRINUSE") {
861
+ process.on("SIGINT", je), process.on("SIGTERM", je), pe.on("error", async (o) => {
862
+ if (o.code === "EADDRINUSE") {
858
863
  console.log(`
859
864
  πŸ”— Connecting to existing dev server...`);
860
865
  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();
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();
864
871
  } catch (t) {
865
872
  console.error("❌ Failed to register component:", t.message), process.exit(1);
866
873
  }
867
874
  } else
868
- console.error("❌ Management server error:", n.message), process.exit(1);
869
- }), de.on("upgrade", Le), de.listen(y, async () => {
875
+ console.error("❌ Management server error:", o.message), process.exit(1);
876
+ }), pe.on("upgrade", Je), pe.listen(y, async () => {
870
877
  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
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}/`);
877
888
  });
878
- const n = k ? ` (${k})` : "";
879
- console.log(`βœ… Registered component: ${S}${n}`), console.log(`πŸ“‘ Access at: http://localhost:${u}/view/${S}/`), Me();
880
889
  });
881
890
  });
882
891
  }
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 });
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 });
886
895
  }
887
- function ye() {
896
+ function we() {
888
897
  try {
889
- if (!A.existsSync(Q))
898
+ if (!R.existsSync(Z))
890
899
  return null;
891
- const e = A.readFileSync(Q, "utf8");
900
+ const e = R.readFileSync(Z, "utf8");
892
901
  return JSON.parse(e);
893
902
  } catch (e) {
894
903
  return console.info("Failed to read credentials:", e.message), null;
895
904
  }
896
905
  }
897
- function Fe(e) {
898
- ct();
899
- const o = {
906
+ function Ae(e) {
907
+ lt();
908
+ const n = {
900
909
  ...e,
901
910
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
902
911
  };
903
- A.writeFileSync(Q, JSON.stringify(o, null, 2), {
912
+ R.writeFileSync(Z, JSON.stringify(n, null, 2), {
904
913
  mode: 384
905
914
  // Read/write for owner only
906
915
  });
907
916
  }
908
- function Ae() {
917
+ function De() {
909
918
  try {
910
- return A.existsSync(Q) && A.unlinkSync(Q), !0;
919
+ return R.existsSync(Z) && R.unlinkSync(Z), !0;
911
920
  } catch (e) {
912
921
  return console.error("Failed to clear credentials:", e.message), !1;
913
922
  }
914
923
  }
915
- function lt(e) {
924
+ function dt(e) {
916
925
  if (!e || !e.expiresAt)
917
926
  return !0;
918
- const o = 5 * 60 * 1e3, s = new Date(e.expiresAt).getTime();
919
- return Date.now() > s - o;
927
+ const n = 5 * 60 * 1e3, s = new Date(e.expiresAt).getTime();
928
+ return Date.now() > s - n;
920
929
  }
921
- function we() {
922
- const e = ye();
930
+ function ve() {
931
+ const e = we();
923
932
  return e ? {
924
933
  email: e.userEmail,
925
934
  userId: e.userId
926
935
  } : null;
927
936
  }
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");
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");
931
940
  }
932
- function mt(e) {
933
- return ge.createHash("sha256").update(e).digest("base64url");
941
+ function ut(e) {
942
+ return he.createHash("sha256").update(e).digest("base64url");
934
943
  }
935
- async function ut() {
936
- const e = await fetch(`${Y}/oauth/register`, {
944
+ async function ft() {
945
+ const e = await fetch(`${X}/oauth/register`, {
937
946
  method: "POST",
938
947
  headers: { "Content-Type": "application/json" },
939
948
  body: JSON.stringify({
940
- client_name: dt,
941
- redirect_uris: [ve],
949
+ client_name: pt,
950
+ redirect_uris: [Se],
942
951
  grant_types: ["authorization_code", "refresh_token"],
943
952
  response_types: ["code"]
944
953
  })
945
954
  });
946
955
  if (!e.ok) {
947
- const o = await e.text();
948
- throw new Error(`Failed to register client: ${o}`);
956
+ const n = await e.text();
957
+ throw new Error(`Failed to register client: ${n}`);
949
958
  }
950
959
  return e.json();
951
960
  }
952
- function se(e, o, s, r = null) {
961
+ function re(e, n, s, a = null) {
953
962
  const f = {
954
963
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
955
964
  <circle cx="12" cy="12" r="10"/>
@@ -967,13 +976,13 @@ function se(e, o, s, r = null) {
967
976
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
968
977
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
969
978
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
970
- }, { accent: m, glow: w } = c[e] || c.error;
979
+ }, { accent: u, glow: w } = c[e] || c.error;
971
980
  return `<!DOCTYPE html>
972
981
  <html lang="en">
973
982
  <head>
974
983
  <meta charset="UTF-8">
975
984
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
976
- <title>myop-cli | ${o}</title>
985
+ <title>myop-cli | ${n}</title>
977
986
  <style>
978
987
  * {
979
988
  margin: 0;
@@ -1028,7 +1037,7 @@ function se(e, o, s, r = null) {
1028
1037
  h1 {
1029
1038
  font-size: 20px;
1030
1039
  font-weight: 500;
1031
- color: ${m};
1040
+ color: ${u};
1032
1041
  margin-bottom: 12px;
1033
1042
  letter-spacing: -0.5px;
1034
1043
  }
@@ -1061,7 +1070,7 @@ function se(e, o, s, r = null) {
1061
1070
  align-items: center;
1062
1071
  gap: 8px;
1063
1072
  background: ${w};
1064
- border: 1px solid ${m}33;
1073
+ border: 1px solid ${u}33;
1065
1074
  border-radius: 4px;
1066
1075
  padding: 10px 16px;
1067
1076
  font-size: 12px;
@@ -1100,9 +1109,9 @@ function se(e, o, s, r = null) {
1100
1109
  <div class="icon">
1101
1110
  ${f[e] || f.error}
1102
1111
  </div>
1103
- <h1>${o}</h1>
1112
+ <h1>${n}</h1>
1104
1113
  <p class="message">${s}</p>
1105
- ${r ? `<div class="details"><code>Error:</code> ${r}</div>` : ""}
1114
+ ${a ? `<div class="details"><code>Error:</code> ${a}</div>` : ""}
1106
1115
  <div class="hint">
1107
1116
  <span>Press</span>
1108
1117
  <kbd>⌘</kbd><kbd>W</kbd>
@@ -1115,91 +1124,91 @@ function se(e, o, s, r = null) {
1115
1124
  </body>
1116
1125
  </html>`;
1117
1126
  }
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}`);
1122
- 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(
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(
1126
1135
  "error",
1127
1136
  "Authentication Failed",
1128
1137
  "Unable to complete the authentication process.",
1129
- u
1130
- )), r.close(), s(new Error(`OAuth error: ${u}`));
1138
+ m
1139
+ )), a.close(), s(new Error(`OAuth error: ${m}`));
1131
1140
  return;
1132
1141
  }
1133
- if (I !== e) {
1134
- 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(
1135
1144
  "warning",
1136
1145
  "Security Error",
1137
1146
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
1138
1147
  "state_mismatch"
1139
- )), r.close(), s(new Error("State mismatch"));
1148
+ )), a.close(), s(new Error("State mismatch"));
1140
1149
  return;
1141
1150
  }
1142
1151
  if (!w) {
1143
- c.writeHead(400, { "Content-Type": "text/html" }), c.end(se(
1152
+ c.writeHead(400, { "Content-Type": "text/html" }), c.end(re(
1144
1153
  "error",
1145
1154
  "Missing Authorization Code",
1146
1155
  "No authorization code was received from the server.",
1147
1156
  "missing_code"
1148
- )), r.close(), s(new Error("No authorization code"));
1157
+ )), a.close(), s(new Error("No authorization code"));
1149
1158
  return;
1150
1159
  }
1151
- c.writeHead(200, { "Content-Type": "text/html" }), c.end(se(
1160
+ c.writeHead(200, { "Content-Type": "text/html" }), c.end(re(
1152
1161
  "success",
1153
1162
  "Authentication Successful",
1154
1163
  "You have been authenticated successfully. Return to the terminal to continue."
1155
- )), r.close(), o(w);
1164
+ )), a.close(), n(w);
1156
1165
  } else
1157
1166
  c.writeHead(404), c.end("Not found");
1158
1167
  });
1159
- r.listen(ie, () => {
1160
- console.info(`OAuth callback server listening on port ${ie}`);
1168
+ a.listen(ae, () => {
1169
+ console.info(`OAuth callback server listening on port ${ae}`);
1161
1170
  }), setTimeout(() => {
1162
- r.close(), s(new Error("Authentication timed out"));
1171
+ a.close(), s(new Error("Authentication timed out"));
1163
1172
  }, 5 * 60 * 1e3);
1164
1173
  });
1165
1174
  }
1166
- async function gt(e, o, s) {
1167
- const r = await fetch(`${Y}/oauth/token`, {
1175
+ async function ht(e, n, s) {
1176
+ const a = await fetch(`${X}/oauth/token`, {
1168
1177
  method: "POST",
1169
1178
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1170
- body: new ke({
1179
+ body: new Ee({
1171
1180
  grant_type: "authorization_code",
1172
1181
  code: e,
1173
- client_id: o,
1174
- redirect_uri: ve,
1182
+ client_id: n,
1183
+ redirect_uri: Se,
1175
1184
  code_verifier: s
1176
1185
  })
1177
1186
  });
1178
- if (!r.ok) {
1179
- const f = await r.json();
1187
+ if (!a.ok) {
1188
+ const f = await a.json();
1180
1189
  throw new Error(f.error_description || f.error || "Token exchange failed");
1181
1190
  }
1182
- return r.json();
1191
+ return a.json();
1183
1192
  }
1184
- async function ht(e, o) {
1185
- const s = await fetch(`${Y}/oauth/token`, {
1193
+ async function yt(e, n) {
1194
+ const s = await fetch(`${X}/oauth/token`, {
1186
1195
  method: "POST",
1187
1196
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1188
- body: new ke({
1197
+ body: new Ee({
1189
1198
  grant_type: "refresh_token",
1190
1199
  refresh_token: e,
1191
- client_id: o
1200
+ client_id: n
1192
1201
  })
1193
1202
  });
1194
1203
  if (!s.ok) {
1195
- const r = await s.json();
1196
- throw new Error(r.error_description || r.error || "Token refresh failed");
1204
+ const a = await s.json();
1205
+ throw new Error(a.error_description || a.error || "Token refresh failed");
1197
1206
  }
1198
1207
  return s.json();
1199
1208
  }
1200
- async function yt(e) {
1201
- var f, c, m;
1202
- const o = await fetch(`${Y}/mcp`, {
1209
+ async function wt(e) {
1210
+ var f, c, u;
1211
+ const n = await fetch(`${X}/mcp`, {
1203
1212
  method: "POST",
1204
1213
  headers: {
1205
1214
  "Content-Type": "application/json",
@@ -1215,62 +1224,62 @@ async function yt(e) {
1215
1224
  }
1216
1225
  })
1217
1226
  });
1218
- if (!o.ok)
1227
+ if (!n.ok)
1219
1228
  throw new Error("Failed to get user info");
1220
- const s = await o.json();
1229
+ const s = await n.json();
1221
1230
  if (s.error)
1222
1231
  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;
1224
- if (r)
1225
- return JSON.parse(r);
1232
+ const a = (u = (c = (f = s.result) == null ? void 0 : f.content) == null ? void 0 : c[0]) == null ? void 0 : u.text;
1233
+ if (a)
1234
+ return JSON.parse(a);
1226
1235
  throw new Error("Invalid response from whoami");
1227
1236
  }
1228
- async function X() {
1229
- const e = F("Starting authentication...").start();
1237
+ async function Q() {
1238
+ const e = P("Starting authentication...").start();
1230
1239
  try {
1231
1240
  e.text = "Registering OAuth client...";
1232
- const s = (await ut()).client_id, r = pt(), f = mt(r), c = ge.randomBytes(16).toString("hex");
1241
+ const s = (await ft()).client_id, a = mt(), f = ut(a), c = he.randomBytes(16).toString("hex");
1233
1242
  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(`
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(`
1236
1245
  🌐 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;
1246
+ `), await Qe(w.toString());
1247
+ const O = await u;
1239
1248
  e.start("Exchanging authorization code...");
1240
- const u = await gt(I, s, r);
1249
+ const m = await ht(O, s, a);
1241
1250
  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(),
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(),
1246
1255
  clientId: s,
1247
1256
  userId: y.userId,
1248
1257
  userEmail: y.email
1249
1258
  };
1250
- return Fe(b), e.succeed(`Authenticated as ${y.email}`), b;
1251
- } catch (o) {
1252
- 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;
1253
1262
  }
1254
1263
  }
1255
- async function De() {
1256
- const e = ye();
1264
+ async function He() {
1265
+ const e = we();
1257
1266
  if (!e) {
1258
1267
  console.log("Not currently logged in.");
1259
1268
  return;
1260
1269
  }
1261
- Ae(), console.log(`βœ… Logged out (was: ${e.userEmail})`);
1270
+ De(), console.log(`βœ… Logged out (was: ${e.userEmail})`);
1262
1271
  }
1263
- async function wt() {
1264
- let e = ye();
1272
+ async function vt() {
1273
+ let e = we();
1265
1274
  if (!e)
1266
1275
  return console.log(`Not logged in. Starting authentication...
1267
- `), await X();
1268
- if (!lt(e))
1276
+ `), await Q();
1277
+ if (!dt(e))
1269
1278
  return e;
1270
1279
  if (e.refreshToken) {
1271
- const o = F("Refreshing access token...").start();
1280
+ const n = P("Refreshing access token...").start();
1272
1281
  try {
1273
- const s = await ht(
1282
+ const s = await yt(
1274
1283
  e.refreshToken,
1275
1284
  e.clientId
1276
1285
  );
@@ -1279,48 +1288,48 @@ async function wt() {
1279
1288
  accessToken: s.access_token,
1280
1289
  refreshToken: s.refresh_token,
1281
1290
  expiresAt: new Date(Date.now() + s.expires_in * 1e3).toISOString()
1282
- }, Fe(e), o.succeed("Token refreshed"), e;
1291
+ }, Ae(e), n.succeed("Token refreshed"), e;
1283
1292
  } catch {
1284
- return o.warn("Token refresh failed, please log in again"), Ae(), await X();
1293
+ return n.warn("Token refresh failed, please log in again"), De(), await Q();
1285
1294
  }
1286
1295
  }
1287
1296
  return console.log(`Session expired. Please log in again.
1288
- `), await X();
1297
+ `), await Q();
1289
1298
  }
1290
- function vt() {
1291
- return Y;
1299
+ function St() {
1300
+ return X;
1292
1301
  }
1293
- const ae = "@myop/cli";
1294
- async function St() {
1302
+ const ce = "@myop/cli";
1303
+ async function bt() {
1295
1304
  try {
1296
- const e = await fetch(`https://registry.npmjs.org/${ae}/latest`);
1305
+ const e = await fetch(`https://registry.npmjs.org/${ce}/latest`);
1297
1306
  return e.ok ? (await e.json()).version : null;
1298
1307
  } catch {
1299
1308
  return null;
1300
1309
  }
1301
1310
  }
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;
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;
1308
1317
  }
1309
1318
  return 0;
1310
1319
  }
1311
- async function xt(e) {
1312
- const o = F({
1320
+ async function Ct(e) {
1321
+ const n = P({
1313
1322
  text: "Checking for updates...",
1314
1323
  color: "cyan"
1315
- }).start(), s = await St();
1316
- if (o.stop(), !s || bt(s, e) <= 0)
1324
+ }).start(), s = await bt();
1325
+ if (n.stop(), !s || xt(s, e) <= 0)
1317
1326
  return !1;
1318
1327
  console.log(`
1319
1328
  πŸ“¦ New version available: ${e} β†’ ${s}
1320
1329
  `);
1321
- let r;
1330
+ let a;
1322
1331
  try {
1323
- r = await _e({
1332
+ a = await Ne({
1324
1333
  message: "Would you like to update now?",
1325
1334
  choices: [
1326
1335
  { name: "Yes, update now", value: !0 },
@@ -1333,49 +1342,49 @@ async function xt(e) {
1333
1342
  πŸ‘‹ Goodbye!
1334
1343
  `), process.exit(0)), f;
1335
1344
  }
1336
- if (r) {
1337
- const f = F({
1338
- text: `Updating ${ae} to v${s}...`,
1345
+ if (a) {
1346
+ const f = P({
1347
+ text: `Updating ${ce} to v${s}...`,
1339
1348
  color: "green"
1340
1349
  }).start();
1341
1350
  try {
1342
- return re(`npm install -g ${ae}@latest`, { stdio: "pipe" }), f.succeed(`Updated to v${s}`), console.log(`
1351
+ return ie(`npm install -g ${ce}@latest`, { stdio: "pipe" }), f.succeed(`Updated to v${s}`), console.log(`
1343
1352
  πŸ”„ Restarting with new version...
1344
- `), Ye("myop", process.argv.slice(2), {
1353
+ `), Ke("myop", process.argv.slice(2), {
1345
1354
  stdio: "inherit",
1346
1355
  shell: !0
1347
- }).on("close", (m) => {
1348
- process.exit(m || 0);
1356
+ }).on("close", (u) => {
1357
+ process.exit(u || 0);
1349
1358
  }), !0;
1350
1359
  } catch {
1351
1360
  return f.fail("Update failed"), console.log(`
1352
- You can manually update by running: npm install -g ${ae}@latest
1361
+ You can manually update by running: npm install -g ${ce}@latest
1353
1362
  `), !1;
1354
1363
  }
1355
1364
  }
1356
1365
  return !1;
1357
1366
  }
1358
- const Ct = (e) => new Promise((o) => setTimeout(o, e));
1367
+ const $t = (e) => new Promise((n) => setTimeout(n, e));
1359
1368
  d.executionPath = process.cwd();
1360
- const le = (e = !1) => {
1361
- const o = d.program.getOptionValue("verbose");
1362
- o || (console.info = () => {
1369
+ const de = (e = !1) => {
1370
+ const n = d.program.getOptionValue("verbose");
1371
+ n || (console.info = () => {
1363
1372
  }), console.info("πŸ“ verbose mode on"), d.options = {
1364
1373
  configPath: d.program.getOptionValue("config"),
1365
- verbose: o
1374
+ verbose: n
1366
1375
  };
1367
1376
  try {
1368
- return d.myopConfig = qe(d.options.configPath), { configFound: !0 };
1377
+ return d.myopConfig = et(d.options.configPath), { configFound: !0 };
1369
1378
  } catch (s) {
1370
1379
  if (e) {
1371
1380
  console.info(`
1372
1381
  ⚠️ failed read config file from ${d.options.configPath}, trying to create new one`);
1373
1382
  try {
1374
- const r = {
1383
+ const a = {
1375
1384
  author: "@myop-cli",
1376
1385
  flows: []
1377
1386
  };
1378
- return he(d.options.configPath, r), d.myopConfig = r, { configFound: !0 };
1387
+ return ye(d.options.configPath, a), d.myopConfig = a, { configFound: !0 };
1379
1388
  } catch {
1380
1389
  return console.info("Error details :", s), { configFound: !1, error: s };
1381
1390
  }
@@ -1384,75 +1393,75 @@ const le = (e = !1) => {
1384
1393
  }
1385
1394
  };
1386
1395
  [
1387
- new ue(),
1388
- ...it
1396
+ new fe(),
1397
+ ...at
1389
1398
  ];
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();
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();
1399
1408
  });
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();
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();
1402
1411
  });
1403
1412
  d.program.command("install").description("Install Myop assets").action(async () => {
1404
- le(), await Ee.action();
1413
+ de(), await Te.action();
1405
1414
  });
1406
1415
  d.program.command("login").description("Authenticate with Myop platform").action(async () => {
1407
1416
  try {
1408
- await X();
1417
+ await Q();
1409
1418
  } catch (e) {
1410
1419
  console.error("Login failed:", e.message), process.exit(1);
1411
1420
  }
1412
1421
  process.exit(0);
1413
1422
  });
1414
1423
  d.program.command("logout").description("Clear stored credentials").action(async () => {
1415
- await De(), process.exit(0);
1424
+ await He(), process.exit(0);
1416
1425
  });
1417
1426
  d.program.command("whoami").description("Show current authenticated user").action(async () => {
1418
- const e = we();
1427
+ const e = ve();
1419
1428
  e && e.email ? console.log(`Logged in as: ${e.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1420
1429
  });
1421
1430
  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");
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");
1424
1433
  let c = {};
1425
- if (s.existsSync(o))
1434
+ if (s.existsSync(n))
1426
1435
  try {
1427
- const h = s.readFileSync(o, "utf-8");
1436
+ const h = s.readFileSync(n, "utf-8");
1428
1437
  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}`);
1438
+ const C = c.name || c.componentName;
1439
+ console.log(`πŸ“‹ Found config: ${C || "Unnamed component"}`), c.componentId && console.log(` Component ID: ${c.componentId}`);
1431
1440
  } catch (h) {
1432
- console.error(`⚠️ Failed to parse ${o}:`, h.message);
1441
+ console.error(`⚠️ Failed to parse ${n}:`, h.message);
1433
1442
  }
1434
1443
  else
1435
1444
  console.log("⚠️ No myop.config.json found. A new component will be created.");
1436
1445
  if (!e.skipBuild) {
1437
- const h = F("Building project...").start();
1446
+ const h = P("Building project...").start();
1438
1447
  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);
1448
+ a("npm run build", { stdio: "pipe" }), h.succeed("Build completed");
1449
+ } catch (C) {
1450
+ h.fail("Build failed"), console.error(C.message), process.exit(1);
1442
1451
  }
1443
1452
  }
1444
- 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));
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));
1446
1455
  let w;
1447
1456
  try {
1448
- w = await wt();
1457
+ w = await vt();
1449
1458
  } catch (h) {
1450
1459
  console.error("❌ Authentication failed:", h.message), process.exit(1);
1451
1460
  }
1452
- const I = vt();
1453
- let u = F("Requesting upload URL...").start(), y;
1461
+ const O = St();
1462
+ let m = P("Requesting upload URL...").start(), y;
1454
1463
  try {
1455
- const h = await fetch(`${I}/mcp`, {
1464
+ const h = await fetch(`${O}/mcp`, {
1456
1465
  method: "POST",
1457
1466
  headers: {
1458
1467
  "Content-Type": "application/json",
@@ -1474,50 +1483,50 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1474
1483
  });
1475
1484
  if (!h.ok)
1476
1485
  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)
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)
1482
1491
  throw new Error(y.error);
1483
- u.succeed("Upload URL obtained");
1492
+ m.succeed("Upload URL obtained");
1484
1493
  } catch (h) {
1485
- 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);
1486
1495
  }
1487
- u = F("Uploading component...").start();
1496
+ m = P("Uploading component...").start();
1488
1497
  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];
1498
+ const h = s.readFileSync(u, "utf-8");
1499
+ let C;
1500
+ const A = y.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
1501
+ if (A)
1502
+ C = A[1];
1494
1503
  else {
1495
- const x = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1496
- if (x)
1497
- M = x[1];
1504
+ const V = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1505
+ if (V)
1506
+ C = V[1];
1498
1507
  else
1499
1508
  throw new Error("Could not parse presigned URL from: " + y.curlCommand);
1500
1509
  }
1501
- console.info("Uploading to:", M.substring(0, 100) + "...");
1502
- const K = await fetch(M, {
1510
+ console.info("Uploading to:", C.substring(0, 100) + "...");
1511
+ const D = await fetch(C, {
1503
1512
  method: "PUT",
1504
1513
  headers: {
1505
1514
  "Content-Type": "text/html"
1506
1515
  },
1507
1516
  body: h
1508
1517
  });
1509
- if (!K.ok) {
1510
- const x = await K.text();
1511
- throw new Error(`Upload failed with status ${K.status}: ${x}`);
1518
+ if (!D.ok) {
1519
+ const V = await D.text();
1520
+ throw new Error(`Upload failed with status ${D.status}: ${V}`);
1512
1521
  }
1513
- u.succeed("Component uploaded");
1522
+ m.succeed("Component uploaded");
1514
1523
  } catch (h) {
1515
- 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);
1516
1525
  }
1517
- u = F("Confirming upload...").start();
1526
+ m = P("Confirming upload...").start();
1518
1527
  let b;
1519
1528
  try {
1520
- const h = await fetch(`${I}/mcp`, {
1529
+ const h = await fetch(`${O}/mcp`, {
1521
1530
  method: "POST",
1522
1531
  headers: {
1523
1532
  "Content-Type": "application/json",
@@ -1537,43 +1546,43 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1537
1546
  });
1538
1547
  if (!h.ok)
1539
1548
  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)
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)
1545
1554
  throw new Error(b.error);
1546
- u.succeed("Upload confirmed");
1555
+ m.succeed("Upload confirmed");
1547
1556
  } catch (h) {
1548
- u.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
1557
+ m.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
1549
1558
  }
1550
1559
  if (b.isNewComponent || !c.componentId) {
1551
1560
  c.componentId = b.componentId, c.organization = b.orgId, c.name || (c.name = b.componentName);
1552
1561
  try {
1553
- s.writeFileSync(o, JSON.stringify(c, null, 2)), console.log(`
1554
- πŸ“ Updated ${o} with componentId`);
1562
+ s.writeFileSync(n, JSON.stringify(c, null, 2)), console.log(`
1563
+ πŸ“ Updated ${n} with componentId`);
1555
1564
  } catch (h) {
1556
1565
  console.log(`
1557
- ⚠️ Could not update ${o}: ${h.message}`), console.log(` Please add componentId: "${b.componentId}" manually`);
1566
+ ⚠️ Could not update ${n}: ${h.message}`), console.log(` Please add componentId: "${b.componentId}" manually`);
1558
1567
  }
1559
1568
  }
1560
1569
  console.log(`
1561
1570
  βœ… Sync completed successfully!`), console.log(` Component: ${b.componentName}`), console.log(` Dashboard: ${b.dashboardUrl}`), process.exit(0);
1562
1571
  });
1563
- d.program.command("dev").description("Start development server with file watching").action(Re);
1564
- const Mt = () => {
1572
+ d.program.command("dev").description("Start development server with file watching").action(Fe);
1573
+ const Ot = () => {
1565
1574
  try {
1566
- re("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1575
+ ie("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1567
1576
  } catch {
1568
1577
  return { gitNotInstalled: !0 };
1569
1578
  }
1570
1579
  try {
1571
- 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"] });
1572
1581
  } catch {
1573
1582
  return { notARepo: !0 };
1574
1583
  }
1575
1584
  try {
1576
- 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", {
1577
1586
  encoding: "utf-8",
1578
1587
  stdio: ["pipe", "pipe", "pipe"]
1579
1588
  }).trim();
@@ -1583,23 +1592,23 @@ const Mt = () => {
1583
1592
  insertions: 0,
1584
1593
  deletions: 0
1585
1594
  };
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/);
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/);
1588
1597
  return {
1589
1598
  files: c ? parseInt(c[1]) : 0,
1590
- insertions: r ? parseInt(r[1]) : 0,
1599
+ insertions: a ? parseInt(a[1]) : 0,
1591
1600
  deletions: f ? parseInt(f[1]) : 0
1592
1601
  };
1593
1602
  } catch {
1594
1603
  return null;
1595
1604
  }
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();
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();
1599
1608
  console.log(`
1600
1609
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), 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 = [
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 = [
1603
1612
  {
1604
1613
  emoji: "πŸš€",
1605
1614
  label: "Initialize new component",
@@ -1607,49 +1616,49 @@ const Mt = () => {
1607
1616
  help: "Creates myop.config.json in current directory",
1608
1617
  disabled: e ? "(config already exists)" : !1
1609
1618
  },
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
1619
  {
1618
1620
  emoji: "πŸ› οΈ ",
1619
1621
  label: f ? `Start dev mode for "${f}"` : "Start dev mode",
1620
1622
  value: "dev",
1621
1623
  help: "Starts dev server with HMR for instant preview of changes",
1622
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)"
1623
1632
  }
1624
1633
  ].map((v) => ({
1625
- name: o && !v.disabled ? `${v.emoji} ${v.label}
1634
+ name: n && !v.disabled ? `${v.emoji} ${v.label}
1626
1635
  ${v.help}` : `${v.emoji} ${v.label}`,
1627
1636
  value: v.value,
1628
1637
  disabled: v.disabled
1629
1638
  }));
1630
- I.push(
1631
- new ue(),
1639
+ O.push(
1640
+ new fe(),
1632
1641
  {
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",
1636
- value: r ? "logout" : "login"
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",
1645
+ value: a ? "logout" : "login"
1637
1646
  },
1638
1647
  {
1639
- name: o ? "πŸ“– Hide help" : "πŸ“– Show help",
1648
+ name: n ? "πŸ“– Hide help" : "πŸ“– Show help",
1640
1649
  value: "help"
1641
1650
  },
1642
- new ue(),
1651
+ new fe(),
1643
1652
  {
1644
1653
  name: "πŸ‘‹ Exit",
1645
1654
  value: "exit"
1646
1655
  }
1647
1656
  );
1648
- let u;
1657
+ let m;
1649
1658
  try {
1650
- u = await _e({
1659
+ m = await Ne({
1651
1660
  message: "What would you like to do?",
1652
- choices: I
1661
+ choices: O
1653
1662
  });
1654
1663
  } catch (v) {
1655
1664
  throw v.name === "ExitPromptError" && (console.log(`
@@ -1657,9 +1666,9 @@ const Mt = () => {
1657
1666
  πŸ‘‹ Goodbye!
1658
1667
  `), process.exit(0)), v;
1659
1668
  }
1660
- switch (u) {
1669
+ switch (m) {
1661
1670
  case "init":
1662
- await Ot();
1671
+ await It();
1663
1672
  break;
1664
1673
  case "sync":
1665
1674
  console.log(`
@@ -1670,37 +1679,37 @@ Running sync...
1670
1679
  v("node " + process.argv[1] + " sync", { stdio: "inherit" });
1671
1680
  } catch {
1672
1681
  }
1673
- await B(!0, o);
1682
+ await z(!0, n);
1674
1683
  break;
1675
1684
  case "dev":
1676
- await Re();
1685
+ await Fe();
1677
1686
  break;
1678
1687
  case "login":
1679
1688
  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);
1689
+ await Q(), console.log(`
1690
+ `), await z(e, n);
1691
+ } catch (E) {
1692
+ console.error("Login failed:", E.message), await z(e, n);
1684
1693
  }
1685
1694
  break;
1686
1695
  case "logout":
1687
- await De(), console.log(`
1688
- `), await B(e, o);
1696
+ await He(), console.log(`
1697
+ `), await z(e, n);
1689
1698
  break;
1690
1699
  case "help":
1691
- await B(e, !o);
1700
+ await z(e, !n);
1692
1701
  break;
1693
1702
  case "exit":
1694
1703
  process.exit(0);
1695
1704
  }
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;
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;
1699
1708
  try {
1700
1709
  c = await e({
1701
1710
  message: "Component name:",
1702
1711
  default: f
1703
- }), m = await o({
1712
+ }), u = await n({
1704
1713
  message: "Component type:",
1705
1714
  choices: [
1706
1715
  { name: "πŸ“„ HTML", value: "html", description: "Plain HTML/JS/CSS component" },
@@ -1709,21 +1718,22 @@ Running sync...
1709
1718
  { name: "πŸ…°οΈ Angular", value: "angular", disabled: "(coming soon)" }
1710
1719
  ]
1711
1720
  });
1712
- } catch (u) {
1713
- throw u.name === "ExitPromptError" && (console.log(`
1721
+ } catch (m) {
1722
+ throw m.name === "ExitPromptError" && (console.log(`
1714
1723
 
1715
1724
  πŸ‘‹ Goodbye!
1716
- `), process.exit(0)), u;
1725
+ `), process.exit(0)), m;
1717
1726
  }
1718
1727
  const w = {
1719
1728
  name: c,
1720
- type: m,
1721
- author: "@myop-cli"
1722
- }, 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";
1723
1733
  try {
1724
- s.writeFileSync(I, JSON.stringify(w, null, 2)), console.log(`
1725
- βœ… Created ${I}`);
1726
- const u = {
1734
+ s.writeFileSync(O, JSON.stringify(w, null, 2)), console.log(`
1735
+ βœ… Created ${O}`);
1736
+ const m = {
1727
1737
  name: c.toLowerCase().replace(/\s+/g, "-"),
1728
1738
  version: "1.0.0",
1729
1739
  type: "module",
@@ -1735,7 +1745,7 @@ Running sync...
1735
1745
  esbuild: "^0.24.0"
1736
1746
  }
1737
1747
  };
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';
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';
1739
1749
  import fs from 'fs';
1740
1750
  import path from 'path';
1741
1751
 
@@ -1833,7 +1843,7 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
1833
1843
  </html>
1834
1844
  `;
1835
1845
  s.writeFileSync("index.html", b), console.log("βœ… Created index.html");
1836
- const j = `// ${c} - Entry Point
1846
+ const I = `// ${c} - Entry Point
1837
1847
  import { init } from './modules/app.js';
1838
1848
  import { setupMyopInterface } from './modules/myop.js';
1839
1849
 
@@ -1842,7 +1852,7 @@ document.addEventListener('DOMContentLoaded', () => {
1842
1852
  setupMyopInterface();
1843
1853
  });
1844
1854
  `;
1845
- s.writeFileSync("src/index.js", j), console.log("βœ… Created src/index.js");
1855
+ s.writeFileSync("src/index.js", I), console.log("βœ… Created src/index.js");
1846
1856
  const v = `// ${c} - Main Application Logic
1847
1857
 
1848
1858
  export function init() {
@@ -1867,12 +1877,12 @@ export function setupMyopInterface() {
1867
1877
  };
1868
1878
  }
1869
1879
  `), console.log("βœ… Created src/modules/myop.js");
1870
- const z = `/* ${c} - Styles Entry Point */
1880
+ const F = `/* ${c} - Styles Entry Point */
1871
1881
  /* Add your CSS imports here - they will be auto-bundled */
1872
1882
  @import './main.css';
1873
1883
  `;
1874
- s.writeFileSync("src/styles/index.css", z), console.log("βœ… Created src/styles/index.css");
1875
- const S = `/* ${c} - Main Styles */
1884
+ s.writeFileSync("src/styles/index.css", F), console.log("βœ… Created src/styles/index.css");
1885
+ const W = `/* ${c} - Main Styles */
1876
1886
 
1877
1887
  * {
1878
1888
  box-sizing: border-box;
@@ -1901,20 +1911,20 @@ p {
1901
1911
  line-height: 1.5;
1902
1912
  }
1903
1913
  `;
1904
- s.writeFileSync("src/styles/main.css", S), 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(`
1905
1915
  πŸ“¦ 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);
1916
+ `), d.myopConfig = w, await z(!0);
1917
+ } catch (m) {
1918
+ console.error(`Failed to initialize component: ${m.message}`), process.exit(1);
1909
1919
  }
1910
1920
  };
1911
1921
  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();
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();
1914
1924
  let y = { found: !1 };
1915
1925
  try {
1916
- if (m.existsSync(w)) {
1917
- 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);
1918
1928
  y = {
1919
1929
  found: !0,
1920
1930
  path: w,
@@ -1923,27 +1933,27 @@ d.program.command("default", { isDefault: !0 }).action(async () => {
1923
1933
  organization: v.organization || null
1924
1934
  };
1925
1935
  }
1926
- } catch (j) {
1927
- y = { found: !1, error: j.message };
1936
+ } catch (I) {
1937
+ y = { found: !1, error: I.message };
1928
1938
  }
1929
1939
  const b = {
1930
- version: I,
1940
+ version: O,
1931
1941
  config: y,
1932
1942
  auth: {
1933
- loggedIn: !!(u != null && u.email),
1934
- email: (u == null ? void 0 : u.email) || null
1943
+ loggedIn: !!(m != null && m.email),
1944
+ email: (m == null ? void 0 : m.email) || null
1935
1945
  }
1936
1946
  };
1937
1947
  console.log(JSON.stringify(b, null, 2)), process.exit(0);
1938
1948
  }
1939
- let s = F({
1949
+ let s = P({
1940
1950
  text: "Loading Myop CLI...",
1941
1951
  color: "green"
1942
1952
  }).start();
1943
- const r = le();
1944
- await Ct(500), s.stop();
1953
+ const a = de();
1954
+ await $t(500), s.stop();
1945
1955
  const f = d.program.version();
1946
- await xt(f) || await B(r.configFound);
1956
+ await Ct(f) || await z(a.configFound);
1947
1957
  });
1948
1958
  d.program.parse(process.argv);
1949
1959
  d.program.opts();