@telepath-computer/television 1.4.29 → 1.5.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/cli.cjs CHANGED
@@ -1198,8 +1198,8 @@ var require_command = __commonJS({
1198
1198
  "../../node_modules/commander/lib/command.js"(exports2) {
1199
1199
  var EventEmitter2 = require("node:events").EventEmitter;
1200
1200
  var childProcess = require("node:child_process");
1201
- var path23 = require("node:path");
1202
- var fs4 = require("node:fs");
1201
+ var path24 = require("node:path");
1202
+ var fs5 = require("node:fs");
1203
1203
  var process3 = require("node:process");
1204
1204
  var { Argument: Argument2, humanReadableArgName } = require_argument();
1205
1205
  var { CommanderError: CommanderError2 } = require_error();
@@ -2193,7 +2193,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2193
2193
  * @param {string} subcommandName
2194
2194
  */
2195
2195
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
2196
- if (fs4.existsSync(executableFile)) return;
2196
+ if (fs5.existsSync(executableFile)) return;
2197
2197
  const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
2198
2198
  const executableMissing = `'${executableFile}' does not exist
2199
2199
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -2211,11 +2211,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2211
2211
  let launchWithNode = false;
2212
2212
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2213
2213
  function findFile(baseDir, baseName) {
2214
- const localBin = path23.resolve(baseDir, baseName);
2215
- if (fs4.existsSync(localBin)) return localBin;
2216
- if (sourceExt.includes(path23.extname(baseName))) return void 0;
2214
+ const localBin = path24.resolve(baseDir, baseName);
2215
+ if (fs5.existsSync(localBin)) return localBin;
2216
+ if (sourceExt.includes(path24.extname(baseName))) return void 0;
2217
2217
  const foundExt = sourceExt.find(
2218
- (ext) => fs4.existsSync(`${localBin}${ext}`)
2218
+ (ext) => fs5.existsSync(`${localBin}${ext}`)
2219
2219
  );
2220
2220
  if (foundExt) return `${localBin}${foundExt}`;
2221
2221
  return void 0;
@@ -2227,21 +2227,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
2227
2227
  if (this._scriptPath) {
2228
2228
  let resolvedScriptPath;
2229
2229
  try {
2230
- resolvedScriptPath = fs4.realpathSync(this._scriptPath);
2230
+ resolvedScriptPath = fs5.realpathSync(this._scriptPath);
2231
2231
  } catch {
2232
2232
  resolvedScriptPath = this._scriptPath;
2233
2233
  }
2234
- executableDir = path23.resolve(
2235
- path23.dirname(resolvedScriptPath),
2234
+ executableDir = path24.resolve(
2235
+ path24.dirname(resolvedScriptPath),
2236
2236
  executableDir
2237
2237
  );
2238
2238
  }
2239
2239
  if (executableDir) {
2240
2240
  let localFile = findFile(executableDir, executableFile);
2241
2241
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2242
- const legacyName = path23.basename(
2242
+ const legacyName = path24.basename(
2243
2243
  this._scriptPath,
2244
- path23.extname(this._scriptPath)
2244
+ path24.extname(this._scriptPath)
2245
2245
  );
2246
2246
  if (legacyName !== this._name) {
2247
2247
  localFile = findFile(
@@ -2252,7 +2252,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2252
2252
  }
2253
2253
  executableFile = localFile || executableFile;
2254
2254
  }
2255
- launchWithNode = sourceExt.includes(path23.extname(executableFile));
2255
+ launchWithNode = sourceExt.includes(path24.extname(executableFile));
2256
2256
  let proc;
2257
2257
  if (process3.platform !== "win32") {
2258
2258
  if (launchWithNode) {
@@ -3167,7 +3167,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3167
3167
  * @return {Command}
3168
3168
  */
3169
3169
  nameFromFilename(filename) {
3170
- this._name = path23.basename(filename, path23.extname(filename));
3170
+ this._name = path24.basename(filename, path24.extname(filename));
3171
3171
  return this;
3172
3172
  }
3173
3173
  /**
@@ -3181,9 +3181,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3181
3181
  * @param {string} [path]
3182
3182
  * @return {(string|null|Command)}
3183
3183
  */
3184
- executableDir(path24) {
3185
- if (path24 === void 0) return this._executableDir;
3186
- this._executableDir = path24;
3184
+ executableDir(path25) {
3185
+ if (path25 === void 0) return this._executableDir;
3186
+ this._executableDir = path25;
3187
3187
  return this;
3188
3188
  }
3189
3189
  /**
@@ -8696,8 +8696,8 @@ var require_node = __commonJS({
8696
8696
  }
8697
8697
  break;
8698
8698
  case "FILE":
8699
- var fs4 = require("fs");
8700
- stream2 = new fs4.SyncWriteStream(fd2, { autoClose: false });
8699
+ var fs5 = require("fs");
8700
+ stream2 = new fs5.SyncWriteStream(fd2, { autoClose: false });
8701
8701
  stream2._type = "fs";
8702
8702
  break;
8703
8703
  case "PIPE":
@@ -21484,11 +21484,11 @@ var require_mime_types = __commonJS({
21484
21484
  }
21485
21485
  return exts[0];
21486
21486
  }
21487
- function lookup(path23) {
21488
- if (!path23 || typeof path23 !== "string") {
21487
+ function lookup(path24) {
21488
+ if (!path24 || typeof path24 !== "string") {
21489
21489
  return false;
21490
21490
  }
21491
- var extension3 = extname("x." + path23).toLowerCase().substr(1);
21491
+ var extension3 = extname("x." + path24).toLowerCase().substr(1);
21492
21492
  if (!extension3) {
21493
21493
  return false;
21494
21494
  }
@@ -23515,8 +23515,8 @@ var require_node2 = __commonJS({
23515
23515
  }
23516
23516
  break;
23517
23517
  case "FILE":
23518
- var fs4 = require("fs");
23519
- stream2 = new fs4.SyncWriteStream(fd2, { autoClose: false });
23518
+ var fs5 = require("fs");
23519
+ stream2 = new fs5.SyncWriteStream(fd2, { autoClose: false });
23520
23520
  stream2._type = "fs";
23521
23521
  break;
23522
23522
  case "PIPE":
@@ -24234,8 +24234,8 @@ var require_node3 = __commonJS({
24234
24234
  }
24235
24235
  break;
24236
24236
  case "FILE":
24237
- var fs4 = require("fs");
24238
- stream2 = new fs4.SyncWriteStream(fd2, { autoClose: false });
24237
+ var fs5 = require("fs");
24238
+ stream2 = new fs5.SyncWriteStream(fd2, { autoClose: false });
24239
24239
  stream2._type = "fs";
24240
24240
  break;
24241
24241
  case "PIPE":
@@ -24323,7 +24323,7 @@ var require_path_to_regexp = __commonJS({
24323
24323
  "../../node_modules/path-to-regexp/index.js"(exports2, module2) {
24324
24324
  module2.exports = pathToRegexp;
24325
24325
  var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
24326
- function pathToRegexp(path23, keys, options) {
24326
+ function pathToRegexp(path24, keys, options) {
24327
24327
  options = options || {};
24328
24328
  keys = keys || [];
24329
24329
  var strict = options.strict;
@@ -24337,8 +24337,8 @@ var require_path_to_regexp = __commonJS({
24337
24337
  var pos = 0;
24338
24338
  var backtrack = "";
24339
24339
  var m2;
24340
- if (path23 instanceof RegExp) {
24341
- while (m2 = MATCHING_GROUP_REGEXP.exec(path23.source)) {
24340
+ if (path24 instanceof RegExp) {
24341
+ while (m2 = MATCHING_GROUP_REGEXP.exec(path24.source)) {
24342
24342
  if (m2[0][0] === "\\") continue;
24343
24343
  keys.push({
24344
24344
  name: m2[1] || name++,
@@ -24346,18 +24346,18 @@ var require_path_to_regexp = __commonJS({
24346
24346
  offset: m2.index
24347
24347
  });
24348
24348
  }
24349
- return path23;
24349
+ return path24;
24350
24350
  }
24351
- if (Array.isArray(path23)) {
24352
- path23 = path23.map(function(value) {
24351
+ if (Array.isArray(path24)) {
24352
+ path24 = path24.map(function(value) {
24353
24353
  return pathToRegexp(value, keys, options).source;
24354
24354
  });
24355
- return new RegExp(path23.join("|"), flags);
24355
+ return new RegExp(path24.join("|"), flags);
24356
24356
  }
24357
- if (typeof path23 !== "string") {
24357
+ if (typeof path24 !== "string") {
24358
24358
  throw new TypeError("path must be a string, array of strings, or regular expression");
24359
24359
  }
24360
- path23 = path23.replace(
24360
+ path24 = path24.replace(
24361
24361
  /\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,
24362
24362
  function(match, slash, format, key, capture2, star, optional2, offset) {
24363
24363
  if (match[0] === "\\") {
@@ -24374,7 +24374,7 @@ var require_path_to_regexp = __commonJS({
24374
24374
  if (slash || format) {
24375
24375
  backtrack = "";
24376
24376
  } else {
24377
- backtrack += path23.slice(pos, offset);
24377
+ backtrack += path24.slice(pos, offset);
24378
24378
  }
24379
24379
  pos = offset + match.length;
24380
24380
  if (match === "*") {
@@ -24404,7 +24404,7 @@ var require_path_to_regexp = __commonJS({
24404
24404
  return result;
24405
24405
  }
24406
24406
  );
24407
- while (m2 = MATCHING_GROUP_REGEXP.exec(path23)) {
24407
+ while (m2 = MATCHING_GROUP_REGEXP.exec(path24)) {
24408
24408
  if (m2[0][0] === "\\") continue;
24409
24409
  if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m2.index) {
24410
24410
  keys.splice(keysOffset + i, 0, {
@@ -24416,13 +24416,13 @@ var require_path_to_regexp = __commonJS({
24416
24416
  }
24417
24417
  i++;
24418
24418
  }
24419
- path23 += strict ? "" : path23[path23.length - 1] === "/" ? "?" : "/?";
24419
+ path24 += strict ? "" : path24[path24.length - 1] === "/" ? "?" : "/?";
24420
24420
  if (end) {
24421
- path23 += "$";
24422
- } else if (path23[path23.length - 1] !== "/") {
24423
- path23 += lookahead ? "(?=/|$)" : "(?:/|$)";
24421
+ path24 += "$";
24422
+ } else if (path24[path24.length - 1] !== "/") {
24423
+ path24 += lookahead ? "(?=/|$)" : "(?:/|$)";
24424
24424
  }
24425
- return new RegExp("^" + path23, flags);
24425
+ return new RegExp("^" + path24, flags);
24426
24426
  }
24427
24427
  }
24428
24428
  });
@@ -24435,19 +24435,19 @@ var require_layer = __commonJS({
24435
24435
  var debug = require_src3()("express:router:layer");
24436
24436
  var hasOwnProperty = Object.prototype.hasOwnProperty;
24437
24437
  module2.exports = Layer;
24438
- function Layer(path23, options, fn) {
24438
+ function Layer(path24, options, fn) {
24439
24439
  if (!(this instanceof Layer)) {
24440
- return new Layer(path23, options, fn);
24440
+ return new Layer(path24, options, fn);
24441
24441
  }
24442
- debug("new %o", path23);
24442
+ debug("new %o", path24);
24443
24443
  var opts = options || {};
24444
24444
  this.handle = fn;
24445
24445
  this.name = fn.name || "<anonymous>";
24446
24446
  this.params = void 0;
24447
24447
  this.path = void 0;
24448
- this.regexp = pathRegexp(path23, this.keys = [], opts);
24449
- this.regexp.fast_star = path23 === "*";
24450
- this.regexp.fast_slash = path23 === "/" && opts.end === false;
24448
+ this.regexp = pathRegexp(path24, this.keys = [], opts);
24449
+ this.regexp.fast_star = path24 === "*";
24450
+ this.regexp.fast_slash = path24 === "/" && opts.end === false;
24451
24451
  }
24452
24452
  Layer.prototype.handle_error = function handle_error(error48, req, res, next) {
24453
24453
  var fn = this.handle;
@@ -24471,20 +24471,20 @@ var require_layer = __commonJS({
24471
24471
  next(err);
24472
24472
  }
24473
24473
  };
24474
- Layer.prototype.match = function match(path23) {
24474
+ Layer.prototype.match = function match(path24) {
24475
24475
  var match2;
24476
- if (path23 != null) {
24476
+ if (path24 != null) {
24477
24477
  if (this.regexp.fast_slash) {
24478
24478
  this.params = {};
24479
24479
  this.path = "";
24480
24480
  return true;
24481
24481
  }
24482
24482
  if (this.regexp.fast_star) {
24483
- this.params = { "0": decode_param(path23) };
24484
- this.path = path23;
24483
+ this.params = { "0": decode_param(path24) };
24484
+ this.path = path24;
24485
24485
  return true;
24486
24486
  }
24487
- match2 = this.regexp.exec(path23);
24487
+ match2 = this.regexp.exec(path24);
24488
24488
  }
24489
24489
  if (!match2) {
24490
24490
  this.params = void 0;
@@ -24577,10 +24577,10 @@ var require_route = __commonJS({
24577
24577
  var slice = Array.prototype.slice;
24578
24578
  var toString = Object.prototype.toString;
24579
24579
  module2.exports = Route;
24580
- function Route(path23) {
24581
- this.path = path23;
24580
+ function Route(path24) {
24581
+ this.path = path24;
24582
24582
  this.stack = [];
24583
- debug("new %o", path23);
24583
+ debug("new %o", path24);
24584
24584
  this.methods = {};
24585
24585
  }
24586
24586
  Route.prototype._handles_method = function _handles_method(method) {
@@ -24792,8 +24792,8 @@ var require_router = __commonJS({
24792
24792
  if (++sync > 100) {
24793
24793
  return setImmediate(next, err);
24794
24794
  }
24795
- var path23 = getPathname(req);
24796
- if (path23 == null) {
24795
+ var path24 = getPathname(req);
24796
+ if (path24 == null) {
24797
24797
  return done(layerError);
24798
24798
  }
24799
24799
  var layer;
@@ -24801,7 +24801,7 @@ var require_router = __commonJS({
24801
24801
  var route;
24802
24802
  while (match !== true && idx < stack.length) {
24803
24803
  layer = stack[idx++];
24804
- match = matchLayer(layer, path23);
24804
+ match = matchLayer(layer, path24);
24805
24805
  route = layer.route;
24806
24806
  if (typeof match !== "boolean") {
24807
24807
  layerError = layerError || match;
@@ -24839,18 +24839,18 @@ var require_router = __commonJS({
24839
24839
  } else if (route) {
24840
24840
  layer.handle_request(req, res, next);
24841
24841
  } else {
24842
- trim_prefix(layer, layerError, layerPath, path23);
24842
+ trim_prefix(layer, layerError, layerPath, path24);
24843
24843
  }
24844
24844
  sync = 0;
24845
24845
  });
24846
24846
  }
24847
- function trim_prefix(layer, layerError, layerPath, path23) {
24847
+ function trim_prefix(layer, layerError, layerPath, path24) {
24848
24848
  if (layerPath.length !== 0) {
24849
- if (layerPath !== path23.slice(0, layerPath.length)) {
24849
+ if (layerPath !== path24.slice(0, layerPath.length)) {
24850
24850
  next(layerError);
24851
24851
  return;
24852
24852
  }
24853
- var c = path23[layerPath.length];
24853
+ var c = path24[layerPath.length];
24854
24854
  if (c && c !== "/" && c !== ".") return next(layerError);
24855
24855
  debug("trim prefix (%s) from url %s", layerPath, req.url);
24856
24856
  removed = layerPath;
@@ -24928,7 +24928,7 @@ var require_router = __commonJS({
24928
24928
  };
24929
24929
  proto.use = function use(fn) {
24930
24930
  var offset = 0;
24931
- var path23 = "/";
24931
+ var path24 = "/";
24932
24932
  if (typeof fn !== "function") {
24933
24933
  var arg = fn;
24934
24934
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -24936,7 +24936,7 @@ var require_router = __commonJS({
24936
24936
  }
24937
24937
  if (typeof arg !== "function") {
24938
24938
  offset = 1;
24939
- path23 = fn;
24939
+ path24 = fn;
24940
24940
  }
24941
24941
  }
24942
24942
  var callbacks = flatten(slice.call(arguments, offset));
@@ -24948,8 +24948,8 @@ var require_router = __commonJS({
24948
24948
  if (typeof fn !== "function") {
24949
24949
  throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
24950
24950
  }
24951
- debug("use %o %s", path23, fn.name || "<anonymous>");
24952
- var layer = new Layer(path23, {
24951
+ debug("use %o %s", path24, fn.name || "<anonymous>");
24952
+ var layer = new Layer(path24, {
24953
24953
  sensitive: this.caseSensitive,
24954
24954
  strict: false,
24955
24955
  end: false
@@ -24959,9 +24959,9 @@ var require_router = __commonJS({
24959
24959
  }
24960
24960
  return this;
24961
24961
  };
24962
- proto.route = function route(path23) {
24963
- var route2 = new Route(path23);
24964
- var layer = new Layer(path23, {
24962
+ proto.route = function route(path24) {
24963
+ var route2 = new Route(path24);
24964
+ var layer = new Layer(path24, {
24965
24965
  sensitive: this.caseSensitive,
24966
24966
  strict: this.strict,
24967
24967
  end: true
@@ -24971,8 +24971,8 @@ var require_router = __commonJS({
24971
24971
  return route2;
24972
24972
  };
24973
24973
  methods.concat("all").forEach(function(method) {
24974
- proto[method] = function(path23) {
24975
- var route = this.route(path23);
24974
+ proto[method] = function(path24) {
24975
+ var route = this.route(path24);
24976
24976
  route[method].apply(route, slice.call(arguments, 1));
24977
24977
  return this;
24978
24978
  };
@@ -25008,9 +25008,9 @@ var require_router = __commonJS({
25008
25008
  }
25009
25009
  return toString.call(obj).replace(objectRegExp, "$1");
25010
25010
  }
25011
- function matchLayer(layer, path23) {
25011
+ function matchLayer(layer, path24) {
25012
25012
  try {
25013
- return layer.match(path23);
25013
+ return layer.match(path24);
25014
25014
  } catch (err) {
25015
25015
  return err;
25016
25016
  }
@@ -25128,13 +25128,13 @@ var require_view = __commonJS({
25128
25128
  "../../node_modules/express/lib/view.js"(exports2, module2) {
25129
25129
  "use strict";
25130
25130
  var debug = require_src3()("express:view");
25131
- var path23 = require("path");
25132
- var fs4 = require("fs");
25133
- var dirname = path23.dirname;
25134
- var basename = path23.basename;
25135
- var extname = path23.extname;
25136
- var join2 = path23.join;
25137
- var resolve = path23.resolve;
25131
+ var path24 = require("path");
25132
+ var fs5 = require("fs");
25133
+ var dirname = path24.dirname;
25134
+ var basename = path24.basename;
25135
+ var extname = path24.extname;
25136
+ var join2 = path24.join;
25137
+ var resolve = path24.resolve;
25138
25138
  module2.exports = View;
25139
25139
  function View(name, options) {
25140
25140
  var opts = options || {};
@@ -25163,17 +25163,17 @@ var require_view = __commonJS({
25163
25163
  this.path = this.lookup(fileName);
25164
25164
  }
25165
25165
  View.prototype.lookup = function lookup(name) {
25166
- var path24;
25166
+ var path25;
25167
25167
  var roots = [].concat(this.root);
25168
25168
  debug('lookup "%s"', name);
25169
- for (var i = 0; i < roots.length && !path24; i++) {
25169
+ for (var i = 0; i < roots.length && !path25; i++) {
25170
25170
  var root = roots[i];
25171
25171
  var loc = resolve(root, name);
25172
25172
  var dir = dirname(loc);
25173
25173
  var file2 = basename(loc);
25174
- path24 = this.resolve(dir, file2);
25174
+ path25 = this.resolve(dir, file2);
25175
25175
  }
25176
- return path24;
25176
+ return path25;
25177
25177
  };
25178
25178
  View.prototype.render = function render(options, callback) {
25179
25179
  debug('render "%s"', this.path);
@@ -25181,21 +25181,21 @@ var require_view = __commonJS({
25181
25181
  };
25182
25182
  View.prototype.resolve = function resolve2(dir, file2) {
25183
25183
  var ext = this.ext;
25184
- var path24 = join2(dir, file2);
25185
- var stat = tryStat(path24);
25184
+ var path25 = join2(dir, file2);
25185
+ var stat = tryStat(path25);
25186
25186
  if (stat && stat.isFile()) {
25187
- return path24;
25187
+ return path25;
25188
25188
  }
25189
- path24 = join2(dir, basename(file2, ext), "index" + ext);
25190
- stat = tryStat(path24);
25189
+ path25 = join2(dir, basename(file2, ext), "index" + ext);
25190
+ stat = tryStat(path25);
25191
25191
  if (stat && stat.isFile()) {
25192
- return path24;
25192
+ return path25;
25193
25193
  }
25194
25194
  };
25195
- function tryStat(path24) {
25196
- debug('stat "%s"', path24);
25195
+ function tryStat(path25) {
25196
+ debug('stat "%s"', path25);
25197
25197
  try {
25198
- return fs4.statSync(path24);
25198
+ return fs5.statSync(path25);
25199
25199
  } catch (e) {
25200
25200
  return void 0;
25201
25201
  }
@@ -25800,8 +25800,8 @@ var require_node4 = __commonJS({
25800
25800
  }
25801
25801
  break;
25802
25802
  case "FILE":
25803
- var fs4 = require("fs");
25804
- stream2 = new fs4.SyncWriteStream(fd2, { autoClose: false });
25803
+ var fs5 = require("fs");
25804
+ stream2 = new fs5.SyncWriteStream(fd2, { autoClose: false });
25805
25805
  stream2._type = "fs";
25806
25806
  break;
25807
25807
  case "PIPE":
@@ -25973,8 +25973,8 @@ var require_types = __commonJS({
25973
25973
  // ../../node_modules/mime/mime.js
25974
25974
  var require_mime = __commonJS({
25975
25975
  "../../node_modules/mime/mime.js"(exports2, module2) {
25976
- var path23 = require("path");
25977
- var fs4 = require("fs");
25976
+ var path24 = require("path");
25977
+ var fs5 = require("fs");
25978
25978
  function Mime() {
25979
25979
  this.types = /* @__PURE__ */ Object.create(null);
25980
25980
  this.extensions = /* @__PURE__ */ Object.create(null);
@@ -25995,7 +25995,7 @@ var require_mime = __commonJS({
25995
25995
  };
25996
25996
  Mime.prototype.load = function(file2) {
25997
25997
  this._loading = file2;
25998
- var map2 = {}, content = fs4.readFileSync(file2, "ascii"), lines = content.split(/[\r\n]+/);
25998
+ var map2 = {}, content = fs5.readFileSync(file2, "ascii"), lines = content.split(/[\r\n]+/);
25999
25999
  lines.forEach(function(line) {
26000
26000
  var fields = line.replace(/\s*#.*|^\s*|\s*$/g, "").split(/\s+/);
26001
26001
  map2[fields.shift()] = fields;
@@ -26003,8 +26003,8 @@ var require_mime = __commonJS({
26003
26003
  this.define(map2);
26004
26004
  this._loading = null;
26005
26005
  };
26006
- Mime.prototype.lookup = function(path24, fallback) {
26007
- var ext = path24.replace(/^.*[\.\/\\]/, "").toLowerCase();
26006
+ Mime.prototype.lookup = function(path25, fallback) {
26007
+ var ext = path25.replace(/^.*[\.\/\\]/, "").toLowerCase();
26008
26008
  return this.types[ext] || fallback || this.default_type;
26009
26009
  };
26010
26010
  Mime.prototype.extension = function(mimeType) {
@@ -26233,33 +26233,33 @@ var require_send = __commonJS({
26233
26233
  var escapeHtml = require_escape_html();
26234
26234
  var etag = require_etag();
26235
26235
  var fresh = require_fresh();
26236
- var fs4 = require("fs");
26236
+ var fs5 = require("fs");
26237
26237
  var mime = require_mime();
26238
26238
  var ms = require_ms5();
26239
26239
  var onFinished = require_on_finished();
26240
26240
  var parseRange = require_range_parser();
26241
- var path23 = require("path");
26241
+ var path24 = require("path");
26242
26242
  var statuses = require_statuses();
26243
26243
  var Stream = require("stream");
26244
26244
  var util = require("util");
26245
- var extname = path23.extname;
26246
- var join2 = path23.join;
26247
- var normalize = path23.normalize;
26248
- var resolve = path23.resolve;
26249
- var sep = path23.sep;
26245
+ var extname = path24.extname;
26246
+ var join2 = path24.join;
26247
+ var normalize = path24.normalize;
26248
+ var resolve = path24.resolve;
26249
+ var sep = path24.sep;
26250
26250
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
26251
26251
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
26252
26252
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
26253
26253
  module2.exports = send2;
26254
26254
  module2.exports.mime = mime;
26255
- function send2(req, path24, options) {
26256
- return new SendStream(req, path24, options);
26255
+ function send2(req, path25, options) {
26256
+ return new SendStream(req, path25, options);
26257
26257
  }
26258
- function SendStream(req, path24, options) {
26258
+ function SendStream(req, path25, options) {
26259
26259
  Stream.call(this);
26260
26260
  var opts = options || {};
26261
26261
  this.options = opts;
26262
- this.path = path24;
26262
+ this.path = path25;
26263
26263
  this.req = req;
26264
26264
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
26265
26265
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -26305,8 +26305,8 @@ var require_send = __commonJS({
26305
26305
  this._index = index2;
26306
26306
  return this;
26307
26307
  }, "send.index: pass index as option");
26308
- SendStream.prototype.root = function root(path24) {
26309
- this._root = resolve(String(path24));
26308
+ SendStream.prototype.root = function root(path25) {
26309
+ this._root = resolve(String(path25));
26310
26310
  debug("root %s", this._root);
26311
26311
  return this;
26312
26312
  };
@@ -26419,10 +26419,10 @@ var require_send = __commonJS({
26419
26419
  var lastModified = this.res.getHeader("Last-Modified");
26420
26420
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
26421
26421
  };
26422
- SendStream.prototype.redirect = function redirect(path24) {
26422
+ SendStream.prototype.redirect = function redirect(path25) {
26423
26423
  var res = this.res;
26424
26424
  if (hasListeners(this, "directory")) {
26425
- this.emit("directory", res, path24);
26425
+ this.emit("directory", res, path25);
26426
26426
  return;
26427
26427
  }
26428
26428
  if (this.hasTrailingSlash()) {
@@ -26442,42 +26442,42 @@ var require_send = __commonJS({
26442
26442
  SendStream.prototype.pipe = function pipe2(res) {
26443
26443
  var root = this._root;
26444
26444
  this.res = res;
26445
- var path24 = decode3(this.path);
26446
- if (path24 === -1) {
26445
+ var path25 = decode3(this.path);
26446
+ if (path25 === -1) {
26447
26447
  this.error(400);
26448
26448
  return res;
26449
26449
  }
26450
- if (~path24.indexOf("\0")) {
26450
+ if (~path25.indexOf("\0")) {
26451
26451
  this.error(400);
26452
26452
  return res;
26453
26453
  }
26454
26454
  var parts;
26455
26455
  if (root !== null) {
26456
- if (path24) {
26457
- path24 = normalize("." + sep + path24);
26456
+ if (path25) {
26457
+ path25 = normalize("." + sep + path25);
26458
26458
  }
26459
- if (UP_PATH_REGEXP.test(path24)) {
26460
- debug('malicious path "%s"', path24);
26459
+ if (UP_PATH_REGEXP.test(path25)) {
26460
+ debug('malicious path "%s"', path25);
26461
26461
  this.error(403);
26462
26462
  return res;
26463
26463
  }
26464
- parts = path24.split(sep);
26465
- path24 = normalize(join2(root, path24));
26464
+ parts = path25.split(sep);
26465
+ path25 = normalize(join2(root, path25));
26466
26466
  } else {
26467
- if (UP_PATH_REGEXP.test(path24)) {
26468
- debug('malicious path "%s"', path24);
26467
+ if (UP_PATH_REGEXP.test(path25)) {
26468
+ debug('malicious path "%s"', path25);
26469
26469
  this.error(403);
26470
26470
  return res;
26471
26471
  }
26472
- parts = normalize(path24).split(sep);
26473
- path24 = resolve(path24);
26472
+ parts = normalize(path25).split(sep);
26473
+ path25 = resolve(path25);
26474
26474
  }
26475
26475
  if (containsDotFile(parts)) {
26476
26476
  var access2 = this._dotfiles;
26477
26477
  if (access2 === void 0) {
26478
26478
  access2 = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
26479
26479
  }
26480
- debug('%s dotfile "%s"', access2, path24);
26480
+ debug('%s dotfile "%s"', access2, path25);
26481
26481
  switch (access2) {
26482
26482
  case "allow":
26483
26483
  break;
@@ -26491,13 +26491,13 @@ var require_send = __commonJS({
26491
26491
  }
26492
26492
  }
26493
26493
  if (this._index.length && this.hasTrailingSlash()) {
26494
- this.sendIndex(path24);
26494
+ this.sendIndex(path25);
26495
26495
  return res;
26496
26496
  }
26497
- this.sendFile(path24);
26497
+ this.sendFile(path25);
26498
26498
  return res;
26499
26499
  };
26500
- SendStream.prototype.send = function send3(path24, stat) {
26500
+ SendStream.prototype.send = function send3(path25, stat) {
26501
26501
  var len = stat.size;
26502
26502
  var options = this.options;
26503
26503
  var opts = {};
@@ -26509,9 +26509,9 @@ var require_send = __commonJS({
26509
26509
  this.headersAlreadySent();
26510
26510
  return;
26511
26511
  }
26512
- debug('pipe "%s"', path24);
26513
- this.setHeader(path24, stat);
26514
- this.type(path24);
26512
+ debug('pipe "%s"', path25);
26513
+ this.setHeader(path25, stat);
26514
+ this.type(path25);
26515
26515
  if (this.isConditionalGET()) {
26516
26516
  if (this.isPreconditionFailure()) {
26517
26517
  this.error(412);
@@ -26560,28 +26560,28 @@ var require_send = __commonJS({
26560
26560
  res.end();
26561
26561
  return;
26562
26562
  }
26563
- this.stream(path24, opts);
26563
+ this.stream(path25, opts);
26564
26564
  };
26565
- SendStream.prototype.sendFile = function sendFile(path24) {
26565
+ SendStream.prototype.sendFile = function sendFile(path25) {
26566
26566
  var i = 0;
26567
26567
  var self2 = this;
26568
- debug('stat "%s"', path24);
26569
- fs4.stat(path24, function onstat(err, stat) {
26570
- if (err && err.code === "ENOENT" && !extname(path24) && path24[path24.length - 1] !== sep) {
26568
+ debug('stat "%s"', path25);
26569
+ fs5.stat(path25, function onstat(err, stat) {
26570
+ if (err && err.code === "ENOENT" && !extname(path25) && path25[path25.length - 1] !== sep) {
26571
26571
  return next(err);
26572
26572
  }
26573
26573
  if (err) return self2.onStatError(err);
26574
- if (stat.isDirectory()) return self2.redirect(path24);
26575
- self2.emit("file", path24, stat);
26576
- self2.send(path24, stat);
26574
+ if (stat.isDirectory()) return self2.redirect(path25);
26575
+ self2.emit("file", path25, stat);
26576
+ self2.send(path25, stat);
26577
26577
  });
26578
26578
  function next(err) {
26579
26579
  if (self2._extensions.length <= i) {
26580
26580
  return err ? self2.onStatError(err) : self2.error(404);
26581
26581
  }
26582
- var p = path24 + "." + self2._extensions[i++];
26582
+ var p = path25 + "." + self2._extensions[i++];
26583
26583
  debug('stat "%s"', p);
26584
- fs4.stat(p, function(err2, stat) {
26584
+ fs5.stat(p, function(err2, stat) {
26585
26585
  if (err2) return next(err2);
26586
26586
  if (stat.isDirectory()) return next();
26587
26587
  self2.emit("file", p, stat);
@@ -26589,7 +26589,7 @@ var require_send = __commonJS({
26589
26589
  });
26590
26590
  }
26591
26591
  };
26592
- SendStream.prototype.sendIndex = function sendIndex(path24) {
26592
+ SendStream.prototype.sendIndex = function sendIndex(path25) {
26593
26593
  var i = -1;
26594
26594
  var self2 = this;
26595
26595
  function next(err) {
@@ -26597,9 +26597,9 @@ var require_send = __commonJS({
26597
26597
  if (err) return self2.onStatError(err);
26598
26598
  return self2.error(404);
26599
26599
  }
26600
- var p = join2(path24, self2._index[i]);
26600
+ var p = join2(path25, self2._index[i]);
26601
26601
  debug('stat "%s"', p);
26602
- fs4.stat(p, function(err2, stat) {
26602
+ fs5.stat(p, function(err2, stat) {
26603
26603
  if (err2) return next(err2);
26604
26604
  if (stat.isDirectory()) return next();
26605
26605
  self2.emit("file", p, stat);
@@ -26608,10 +26608,10 @@ var require_send = __commonJS({
26608
26608
  }
26609
26609
  next();
26610
26610
  };
26611
- SendStream.prototype.stream = function stream(path24, options) {
26611
+ SendStream.prototype.stream = function stream(path25, options) {
26612
26612
  var self2 = this;
26613
26613
  var res = this.res;
26614
- var stream2 = fs4.createReadStream(path24, options);
26614
+ var stream2 = fs5.createReadStream(path25, options);
26615
26615
  this.emit("stream", stream2);
26616
26616
  stream2.pipe(res);
26617
26617
  function cleanup() {
@@ -26626,10 +26626,10 @@ var require_send = __commonJS({
26626
26626
  self2.emit("end");
26627
26627
  });
26628
26628
  };
26629
- SendStream.prototype.type = function type(path24) {
26629
+ SendStream.prototype.type = function type(path25) {
26630
26630
  var res = this.res;
26631
26631
  if (res.getHeader("Content-Type")) return;
26632
- var type2 = mime.lookup(path24);
26632
+ var type2 = mime.lookup(path25);
26633
26633
  if (!type2) {
26634
26634
  debug("no content-type");
26635
26635
  return;
@@ -26638,9 +26638,9 @@ var require_send = __commonJS({
26638
26638
  debug("content-type %s", type2);
26639
26639
  res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
26640
26640
  };
26641
- SendStream.prototype.setHeader = function setHeader(path24, stat) {
26641
+ SendStream.prototype.setHeader = function setHeader(path25, stat) {
26642
26642
  var res = this.res;
26643
- this.emit("headers", res, path24, stat);
26643
+ this.emit("headers", res, path25, stat);
26644
26644
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
26645
26645
  debug("accept ranges");
26646
26646
  res.setHeader("Accept-Ranges", "bytes");
@@ -26699,9 +26699,9 @@ var require_send = __commonJS({
26699
26699
  }
26700
26700
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
26701
26701
  }
26702
- function decode3(path24) {
26702
+ function decode3(path25) {
26703
26703
  try {
26704
- return decodeURIComponent(path24);
26704
+ return decodeURIComponent(path25);
26705
26705
  } catch (err) {
26706
26706
  return -1;
26707
26707
  }
@@ -27610,10 +27610,10 @@ var require_utils2 = __commonJS({
27610
27610
  var querystring = require("querystring");
27611
27611
  exports2.etag = createETagGenerator({ weak: false });
27612
27612
  exports2.wetag = createETagGenerator({ weak: true });
27613
- exports2.isAbsolute = function(path23) {
27614
- if ("/" === path23[0]) return true;
27615
- if (":" === path23[1] && ("\\" === path23[2] || "/" === path23[2])) return true;
27616
- if ("\\\\" === path23.substring(0, 2)) return true;
27613
+ exports2.isAbsolute = function(path24) {
27614
+ if ("/" === path24[0]) return true;
27615
+ if (":" === path24[1] && ("\\" === path24[2] || "/" === path24[2])) return true;
27616
+ if ("\\\\" === path24.substring(0, 2)) return true;
27617
27617
  };
27618
27618
  exports2.flatten = deprecate.function(
27619
27619
  flatten,
@@ -27825,7 +27825,7 @@ var require_application = __commonJS({
27825
27825
  };
27826
27826
  app.use = function use(fn) {
27827
27827
  var offset = 0;
27828
- var path23 = "/";
27828
+ var path24 = "/";
27829
27829
  if (typeof fn !== "function") {
27830
27830
  var arg = fn;
27831
27831
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -27833,7 +27833,7 @@ var require_application = __commonJS({
27833
27833
  }
27834
27834
  if (typeof arg !== "function") {
27835
27835
  offset = 1;
27836
- path23 = fn;
27836
+ path24 = fn;
27837
27837
  }
27838
27838
  }
27839
27839
  var fns = flatten(slice.call(arguments, offset));
@@ -27844,12 +27844,12 @@ var require_application = __commonJS({
27844
27844
  var router = this._router;
27845
27845
  fns.forEach(function(fn2) {
27846
27846
  if (!fn2 || !fn2.handle || !fn2.set) {
27847
- return router.use(path23, fn2);
27847
+ return router.use(path24, fn2);
27848
27848
  }
27849
- debug(".use app under %s", path23);
27850
- fn2.mountpath = path23;
27849
+ debug(".use app under %s", path24);
27850
+ fn2.mountpath = path24;
27851
27851
  fn2.parent = this;
27852
- router.use(path23, function mounted_app(req, res, next) {
27852
+ router.use(path24, function mounted_app(req, res, next) {
27853
27853
  var orig = req.app;
27854
27854
  fn2.handle(req, res, function(err) {
27855
27855
  setPrototypeOf(req, orig.request);
@@ -27861,9 +27861,9 @@ var require_application = __commonJS({
27861
27861
  }, this);
27862
27862
  return this;
27863
27863
  };
27864
- app.route = function route(path23) {
27864
+ app.route = function route(path24) {
27865
27865
  this.lazyrouter();
27866
- return this._router.route(path23);
27866
+ return this._router.route(path24);
27867
27867
  };
27868
27868
  app.engine = function engine(ext, fn) {
27869
27869
  if (typeof fn !== "function") {
@@ -27914,7 +27914,7 @@ var require_application = __commonJS({
27914
27914
  }
27915
27915
  return this;
27916
27916
  };
27917
- app.path = function path23() {
27917
+ app.path = function path24() {
27918
27918
  return this.parent ? this.parent.path() + this.mountpath : "";
27919
27919
  };
27920
27920
  app.enabled = function enabled(setting) {
@@ -27930,19 +27930,19 @@ var require_application = __commonJS({
27930
27930
  return this.set(setting, false);
27931
27931
  };
27932
27932
  methods.forEach(function(method) {
27933
- app[method] = function(path23) {
27933
+ app[method] = function(path24) {
27934
27934
  if (method === "get" && arguments.length === 1) {
27935
- return this.set(path23);
27935
+ return this.set(path24);
27936
27936
  }
27937
27937
  this.lazyrouter();
27938
- var route = this._router.route(path23);
27938
+ var route = this._router.route(path24);
27939
27939
  route[method].apply(route, slice.call(arguments, 1));
27940
27940
  return this;
27941
27941
  };
27942
27942
  });
27943
- app.all = function all(path23) {
27943
+ app.all = function all(path24) {
27944
27944
  this.lazyrouter();
27945
- var route = this._router.route(path23);
27945
+ var route = this._router.route(path24);
27946
27946
  var args = slice.call(arguments, 1);
27947
27947
  for (var i = 0; i < methods.length; i++) {
27948
27948
  route[methods[i]].apply(route, args);
@@ -28701,7 +28701,7 @@ var require_request = __commonJS({
28701
28701
  var subdomains2 = !isIP2(hostname3) ? hostname3.split(".").reverse() : [hostname3];
28702
28702
  return subdomains2.slice(offset);
28703
28703
  });
28704
- defineGetter(req, "path", function path23() {
28704
+ defineGetter(req, "path", function path24() {
28705
28705
  return parse3(this).pathname;
28706
28706
  });
28707
28707
  defineGetter(req, "hostname", function hostname3() {
@@ -29023,7 +29023,7 @@ var require_response = __commonJS({
29023
29023
  var http2 = require("http");
29024
29024
  var isAbsolute = require_utils2().isAbsolute;
29025
29025
  var onFinished = require_on_finished();
29026
- var path23 = require("path");
29026
+ var path24 = require("path");
29027
29027
  var statuses = require_statuses();
29028
29028
  var merge2 = require_utils_merge();
29029
29029
  var sign = require_cookie_signature().sign;
@@ -29032,9 +29032,9 @@ var require_response = __commonJS({
29032
29032
  var setCharset = require_utils2().setCharset;
29033
29033
  var cookie = require_cookie();
29034
29034
  var send2 = require_send();
29035
- var extname = path23.extname;
29035
+ var extname = path24.extname;
29036
29036
  var mime = send2.mime;
29037
- var resolve = path23.resolve;
29037
+ var resolve = path24.resolve;
29038
29038
  var vary = require_vary();
29039
29039
  var res = Object.create(http2.ServerResponse.prototype);
29040
29040
  module2.exports = res;
@@ -29211,26 +29211,26 @@ var require_response = __commonJS({
29211
29211
  this.type("txt");
29212
29212
  return this.send(body2);
29213
29213
  };
29214
- res.sendFile = function sendFile(path24, options, callback) {
29214
+ res.sendFile = function sendFile(path25, options, callback) {
29215
29215
  var done = callback;
29216
29216
  var req = this.req;
29217
29217
  var res2 = this;
29218
29218
  var next = req.next;
29219
29219
  var opts = options || {};
29220
- if (!path24) {
29220
+ if (!path25) {
29221
29221
  throw new TypeError("path argument is required to res.sendFile");
29222
29222
  }
29223
- if (typeof path24 !== "string") {
29223
+ if (typeof path25 !== "string") {
29224
29224
  throw new TypeError("path must be a string to res.sendFile");
29225
29225
  }
29226
29226
  if (typeof options === "function") {
29227
29227
  done = options;
29228
29228
  opts = {};
29229
29229
  }
29230
- if (!opts.root && !isAbsolute(path24)) {
29230
+ if (!opts.root && !isAbsolute(path25)) {
29231
29231
  throw new TypeError("path must be absolute or specify root to res.sendFile");
29232
29232
  }
29233
- var pathname = encodeURI(path24);
29233
+ var pathname = encodeURI(path25);
29234
29234
  var file2 = send2(req, pathname, opts);
29235
29235
  sendfile(res2, file2, opts, function(err) {
29236
29236
  if (done) return done(err);
@@ -29240,7 +29240,7 @@ var require_response = __commonJS({
29240
29240
  }
29241
29241
  });
29242
29242
  };
29243
- res.sendfile = function(path24, options, callback) {
29243
+ res.sendfile = function(path25, options, callback) {
29244
29244
  var done = callback;
29245
29245
  var req = this.req;
29246
29246
  var res2 = this;
@@ -29250,7 +29250,7 @@ var require_response = __commonJS({
29250
29250
  done = options;
29251
29251
  opts = {};
29252
29252
  }
29253
- var file2 = send2(req, path24, opts);
29253
+ var file2 = send2(req, path25, opts);
29254
29254
  sendfile(res2, file2, opts, function(err) {
29255
29255
  if (done) return done(err);
29256
29256
  if (err && err.code === "EISDIR") return next();
@@ -29263,7 +29263,7 @@ var require_response = __commonJS({
29263
29263
  res.sendfile,
29264
29264
  "res.sendfile: Use res.sendFile instead"
29265
29265
  );
29266
- res.download = function download(path24, filename, options, callback) {
29266
+ res.download = function download(path25, filename, options, callback) {
29267
29267
  var done = callback;
29268
29268
  var name = filename;
29269
29269
  var opts = options || null;
@@ -29280,7 +29280,7 @@ var require_response = __commonJS({
29280
29280
  opts = filename;
29281
29281
  }
29282
29282
  var headers = {
29283
- "Content-Disposition": contentDisposition(name || path24)
29283
+ "Content-Disposition": contentDisposition(name || path25)
29284
29284
  };
29285
29285
  if (opts && opts.headers) {
29286
29286
  var keys = Object.keys(opts.headers);
@@ -29293,7 +29293,7 @@ var require_response = __commonJS({
29293
29293
  }
29294
29294
  opts = Object.create(opts);
29295
29295
  opts.headers = headers;
29296
- var fullPath = !opts.root ? resolve(path24) : path24;
29296
+ var fullPath = !opts.root ? resolve(path25) : path25;
29297
29297
  return this.sendFile(fullPath, opts, done);
29298
29298
  };
29299
29299
  res.contentType = res.type = function contentType(type) {
@@ -29594,11 +29594,11 @@ var require_serve_static = __commonJS({
29594
29594
  }
29595
29595
  var forwardError = !fallthrough;
29596
29596
  var originalUrl = parseUrl.original(req);
29597
- var path23 = parseUrl(req).pathname;
29598
- if (path23 === "/" && originalUrl.pathname.substr(-1) !== "/") {
29599
- path23 = "";
29597
+ var path24 = parseUrl(req).pathname;
29598
+ if (path24 === "/" && originalUrl.pathname.substr(-1) !== "/") {
29599
+ path24 = "";
29600
29600
  }
29601
- var stream = send2(req, path23, opts);
29601
+ var stream = send2(req, path24, opts);
29602
29602
  stream.on("directory", onDirectory);
29603
29603
  if (setHeaders) {
29604
29604
  stream.on("headers", setHeaders);
@@ -33434,9 +33434,9 @@ __export(index_exports, {
33434
33434
  });
33435
33435
  module.exports = __toCommonJS(index_exports);
33436
33436
  var import_node_child_process3 = require("node:child_process");
33437
- var import_node_fs19 = require("node:fs");
33437
+ var import_node_fs20 = require("node:fs");
33438
33438
  var import_node_os7 = __toESM(require("node:os"), 1);
33439
- var import_node_path23 = __toESM(require("node:path"), 1);
33439
+ var import_node_path24 = __toESM(require("node:path"), 1);
33440
33440
  var import_node_module = require("node:module");
33441
33441
  var import_node_url2 = require("node:url");
33442
33442
 
@@ -33589,22 +33589,22 @@ var Daemon = class {
33589
33589
  }
33590
33590
  async install() {
33591
33591
  if (this.platform === "darwin") {
33592
- const path23 = plistPath(this.home, this.name);
33593
- if ((0, import_node_fs.existsSync)(path23)) {
33594
- await this.exec("launchctl", ["unload", "-w", path23]).catch(() => void 0);
33592
+ const path24 = plistPath(this.home, this.name);
33593
+ if ((0, import_node_fs.existsSync)(path24)) {
33594
+ await this.exec("launchctl", ["unload", "-w", path24]).catch(() => void 0);
33595
33595
  }
33596
33596
  await (0, import_promises.mkdir)((0, import_node_path.join)(this.home, "Library", "LaunchAgents"), { recursive: true });
33597
- await (0, import_promises.writeFile)(path23, renderPlist(this.name, this.programArgs, this.env), "utf8");
33598
- await this.exec("launchctl", ["load", "-w", path23]);
33597
+ await (0, import_promises.writeFile)(path24, renderPlist(this.name, this.programArgs, this.env), "utf8");
33598
+ await this.exec("launchctl", ["load", "-w", path24]);
33599
33599
  return;
33600
33600
  }
33601
33601
  if (this.platform === "linux") {
33602
- const path23 = unitPath(this.home, this.name);
33603
- if ((0, import_node_fs.existsSync)(path23)) {
33602
+ const path24 = unitPath(this.home, this.name);
33603
+ if ((0, import_node_fs.existsSync)(path24)) {
33604
33604
  await this.exec("systemctl", ["--user", "disable", "--now", `${this.name}.service`]).catch(() => void 0);
33605
33605
  }
33606
33606
  await (0, import_promises.mkdir)((0, import_node_path.join)(this.home, ".config", "systemd", "user"), { recursive: true });
33607
- await (0, import_promises.writeFile)(path23, renderUnit(this.description, this.programArgs, this.env), "utf8");
33607
+ await (0, import_promises.writeFile)(path24, renderUnit(this.description, this.programArgs, this.env), "utf8");
33608
33608
  await this.exec("systemctl", ["--user", "daemon-reload"]);
33609
33609
  await this.exec("systemctl", ["--user", "enable", "--now", `${this.name}.service`]);
33610
33610
  return;
@@ -33613,17 +33613,17 @@ var Daemon = class {
33613
33613
  }
33614
33614
  async uninstall() {
33615
33615
  if (this.platform === "darwin") {
33616
- const path23 = plistPath(this.home, this.name);
33617
- if ((0, import_node_fs.existsSync)(path23)) {
33618
- await this.exec("launchctl", ["unload", "-w", path23]).catch(() => void 0);
33619
- await (0, import_promises.rm)(path23, { force: true });
33616
+ const path24 = plistPath(this.home, this.name);
33617
+ if ((0, import_node_fs.existsSync)(path24)) {
33618
+ await this.exec("launchctl", ["unload", "-w", path24]).catch(() => void 0);
33619
+ await (0, import_promises.rm)(path24, { force: true });
33620
33620
  }
33621
33621
  return;
33622
33622
  }
33623
33623
  if (this.platform === "linux") {
33624
- const path23 = unitPath(this.home, this.name);
33624
+ const path24 = unitPath(this.home, this.name);
33625
33625
  await this.exec("systemctl", ["--user", "disable", "--now", `${this.name}.service`]).catch(() => void 0);
33626
- await (0, import_promises.rm)(path23, { force: true });
33626
+ await (0, import_promises.rm)(path24, { force: true });
33627
33627
  await this.exec("systemctl", ["--user", "daemon-reload"]);
33628
33628
  return;
33629
33629
  }
@@ -33631,8 +33631,8 @@ var Daemon = class {
33631
33631
  }
33632
33632
  async status() {
33633
33633
  if (this.platform === "darwin") {
33634
- const path23 = plistPath(this.home, this.name);
33635
- if (!(0, import_node_fs.existsSync)(path23))
33634
+ const path24 = plistPath(this.home, this.name);
33635
+ if (!(0, import_node_fs.existsSync)(path24))
33636
33636
  return { installed: false, running: false };
33637
33637
  try {
33638
33638
  await this.exec("launchctl", ["list", this.name]);
@@ -33642,8 +33642,8 @@ var Daemon = class {
33642
33642
  }
33643
33643
  }
33644
33644
  if (this.platform === "linux") {
33645
- const path23 = unitPath(this.home, this.name);
33646
- if (!(0, import_node_fs.existsSync)(path23))
33645
+ const path24 = unitPath(this.home, this.name);
33646
+ if (!(0, import_node_fs.existsSync)(path24))
33647
33647
  return { installed: false, running: false };
33648
33648
  try {
33649
33649
  const result = await this.exec("systemctl", [
@@ -33667,10 +33667,10 @@ require_shim7()();
33667
33667
 
33668
33668
  // ../server/src/server.ts
33669
33669
  var import_express4 = __toESM(require_express2(), 1);
33670
- var import_node_fs12 = require("node:fs");
33670
+ var import_node_fs13 = require("node:fs");
33671
33671
  var import_node_http2 = __toESM(require("node:http"), 1);
33672
33672
  var import_node_os6 = __toESM(require("node:os"), 1);
33673
- var import_node_path16 = __toESM(require("node:path"), 1);
33673
+ var import_node_path17 = __toESM(require("node:path"), 1);
33674
33674
  var import_node_url = require("node:url");
33675
33675
 
33676
33676
  // ../server/src/config.ts
@@ -33928,9 +33928,9 @@ function isVitestRuntime() {
33928
33928
  }
33929
33929
 
33930
33930
  // ../server/src/routes.ts
33931
- var import_node_fs7 = require("node:fs");
33931
+ var import_node_fs8 = require("node:fs");
33932
33932
  var import_node_os3 = __toESM(require("node:os"), 1);
33933
- var import_node_path7 = __toESM(require("node:path"), 1);
33933
+ var import_node_path8 = __toESM(require("node:path"), 1);
33934
33934
 
33935
33935
  // ../../node_modules/zod/v4/classic/external.js
33936
33936
  var external_exports = {};
@@ -34699,10 +34699,10 @@ function mergeDefs(...defs) {
34699
34699
  function cloneDef(schema) {
34700
34700
  return mergeDefs(schema._zod.def);
34701
34701
  }
34702
- function getElementAtPath(obj, path23) {
34703
- if (!path23)
34702
+ function getElementAtPath(obj, path24) {
34703
+ if (!path24)
34704
34704
  return obj;
34705
- return path23.reduce((acc, key) => acc?.[key], obj);
34705
+ return path24.reduce((acc, key) => acc?.[key], obj);
34706
34706
  }
34707
34707
  function promiseAllObject(promisesObj) {
34708
34708
  const keys = Object.keys(promisesObj);
@@ -35085,11 +35085,11 @@ function aborted(x2, startIndex = 0) {
35085
35085
  }
35086
35086
  return false;
35087
35087
  }
35088
- function prefixIssues(path23, issues) {
35088
+ function prefixIssues(path24, issues) {
35089
35089
  return issues.map((iss) => {
35090
35090
  var _a2;
35091
35091
  (_a2 = iss).path ?? (_a2.path = []);
35092
- iss.path.unshift(path23);
35092
+ iss.path.unshift(path24);
35093
35093
  return iss;
35094
35094
  });
35095
35095
  }
@@ -35272,7 +35272,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
35272
35272
  }
35273
35273
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
35274
35274
  const result = { errors: [] };
35275
- const processError = (error49, path23 = []) => {
35275
+ const processError = (error49, path24 = []) => {
35276
35276
  var _a2, _b;
35277
35277
  for (const issue2 of error49.issues) {
35278
35278
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -35282,7 +35282,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
35282
35282
  } else if (issue2.code === "invalid_element") {
35283
35283
  processError({ issues: issue2.issues }, issue2.path);
35284
35284
  } else {
35285
- const fullpath = [...path23, ...issue2.path];
35285
+ const fullpath = [...path24, ...issue2.path];
35286
35286
  if (fullpath.length === 0) {
35287
35287
  result.errors.push(mapper(issue2));
35288
35288
  continue;
@@ -35314,8 +35314,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
35314
35314
  }
35315
35315
  function toDotPath(_path) {
35316
35316
  const segs = [];
35317
- const path23 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
35318
- for (const seg of path23) {
35317
+ const path24 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
35318
+ for (const seg of path24) {
35319
35319
  if (typeof seg === "number")
35320
35320
  segs.push(`[${seg}]`);
35321
35321
  else if (typeof seg === "symbol")
@@ -47292,13 +47292,13 @@ function resolveRef(ref, ctx) {
47292
47292
  if (!ref.startsWith("#")) {
47293
47293
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
47294
47294
  }
47295
- const path23 = ref.slice(1).split("/").filter(Boolean);
47296
- if (path23.length === 0) {
47295
+ const path24 = ref.slice(1).split("/").filter(Boolean);
47296
+ if (path24.length === 0) {
47297
47297
  return ctx.rootSchema;
47298
47298
  }
47299
47299
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
47300
- if (path23[0] === defsKey) {
47301
- const key = path23[1];
47300
+ if (path24[0] === defsKey) {
47301
+ const key = path24[1];
47302
47302
  if (!key || !ctx.defs[key]) {
47303
47303
  throw new Error(`Reference not found: ${ref}`);
47304
47304
  }
@@ -47995,8 +47995,8 @@ function validateResourceUsage(usage) {
47995
47995
  var JSON_STORE_MAX_KEY_BYTES = 768;
47996
47996
  var JSON_STORE_MAX_DEPTH = 32;
47997
47997
  var INDEX_PATTERN = /^(?:0|[1-9][0-9]*)$/;
47998
- function parseJsonPath(path23) {
47999
- const segments = path23.split("/").filter((segment) => segment.length > 0);
47998
+ function parseJsonPath(path24) {
47999
+ const segments = path24.split("/").filter((segment) => segment.length > 0);
48000
48000
  checkPathSegments(segments);
48001
48001
  return segments;
48002
48002
  }
@@ -48991,7 +48991,7 @@ var JsonStoreClient = class {
48991
48991
  return;
48992
48992
  }
48993
48993
  if (event.event !== "changed" || !isOwn(event)) return;
48994
- if (event.paths.some((path23) => pathsMeet(parseJsonPath(path23), watched))) read();
48994
+ if (event.paths.some((path24) => pathsMeet(parseJsonPath(path24), watched))) read();
48995
48995
  }
48996
48996
  }, input.signal);
48997
48997
  return stream.finished;
@@ -49343,6 +49343,7 @@ var ETAG_DIGEST_LENGTH = 16;
49343
49343
  var HTTP_NO_CONTENT_STATUS = 204;
49344
49344
  var HTTP_NOT_FOUND_STATUS = 404;
49345
49345
  var HTTP_NOT_MODIFIED_STATUS = 304;
49346
+ var HTTP_METHOD_NOT_ALLOWED_STATUS = 405;
49346
49347
  var THEME_MANIFEST_FILE = "manifest.json";
49347
49348
  var THEME_ENTRY_FILE = "theme.css";
49348
49349
  var THEME_SCRIPT_ENTRIES = [
@@ -49534,7 +49535,7 @@ function scanThemesDirectory(themesDir) {
49534
49535
  return { themes, errors };
49535
49536
  }
49536
49537
  function serveActiveTheme(store) {
49537
- return (req, res, next) => {
49538
+ return (req, res) => {
49538
49539
  res.setHeader("Access-Control-Allow-Origin", "*");
49539
49540
  res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS");
49540
49541
  if (req.method === "OPTIONS") {
@@ -49542,7 +49543,8 @@ function serveActiveTheme(store) {
49542
49543
  return;
49543
49544
  }
49544
49545
  if (req.method !== "GET" && req.method !== "HEAD") {
49545
- next();
49546
+ res.setHeader("Allow", "GET, HEAD, OPTIONS");
49547
+ res.sendStatus(HTTP_METHOD_NOT_ALLOWED_STATUS);
49546
49548
  return;
49547
49549
  }
49548
49550
  res.setHeader("Cache-Control", "no-cache");
@@ -50176,9 +50178,9 @@ function telemetryContextFromMeta(value) {
50176
50178
  // ../server/src/artifact-proxy.ts
50177
50179
  var import_node_crypto3 = require("node:crypto");
50178
50180
  var import_promises2 = require("node:fs/promises");
50179
- var import_node_fs5 = __toESM(require("node:fs"), 1);
50181
+ var import_node_fs6 = __toESM(require("node:fs"), 1);
50180
50182
  var import_node_http = require("node:http");
50181
- var import_node_path6 = __toESM(require("node:path"), 1);
50183
+ var import_node_path7 = __toESM(require("node:path"), 1);
50182
50184
  var import_send = __toESM(require_send(), 1);
50183
50185
 
50184
50186
  // ../../node_modules/marked/lib/marked.esm.js
@@ -51663,7 +51665,7 @@ function installBridge(win = window, options = {}) {
51663
51665
  };
51664
51666
  postNavigationRequest({ url: win.location.href });
51665
51667
  const navigation = win.navigation;
51666
- if (navigation) {
51668
+ if (navigation && navigation.currentEntry !== null) {
51667
51669
  navigation.addEventListener("navigate", (event) => {
51668
51670
  const navigateEvent = event;
51669
51671
  const url2 = navigateEvent.destination?.url;
@@ -51691,30 +51693,44 @@ function installBridge(win = window, options = {}) {
51691
51693
  postNavigationRequest(message);
51692
51694
  });
51693
51695
  } else {
51694
- win.document.addEventListener(
51695
- "click",
51696
- (event) => {
51697
- const mouse = event;
51698
- if (mouse.metaKey || mouse.ctrlKey || mouse.shiftKey || mouse.altKey) return;
51699
- const elementConstructor = win.document.defaultView?.Element;
51700
- if (!elementConstructor || !(mouse.target instanceof elementConstructor)) return;
51701
- const anchor = mouse.target.closest("a[href]");
51702
- if (!anchor) return;
51703
- if (anchor.target && anchor.target.toLowerCase() !== "_self") return;
51704
- if (anchor.hasAttribute("download")) return;
51705
- const href = anchor.getAttribute("href");
51706
- if (!href) return;
51707
- const url2 = webNavigationURL(anchor.href, win.document.baseURI);
51708
- if (!url2) return;
51709
- if (url2.origin === win.location.origin && url2.pathname === win.location.pathname && url2.search === win.location.search && url2.hash !== "") {
51710
- postNavigationRequest({ url: url2.href, sameDocument: true });
51711
- return;
51712
- }
51713
- mouse.preventDefault();
51714
- postNavigationRequest({ url: url2.href });
51715
- },
51716
- true
51717
- );
51696
+ const afterPageHandlers = (type, act) => {
51697
+ let pending = null;
51698
+ win.addEventListener(
51699
+ type,
51700
+ (captured) => {
51701
+ if (pending) win.removeEventListener(type, pending);
51702
+ const settle = (event) => {
51703
+ if (event !== captured) return;
51704
+ win.removeEventListener(type, settle);
51705
+ pending = null;
51706
+ if (!event.defaultPrevented) act(event);
51707
+ };
51708
+ pending = settle;
51709
+ win.addEventListener(type, settle);
51710
+ },
51711
+ true
51712
+ );
51713
+ };
51714
+ afterPageHandlers("click", (event) => {
51715
+ const mouse = event;
51716
+ if (mouse.metaKey || mouse.ctrlKey || mouse.shiftKey || mouse.altKey) return;
51717
+ const elementConstructor = win.document.defaultView?.Element;
51718
+ if (!elementConstructor || !(mouse.target instanceof elementConstructor)) return;
51719
+ const anchor = mouse.target.closest("a[href]");
51720
+ if (!anchor) return;
51721
+ if (anchor.target && anchor.target.toLowerCase() !== "_self") return;
51722
+ if (anchor.hasAttribute("download")) return;
51723
+ const href = anchor.getAttribute("href");
51724
+ if (!href) return;
51725
+ const url2 = webNavigationURL(anchor.href, win.document.baseURI);
51726
+ if (!url2) return;
51727
+ if (url2.origin === win.location.origin && url2.pathname === win.location.pathname && url2.search === win.location.search && url2.hash !== "") {
51728
+ postNavigationRequest({ url: url2.href, sameDocument: true });
51729
+ return;
51730
+ }
51731
+ mouse.preventDefault();
51732
+ postNavigationRequest({ url: url2.href });
51733
+ });
51718
51734
  const originalPushState = win.history.pushState.bind(win.history);
51719
51735
  const originalReplaceState = win.history.replaceState.bind(win.history);
51720
51736
  win.history.pushState = function pushState(...args) {
@@ -51731,31 +51747,29 @@ function installBridge(win = window, options = {}) {
51731
51747
  win.addEventListener("hashchange", () => {
51732
51748
  postNavigationRequest({ url: win.location.href, sameDocument: true });
51733
51749
  });
51734
- win.document.addEventListener(
51735
- "submit",
51736
- (event) => {
51737
- const submit = event;
51738
- const form = submit.target;
51739
- const formConstructor = win.document.defaultView?.HTMLFormElement;
51740
- if (!formConstructor || !(form instanceof formConstructor)) return;
51741
- if (form.target && form.target.toLowerCase() !== "_self") return;
51742
- const action = webNavigationURL(form.action || win.location.href, win.document.baseURI);
51743
- if (!action) return;
51744
- submit.preventDefault();
51745
- const method = form.method.toLowerCase();
51746
- if (method === "get") {
51747
- const formDataConstructor = win.document.defaultView?.FormData;
51748
- if (!formDataConstructor) return;
51749
- const params = new URLSearchParams();
51750
- for (const [name, value] of new formDataConstructor(form)) {
51751
- if (typeof value === "string") params.append(name, value);
51752
- }
51753
- action.search = params.toString();
51754
- }
51755
- postNavigationRequest({ url: action.href });
51756
- },
51757
- true
51758
- );
51750
+ afterPageHandlers("submit", (event) => {
51751
+ const submit = event;
51752
+ const form = submit.target;
51753
+ const formConstructor = win.document.defaultView?.HTMLFormElement;
51754
+ if (!formConstructor || !(form instanceof formConstructor)) return;
51755
+ const submitter = submit.submitter ?? null;
51756
+ const override = (name) => submitter?.hasAttribute(name) ? submitter.getAttribute(name) ?? "" : null;
51757
+ const target = override("formtarget") ?? form.getAttribute("target");
51758
+ if (target && target.toLowerCase() !== "_self") return;
51759
+ const method = (override("formmethod") ?? form.getAttribute("method"))?.toLowerCase();
51760
+ if (method === "post" || method === "dialog") return;
51761
+ const action = webNavigationURL((override("formaction") ?? form.getAttribute("action")) || win.location.href, win.document.baseURI);
51762
+ if (!action) return;
51763
+ const formDataConstructor = win.document.defaultView?.FormData;
51764
+ if (!formDataConstructor) return;
51765
+ const params = new URLSearchParams();
51766
+ for (const [name, value] of new formDataConstructor(form, submitter)) {
51767
+ params.append(name, typeof value === "string" ? value : value.name);
51768
+ }
51769
+ action.search = params.toString();
51770
+ submit.preventDefault();
51771
+ postNavigationRequest({ url: action.href });
51772
+ });
51759
51773
  }
51760
51774
  }
51761
51775
  postBridgeReady();
@@ -51957,10 +51971,39 @@ li input[type="checkbox"] {
51957
51971
  `
51958
51972
  );
51959
51973
 
51974
+ // ../server/src/artifact-location.ts
51975
+ var import_node_fs5 = __toESM(require("node:fs"), 1);
51976
+ var import_node_path6 = __toESM(require("node:path"), 1);
51977
+ var DIRECTORY_INDEX_BASENAMES = ["index.html", "index.htm"];
51978
+ function isReadable(realPath) {
51979
+ try {
51980
+ import_node_fs5.default.accessSync(realPath, import_node_fs5.default.constants.R_OK);
51981
+ return true;
51982
+ } catch {
51983
+ return false;
51984
+ }
51985
+ }
51986
+ function artifactRealLocation(artifactPath) {
51987
+ let realPath;
51988
+ let stat;
51989
+ try {
51990
+ realPath = import_node_fs5.default.realpathSync(artifactPath);
51991
+ stat = import_node_fs5.default.statSync(realPath);
51992
+ } catch {
51993
+ return null;
51994
+ }
51995
+ if (hasTrailingSeparator(artifactPath)) {
51996
+ const holdsIndex = stat.isDirectory() && DIRECTORY_INDEX_BASENAMES.some((basename) => import_node_fs5.default.existsSync(import_node_path6.default.join(realPath, basename)));
51997
+ return holdsIndex && isReadable(realPath) ? { path: realPath, stat } : null;
51998
+ }
51999
+ return stat.isFile() && isAllowedArtifactFilePath(realPath) && isReadable(realPath) ? { path: realPath, stat } : null;
52000
+ }
52001
+
51960
52002
  // ../server/src/artifact-proxy.ts
51961
52003
  var HTTP_OK2 = 200;
51962
52004
  var HTTP_MOVED_PERMANENTLY = 301;
51963
52005
  var HTTP_NOT_MODIFIED = 304;
52006
+ var HTTP_FORBIDDEN = 403;
51964
52007
  var HTTP_NOT_FOUND = 404;
51965
52008
  var HTTP_METHOD_NOT_ALLOWED = 405;
51966
52009
  var HTML_CACHE_CONTROL = "no-cache, must-revalidate";
@@ -51968,6 +52011,10 @@ var SHARED_PROXY_HEADERS = {
51968
52011
  "X-Content-Type-Options": "nosniff",
51969
52012
  "Referrer-Policy": "no-referrer"
51970
52013
  };
52014
+ var CROSS_ORIGIN_HEADERS = {
52015
+ "Access-Control-Allow-Origin": "*",
52016
+ "Access-Control-Expose-Headers": "ETag"
52017
+ };
51971
52018
  function applyProxyHeaders(res) {
51972
52019
  for (const [name, value] of Object.entries(SHARED_PROXY_HEADERS)) res.setHeader(name, value);
51973
52020
  }
@@ -52009,7 +52056,7 @@ function sendArtifactNotFound(req, res, store) {
52009
52056
  return;
52010
52057
  }
52011
52058
  try {
52012
- const body2 = await (0, import_promises2.readFile)(import_node_path6.default.join(viewPath, "index.html"));
52059
+ const body2 = await (0, import_promises2.readFile)(import_node_path7.default.join(viewPath, "index.html"));
52013
52060
  applyProxyHeaders(res);
52014
52061
  res.status(HTTP_NOT_FOUND).type("text/html; charset=utf-8");
52015
52062
  res.setHeader("Content-Length", String(body2.byteLength));
@@ -52181,16 +52228,30 @@ function sendRenderedMarkdown(req, res, reply, resolvedPath, stat, appearanceSou
52181
52228
  }
52182
52229
  })();
52183
52230
  }
