@demoscript/cli 1.0.3 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.cjs CHANGED
@@ -7940,10 +7940,10 @@ var require_raw_body = __commonJS({
7940
7940
  if (done) {
7941
7941
  return readStream(stream, encoding, length, limit, wrap(done));
7942
7942
  }
7943
- return new Promise(function executor(resolve5, reject) {
7943
+ return new Promise(function executor(resolve6, reject) {
7944
7944
  readStream(stream, encoding, length, limit, function onRead(err, buf) {
7945
7945
  if (err) return reject(err);
7946
- resolve5(buf);
7946
+ resolve6(buf);
7947
7947
  });
7948
7948
  });
7949
7949
  }
@@ -22217,11 +22217,11 @@ var require_view = __commonJS({
22217
22217
  var debug = require_src3()("express:view");
22218
22218
  var path2 = require("path");
22219
22219
  var fs6 = require("fs");
22220
- var dirname7 = path2.dirname;
22220
+ var dirname8 = path2.dirname;
22221
22221
  var basename4 = path2.basename;
22222
22222
  var extname2 = path2.extname;
22223
- var join7 = path2.join;
22224
- var resolve5 = path2.resolve;
22223
+ var join8 = path2.join;
22224
+ var resolve6 = path2.resolve;
22225
22225
  module2.exports = View;
22226
22226
  function View(name, options) {
22227
22227
  var opts = options || {};
@@ -22255,8 +22255,8 @@ var require_view = __commonJS({
22255
22255
  debug('lookup "%s"', name);
22256
22256
  for (var i = 0; i < roots.length && !path3; i++) {
22257
22257
  var root = roots[i];
22258
- var loc = resolve5(root, name);
22259
- var dir = dirname7(loc);
22258
+ var loc = resolve6(root, name);
22259
+ var dir = dirname8(loc);
22260
22260
  var file = basename4(loc);
22261
22261
  path3 = this.resolve(dir, file);
22262
22262
  }
@@ -22266,14 +22266,14 @@ var require_view = __commonJS({
22266
22266
  debug('render "%s"', this.path);
22267
22267
  this.engine(this.path, options, callback);
22268
22268
  };
22269
- View.prototype.resolve = function resolve6(dir, file) {
22269
+ View.prototype.resolve = function resolve7(dir, file) {
22270
22270
  var ext = this.ext;
22271
- var path3 = join7(dir, file);
22271
+ var path3 = join8(dir, file);
22272
22272
  var stat4 = tryStat(path3);
22273
22273
  if (stat4 && stat4.isFile()) {
22274
22274
  return path3;
22275
22275
  }
22276
- path3 = join7(dir, basename4(file, ext), "index" + ext);
22276
+ path3 = join8(dir, basename4(file, ext), "index" + ext);
22277
22277
  stat4 = tryStat(path3);
22278
22278
  if (stat4 && stat4.isFile()) {
22279
22279
  return path3;
@@ -23330,9 +23330,9 @@ var require_send = __commonJS({
23330
23330
  var Stream = require("stream");
23331
23331
  var util = require("util");
23332
23332
  var extname2 = path2.extname;
23333
- var join7 = path2.join;
23333
+ var join8 = path2.join;
23334
23334
  var normalize2 = path2.normalize;
23335
- var resolve5 = path2.resolve;
23335
+ var resolve6 = path2.resolve;
23336
23336
  var sep = path2.sep;
23337
23337
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
23338
23338
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
@@ -23369,7 +23369,7 @@ var require_send = __commonJS({
23369
23369
  this._maxage = opts.maxAge || opts.maxage;
23370
23370
  this._maxage = typeof this._maxage === "string" ? ms(this._maxage) : Number(this._maxage);
23371
23371
  this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
23372
- this._root = opts.root ? resolve5(opts.root) : null;
23372
+ this._root = opts.root ? resolve6(opts.root) : null;
23373
23373
  if (!this._root && opts.from) {
23374
23374
  this.from(opts.from);
23375
23375
  }
@@ -23393,7 +23393,7 @@ var require_send = __commonJS({
23393
23393
  return this;
23394
23394
  }, "send.index: pass index as option");
23395
23395
  SendStream.prototype.root = function root(path3) {
23396
- this._root = resolve5(String(path3));
23396
+ this._root = resolve6(String(path3));
23397
23397
  debug("root %s", this._root);
23398
23398
  return this;
23399
23399
  };
@@ -23549,7 +23549,7 @@ var require_send = __commonJS({
23549
23549
  return res;
23550
23550
  }
23551
23551
  parts = path3.split(sep);
23552
- path3 = normalize2(join7(root, path3));
23552
+ path3 = normalize2(join8(root, path3));
23553
23553
  } else {
23554
23554
  if (UP_PATH_REGEXP.test(path3)) {
23555
23555
  debug('malicious path "%s"', path3);
@@ -23557,7 +23557,7 @@ var require_send = __commonJS({
23557
23557
  return res;
23558
23558
  }
23559
23559
  parts = normalize2(path3).split(sep);
23560
- path3 = resolve5(path3);
23560
+ path3 = resolve6(path3);
23561
23561
  }
23562
23562
  if (containsDotFile(parts)) {
23563
23563
  var access = this._dotfiles;
@@ -23684,7 +23684,7 @@ var require_send = __commonJS({
23684
23684
  if (err) return self.onStatError(err);
23685
23685
  return self.error(404);
23686
23686
  }
23687
- var p = join7(path3, self._index[i]);
23687
+ var p = join8(path3, self._index[i]);
23688
23688
  debug('stat "%s"', p);
23689
23689
  fs6.stat(p, function(err2, stat4) {
23690
23690
  if (err2) return next(err2);
@@ -24836,7 +24836,7 @@ var require_application = __commonJS({
24836
24836
  var deprecate = require_depd()("express");
24837
24837
  var flatten = require_array_flatten();
24838
24838
  var merge2 = require_utils_merge();
24839
- var resolve5 = require("path").resolve;
24839
+ var resolve6 = require("path").resolve;
24840
24840
  var setPrototypeOf = require_setprototypeof();
24841
24841
  var hasOwnProperty = Object.prototype.hasOwnProperty;
24842
24842
  var slice = Array.prototype.slice;
@@ -24875,7 +24875,7 @@ var require_application = __commonJS({
24875
24875
  this.mountpath = "/";
24876
24876
  this.locals.settings = this.settings;
24877
24877
  this.set("view", View);
24878
- this.set("views", resolve5("views"));
24878
+ this.set("views", resolve6("views"));
24879
24879
  this.set("jsonp callback name", "callback");
24880
24880
  if (env2 === "production") {
24881
24881
  this.enable("view cache");
@@ -26120,7 +26120,7 @@ var require_response = __commonJS({
26120
26120
  var send = require_send();
26121
26121
  var extname2 = path2.extname;
26122
26122
  var mime = send.mime;
26123
- var resolve5 = path2.resolve;
26123
+ var resolve6 = path2.resolve;
26124
26124
  var vary = require_vary();
26125
26125
  var res = Object.create(http.ServerResponse.prototype);
26126
26126
  module2.exports = res;
@@ -26379,7 +26379,7 @@ var require_response = __commonJS({
26379
26379
  }
26380
26380
  opts = Object.create(opts);
26381
26381
  opts.headers = headers;
26382
- var fullPath = !opts.root ? resolve5(path3) : path3;
26382
+ var fullPath = !opts.root ? resolve6(path3) : path3;
26383
26383
  return this.sendFile(fullPath, opts, done);
26384
26384
  };
26385
26385
  res.contentType = res.type = function contentType(type2) {
@@ -26645,7 +26645,7 @@ var require_serve_static = __commonJS({
26645
26645
  var encodeUrl = require_encodeurl();
26646
26646
  var escapeHtml = require_escape_html();
26647
26647
  var parseUrl = require_parseurl();
26648
- var resolve5 = require("path").resolve;
26648
+ var resolve6 = require("path").resolve;
26649
26649
  var send = require_send();
26650
26650
  var url = require("url");
26651
26651
  module2.exports = serveStatic;
@@ -26665,7 +26665,7 @@ var require_serve_static = __commonJS({
26665
26665
  throw new TypeError("option setHeaders must be function");
26666
26666
  }
26667
26667
  opts.maxage = opts.maxage || opts.maxAge || 0;
26668
- opts.root = resolve5(root);
26668
+ opts.root = resolve6(root);
26669
26669
  var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
26670
26670
  return function serveStatic2(req, res, next) {
26671
26671
  if (req.method !== "GET" && req.method !== "HEAD") {
@@ -36033,7 +36033,7 @@ var require_compile = __commonJS({
36033
36033
  const schOrFunc = root.refs[ref];
36034
36034
  if (schOrFunc)
36035
36035
  return schOrFunc;
36036
- let _sch = resolve5.call(this, root, ref);
36036
+ let _sch = resolve6.call(this, root, ref);
36037
36037
  if (_sch === void 0) {
36038
36038
  const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
36039
36039
  const { schemaId } = this.opts;
@@ -36060,7 +36060,7 @@ var require_compile = __commonJS({
36060
36060
  function sameSchemaEnv(s1, s2) {
36061
36061
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
36062
36062
  }
36063
- function resolve5(root, ref) {
36063
+ function resolve6(root, ref) {
36064
36064
  let sch;
36065
36065
  while (typeof (sch = this.refs[ref]) == "string")
36066
36066
  ref = sch;
@@ -36635,7 +36635,7 @@ var require_fast_uri = __commonJS({
36635
36635
  }
36636
36636
  return uri;
36637
36637
  }
36638
- function resolve5(baseURI, relativeURI, options) {
36638
+ function resolve6(baseURI, relativeURI, options) {
36639
36639
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
36640
36640
  const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
36641
36641
  schemelessOptions.skipEscape = true;
@@ -36862,7 +36862,7 @@ var require_fast_uri = __commonJS({
36862
36862
  var fastUri = {
36863
36863
  SCHEMES,
36864
36864
  normalize: normalize2,
36865
- resolve: resolve5,
36865
+ resolve: resolve6,
36866
36866
  resolveComponent,
36867
36867
  equal,
36868
36868
  serialize,
@@ -40029,14 +40029,14 @@ var init_open = __esm({
40029
40029
  }
40030
40030
  const subprocess = import_node_child_process5.default.spawn(command, cliArguments, childProcessOptions);
40031
40031
  if (options.wait) {
40032
- return new Promise((resolve5, reject) => {
40032
+ return new Promise((resolve6, reject) => {
40033
40033
  subprocess.once("error", reject);
40034
40034
  subprocess.once("close", (exitCode) => {
40035
40035
  if (!options.allowNonzeroExitCode && exitCode > 0) {
40036
40036
  reject(new Error(`Exited with code ${exitCode}`));
40037
40037
  return;
40038
40038
  }
40039
- resolve5(subprocess);
40039
+ resolve6(subprocess);
40040
40040
  });
40041
40041
  });
40042
40042
  }
@@ -40126,6 +40126,9 @@ var {
40126
40126
  Help
40127
40127
  } = import_index.default;
40128
40128
 
40129
+ // src/index.ts
40130
+ var import_module = require("module");
40131
+
40129
40132
  // src/commands/serve.ts
40130
40133
  var import_path3 = require("path");
40131
40134
  var import_url2 = require("url");
@@ -40869,9 +40872,9 @@ var NodeFsHandler = class {
40869
40872
  if (this.fsw.closed) {
40870
40873
  return;
40871
40874
  }
40872
- const dirname7 = sysPath.dirname(file);
40875
+ const dirname8 = sysPath.dirname(file);
40873
40876
  const basename4 = sysPath.basename(file);
40874
- const parent = this.fsw._getWatchedDir(dirname7);
40877
+ const parent = this.fsw._getWatchedDir(dirname8);
40875
40878
  let prevStats = stats;
40876
40879
  if (parent.has(basename4))
40877
40880
  return;
@@ -40898,7 +40901,7 @@ var NodeFsHandler = class {
40898
40901
  prevStats = newStats2;
40899
40902
  }
40900
40903
  } catch (error) {
40901
- this.fsw._remove(dirname7, basename4);
40904
+ this.fsw._remove(dirname8, basename4);
40902
40905
  }
40903
40906
  } else if (parent.has(basename4)) {
40904
40907
  const at = newStats.atimeMs;
@@ -40994,7 +40997,7 @@ var NodeFsHandler = class {
40994
40997
  this._addToNodeFs(path2, initialAdd, wh, depth + 1);
40995
40998
  }
40996
40999
  }).on(EV.ERROR, this._boundHandleError);
40997
- return new Promise((resolve5, reject) => {
41000
+ return new Promise((resolve6, reject) => {
40998
41001
  if (!stream)
40999
41002
  return reject();
41000
41003
  stream.once(STR_END, () => {
@@ -41003,7 +41006,7 @@ var NodeFsHandler = class {
41003
41006
  return;
41004
41007
  }
41005
41008
  const wasThrottled = throttler ? throttler.clear() : false;
41006
- resolve5(void 0);
41009
+ resolve6(void 0);
41007
41010
  previous.getChildren().filter((item) => {
41008
41011
  return item !== directory && !current.has(item);
41009
41012
  }).forEach((item) => {
@@ -42121,7 +42124,7 @@ function inferResultType(varName, jsonPath) {
42121
42124
  return "mono";
42122
42125
  }
42123
42126
  if (nameLower.includes("address") || nameLower.includes("wallet")) {
42124
- return "address";
42127
+ return "ref";
42125
42128
  }
42126
42129
  if (nameLower.includes("url") || nameLower.includes("link")) {
42127
42130
  return "link";
@@ -42281,7 +42284,7 @@ function createShellExecutor() {
42281
42284
  };
42282
42285
  }
42283
42286
  function executeCommand(command, options) {
42284
- return new Promise((resolve5) => {
42287
+ return new Promise((resolve6) => {
42285
42288
  const shell = typeof options.shell === "string" ? options.shell : "/bin/sh";
42286
42289
  const child = (0, import_child_process.spawn)(shell, ["-c", command], {
42287
42290
  cwd: options.cwd,
@@ -42296,14 +42299,14 @@ function executeCommand(command, options) {
42296
42299
  stderr += data.toString();
42297
42300
  });
42298
42301
  child.on("close", (code) => {
42299
- resolve5({
42302
+ resolve6({
42300
42303
  stdout: stdout.trim(),
42301
42304
  stderr: stderr.trim(),
42302
42305
  status: code ?? 1
42303
42306
  });
42304
42307
  });
42305
42308
  child.on("error", (err) => {
42306
- resolve5({
42309
+ resolve6({
42307
42310
  stdout: "",
42308
42311
  stderr: err.message,
42309
42312
  status: 1
@@ -42692,17 +42695,17 @@ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
42692
42695
  for (const [styleName, style] of Object.entries(ansi_styles_default)) {
42693
42696
  styles2[styleName] = {
42694
42697
  get() {
42695
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
42696
- Object.defineProperty(this, styleName, { value: builder });
42697
- return builder;
42698
+ const builder2 = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
42699
+ Object.defineProperty(this, styleName, { value: builder2 });
42700
+ return builder2;
42698
42701
  }
42699
42702
  };
42700
42703
  }
42701
42704
  styles2.visible = {
42702
42705
  get() {
42703
- const builder = createBuilder(this, this[STYLER], true);
42704
- Object.defineProperty(this, "visible", { value: builder });
42705
- return builder;
42706
+ const builder2 = createBuilder(this, this[STYLER], true);
42707
+ Object.defineProperty(this, "visible", { value: builder2 });
42708
+ return builder2;
42706
42709
  }
42707
42710
  };
42708
42711
  var getModelAnsi = (model, level, type2, ...arguments_) => {
@@ -42774,12 +42777,12 @@ var createStyler = (open3, close, parent) => {
42774
42777
  };
42775
42778
  };
42776
42779
  var createBuilder = (self, _styler, _isEmpty) => {
42777
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
42778
- Object.setPrototypeOf(builder, proto);
42779
- builder[GENERATOR] = self;
42780
- builder[STYLER] = _styler;
42781
- builder[IS_EMPTY] = _isEmpty;
42782
- return builder;
42780
+ const builder2 = (...arguments_) => applyStyle(builder2, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
42781
+ Object.setPrototypeOf(builder2, proto);
42782
+ builder2[GENERATOR] = self;
42783
+ builder2[STYLER] = _styler;
42784
+ builder2[IS_EMPTY] = _isEmpty;
42785
+ return builder2;
42783
42786
  };
42784
42787
  var applyStyle = (self, string) => {
42785
42788
  if (self.level <= 0 || !string) {
@@ -43148,7 +43151,7 @@ function prompt(question, hidden = false) {
43148
43151
  input: process.stdin,
43149
43152
  output: process.stdout
43150
43153
  });
43151
- return new Promise((resolve5) => {
43154
+ return new Promise((resolve6) => {
43152
43155
  if (hidden) {
43153
43156
  process.stdout.write(question);
43154
43157
  let password = "";
@@ -43161,7 +43164,7 @@ function prompt(question, hidden = false) {
43161
43164
  process.stdin.removeListener("data", handler);
43162
43165
  console.log();
43163
43166
  rl.close();
43164
- resolve5(password);
43167
+ resolve6(password);
43165
43168
  } else if (char === "") {
43166
43169
  process.exit();
43167
43170
  } else if (char === "\x7F" || char === "\b") {
@@ -43176,7 +43179,7 @@ function prompt(question, hidden = false) {
43176
43179
  } else {
43177
43180
  rl.question(question, (answer) => {
43178
43181
  rl.close();
43179
- resolve5(answer);
43182
+ resolve6(answer);
43180
43183
  });
43181
43184
  }
43182
43185
  });
@@ -43240,9 +43243,213 @@ async function whoami() {
43240
43243
  console.log(source_default.gray(`API: ${getApiUrl()}`));
43241
43244
  }
43242
43245
 
43246
+ // ../builder/dist/cli/index.js
43247
+ var import_path6 = require("path");
43248
+ var import_url3 = require("url");
43249
+ var import_fs8 = require("fs");
43250
+ var import_express2 = __toESM(require_express2(), 1);
43251
+ var __dirname4 = (0, import_path6.dirname)((0, import_url3.fileURLToPath)(importMetaUrl));
43252
+ function getNetworkUrl2(port) {
43253
+ const { networkInterfaces: networkInterfaces2 } = require("os");
43254
+ const nets = networkInterfaces2();
43255
+ for (const name of Object.keys(nets)) {
43256
+ for (const net of nets[name] || []) {
43257
+ if (net.family === "IPv4" && !net.internal) {
43258
+ return `http://${net.address}:${port}`;
43259
+ }
43260
+ }
43261
+ }
43262
+ return null;
43263
+ }
43264
+ function createRestProxy2() {
43265
+ return async (req, res) => {
43266
+ const { url, method, headers, body } = req.body;
43267
+ if (!url) {
43268
+ return res.status(400).json({ error: "URL is required" });
43269
+ }
43270
+ try {
43271
+ const fetchHeaders = {};
43272
+ if (headers) {
43273
+ Object.assign(fetchHeaders, headers);
43274
+ }
43275
+ if (body && !fetchHeaders["Content-Type"]) {
43276
+ fetchHeaders["Content-Type"] = "application/json";
43277
+ }
43278
+ const response = await fetch(url, {
43279
+ method: method || "GET",
43280
+ headers: fetchHeaders,
43281
+ body: body ? JSON.stringify(body) : void 0
43282
+ });
43283
+ const contentType = response.headers.get("content-type");
43284
+ let data;
43285
+ if (contentType?.includes("application/json")) {
43286
+ data = await response.json();
43287
+ } else {
43288
+ data = await response.text();
43289
+ }
43290
+ res.json({
43291
+ status: response.status,
43292
+ headers: Object.fromEntries(response.headers.entries()),
43293
+ data
43294
+ });
43295
+ } catch (err) {
43296
+ res.status(500).json({
43297
+ error: err instanceof Error ? err.message : "Request failed"
43298
+ });
43299
+ }
43300
+ };
43301
+ }
43302
+ async function builder(options) {
43303
+ const { port, host, open: open3 } = options;
43304
+ console.log(source_default.blue("Starting DemoScript Builder..."));
43305
+ const app = (0, import_express2.default)();
43306
+ app.use(import_express2.default.json());
43307
+ app.post("/api/execute", createRestProxy2());
43308
+ app.get("/api/openapi", async (req, res) => {
43309
+ const url = req.query.url;
43310
+ if (!url) {
43311
+ return res.status(400).json({ error: "url query parameter is required" });
43312
+ }
43313
+ try {
43314
+ const response = await fetch(url);
43315
+ if (!response.ok) {
43316
+ return res.status(response.status).json({ error: `Failed to fetch: ${response.statusText}` });
43317
+ }
43318
+ const spec = await response.json();
43319
+ res.json(spec);
43320
+ } catch (err) {
43321
+ res.status(500).json({ error: err instanceof Error ? err.message : "Failed to fetch OpenAPI spec" });
43322
+ }
43323
+ });
43324
+ const uiSourcePaths = [
43325
+ (0, import_path6.resolve)(__dirname4, "..", "ui"),
43326
+ // packages/cli/dist -> packages/ui (bundled)
43327
+ (0, import_path6.resolve)(__dirname4, "../../../..", "ui"),
43328
+ // packages/builder/dist/cli -> packages/ui
43329
+ (0, import_path6.resolve)(__dirname4, "../../..", "ui")
43330
+ // packages/builder/src/cli -> packages/ui
43331
+ ];
43332
+ const uiDistPaths = [
43333
+ (0, import_path6.resolve)(__dirname4, "ui-dist"),
43334
+ // packages/cli/dist/ui-dist (bundled)
43335
+ (0, import_path6.resolve)(__dirname4, "../../../cli/dist", "ui-dist"),
43336
+ // packages/builder/dist/cli -> cli bundled UI
43337
+ (0, import_path6.resolve)(__dirname4, "../..", "ui-dist")
43338
+ // If builder has its own ui-dist
43339
+ ];
43340
+ const uiSourcePath = uiSourcePaths.find((p) => (0, import_fs8.existsSync)((0, import_path6.resolve)(p, "vite.config.ts"))) || uiSourcePaths[0];
43341
+ const uiDistPath = uiDistPaths.find((p) => (0, import_fs8.existsSync)((0, import_path6.resolve)(p, "index.html"))) || uiDistPaths[0];
43342
+ const useViteDevServer = (0, import_fs8.existsSync)((0, import_path6.resolve)(uiSourcePath, "vite.config.ts"));
43343
+ if (useViteDevServer) {
43344
+ const { createServer: createViteServer } = await import("vite");
43345
+ const vite = await createViteServer({
43346
+ root: uiSourcePath,
43347
+ configFile: (0, import_path6.resolve)(uiSourcePath, "vite.config.ts"),
43348
+ server: {
43349
+ middlewareMode: true,
43350
+ hmr: {
43351
+ port: port + 1,
43352
+ host: host || "localhost"
43353
+ }
43354
+ },
43355
+ appType: "spa"
43356
+ });
43357
+ app.get("/builder", async (_req, res) => {
43358
+ const indexPath = (0, import_path6.resolve)(uiSourcePath, "index.html");
43359
+ let html = (0, import_fs8.readFileSync)(indexPath, "utf-8");
43360
+ html = await vite.transformIndexHtml("/builder", html);
43361
+ html = html.replace("</head>", "<script>window.__DEMOSCRIPT_BUILDER__ = true;</script></head>");
43362
+ res.type("html").send(html);
43363
+ });
43364
+ app.get("/builder-embed", async (_req, res) => {
43365
+ const indexPath = (0, import_path6.resolve)(uiSourcePath, "index.html");
43366
+ let html = (0, import_fs8.readFileSync)(indexPath, "utf-8");
43367
+ html = await vite.transformIndexHtml("/builder-embed", html);
43368
+ html = html.replace("</head>", "<script>window.__DEMOSCRIPT_BUILDER__ = true; window.__DEMOSCRIPT_BUILDER_EMBEDDED__ = true;</script></head>");
43369
+ res.type("html").send(html);
43370
+ });
43371
+ app.get("/editor", async (_req, res) => {
43372
+ const indexPath = (0, import_path6.resolve)(uiSourcePath, "index.html");
43373
+ let html = (0, import_fs8.readFileSync)(indexPath, "utf-8");
43374
+ html = await vite.transformIndexHtml("/editor", html);
43375
+ html = html.replace("</head>", "<script>window.__DEMOSCRIPT_EDITOR__ = true;</script></head>");
43376
+ res.type("html").send(html);
43377
+ });
43378
+ app.get("/editor-embed", async (_req, res) => {
43379
+ const indexPath = (0, import_path6.resolve)(uiSourcePath, "index.html");
43380
+ let html = (0, import_fs8.readFileSync)(indexPath, "utf-8");
43381
+ html = await vite.transformIndexHtml("/editor-embed", html);
43382
+ html = html.replace("</head>", "<script>window.__DEMOSCRIPT_EDITOR__ = true; window.__DEMOSCRIPT_EDITOR_EMBEDDED__ = true;</script></head>");
43383
+ res.type("html").send(html);
43384
+ });
43385
+ app.get("/", (_req, res) => {
43386
+ res.redirect("/editor");
43387
+ });
43388
+ app.use(vite.middlewares);
43389
+ } else if ((0, import_fs8.existsSync)(uiDistPath)) {
43390
+ const indexHtml = (0, import_fs8.readFileSync)((0, import_path6.join)(uiDistPath, "index.html"), "utf-8");
43391
+ const injectedHtml = indexHtml.replace("</head>", `<script>window.__DEMOSCRIPT_BUILDER__ = true;</script></head>`);
43392
+ app.get("/builder", (_req, res) => {
43393
+ res.type("html").send(injectedHtml);
43394
+ });
43395
+ const embeddedHtml = indexHtml.replace("</head>", `<script>window.__DEMOSCRIPT_BUILDER__ = true; window.__DEMOSCRIPT_BUILDER_EMBEDDED__ = true;</script></head>`);
43396
+ app.get("/builder-embed", (_req, res) => {
43397
+ res.type("html").send(embeddedHtml);
43398
+ });
43399
+ const editorHtml = indexHtml.replace("</head>", `<script>window.__DEMOSCRIPT_EDITOR__ = true;</script></head>`);
43400
+ app.get("/editor", (_req, res) => {
43401
+ res.type("html").send(editorHtml);
43402
+ });
43403
+ const editorEmbeddedHtml = indexHtml.replace("</head>", `<script>window.__DEMOSCRIPT_EDITOR__ = true; window.__DEMOSCRIPT_EDITOR_EMBEDDED__ = true;</script></head>`);
43404
+ app.get("/editor-embed", (_req, res) => {
43405
+ res.type("html").send(editorEmbeddedHtml);
43406
+ });
43407
+ app.get("/", (_req, res) => {
43408
+ res.redirect("/editor");
43409
+ });
43410
+ app.use(import_express2.default.static(uiDistPath));
43411
+ } else {
43412
+ console.error(source_default.red("Error: UI files not found. Please rebuild the package."));
43413
+ process.exit(1);
43414
+ }
43415
+ const listenHost = host || "localhost";
43416
+ const server = app.listen(port, listenHost, async () => {
43417
+ console.log();
43418
+ console.log(source_default.green.bold(" DemoScript Builder is running!"));
43419
+ console.log();
43420
+ console.log(` ${source_default.cyan("Editor:")} http://localhost:${port}/editor ${source_default.gray("(new)")}`);
43421
+ console.log(` ${source_default.cyan("Builder:")} http://localhost:${port}/builder ${source_default.gray("(legacy)")}`);
43422
+ if (host === "0.0.0.0") {
43423
+ const networkUrl = getNetworkUrl2(port);
43424
+ if (networkUrl) {
43425
+ console.log(` ${source_default.cyan("Network:")} ${networkUrl}/editor`);
43426
+ }
43427
+ }
43428
+ console.log();
43429
+ console.log(source_default.gray(" Press 'q' to quit"));
43430
+ console.log();
43431
+ if (open3) {
43432
+ Promise.resolve().then(() => (init_open(), open_exports)).then((mod) => mod.default(`http://localhost:${port}/editor`)).catch(() => {
43433
+ });
43434
+ }
43435
+ });
43436
+ process.stdin.setRawMode?.(true);
43437
+ process.stdin.resume();
43438
+ process.stdin.on("data", (data) => {
43439
+ const key = data.toString();
43440
+ if (key === "q" || key === "") {
43441
+ console.log(source_default.gray("\nShutting down..."));
43442
+ server.close();
43443
+ process.exit(0);
43444
+ }
43445
+ });
43446
+ }
43447
+
43243
43448
  // src/index.ts
43449
+ var require2 = (0, import_module.createRequire)(importMetaUrl);
43450
+ var pkg = require2("../package.json");
43244
43451
  var program2 = new Command();
43245
- program2.name("demoscript").description("Framework for creating scripted, shareable product demonstrations").version("1.0.2");
43452
+ program2.name("demoscript").description("Framework for creating scripted, shareable product demonstrations").version(pkg.version);
43246
43453
  program2.command("serve <demo>").description("Start dev server for live demo presentation").option("-p, --port <port>", "Port to run server on", "3000").option("-H, --host [host]", "Host to bind to (use --host for 0.0.0.0)").option("--no-open", "Do not open browser automatically").option("-w, --watch", "Watch demo files for changes and reload").action(async (demo, options) => {
43247
43454
  const host = options.host === true ? "0.0.0.0" : typeof options.host === "string" ? options.host : void 0;
43248
43455
  await serve(demo, { port: parseInt(options.port, 10), host, open: options.open, watch: options.watch });
@@ -43259,6 +43466,10 @@ program2.command("whoami").description("Show current logged in user").action(asy
43259
43466
  program2.command("push <demo>").description("Push demo to DemoScript Cloud").option("-s, --slug <slug>", "Demo slug (default: directory name)").option("-t, --title <title>", "Demo title (default: from YAML)").option("--public", "Make demo public (default)").option("--private", "Make demo private").action(async (demo, options) => {
43260
43467
  await push(demo, options);
43261
43468
  });
43469
+ program2.command("builder").description("Open the visual demo builder").option("-p, --port <port>", "Port to run on", "3002").option("-H, --host [host]", "Host to bind to (use --host for 0.0.0.0)").option("--no-open", "Do not open browser automatically").action(async (options) => {
43470
+ const host = options.host === true ? "0.0.0.0" : typeof options.host === "string" ? options.host : void 0;
43471
+ await builder({ port: parseInt(options.port, 10), host, open: options.open });
43472
+ });
43262
43473
  program2.parse();
43263
43474
  /*! Bundled license information:
43264
43475
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAA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