52184
- function pipeWithInjection(req, res, reply, subpath, options, appearanceSource, bridgeSource, onFolder, onMissing) {
52231
+ function isServedFromFolder(realFolder, resolvedPath) {
52232
+ let realPath;
52233
+ try {
52234
+ realPath = import_node_fs6.default.realpathSync(resolvedPath);
52235
+ } catch {
52236
+ return false;
52237
+ }
52238
+ const relative = import_node_path7.default.relative(realFolder, realPath);
52239
+ return !import_node_path7.default.isAbsolute(relative) && relative.split(import_node_path7.default.sep).every((part) => !part.startsWith("."));
52240
+ }
52241
+ function pipeWithInjection(req, res, reply, subpath, options, appearanceSource, bridgeSource, onFolder, onMissing, serves = () => true) {
52185
52242
  applyProxyHeaders(res);
52186
52243
  const stream = (0, import_send.default)(req, subpath, { ...options, etag: true });
52187
- stream.on("directory", onFolder);
52244
+ stream.on("directory", (_res, resolvedPath) => serves(resolvedPath) ? onFolder() : onMissing());
52188
52245
  const sendOriginal = stream.send.bind(stream);
52189
52246
  stream.send = (resolvedPath, stat) => {
52190
52247
  if (!stat) {
52191
52248
  sendOriginal(resolvedPath, stat);
52192
52249
  return;
52193
52250
  }
52251
+ if (!serves(resolvedPath)) {
52252
+ onMissing();
52253
+ return;
52254
+ }
52194
52255
  stream.setHeader(resolvedPath, stat);
52195
52256
  stream.type(resolvedPath);
52196
52257
  if (!isHTMLResponse(res)) {
@@ -52203,7 +52264,7 @@ function pipeWithInjection(req, res, reply, subpath, options, appearanceSource,
52203
52264
  };
52204
52265
  stream.on("error", (error48) => {
52205
52266
  const status = error48.status ?? HTTP_NOT_FOUND;
52206
- if (status === HTTP_NOT_FOUND) onMissing();
52267
+ if (status === HTTP_NOT_FOUND || status === HTTP_FORBIDDEN) onMissing();
52207
52268
  else reply.failed(status);
52208
52269
  });
52209
52270
  stream.pipe(res);
@@ -52213,19 +52274,18 @@ function serveDirectoryArtifact(req, res, reply, artifact, subpath, appearanceSo
52213
52274
  reply.addSlash();
52214
52275
  return;
52215
52276
  }
52216
- pipeWithInjection(req, res, reply, subpath, { root: artifact.path, index: ["index.html", "index.htm"], dotfiles: "allow" }, appearanceSource, bridgeSource, reply.addSlash, subpath === "/" ? reply.artifactMissing : reply.notFound);
52277
+ const onMissing = subpath === "/" ? reply.artifactMissing : reply.notFound;
52278
+ const location = artifactRealLocation(artifact.path);
52279
+ if (location === null) {
52280
+ onMissing();
52281
+ return;
52282
+ }
52283
+ const realFolder = location.path;
52284
+ pipeWithInjection(req, res, reply, subpath, { root: realFolder, index: ["index.html", "index.htm"], dotfiles: "allow" }, appearanceSource, bridgeSource, reply.addSlash, onMissing, (resolvedPath) => isServedFromFolder(realFolder, resolvedPath));
52217
52285
  }
52218
52286
  function serveFileArtifact(req, res, reply, artifact, subpath, appearanceSource, bridgeSource) {
52219
52287
  const entry = fileEntry(artifact, reply);
52220
- let stat;
52221
- try {
52222
- stat = import_node_fs5.default.statSync(artifact.path);
52223
- } catch {
52224
- if (subpath === entry) reply.artifactMissing();
52225
- else reply.notFound();
52226
- return;
52227
- }
52228
- if (!stat.isFile()) {
52288
+ if (artifactRealLocation(artifact.path) === null) {
52229
52289
  if (subpath === entry) reply.artifactMissing();
52230
52290
  else reply.notFound();
52231
52291
  return;
@@ -52238,19 +52298,12 @@ function serveFileArtifact(req, res, reply, artifact, subpath, appearanceSource,
52238
52298
  reply.notFound();
52239
52299
  return;
52240
52300
  }
52241
- pipeWithInjection(req, res, reply, fileNamePath(artifact), { root: import_node_path6.default.dirname(artifact.path), index: false, dotfiles: "allow" }, appearanceSource, bridgeSource, reply.artifactMissing, reply.artifactMissing);
52301
+ pipeWithInjection(req, res, reply, fileNamePath(artifact), { root: import_node_path7.default.dirname(artifact.path), index: false, dotfiles: "allow" }, appearanceSource, bridgeSource, reply.artifactMissing, reply.artifactMissing, (resolvedPath) => artifactRealLocation(resolvedPath) !== null);
52242
52302
  }
52243
52303
  function serveMarkdownArtifact(req, res, reply, artifact, subpath, appearanceSource, bridgeSource) {
52244
52304
  const entry = fileEntry(artifact, reply);
52245
- let stat;
52246
- try {
52247
- stat = import_node_fs5.default.statSync(artifact.path);
52248
- } catch {
52249
- if (subpath === entry) reply.artifactMissing();
52250
- else reply.notFound();
52251
- return;
52252
- }
52253
- if (!stat.isFile()) {
52305
+ const location = artifactRealLocation(artifact.path);
52306
+ if (location === null) {
52254
52307
  if (subpath === entry) reply.artifactMissing();
52255
52308
  else reply.notFound();
52256
52309
  return;
@@ -52263,12 +52316,13 @@ function serveMarkdownArtifact(req, res, reply, artifact, subpath, appearanceSou
52263
52316
  reply.notFound();
52264
52317
  return;
52265
52318
  }
52266
- sendRenderedMarkdown(req, res, reply, artifact.path, stat, appearanceSource, bridgeSource);
52319
+ sendRenderedMarkdown(req, res, reply, location.path, location.stat, appearanceSource, bridgeSource);
52267
52320
  }
52268
52321
  function serveArtifactProxy(store, options = {}) {
52269
52322
  const appearanceSource = appearanceResolverScriptSource('"system"');
52270
52323
  const bridgeSource = bridgeScriptSource({ pollCadence: options.pollCadence });
52271
52324
  return (req, res) => {
52325
+ for (const [name, value] of Object.entries(CROSS_ORIGIN_HEADERS)) res.setHeader(name, value);
52272
52326
  if (req.method !== "GET" && req.method !== "HEAD") {
52273
52327
  sendMethodNotAllowed(res);
52274
52328
  return;
@@ -52292,8 +52346,8 @@ function serveArtifactProxy(store, options = {}) {
52292
52346
  }
52293
52347
 
52294
52348
  // ../server/src/markdown.ts
52295
- var fs2 = __toESM(require("node:fs/promises"), 1);
52296
- var import_node_fs6 = require("node:fs");
52349
+ var fs3 = __toESM(require("node:fs/promises"), 1);
52350
+ var import_node_fs7 = require("node:fs");
52297
52351
  var import_express = __toESM(require_express2(), 1);
52298
52352
  var HTTP_NO_CONTENT = 204;
52299
52353
  var HTTP_NOT_FOUND2 = 404;
@@ -52319,8 +52373,13 @@ function serveMarkdownContent(store) {
52319
52373
  sendMarkdownError(res, HTTP_NOT_FOUND2, `Markdown artifact not found: ${id}`);
52320
52374
  return;
52321
52375
  }
52376
+ const location = artifactRealLocation(artifact.path);
52377
+ if (location === null) {
52378
+ sendMarkdownError(res, HTTP_NOT_FOUND2, `Markdown artifact not found: ${id}`);
52379
+ return;
52380
+ }
52322
52381
  try {
52323
- const content = await fs2.readFile(artifact.path, "utf8");
52382
+ const content = await fs3.readFile(location.path, "utf8");
52324
52383
  res.type("text/markdown; charset=utf-8").send(content);
52325
52384
  } catch (error48) {
52326
52385
  if (isNotFoundIOError(error48)) {
@@ -52337,10 +52396,15 @@ function serveMarkdownContent(store) {
52337
52396
  sendMarkdownError(res, HTTP_NOT_FOUND2, `Markdown artifact not found: ${id}`);
52338
52397
  return;
52339
52398
  }
52399
+ const location = artifactRealLocation(artifact.path);
52400
+ if (location === null) {
52401
+ sendMarkdownError(res, HTTP_NOT_FOUND2, `Markdown artifact not found: ${id}`);
52402
+ return;
52403
+ }
52340
52404
  const content = typeof req.body === "string" ? req.body : "";
52341
52405
  try {
52342
- await fs2.access(artifact.path, import_node_fs6.constants.F_OK);
52343
- await fs2.writeFile(artifact.path, content, "utf8");
52406
+ await fs3.access(location.path, import_node_fs7.constants.F_OK);
52407
+ await fs3.writeFile(location.path, content, "utf8");
52344
52408
  res.status(HTTP_NO_CONTENT).end();
52345
52409
  } catch (error48) {
52346
52410
  if (isNotFoundIOError(error48)) {
@@ -52417,23 +52481,6 @@ var HTTP_BAD_REQUEST = 400;
52417
52481
  var HTTP_NOT_FOUND3 = 404;
52418
52482
  var HTTP_CONFLICT = 409;
52419
52483
  var HTTP_SERVICE_UNAVAILABLE = 503;
52420
- var CORS_HEADERS = {
52421
- "Access-Control-Allow-Origin": "*",
52422
- "Access-Control-Allow-Methods": "GET, POST, PUT, PATCH, DELETE, OPTIONS",
52423
- "Access-Control-Allow-Headers": `Authorization, Content-Type, ${TELEVISION_CLIENT_META_HEADER}`,
52424
- // Cross-origin clients can read the version advertisement header
52425
- // (specs/arch/updates/version-advertisement.md ^version-header).
52426
- "Access-Control-Expose-Headers": "X-TV-Version"
52427
- };
52428
- function applyCorsHeaders(res) {
52429
- for (const [name, value] of Object.entries(CORS_HEADERS)) {
52430
- res.setHeader(name, value);
52431
- }
52432
- }
52433
- var applyCorsMiddleware = (_req, res, next) => {
52434
- applyCorsHeaders(res);
52435
- next();
52436
- };
52437
52484
  function sendError(res, status, message) {
52438
52485
  res.status(status).json({ error: message });
52439
52486
  }
@@ -52470,34 +52517,19 @@ function registerRoutes(app, store, options) {
52470
52517
  app.get("/desktop/connect-check", ...bearerAuth, (_req, res) => {
52471
52518
  res.status(HTTP_OK3).json({ product: "television" });
52472
52519
  });
52473
- app.use("/channels", applyCorsMiddleware, telemetryMiddleware);
52474
- app.use("/artifacts", applyCorsMiddleware, telemetryMiddleware);
52475
- app.use("/display", applyCorsMiddleware, telemetryMiddleware);
52476
- app.use("/themes", applyCorsMiddleware, telemetryMiddleware);
52477
- app.use("/markdown", applyCorsMiddleware, telemetryMiddleware);
52478
- app.use("/telemetry", applyCorsMiddleware);
52479
- app.use("/demo-mode", applyCorsMiddleware);
52520
+ app.use("/channels", telemetryMiddleware);
52521
+ app.use("/artifacts", telemetryMiddleware);
52522
+ app.use("/display", telemetryMiddleware);
52523
+ app.use("/themes", telemetryMiddleware);
52524
+ app.use("/markdown", telemetryMiddleware);
52480
52525
  const artifactProxy = serveArtifactProxy(store, { pollCadence: options.testArtifactPollCadence });
52481
52526
  app.all("/artifact/:id", artifactProxy);
52482
52527
  app.all("/artifact/:id/*", artifactProxy);
52483
52528
  const markdownContent = serveMarkdownContent(store);
52484
52529
  app.get("/markdown/:id", ...bearerAuth, markdownContent.get);
52485
52530
  app.put("/markdown/:id", ...bearerAuth, markdownContent.put);
52486
- app.options("/channels", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52487
- app.options("/channels/:id", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52488
- app.options("/artifacts", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52489
- app.options("/artifacts/:id", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52490
- app.options("/display", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52491
- app.options("/display/focus", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52492
- app.options("/themes", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52493
- app.options("/themes/refresh", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52494
- app.options("/markdown/:id", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52495
- app.options("/telemetry", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52496
- app.options("/demo-mode", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52497
- app.options("/telemetry/enable", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52498
- app.options("/telemetry/disable", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
52499
52531
  app.get("/demo-mode", ...auth, (_req, res) => {
52500
- res.json({ browserExternalPages: (0, import_node_fs7.existsSync)(import_node_path7.default.join(import_node_os3.default.homedir(), BROWSER_DEMO_MARKER)) });
52532
+ res.json({ browserExternalPages: (0, import_node_fs8.existsSync)(import_node_path8.default.join(import_node_os3.default.homedir(), BROWSER_DEMO_MARKER)) });
52501
52533
  });
52502
52534
  app.get("/telemetry", ...auth, (_req, res) => {
52503
52535
  res.json(options.getTelemetryStatus?.() ?? { state: "unavailable", reason: null, guidPresent: false, region: "us" });
@@ -52914,7 +52946,7 @@ function isTelemetryActivityMessage(parsed, expectedClientId) {
52914
52946
  var import_node_child_process2 = require("node:child_process");
52915
52947
  var import_promises3 = require("node:fs/promises");
52916
52948
  var import_node_os4 = require("node:os");
52917
- var import_node_path8 = __toESM(require("node:path"), 1);
52949
+ var import_node_path9 = __toESM(require("node:path"), 1);
52918
52950
  var launchACPProcess = (command, args, options) => {
52919
52951
  const child = (0, import_node_child_process2.spawn)(command, args, options);
52920
52952
  const directKill = child.kill.bind(child);
@@ -52957,9 +52989,9 @@ function trackChild(child) {
52957
52989
  child.once("exit", untrack);
52958
52990
  child.once("error", untrack);
52959
52991
  }
52960
- var ACP_STUB_CWD = import_node_path8.default.join((0, import_node_os4.homedir)(), ".television", "acp");
52992
+ var ACP_STUB_CWD = import_node_path9.default.join((0, import_node_os4.homedir)(), ".television", "acp");
52961
52993
  function buildACPAgentTVArgs(input) {
52962
- const args = ["--home", import_node_path8.default.resolve(input.home)];
52994
+ const args = ["--home", import_node_path9.default.resolve(input.home)];
52963
52995
  if (input.configuredPort === 0) args.push("--port", String(input.acquiredPort));
52964
52996
  return args;
52965
52997
  }
@@ -52981,7 +53013,7 @@ var ACPBridge = class extends withDisposable(class {
52981
53013
  this.profile = options.profile;
52982
53014
  this.tvArgs = options.tvArgs;
52983
53015
  this.launchProcess = options.launchProcess ?? launchACPProcess;
52984
- this.sessionCwd = import_node_path8.default.resolve(process.cwd());
53016
+ this.sessionCwd = import_node_path9.default.resolve(process.cwd());
52985
53017
  }
52986
53018
  handleClientMessage(message) {
52987
53019
  switch (message.type) {
@@ -53222,8 +53254,8 @@ function splitListenValues(values) {
53222
53254
 
53223
53255
  // ../server/src/canonical.ts
53224
53256
  var import_node_crypto5 = require("node:crypto");
53225
- var import_node_fs8 = require("node:fs");
53226
- var import_node_path9 = __toESM(require("node:path"), 1);
53257
+ var import_node_fs9 = require("node:fs");
53258
+ var import_node_path10 = __toESM(require("node:path"), 1);
53227
53259
  var CACHE_CONTROL_NO_CACHE = "no-cache";
53228
53260
  var ETAG_DIGEST_LENGTH2 = 16;
53229
53261
  var HTTP_NOT_MODIFIED_STATUS2 = 304;
@@ -53236,7 +53268,7 @@ function canonicalWrapper(version2, frozen = false, querySuffix = "") {
53236
53268
  `;
53237
53269
  }
53238
53270
  function serveCanonicalBase(canonicalDir) {
53239
- const body2 = (0, import_node_fs8.readFileSync)(import_node_path9.default.join(canonicalDir, CANONICAL_STYLESHEET));
53271
+ const body2 = (0, import_node_fs9.readFileSync)(import_node_path10.default.join(canonicalDir, CANONICAL_STYLESHEET));
53240
53272
  const digest = (0, import_node_crypto5.createHash)("sha256").update(body2).digest("hex").slice(0, ETAG_DIGEST_LENGTH2);
53241
53273
  const etag = `W/"canonical-base-${digest}"`;
53242
53274
  return (req, res) => {
@@ -53275,9 +53307,15 @@ function matchesIfNoneMatch2(header, etag) {
53275
53307
  );
53276
53308
  }
53277
53309
 
53310
+ // ../server/src/sandbox-header.ts
53311
+ var SANDBOX_POLICY = "sandbox allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads";
53312
+ function applySandboxHeader(res) {
53313
+ res.setHeader("Content-Security-Policy", SANDBOX_POLICY);
53314
+ }
53315
+
53278
53316
  // ../server/src/logger.ts
53279
- var import_node_fs9 = require("node:fs");
53280
- var import_node_path10 = __toESM(require("node:path"), 1);
53317
+ var import_node_fs10 = require("node:fs");
53318
+ var import_node_path11 = __toESM(require("node:path"), 1);
53281
53319
  var LOG_DIR_NAME = "logs";
53282
53320
  var ACTIVE_LOG_FILE = "tv.log";
53283
53321
  var LOG_RETENTION_DAYS = 14;
@@ -53293,9 +53331,9 @@ var ROTATION_LOCK_TIMEOUT_MS = 5e3;
53293
53331
  var INT32_BYTES = 4;
53294
53332
  function log(storagePath, msg, data) {
53295
53333
  try {
53296
- const logsDir = import_node_path10.default.join(storagePath, LOG_DIR_NAME);
53297
- (0, import_node_fs9.mkdirSync)(logsDir, { recursive: true });
53298
- const logPath = import_node_path10.default.join(logsDir, ACTIVE_LOG_FILE);
53334
+ const logsDir = import_node_path11.default.join(storagePath, LOG_DIR_NAME);
53335
+ (0, import_node_fs10.mkdirSync)(logsDir, { recursive: true });
53336
+ const logPath = import_node_path11.default.join(logsDir, ACTIVE_LOG_FILE);
53299
53337
  rotateIfStale(logsDir, logPath);
53300
53338
  const record2 = {
53301
53339
  ts: localTimestamp(/* @__PURE__ */ new Date()),
@@ -53303,7 +53341,7 @@ function log(storagePath, msg, data) {
53303
53341
  msg,
53304
53342
  ...serializeData(data)
53305
53343
  };
53306
- (0, import_node_fs9.appendFileSync)(logPath, `${JSON.stringify(record2)}
53344
+ (0, import_node_fs10.appendFileSync)(logPath, `${JSON.stringify(record2)}
53307
53345
  `, { encoding: "utf8" });
53308
53346
  } catch (error48) {
53309
53347
  const message = error48 instanceof Error ? error48.message : String(error48);
@@ -53326,21 +53364,21 @@ function serializeError(error48) {
53326
53364
  return { name: "NonError", message: String(error48) };
53327
53365
  }
53328
53366
  function rotateIfStale(logsDir, logPath) {
53329
- const lockPath = import_node_path10.default.join(logsDir, ROTATION_LOCK_DIR);
53367
+ const lockPath = import_node_path11.default.join(logsDir, ROTATION_LOCK_DIR);
53330
53368
  if (!acquireRotationLock(lockPath)) return;
53331
53369
  try {
53332
53370
  let stats;
53333
53371
  try {
53334
- stats = (0, import_node_fs9.statSync)(logPath);
53372
+ stats = (0, import_node_fs10.statSync)(logPath);
53335
53373
  } catch (error48) {
53336
53374
  if (error48.code === "ENOENT") return;
53337
53375
  throw error48;
53338
53376
  }
53339
53377
  if (!isPreviousLocalCalendarDay(stats.mtime, /* @__PURE__ */ new Date())) return;
53340
53378
  const archiveDate = localDateString(stats.mtime);
53341
- const archivePath = uniqueArchivePath(import_node_path10.default.join(logsDir, `${ACTIVE_LOG_FILE}.${archiveDate}`));
53379
+ const archivePath = uniqueArchivePath(import_node_path11.default.join(logsDir, `${ACTIVE_LOG_FILE}.${archiveDate}`));
53342
53380
  try {
53343
- (0, import_node_fs9.renameSync)(logPath, archivePath);
53381
+ (0, import_node_fs10.renameSync)(logPath, archivePath);
53344
53382
  } catch (error48) {
53345
53383
  if (error48.code === "ENOENT") return;
53346
53384
  throw error48;
@@ -53354,7 +53392,7 @@ function acquireRotationLock(lockPath) {
53354
53392
  const deadline = Date.now() + ROTATION_LOCK_TIMEOUT_MS;
53355
53393
  while (true) {
53356
53394
  try {
53357
- (0, import_node_fs9.mkdirSync)(lockPath);
53395
+ (0, import_node_fs10.mkdirSync)(lockPath);
53358
53396
  return true;
53359
53397
  } catch (error48) {
53360
53398
  if (error48.code !== "EEXIST") throw error48;
@@ -53365,7 +53403,7 @@ function acquireRotationLock(lockPath) {
53365
53403
  }
53366
53404
  function releaseRotationLock(lockPath) {
53367
53405
  try {
53368
- (0, import_node_fs9.rmdirSync)(lockPath);
53406
+ (0, import_node_fs10.rmdirSync)(lockPath);
53369
53407
  } catch {
53370
53408
  }
53371
53409
  }
@@ -53373,21 +53411,21 @@ function sleepSync(ms) {
53373
53411
  Atomics.wait(new Int32Array(new SharedArrayBuffer(INT32_BYTES)), 0, 0, ms);
53374
53412
  }
53375
53413
  function uniqueArchivePath(basePath) {
53376
- if (!(0, import_node_fs9.existsSync)(basePath)) return basePath;
53414
+ if (!(0, import_node_fs10.existsSync)(basePath)) return basePath;
53377
53415
  for (let index = 1; ; index += 1) {
53378
53416
  const candidate = `${basePath}-${index}`;
53379
- if (!(0, import_node_fs9.existsSync)(candidate)) return candidate;
53417
+ if (!(0, import_node_fs10.existsSync)(candidate)) return candidate;
53380
53418
  }
53381
53419
  }
53382
53420
  function removeExpiredArchives(logsDir, retainedArchivePath) {
53383
53421
  const cutoff = Date.now() - LOG_RETENTION_DAYS * MS_PER_DAY;
53384
- for (const entry of (0, import_node_fs9.readdirSync)(logsDir, { withFileTypes: true })) {
53422
+ for (const entry of (0, import_node_fs10.readdirSync)(logsDir, { withFileTypes: true })) {
53385
53423
  if (!entry.isFile() || !entry.name.startsWith(`${ACTIVE_LOG_FILE}.`)) continue;
53386
- const fullPath = import_node_path10.default.join(logsDir, entry.name);
53424
+ const fullPath = import_node_path11.default.join(logsDir, entry.name);
53387
53425
  if (fullPath === retainedArchivePath) continue;
53388
53426
  try {
53389
- if ((0, import_node_fs9.statSync)(fullPath).mtime.getTime() < cutoff) {
53390
- (0, import_node_fs9.rmSync)(fullPath, { force: true });
53427
+ if ((0, import_node_fs10.statSync)(fullPath).mtime.getTime() < cutoff) {
53428
+ (0, import_node_fs10.rmSync)(fullPath, { force: true });
53391
53429
  }
53392
53430
  } catch {
53393
53431
  }
@@ -53641,7 +53679,7 @@ function safeEmit(callback) {
53641
53679
  // ../server/src/telemetry/identity.ts
53642
53680
  var import_node_crypto6 = require("node:crypto");
53643
53681
  var import_promises4 = require("node:fs/promises");
53644
- var import_node_path11 = __toESM(require("node:path"), 1);
53682
+ var import_node_path12 = __toESM(require("node:path"), 1);
53645
53683
  var TELEMETRY_STATE_SCHEMA_VERSION = 1;
53646
53684
  var SEMVER_MAJOR_CAPTURE_INDEX = 1;
53647
53685
  var SEMVER_MINOR_CAPTURE_INDEX = 2;
@@ -53658,7 +53696,7 @@ async function readTelemetryState(storagePath) {
53658
53696
  }
53659
53697
  async function writeTelemetryState(storagePath, state) {
53660
53698
  const statePath = getTelemetryStatePath(storagePath);
53661
- await (0, import_promises4.mkdir)(import_node_path11.default.dirname(statePath), { recursive: true });
53699
+ await (0, import_promises4.mkdir)(import_node_path12.default.dirname(statePath), { recursive: true });
53662
53700
  const tempPath = `${statePath}.${process.pid}.${Date.now()}.tmp`;
53663
53701
  await (0, import_promises4.writeFile)(tempPath, `${JSON.stringify(state, null, 2)}
53664
53702
  `, "utf8");
@@ -53849,9 +53887,9 @@ function classifyVersions(properties = {}) {
53849
53887
  }
53850
53888
 
53851
53889
  // ../server/src/telemetry/posthog-config.ts
53852
- var import_node_fs10 = require("node:fs");
53890
+ var import_node_fs11 = require("node:fs");
53853
53891
  var import_node_os5 = __toESM(require("node:os"), 1);
53854
- var import_node_path12 = __toESM(require("node:path"), 1);
53892
+ var import_node_path13 = __toESM(require("node:path"), 1);
53855
53893
  var POSTHOG_US_INGESTION_HOST = "https://us.i.posthog.com";
53856
53894
  var POSTHOG_US_API_HOST = "https://us.posthog.com";
53857
53895
  var POSTHOG_PRODUCTION_PROJECT_ID = 482022;
@@ -53880,7 +53918,7 @@ function resolveTelemetryDeveloperHome(env = process.env) {
53880
53918
  }
53881
53919
  function detectTelemetryDeveloperHost(homeDir = import_node_os5.default.homedir()) {
53882
53920
  try {
53883
- return (0, import_node_fs10.existsSync)(import_node_path12.default.join(homeDir, ".tv-developer"));
53921
+ return (0, import_node_fs11.existsSync)(import_node_path13.default.join(homeDir, ".tv-developer"));
53884
53922
  } catch {
53885
53923
  return false;
53886
53924
  }
@@ -54221,7 +54259,7 @@ function disabledTelemetryRuntime() {
54221
54259
 
54222
54260
  // ../server/src/updates/version.ts
54223
54261
  function readVersionStamp() {
54224
- if ("1.4.29".length > 0) return "1.4.29";
54262
+ if ("1.5.1".length > 0) return "1.5.1";
54225
54263
  return void 0;
54226
54264
  }
54227
54265
  function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
@@ -54238,7 +54276,7 @@ function resolveRequiredDesktopVersion(baked, env = process.env, stamp = readVer
54238
54276
  }
54239
54277
 
54240
54278
  // ../server/src/required-desktop-version.ts
54241
- var REQUIRED_DESKTOP_VERSION = "1.3.1";
54279
+ var REQUIRED_DESKTOP_VERSION = "1.5.0";
54242
54280
 
54243
54281
  // ../server/src/updates/server-status.ts
54244
54282
  function buildServerStatus(env = process.env, stamp = readVersionStamp(), baked = REQUIRED_DESKTOP_VERSION, update = null) {
@@ -54594,7 +54632,7 @@ function createArtifactRouter() {
54594
54632
  }
54595
54633
 
54596
54634
  // ../server/src/resources/layer.ts
54597
- var import_node_path14 = __toESM(require("node:path"), 1);
54635
+ var import_node_path15 = __toESM(require("node:path"), 1);
54598
54636
 
54599
54637
  // ../server/src/resources/type.ts
54600
54638
  function subscriptionKey(address) {
@@ -54683,8 +54721,8 @@ var JsonStoreType = class {
54683
54721
  return this.host.createStore("json", { description: input.description, usage: input.usage ?? "" }, value);
54684
54722
  }
54685
54723
  /** A read: the value at a path. */
54686
- get(address, path23) {
54687
- const segments = parseJsonPath(path23);
54724
+ get(address, path24) {
54725
+ const segments = parseJsonPath(path24);
54688
54726
  return readResult(this.valueOf(this.host.resolveForRead(address, "json")), segments);
54689
54727
  }
54690
54728
  /**
@@ -54709,8 +54747,8 @@ var JsonStoreType = class {
54709
54747
  if (saved.uncertain !== null) throw saved.uncertain;
54710
54748
  }
54711
54749
  /** A write that adds `value` under a new client-generated key; refused below an array. */
54712
- push(address, path23, key, value) {
54713
- const segments = parseJsonPath(path23);
54750
+ push(address, path24, key, value) {
54751
+ const segments = parseJsonPath(path24);
54714
54752
  if (!isValidKey(key)) throw resourceError("invalid-path", "A push key must be a valid path key.");
54715
54753
  const current = this.valueOf(this.host.resolveForRead(address, "json"));
54716
54754
  if (Array.isArray(readJsonValue(current, segments))) {
@@ -54723,18 +54761,18 @@ var JsonStoreType = class {
54723
54761
  * still equals `expected`; otherwise returns what is there now
54724
54762
  * (specs/arch/resources/json-store.md#^js-arch-transactions).
54725
54763
  */
54726
- compareAndSet(address, path23, expected, value) {
54727
- const segments = parseJsonPath(path23);
54764
+ compareAndSet(address, path24, expected, value) {
54765
+ const segments = parseJsonPath(path24);
54728
54766
  const seen = receivedReadResult(expected);
54729
54767
  validateJsonValue(value);
54730
54768
  const current = readResult(this.valueOf(this.host.resolveForRead(address, "json")), segments);
54731
54769
  if (!sameResult(current, seen)) return { applied: false, current };
54732
- this.write(address, { kind: "set", path: path23, value });
54770
+ this.write(address, { kind: "set", path: path24, value });
54733
54771
  return { applied: true };
54734
54772
  }
54735
54773
  /** A subscription to the value at a path: the current value now, then each change to it. */
54736
- subscribe(address, path23, subscriber) {
54737
- const segments = parseJsonPath(path23);
54774
+ subscribe(address, path24, subscriber) {
54775
+ const segments = parseJsonPath(path24);
54738
54776
  const value = this.valueOf(this.host.resolveForRead(address, "json"));
54739
54777
  const subscription = { segments, last: readResult(value, segments), subscriber };
54740
54778
  const key = subscriptionKey(address);
@@ -54765,36 +54803,36 @@ var JsonStoreType = class {
54765
54803
 
54766
54804
  // ../server/src/resources/storage.ts
54767
54805
  var import_node_crypto8 = require("node:crypto");
54768
- var import_node_fs11 = require("node:fs");
54769
- var import_node_path13 = __toESM(require("node:path"), 1);
54806
+ var import_node_fs12 = require("node:fs");
54807
+ var import_node_path14 = __toESM(require("node:path"), 1);
54770
54808
  function flush(target, flags) {
54771
- const descriptor = (0, import_node_fs11.openSync)(target, flags);
54809
+ const descriptor = (0, import_node_fs12.openSync)(target, flags);
54772
54810
  try {
54773
- (0, import_node_fs11.fsyncSync)(descriptor);
54811
+ (0, import_node_fs12.fsyncSync)(descriptor);
54774
54812
  } finally {
54775
- (0, import_node_fs11.closeSync)(descriptor);
54813
+ (0, import_node_fs12.closeSync)(descriptor);
54776
54814
  }
54777
54815
  }
54778
54816
  var nodeResourceStorageOperations = {
54779
54817
  writeTemporaryFile(filePath, contents) {
54780
- const descriptor = (0, import_node_fs11.openSync)(filePath, "wx");
54818
+ const descriptor = (0, import_node_fs12.openSync)(filePath, "wx");
54781
54819
  try {
54782
- (0, import_node_fs11.writeFileSync)(descriptor, contents);
54820
+ (0, import_node_fs12.writeFileSync)(descriptor, contents);
54783
54821
  } finally {
54784
- (0, import_node_fs11.closeSync)(descriptor);
54822
+ (0, import_node_fs12.closeSync)(descriptor);
54785
54823
  }
54786
54824
  },
54787
54825
  flushFile: (filePath) => flush(filePath, "r+"),
54788
- rename: (fromPath, toPath) => (0, import_node_fs11.renameSync)(fromPath, toPath),
54826
+ rename: (fromPath, toPath) => (0, import_node_fs12.renameSync)(fromPath, toPath),
54789
54827
  flushDirectory: (directoryPath) => flush(directoryPath, "r"),
54790
- deleteFile: (filePath) => (0, import_node_fs11.unlinkSync)(filePath),
54791
- createDirectory: (directoryPath) => (0, import_node_fs11.mkdirSync)(directoryPath),
54792
- removeDirectory: (directoryPath) => (0, import_node_fs11.rmdirSync)(directoryPath),
54793
- readFile: (filePath) => (0, import_node_fs11.readFileSync)(filePath, "utf8"),
54794
- readDirectory: (directoryPath) => (0, import_node_fs11.readdirSync)(directoryPath, { withFileTypes: true }).map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() })),
54828
+ deleteFile: (filePath) => (0, import_node_fs12.unlinkSync)(filePath),
54829
+ createDirectory: (directoryPath) => (0, import_node_fs12.mkdirSync)(directoryPath),
54830
+ removeDirectory: (directoryPath) => (0, import_node_fs12.rmdirSync)(directoryPath),
54831
+ readFile: (filePath) => (0, import_node_fs12.readFileSync)(filePath, "utf8"),
54832
+ readDirectory: (directoryPath) => (0, import_node_fs12.readdirSync)(directoryPath, { withFileTypes: true }).map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() })),
54795
54833
  exists(targetPath) {
54796
54834
  try {
54797
- (0, import_node_fs11.statSync)(targetPath);
54835
+ (0, import_node_fs12.statSync)(targetPath);
54798
54836
  return true;
54799
54837
  } catch (error48) {
54800
54838
  if (error48.code === "ENOENT") return false;
@@ -54810,8 +54848,8 @@ function isTemporaryFileName(name) {
54810
54848
  var UncertainWriteError = class extends Error {
54811
54849
  };
54812
54850
  function rewriteFile(storage, filePath, contents) {
54813
- const directory = import_node_path13.default.dirname(filePath);
54814
- const temporaryPath = import_node_path13.default.join(directory, `.${import_node_path13.default.basename(filePath)}.tmp-${(0, import_node_crypto8.randomBytes)(TEMPORARY_SUFFIX_BYTES).toString("hex")}`);
54851
+ const directory = import_node_path14.default.dirname(filePath);
54852
+ const temporaryPath = import_node_path14.default.join(directory, `.${import_node_path14.default.basename(filePath)}.tmp-${(0, import_node_crypto8.randomBytes)(TEMPORARY_SUFFIX_BYTES).toString("hex")}`);
54815
54853
  let renamed = false;
54816
54854
  try {
54817
54855
  storage.writeTemporaryFile(temporaryPath, contents);
@@ -54837,20 +54875,20 @@ function deleteFile(storage, filePath) {
54837
54875
  if (error48.code !== "ENOENT") throw error48;
54838
54876
  }
54839
54877
  try {
54840
- storage.flushDirectory(import_node_path13.default.dirname(filePath));
54878
+ storage.flushDirectory(import_node_path14.default.dirname(filePath));
54841
54879
  } catch (error48) {
54842
54880
  throw new UncertainWriteError(`the deletion may not have reached the disk: ${errorMessage2(error48)}`, { cause: error48 });
54843
54881
  }
54844
54882
  }
54845
54883
  function createDirectories(storage, root, directoryPath) {
54846
- const relative = import_node_path13.default.relative(root, directoryPath);
54847
- if (relative === "" || relative.startsWith("..") || import_node_path13.default.isAbsolute(relative)) {
54884
+ const relative = import_node_path14.default.relative(root, directoryPath);
54885
+ if (relative === "" || relative.startsWith("..") || import_node_path14.default.isAbsolute(relative)) {
54848
54886
  throw new Error(`${directoryPath} is not inside ${root}`);
54849
54887
  }
54850
54888
  let current = root;
54851
- for (const segment of relative.split(import_node_path13.default.sep)) {
54889
+ for (const segment of relative.split(import_node_path14.default.sep)) {
54852
54890
  const parent = current;
54853
- current = import_node_path13.default.join(current, segment);
54891
+ current = import_node_path14.default.join(current, segment);
54854
54892
  if (storage.exists(current)) continue;
54855
54893
  storage.createDirectory(current);
54856
54894
  try {
@@ -54863,7 +54901,7 @@ function createDirectories(storage, root, directoryPath) {
54863
54901
  function removeDirectory(storage, directoryPath) {
54864
54902
  storage.removeDirectory(directoryPath);
54865
54903
  try {
54866
- storage.flushDirectory(import_node_path13.default.dirname(directoryPath));
54904
+ storage.flushDirectory(import_node_path14.default.dirname(directoryPath));
54867
54905
  } catch (error48) {
54868
54906
  throw new UncertainWriteError(`the removal may not have reached the disk: ${errorMessage2(error48)}`, { cause: error48 });
54869
54907
  }
@@ -55039,7 +55077,7 @@ var ResourceLayer = class {
55039
55077
  * bindings file are removed.
55040
55078
  */
55041
55079
  load() {
55042
- const stateDir = import_node_path14.default.dirname(this.bindingsPath);
55080
+ const stateDir = import_node_path15.default.dirname(this.bindingsPath);
55043
55081
  let entries = [];
55044
55082
  try {
55045
55083
  if (this.storage.exists(stateDir)) entries = this.storage.readDirectory(stateDir).map((entry) => entry.name);
@@ -55047,11 +55085,11 @@ var ResourceLayer = class {
55047
55085
  console.warn(`Could not look for leftover temporary files in ${stateDir}: ${errorMessage2(error48)}`);
55048
55086
  }
55049
55087
  for (const entry of entries) {
55050
- if (isTemporaryFileName(entry) && entry.startsWith(`.${import_node_path14.default.basename(this.bindingsPath)}.`)) {
55088
+ if (isTemporaryFileName(entry) && entry.startsWith(`.${import_node_path15.default.basename(this.bindingsPath)}.`)) {
55051
55089
  try {
55052
- this.storage.deleteFile(import_node_path14.default.join(stateDir, entry));
55090
+ this.storage.deleteFile(import_node_path15.default.join(stateDir, entry));
55053
55091
  } catch (error48) {
55054
- console.warn(`Could not remove the leftover temporary file ${import_node_path14.default.join(stateDir, entry)}: ${errorMessage2(error48)}`);
55092
+ console.warn(`Could not remove the leftover temporary file ${import_node_path15.default.join(stateDir, entry)}: ${errorMessage2(error48)}`);
55055
55093
  }
55056
55094
  }
55057
55095
  }
@@ -55098,7 +55136,7 @@ var ResourceLayer = class {
55098
55136
  const found = [];
55099
55137
  for (const type of RESOURCE_TYPES) {
55100
55138
  if (!this.types.has(type)) continue;
55101
- const directory = import_node_path14.default.join(this.storagePath, "resources", type);
55139
+ const directory = import_node_path15.default.join(this.storagePath, "resources", type);
55102
55140
  let entries;
55103
55141
  try {
55104
55142
  if (!this.storage.exists(directory)) continue;
@@ -55469,7 +55507,7 @@ var ResourceLayer = class {
55469
55507
  saveContent(resourceID, content) {
55470
55508
  const record2 = this.stores.get(resourceID);
55471
55509
  const implementation = this.types.get(record2.type);
55472
- const filePath = import_node_path14.default.join(this.storeDirectory(record2.type, resourceID), implementation.contentFileName);
55510
+ const filePath = import_node_path15.default.join(this.storeDirectory(record2.type, resourceID), implementation.contentFileName);
55473
55511
  const text = implementation.serializeContent(content);
55474
55512
  const label = `${record2.type === "json" ? "writing to JSON store" : "writing to resource"} ${resourceID}`;
55475
55513
  try {
@@ -55573,13 +55611,13 @@ var ResourceLayer = class {
55573
55611
  for (const { name: entry } of this.storage.readDirectory(directory)) {
55574
55612
  if (!isTemporaryFileName(entry)) continue;
55575
55613
  try {
55576
- this.storage.deleteFile(import_node_path14.default.join(directory, entry));
55614
+ this.storage.deleteFile(import_node_path15.default.join(directory, entry));
55577
55615
  } catch (error48) {
55578
- console.warn(`Could not remove the leftover temporary file ${import_node_path14.default.join(directory, entry)}: ${errorMessage2(error48)}`);
55616
+ console.warn(`Could not remove the leftover temporary file ${import_node_path15.default.join(directory, entry)}: ${errorMessage2(error48)}`);
55579
55617
  }
55580
55618
  }
55581
- const manifestText = readIfExists(this.storage, import_node_path14.default.join(directory, "manifest.json"));
55582
- const contentText = readIfExists(this.storage, import_node_path14.default.join(directory, implementation.contentFileName));
55619
+ const manifestText = readIfExists(this.storage, import_node_path15.default.join(directory, "manifest.json"));
55620
+ const contentText = readIfExists(this.storage, import_node_path15.default.join(directory, implementation.contentFileName));
55583
55621
  if (manifestText !== null) {
55584
55622
  record2.manifest = parseManifest(manifestText);
55585
55623
  if (record2.manifest === null) record2.unavailableReason = "its manifest is not valid";
@@ -55629,7 +55667,7 @@ var ResourceLayer = class {
55629
55667
  * state from before stands.
55630
55668
  */
55631
55669
  saveManifest(record2, manifest, change) {
55632
- const filePath = import_node_path14.default.join(this.storeDirectory(record2.type, record2.resourceID), "manifest.json");
55670
+ const filePath = import_node_path15.default.join(this.storeDirectory(record2.type, record2.resourceID), "manifest.json");
55633
55671
  try {
55634
55672
  rewriteFile(this.storage, filePath, serializeManifest(manifest));
55635
55673
  } catch (error48) {
@@ -55731,7 +55769,7 @@ var ResourceLayer = class {
55731
55769
  firstStoreFile(directory) {
55732
55770
  if (!this.storage.exists(directory)) return null;
55733
55771
  const entries = this.storage.readDirectory(directory).map((entry) => entry.name).sort((left, right) => left === "manifest.json" ? 1 : right === "manifest.json" ? -1 : compareStrings(left, right));
55734
- return entries.length === 0 ? null : import_node_path14.default.join(directory, entries[0]);
55772
+ return entries.length === 0 ? null : import_node_path15.default.join(directory, entries[0]);
55735
55773
  }
55736
55774
  /** Removes what a failed creation left, as far as it can. */
55737
55775
  removeIncompleteStore(directory) {
@@ -55852,10 +55890,10 @@ var ResourceLayer = class {
55852
55890
  }
55853
55891
  }
55854
55892
  storeDirectory(type, resourceID) {
55855
- return import_node_path14.default.join(this.storagePath, "resources", type, resourceID);
55893
+ return import_node_path15.default.join(this.storagePath, "resources", type, resourceID);
55856
55894
  }
55857
55895
  get bindingsPath() {
55858
- return import_node_path14.default.join(this.storagePath, "state", "resource-bindings.json");
55896
+ return import_node_path15.default.join(this.storagePath, "state", "resource-bindings.json");
55859
55897
  }
55860
55898
  };
55861
55899
 
@@ -56097,11 +56135,11 @@ var PageConnectionServer = class {
56097
56135
  this.byID.set(id, connections);
56098
56136
  send2({ type: "open", serverTime: Date.now(), ...pageAccess() });
56099
56137
  };
56100
- const subscribe = (subscriptionID, resourceID, path23) => {
56138
+ const subscribe = (subscriptionID, resourceID, path24) => {
56101
56139
  subscriptions.get(subscriptionID)?.unsubscribe();
56102
56140
  subscriptions.delete(subscriptionID);
56103
56141
  try {
56104
- const unsubscribe = layer.json.subscribe(target(resourceID, "subscribe"), path23, {
56142
+ const unsubscribe = layer.json.subscribe(target(resourceID, "subscribe"), path24, {
56105
56143
  onValue: (result) => send2({ type: "value", id: subscriptionID, result, seq: highestHandled }),
56106
56144
  // Only a store addressed by its resource ID ends: one through the
56107
56145
  // artifact follows its pointer, across a destroy and the next first write.
@@ -56189,20 +56227,23 @@ var PageConnectionServer = class {
56189
56227
  };
56190
56228
 
56191
56229
  // ../server/src/resources/sdk-route.ts
56192
- var import_node_path15 = __toESM(require("node:path"), 1);
56230
+ var import_node_path16 = __toESM(require("node:path"), 1);
56193
56231
  var SDK_ROUTE = "/sdk/v1/resources.js";
56194
56232
  var SDK_NOTICES_ROUTE = "/sdk/v1/THIRD-PARTY-NOTICES.txt";
56195
56233
  function serveResourceSdk(sdkDir) {
56196
- return serveSdkFile(import_node_path15.default.resolve(sdkDir, "v1", "resources.js"), "text/javascript; charset=utf-8");
56234
+ return serveSdkFile(import_node_path16.default.resolve(sdkDir, "v1", "resources.js"), "text/javascript; charset=utf-8");
56197
56235
  }
56198
56236
  function serveResourceSdkNotices(sdkDir) {
56199
- return serveSdkFile(import_node_path15.default.resolve(sdkDir, "v1", "THIRD-PARTY-NOTICES.txt"), "text/plain; charset=utf-8");
56237
+ return serveSdkFile(import_node_path16.default.resolve(sdkDir, "v1", "THIRD-PARTY-NOTICES.txt"), "text/plain; charset=utf-8");
56200
56238
  }
56201
56239
  function serveSdkFile(file2, contentType) {
56202
56240
  return (_req, res, next) => {
56203
56241
  res.sendFile(
56204
56242
  file2,
56205
- { cacheControl: false, headers: { "Content-Type": contentType, "Cache-Control": "no-cache" } },
56243
+ {
56244
+ cacheControl: false,
56245
+ headers: { "Content-Type": contentType, "Cache-Control": "no-cache", "Access-Control-Allow-Origin": "*" }
56246
+ },
56206
56247
  (error48) => {
56207
56248
  if (error48 && !res.headersSent) next(error48);
56208
56249
  }
@@ -56223,15 +56264,15 @@ function errorStatus(error48) {
56223
56264
  }
56224
56265
  var CANONICAL_VERSION_DIRECTORY_PATTERN = /^v\d+(?:\.\d+)?$/;
56225
56266
  function resolveCanonicalVersionDirectories(canonicalDir) {
56226
- const canonicalRoot = import_node_path16.default.resolve(canonicalDir);
56227
- const versions = (0, import_node_fs12.readdirSync)(canonicalRoot, { withFileTypes: true }).filter(
56267
+ const canonicalRoot = import_node_path17.default.resolve(canonicalDir);
56268
+ const versions = (0, import_node_fs13.readdirSync)(canonicalRoot, { withFileTypes: true }).filter(
56228
56269
  (entry) => entry.isDirectory() && CANONICAL_VERSION_DIRECTORY_PATTERN.test(entry.name)
56229
56270
  ).map((entry) => {
56230
- const directory = import_node_path16.default.join(canonicalRoot, entry.name);
56271
+ const directory = import_node_path17.default.join(canonicalRoot, entry.name);
56231
56272
  return {
56232
56273
  version: entry.name,
56233
56274
  directory,
56234
- frozen: (0, import_node_fs12.existsSync)(import_node_path16.default.join(directory, "frozen.json"))
56275
+ frozen: (0, import_node_fs13.existsSync)(import_node_path17.default.join(directory, "frozen.json"))
56235
56276
  };
56236
56277
  }).sort(
56237
56278
  (left, right) => left.version.localeCompare(right.version, void 0, { numeric: true })
@@ -56284,6 +56325,10 @@ var Server = class {
56284
56325
  res.setHeader("X-TV-Version", updateReleaseVersion);
56285
56326
  next();
56286
56327
  });
56328
+ this.app.use(["/artifact", "/theme"], (_req, res, next) => {
56329
+ applySandboxHeader(res);
56330
+ next();
56331
+ });
56287
56332
  this.app.get("/health", (_req, res) => {
56288
56333
  res.json({
56289
56334
  status: "ok",
@@ -56360,7 +56405,7 @@ var Server = class {
56360
56405
  import_express4.default.static(directory, {
56361
56406
  setHeaders: (res, filePath) => {
56362
56407
  if (filePath.startsWith(
56363
- `${import_node_path16.default.resolve(directory, "fonts")}${import_node_path16.default.sep}`
56408
+ `${import_node_path17.default.resolve(directory, "fonts")}${import_node_path17.default.sep}`
56364
56409
  )) {
56365
56410
  res.setHeader(
56366
56411
  "Cache-Control",
@@ -56378,7 +56423,10 @@ var Server = class {
56378
56423
  for (const viewID of ["artifact-missing", "markdown"]) {
56379
56424
  const viewPath = this.store.getViewPath(viewID);
56380
56425
  if (viewPath) {
56381
- this.app.use(`/views/${viewID}`, import_express4.default.static(viewPath));
56426
+ const crossOrigin = viewID === "artifact-missing";
56427
+ this.app.use(`/views/${viewID}`, import_express4.default.static(viewPath, {
56428
+ setHeaders: crossOrigin ? (res) => res.setHeader("Access-Control-Allow-Origin", "*") : void 0
56429
+ }));
56382
56430
  }
56383
56431
  }
56384
56432
  if (options.staticDir) {
@@ -56387,7 +56435,7 @@ var Server = class {
56387
56435
  if (filePath.endsWith(".html") || filePath.endsWith(".htm")) {
56388
56436
  res.setHeader("Referrer-Policy", "no-referrer");
56389
56437
  res.setHeader("Cache-Control", "no-cache");
56390
- } else if (filePath.includes(`${import_node_path16.default.sep}assets${import_node_path16.default.sep}`)) {
56438
+ } else if (filePath.includes(`${import_node_path17.default.sep}assets${import_node_path17.default.sep}`)) {
56391
56439
  res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
56392
56440
  }
56393
56441
  }
@@ -56635,22 +56683,22 @@ var Server = class {
56635
56683
  };
56636
56684
  };
56637
56685
  function readServerPackageVersion() {
56638
- if ("1.4.29".length > 0) {
56639
- return telemetryVersion("1.4.29");
56686
+ if ("1.5.1".length > 0) {
56687
+ return telemetryVersion("1.5.1");
56640
56688
  }
56641
- const packageJsonPath = import_node_path16.default.resolve(import_node_path16.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
56642
- if (!(0, import_node_fs12.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
56643
- return telemetryVersion(JSON.parse((0, import_node_fs12.readFileSync)(packageJsonPath, "utf8")).version);
56689
+ const packageJsonPath = import_node_path17.default.resolve(import_node_path17.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
56690
+ if (!(0, import_node_fs13.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
56691
+ return telemetryVersion(JSON.parse((0, import_node_fs13.readFileSync)(packageJsonPath, "utf8")).version);
56644
56692
  }
56645
56693
 
56646
56694
  // ../server/src/server-store.ts
56647
- var import_node_fs18 = require("node:fs");
56648
- var import_node_path22 = __toESM(require("node:path"), 1);
56695
+ var import_node_fs19 = require("node:fs");
56696
+ var import_node_path23 = __toESM(require("node:path"), 1);
56649
56697
 
56650
56698
  // ../server/src/file-watcher.ts
56651
56699
  var import_node_events = require("node:events");
56652
- var fs3 = __toESM(require("node:fs"), 1);
56653
- var import_node_path17 = __toESM(require("node:path"), 1);
56700
+ var fs4 = __toESM(require("node:fs"), 1);
56701
+ var import_node_path18 = __toESM(require("node:path"), 1);
56654
56702
  var DEFAULT_REARM_INTERVAL_MS = 250;
56655
56703
  function isMissingWatchRootError(error48) {
56656
56704
  return typeof error48 === "object" && error48 !== null && "code" in error48 && error48.code === "ENOENT";
@@ -56672,9 +56720,9 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
56672
56720
  constructor(contentPath, onChange, options = {}) {
56673
56721
  super();
56674
56722
  this.#recursive = options.recursive === true;
56675
- this.#dir = this.#recursive ? contentPath : import_node_path17.default.dirname(contentPath);
56676
- this.#watchedBasename = import_node_path17.default.basename(contentPath);
56677
- this.#watchRootBasename = import_node_path17.default.basename(import_node_path17.default.normalize(this.#dir));
56723
+ this.#dir = this.#recursive ? contentPath : import_node_path18.default.dirname(contentPath);
56724
+ this.#watchedBasename = import_node_path18.default.basename(contentPath);
56725
+ this.#watchRootBasename = import_node_path18.default.basename(import_node_path18.default.normalize(this.#dir));
56678
56726
  this.#onChange = onChange;
56679
56727
  this.#options = options;
56680
56728
  try {
@@ -56703,7 +56751,7 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
56703
56751
  this.#closeActiveWatchers();
56704
56752
  }
56705
56753
  #attach() {
56706
- const watcher = fs3.watch(this.#dir, { recursive: this.#recursive }, (_event, filename) => {
56754
+ const watcher = fs4.watch(this.#dir, { recursive: this.#recursive }, (_event, filename) => {
56707
56755
  const relativePath = filename?.toString();
56708
56756
  const isWatchRootEvent = relativePath === void 0 || relativePath === "" || relativePath === this.#watchRootBasename;
56709
56757
  if (this.#recursive) {
@@ -56732,9 +56780,9 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
56732
56780
  });
56733
56781
  const ancestorWatchers = [];
56734
56782
  for (const ancestorDir of this.#ancestorDirs()) {
56735
- const ancestorBasename = import_node_path17.default.basename(import_node_path17.default.normalize(ancestorDir));
56783
+ const ancestorBasename = import_node_path18.default.basename(import_node_path18.default.normalize(ancestorDir));
56736
56784
  try {
56737
- const ancestorWatcher = fs3.watch(ancestorDir, (_event, filename) => {
56785
+ const ancestorWatcher = fs4.watch(ancestorDir, (_event, filename) => {
56738
56786
  const basename = filename?.toString();
56739
56787
  if (basename === void 0 || basename === "" || basename === ancestorBasename) {
56740
56788
  this.#handleWatchRootEvent();
@@ -56799,10 +56847,10 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
56799
56847
  }
56800
56848
  #ancestorDirs() {
56801
56849
  const ancestors = [];
56802
- let current = import_node_path17.default.dirname(this.#dir);
56803
- while (current !== import_node_path17.default.dirname(current)) {
56850
+ let current = import_node_path18.default.dirname(this.#dir);
56851
+ while (current !== import_node_path18.default.dirname(current)) {
56804
56852
  ancestors.push(current);
56805
- current = import_node_path17.default.dirname(current);
56853
+ current = import_node_path18.default.dirname(current);
56806
56854
  }
56807
56855
  return ancestors;
56808
56856
  }
@@ -56816,7 +56864,7 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
56816
56864
  }
56817
56865
  #isWatchRootPresent() {
56818
56866
  try {
56819
- return fs3.statSync(this.#dir).isDirectory();
56867
+ return fs4.statSync(this.#dir).isDirectory();
56820
56868
  } catch {
56821
56869
  return false;
56822
56870
  }
@@ -56859,8 +56907,8 @@ var defaultWatchContentFile = (contentPath, onChange, options) => {
56859
56907
  };
56860
56908
 
56861
56909
  // ../server/src/redesign-storage-migration.ts
56862
- var import_node_fs14 = require("node:fs");
56863
- var import_node_path18 = __toESM(require("node:path"), 1);
56910
+ var import_node_fs15 = require("node:fs");
56911
+ var import_node_path19 = __toESM(require("node:path"), 1);
56864
56912
 
56865
56913
  // ../server/src/redesign-record-migration.ts
56866
56914
  function convertStoredChannelRecord(record2) {
@@ -56935,7 +56983,7 @@ function newestChannelId(channelIds) {
56935
56983
  }
56936
56984
 
56937
56985
  // ../server/src/storage-name-migration.ts
56938
- var import_node_fs13 = require("node:fs");
56986
+ var import_node_fs14 = require("node:fs");
56939
56987
  var JSON_INDENT_SPACES2 = 2;
56940
56988
  function isActiveID(value) {
56941
56989
  return typeof value === "string" || value === null;
@@ -56946,23 +56994,23 @@ function isThemeName(value) {
56946
56994
  function migrateChannelMetadataDirectory(storagePath) {
56947
56995
  const legacyDir = getLegacyScreensDir(storagePath);
56948
56996
  const currentDir = getChannelsDir(storagePath);
56949
- const legacyExists = (0, import_node_fs13.existsSync)(legacyDir);
56950
- const currentExists = (0, import_node_fs13.existsSync)(currentDir);
56997
+ const legacyExists = (0, import_node_fs14.existsSync)(legacyDir);
56998
+ const currentExists = (0, import_node_fs14.existsSync)(currentDir);
56951
56999
  if (!legacyExists) {
56952
57000
  return;
56953
57001
  }
56954
57002
  if (!currentExists) {
56955
- (0, import_node_fs13.renameSync)(legacyDir, currentDir);
57003
+ (0, import_node_fs14.renameSync)(legacyDir, currentDir);
56956
57004
  return;
56957
57005
  }
56958
- const legacyEntries = (0, import_node_fs13.readdirSync)(legacyDir);
56959
- const currentEntries = (0, import_node_fs13.readdirSync)(currentDir);
57006
+ const legacyEntries = (0, import_node_fs14.readdirSync)(legacyDir);
57007
+ const currentEntries = (0, import_node_fs14.readdirSync)(currentDir);
56960
57008
  if (legacyEntries.length === 0) {
56961
- (0, import_node_fs13.rmdirSync)(legacyDir);
57009
+ (0, import_node_fs14.rmdirSync)(legacyDir);
56962
57010
  return;
56963
57011
  }
56964
57012
  if (currentEntries.length === 0) {
56965
- (0, import_node_fs13.renameSync)(legacyDir, currentDir);
57013
+ (0, import_node_fs14.renameSync)(legacyDir, currentDir);
56966
57014
  return;
56967
57015
  }
56968
57016
  throw new Error(
@@ -56971,12 +57019,12 @@ function migrateChannelMetadataDirectory(storagePath) {
56971
57019
  }
56972
57020
  function migrateDisplayStateField(storagePath) {
56973
57021
  const displayPath = getDisplayStatePath(storagePath);
56974
- if (!(0, import_node_fs13.existsSync)(displayPath)) {
57022
+ if (!(0, import_node_fs14.existsSync)(displayPath)) {
56975
57023
  return;
56976
57024
  }
56977
57025
  let parsed;
56978
57026
  try {
56979
- parsed = JSON.parse((0, import_node_fs13.readFileSync)(displayPath, "utf8"));
57027
+ parsed = JSON.parse((0, import_node_fs14.readFileSync)(displayPath, "utf8"));
56980
57028
  } catch {
56981
57029
  return;
56982
57030
  }
@@ -57017,8 +57065,8 @@ function migrateDisplayStateField(storagePath) {
57017
57065
  next[key] = value;
57018
57066
  }
57019
57067
  const temporaryPath = getDisplayMigrationTempPath(storagePath);
57020
- (0, import_node_fs13.writeFileSync)(temporaryPath, JSON.stringify(next, null, JSON_INDENT_SPACES2));
57021
- (0, import_node_fs13.renameSync)(temporaryPath, displayPath);
57068
+ (0, import_node_fs14.writeFileSync)(temporaryPath, JSON.stringify(next, null, JSON_INDENT_SPACES2));
57069
+ (0, import_node_fs14.renameSync)(temporaryPath, displayPath);
57022
57070
  }
57023
57071
 
57024
57072
  // ../server/src/redesign-storage-migration.ts
@@ -57033,17 +57081,17 @@ function runRedesignStorageMigration(storagePath) {
57033
57081
  migrateDisplayAppearanceMode(storagePath);
57034
57082
  }
57035
57083
  function getRedesignRecordMigrationTempPath(recordPath) {
57036
- return import_node_path18.default.join(import_node_path18.default.dirname(recordPath), `.${import_node_path18.default.basename(recordPath)}.redesign.tmp`);
57084
+ return import_node_path19.default.join(import_node_path19.default.dirname(recordPath), `.${import_node_path19.default.basename(recordPath)}.redesign.tmp`);
57037
57085
  }
57038
57086
  function migrateChannelRecords(storagePath) {
57039
57087
  const channelsDir = getChannelsDir(storagePath);
57040
- if (!(0, import_node_fs14.existsSync)(channelsDir)) {
57088
+ if (!(0, import_node_fs15.existsSync)(channelsDir)) {
57041
57089
  return [];
57042
57090
  }
57043
57091
  const channelIds = [];
57044
- for (const file2 of (0, import_node_fs14.readdirSync)(channelsDir).sort()) {
57092
+ for (const file2 of (0, import_node_fs15.readdirSync)(channelsDir).sort()) {
57045
57093
  if (!file2.endsWith(JSON_FILE_SUFFIX)) continue;
57046
- const recordPath = import_node_path18.default.join(channelsDir, file2);
57094
+ const recordPath = import_node_path19.default.join(channelsDir, file2);
57047
57095
  const parsed = readJSON(recordPath);
57048
57096
  const inspected = inspectChannelRecord(parsed);
57049
57097
  if (inspected === null) continue;
@@ -57059,7 +57107,7 @@ function migrateChannelRecords(storagePath) {
57059
57107
  }
57060
57108
  function migrateDisplayRecord(storagePath, channelIds) {
57061
57109
  const displayPath = getDisplayStatePath(storagePath);
57062
- if (!(0, import_node_fs14.existsSync)(displayPath)) return;
57110
+ if (!(0, import_node_fs15.existsSync)(displayPath)) return;
57063
57111
  const parsed = readJSON(displayPath);
57064
57112
  const record2 = parseConvertibleDisplayRecord(parsed);
57065
57113
  if (record2 === null) return;
@@ -57070,10 +57118,10 @@ function migrateDisplayRecord(storagePath, channelIds) {
57070
57118
  }
57071
57119
  function backfillChannelPageSizes(storagePath) {
57072
57120
  const channelsDir = getChannelsDir(storagePath);
57073
- if (!(0, import_node_fs14.existsSync)(channelsDir)) return;
57074
- for (const file2 of (0, import_node_fs14.readdirSync)(channelsDir).sort()) {
57121
+ if (!(0, import_node_fs15.existsSync)(channelsDir)) return;
57122
+ for (const file2 of (0, import_node_fs15.readdirSync)(channelsDir).sort()) {
57075
57123
  if (!file2.endsWith(JSON_FILE_SUFFIX)) continue;
57076
- const recordPath = import_node_path18.default.join(channelsDir, file2);
57124
+ const recordPath = import_node_path19.default.join(channelsDir, file2);
57077
57125
  const record2 = inspectPageSizeBackfillRecord(readJSON(recordPath));
57078
57126
  if (record2 === null) continue;
57079
57127
  const backfilled = backfillStoredChannelPageSizes(record2);
@@ -57084,7 +57132,7 @@ function backfillChannelPageSizes(storagePath) {
57084
57132
  }
57085
57133
  function migrateDisplayAppearanceMode(storagePath) {
57086
57134
  const displayPath = getDisplayStatePath(storagePath);
57087
- if (!(0, import_node_fs14.existsSync)(displayPath)) return;
57135
+ if (!(0, import_node_fs15.existsSync)(displayPath)) return;
57088
57136
  const record2 = readJSON(displayPath);
57089
57137
  if (!isRecord3(record2) || Object.hasOwn(record2, "appearanceMode")) return;
57090
57138
  if (!isNullableString(record2.focusedChannelId) || !Array.isArray(record2.pinnedChannelIds) || !record2.pinnedChannelIds.every((id) => typeof id === "string") || !isThemeName2(record2.activeThemeName)) {
@@ -57094,11 +57142,11 @@ function migrateDisplayAppearanceMode(storagePath) {
57094
57142
  }
57095
57143
  function writeAtomicJSON(recordPath, value) {
57096
57144
  const temporaryPath = getRedesignRecordMigrationTempPath(recordPath);
57097
- (0, import_node_fs14.writeFileSync)(temporaryPath, JSON.stringify(value, null, JSON_INDENT_SPACES3));
57098
- (0, import_node_fs14.renameSync)(temporaryPath, recordPath);
57145
+ (0, import_node_fs15.writeFileSync)(temporaryPath, JSON.stringify(value, null, JSON_INDENT_SPACES3));
57146
+ (0, import_node_fs15.renameSync)(temporaryPath, recordPath);
57099
57147
  }
57100
57148
  function readJSON(recordPath) {
57101
- const bytes = (0, import_node_fs14.readFileSync)(recordPath, "utf8");
57149
+ const bytes = (0, import_node_fs15.readFileSync)(recordPath, "utf8");
57102
57150
  try {
57103
57151
  return JSON.parse(bytes);
57104
57152
  } catch {
@@ -57191,12 +57239,12 @@ function isRecord3(value) {
57191
57239
  }
57192
57240
 
57193
57241
  // ../server/src/onboarding-installer.ts
57194
- var import_node_fs17 = require("node:fs");
57195
- var import_node_path21 = __toESM(require("node:path"), 1);
57242
+ var import_node_fs18 = require("node:fs");
57243
+ var import_node_path22 = __toESM(require("node:path"), 1);
57196
57244
 
57197
57245
  // ../server/src/onboarding-content.ts
57198
- var import_node_fs15 = require("node:fs");
57199
- var import_node_path19 = __toESM(require("node:path"), 1);
57246
+ var import_node_fs16 = require("node:fs");
57247
+ var import_node_path20 = __toESM(require("node:path"), 1);
57200
57248
  var ONBOARDING_CONFIG_FILENAME = "onboarding-channels.json";
57201
57249
  var ONBOARDING_CONFIG_VERSION = 3;
57202
57250
  var STORE_DECLARATION_FIELDS = ["value", "shiftDatesFrom"];
@@ -57215,10 +57263,10 @@ function isValidOnboardingSlug(slug) {
57215
57263
  return ONBOARDING_SLUG_PATTERN.test(slug) && !slug.includes("--");
57216
57264
  }
57217
57265
  function loadOnboardingConfig(contentRoot) {
57218
- const configPath = import_node_path19.default.join(contentRoot, ONBOARDING_CONFIG_FILENAME);
57266
+ const configPath = import_node_path20.default.join(contentRoot, ONBOARDING_CONFIG_FILENAME);
57219
57267
  let raw;
57220
57268
  try {
57221
- raw = (0, import_node_fs15.readFileSync)(configPath, "utf8");
57269
+ raw = (0, import_node_fs16.readFileSync)(configPath, "utf8");
57222
57270
  } catch (error48) {
57223
57271
  return { errors: [`cannot read ${ONBOARDING_CONFIG_FILENAME}: ${describeError2(error48)}`] };
57224
57272
  }
@@ -57236,15 +57284,15 @@ function loadOnboardingConfig(contentRoot) {
57236
57284
  }
57237
57285
  function resolveOnboardingArtifactSource(contentRoot, channelSlug, artifactSlug) {
57238
57286
  const label = `artifact "${artifactSlug}" in channel "${channelSlug}"`;
57239
- const channelDir = import_node_path19.default.join(contentRoot, channelSlug);
57287
+ const channelDir = import_node_path20.default.join(contentRoot, channelSlug);
57240
57288
  const shapes = [];
57241
57289
  for (const extension2 of [".html", ".md"]) {
57242
- const candidate = import_node_path19.default.join(channelDir, `${artifactSlug}${extension2}`);
57290
+ const candidate = import_node_path20.default.join(channelDir, `${artifactSlug}${extension2}`);
57243
57291
  if (isFile(candidate)) {
57244
57292
  shapes.push({ kind: "file", path: candidate, display: `${artifactSlug}${extension2}` });
57245
57293
  }
57246
57294
  }
57247
- const dirPath = import_node_path19.default.join(channelDir, artifactSlug);
57295
+ const dirPath = import_node_path20.default.join(channelDir, artifactSlug);
57248
57296
  if (isDirectory(dirPath)) {
57249
57297
  shapes.push({ kind: "directory", path: dirPath, display: `${artifactSlug}/` });
57250
57298
  }
@@ -57261,7 +57309,7 @@ function resolveOnboardingArtifactSource(contentRoot, channelSlug, artifactSlug)
57261
57309
  error: `${label} has no source: expected ${artifactSlug}.html, ${artifactSlug}.md, or ${artifactSlug}/`
57262
57310
  };
57263
57311
  }
57264
- if (shape.kind === "directory" && !isFile(import_node_path19.default.join(shape.path, "index.html"))) {
57312
+ if (shape.kind === "directory" && !isFile(import_node_path20.default.join(shape.path, "index.html"))) {
57265
57313
  return { ok: false, error: `${label} is a directory artifact missing index.html at its root` };
57266
57314
  }
57267
57315
  return { ok: true, source: { kind: shape.kind, path: shape.path } };
@@ -57396,18 +57444,18 @@ function refusal2(check2) {
57396
57444
  }
57397
57445
  }
57398
57446
  function isFile(candidate) {
57399
- return (0, import_node_fs15.existsSync)(candidate) && (0, import_node_fs15.statSync)(candidate).isFile();
57447
+ return (0, import_node_fs16.existsSync)(candidate) && (0, import_node_fs16.statSync)(candidate).isFile();
57400
57448
  }
57401
57449
  function isDirectory(candidate) {
57402
- return (0, import_node_fs15.existsSync)(candidate) && (0, import_node_fs15.statSync)(candidate).isDirectory();
57450
+ return (0, import_node_fs16.existsSync)(candidate) && (0, import_node_fs16.statSync)(candidate).isDirectory();
57403
57451
  }
57404
57452
  function describeError2(error48) {
57405
57453
  return error48 instanceof Error ? error48.message : String(error48);
57406
57454
  }
57407
57455
 
57408
57456
  // ../server/src/onboarding-state.ts
57409
- var import_node_fs16 = require("node:fs");
57410
- var import_node_path20 = __toESM(require("node:path"), 1);
57457
+ var import_node_fs17 = require("node:fs");
57458
+ var import_node_path21 = __toESM(require("node:path"), 1);
57411
57459
 
57412
57460
  // ../server/src/onboarding.ts
57413
57461
  var ONBOARDING_ARTIFACT_ID = "television-onboarding";
@@ -57417,7 +57465,7 @@ var JSON_INDENT_SPACES4 = 2;
57417
57465
  var ONBOARDING_STATE_VERSION = 3;
57418
57466
  function readOnboardingStateFile(storagePath) {
57419
57467
  const statePath = getOnboardingStatePath(storagePath);
57420
- if (!(0, import_node_fs16.existsSync)(statePath)) {
57468
+ if (!(0, import_node_fs17.existsSync)(statePath)) {
57421
57469
  return { status: "absent" };
57422
57470
  }
57423
57471
  const parsed = parseJSONFile(statePath);
@@ -57433,7 +57481,7 @@ function readOnboardingStateFile(storagePath) {
57433
57481
  }
57434
57482
  function readLegacyOnboardingFile(storagePath) {
57435
57483
  const legacyPath = getOnboardingArtifactSentinelPath(storagePath);
57436
- if (!(0, import_node_fs16.existsSync)(legacyPath)) {
57484
+ if (!(0, import_node_fs17.existsSync)(legacyPath)) {
57437
57485
  return { status: "absent" };
57438
57486
  }
57439
57487
  const parsed = parseJSONFile(legacyPath);
@@ -57459,17 +57507,17 @@ function readLegacyOnboardingFile(storagePath) {
57459
57507
  }
57460
57508
  function getOnboardingStateTempPath(storagePath) {
57461
57509
  const statePath = getOnboardingStatePath(storagePath);
57462
- return import_node_path20.default.join(import_node_path20.default.dirname(statePath), `.${import_node_path20.default.basename(statePath)}.tmp-${process.pid}`);
57510
+ return import_node_path21.default.join(import_node_path21.default.dirname(statePath), `.${import_node_path21.default.basename(statePath)}.tmp-${process.pid}`);
57463
57511
  }
57464
57512
  function writeOnboardingStateFile(storagePath, state) {
57465
57513
  const statePath = getOnboardingStatePath(storagePath);
57466
57514
  const tempPath = getOnboardingStateTempPath(storagePath);
57467
57515
  try {
57468
- (0, import_node_fs16.writeFileSync)(tempPath, JSON.stringify(state, null, JSON_INDENT_SPACES4));
57469
- (0, import_node_fs16.renameSync)(tempPath, statePath);
57516
+ (0, import_node_fs17.writeFileSync)(tempPath, JSON.stringify(state, null, JSON_INDENT_SPACES4));
57517
+ (0, import_node_fs17.renameSync)(tempPath, statePath);
57470
57518
  } catch (error48) {
57471
57519
  try {
57472
- (0, import_node_fs16.rmSync)(tempPath, { force: true });
57520
+ (0, import_node_fs17.rmSync)(tempPath, { force: true });
57473
57521
  } catch {
57474
57522
  }
57475
57523
  throw error48;
@@ -57478,7 +57526,7 @@ function writeOnboardingStateFile(storagePath, state) {
57478
57526
  function parseJSONFile(filePath) {
57479
57527
  let raw;
57480
57528
  try {
57481
- raw = (0, import_node_fs16.readFileSync)(filePath, "utf8");
57529
+ raw = (0, import_node_fs17.readFileSync)(filePath, "utf8");
57482
57530
  } catch (error48) {
57483
57531
  return { ok: false, error: `cannot read ${filePath}: ${describeError3(error48)}` };
57484
57532
  }
@@ -57654,17 +57702,17 @@ function installChannel(target, contentPath, channelConfig) {
57654
57702
  const copyName = onboardingCopyName(channelConfig.slug, artifactConfig.slug);
57655
57703
  const artifactsDir = getAgentArtifactsDir(target.storagePath);
57656
57704
  if (resolved.source.kind === "file") {
57657
- const destination = import_node_path21.default.join(artifactsDir, `${copyName}${import_node_path21.default.extname(resolved.source.path)}`);
57658
- (0, import_node_fs17.rmSync)(destination, { recursive: true, force: true });
57659
- (0, import_node_fs17.cpSync)(resolved.source.path, destination);
57705
+ const destination = import_node_path22.default.join(artifactsDir, `${copyName}${import_node_path22.default.extname(resolved.source.path)}`);
57706
+ (0, import_node_fs18.rmSync)(destination, { recursive: true, force: true });
57707
+ (0, import_node_fs18.cpSync)(resolved.source.path, destination);
57660
57708
  copies.push({ artifactConfig, destination });
57661
57709
  } else {
57662
- const destinationDir = import_node_path21.default.join(artifactsDir, copyName);
57663
- if ((0, import_node_fs17.existsSync)(destinationDir)) {
57664
- (0, import_node_fs17.rmSync)(destinationDir, { recursive: true, force: true });
57710
+ const destinationDir = import_node_path22.default.join(artifactsDir, copyName);
57711
+ if ((0, import_node_fs18.existsSync)(destinationDir)) {
57712
+ (0, import_node_fs18.rmSync)(destinationDir, { recursive: true, force: true });
57665
57713
  }
57666
- (0, import_node_fs17.cpSync)(resolved.source.path, destinationDir, { recursive: true });
57667
- copies.push({ artifactConfig, destination: destinationDir + import_node_path21.default.sep });
57714
+ (0, import_node_fs18.cpSync)(resolved.source.path, destinationDir, { recursive: true });
57715
+ copies.push({ artifactConfig, destination: destinationDir + import_node_path22.default.sep });
57668
57716
  }
57669
57717
  }
57670
57718
  const installed = copies.map(({ artifactConfig, destination }) => ({
@@ -57724,7 +57772,6 @@ var JSON_INDENT_SPACES5 = 2;
57724
57772
  var LAYOUT_VERSION = 2;
57725
57773
  var CONTENT_WATCH_DEBOUNCE_MS = 100;
57726
57774
  var JSON_FILE_SUFFIX2 = ".json";
57727
- var DIRECTORY_INDEX_BASENAMES = ["index.html", "index.htm"];
57728
57775
  var BUNDLED_VIEW_IDS = /* @__PURE__ */ new Set(["artifact-missing", "markdown"]);
57729
57776
  function isBundledViewID(id) {
57730
57777
  return BUNDLED_VIEW_IDS.has(id);
@@ -57751,9 +57798,9 @@ function hasSameArtifactMetadata(left, right) {
57751
57798
  return left.kind === "path" && right.kind === "path" ? left.path === right.path : left.kind === "url" && right.kind === "url" && left.url === right.url;
57752
57799
  }
57753
57800
  function hasExistingTelevisionDataStructure(storagePath) {
57754
- if ((0, import_node_fs18.existsSync)(getDisplayStatePath(storagePath))) return true;
57755
- if ((0, import_node_fs18.existsSync)(getOnboardingStatePath(storagePath))) return true;
57756
- if ((0, import_node_fs18.existsSync)(getOnboardingArtifactSentinelPath(storagePath))) return true;
57801
+ if ((0, import_node_fs19.existsSync)(getDisplayStatePath(storagePath))) return true;
57802
+ if ((0, import_node_fs19.existsSync)(getOnboardingStatePath(storagePath))) return true;
57803
+ if ((0, import_node_fs19.existsSync)(getOnboardingArtifactSentinelPath(storagePath))) return true;
57757
57804
  if (directoryIsNonEmpty(getChannelsDir(storagePath))) return true;
57758
57805
  if (directoryIsNonEmpty(getLegacyScreensDir(storagePath))) return true;
57759
57806
  if (directoryIsNonEmpty(getArtifactsMetadataDir(storagePath))) return true;
@@ -57763,7 +57810,7 @@ function hasExistingTelevisionDataStructure(storagePath) {
57763
57810
  }
57764
57811
  function directoryIsNonEmpty(dir) {
57765
57812
  try {
57766
- return (0, import_node_fs18.readdirSync)(dir).length > 0;
57813
+ return (0, import_node_fs19.readdirSync)(dir).length > 0;
57767
57814
  } catch {
57768
57815
  return false;
57769
57816
  }
@@ -57821,13 +57868,13 @@ var ServerStore = class extends EventTarget {
57821
57868
  // specs/arch/onboarding/installer.md#^bootstrap-sequence, #^token-only-boot.
57822
57869
  constructor(options) {
57823
57870
  super();
57824
- this.storagePath = import_node_path22.default.resolve(options.storagePath);
57871
+ this.storagePath = import_node_path23.default.resolve(options.storagePath);
57825
57872
  this.serving = options.installOnboardingChannels === true;
57826
57873
  this.dataDirCreated = !hasExistingTelevisionDataStructure(this.storagePath);
57827
57874
  this.watchContentFile = options.watchContentFile ?? defaultWatchContentFile;
57828
57875
  this.bundledViewsPath = options.bundledViewsPath;
57829
57876
  this.onboardingContentPath = options.onboardingContentPath;
57830
- this.bundledThemesPath = options.bundledThemesPath === void 0 ? void 0 : import_node_path22.default.resolve(options.bundledThemesPath);
57877
+ this.bundledThemesPath = options.bundledThemesPath === void 0 ? void 0 : import_node_path23.default.resolve(options.bundledThemesPath);
57831
57878
  this.recordStorage = options.resourceStorageOperations ?? nodeResourceStorageOperations;
57832
57879
  this.generateID = options.generateID ?? ulid3;
57833
57880
  if (this.serving) {
@@ -57918,8 +57965,8 @@ var ServerStore = class extends EventTarget {
57918
57965
  if (!isBundledViewID(id) || this.bundledViewsPath === void 0) {
57919
57966
  return null;
57920
57967
  }
57921
- const viewPath = import_node_path22.default.join(this.bundledViewsPath, id);
57922
- return (0, import_node_fs18.existsSync)(import_node_path22.default.join(viewPath, "index.html")) ? viewPath : null;
57968
+ const viewPath = import_node_path23.default.join(this.bundledViewsPath, id);
57969
+ return (0, import_node_fs19.existsSync)(import_node_path23.default.join(viewPath, "index.html")) ? viewPath : null;
57923
57970
  }
57924
57971
  getChannel(id) {
57925
57972
  const channel = this.channels.get(id);
@@ -57941,9 +57988,10 @@ var ServerStore = class extends EventTarget {
57941
57988
  return [...this._artifacts.values()];
57942
57989
  }
57943
57990
  /** Create a new artifact and append its default page to the owning channel. */
57991
+ /** Creates an artifact with a generated ID; nothing that creates an artifact supplies its ID (specs/product/artifacts.md#^af-artifact-id). */
57944
57992
  createArtifact(input, telemetryContext) {
57945
57993
  const channel = this.requireChannel(input.channelID);
57946
- const created = this.createKindArtifact({ ...input, id: input.id ?? this.newID() });
57994
+ const created = this.createKindArtifact({ ...input, id: this.newID() });
57947
57995
  const previousLayout = channel.layout;
57948
57996
  const saved = this.saveArtifactRecord(created, `creating artifact ${created.id}`);
57949
57997
  const artifact = saved.artifact;
@@ -57959,7 +58007,7 @@ var ServerStore = class extends EventTarget {
57959
58007
  this.persistChannel(channel);
57960
58008
  } catch (error48) {
57961
58009
  channel.layout = previousLayout;
57962
- (0, import_node_fs18.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifact.id), { force: true });
58010
+ (0, import_node_fs19.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifact.id), { force: true });
57963
58011
  throw error48;
57964
58012
  }
57965
58013
  this._artifacts.set(artifact.id, artifact);
@@ -58329,8 +58377,8 @@ var ServerStore = class extends EventTarget {
58329
58377
  const artifactResults = artifactIDs.map(
58330
58378
  (artifactID) => this.deleteArtifactWithCause(artifactID, "channel_deleted", telemetryContext)
58331
58379
  );
58332
- const metadataPath = import_node_path22.default.join(this.channelsDir, `${channel.id}.json`);
58333
- (0, import_node_fs18.rmSync)(metadataPath, { force: true });
58380
+ const metadataPath = import_node_path23.default.join(this.channelsDir, `${channel.id}.json`);
58381
+ (0, import_node_fs19.rmSync)(metadataPath, { force: true });
58334
58382
  this.channels.delete(channel.id);
58335
58383
  const nextFocusedChannelId = previousFocusedChannelId === channel.id ? this.pickDeletionSuccessorChannelID(nextPinnedChannelIds) : previousFocusedChannelId;
58336
58384
  const pinnedChannelsChanged = !sameIds(nextPinnedChannelIds, this.pinnedChannelIds);
@@ -58377,13 +58425,13 @@ var ServerStore = class extends EventTarget {
58377
58425
  }
58378
58426
  }
58379
58427
  load() {
58380
- if ((0, import_node_fs18.existsSync)(this.channelsDir)) {
58381
- for (const file2 of (0, import_node_fs18.readdirSync)(this.channelsDir)) {
58428
+ if ((0, import_node_fs19.existsSync)(this.channelsDir)) {
58429
+ for (const file2 of (0, import_node_fs19.readdirSync)(this.channelsDir)) {
58382
58430
  if (!file2.endsWith(JSON_FILE_SUFFIX2)) continue;
58383
- const filePath = import_node_path22.default.join(this.channelsDir, file2);
58431
+ const filePath = import_node_path23.default.join(this.channelsDir, file2);
58384
58432
  let raw;
58385
58433
  try {
58386
- raw = JSON.parse((0, import_node_fs18.readFileSync)(filePath, "utf8"));
58434
+ raw = JSON.parse((0, import_node_fs19.readFileSync)(filePath, "utf8"));
58387
58435
  } catch (error48) {
58388
58436
  console.warn(`Skipping malformed JSON file: ${filePath}`, error48);
58389
58437
  continue;
@@ -58401,15 +58449,15 @@ var ServerStore = class extends EventTarget {
58401
58449
  });
58402
58450
  }
58403
58451
  }
58404
- if (!(0, import_node_fs18.existsSync)(this.artifactsDir)) {
58452
+ if (!(0, import_node_fs19.existsSync)(this.artifactsDir)) {
58405
58453
  return;
58406
58454
  }
58407
- for (const file2 of (0, import_node_fs18.readdirSync)(this.artifactsDir)) {
58455
+ for (const file2 of (0, import_node_fs19.readdirSync)(this.artifactsDir)) {
58408
58456
  if (!file2.endsWith(JSON_FILE_SUFFIX2)) {
58409
58457
  continue;
58410
58458
  }
58411
58459
  const id = file2.slice(0, -JSON_FILE_SUFFIX2.length);
58412
- const metadataPath = import_node_path22.default.join(this.artifactsDir, file2);
58460
+ const metadataPath = import_node_path23.default.join(this.artifactsDir, file2);
58413
58461
  const metadata = this.readArtifactFile(metadataPath, id);
58414
58462
  this._artifacts.set(id, metadata);
58415
58463
  }
@@ -58593,7 +58641,7 @@ var ServerStore = class extends EventTarget {
58593
58641
  throw new InvalidRequestError("path artifacts cannot set url");
58594
58642
  }
58595
58643
  const artifactPath = this.normalizeArtifactPath(input.path.trim());
58596
- return createArtifact({ ...input.id ? { id: input.id } : {}, kind: "path", title: input.title, path: artifactPath });
58644
+ return createArtifact({ id: input.id, kind: "path", title: input.title, path: artifactPath });
58597
58645
  }
58598
58646
  case "url": {
58599
58647
  if (input.url === void 0) {
@@ -58606,7 +58654,7 @@ var ServerStore = class extends EventTarget {
58606
58654
  if (!isExternalArtifactURL(url2)) {
58607
58655
  throw new InvalidRequestError(`url must be an absolute http(s) URL: ${url2}`);
58608
58656
  }
58609
- return createArtifact({ ...input.id ? { id: input.id } : {}, kind: "url", title: input.title, url: url2 });
58657
+ return createArtifact({ id: input.id, kind: "url", title: input.title, url: url2 });
58610
58658
  }
58611
58659
  }
58612
58660
  }
@@ -58619,20 +58667,20 @@ var ServerStore = class extends EventTarget {
58619
58667
  * without statting.
58620
58668
  */
58621
58669
  normalizeArtifactPath(artifactPath) {
58622
- if (!import_node_path22.default.isAbsolute(artifactPath)) {
58670
+ if (!import_node_path23.default.isAbsolute(artifactPath)) {
58623
58671
  throw new InvalidRequestError("path must be absolute");
58624
58672
  }
58625
58673
  const stripped = stripTrailingSeparators(artifactPath);
58626
58674
  let stat;
58627
58675
  try {
58628
- (0, import_node_fs18.accessSync)(stripped, import_node_fs18.constants.R_OK);
58629
- stat = (0, import_node_fs18.statSync)(stripped);
58676
+ (0, import_node_fs19.accessSync)(stripped, import_node_fs19.constants.R_OK);
58677
+ stat = (0, import_node_fs19.statSync)(stripped);
58630
58678
  } catch {
58631
58679
  throw new InvalidRequestError(`path does not exist or is not readable: ${artifactPath}`);
58632
58680
  }
58633
58681
  if (stat.isDirectory()) {
58634
- const canonical = hasTrailingSeparator(stripped) ? stripped : `${stripped}${import_node_path22.default.sep}`;
58635
- if (!DIRECTORY_INDEX_BASENAMES.some((basename) => (0, import_node_fs18.existsSync)(import_node_path22.default.join(canonical, basename)))) {
58682
+ const canonical = hasTrailingSeparator(stripped) ? stripped : `${stripped}${import_node_path23.default.sep}`;
58683
+ if (artifactRealLocation(canonical) === null) {
58636
58684
  throw new InvalidRequestError(`directory artifact must contain index.html or index.htm: ${canonical}`);
58637
58685
  }
58638
58686
  return canonical;
@@ -58643,6 +58691,9 @@ var ServerStore = class extends EventTarget {
58643
58691
  if (!isAllowedArtifactFilePath(stripped)) {
58644
58692
  throw new InvalidRequestError(`path extension must be one of .md, .markdown, .htm, .html: ${stripped}`);
58645
58693
  }
58694
+ if (artifactRealLocation(stripped) === null) {
58695
+ throw new InvalidRequestError(`path must lead, once symbolic links are followed, to a file ending in .md, .markdown, .htm or .html: ${stripped}`);
58696
+ }
58646
58697
  return stripped;
58647
58698
  }
58648
58699
  /** Installer-only whole-page write for retry-safe onboarding installation. */
@@ -58709,11 +58760,11 @@ var ServerStore = class extends EventTarget {
58709
58760
  }
58710
58761
  }
58711
58762
  ensureDirectories() {
58712
- (0, import_node_fs18.mkdirSync)(import_node_path22.default.join(this.storagePath, "state"), { recursive: true });
58713
- (0, import_node_fs18.mkdirSync)(this.channelsDir, { recursive: true });
58714
- (0, import_node_fs18.mkdirSync)(this.artifactsDir, { recursive: true });
58715
- (0, import_node_fs18.mkdirSync)(getThemesDir(this.storagePath), { recursive: true });
58716
- (0, import_node_fs18.mkdirSync)(getAgentArtifactsDir(this.storagePath), { recursive: true });
58763
+ (0, import_node_fs19.mkdirSync)(import_node_path23.default.join(this.storagePath, "state"), { recursive: true });
58764
+ (0, import_node_fs19.mkdirSync)(this.channelsDir, { recursive: true });
58765
+ (0, import_node_fs19.mkdirSync)(this.artifactsDir, { recursive: true });
58766
+ (0, import_node_fs19.mkdirSync)(getThemesDir(this.storagePath), { recursive: true });
58767
+ (0, import_node_fs19.mkdirSync)(getAgentArtifactsDir(this.storagePath), { recursive: true });
58717
58768
  }
58718
58769
  rebuildArtifactChannels() {
58719
58770
  this.artifactChannels.clear();
@@ -58732,12 +58783,12 @@ var ServerStore = class extends EventTarget {
58732
58783
  }
58733
58784
  }
58734
58785
  loadDisplayState() {
58735
- if (!(0, import_node_fs18.existsSync)(this.displayStatePath)) {
58786
+ if (!(0, import_node_fs19.existsSync)(this.displayStatePath)) {
58736
58787
  return false;
58737
58788
  }
58738
58789
  let raw;
58739
58790
  try {
58740
- raw = (0, import_node_fs18.readFileSync)(this.displayStatePath, "utf8");
58791
+ raw = (0, import_node_fs19.readFileSync)(this.displayStatePath, "utf8");
58741
58792
  } catch {
58742
58793
  return false;
58743
58794
  }
@@ -58766,7 +58817,7 @@ var ServerStore = class extends EventTarget {
58766
58817
  appearanceMode: this.appearanceMode,
58767
58818
  themeJavaScriptConsentIds: [...this.themeJavaScriptConsentIds]
58768
58819
  }) {
58769
- (0, import_node_fs18.writeFileSync)(
58820
+ (0, import_node_fs19.writeFileSync)(
58770
58821
  this.displayStatePath,
58771
58822
  JSON.stringify({
58772
58823
  focusedChannelId: state.focusedChannelId,
@@ -58808,11 +58859,11 @@ var ServerStore = class extends EventTarget {
58808
58859
  return newestChannelID;
58809
58860
  }
58810
58861
  loadOrCreateAuthToken() {
58811
- if ((0, import_node_fs18.existsSync)(this.tokenPath)) {
58812
- return (0, import_node_fs18.readFileSync)(this.tokenPath, "utf8").trim();
58862
+ if ((0, import_node_fs19.existsSync)(this.tokenPath)) {
58863
+ return (0, import_node_fs19.readFileSync)(this.tokenPath, "utf8").trim();
58813
58864
  }
58814
58865
  const token = createToken();
58815
- (0, import_node_fs18.writeFileSync)(this.tokenPath, `${token}
58866
+ (0, import_node_fs19.writeFileSync)(this.tokenPath, `${token}
58816
58867
  `);
58817
58868
  return token;
58818
58869
  }
@@ -58827,15 +58878,15 @@ var ServerStore = class extends EventTarget {
58827
58878
  layout: channel.layout,
58828
58879
  ...channel.onboarding ? { onboarding: channel.onboarding } : {}
58829
58880
  };
58830
- (0, import_node_fs18.writeFileSync)(
58831
- import_node_path22.default.join(this.channelsDir, `${channel.id}.json`),
58881
+ (0, import_node_fs19.writeFileSync)(
58882
+ import_node_path23.default.join(this.channelsDir, `${channel.id}.json`),
58832
58883
  JSON.stringify(stored, null, JSON_INDENT_SPACES5)
58833
58884
  );
58834
58885
  }
58835
58886
  readArtifactFile(filePath, expectedID) {
58836
58887
  let raw;
58837
58888
  try {
58838
- raw = (0, import_node_fs18.readFileSync)(filePath, "utf8");
58889
+ raw = (0, import_node_fs19.readFileSync)(filePath, "utf8");
58839
58890
  } catch (error48) {
58840
58891
  throw this.invalidMetadataFile(filePath, "unreadable", error48);
58841
58892
  }
@@ -58857,7 +58908,7 @@ var ServerStore = class extends EventTarget {
58857
58908
  `id ${result.data.id} does not match filename ${expectedID}`
58858
58909
  );
58859
58910
  }
58860
- if (result.data.kind === "path" && !import_node_path22.default.isAbsolute(result.data.path)) {
58911
+ if (result.data.kind === "path" && !import_node_path23.default.isAbsolute(result.data.path)) {
58861
58912
  throw this.invalidMetadataFile(filePath, "path must be absolute");
58862
58913
  }
58863
58914
  return result.data;
@@ -58995,13 +59046,13 @@ Correct this metadata file and restart Television, or delete only this metadata
58995
59046
  }
58996
59047
  /** Removes temporary files that an interrupted record save left (specs/arch/resources/index.md#^rs-storage). */
58997
59048
  removeLeftoverRecordFiles() {
58998
- if (!(0, import_node_fs18.existsSync)(this.artifactsDir)) return;
58999
- for (const file2 of (0, import_node_fs18.readdirSync)(this.artifactsDir)) {
59049
+ if (!(0, import_node_fs19.existsSync)(this.artifactsDir)) return;
59050
+ for (const file2 of (0, import_node_fs19.readdirSync)(this.artifactsDir)) {
59000
59051
  if (!isTemporaryFileName(file2)) continue;
59001
59052
  try {
59002
- this.recordStorage.deleteFile(import_node_path22.default.join(this.artifactsDir, file2));
59053
+ this.recordStorage.deleteFile(import_node_path23.default.join(this.artifactsDir, file2));
59003
59054
  } catch (error48) {
59004
- console.warn(`Could not remove the leftover temporary file ${import_node_path22.default.join(this.artifactsDir, file2)}: ${errorMessage2(error48)}`);
59055
+ console.warn(`Could not remove the leftover temporary file ${import_node_path23.default.join(this.artifactsDir, file2)}: ${errorMessage2(error48)}`);
59005
59056
  }
59006
59057
  }
59007
59058
  }
@@ -59166,24 +59217,24 @@ function createDirectiveError(message) {
59166
59217
  return new CLIDirectiveError(ensureHelpPointer(message));
59167
59218
  }
59168
59219
  function getDevPackageDir() {
59169
- return import_node_path23.default.resolve(import_node_path23.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "..");
59220
+ return import_node_path24.default.resolve(import_node_path24.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "..");
59170
59221
  }
59171
59222
  function resolveVercelSkillsInstallerBin() {
59172
59223
  if (typeof require === "function" && typeof require.resolve === "function") {
59173
59224
  return require.resolve("skills/bin/cli.mjs");
59174
59225
  }
59175
- const localRequire = (0, import_node_module.createRequire)(import_node_path23.default.join(getDevPackageDir(), "package.json"));
59226
+ const localRequire = (0, import_node_module.createRequire)(import_node_path24.default.join(getDevPackageDir(), "package.json"));
59176
59227
  return localRequire.resolve("skills/bin/cli.mjs");
59177
59228
  }
59178
59229
  function readCLIVersion() {
59179
- if ("1.4.29".length > 0) {
59180
- return "1.4.29";
59230
+ if ("1.5.1".length > 0) {
59231
+ return "1.5.1";
59181
59232
  }
59182
- const devPackageJsonPath = import_node_path23.default.join(getDevPackageDir(), "package.json");
59183
- if (!(0, import_node_fs19.existsSync)(devPackageJsonPath)) {
59233
+ const devPackageJsonPath = import_node_path24.default.join(getDevPackageDir(), "package.json");
59234
+ if (!(0, import_node_fs20.existsSync)(devPackageJsonPath)) {
59184
59235
  throw new Error("Could not resolve package.json for repo-local CLI version.");
59185
59236
  }
59186
- return JSON.parse((0, import_node_fs19.readFileSync)(devPackageJsonPath, "utf8")).version;
59237
+ return JSON.parse((0, import_node_fs20.readFileSync)(devPackageJsonPath, "utf8")).version;
59187
59238
  }
59188
59239
  function readCLIVersionOutput(resolveHomeDir) {
59189
59240
  const releaseVersion = readCLIVersion();
@@ -59315,7 +59366,7 @@ function formatCLIError(error48, invocation) {
59315
59366
  const status = typeof error48.status === "number" ? Number(error48.status) : void 0;
59316
59367
  if (status === HTTP_UNAUTHORIZED_STATUS2) {
59317
59368
  return ensureHelpPointer(
59318
- `Television server at ${serverURL} rejected the request as unauthorized. Check the token in ${import_node_path23.default.join(invocation.home ?? "<home>", "state", "token")}.`
59369
+ `Television server at ${serverURL} rejected the request as unauthorized. Check the token in ${import_node_path24.default.join(invocation.home ?? "<home>", "state", "token")}.`
59319
59370
  );
59320
59371
  }
59321
59372
  if (status !== void 0) {
@@ -59378,85 +59429,85 @@ function parseConfigSetPairs(pairs, invocation) {
59378
59429
  }
59379
59430
  function resolveStaticDir() {
59380
59431
  if (process.argv[1]) {
59381
- const entryDir = import_node_path23.default.dirname((0, import_node_fs19.realpathSync)(process.argv[1]));
59382
- const resolved = import_node_path23.default.resolve(entryDir, "./web");
59383
- return (0, import_node_fs19.existsSync)(import_node_path23.default.join(resolved, "index.html")) ? resolved : void 0;
59432
+ const entryDir = import_node_path24.default.dirname((0, import_node_fs20.realpathSync)(process.argv[1]));
59433
+ const resolved = import_node_path24.default.resolve(entryDir, "./web");
59434
+ return (0, import_node_fs20.existsSync)(import_node_path24.default.join(resolved, "index.html")) ? resolved : void 0;
59384
59435
  }
59385
- const devStaticPath = import_node_path23.default.resolve(getDevPackageDir(), "../web/dist");
59386
- return (0, import_node_fs19.existsSync)(import_node_path23.default.join(devStaticPath, "index.html")) ? devStaticPath : void 0;
59436
+ const devStaticPath = import_node_path24.default.resolve(getDevPackageDir(), "../web/dist");
59437
+ return (0, import_node_fs20.existsSync)(import_node_path24.default.join(devStaticPath, "index.html")) ? devStaticPath : void 0;
59387
59438
  }
59388
59439
  function resolveBundledViewsPath() {
59389
59440
  if (process.argv[1]) {
59390
- const entryDir = import_node_path23.default.dirname((0, import_node_fs19.realpathSync)(process.argv[1]));
59391
- const resolved = import_node_path23.default.resolve(entryDir, "./views");
59392
- return (0, import_node_fs19.existsSync)(resolved) ? resolved : void 0;
59441
+ const entryDir = import_node_path24.default.dirname((0, import_node_fs20.realpathSync)(process.argv[1]));
59442
+ const resolved = import_node_path24.default.resolve(entryDir, "./views");
59443
+ return (0, import_node_fs20.existsSync)(resolved) ? resolved : void 0;
59393
59444
  }
59394
- const devViewsPath = import_node_path23.default.join(getDevPackageDir(), "dist/views");
59395
- return (0, import_node_fs19.existsSync)(devViewsPath) ? devViewsPath : void 0;
59445
+ const devViewsPath = import_node_path24.default.join(getDevPackageDir(), "dist/views");
59446
+ return (0, import_node_fs20.existsSync)(devViewsPath) ? devViewsPath : void 0;
59396
59447
  }
59397
59448
  function resolveCanonicalDir() {
59398
59449
  if (process.argv[1]) {
59399
- const entryDir = import_node_path23.default.dirname((0, import_node_fs19.realpathSync)(process.argv[1]));
59400
- const resolved = import_node_path23.default.resolve(entryDir, "./canonical");
59401
- return (0, import_node_fs19.existsSync)(resolved) ? resolved : void 0;
59450
+ const entryDir = import_node_path24.default.dirname((0, import_node_fs20.realpathSync)(process.argv[1]));
59451
+ const resolved = import_node_path24.default.resolve(entryDir, "./canonical");
59452
+ return (0, import_node_fs20.existsSync)(resolved) ? resolved : void 0;
59402
59453
  }
59403
- const devCanonicalPath = import_node_path23.default.resolve(
59454
+ const devCanonicalPath = import_node_path24.default.resolve(
59404
59455
  getDevPackageDir(),
59405
59456
  "../server/dist/canonical"
59406
59457
  );
59407
- return (0, import_node_fs19.existsSync)(devCanonicalPath) ? devCanonicalPath : void 0;
59458
+ return (0, import_node_fs20.existsSync)(devCanonicalPath) ? devCanonicalPath : void 0;
59408
59459
  }
59409
59460
  function resolveOnboardingContentPath() {
59410
59461
  if (process.argv[1]) {
59411
- const entryDir = import_node_path23.default.dirname((0, import_node_fs19.realpathSync)(process.argv[1]));
59412
- const resolved = import_node_path23.default.resolve(entryDir, "./onboarding");
59413
- return (0, import_node_fs19.existsSync)(resolved) ? resolved : void 0;
59462
+ const entryDir = import_node_path24.default.dirname((0, import_node_fs20.realpathSync)(process.argv[1]));
59463
+ const resolved = import_node_path24.default.resolve(entryDir, "./onboarding");
59464
+ return (0, import_node_fs20.existsSync)(resolved) ? resolved : void 0;
59414
59465
  }
59415
- const devPath = import_node_path23.default.resolve(
59466
+ const devPath = import_node_path24.default.resolve(
59416
59467
  getDevPackageDir(),
59417
59468
  "../server/assets/onboarding-channels"
59418
59469
  );
59419
- return (0, import_node_fs19.existsSync)(devPath) ? devPath : void 0;
59470
+ return (0, import_node_fs20.existsSync)(devPath) ? devPath : void 0;
59420
59471
  }
59421
59472
  function resolveBundledThemesPath() {
59422
59473
  if (process.argv[1]) {
59423
- const entryDir = import_node_path23.default.dirname((0, import_node_fs19.realpathSync)(process.argv[1]));
59424
- const resolved = import_node_path23.default.resolve(entryDir, "./themes");
59425
- return (0, import_node_fs19.existsSync)(resolved) ? resolved : void 0;
59474
+ const entryDir = import_node_path24.default.dirname((0, import_node_fs20.realpathSync)(process.argv[1]));
59475
+ const resolved = import_node_path24.default.resolve(entryDir, "./themes");
59476
+ return (0, import_node_fs20.existsSync)(resolved) ? resolved : void 0;
59426
59477
  }
59427
- const devPath = import_node_path23.default.resolve(getDevPackageDir(), "../server/assets/themes");
59428
- return (0, import_node_fs19.existsSync)(devPath) ? devPath : void 0;
59478
+ const devPath = import_node_path24.default.resolve(getDevPackageDir(), "../server/assets/themes");
59479
+ return (0, import_node_fs20.existsSync)(devPath) ? devPath : void 0;
59429
59480
  }
59430
59481
  function resolveSdkDir() {
59431
59482
  if (process.argv[1]) {
59432
- const entryDir = import_node_path23.default.dirname((0, import_node_fs19.realpathSync)(process.argv[1]));
59433
- const resolved = import_node_path23.default.resolve(entryDir, "./sdk");
59434
- return (0, import_node_fs19.existsSync)(resolved) ? resolved : void 0;
59483
+ const entryDir = import_node_path24.default.dirname((0, import_node_fs20.realpathSync)(process.argv[1]));
59484
+ const resolved = import_node_path24.default.resolve(entryDir, "./sdk");
59485
+ return (0, import_node_fs20.existsSync)(resolved) ? resolved : void 0;
59435
59486
  }
59436
- const devPath = import_node_path23.default.resolve(getDevPackageDir(), "../server/dist/sdk");
59437
- return (0, import_node_fs19.existsSync)(devPath) ? devPath : void 0;
59487
+ const devPath = import_node_path24.default.resolve(getDevPackageDir(), "../server/dist/sdk");
59488
+ return (0, import_node_fs20.existsSync)(devPath) ? devPath : void 0;
59438
59489
  }
59439
59490
  function resolveBundledSkillsRoot() {
59440
- const builtPath = typeof process.argv[1] === "string" ? import_node_path23.default.resolve(import_node_path23.default.dirname((0, import_node_fs19.realpathSync)(process.argv[1])), "./skills") : void 0;
59441
- if (builtPath && (0, import_node_fs19.existsSync)(builtPath)) {
59491
+ const builtPath = typeof process.argv[1] === "string" ? import_node_path24.default.resolve(import_node_path24.default.dirname((0, import_node_fs20.realpathSync)(process.argv[1])), "./skills") : void 0;
59492
+ if (builtPath && (0, import_node_fs20.existsSync)(builtPath)) {
59442
59493
  return builtPath;
59443
59494
  }
59444
- const devPath = import_node_path23.default.resolve(getDevPackageDir(), "../skills/dist");
59445
- return (0, import_node_fs19.existsSync)(devPath) ? devPath : void 0;
59495
+ const devPath = import_node_path24.default.resolve(getDevPackageDir(), "../skills/dist");
59496
+ return (0, import_node_fs20.existsSync)(devPath) ? devPath : void 0;
59446
59497
  }
59447
59498
  function copyBundledSkillsToDestination(bundledSkillsRoot, destinationRoot) {
59448
- if ((0, import_node_fs19.existsSync)(destinationRoot) && !(0, import_node_fs19.statSync)(destinationRoot).isDirectory()) {
59499
+ if ((0, import_node_fs20.existsSync)(destinationRoot) && !(0, import_node_fs20.statSync)(destinationRoot).isDirectory()) {
59449
59500
  throw new Error(`Skills destination is not a directory: ${destinationRoot}`);
59450
59501
  }
59451
- (0, import_node_fs19.mkdirSync)(destinationRoot, { recursive: true });
59452
- (0, import_node_fs19.rmSync)(import_node_path23.default.join(destinationRoot, "tv-theme"), { recursive: true, force: true });
59502
+ (0, import_node_fs20.mkdirSync)(destinationRoot, { recursive: true });
59503
+ (0, import_node_fs20.rmSync)(import_node_path24.default.join(destinationRoot, "tv-theme"), { recursive: true, force: true });
59453
59504
  const copied = [];
59454
- const entries = (0, import_node_fs19.readdirSync)(bundledSkillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b2) => a.name.localeCompare(b2.name));
59505
+ const entries = (0, import_node_fs20.readdirSync)(bundledSkillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b2) => a.name.localeCompare(b2.name));
59455
59506
  for (const entry of entries) {
59456
- const sourcePath = import_node_path23.default.join(bundledSkillsRoot, entry.name);
59457
- const destinationPath = import_node_path23.default.join(destinationRoot, entry.name);
59458
- (0, import_node_fs19.rmSync)(destinationPath, { recursive: true, force: true });
59459
- (0, import_node_fs19.cpSync)(sourcePath, destinationPath, { recursive: true });
59507
+ const sourcePath = import_node_path24.default.join(bundledSkillsRoot, entry.name);
59508
+ const destinationPath = import_node_path24.default.join(destinationRoot, entry.name);
59509
+ (0, import_node_fs20.rmSync)(destinationPath, { recursive: true, force: true });
59510
+ (0, import_node_fs20.cpSync)(sourcePath, destinationPath, { recursive: true });
59460
59511
  copied.push({ name: entry.name, sourcePath, destinationPath });
59461
59512
  }
59462
59513
  return copied;
@@ -59539,11 +59590,11 @@ function formatCommanderError(argv, error48) {
59539
59590
  return null;
59540
59591
  }
59541
59592
  function readAuthToken(home) {
59542
- const tokenPath = import_node_path23.default.join(home, "state", "token");
59543
- if (!(0, import_node_fs19.existsSync)(tokenPath)) {
59593
+ const tokenPath = import_node_path24.default.join(home, "state", "token");
59594
+ if (!(0, import_node_fs20.existsSync)(tokenPath)) {
59544
59595
  return void 0;
59545
59596
  }
59546
- const token = (0, import_node_fs19.readFileSync)(tokenPath, "utf8").trim();
59597
+ const token = (0, import_node_fs20.readFileSync)(tokenPath, "utf8").trim();
59547
59598
  return token.length > 0 ? token : void 0;
59548
59599
  }
59549
59600
  function readOrCreateAuthToken(home) {
@@ -59633,7 +59684,7 @@ function createEnvironment(environment) {
59633
59684
  };
59634
59685
  }
59635
59686
  function startRetiredService(home, definition) {
59636
- const wroteConfig = !(0, import_node_fs19.existsSync)(import_node_path23.default.join(home, "config.json"));
59687
+ const wroteConfig = !(0, import_node_fs20.existsSync)(import_node_path24.default.join(home, "config.json"));
59637
59688
  if (wroteConfig) updateTelevisionConfig(home, definition.settings);
59638
59689
  log(home, RETIRED_SERVICE_RECORD, {
59639
59690
  wroteConfig,
@@ -59682,9 +59733,9 @@ function createProgram(env, invocation = { argv: [] }) {
59682
59733
  return env.createClient(serverURL, readAuthToken(resolveHome()));
59683
59734
  };
59684
59735
  const shouldDiscloseTelemetry = (home, telemetryEnv) => {
59685
- if ((0, import_node_fs19.existsSync)(getTelemetryStatePath(home))) return false;
59736
+ if ((0, import_node_fs20.existsSync)(getTelemetryStatePath(home))) return false;
59686
59737
  const developerHome = telemetryEnv.TELEVISION_DEVELOPER_HOME || env.resolveHomeDir();
59687
- const developerHost = (0, import_node_fs19.existsSync)(import_node_path23.default.join(developerHome, DEVELOPER_MARKER));
59738
+ const developerHost = (0, import_node_fs20.existsSync)(import_node_path24.default.join(developerHome, DEVELOPER_MARKER));
59688
59739
  return telemetryDestination(telemetryEnv, { optedOut: false }, developerHost) === "production";
59689
59740
  };
59690
59741
  const emitSkillInstallTelemetry = async (input) => {
@@ -59793,7 +59844,7 @@ function createProgram(env, invocation = { argv: [] }) {
59793
59844
  });
59794
59845
  if (disclose) writeLine(env.stderr, TELEMETRY_NOTICE);
59795
59846
  throw new Error(
59796
- `Television service installed, but the server did not respond at ${healthServerURL} within ${PERSISTED_HEALTH_TIMEOUT_MS / 1e3} seconds. The service remains installed. See ${import_node_path23.default.join(home, "logs", "tv.log")} for the cause.`
59847
+ `Television service installed, but the server did not respond at ${healthServerURL} within ${PERSISTED_HEALTH_TIMEOUT_MS / 1e3} seconds. The service remains installed. See ${import_node_path24.default.join(home, "logs", "tv.log")} for the cause.`
59797
59848
  );
59798
59849
  }
59799
59850
  const links = startup.printLinks || env.stdout.isTTY === true ? await persistedLinks(healthServerURL, token, client, health, deadline) : null;
@@ -60103,7 +60154,7 @@ function createProgram(env, invocation = { argv: [] }) {
60103
60154
  writeLine(env.stdout, `Active theme changed from '${previousLabel}' to '${nextLabel}'.`);
60104
60155
  });
60105
60156
  program2.command("themes-path").description("Print the themes directory of the selected home as JSON").action(() => {
60106
- writeJSON(env.stdout, { themesPath: import_node_path23.default.join(resolveHome(), "themes") });
60157
+ writeJSON(env.stdout, { themesPath: import_node_path24.default.join(resolveHome(), "themes") });
60107
60158
  });
60108
60159
  program2.command("focus-artifact").description(
60109
60160
  "Send a transient focus nudge for a specific artifact. Connected clients select the artifact's tab page and switch to its channel when needed. This is NOT persisted as state \u2014 there is no concept of a 'focused artifact' that survives reconnects (the focused channel is persistent, but artifact focus is a one-shot event)."
@@ -60146,7 +60197,7 @@ function createProgram(env, invocation = { argv: [] }) {
60146
60197
  if (!bundledTelevisionSkillsCollectionRoot) {
60147
60198
  throw new Error("Could not resolve the bundled Television skills root.");
60148
60199
  }
60149
- const destinationRoot = import_node_path23.default.resolve(inputPath);
60200
+ const destinationRoot = import_node_path24.default.resolve(inputPath);
60150
60201
  const copied = copyBundledSkillsToDestination(bundledTelevisionSkillsCollectionRoot, destinationRoot);
60151
60202
  writeLine(env.stdout, `Copied ${copied.length} bundled Television skill(s):`);
60152
60203
  for (const skill of copied) {
@@ -60224,7 +60275,7 @@ function createProgram(env, invocation = { argv: [] }) {
60224
60275
  source = await readStandardInput();
60225
60276
  } else if (file2 !== void 0) {
60226
60277
  try {
60227
- source = (0, import_node_fs19.readFileSync)(file2, "utf8");
60278
+ source = (0, import_node_fs20.readFileSync)(file2, "utf8");
60228
60279
  } catch (error48) {
60229
60280
  throw createDirectiveError(`${invocation2} could not read ${file2}: ${error48 instanceof Error ? error48.message : String(error48)}`);
60230
60281
  }