@telepath-computer/television 1.3.8 → 1.3.9
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
|
@@ -1194,7 +1194,7 @@ var require_command = __commonJS({
|
|
|
1194
1194
|
"../../node_modules/commander/lib/command.js"(exports2) {
|
|
1195
1195
|
var EventEmitter2 = require("node:events").EventEmitter;
|
|
1196
1196
|
var childProcess = require("node:child_process");
|
|
1197
|
-
var
|
|
1197
|
+
var path20 = require("node:path");
|
|
1198
1198
|
var fs4 = require("node:fs");
|
|
1199
1199
|
var process3 = require("node:process");
|
|
1200
1200
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -2207,9 +2207,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2207
2207
|
let launchWithNode = false;
|
|
2208
2208
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2209
2209
|
function findFile(baseDir, baseName) {
|
|
2210
|
-
const localBin =
|
|
2210
|
+
const localBin = path20.resolve(baseDir, baseName);
|
|
2211
2211
|
if (fs4.existsSync(localBin)) return localBin;
|
|
2212
|
-
if (sourceExt.includes(
|
|
2212
|
+
if (sourceExt.includes(path20.extname(baseName))) return void 0;
|
|
2213
2213
|
const foundExt = sourceExt.find(
|
|
2214
2214
|
(ext) => fs4.existsSync(`${localBin}${ext}`)
|
|
2215
2215
|
);
|
|
@@ -2227,17 +2227,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2227
2227
|
} catch {
|
|
2228
2228
|
resolvedScriptPath = this._scriptPath;
|
|
2229
2229
|
}
|
|
2230
|
-
executableDir =
|
|
2231
|
-
|
|
2230
|
+
executableDir = path20.resolve(
|
|
2231
|
+
path20.dirname(resolvedScriptPath),
|
|
2232
2232
|
executableDir
|
|
2233
2233
|
);
|
|
2234
2234
|
}
|
|
2235
2235
|
if (executableDir) {
|
|
2236
2236
|
let localFile = findFile(executableDir, executableFile);
|
|
2237
2237
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2238
|
-
const legacyName =
|
|
2238
|
+
const legacyName = path20.basename(
|
|
2239
2239
|
this._scriptPath,
|
|
2240
|
-
|
|
2240
|
+
path20.extname(this._scriptPath)
|
|
2241
2241
|
);
|
|
2242
2242
|
if (legacyName !== this._name) {
|
|
2243
2243
|
localFile = findFile(
|
|
@@ -2248,7 +2248,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2248
2248
|
}
|
|
2249
2249
|
executableFile = localFile || executableFile;
|
|
2250
2250
|
}
|
|
2251
|
-
launchWithNode = sourceExt.includes(
|
|
2251
|
+
launchWithNode = sourceExt.includes(path20.extname(executableFile));
|
|
2252
2252
|
let proc;
|
|
2253
2253
|
if (process3.platform !== "win32") {
|
|
2254
2254
|
if (launchWithNode) {
|
|
@@ -3163,7 +3163,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3163
3163
|
* @return {Command}
|
|
3164
3164
|
*/
|
|
3165
3165
|
nameFromFilename(filename) {
|
|
3166
|
-
this._name =
|
|
3166
|
+
this._name = path20.basename(filename, path20.extname(filename));
|
|
3167
3167
|
return this;
|
|
3168
3168
|
}
|
|
3169
3169
|
/**
|
|
@@ -3177,9 +3177,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3177
3177
|
* @param {string} [path]
|
|
3178
3178
|
* @return {(string|null|Command)}
|
|
3179
3179
|
*/
|
|
3180
|
-
executableDir(
|
|
3181
|
-
if (
|
|
3182
|
-
this._executableDir =
|
|
3180
|
+
executableDir(path21) {
|
|
3181
|
+
if (path21 === void 0) return this._executableDir;
|
|
3182
|
+
this._executableDir = path21;
|
|
3183
3183
|
return this;
|
|
3184
3184
|
}
|
|
3185
3185
|
/**
|
|
@@ -21480,11 +21480,11 @@ var require_mime_types = __commonJS({
|
|
|
21480
21480
|
}
|
|
21481
21481
|
return exts[0];
|
|
21482
21482
|
}
|
|
21483
|
-
function lookup(
|
|
21484
|
-
if (!
|
|
21483
|
+
function lookup(path20) {
|
|
21484
|
+
if (!path20 || typeof path20 !== "string") {
|
|
21485
21485
|
return false;
|
|
21486
21486
|
}
|
|
21487
|
-
var extension3 = extname("x." +
|
|
21487
|
+
var extension3 = extname("x." + path20).toLowerCase().substr(1);
|
|
21488
21488
|
if (!extension3) {
|
|
21489
21489
|
return false;
|
|
21490
21490
|
}
|
|
@@ -24307,7 +24307,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
24307
24307
|
"../../node_modules/path-to-regexp/index.js"(exports2, module2) {
|
|
24308
24308
|
module2.exports = pathToRegexp;
|
|
24309
24309
|
var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
|
|
24310
|
-
function pathToRegexp(
|
|
24310
|
+
function pathToRegexp(path20, keys, options) {
|
|
24311
24311
|
options = options || {};
|
|
24312
24312
|
keys = keys || [];
|
|
24313
24313
|
var strict = options.strict;
|
|
@@ -24321,8 +24321,8 @@ var require_path_to_regexp = __commonJS({
|
|
|
24321
24321
|
var pos = 0;
|
|
24322
24322
|
var backtrack = "";
|
|
24323
24323
|
var m2;
|
|
24324
|
-
if (
|
|
24325
|
-
while (m2 = MATCHING_GROUP_REGEXP.exec(
|
|
24324
|
+
if (path20 instanceof RegExp) {
|
|
24325
|
+
while (m2 = MATCHING_GROUP_REGEXP.exec(path20.source)) {
|
|
24326
24326
|
if (m2[0][0] === "\\") continue;
|
|
24327
24327
|
keys.push({
|
|
24328
24328
|
name: m2[1] || name++,
|
|
@@ -24330,18 +24330,18 @@ var require_path_to_regexp = __commonJS({
|
|
|
24330
24330
|
offset: m2.index
|
|
24331
24331
|
});
|
|
24332
24332
|
}
|
|
24333
|
-
return
|
|
24333
|
+
return path20;
|
|
24334
24334
|
}
|
|
24335
|
-
if (Array.isArray(
|
|
24336
|
-
|
|
24335
|
+
if (Array.isArray(path20)) {
|
|
24336
|
+
path20 = path20.map(function(value) {
|
|
24337
24337
|
return pathToRegexp(value, keys, options).source;
|
|
24338
24338
|
});
|
|
24339
|
-
return new RegExp(
|
|
24339
|
+
return new RegExp(path20.join("|"), flags);
|
|
24340
24340
|
}
|
|
24341
|
-
if (typeof
|
|
24341
|
+
if (typeof path20 !== "string") {
|
|
24342
24342
|
throw new TypeError("path must be a string, array of strings, or regular expression");
|
|
24343
24343
|
}
|
|
24344
|
-
|
|
24344
|
+
path20 = path20.replace(
|
|
24345
24345
|
/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,
|
|
24346
24346
|
function(match, slash, format, key, capture2, star, optional2, offset) {
|
|
24347
24347
|
if (match[0] === "\\") {
|
|
@@ -24358,7 +24358,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
24358
24358
|
if (slash || format) {
|
|
24359
24359
|
backtrack = "";
|
|
24360
24360
|
} else {
|
|
24361
|
-
backtrack +=
|
|
24361
|
+
backtrack += path20.slice(pos, offset);
|
|
24362
24362
|
}
|
|
24363
24363
|
pos = offset + match.length;
|
|
24364
24364
|
if (match === "*") {
|
|
@@ -24388,7 +24388,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
24388
24388
|
return result;
|
|
24389
24389
|
}
|
|
24390
24390
|
);
|
|
24391
|
-
while (m2 = MATCHING_GROUP_REGEXP.exec(
|
|
24391
|
+
while (m2 = MATCHING_GROUP_REGEXP.exec(path20)) {
|
|
24392
24392
|
if (m2[0][0] === "\\") continue;
|
|
24393
24393
|
if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m2.index) {
|
|
24394
24394
|
keys.splice(keysOffset + i, 0, {
|
|
@@ -24400,13 +24400,13 @@ var require_path_to_regexp = __commonJS({
|
|
|
24400
24400
|
}
|
|
24401
24401
|
i++;
|
|
24402
24402
|
}
|
|
24403
|
-
|
|
24403
|
+
path20 += strict ? "" : path20[path20.length - 1] === "/" ? "?" : "/?";
|
|
24404
24404
|
if (end) {
|
|
24405
|
-
|
|
24406
|
-
} else if (
|
|
24407
|
-
|
|
24405
|
+
path20 += "$";
|
|
24406
|
+
} else if (path20[path20.length - 1] !== "/") {
|
|
24407
|
+
path20 += lookahead ? "(?=/|$)" : "(?:/|$)";
|
|
24408
24408
|
}
|
|
24409
|
-
return new RegExp("^" +
|
|
24409
|
+
return new RegExp("^" + path20, flags);
|
|
24410
24410
|
}
|
|
24411
24411
|
}
|
|
24412
24412
|
});
|
|
@@ -24419,19 +24419,19 @@ var require_layer = __commonJS({
|
|
|
24419
24419
|
var debug = require_src3()("express:router:layer");
|
|
24420
24420
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
24421
24421
|
module2.exports = Layer;
|
|
24422
|
-
function Layer(
|
|
24422
|
+
function Layer(path20, options, fn) {
|
|
24423
24423
|
if (!(this instanceof Layer)) {
|
|
24424
|
-
return new Layer(
|
|
24424
|
+
return new Layer(path20, options, fn);
|
|
24425
24425
|
}
|
|
24426
|
-
debug("new %o",
|
|
24426
|
+
debug("new %o", path20);
|
|
24427
24427
|
var opts = options || {};
|
|
24428
24428
|
this.handle = fn;
|
|
24429
24429
|
this.name = fn.name || "<anonymous>";
|
|
24430
24430
|
this.params = void 0;
|
|
24431
24431
|
this.path = void 0;
|
|
24432
|
-
this.regexp = pathRegexp(
|
|
24433
|
-
this.regexp.fast_star =
|
|
24434
|
-
this.regexp.fast_slash =
|
|
24432
|
+
this.regexp = pathRegexp(path20, this.keys = [], opts);
|
|
24433
|
+
this.regexp.fast_star = path20 === "*";
|
|
24434
|
+
this.regexp.fast_slash = path20 === "/" && opts.end === false;
|
|
24435
24435
|
}
|
|
24436
24436
|
Layer.prototype.handle_error = function handle_error(error48, req, res, next) {
|
|
24437
24437
|
var fn = this.handle;
|
|
@@ -24455,20 +24455,20 @@ var require_layer = __commonJS({
|
|
|
24455
24455
|
next(err);
|
|
24456
24456
|
}
|
|
24457
24457
|
};
|
|
24458
|
-
Layer.prototype.match = function match(
|
|
24458
|
+
Layer.prototype.match = function match(path20) {
|
|
24459
24459
|
var match2;
|
|
24460
|
-
if (
|
|
24460
|
+
if (path20 != null) {
|
|
24461
24461
|
if (this.regexp.fast_slash) {
|
|
24462
24462
|
this.params = {};
|
|
24463
24463
|
this.path = "";
|
|
24464
24464
|
return true;
|
|
24465
24465
|
}
|
|
24466
24466
|
if (this.regexp.fast_star) {
|
|
24467
|
-
this.params = { "0": decode_param(
|
|
24468
|
-
this.path =
|
|
24467
|
+
this.params = { "0": decode_param(path20) };
|
|
24468
|
+
this.path = path20;
|
|
24469
24469
|
return true;
|
|
24470
24470
|
}
|
|
24471
|
-
match2 = this.regexp.exec(
|
|
24471
|
+
match2 = this.regexp.exec(path20);
|
|
24472
24472
|
}
|
|
24473
24473
|
if (!match2) {
|
|
24474
24474
|
this.params = void 0;
|
|
@@ -24561,10 +24561,10 @@ var require_route = __commonJS({
|
|
|
24561
24561
|
var slice = Array.prototype.slice;
|
|
24562
24562
|
var toString = Object.prototype.toString;
|
|
24563
24563
|
module2.exports = Route;
|
|
24564
|
-
function Route(
|
|
24565
|
-
this.path =
|
|
24564
|
+
function Route(path20) {
|
|
24565
|
+
this.path = path20;
|
|
24566
24566
|
this.stack = [];
|
|
24567
|
-
debug("new %o",
|
|
24567
|
+
debug("new %o", path20);
|
|
24568
24568
|
this.methods = {};
|
|
24569
24569
|
}
|
|
24570
24570
|
Route.prototype._handles_method = function _handles_method(method) {
|
|
@@ -24776,8 +24776,8 @@ var require_router = __commonJS({
|
|
|
24776
24776
|
if (++sync > 100) {
|
|
24777
24777
|
return setImmediate(next, err);
|
|
24778
24778
|
}
|
|
24779
|
-
var
|
|
24780
|
-
if (
|
|
24779
|
+
var path20 = getPathname(req);
|
|
24780
|
+
if (path20 == null) {
|
|
24781
24781
|
return done(layerError);
|
|
24782
24782
|
}
|
|
24783
24783
|
var layer;
|
|
@@ -24785,7 +24785,7 @@ var require_router = __commonJS({
|
|
|
24785
24785
|
var route;
|
|
24786
24786
|
while (match !== true && idx < stack.length) {
|
|
24787
24787
|
layer = stack[idx++];
|
|
24788
|
-
match = matchLayer(layer,
|
|
24788
|
+
match = matchLayer(layer, path20);
|
|
24789
24789
|
route = layer.route;
|
|
24790
24790
|
if (typeof match !== "boolean") {
|
|
24791
24791
|
layerError = layerError || match;
|
|
@@ -24823,18 +24823,18 @@ var require_router = __commonJS({
|
|
|
24823
24823
|
} else if (route) {
|
|
24824
24824
|
layer.handle_request(req, res, next);
|
|
24825
24825
|
} else {
|
|
24826
|
-
trim_prefix(layer, layerError, layerPath,
|
|
24826
|
+
trim_prefix(layer, layerError, layerPath, path20);
|
|
24827
24827
|
}
|
|
24828
24828
|
sync = 0;
|
|
24829
24829
|
});
|
|
24830
24830
|
}
|
|
24831
|
-
function trim_prefix(layer, layerError, layerPath,
|
|
24831
|
+
function trim_prefix(layer, layerError, layerPath, path20) {
|
|
24832
24832
|
if (layerPath.length !== 0) {
|
|
24833
|
-
if (layerPath !==
|
|
24833
|
+
if (layerPath !== path20.slice(0, layerPath.length)) {
|
|
24834
24834
|
next(layerError);
|
|
24835
24835
|
return;
|
|
24836
24836
|
}
|
|
24837
|
-
var c =
|
|
24837
|
+
var c = path20[layerPath.length];
|
|
24838
24838
|
if (c && c !== "/" && c !== ".") return next(layerError);
|
|
24839
24839
|
debug("trim prefix (%s) from url %s", layerPath, req.url);
|
|
24840
24840
|
removed = layerPath;
|
|
@@ -24912,7 +24912,7 @@ var require_router = __commonJS({
|
|
|
24912
24912
|
};
|
|
24913
24913
|
proto.use = function use(fn) {
|
|
24914
24914
|
var offset = 0;
|
|
24915
|
-
var
|
|
24915
|
+
var path20 = "/";
|
|
24916
24916
|
if (typeof fn !== "function") {
|
|
24917
24917
|
var arg = fn;
|
|
24918
24918
|
while (Array.isArray(arg) && arg.length !== 0) {
|
|
@@ -24920,7 +24920,7 @@ var require_router = __commonJS({
|
|
|
24920
24920
|
}
|
|
24921
24921
|
if (typeof arg !== "function") {
|
|
24922
24922
|
offset = 1;
|
|
24923
|
-
|
|
24923
|
+
path20 = fn;
|
|
24924
24924
|
}
|
|
24925
24925
|
}
|
|
24926
24926
|
var callbacks = flatten(slice.call(arguments, offset));
|
|
@@ -24932,8 +24932,8 @@ var require_router = __commonJS({
|
|
|
24932
24932
|
if (typeof fn !== "function") {
|
|
24933
24933
|
throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
|
|
24934
24934
|
}
|
|
24935
|
-
debug("use %o %s",
|
|
24936
|
-
var layer = new Layer(
|
|
24935
|
+
debug("use %o %s", path20, fn.name || "<anonymous>");
|
|
24936
|
+
var layer = new Layer(path20, {
|
|
24937
24937
|
sensitive: this.caseSensitive,
|
|
24938
24938
|
strict: false,
|
|
24939
24939
|
end: false
|
|
@@ -24943,9 +24943,9 @@ var require_router = __commonJS({
|
|
|
24943
24943
|
}
|
|
24944
24944
|
return this;
|
|
24945
24945
|
};
|
|
24946
|
-
proto.route = function route(
|
|
24947
|
-
var route2 = new Route(
|
|
24948
|
-
var layer = new Layer(
|
|
24946
|
+
proto.route = function route(path20) {
|
|
24947
|
+
var route2 = new Route(path20);
|
|
24948
|
+
var layer = new Layer(path20, {
|
|
24949
24949
|
sensitive: this.caseSensitive,
|
|
24950
24950
|
strict: this.strict,
|
|
24951
24951
|
end: true
|
|
@@ -24955,8 +24955,8 @@ var require_router = __commonJS({
|
|
|
24955
24955
|
return route2;
|
|
24956
24956
|
};
|
|
24957
24957
|
methods.concat("all").forEach(function(method) {
|
|
24958
|
-
proto[method] = function(
|
|
24959
|
-
var route = this.route(
|
|
24958
|
+
proto[method] = function(path20) {
|
|
24959
|
+
var route = this.route(path20);
|
|
24960
24960
|
route[method].apply(route, slice.call(arguments, 1));
|
|
24961
24961
|
return this;
|
|
24962
24962
|
};
|
|
@@ -24992,9 +24992,9 @@ var require_router = __commonJS({
|
|
|
24992
24992
|
}
|
|
24993
24993
|
return toString.call(obj).replace(objectRegExp, "$1");
|
|
24994
24994
|
}
|
|
24995
|
-
function matchLayer(layer,
|
|
24995
|
+
function matchLayer(layer, path20) {
|
|
24996
24996
|
try {
|
|
24997
|
-
return layer.match(
|
|
24997
|
+
return layer.match(path20);
|
|
24998
24998
|
} catch (err) {
|
|
24999
24999
|
return err;
|
|
25000
25000
|
}
|
|
@@ -25995,13 +25995,13 @@ var require_view = __commonJS({
|
|
|
25995
25995
|
"../../node_modules/express/lib/view.js"(exports2, module2) {
|
|
25996
25996
|
"use strict";
|
|
25997
25997
|
var debug = require_src3()("express:view");
|
|
25998
|
-
var
|
|
25998
|
+
var path20 = require("path");
|
|
25999
25999
|
var fs4 = require("fs");
|
|
26000
|
-
var dirname =
|
|
26001
|
-
var basename =
|
|
26002
|
-
var extname =
|
|
26003
|
-
var join2 =
|
|
26004
|
-
var resolve =
|
|
26000
|
+
var dirname = path20.dirname;
|
|
26001
|
+
var basename = path20.basename;
|
|
26002
|
+
var extname = path20.extname;
|
|
26003
|
+
var join2 = path20.join;
|
|
26004
|
+
var resolve = path20.resolve;
|
|
26005
26005
|
module2.exports = View;
|
|
26006
26006
|
function View(name, options) {
|
|
26007
26007
|
var opts = options || {};
|
|
@@ -26030,17 +26030,17 @@ var require_view = __commonJS({
|
|
|
26030
26030
|
this.path = this.lookup(fileName);
|
|
26031
26031
|
}
|
|
26032
26032
|
View.prototype.lookup = function lookup(name) {
|
|
26033
|
-
var
|
|
26033
|
+
var path21;
|
|
26034
26034
|
var roots = [].concat(this.root);
|
|
26035
26035
|
debug('lookup "%s"', name);
|
|
26036
|
-
for (var i = 0; i < roots.length && !
|
|
26036
|
+
for (var i = 0; i < roots.length && !path21; i++) {
|
|
26037
26037
|
var root = roots[i];
|
|
26038
26038
|
var loc = resolve(root, name);
|
|
26039
26039
|
var dir = dirname(loc);
|
|
26040
26040
|
var file2 = basename(loc);
|
|
26041
|
-
|
|
26041
|
+
path21 = this.resolve(dir, file2);
|
|
26042
26042
|
}
|
|
26043
|
-
return
|
|
26043
|
+
return path21;
|
|
26044
26044
|
};
|
|
26045
26045
|
View.prototype.render = function render(options, callback) {
|
|
26046
26046
|
debug('render "%s"', this.path);
|
|
@@ -26048,21 +26048,21 @@ var require_view = __commonJS({
|
|
|
26048
26048
|
};
|
|
26049
26049
|
View.prototype.resolve = function resolve2(dir, file2) {
|
|
26050
26050
|
var ext = this.ext;
|
|
26051
|
-
var
|
|
26052
|
-
var stat = tryStat(
|
|
26051
|
+
var path21 = join2(dir, file2);
|
|
26052
|
+
var stat = tryStat(path21);
|
|
26053
26053
|
if (stat && stat.isFile()) {
|
|
26054
|
-
return
|
|
26054
|
+
return path21;
|
|
26055
26055
|
}
|
|
26056
|
-
|
|
26057
|
-
stat = tryStat(
|
|
26056
|
+
path21 = join2(dir, basename(file2, ext), "index" + ext);
|
|
26057
|
+
stat = tryStat(path21);
|
|
26058
26058
|
if (stat && stat.isFile()) {
|
|
26059
|
-
return
|
|
26059
|
+
return path21;
|
|
26060
26060
|
}
|
|
26061
26061
|
};
|
|
26062
|
-
function tryStat(
|
|
26063
|
-
debug('stat "%s"',
|
|
26062
|
+
function tryStat(path21) {
|
|
26063
|
+
debug('stat "%s"', path21);
|
|
26064
26064
|
try {
|
|
26065
|
-
return fs4.statSync(
|
|
26065
|
+
return fs4.statSync(path21);
|
|
26066
26066
|
} catch (e) {
|
|
26067
26067
|
return void 0;
|
|
26068
26068
|
}
|
|
@@ -26840,7 +26840,7 @@ var require_types = __commonJS({
|
|
|
26840
26840
|
// ../../node_modules/mime/mime.js
|
|
26841
26841
|
var require_mime = __commonJS({
|
|
26842
26842
|
"../../node_modules/mime/mime.js"(exports2, module2) {
|
|
26843
|
-
var
|
|
26843
|
+
var path20 = require("path");
|
|
26844
26844
|
var fs4 = require("fs");
|
|
26845
26845
|
function Mime() {
|
|
26846
26846
|
this.types = /* @__PURE__ */ Object.create(null);
|
|
@@ -26870,8 +26870,8 @@ var require_mime = __commonJS({
|
|
|
26870
26870
|
this.define(map2);
|
|
26871
26871
|
this._loading = null;
|
|
26872
26872
|
};
|
|
26873
|
-
Mime.prototype.lookup = function(
|
|
26874
|
-
var ext =
|
|
26873
|
+
Mime.prototype.lookup = function(path21, fallback) {
|
|
26874
|
+
var ext = path21.replace(/^.*[\.\/\\]/, "").toLowerCase();
|
|
26875
26875
|
return this.types[ext] || fallback || this.default_type;
|
|
26876
26876
|
};
|
|
26877
26877
|
Mime.prototype.extension = function(mimeType) {
|
|
@@ -27105,28 +27105,28 @@ var require_send = __commonJS({
|
|
|
27105
27105
|
var ms = require_ms5();
|
|
27106
27106
|
var onFinished = require_on_finished();
|
|
27107
27107
|
var parseRange = require_range_parser();
|
|
27108
|
-
var
|
|
27108
|
+
var path20 = require("path");
|
|
27109
27109
|
var statuses = require_statuses();
|
|
27110
27110
|
var Stream = require("stream");
|
|
27111
27111
|
var util = require("util");
|
|
27112
|
-
var extname =
|
|
27113
|
-
var join2 =
|
|
27114
|
-
var normalize =
|
|
27115
|
-
var resolve =
|
|
27116
|
-
var sep =
|
|
27112
|
+
var extname = path20.extname;
|
|
27113
|
+
var join2 = path20.join;
|
|
27114
|
+
var normalize = path20.normalize;
|
|
27115
|
+
var resolve = path20.resolve;
|
|
27116
|
+
var sep = path20.sep;
|
|
27117
27117
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
27118
27118
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
27119
27119
|
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
27120
27120
|
module2.exports = send2;
|
|
27121
27121
|
module2.exports.mime = mime;
|
|
27122
|
-
function send2(req,
|
|
27123
|
-
return new SendStream(req,
|
|
27122
|
+
function send2(req, path21, options) {
|
|
27123
|
+
return new SendStream(req, path21, options);
|
|
27124
27124
|
}
|
|
27125
|
-
function SendStream(req,
|
|
27125
|
+
function SendStream(req, path21, options) {
|
|
27126
27126
|
Stream.call(this);
|
|
27127
27127
|
var opts = options || {};
|
|
27128
27128
|
this.options = opts;
|
|
27129
|
-
this.path =
|
|
27129
|
+
this.path = path21;
|
|
27130
27130
|
this.req = req;
|
|
27131
27131
|
this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
|
|
27132
27132
|
this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
|
|
@@ -27172,8 +27172,8 @@ var require_send = __commonJS({
|
|
|
27172
27172
|
this._index = index2;
|
|
27173
27173
|
return this;
|
|
27174
27174
|
}, "send.index: pass index as option");
|
|
27175
|
-
SendStream.prototype.root = function root(
|
|
27176
|
-
this._root = resolve(String(
|
|
27175
|
+
SendStream.prototype.root = function root(path21) {
|
|
27176
|
+
this._root = resolve(String(path21));
|
|
27177
27177
|
debug("root %s", this._root);
|
|
27178
27178
|
return this;
|
|
27179
27179
|
};
|
|
@@ -27286,10 +27286,10 @@ var require_send = __commonJS({
|
|
|
27286
27286
|
var lastModified = this.res.getHeader("Last-Modified");
|
|
27287
27287
|
return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
|
|
27288
27288
|
};
|
|
27289
|
-
SendStream.prototype.redirect = function redirect(
|
|
27289
|
+
SendStream.prototype.redirect = function redirect(path21) {
|
|
27290
27290
|
var res = this.res;
|
|
27291
27291
|
if (hasListeners(this, "directory")) {
|
|
27292
|
-
this.emit("directory", res,
|
|
27292
|
+
this.emit("directory", res, path21);
|
|
27293
27293
|
return;
|
|
27294
27294
|
}
|
|
27295
27295
|
if (this.hasTrailingSlash()) {
|
|
@@ -27309,42 +27309,42 @@ var require_send = __commonJS({
|
|
|
27309
27309
|
SendStream.prototype.pipe = function pipe2(res) {
|
|
27310
27310
|
var root = this._root;
|
|
27311
27311
|
this.res = res;
|
|
27312
|
-
var
|
|
27313
|
-
if (
|
|
27312
|
+
var path21 = decode3(this.path);
|
|
27313
|
+
if (path21 === -1) {
|
|
27314
27314
|
this.error(400);
|
|
27315
27315
|
return res;
|
|
27316
27316
|
}
|
|
27317
|
-
if (~
|
|
27317
|
+
if (~path21.indexOf("\0")) {
|
|
27318
27318
|
this.error(400);
|
|
27319
27319
|
return res;
|
|
27320
27320
|
}
|
|
27321
27321
|
var parts;
|
|
27322
27322
|
if (root !== null) {
|
|
27323
|
-
if (
|
|
27324
|
-
|
|
27323
|
+
if (path21) {
|
|
27324
|
+
path21 = normalize("." + sep + path21);
|
|
27325
27325
|
}
|
|
27326
|
-
if (UP_PATH_REGEXP.test(
|
|
27327
|
-
debug('malicious path "%s"',
|
|
27326
|
+
if (UP_PATH_REGEXP.test(path21)) {
|
|
27327
|
+
debug('malicious path "%s"', path21);
|
|
27328
27328
|
this.error(403);
|
|
27329
27329
|
return res;
|
|
27330
27330
|
}
|
|
27331
|
-
parts =
|
|
27332
|
-
|
|
27331
|
+
parts = path21.split(sep);
|
|
27332
|
+
path21 = normalize(join2(root, path21));
|
|
27333
27333
|
} else {
|
|
27334
|
-
if (UP_PATH_REGEXP.test(
|
|
27335
|
-
debug('malicious path "%s"',
|
|
27334
|
+
if (UP_PATH_REGEXP.test(path21)) {
|
|
27335
|
+
debug('malicious path "%s"', path21);
|
|
27336
27336
|
this.error(403);
|
|
27337
27337
|
return res;
|
|
27338
27338
|
}
|
|
27339
|
-
parts = normalize(
|
|
27340
|
-
|
|
27339
|
+
parts = normalize(path21).split(sep);
|
|
27340
|
+
path21 = resolve(path21);
|
|
27341
27341
|
}
|
|
27342
27342
|
if (containsDotFile(parts)) {
|
|
27343
27343
|
var access2 = this._dotfiles;
|
|
27344
27344
|
if (access2 === void 0) {
|
|
27345
27345
|
access2 = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
|
|
27346
27346
|
}
|
|
27347
|
-
debug('%s dotfile "%s"', access2,
|
|
27347
|
+
debug('%s dotfile "%s"', access2, path21);
|
|
27348
27348
|
switch (access2) {
|
|
27349
27349
|
case "allow":
|
|
27350
27350
|
break;
|
|
@@ -27358,13 +27358,13 @@ var require_send = __commonJS({
|
|
|
27358
27358
|
}
|
|
27359
27359
|
}
|
|
27360
27360
|
if (this._index.length && this.hasTrailingSlash()) {
|
|
27361
|
-
this.sendIndex(
|
|
27361
|
+
this.sendIndex(path21);
|
|
27362
27362
|
return res;
|
|
27363
27363
|
}
|
|
27364
|
-
this.sendFile(
|
|
27364
|
+
this.sendFile(path21);
|
|
27365
27365
|
return res;
|
|
27366
27366
|
};
|
|
27367
|
-
SendStream.prototype.send = function send3(
|
|
27367
|
+
SendStream.prototype.send = function send3(path21, stat) {
|
|
27368
27368
|
var len = stat.size;
|
|
27369
27369
|
var options = this.options;
|
|
27370
27370
|
var opts = {};
|
|
@@ -27376,9 +27376,9 @@ var require_send = __commonJS({
|
|
|
27376
27376
|
this.headersAlreadySent();
|
|
27377
27377
|
return;
|
|
27378
27378
|
}
|
|
27379
|
-
debug('pipe "%s"',
|
|
27380
|
-
this.setHeader(
|
|
27381
|
-
this.type(
|
|
27379
|
+
debug('pipe "%s"', path21);
|
|
27380
|
+
this.setHeader(path21, stat);
|
|
27381
|
+
this.type(path21);
|
|
27382
27382
|
if (this.isConditionalGET()) {
|
|
27383
27383
|
if (this.isPreconditionFailure()) {
|
|
27384
27384
|
this.error(412);
|
|
@@ -27427,26 +27427,26 @@ var require_send = __commonJS({
|
|
|
27427
27427
|
res.end();
|
|
27428
27428
|
return;
|
|
27429
27429
|
}
|
|
27430
|
-
this.stream(
|
|
27430
|
+
this.stream(path21, opts);
|
|
27431
27431
|
};
|
|
27432
|
-
SendStream.prototype.sendFile = function sendFile(
|
|
27432
|
+
SendStream.prototype.sendFile = function sendFile(path21) {
|
|
27433
27433
|
var i = 0;
|
|
27434
27434
|
var self2 = this;
|
|
27435
|
-
debug('stat "%s"',
|
|
27436
|
-
fs4.stat(
|
|
27437
|
-
if (err && err.code === "ENOENT" && !extname(
|
|
27435
|
+
debug('stat "%s"', path21);
|
|
27436
|
+
fs4.stat(path21, function onstat(err, stat) {
|
|
27437
|
+
if (err && err.code === "ENOENT" && !extname(path21) && path21[path21.length - 1] !== sep) {
|
|
27438
27438
|
return next(err);
|
|
27439
27439
|
}
|
|
27440
27440
|
if (err) return self2.onStatError(err);
|
|
27441
|
-
if (stat.isDirectory()) return self2.redirect(
|
|
27442
|
-
self2.emit("file",
|
|
27443
|
-
self2.send(
|
|
27441
|
+
if (stat.isDirectory()) return self2.redirect(path21);
|
|
27442
|
+
self2.emit("file", path21, stat);
|
|
27443
|
+
self2.send(path21, stat);
|
|
27444
27444
|
});
|
|
27445
27445
|
function next(err) {
|
|
27446
27446
|
if (self2._extensions.length <= i) {
|
|
27447
27447
|
return err ? self2.onStatError(err) : self2.error(404);
|
|
27448
27448
|
}
|
|
27449
|
-
var p =
|
|
27449
|
+
var p = path21 + "." + self2._extensions[i++];
|
|
27450
27450
|
debug('stat "%s"', p);
|
|
27451
27451
|
fs4.stat(p, function(err2, stat) {
|
|
27452
27452
|
if (err2) return next(err2);
|
|
@@ -27456,7 +27456,7 @@ var require_send = __commonJS({
|
|
|
27456
27456
|
});
|
|
27457
27457
|
}
|
|
27458
27458
|
};
|
|
27459
|
-
SendStream.prototype.sendIndex = function sendIndex(
|
|
27459
|
+
SendStream.prototype.sendIndex = function sendIndex(path21) {
|
|
27460
27460
|
var i = -1;
|
|
27461
27461
|
var self2 = this;
|
|
27462
27462
|
function next(err) {
|
|
@@ -27464,7 +27464,7 @@ var require_send = __commonJS({
|
|
|
27464
27464
|
if (err) return self2.onStatError(err);
|
|
27465
27465
|
return self2.error(404);
|
|
27466
27466
|
}
|
|
27467
|
-
var p = join2(
|
|
27467
|
+
var p = join2(path21, self2._index[i]);
|
|
27468
27468
|
debug('stat "%s"', p);
|
|
27469
27469
|
fs4.stat(p, function(err2, stat) {
|
|
27470
27470
|
if (err2) return next(err2);
|
|
@@ -27475,10 +27475,10 @@ var require_send = __commonJS({
|
|
|
27475
27475
|
}
|
|
27476
27476
|
next();
|
|
27477
27477
|
};
|
|
27478
|
-
SendStream.prototype.stream = function stream(
|
|
27478
|
+
SendStream.prototype.stream = function stream(path21, options) {
|
|
27479
27479
|
var self2 = this;
|
|
27480
27480
|
var res = this.res;
|
|
27481
|
-
var stream2 = fs4.createReadStream(
|
|
27481
|
+
var stream2 = fs4.createReadStream(path21, options);
|
|
27482
27482
|
this.emit("stream", stream2);
|
|
27483
27483
|
stream2.pipe(res);
|
|
27484
27484
|
function cleanup() {
|
|
@@ -27493,10 +27493,10 @@ var require_send = __commonJS({
|
|
|
27493
27493
|
self2.emit("end");
|
|
27494
27494
|
});
|
|
27495
27495
|
};
|
|
27496
|
-
SendStream.prototype.type = function type(
|
|
27496
|
+
SendStream.prototype.type = function type(path21) {
|
|
27497
27497
|
var res = this.res;
|
|
27498
27498
|
if (res.getHeader("Content-Type")) return;
|
|
27499
|
-
var type2 = mime.lookup(
|
|
27499
|
+
var type2 = mime.lookup(path21);
|
|
27500
27500
|
if (!type2) {
|
|
27501
27501
|
debug("no content-type");
|
|
27502
27502
|
return;
|
|
@@ -27505,9 +27505,9 @@ var require_send = __commonJS({
|
|
|
27505
27505
|
debug("content-type %s", type2);
|
|
27506
27506
|
res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
|
|
27507
27507
|
};
|
|
27508
|
-
SendStream.prototype.setHeader = function setHeader(
|
|
27508
|
+
SendStream.prototype.setHeader = function setHeader(path21, stat) {
|
|
27509
27509
|
var res = this.res;
|
|
27510
|
-
this.emit("headers", res,
|
|
27510
|
+
this.emit("headers", res, path21, stat);
|
|
27511
27511
|
if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
|
|
27512
27512
|
debug("accept ranges");
|
|
27513
27513
|
res.setHeader("Accept-Ranges", "bytes");
|
|
@@ -27566,9 +27566,9 @@ var require_send = __commonJS({
|
|
|
27566
27566
|
}
|
|
27567
27567
|
return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
|
|
27568
27568
|
}
|
|
27569
|
-
function decode3(
|
|
27569
|
+
function decode3(path21) {
|
|
27570
27570
|
try {
|
|
27571
|
-
return decodeURIComponent(
|
|
27571
|
+
return decodeURIComponent(path21);
|
|
27572
27572
|
} catch (err) {
|
|
27573
27573
|
return -1;
|
|
27574
27574
|
}
|
|
@@ -28477,10 +28477,10 @@ var require_utils3 = __commonJS({
|
|
|
28477
28477
|
var querystring = require("querystring");
|
|
28478
28478
|
exports2.etag = createETagGenerator({ weak: false });
|
|
28479
28479
|
exports2.wetag = createETagGenerator({ weak: true });
|
|
28480
|
-
exports2.isAbsolute = function(
|
|
28481
|
-
if ("/" ===
|
|
28482
|
-
if (":" ===
|
|
28483
|
-
if ("\\\\" ===
|
|
28480
|
+
exports2.isAbsolute = function(path20) {
|
|
28481
|
+
if ("/" === path20[0]) return true;
|
|
28482
|
+
if (":" === path20[1] && ("\\" === path20[2] || "/" === path20[2])) return true;
|
|
28483
|
+
if ("\\\\" === path20.substring(0, 2)) return true;
|
|
28484
28484
|
};
|
|
28485
28485
|
exports2.flatten = deprecate.function(
|
|
28486
28486
|
flatten,
|
|
@@ -28691,7 +28691,7 @@ var require_application = __commonJS({
|
|
|
28691
28691
|
};
|
|
28692
28692
|
app.use = function use(fn) {
|
|
28693
28693
|
var offset = 0;
|
|
28694
|
-
var
|
|
28694
|
+
var path20 = "/";
|
|
28695
28695
|
if (typeof fn !== "function") {
|
|
28696
28696
|
var arg = fn;
|
|
28697
28697
|
while (Array.isArray(arg) && arg.length !== 0) {
|
|
@@ -28699,7 +28699,7 @@ var require_application = __commonJS({
|
|
|
28699
28699
|
}
|
|
28700
28700
|
if (typeof arg !== "function") {
|
|
28701
28701
|
offset = 1;
|
|
28702
|
-
|
|
28702
|
+
path20 = fn;
|
|
28703
28703
|
}
|
|
28704
28704
|
}
|
|
28705
28705
|
var fns = flatten(slice.call(arguments, offset));
|
|
@@ -28710,12 +28710,12 @@ var require_application = __commonJS({
|
|
|
28710
28710
|
var router = this._router;
|
|
28711
28711
|
fns.forEach(function(fn2) {
|
|
28712
28712
|
if (!fn2 || !fn2.handle || !fn2.set) {
|
|
28713
|
-
return router.use(
|
|
28713
|
+
return router.use(path20, fn2);
|
|
28714
28714
|
}
|
|
28715
|
-
debug(".use app under %s",
|
|
28716
|
-
fn2.mountpath =
|
|
28715
|
+
debug(".use app under %s", path20);
|
|
28716
|
+
fn2.mountpath = path20;
|
|
28717
28717
|
fn2.parent = this;
|
|
28718
|
-
router.use(
|
|
28718
|
+
router.use(path20, function mounted_app(req, res, next) {
|
|
28719
28719
|
var orig = req.app;
|
|
28720
28720
|
fn2.handle(req, res, function(err) {
|
|
28721
28721
|
setPrototypeOf(req, orig.request);
|
|
@@ -28727,9 +28727,9 @@ var require_application = __commonJS({
|
|
|
28727
28727
|
}, this);
|
|
28728
28728
|
return this;
|
|
28729
28729
|
};
|
|
28730
|
-
app.route = function route(
|
|
28730
|
+
app.route = function route(path20) {
|
|
28731
28731
|
this.lazyrouter();
|
|
28732
|
-
return this._router.route(
|
|
28732
|
+
return this._router.route(path20);
|
|
28733
28733
|
};
|
|
28734
28734
|
app.engine = function engine(ext, fn) {
|
|
28735
28735
|
if (typeof fn !== "function") {
|
|
@@ -28780,7 +28780,7 @@ var require_application = __commonJS({
|
|
|
28780
28780
|
}
|
|
28781
28781
|
return this;
|
|
28782
28782
|
};
|
|
28783
|
-
app.path = function
|
|
28783
|
+
app.path = function path20() {
|
|
28784
28784
|
return this.parent ? this.parent.path() + this.mountpath : "";
|
|
28785
28785
|
};
|
|
28786
28786
|
app.enabled = function enabled(setting) {
|
|
@@ -28796,19 +28796,19 @@ var require_application = __commonJS({
|
|
|
28796
28796
|
return this.set(setting, false);
|
|
28797
28797
|
};
|
|
28798
28798
|
methods.forEach(function(method) {
|
|
28799
|
-
app[method] = function(
|
|
28799
|
+
app[method] = function(path20) {
|
|
28800
28800
|
if (method === "get" && arguments.length === 1) {
|
|
28801
|
-
return this.set(
|
|
28801
|
+
return this.set(path20);
|
|
28802
28802
|
}
|
|
28803
28803
|
this.lazyrouter();
|
|
28804
|
-
var route = this._router.route(
|
|
28804
|
+
var route = this._router.route(path20);
|
|
28805
28805
|
route[method].apply(route, slice.call(arguments, 1));
|
|
28806
28806
|
return this;
|
|
28807
28807
|
};
|
|
28808
28808
|
});
|
|
28809
|
-
app.all = function all(
|
|
28809
|
+
app.all = function all(path20) {
|
|
28810
28810
|
this.lazyrouter();
|
|
28811
|
-
var route = this._router.route(
|
|
28811
|
+
var route = this._router.route(path20);
|
|
28812
28812
|
var args = slice.call(arguments, 1);
|
|
28813
28813
|
for (var i = 0; i < methods.length; i++) {
|
|
28814
28814
|
route[methods[i]].apply(route, args);
|
|
@@ -29567,7 +29567,7 @@ var require_request = __commonJS({
|
|
|
29567
29567
|
var subdomains2 = !isIP2(hostname3) ? hostname3.split(".").reverse() : [hostname3];
|
|
29568
29568
|
return subdomains2.slice(offset);
|
|
29569
29569
|
});
|
|
29570
|
-
defineGetter(req, "path", function
|
|
29570
|
+
defineGetter(req, "path", function path20() {
|
|
29571
29571
|
return parse3(this).pathname;
|
|
29572
29572
|
});
|
|
29573
29573
|
defineGetter(req, "hostname", function hostname3() {
|
|
@@ -29889,7 +29889,7 @@ var require_response = __commonJS({
|
|
|
29889
29889
|
var http2 = require("http");
|
|
29890
29890
|
var isAbsolute = require_utils3().isAbsolute;
|
|
29891
29891
|
var onFinished = require_on_finished();
|
|
29892
|
-
var
|
|
29892
|
+
var path20 = require("path");
|
|
29893
29893
|
var statuses = require_statuses();
|
|
29894
29894
|
var merge2 = require_utils_merge();
|
|
29895
29895
|
var sign = require_cookie_signature().sign;
|
|
@@ -29898,9 +29898,9 @@ var require_response = __commonJS({
|
|
|
29898
29898
|
var setCharset = require_utils3().setCharset;
|
|
29899
29899
|
var cookie = require_cookie();
|
|
29900
29900
|
var send2 = require_send();
|
|
29901
|
-
var extname =
|
|
29901
|
+
var extname = path20.extname;
|
|
29902
29902
|
var mime = send2.mime;
|
|
29903
|
-
var resolve =
|
|
29903
|
+
var resolve = path20.resolve;
|
|
29904
29904
|
var vary = require_vary();
|
|
29905
29905
|
var res = Object.create(http2.ServerResponse.prototype);
|
|
29906
29906
|
module2.exports = res;
|
|
@@ -30077,26 +30077,26 @@ var require_response = __commonJS({
|
|
|
30077
30077
|
this.type("txt");
|
|
30078
30078
|
return this.send(body);
|
|
30079
30079
|
};
|
|
30080
|
-
res.sendFile = function sendFile(
|
|
30080
|
+
res.sendFile = function sendFile(path21, options, callback) {
|
|
30081
30081
|
var done = callback;
|
|
30082
30082
|
var req = this.req;
|
|
30083
30083
|
var res2 = this;
|
|
30084
30084
|
var next = req.next;
|
|
30085
30085
|
var opts = options || {};
|
|
30086
|
-
if (!
|
|
30086
|
+
if (!path21) {
|
|
30087
30087
|
throw new TypeError("path argument is required to res.sendFile");
|
|
30088
30088
|
}
|
|
30089
|
-
if (typeof
|
|
30089
|
+
if (typeof path21 !== "string") {
|
|
30090
30090
|
throw new TypeError("path must be a string to res.sendFile");
|
|
30091
30091
|
}
|
|
30092
30092
|
if (typeof options === "function") {
|
|
30093
30093
|
done = options;
|
|
30094
30094
|
opts = {};
|
|
30095
30095
|
}
|
|
30096
|
-
if (!opts.root && !isAbsolute(
|
|
30096
|
+
if (!opts.root && !isAbsolute(path21)) {
|
|
30097
30097
|
throw new TypeError("path must be absolute or specify root to res.sendFile");
|
|
30098
30098
|
}
|
|
30099
|
-
var pathname = encodeURI(
|
|
30099
|
+
var pathname = encodeURI(path21);
|
|
30100
30100
|
var file2 = send2(req, pathname, opts);
|
|
30101
30101
|
sendfile(res2, file2, opts, function(err) {
|
|
30102
30102
|
if (done) return done(err);
|
|
@@ -30106,7 +30106,7 @@ var require_response = __commonJS({
|
|
|
30106
30106
|
}
|
|
30107
30107
|
});
|
|
30108
30108
|
};
|
|
30109
|
-
res.sendfile = function(
|
|
30109
|
+
res.sendfile = function(path21, options, callback) {
|
|
30110
30110
|
var done = callback;
|
|
30111
30111
|
var req = this.req;
|
|
30112
30112
|
var res2 = this;
|
|
@@ -30116,7 +30116,7 @@ var require_response = __commonJS({
|
|
|
30116
30116
|
done = options;
|
|
30117
30117
|
opts = {};
|
|
30118
30118
|
}
|
|
30119
|
-
var file2 = send2(req,
|
|
30119
|
+
var file2 = send2(req, path21, opts);
|
|
30120
30120
|
sendfile(res2, file2, opts, function(err) {
|
|
30121
30121
|
if (done) return done(err);
|
|
30122
30122
|
if (err && err.code === "EISDIR") return next();
|
|
@@ -30129,7 +30129,7 @@ var require_response = __commonJS({
|
|
|
30129
30129
|
res.sendfile,
|
|
30130
30130
|
"res.sendfile: Use res.sendFile instead"
|
|
30131
30131
|
);
|
|
30132
|
-
res.download = function download(
|
|
30132
|
+
res.download = function download(path21, filename, options, callback) {
|
|
30133
30133
|
var done = callback;
|
|
30134
30134
|
var name = filename;
|
|
30135
30135
|
var opts = options || null;
|
|
@@ -30146,7 +30146,7 @@ var require_response = __commonJS({
|
|
|
30146
30146
|
opts = filename;
|
|
30147
30147
|
}
|
|
30148
30148
|
var headers = {
|
|
30149
|
-
"Content-Disposition": contentDisposition(name ||
|
|
30149
|
+
"Content-Disposition": contentDisposition(name || path21)
|
|
30150
30150
|
};
|
|
30151
30151
|
if (opts && opts.headers) {
|
|
30152
30152
|
var keys = Object.keys(opts.headers);
|
|
@@ -30159,7 +30159,7 @@ var require_response = __commonJS({
|
|
|
30159
30159
|
}
|
|
30160
30160
|
opts = Object.create(opts);
|
|
30161
30161
|
opts.headers = headers;
|
|
30162
|
-
var fullPath = !opts.root ? resolve(
|
|
30162
|
+
var fullPath = !opts.root ? resolve(path21) : path21;
|
|
30163
30163
|
return this.sendFile(fullPath, opts, done);
|
|
30164
30164
|
};
|
|
30165
30165
|
res.contentType = res.type = function contentType(type) {
|
|
@@ -30460,11 +30460,11 @@ var require_serve_static = __commonJS({
|
|
|
30460
30460
|
}
|
|
30461
30461
|
var forwardError = !fallthrough;
|
|
30462
30462
|
var originalUrl = parseUrl.original(req);
|
|
30463
|
-
var
|
|
30464
|
-
if (
|
|
30465
|
-
|
|
30463
|
+
var path20 = parseUrl(req).pathname;
|
|
30464
|
+
if (path20 === "/" && originalUrl.pathname.substr(-1) !== "/") {
|
|
30465
|
+
path20 = "";
|
|
30466
30466
|
}
|
|
30467
|
-
var stream = send2(req,
|
|
30467
|
+
var stream = send2(req, path20, opts);
|
|
30468
30468
|
stream.on("directory", onDirectory);
|
|
30469
30469
|
if (setHeaders) {
|
|
30470
30470
|
stream.on("headers", setHeaders);
|
|
@@ -34232,9 +34232,9 @@ __export(index_exports, {
|
|
|
34232
34232
|
});
|
|
34233
34233
|
module.exports = __toCommonJS(index_exports);
|
|
34234
34234
|
var import_node_child_process3 = require("node:child_process");
|
|
34235
|
-
var
|
|
34236
|
-
var
|
|
34237
|
-
var
|
|
34235
|
+
var import_node_fs18 = require("node:fs");
|
|
34236
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
34237
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
34238
34238
|
var import_node_module = require("node:module");
|
|
34239
34239
|
var import_node_url2 = require("node:url");
|
|
34240
34240
|
|
|
@@ -34387,22 +34387,22 @@ var Daemon = class {
|
|
|
34387
34387
|
}
|
|
34388
34388
|
async install() {
|
|
34389
34389
|
if (this.platform === "darwin") {
|
|
34390
|
-
const
|
|
34391
|
-
if ((0, import_node_fs.existsSync)(
|
|
34392
|
-
await this.exec("launchctl", ["unload", "-w",
|
|
34390
|
+
const path20 = plistPath(this.home, this.name);
|
|
34391
|
+
if ((0, import_node_fs.existsSync)(path20)) {
|
|
34392
|
+
await this.exec("launchctl", ["unload", "-w", path20]).catch(() => void 0);
|
|
34393
34393
|
}
|
|
34394
34394
|
await (0, import_promises.mkdir)((0, import_node_path.join)(this.home, "Library", "LaunchAgents"), { recursive: true });
|
|
34395
|
-
await (0, import_promises.writeFile)(
|
|
34396
|
-
await this.exec("launchctl", ["load", "-w",
|
|
34395
|
+
await (0, import_promises.writeFile)(path20, renderPlist(this.name, this.programArgs, this.env), "utf8");
|
|
34396
|
+
await this.exec("launchctl", ["load", "-w", path20]);
|
|
34397
34397
|
return;
|
|
34398
34398
|
}
|
|
34399
34399
|
if (this.platform === "linux") {
|
|
34400
|
-
const
|
|
34401
|
-
if ((0, import_node_fs.existsSync)(
|
|
34400
|
+
const path20 = unitPath(this.home, this.name);
|
|
34401
|
+
if ((0, import_node_fs.existsSync)(path20)) {
|
|
34402
34402
|
await this.exec("systemctl", ["--user", "disable", "--now", `${this.name}.service`]).catch(() => void 0);
|
|
34403
34403
|
}
|
|
34404
34404
|
await (0, import_promises.mkdir)((0, import_node_path.join)(this.home, ".config", "systemd", "user"), { recursive: true });
|
|
34405
|
-
await (0, import_promises.writeFile)(
|
|
34405
|
+
await (0, import_promises.writeFile)(path20, renderUnit(this.description, this.programArgs, this.env), "utf8");
|
|
34406
34406
|
await this.exec("systemctl", ["--user", "daemon-reload"]);
|
|
34407
34407
|
await this.exec("systemctl", ["--user", "enable", "--now", `${this.name}.service`]);
|
|
34408
34408
|
return;
|
|
@@ -34411,17 +34411,17 @@ var Daemon = class {
|
|
|
34411
34411
|
}
|
|
34412
34412
|
async uninstall() {
|
|
34413
34413
|
if (this.platform === "darwin") {
|
|
34414
|
-
const
|
|
34415
|
-
if ((0, import_node_fs.existsSync)(
|
|
34416
|
-
await this.exec("launchctl", ["unload", "-w",
|
|
34417
|
-
await (0, import_promises.rm)(
|
|
34414
|
+
const path20 = plistPath(this.home, this.name);
|
|
34415
|
+
if ((0, import_node_fs.existsSync)(path20)) {
|
|
34416
|
+
await this.exec("launchctl", ["unload", "-w", path20]).catch(() => void 0);
|
|
34417
|
+
await (0, import_promises.rm)(path20, { force: true });
|
|
34418
34418
|
}
|
|
34419
34419
|
return;
|
|
34420
34420
|
}
|
|
34421
34421
|
if (this.platform === "linux") {
|
|
34422
|
-
const
|
|
34422
|
+
const path20 = unitPath(this.home, this.name);
|
|
34423
34423
|
await this.exec("systemctl", ["--user", "disable", "--now", `${this.name}.service`]).catch(() => void 0);
|
|
34424
|
-
await (0, import_promises.rm)(
|
|
34424
|
+
await (0, import_promises.rm)(path20, { force: true });
|
|
34425
34425
|
await this.exec("systemctl", ["--user", "daemon-reload"]);
|
|
34426
34426
|
return;
|
|
34427
34427
|
}
|
|
@@ -34429,8 +34429,8 @@ var Daemon = class {
|
|
|
34429
34429
|
}
|
|
34430
34430
|
async status() {
|
|
34431
34431
|
if (this.platform === "darwin") {
|
|
34432
|
-
const
|
|
34433
|
-
if (!(0, import_node_fs.existsSync)(
|
|
34432
|
+
const path20 = plistPath(this.home, this.name);
|
|
34433
|
+
if (!(0, import_node_fs.existsSync)(path20))
|
|
34434
34434
|
return { installed: false, running: false };
|
|
34435
34435
|
try {
|
|
34436
34436
|
await this.exec("launchctl", ["list", this.name]);
|
|
@@ -34440,8 +34440,8 @@ var Daemon = class {
|
|
|
34440
34440
|
}
|
|
34441
34441
|
}
|
|
34442
34442
|
if (this.platform === "linux") {
|
|
34443
|
-
const
|
|
34444
|
-
if (!(0, import_node_fs.existsSync)(
|
|
34443
|
+
const path20 = unitPath(this.home, this.name);
|
|
34444
|
+
if (!(0, import_node_fs.existsSync)(path20))
|
|
34445
34445
|
return { installed: false, running: false };
|
|
34446
34446
|
try {
|
|
34447
34447
|
const result = await this.exec("systemctl", [
|
|
@@ -34465,9 +34465,9 @@ require_shim7()();
|
|
|
34465
34465
|
|
|
34466
34466
|
// ../server/src/server.ts
|
|
34467
34467
|
var import_express2 = __toESM(require_express2(), 1);
|
|
34468
|
-
var
|
|
34468
|
+
var import_node_fs11 = require("node:fs");
|
|
34469
34469
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
34470
|
-
var
|
|
34470
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
34471
34471
|
var import_node_url = require("node:url");
|
|
34472
34472
|
|
|
34473
34473
|
// ../server/src/config.ts
|
|
@@ -34595,6 +34595,11 @@ function isVitestRuntime() {
|
|
|
34595
34595
|
return process.env.VITEST === TRUE_ENV_VALUE;
|
|
34596
34596
|
}
|
|
34597
34597
|
|
|
34598
|
+
// ../server/src/routes.ts
|
|
34599
|
+
var import_node_fs7 = require("node:fs");
|
|
34600
|
+
var import_node_os3 = __toESM(require("node:os"), 1);
|
|
34601
|
+
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
34602
|
+
|
|
34598
34603
|
// ../../node_modules/zod/v4/classic/external.js
|
|
34599
34604
|
var external_exports = {};
|
|
34600
34605
|
__export(external_exports, {
|
|
@@ -35362,10 +35367,10 @@ function mergeDefs(...defs) {
|
|
|
35362
35367
|
function cloneDef(schema) {
|
|
35363
35368
|
return mergeDefs(schema._zod.def);
|
|
35364
35369
|
}
|
|
35365
|
-
function getElementAtPath(obj,
|
|
35366
|
-
if (!
|
|
35370
|
+
function getElementAtPath(obj, path20) {
|
|
35371
|
+
if (!path20)
|
|
35367
35372
|
return obj;
|
|
35368
|
-
return
|
|
35373
|
+
return path20.reduce((acc, key) => acc?.[key], obj);
|
|
35369
35374
|
}
|
|
35370
35375
|
function promiseAllObject(promisesObj) {
|
|
35371
35376
|
const keys = Object.keys(promisesObj);
|
|
@@ -35748,11 +35753,11 @@ function aborted(x2, startIndex = 0) {
|
|
|
35748
35753
|
}
|
|
35749
35754
|
return false;
|
|
35750
35755
|
}
|
|
35751
|
-
function prefixIssues(
|
|
35756
|
+
function prefixIssues(path20, issues) {
|
|
35752
35757
|
return issues.map((iss) => {
|
|
35753
35758
|
var _a2;
|
|
35754
35759
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
35755
|
-
iss.path.unshift(
|
|
35760
|
+
iss.path.unshift(path20);
|
|
35756
35761
|
return iss;
|
|
35757
35762
|
});
|
|
35758
35763
|
}
|
|
@@ -35935,7 +35940,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
35935
35940
|
}
|
|
35936
35941
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
35937
35942
|
const result = { errors: [] };
|
|
35938
|
-
const processError = (error49,
|
|
35943
|
+
const processError = (error49, path20 = []) => {
|
|
35939
35944
|
var _a2, _b;
|
|
35940
35945
|
for (const issue2 of error49.issues) {
|
|
35941
35946
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -35945,7 +35950,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
35945
35950
|
} else if (issue2.code === "invalid_element") {
|
|
35946
35951
|
processError({ issues: issue2.issues }, issue2.path);
|
|
35947
35952
|
} else {
|
|
35948
|
-
const fullpath = [...
|
|
35953
|
+
const fullpath = [...path20, ...issue2.path];
|
|
35949
35954
|
if (fullpath.length === 0) {
|
|
35950
35955
|
result.errors.push(mapper(issue2));
|
|
35951
35956
|
continue;
|
|
@@ -35977,8 +35982,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
35977
35982
|
}
|
|
35978
35983
|
function toDotPath(_path) {
|
|
35979
35984
|
const segs = [];
|
|
35980
|
-
const
|
|
35981
|
-
for (const seg of
|
|
35985
|
+
const path20 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
35986
|
+
for (const seg of path20) {
|
|
35982
35987
|
if (typeof seg === "number")
|
|
35983
35988
|
segs.push(`[${seg}]`);
|
|
35984
35989
|
else if (typeof seg === "symbol")
|
|
@@ -47955,13 +47960,13 @@ function resolveRef(ref, ctx) {
|
|
|
47955
47960
|
if (!ref.startsWith("#")) {
|
|
47956
47961
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
47957
47962
|
}
|
|
47958
|
-
const
|
|
47959
|
-
if (
|
|
47963
|
+
const path20 = ref.slice(1).split("/").filter(Boolean);
|
|
47964
|
+
if (path20.length === 0) {
|
|
47960
47965
|
return ctx.rootSchema;
|
|
47961
47966
|
}
|
|
47962
47967
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
47963
|
-
if (
|
|
47964
|
-
const key =
|
|
47968
|
+
if (path20[0] === defsKey) {
|
|
47969
|
+
const key = path20[1];
|
|
47965
47970
|
if (!key || !ctx.defs[key]) {
|
|
47966
47971
|
throw new Error(`Reference not found: ${ref}`);
|
|
47967
47972
|
}
|
|
@@ -48905,6 +48910,9 @@ var TelevisionClient = class {
|
|
|
48905
48910
|
health() {
|
|
48906
48911
|
return this.#http.requestJSON("GET", "/health");
|
|
48907
48912
|
}
|
|
48913
|
+
demoMode() {
|
|
48914
|
+
return this.#http.requestJSON("GET", "/demo-mode");
|
|
48915
|
+
}
|
|
48908
48916
|
};
|
|
48909
48917
|
|
|
48910
48918
|
// ../shared/src/connect-url.ts
|
|
@@ -52147,6 +52155,7 @@ function serveMarkdownContent(store) {
|
|
|
52147
52155
|
}
|
|
52148
52156
|
|
|
52149
52157
|
// ../server/src/routes.ts
|
|
52158
|
+
var BROWSER_DEMO_MARKER = ".tv-mozfest-demo";
|
|
52150
52159
|
var patchChannelSchema = external_exports.object({
|
|
52151
52160
|
name: external_exports.string().optional(),
|
|
52152
52161
|
layout: external_exports.array(external_exports.unknown()).optional(),
|
|
@@ -52257,6 +52266,7 @@ function registerRoutes(app, store, options) {
|
|
|
52257
52266
|
app.use("/themes", applyCorsMiddleware, telemetryMiddleware);
|
|
52258
52267
|
app.use("/markdown", applyCorsMiddleware, telemetryMiddleware);
|
|
52259
52268
|
app.use("/telemetry", applyCorsMiddleware);
|
|
52269
|
+
app.use("/demo-mode", applyCorsMiddleware);
|
|
52260
52270
|
const artifactProxy = serveArtifactProxy(store, { pollCadence: options.testArtifactPollCadence });
|
|
52261
52271
|
app.all("/artifact/:id", artifactProxy);
|
|
52262
52272
|
app.all("/artifact/:id/*", artifactProxy);
|
|
@@ -52273,8 +52283,12 @@ function registerRoutes(app, store, options) {
|
|
|
52273
52283
|
app.options("/themes/refresh", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
|
|
52274
52284
|
app.options("/markdown/:id", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
|
|
52275
52285
|
app.options("/telemetry", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
|
|
52286
|
+
app.options("/demo-mode", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
|
|
52276
52287
|
app.options("/telemetry/enable", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
|
|
52277
52288
|
app.options("/telemetry/disable", (_req, res) => res.status(HTTP_NO_CONTENT2).end());
|
|
52289
|
+
app.get("/demo-mode", ...auth, (_req, res) => {
|
|
52290
|
+
res.json({ browserExternalPages: (0, import_node_fs7.existsSync)(import_node_path7.default.join(import_node_os3.default.homedir(), BROWSER_DEMO_MARKER)) });
|
|
52291
|
+
});
|
|
52278
52292
|
app.get("/telemetry", ...auth, (_req, res) => {
|
|
52279
52293
|
res.json(options.getTelemetryStatus?.() ?? { state: "unavailable", reason: null, guidPresent: false, region: "us" });
|
|
52280
52294
|
});
|
|
@@ -52685,8 +52699,8 @@ function isTelemetryActivityMessage(parsed, expectedClientId) {
|
|
|
52685
52699
|
// ../server/src/acp-bridge.ts
|
|
52686
52700
|
var import_node_child_process2 = require("node:child_process");
|
|
52687
52701
|
var import_promises3 = require("node:fs/promises");
|
|
52688
|
-
var
|
|
52689
|
-
var
|
|
52702
|
+
var import_node_os4 = require("node:os");
|
|
52703
|
+
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
52690
52704
|
var launchACPProcess = (command, args, options) => {
|
|
52691
52705
|
const child = (0, import_node_child_process2.spawn)(command, args, options);
|
|
52692
52706
|
const directKill = child.kill.bind(child);
|
|
@@ -52729,7 +52743,7 @@ function trackChild(child) {
|
|
|
52729
52743
|
child.once("exit", untrack);
|
|
52730
52744
|
child.once("error", untrack);
|
|
52731
52745
|
}
|
|
52732
|
-
var ACP_STUB_CWD =
|
|
52746
|
+
var ACP_STUB_CWD = import_node_path8.default.join((0, import_node_os4.homedir)(), ".television", "acp");
|
|
52733
52747
|
var ACPBridge = class extends withDisposable(class {
|
|
52734
52748
|
}) {
|
|
52735
52749
|
child = null;
|
|
@@ -52746,7 +52760,7 @@ var ACPBridge = class extends withDisposable(class {
|
|
|
52746
52760
|
this.send = options.send;
|
|
52747
52761
|
this.profile = options.profile;
|
|
52748
52762
|
this.launchProcess = options.launchProcess ?? launchACPProcess;
|
|
52749
|
-
this.sessionCwd =
|
|
52763
|
+
this.sessionCwd = import_node_path8.default.resolve(process.cwd());
|
|
52750
52764
|
}
|
|
52751
52765
|
handleClientMessage(message) {
|
|
52752
52766
|
switch (message.type) {
|
|
@@ -52983,8 +52997,8 @@ function splitListenValues(values) {
|
|
|
52983
52997
|
|
|
52984
52998
|
// ../server/src/canonical.ts
|
|
52985
52999
|
var import_node_crypto5 = require("node:crypto");
|
|
52986
|
-
var
|
|
52987
|
-
var
|
|
53000
|
+
var import_node_fs8 = require("node:fs");
|
|
53001
|
+
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
52988
53002
|
var CACHE_CONTROL_NO_CACHE = "no-cache";
|
|
52989
53003
|
var ETAG_DIGEST_LENGTH2 = 16;
|
|
52990
53004
|
var HTTP_NOT_MODIFIED_STATUS2 = 304;
|
|
@@ -52997,7 +53011,7 @@ function canonicalWrapper(version2, frozen = false, querySuffix = "") {
|
|
|
52997
53011
|
`;
|
|
52998
53012
|
}
|
|
52999
53013
|
function serveCanonicalBase(canonicalDir) {
|
|
53000
|
-
const body = (0,
|
|
53014
|
+
const body = (0, import_node_fs8.readFileSync)(import_node_path9.default.join(canonicalDir, CANONICAL_STYLESHEET));
|
|
53001
53015
|
const digest = (0, import_node_crypto5.createHash)("sha256").update(body).digest("hex").slice(0, ETAG_DIGEST_LENGTH2);
|
|
53002
53016
|
const etag = `W/"canonical-base-${digest}"`;
|
|
53003
53017
|
return (req, res) => {
|
|
@@ -53037,8 +53051,8 @@ function matchesIfNoneMatch2(header, etag) {
|
|
|
53037
53051
|
}
|
|
53038
53052
|
|
|
53039
53053
|
// ../server/src/logger.ts
|
|
53040
|
-
var
|
|
53041
|
-
var
|
|
53054
|
+
var import_node_fs9 = require("node:fs");
|
|
53055
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
53042
53056
|
var LOG_DIR_NAME = "logs";
|
|
53043
53057
|
var ACTIVE_LOG_FILE = "tv.log";
|
|
53044
53058
|
var LOG_RETENTION_DAYS = 14;
|
|
@@ -53054,9 +53068,9 @@ var ROTATION_LOCK_TIMEOUT_MS = 5e3;
|
|
|
53054
53068
|
var INT32_BYTES = 4;
|
|
53055
53069
|
function log(storagePath, msg, data) {
|
|
53056
53070
|
try {
|
|
53057
|
-
const logsDir =
|
|
53058
|
-
(0,
|
|
53059
|
-
const logPath =
|
|
53071
|
+
const logsDir = import_node_path10.default.join(storagePath, LOG_DIR_NAME);
|
|
53072
|
+
(0, import_node_fs9.mkdirSync)(logsDir, { recursive: true });
|
|
53073
|
+
const logPath = import_node_path10.default.join(logsDir, ACTIVE_LOG_FILE);
|
|
53060
53074
|
rotateIfStale(logsDir, logPath);
|
|
53061
53075
|
const record2 = {
|
|
53062
53076
|
ts: localTimestamp(/* @__PURE__ */ new Date()),
|
|
@@ -53064,7 +53078,7 @@ function log(storagePath, msg, data) {
|
|
|
53064
53078
|
msg,
|
|
53065
53079
|
...serializeData(data)
|
|
53066
53080
|
};
|
|
53067
|
-
(0,
|
|
53081
|
+
(0, import_node_fs9.appendFileSync)(logPath, `${JSON.stringify(record2)}
|
|
53068
53082
|
`, { encoding: "utf8" });
|
|
53069
53083
|
} catch (error48) {
|
|
53070
53084
|
const message = error48 instanceof Error ? error48.message : String(error48);
|
|
@@ -53087,21 +53101,21 @@ function serializeError(error48) {
|
|
|
53087
53101
|
return { name: "NonError", message: String(error48) };
|
|
53088
53102
|
}
|
|
53089
53103
|
function rotateIfStale(logsDir, logPath) {
|
|
53090
|
-
const lockPath =
|
|
53104
|
+
const lockPath = import_node_path10.default.join(logsDir, ROTATION_LOCK_DIR);
|
|
53091
53105
|
if (!acquireRotationLock(lockPath)) return;
|
|
53092
53106
|
try {
|
|
53093
53107
|
let stats;
|
|
53094
53108
|
try {
|
|
53095
|
-
stats = (0,
|
|
53109
|
+
stats = (0, import_node_fs9.statSync)(logPath);
|
|
53096
53110
|
} catch (error48) {
|
|
53097
53111
|
if (error48.code === "ENOENT") return;
|
|
53098
53112
|
throw error48;
|
|
53099
53113
|
}
|
|
53100
53114
|
if (!isPreviousLocalCalendarDay(stats.mtime, /* @__PURE__ */ new Date())) return;
|
|
53101
53115
|
const archiveDate = localDateString(stats.mtime);
|
|
53102
|
-
const archivePath = uniqueArchivePath(
|
|
53116
|
+
const archivePath = uniqueArchivePath(import_node_path10.default.join(logsDir, `${ACTIVE_LOG_FILE}.${archiveDate}`));
|
|
53103
53117
|
try {
|
|
53104
|
-
(0,
|
|
53118
|
+
(0, import_node_fs9.renameSync)(logPath, archivePath);
|
|
53105
53119
|
} catch (error48) {
|
|
53106
53120
|
if (error48.code === "ENOENT") return;
|
|
53107
53121
|
throw error48;
|
|
@@ -53115,7 +53129,7 @@ function acquireRotationLock(lockPath) {
|
|
|
53115
53129
|
const deadline = Date.now() + ROTATION_LOCK_TIMEOUT_MS;
|
|
53116
53130
|
while (true) {
|
|
53117
53131
|
try {
|
|
53118
|
-
(0,
|
|
53132
|
+
(0, import_node_fs9.mkdirSync)(lockPath);
|
|
53119
53133
|
return true;
|
|
53120
53134
|
} catch (error48) {
|
|
53121
53135
|
if (error48.code !== "EEXIST") throw error48;
|
|
@@ -53126,7 +53140,7 @@ function acquireRotationLock(lockPath) {
|
|
|
53126
53140
|
}
|
|
53127
53141
|
function releaseRotationLock(lockPath) {
|
|
53128
53142
|
try {
|
|
53129
|
-
(0,
|
|
53143
|
+
(0, import_node_fs9.rmdirSync)(lockPath);
|
|
53130
53144
|
} catch {
|
|
53131
53145
|
}
|
|
53132
53146
|
}
|
|
@@ -53134,21 +53148,21 @@ function sleepSync(ms) {
|
|
|
53134
53148
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(INT32_BYTES)), 0, 0, ms);
|
|
53135
53149
|
}
|
|
53136
53150
|
function uniqueArchivePath(basePath) {
|
|
53137
|
-
if (!(0,
|
|
53151
|
+
if (!(0, import_node_fs9.existsSync)(basePath)) return basePath;
|
|
53138
53152
|
for (let index = 1; ; index += 1) {
|
|
53139
53153
|
const candidate = `${basePath}-${index}`;
|
|
53140
|
-
if (!(0,
|
|
53154
|
+
if (!(0, import_node_fs9.existsSync)(candidate)) return candidate;
|
|
53141
53155
|
}
|
|
53142
53156
|
}
|
|
53143
53157
|
function removeExpiredArchives(logsDir, retainedArchivePath) {
|
|
53144
53158
|
const cutoff = Date.now() - LOG_RETENTION_DAYS * MS_PER_DAY;
|
|
53145
|
-
for (const entry of (0,
|
|
53159
|
+
for (const entry of (0, import_node_fs9.readdirSync)(logsDir, { withFileTypes: true })) {
|
|
53146
53160
|
if (!entry.isFile() || !entry.name.startsWith(`${ACTIVE_LOG_FILE}.`)) continue;
|
|
53147
|
-
const fullPath =
|
|
53161
|
+
const fullPath = import_node_path10.default.join(logsDir, entry.name);
|
|
53148
53162
|
if (fullPath === retainedArchivePath) continue;
|
|
53149
53163
|
try {
|
|
53150
|
-
if ((0,
|
|
53151
|
-
(0,
|
|
53164
|
+
if ((0, import_node_fs9.statSync)(fullPath).mtime.getTime() < cutoff) {
|
|
53165
|
+
(0, import_node_fs9.rmSync)(fullPath, { force: true });
|
|
53152
53166
|
}
|
|
53153
53167
|
} catch {
|
|
53154
53168
|
}
|
|
@@ -53402,7 +53416,7 @@ function safeEmit(callback) {
|
|
|
53402
53416
|
// ../server/src/telemetry/identity.ts
|
|
53403
53417
|
var import_node_crypto6 = require("node:crypto");
|
|
53404
53418
|
var import_promises4 = require("node:fs/promises");
|
|
53405
|
-
var
|
|
53419
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
53406
53420
|
var TELEMETRY_STATE_SCHEMA_VERSION = 1;
|
|
53407
53421
|
var SEMVER_MAJOR_CAPTURE_INDEX = 1;
|
|
53408
53422
|
var SEMVER_MINOR_CAPTURE_INDEX = 2;
|
|
@@ -53419,7 +53433,7 @@ async function readTelemetryState(storagePath) {
|
|
|
53419
53433
|
}
|
|
53420
53434
|
async function writeTelemetryState(storagePath, state) {
|
|
53421
53435
|
const statePath = getTelemetryStatePath(storagePath);
|
|
53422
|
-
await (0, import_promises4.mkdir)(
|
|
53436
|
+
await (0, import_promises4.mkdir)(import_node_path11.default.dirname(statePath), { recursive: true });
|
|
53423
53437
|
const tempPath = `${statePath}.${process.pid}.${Date.now()}.tmp`;
|
|
53424
53438
|
await (0, import_promises4.writeFile)(tempPath, `${JSON.stringify(state, null, 2)}
|
|
53425
53439
|
`, "utf8");
|
|
@@ -53603,9 +53617,9 @@ function buildTelemetryEvent(event, context) {
|
|
|
53603
53617
|
}
|
|
53604
53618
|
|
|
53605
53619
|
// ../server/src/telemetry/posthog-config.ts
|
|
53606
|
-
var
|
|
53607
|
-
var
|
|
53608
|
-
var
|
|
53620
|
+
var import_node_fs10 = require("node:fs");
|
|
53621
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
53622
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
53609
53623
|
var POSTHOG_US_INGESTION_HOST = "https://us.i.posthog.com";
|
|
53610
53624
|
var POSTHOG_US_API_HOST = "https://us.posthog.com";
|
|
53611
53625
|
var POSTHOG_PRODUCTION_PROJECT_ID = 482022;
|
|
@@ -53629,11 +53643,11 @@ function resolvePostHogProject(env, options = {}) {
|
|
|
53629
53643
|
}
|
|
53630
53644
|
function resolveTelemetryDeveloperHome(env = process.env) {
|
|
53631
53645
|
const capturedHome = env.TELEVISION_DEVELOPER_HOME;
|
|
53632
|
-
return capturedHome && capturedHome.length > 0 ? capturedHome :
|
|
53646
|
+
return capturedHome && capturedHome.length > 0 ? capturedHome : import_node_os5.default.homedir();
|
|
53633
53647
|
}
|
|
53634
|
-
function detectTelemetryDeveloperHost(homeDir =
|
|
53648
|
+
function detectTelemetryDeveloperHost(homeDir = import_node_os5.default.homedir()) {
|
|
53635
53649
|
try {
|
|
53636
|
-
return (0,
|
|
53650
|
+
return (0, import_node_fs10.existsSync)(import_node_path12.default.join(homeDir, ".tv-developer"));
|
|
53637
53651
|
} catch {
|
|
53638
53652
|
return false;
|
|
53639
53653
|
}
|
|
@@ -53970,7 +53984,7 @@ function disabledTelemetryRuntime() {
|
|
|
53970
53984
|
|
|
53971
53985
|
// ../server/src/updates/version.ts
|
|
53972
53986
|
function readVersionStamp() {
|
|
53973
|
-
if ("1.3.
|
|
53987
|
+
if ("1.3.9".length > 0) return "1.3.9";
|
|
53974
53988
|
return void 0;
|
|
53975
53989
|
}
|
|
53976
53990
|
function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
|
|
@@ -54139,15 +54153,15 @@ var HTTP_UNAUTHORIZED_STATUS = 401;
|
|
|
54139
54153
|
var LOOPBACK_IPV4 = "127.0.0.1";
|
|
54140
54154
|
var CANONICAL_VERSION_DIRECTORY_PATTERN = /^v\d+(?:\.\d+)?$/;
|
|
54141
54155
|
function resolveCanonicalVersionDirectories(canonicalDir) {
|
|
54142
|
-
const canonicalRoot =
|
|
54143
|
-
const versions = (0,
|
|
54156
|
+
const canonicalRoot = import_node_path13.default.resolve(canonicalDir);
|
|
54157
|
+
const versions = (0, import_node_fs11.readdirSync)(canonicalRoot, { withFileTypes: true }).filter(
|
|
54144
54158
|
(entry) => entry.isDirectory() && CANONICAL_VERSION_DIRECTORY_PATTERN.test(entry.name)
|
|
54145
54159
|
).map((entry) => {
|
|
54146
|
-
const directory =
|
|
54160
|
+
const directory = import_node_path13.default.join(canonicalRoot, entry.name);
|
|
54147
54161
|
return {
|
|
54148
54162
|
version: entry.name,
|
|
54149
54163
|
directory,
|
|
54150
|
-
frozen: (0,
|
|
54164
|
+
frozen: (0, import_node_fs11.existsSync)(import_node_path13.default.join(directory, "frozen.json"))
|
|
54151
54165
|
};
|
|
54152
54166
|
}).sort(
|
|
54153
54167
|
(left, right) => left.version.localeCompare(right.version, void 0, { numeric: true })
|
|
@@ -54252,7 +54266,7 @@ var Server = class {
|
|
|
54252
54266
|
import_express2.default.static(directory, {
|
|
54253
54267
|
setHeaders: (res, filePath) => {
|
|
54254
54268
|
if (filePath.startsWith(
|
|
54255
|
-
`${
|
|
54269
|
+
`${import_node_path13.default.resolve(directory, "fonts")}${import_node_path13.default.sep}`
|
|
54256
54270
|
)) {
|
|
54257
54271
|
res.setHeader(
|
|
54258
54272
|
"Cache-Control",
|
|
@@ -54279,7 +54293,7 @@ var Server = class {
|
|
|
54279
54293
|
if (filePath.endsWith(".html") || filePath.endsWith(".htm")) {
|
|
54280
54294
|
res.setHeader("Referrer-Policy", "no-referrer");
|
|
54281
54295
|
res.setHeader("Cache-Control", "no-cache");
|
|
54282
|
-
} else if (filePath.includes(`${
|
|
54296
|
+
} else if (filePath.includes(`${import_node_path13.default.sep}assets${import_node_path13.default.sep}`)) {
|
|
54283
54297
|
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
|
|
54284
54298
|
}
|
|
54285
54299
|
}
|
|
@@ -54516,22 +54530,22 @@ var Server = class {
|
|
|
54516
54530
|
};
|
|
54517
54531
|
};
|
|
54518
54532
|
function readServerPackageVersion() {
|
|
54519
|
-
if ("1.3.
|
|
54520
|
-
return telemetryVersion("1.3.
|
|
54533
|
+
if ("1.3.9".length > 0) {
|
|
54534
|
+
return telemetryVersion("1.3.9");
|
|
54521
54535
|
}
|
|
54522
|
-
const packageJsonPath =
|
|
54523
|
-
if (!(0,
|
|
54524
|
-
return telemetryVersion(JSON.parse((0,
|
|
54536
|
+
const packageJsonPath = import_node_path13.default.resolve(import_node_path13.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
|
|
54537
|
+
if (!(0, import_node_fs11.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
|
|
54538
|
+
return telemetryVersion(JSON.parse((0, import_node_fs11.readFileSync)(packageJsonPath, "utf8")).version);
|
|
54525
54539
|
}
|
|
54526
54540
|
|
|
54527
54541
|
// ../server/src/server-store.ts
|
|
54528
|
-
var
|
|
54529
|
-
var
|
|
54542
|
+
var import_node_fs17 = require("node:fs");
|
|
54543
|
+
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
54530
54544
|
|
|
54531
54545
|
// ../server/src/file-watcher.ts
|
|
54532
54546
|
var import_node_events = require("node:events");
|
|
54533
54547
|
var fs3 = __toESM(require("node:fs"), 1);
|
|
54534
|
-
var
|
|
54548
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
54535
54549
|
var DEFAULT_REARM_INTERVAL_MS = 250;
|
|
54536
54550
|
function isMissingWatchRootError(error48) {
|
|
54537
54551
|
return typeof error48 === "object" && error48 !== null && "code" in error48 && error48.code === "ENOENT";
|
|
@@ -54553,9 +54567,9 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
|
|
|
54553
54567
|
constructor(contentPath, onChange, options = {}) {
|
|
54554
54568
|
super();
|
|
54555
54569
|
this.#recursive = options.recursive === true;
|
|
54556
|
-
this.#dir = this.#recursive ? contentPath :
|
|
54557
|
-
this.#watchedBasename =
|
|
54558
|
-
this.#watchRootBasename =
|
|
54570
|
+
this.#dir = this.#recursive ? contentPath : import_node_path14.default.dirname(contentPath);
|
|
54571
|
+
this.#watchedBasename = import_node_path14.default.basename(contentPath);
|
|
54572
|
+
this.#watchRootBasename = import_node_path14.default.basename(import_node_path14.default.normalize(this.#dir));
|
|
54559
54573
|
this.#onChange = onChange;
|
|
54560
54574
|
this.#options = options;
|
|
54561
54575
|
try {
|
|
@@ -54613,7 +54627,7 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
|
|
|
54613
54627
|
});
|
|
54614
54628
|
const ancestorWatchers = [];
|
|
54615
54629
|
for (const ancestorDir of this.#ancestorDirs()) {
|
|
54616
|
-
const ancestorBasename =
|
|
54630
|
+
const ancestorBasename = import_node_path14.default.basename(import_node_path14.default.normalize(ancestorDir));
|
|
54617
54631
|
try {
|
|
54618
54632
|
const ancestorWatcher = fs3.watch(ancestorDir, (_event, filename) => {
|
|
54619
54633
|
const basename = filename?.toString();
|
|
@@ -54680,10 +54694,10 @@ var ReArmingContentWatcher = class extends import_node_events.EventEmitter {
|
|
|
54680
54694
|
}
|
|
54681
54695
|
#ancestorDirs() {
|
|
54682
54696
|
const ancestors = [];
|
|
54683
|
-
let current =
|
|
54684
|
-
while (current !==
|
|
54697
|
+
let current = import_node_path14.default.dirname(this.#dir);
|
|
54698
|
+
while (current !== import_node_path14.default.dirname(current)) {
|
|
54685
54699
|
ancestors.push(current);
|
|
54686
|
-
current =
|
|
54700
|
+
current = import_node_path14.default.dirname(current);
|
|
54687
54701
|
}
|
|
54688
54702
|
return ancestors;
|
|
54689
54703
|
}
|
|
@@ -54740,8 +54754,8 @@ var defaultWatchContentFile = (contentPath, onChange, options) => {
|
|
|
54740
54754
|
};
|
|
54741
54755
|
|
|
54742
54756
|
// ../server/src/redesign-storage-migration.ts
|
|
54743
|
-
var
|
|
54744
|
-
var
|
|
54757
|
+
var import_node_fs13 = require("node:fs");
|
|
54758
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
54745
54759
|
|
|
54746
54760
|
// ../server/src/redesign-record-migration.ts
|
|
54747
54761
|
function convertStoredChannelRecord(record2) {
|
|
@@ -54816,7 +54830,7 @@ function newestChannelId(channelIds) {
|
|
|
54816
54830
|
}
|
|
54817
54831
|
|
|
54818
54832
|
// ../server/src/storage-name-migration.ts
|
|
54819
|
-
var
|
|
54833
|
+
var import_node_fs12 = require("node:fs");
|
|
54820
54834
|
var JSON_INDENT_SPACES2 = 2;
|
|
54821
54835
|
function isActiveID(value) {
|
|
54822
54836
|
return typeof value === "string" || value === null;
|
|
@@ -54827,23 +54841,23 @@ function isThemeName(value) {
|
|
|
54827
54841
|
function migrateChannelMetadataDirectory(storagePath) {
|
|
54828
54842
|
const legacyDir = getLegacyScreensDir(storagePath);
|
|
54829
54843
|
const currentDir = getChannelsDir(storagePath);
|
|
54830
|
-
const legacyExists = (0,
|
|
54831
|
-
const currentExists = (0,
|
|
54844
|
+
const legacyExists = (0, import_node_fs12.existsSync)(legacyDir);
|
|
54845
|
+
const currentExists = (0, import_node_fs12.existsSync)(currentDir);
|
|
54832
54846
|
if (!legacyExists) {
|
|
54833
54847
|
return;
|
|
54834
54848
|
}
|
|
54835
54849
|
if (!currentExists) {
|
|
54836
|
-
(0,
|
|
54850
|
+
(0, import_node_fs12.renameSync)(legacyDir, currentDir);
|
|
54837
54851
|
return;
|
|
54838
54852
|
}
|
|
54839
|
-
const legacyEntries = (0,
|
|
54840
|
-
const currentEntries = (0,
|
|
54853
|
+
const legacyEntries = (0, import_node_fs12.readdirSync)(legacyDir);
|
|
54854
|
+
const currentEntries = (0, import_node_fs12.readdirSync)(currentDir);
|
|
54841
54855
|
if (legacyEntries.length === 0) {
|
|
54842
|
-
(0,
|
|
54856
|
+
(0, import_node_fs12.rmdirSync)(legacyDir);
|
|
54843
54857
|
return;
|
|
54844
54858
|
}
|
|
54845
54859
|
if (currentEntries.length === 0) {
|
|
54846
|
-
(0,
|
|
54860
|
+
(0, import_node_fs12.renameSync)(legacyDir, currentDir);
|
|
54847
54861
|
return;
|
|
54848
54862
|
}
|
|
54849
54863
|
throw new Error(
|
|
@@ -54852,12 +54866,12 @@ function migrateChannelMetadataDirectory(storagePath) {
|
|
|
54852
54866
|
}
|
|
54853
54867
|
function migrateDisplayStateField(storagePath) {
|
|
54854
54868
|
const displayPath = getDisplayStatePath(storagePath);
|
|
54855
|
-
if (!(0,
|
|
54869
|
+
if (!(0, import_node_fs12.existsSync)(displayPath)) {
|
|
54856
54870
|
return;
|
|
54857
54871
|
}
|
|
54858
54872
|
let parsed;
|
|
54859
54873
|
try {
|
|
54860
|
-
parsed = JSON.parse((0,
|
|
54874
|
+
parsed = JSON.parse((0, import_node_fs12.readFileSync)(displayPath, "utf8"));
|
|
54861
54875
|
} catch {
|
|
54862
54876
|
return;
|
|
54863
54877
|
}
|
|
@@ -54898,8 +54912,8 @@ function migrateDisplayStateField(storagePath) {
|
|
|
54898
54912
|
next[key] = value;
|
|
54899
54913
|
}
|
|
54900
54914
|
const temporaryPath = getDisplayMigrationTempPath(storagePath);
|
|
54901
|
-
(0,
|
|
54902
|
-
(0,
|
|
54915
|
+
(0, import_node_fs12.writeFileSync)(temporaryPath, JSON.stringify(next, null, JSON_INDENT_SPACES2));
|
|
54916
|
+
(0, import_node_fs12.renameSync)(temporaryPath, displayPath);
|
|
54903
54917
|
}
|
|
54904
54918
|
|
|
54905
54919
|
// ../server/src/redesign-storage-migration.ts
|
|
@@ -54914,17 +54928,17 @@ function runRedesignStorageMigration(storagePath) {
|
|
|
54914
54928
|
migrateDisplayAppearanceMode(storagePath);
|
|
54915
54929
|
}
|
|
54916
54930
|
function getRedesignRecordMigrationTempPath(recordPath) {
|
|
54917
|
-
return
|
|
54931
|
+
return import_node_path15.default.join(import_node_path15.default.dirname(recordPath), `.${import_node_path15.default.basename(recordPath)}.redesign.tmp`);
|
|
54918
54932
|
}
|
|
54919
54933
|
function migrateChannelRecords(storagePath) {
|
|
54920
54934
|
const channelsDir = getChannelsDir(storagePath);
|
|
54921
|
-
if (!(0,
|
|
54935
|
+
if (!(0, import_node_fs13.existsSync)(channelsDir)) {
|
|
54922
54936
|
return [];
|
|
54923
54937
|
}
|
|
54924
54938
|
const channelIds = [];
|
|
54925
|
-
for (const file2 of (0,
|
|
54939
|
+
for (const file2 of (0, import_node_fs13.readdirSync)(channelsDir).sort()) {
|
|
54926
54940
|
if (!file2.endsWith(JSON_FILE_SUFFIX)) continue;
|
|
54927
|
-
const recordPath =
|
|
54941
|
+
const recordPath = import_node_path15.default.join(channelsDir, file2);
|
|
54928
54942
|
const parsed = readJSON(recordPath);
|
|
54929
54943
|
const inspected = inspectChannelRecord(parsed);
|
|
54930
54944
|
if (inspected === null) continue;
|
|
@@ -54940,7 +54954,7 @@ function migrateChannelRecords(storagePath) {
|
|
|
54940
54954
|
}
|
|
54941
54955
|
function migrateDisplayRecord(storagePath, channelIds) {
|
|
54942
54956
|
const displayPath = getDisplayStatePath(storagePath);
|
|
54943
|
-
if (!(0,
|
|
54957
|
+
if (!(0, import_node_fs13.existsSync)(displayPath)) return;
|
|
54944
54958
|
const parsed = readJSON(displayPath);
|
|
54945
54959
|
const record2 = parseConvertibleDisplayRecord(parsed);
|
|
54946
54960
|
if (record2 === null) return;
|
|
@@ -54951,10 +54965,10 @@ function migrateDisplayRecord(storagePath, channelIds) {
|
|
|
54951
54965
|
}
|
|
54952
54966
|
function backfillChannelPageSizes(storagePath) {
|
|
54953
54967
|
const channelsDir = getChannelsDir(storagePath);
|
|
54954
|
-
if (!(0,
|
|
54955
|
-
for (const file2 of (0,
|
|
54968
|
+
if (!(0, import_node_fs13.existsSync)(channelsDir)) return;
|
|
54969
|
+
for (const file2 of (0, import_node_fs13.readdirSync)(channelsDir).sort()) {
|
|
54956
54970
|
if (!file2.endsWith(JSON_FILE_SUFFIX)) continue;
|
|
54957
|
-
const recordPath =
|
|
54971
|
+
const recordPath = import_node_path15.default.join(channelsDir, file2);
|
|
54958
54972
|
const record2 = inspectPageSizeBackfillRecord(readJSON(recordPath));
|
|
54959
54973
|
if (record2 === null) continue;
|
|
54960
54974
|
const backfilled = backfillStoredChannelPageSizes(record2);
|
|
@@ -54965,7 +54979,7 @@ function backfillChannelPageSizes(storagePath) {
|
|
|
54965
54979
|
}
|
|
54966
54980
|
function migrateDisplayAppearanceMode(storagePath) {
|
|
54967
54981
|
const displayPath = getDisplayStatePath(storagePath);
|
|
54968
|
-
if (!(0,
|
|
54982
|
+
if (!(0, import_node_fs13.existsSync)(displayPath)) return;
|
|
54969
54983
|
const record2 = readJSON(displayPath);
|
|
54970
54984
|
if (!isRecord2(record2) || Object.hasOwn(record2, "appearanceMode")) return;
|
|
54971
54985
|
if (!isNullableString(record2.focusedChannelId) || !Array.isArray(record2.pinnedChannelIds) || !record2.pinnedChannelIds.every((id) => typeof id === "string") || !isThemeName2(record2.activeThemeName)) {
|
|
@@ -54975,11 +54989,11 @@ function migrateDisplayAppearanceMode(storagePath) {
|
|
|
54975
54989
|
}
|
|
54976
54990
|
function writeAtomicJSON(recordPath, value) {
|
|
54977
54991
|
const temporaryPath = getRedesignRecordMigrationTempPath(recordPath);
|
|
54978
|
-
(0,
|
|
54979
|
-
(0,
|
|
54992
|
+
(0, import_node_fs13.writeFileSync)(temporaryPath, JSON.stringify(value, null, JSON_INDENT_SPACES3));
|
|
54993
|
+
(0, import_node_fs13.renameSync)(temporaryPath, recordPath);
|
|
54980
54994
|
}
|
|
54981
54995
|
function readJSON(recordPath) {
|
|
54982
|
-
const bytes = (0,
|
|
54996
|
+
const bytes = (0, import_node_fs13.readFileSync)(recordPath, "utf8");
|
|
54983
54997
|
try {
|
|
54984
54998
|
return JSON.parse(bytes);
|
|
54985
54999
|
} catch {
|
|
@@ -55072,12 +55086,12 @@ function isRecord2(value) {
|
|
|
55072
55086
|
}
|
|
55073
55087
|
|
|
55074
55088
|
// ../server/src/onboarding-installer.ts
|
|
55075
|
-
var
|
|
55076
|
-
var
|
|
55089
|
+
var import_node_fs16 = require("node:fs");
|
|
55090
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
55077
55091
|
|
|
55078
55092
|
// ../server/src/onboarding-content.ts
|
|
55079
|
-
var
|
|
55080
|
-
var
|
|
55093
|
+
var import_node_fs14 = require("node:fs");
|
|
55094
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
55081
55095
|
var ONBOARDING_CONFIG_FILENAME = "onboarding-channels.json";
|
|
55082
55096
|
var ONBOARDING_CONFIG_VERSION = 3;
|
|
55083
55097
|
var ONBOARDING_ARTIFACT_ID_PREFIX = "television-onboarding";
|
|
@@ -55089,10 +55103,10 @@ function isValidOnboardingSlug(slug) {
|
|
|
55089
55103
|
return ONBOARDING_SLUG_PATTERN.test(slug) && !slug.includes("--");
|
|
55090
55104
|
}
|
|
55091
55105
|
function loadOnboardingConfig(contentRoot) {
|
|
55092
|
-
const configPath =
|
|
55106
|
+
const configPath = import_node_path16.default.join(contentRoot, ONBOARDING_CONFIG_FILENAME);
|
|
55093
55107
|
let raw;
|
|
55094
55108
|
try {
|
|
55095
|
-
raw = (0,
|
|
55109
|
+
raw = (0, import_node_fs14.readFileSync)(configPath, "utf8");
|
|
55096
55110
|
} catch (error48) {
|
|
55097
55111
|
return { errors: [`cannot read ${ONBOARDING_CONFIG_FILENAME}: ${describeError2(error48)}`] };
|
|
55098
55112
|
}
|
|
@@ -55110,15 +55124,15 @@ function loadOnboardingConfig(contentRoot) {
|
|
|
55110
55124
|
}
|
|
55111
55125
|
function resolveOnboardingArtifactSource(contentRoot, channelSlug, artifactSlug) {
|
|
55112
55126
|
const label = `artifact "${artifactSlug}" in channel "${channelSlug}"`;
|
|
55113
|
-
const channelDir =
|
|
55127
|
+
const channelDir = import_node_path16.default.join(contentRoot, channelSlug);
|
|
55114
55128
|
const shapes = [];
|
|
55115
55129
|
for (const extension2 of [".html", ".md"]) {
|
|
55116
|
-
const candidate =
|
|
55130
|
+
const candidate = import_node_path16.default.join(channelDir, `${artifactSlug}${extension2}`);
|
|
55117
55131
|
if (isFile(candidate)) {
|
|
55118
55132
|
shapes.push({ kind: "file", path: candidate, display: `${artifactSlug}${extension2}` });
|
|
55119
55133
|
}
|
|
55120
55134
|
}
|
|
55121
|
-
const dirPath =
|
|
55135
|
+
const dirPath = import_node_path16.default.join(channelDir, artifactSlug);
|
|
55122
55136
|
if (isDirectory(dirPath)) {
|
|
55123
55137
|
shapes.push({ kind: "directory", path: dirPath, display: `${artifactSlug}/` });
|
|
55124
55138
|
}
|
|
@@ -55135,7 +55149,7 @@ function resolveOnboardingArtifactSource(contentRoot, channelSlug, artifactSlug)
|
|
|
55135
55149
|
error: `${label} has no source: expected ${artifactSlug}.html, ${artifactSlug}.md, or ${artifactSlug}/`
|
|
55136
55150
|
};
|
|
55137
55151
|
}
|
|
55138
|
-
if (shape.kind === "directory" && !isFile(
|
|
55152
|
+
if (shape.kind === "directory" && !isFile(import_node_path16.default.join(shape.path, "index.html"))) {
|
|
55139
55153
|
return { ok: false, error: `${label} is a directory artifact missing index.html at its root` };
|
|
55140
55154
|
}
|
|
55141
55155
|
return { ok: true, source: { kind: shape.kind, path: shape.path } };
|
|
@@ -55234,18 +55248,18 @@ function validateArtifactSchema(rawArtifact, channelLabel, index, artifactSlugs)
|
|
|
55234
55248
|
return errors;
|
|
55235
55249
|
}
|
|
55236
55250
|
function isFile(candidate) {
|
|
55237
|
-
return (0,
|
|
55251
|
+
return (0, import_node_fs14.existsSync)(candidate) && (0, import_node_fs14.statSync)(candidate).isFile();
|
|
55238
55252
|
}
|
|
55239
55253
|
function isDirectory(candidate) {
|
|
55240
|
-
return (0,
|
|
55254
|
+
return (0, import_node_fs14.existsSync)(candidate) && (0, import_node_fs14.statSync)(candidate).isDirectory();
|
|
55241
55255
|
}
|
|
55242
55256
|
function describeError2(error48) {
|
|
55243
55257
|
return error48 instanceof Error ? error48.message : String(error48);
|
|
55244
55258
|
}
|
|
55245
55259
|
|
|
55246
55260
|
// ../server/src/onboarding-state.ts
|
|
55247
|
-
var
|
|
55248
|
-
var
|
|
55261
|
+
var import_node_fs15 = require("node:fs");
|
|
55262
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
55249
55263
|
|
|
55250
55264
|
// ../server/src/onboarding.ts
|
|
55251
55265
|
var ONBOARDING_ARTIFACT_ID = "television-onboarding";
|
|
@@ -55255,7 +55269,7 @@ var JSON_INDENT_SPACES4 = 2;
|
|
|
55255
55269
|
var ONBOARDING_STATE_VERSION = 3;
|
|
55256
55270
|
function readOnboardingStateFile(storagePath) {
|
|
55257
55271
|
const statePath = getOnboardingStatePath(storagePath);
|
|
55258
|
-
if (!(0,
|
|
55272
|
+
if (!(0, import_node_fs15.existsSync)(statePath)) {
|
|
55259
55273
|
return { status: "absent" };
|
|
55260
55274
|
}
|
|
55261
55275
|
const parsed = parseJSONFile(statePath);
|
|
@@ -55271,7 +55285,7 @@ function readOnboardingStateFile(storagePath) {
|
|
|
55271
55285
|
}
|
|
55272
55286
|
function readLegacyOnboardingFile(storagePath) {
|
|
55273
55287
|
const legacyPath = getOnboardingArtifactSentinelPath(storagePath);
|
|
55274
|
-
if (!(0,
|
|
55288
|
+
if (!(0, import_node_fs15.existsSync)(legacyPath)) {
|
|
55275
55289
|
return { status: "absent" };
|
|
55276
55290
|
}
|
|
55277
55291
|
const parsed = parseJSONFile(legacyPath);
|
|
@@ -55297,17 +55311,17 @@ function readLegacyOnboardingFile(storagePath) {
|
|
|
55297
55311
|
}
|
|
55298
55312
|
function getOnboardingStateTempPath(storagePath) {
|
|
55299
55313
|
const statePath = getOnboardingStatePath(storagePath);
|
|
55300
|
-
return
|
|
55314
|
+
return import_node_path17.default.join(import_node_path17.default.dirname(statePath), `.${import_node_path17.default.basename(statePath)}.tmp-${process.pid}`);
|
|
55301
55315
|
}
|
|
55302
55316
|
function writeOnboardingStateFile(storagePath, state) {
|
|
55303
55317
|
const statePath = getOnboardingStatePath(storagePath);
|
|
55304
55318
|
const tempPath = getOnboardingStateTempPath(storagePath);
|
|
55305
55319
|
try {
|
|
55306
|
-
(0,
|
|
55307
|
-
(0,
|
|
55320
|
+
(0, import_node_fs15.writeFileSync)(tempPath, JSON.stringify(state, null, JSON_INDENT_SPACES4));
|
|
55321
|
+
(0, import_node_fs15.renameSync)(tempPath, statePath);
|
|
55308
55322
|
} catch (error48) {
|
|
55309
55323
|
try {
|
|
55310
|
-
(0,
|
|
55324
|
+
(0, import_node_fs15.rmSync)(tempPath, { force: true });
|
|
55311
55325
|
} catch {
|
|
55312
55326
|
}
|
|
55313
55327
|
throw error48;
|
|
@@ -55316,7 +55330,7 @@ function writeOnboardingStateFile(storagePath, state) {
|
|
|
55316
55330
|
function parseJSONFile(filePath) {
|
|
55317
55331
|
let raw;
|
|
55318
55332
|
try {
|
|
55319
|
-
raw = (0,
|
|
55333
|
+
raw = (0, import_node_fs15.readFileSync)(filePath, "utf8");
|
|
55320
55334
|
} catch (error48) {
|
|
55321
55335
|
return { ok: false, error: `cannot read ${filePath}: ${describeError3(error48)}` };
|
|
55322
55336
|
}
|
|
@@ -55491,17 +55505,17 @@ function installChannel(target, contentPath, channelConfig) {
|
|
|
55491
55505
|
const artifactID = onboardingArtifactID(channelConfig.slug, artifactConfig.slug);
|
|
55492
55506
|
const artifactsDir = getAgentArtifactsDir(target.storagePath);
|
|
55493
55507
|
if (resolved.source.kind === "file") {
|
|
55494
|
-
const destination =
|
|
55495
|
-
(0,
|
|
55496
|
-
(0,
|
|
55508
|
+
const destination = import_node_path18.default.join(artifactsDir, `${artifactID}${import_node_path18.default.extname(resolved.source.path)}`);
|
|
55509
|
+
(0, import_node_fs16.rmSync)(destination, { recursive: true, force: true });
|
|
55510
|
+
(0, import_node_fs16.cpSync)(resolved.source.path, destination);
|
|
55497
55511
|
copies.push({ artifactConfig, artifactID, destination });
|
|
55498
55512
|
} else {
|
|
55499
|
-
const destinationDir =
|
|
55500
|
-
if ((0,
|
|
55501
|
-
(0,
|
|
55513
|
+
const destinationDir = import_node_path18.default.join(artifactsDir, artifactID);
|
|
55514
|
+
if ((0, import_node_fs16.existsSync)(destinationDir)) {
|
|
55515
|
+
(0, import_node_fs16.rmSync)(destinationDir, { recursive: true, force: true });
|
|
55502
55516
|
}
|
|
55503
|
-
(0,
|
|
55504
|
-
copies.push({ artifactConfig, artifactID, destination: destinationDir +
|
|
55517
|
+
(0, import_node_fs16.cpSync)(resolved.source.path, destinationDir, { recursive: true });
|
|
55518
|
+
copies.push({ artifactConfig, artifactID, destination: destinationDir + import_node_path18.default.sep });
|
|
55505
55519
|
}
|
|
55506
55520
|
}
|
|
55507
55521
|
for (const { artifactConfig, artifactID, destination } of copies) {
|
|
@@ -55559,9 +55573,9 @@ function hasSameArtifactMetadata(left, right) {
|
|
|
55559
55573
|
return left.kind === "path" && right.kind === "path" ? left.path === right.path : left.kind === "url" && right.kind === "url" && left.url === right.url;
|
|
55560
55574
|
}
|
|
55561
55575
|
function hasExistingTelevisionDataStructure(storagePath) {
|
|
55562
|
-
if ((0,
|
|
55563
|
-
if ((0,
|
|
55564
|
-
if ((0,
|
|
55576
|
+
if ((0, import_node_fs17.existsSync)(getDisplayStatePath(storagePath))) return true;
|
|
55577
|
+
if ((0, import_node_fs17.existsSync)(getOnboardingStatePath(storagePath))) return true;
|
|
55578
|
+
if ((0, import_node_fs17.existsSync)(getOnboardingArtifactSentinelPath(storagePath))) return true;
|
|
55565
55579
|
if (directoryIsNonEmpty(getChannelsDir(storagePath))) return true;
|
|
55566
55580
|
if (directoryIsNonEmpty(getLegacyScreensDir(storagePath))) return true;
|
|
55567
55581
|
if (directoryIsNonEmpty(getArtifactsMetadataDir(storagePath))) return true;
|
|
@@ -55571,7 +55585,7 @@ function hasExistingTelevisionDataStructure(storagePath) {
|
|
|
55571
55585
|
}
|
|
55572
55586
|
function directoryIsNonEmpty(dir) {
|
|
55573
55587
|
try {
|
|
55574
|
-
return (0,
|
|
55588
|
+
return (0, import_node_fs17.readdirSync)(dir).length > 0;
|
|
55575
55589
|
} catch {
|
|
55576
55590
|
return false;
|
|
55577
55591
|
}
|
|
@@ -55621,13 +55635,13 @@ var ServerStore = class extends EventTarget {
|
|
|
55621
55635
|
// specs/arch/onboarding/installer.md#^bootstrap-sequence, #^token-only-boot.
|
|
55622
55636
|
constructor(options) {
|
|
55623
55637
|
super();
|
|
55624
|
-
this.storagePath =
|
|
55638
|
+
this.storagePath = import_node_path19.default.resolve(options.storagePath);
|
|
55625
55639
|
this.serving = options.installOnboardingChannels === true;
|
|
55626
55640
|
this.dataDirCreated = !hasExistingTelevisionDataStructure(this.storagePath);
|
|
55627
55641
|
this.watchContentFile = options.watchContentFile ?? defaultWatchContentFile;
|
|
55628
55642
|
this.bundledViewsPath = options.bundledViewsPath;
|
|
55629
55643
|
this.onboardingContentPath = options.onboardingContentPath;
|
|
55630
|
-
this.bundledThemesPath = options.bundledThemesPath === void 0 ? void 0 :
|
|
55644
|
+
this.bundledThemesPath = options.bundledThemesPath === void 0 ? void 0 : import_node_path19.default.resolve(options.bundledThemesPath);
|
|
55631
55645
|
if (this.serving) {
|
|
55632
55646
|
runRedesignStorageMigration(this.storagePath);
|
|
55633
55647
|
}
|
|
@@ -55684,8 +55698,8 @@ var ServerStore = class extends EventTarget {
|
|
|
55684
55698
|
if (!isBundledViewID(id) || this.bundledViewsPath === void 0) {
|
|
55685
55699
|
return null;
|
|
55686
55700
|
}
|
|
55687
|
-
const viewPath =
|
|
55688
|
-
return (0,
|
|
55701
|
+
const viewPath = import_node_path19.default.join(this.bundledViewsPath, id);
|
|
55702
|
+
return (0, import_node_fs17.existsSync)(import_node_path19.default.join(viewPath, "index.html")) ? viewPath : null;
|
|
55689
55703
|
}
|
|
55690
55704
|
getChannel(id) {
|
|
55691
55705
|
const channel = this.channels.get(id);
|
|
@@ -55724,7 +55738,7 @@ var ServerStore = class extends EventTarget {
|
|
|
55724
55738
|
this.persistChannel(channel);
|
|
55725
55739
|
} catch (error48) {
|
|
55726
55740
|
channel.layout = previousLayout;
|
|
55727
|
-
(0,
|
|
55741
|
+
(0, import_node_fs17.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifact.id), { force: true });
|
|
55728
55742
|
throw error48;
|
|
55729
55743
|
}
|
|
55730
55744
|
this._artifacts.set(artifact.id, artifact);
|
|
@@ -55812,7 +55826,7 @@ var ServerStore = class extends EventTarget {
|
|
|
55812
55826
|
}
|
|
55813
55827
|
this.stopWatchingArtifactContent(artifactID);
|
|
55814
55828
|
this._artifacts.delete(artifactID);
|
|
55815
|
-
(0,
|
|
55829
|
+
(0, import_node_fs17.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifactID), { force: true });
|
|
55816
55830
|
if (channelID !== void 0) {
|
|
55817
55831
|
this.dispatchEvent(new ArtifactRemovedEvent("artifact-removed", { artifactID, channelID }));
|
|
55818
55832
|
}
|
|
@@ -56085,8 +56099,8 @@ var ServerStore = class extends EventTarget {
|
|
|
56085
56099
|
const artifactResults = artifactIDs.map(
|
|
56086
56100
|
(artifactID) => this.deleteArtifactWithCause(artifactID, "channel_deleted", telemetryContext)
|
|
56087
56101
|
);
|
|
56088
|
-
const metadataPath =
|
|
56089
|
-
(0,
|
|
56102
|
+
const metadataPath = import_node_path19.default.join(this.channelsDir, `${channel.id}.json`);
|
|
56103
|
+
(0, import_node_fs17.rmSync)(metadataPath, { force: true });
|
|
56090
56104
|
this.channels.delete(channel.id);
|
|
56091
56105
|
const nextFocusedChannelId = previousFocusedChannelId === channel.id ? this.pickDeletionSuccessorChannelID(nextPinnedChannelIds) : previousFocusedChannelId;
|
|
56092
56106
|
const pinnedChannelsChanged = !sameIds(nextPinnedChannelIds, this.pinnedChannelIds);
|
|
@@ -56133,13 +56147,13 @@ var ServerStore = class extends EventTarget {
|
|
|
56133
56147
|
}
|
|
56134
56148
|
}
|
|
56135
56149
|
load() {
|
|
56136
|
-
if ((0,
|
|
56137
|
-
for (const file2 of (0,
|
|
56150
|
+
if ((0, import_node_fs17.existsSync)(this.channelsDir)) {
|
|
56151
|
+
for (const file2 of (0, import_node_fs17.readdirSync)(this.channelsDir)) {
|
|
56138
56152
|
if (!file2.endsWith(JSON_FILE_SUFFIX2)) continue;
|
|
56139
|
-
const filePath =
|
|
56153
|
+
const filePath = import_node_path19.default.join(this.channelsDir, file2);
|
|
56140
56154
|
let raw;
|
|
56141
56155
|
try {
|
|
56142
|
-
raw = JSON.parse((0,
|
|
56156
|
+
raw = JSON.parse((0, import_node_fs17.readFileSync)(filePath, "utf8"));
|
|
56143
56157
|
} catch (error48) {
|
|
56144
56158
|
console.warn(`Skipping malformed JSON file: ${filePath}`, error48);
|
|
56145
56159
|
continue;
|
|
@@ -56157,15 +56171,15 @@ var ServerStore = class extends EventTarget {
|
|
|
56157
56171
|
});
|
|
56158
56172
|
}
|
|
56159
56173
|
}
|
|
56160
|
-
if (!(0,
|
|
56174
|
+
if (!(0, import_node_fs17.existsSync)(this.artifactsDir)) {
|
|
56161
56175
|
return;
|
|
56162
56176
|
}
|
|
56163
|
-
for (const file2 of (0,
|
|
56177
|
+
for (const file2 of (0, import_node_fs17.readdirSync)(this.artifactsDir)) {
|
|
56164
56178
|
if (!file2.endsWith(JSON_FILE_SUFFIX2)) {
|
|
56165
56179
|
continue;
|
|
56166
56180
|
}
|
|
56167
56181
|
const id = file2.slice(0, -JSON_FILE_SUFFIX2.length);
|
|
56168
|
-
const metadataPath =
|
|
56182
|
+
const metadataPath = import_node_path19.default.join(this.artifactsDir, file2);
|
|
56169
56183
|
const metadata = this.readArtifactFile(metadataPath, id);
|
|
56170
56184
|
this._artifacts.set(id, metadata);
|
|
56171
56185
|
}
|
|
@@ -56375,20 +56389,20 @@ var ServerStore = class extends EventTarget {
|
|
|
56375
56389
|
* without statting.
|
|
56376
56390
|
*/
|
|
56377
56391
|
normalizeArtifactPath(artifactPath) {
|
|
56378
|
-
if (!
|
|
56392
|
+
if (!import_node_path19.default.isAbsolute(artifactPath)) {
|
|
56379
56393
|
throw new InvalidRequestError("path must be absolute");
|
|
56380
56394
|
}
|
|
56381
56395
|
const stripped = stripTrailingSeparators(artifactPath);
|
|
56382
56396
|
let stat;
|
|
56383
56397
|
try {
|
|
56384
|
-
(0,
|
|
56385
|
-
stat = (0,
|
|
56398
|
+
(0, import_node_fs17.accessSync)(stripped, import_node_fs17.constants.R_OK);
|
|
56399
|
+
stat = (0, import_node_fs17.statSync)(stripped);
|
|
56386
56400
|
} catch {
|
|
56387
56401
|
throw new InvalidRequestError(`path does not exist or is not readable: ${artifactPath}`);
|
|
56388
56402
|
}
|
|
56389
56403
|
if (stat.isDirectory()) {
|
|
56390
|
-
const canonical = hasTrailingSeparator(stripped) ? stripped : `${stripped}${
|
|
56391
|
-
if (!DIRECTORY_INDEX_BASENAMES.some((basename) => (0,
|
|
56404
|
+
const canonical = hasTrailingSeparator(stripped) ? stripped : `${stripped}${import_node_path19.default.sep}`;
|
|
56405
|
+
if (!DIRECTORY_INDEX_BASENAMES.some((basename) => (0, import_node_fs17.existsSync)(import_node_path19.default.join(canonical, basename)))) {
|
|
56392
56406
|
throw new InvalidRequestError(`directory artifact must contain index.html or index.htm: ${canonical}`);
|
|
56393
56407
|
}
|
|
56394
56408
|
return canonical;
|
|
@@ -56465,11 +56479,11 @@ var ServerStore = class extends EventTarget {
|
|
|
56465
56479
|
}
|
|
56466
56480
|
}
|
|
56467
56481
|
ensureDirectories() {
|
|
56468
|
-
(0,
|
|
56469
|
-
(0,
|
|
56470
|
-
(0,
|
|
56471
|
-
(0,
|
|
56472
|
-
(0,
|
|
56482
|
+
(0, import_node_fs17.mkdirSync)(import_node_path19.default.join(this.storagePath, "state"), { recursive: true });
|
|
56483
|
+
(0, import_node_fs17.mkdirSync)(this.channelsDir, { recursive: true });
|
|
56484
|
+
(0, import_node_fs17.mkdirSync)(this.artifactsDir, { recursive: true });
|
|
56485
|
+
(0, import_node_fs17.mkdirSync)(getThemesDir(this.storagePath), { recursive: true });
|
|
56486
|
+
(0, import_node_fs17.mkdirSync)(getAgentArtifactsDir(this.storagePath), { recursive: true });
|
|
56473
56487
|
}
|
|
56474
56488
|
rebuildArtifactChannels() {
|
|
56475
56489
|
this.artifactChannels.clear();
|
|
@@ -56488,12 +56502,12 @@ var ServerStore = class extends EventTarget {
|
|
|
56488
56502
|
}
|
|
56489
56503
|
}
|
|
56490
56504
|
loadDisplayState() {
|
|
56491
|
-
if (!(0,
|
|
56505
|
+
if (!(0, import_node_fs17.existsSync)(this.displayStatePath)) {
|
|
56492
56506
|
return false;
|
|
56493
56507
|
}
|
|
56494
56508
|
let raw;
|
|
56495
56509
|
try {
|
|
56496
|
-
raw = (0,
|
|
56510
|
+
raw = (0, import_node_fs17.readFileSync)(this.displayStatePath, "utf8");
|
|
56497
56511
|
} catch {
|
|
56498
56512
|
return false;
|
|
56499
56513
|
}
|
|
@@ -56522,7 +56536,7 @@ var ServerStore = class extends EventTarget {
|
|
|
56522
56536
|
appearanceMode: this.appearanceMode,
|
|
56523
56537
|
themeJavaScriptConsentIds: [...this.themeJavaScriptConsentIds]
|
|
56524
56538
|
}) {
|
|
56525
|
-
(0,
|
|
56539
|
+
(0, import_node_fs17.writeFileSync)(
|
|
56526
56540
|
this.displayStatePath,
|
|
56527
56541
|
JSON.stringify({
|
|
56528
56542
|
focusedChannelId: state.focusedChannelId,
|
|
@@ -56564,11 +56578,11 @@ var ServerStore = class extends EventTarget {
|
|
|
56564
56578
|
return newestChannelID;
|
|
56565
56579
|
}
|
|
56566
56580
|
loadOrCreateAuthToken() {
|
|
56567
|
-
if ((0,
|
|
56568
|
-
return (0,
|
|
56581
|
+
if ((0, import_node_fs17.existsSync)(this.tokenPath)) {
|
|
56582
|
+
return (0, import_node_fs17.readFileSync)(this.tokenPath, "utf8").trim();
|
|
56569
56583
|
}
|
|
56570
56584
|
const token = createToken();
|
|
56571
|
-
(0,
|
|
56585
|
+
(0, import_node_fs17.writeFileSync)(this.tokenPath, `${token}
|
|
56572
56586
|
`);
|
|
56573
56587
|
return token;
|
|
56574
56588
|
}
|
|
@@ -56583,15 +56597,15 @@ var ServerStore = class extends EventTarget {
|
|
|
56583
56597
|
layout: channel.layout,
|
|
56584
56598
|
...channel.onboarding ? { onboarding: channel.onboarding } : {}
|
|
56585
56599
|
};
|
|
56586
|
-
(0,
|
|
56587
|
-
|
|
56600
|
+
(0, import_node_fs17.writeFileSync)(
|
|
56601
|
+
import_node_path19.default.join(this.channelsDir, `${channel.id}.json`),
|
|
56588
56602
|
JSON.stringify(stored, null, JSON_INDENT_SPACES5)
|
|
56589
56603
|
);
|
|
56590
56604
|
}
|
|
56591
56605
|
readArtifactFile(filePath, expectedID) {
|
|
56592
56606
|
let raw;
|
|
56593
56607
|
try {
|
|
56594
|
-
raw = (0,
|
|
56608
|
+
raw = (0, import_node_fs17.readFileSync)(filePath, "utf8");
|
|
56595
56609
|
} catch (error48) {
|
|
56596
56610
|
throw this.invalidMetadataFile(filePath, "unreadable", error48);
|
|
56597
56611
|
}
|
|
@@ -56613,7 +56627,7 @@ var ServerStore = class extends EventTarget {
|
|
|
56613
56627
|
`id ${result.data.id} does not match filename ${expectedID}`
|
|
56614
56628
|
);
|
|
56615
56629
|
}
|
|
56616
|
-
if (result.data.kind === "path" && !
|
|
56630
|
+
if (result.data.kind === "path" && !import_node_path19.default.isAbsolute(result.data.path)) {
|
|
56617
56631
|
throw this.invalidMetadataFile(filePath, "path must be absolute");
|
|
56618
56632
|
}
|
|
56619
56633
|
return result.data;
|
|
@@ -56625,7 +56639,7 @@ Correct this metadata file and restart Television, or delete only this metadata
|
|
|
56625
56639
|
return cause !== void 0 ? new Error(message, { cause }) : new Error(message);
|
|
56626
56640
|
}
|
|
56627
56641
|
writeArtifact(artifact) {
|
|
56628
|
-
(0,
|
|
56642
|
+
(0, import_node_fs17.writeFileSync)(getArtifactLiveMetadataPath(this.storagePath, artifact.id), JSON.stringify(artifact, null, JSON_INDENT_SPACES5));
|
|
56629
56643
|
}
|
|
56630
56644
|
get channelsDir() {
|
|
56631
56645
|
return getChannelsDir(this.storagePath);
|
|
@@ -56713,24 +56727,24 @@ function createDirectiveError(message) {
|
|
|
56713
56727
|
return new CLIDirectiveError(ensureHelpPointer(message));
|
|
56714
56728
|
}
|
|
56715
56729
|
function getDevPackageDir() {
|
|
56716
|
-
return
|
|
56730
|
+
return import_node_path20.default.resolve(import_node_path20.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "..");
|
|
56717
56731
|
}
|
|
56718
56732
|
function resolveVercelSkillsInstallerBin() {
|
|
56719
56733
|
if (typeof require === "function" && typeof require.resolve === "function") {
|
|
56720
56734
|
return require.resolve("skills/bin/cli.mjs");
|
|
56721
56735
|
}
|
|
56722
|
-
const localRequire = (0, import_node_module.createRequire)(
|
|
56736
|
+
const localRequire = (0, import_node_module.createRequire)(import_node_path20.default.join(getDevPackageDir(), "package.json"));
|
|
56723
56737
|
return localRequire.resolve("skills/bin/cli.mjs");
|
|
56724
56738
|
}
|
|
56725
56739
|
function readCLIVersion() {
|
|
56726
|
-
if ("1.3.
|
|
56727
|
-
return "1.3.
|
|
56740
|
+
if ("1.3.9".length > 0) {
|
|
56741
|
+
return "1.3.9";
|
|
56728
56742
|
}
|
|
56729
|
-
const devPackageJsonPath =
|
|
56730
|
-
if (!(0,
|
|
56743
|
+
const devPackageJsonPath = import_node_path20.default.join(getDevPackageDir(), "package.json");
|
|
56744
|
+
if (!(0, import_node_fs18.existsSync)(devPackageJsonPath)) {
|
|
56731
56745
|
throw new Error("Could not resolve package.json for repo-local CLI version.");
|
|
56732
56746
|
}
|
|
56733
|
-
return JSON.parse((0,
|
|
56747
|
+
return JSON.parse((0, import_node_fs18.readFileSync)(devPackageJsonPath, "utf8")).version;
|
|
56734
56748
|
}
|
|
56735
56749
|
function readCLIVersionOutput(resolveHomeDir) {
|
|
56736
56750
|
const releaseVersion = readCLIVersion();
|
|
@@ -56815,7 +56829,7 @@ function formatCLIError(error48, argv = []) {
|
|
|
56815
56829
|
const status = typeof error48.status === "number" ? Number(error48.status) : void 0;
|
|
56816
56830
|
if (status === HTTP_UNAUTHORIZED_STATUS2) {
|
|
56817
56831
|
return ensureHelpPointer(
|
|
56818
|
-
`Television server at ${serverURL} rejected the request as unauthorized. Check the token in ${
|
|
56832
|
+
`Television server at ${serverURL} rejected the request as unauthorized. Check the token in ${import_node_path20.default.join(storagePathFromArgv(argv) ?? getTelevisionStoragePath(), "state", "token")}.`
|
|
56819
56833
|
);
|
|
56820
56834
|
}
|
|
56821
56835
|
if (status !== void 0) {
|
|
@@ -56866,76 +56880,76 @@ function resolveServeAuth(argv, hasListen) {
|
|
|
56866
56880
|
}
|
|
56867
56881
|
function resolveStaticDir() {
|
|
56868
56882
|
if (process.argv[1]) {
|
|
56869
|
-
const entryDir =
|
|
56870
|
-
const resolved =
|
|
56871
|
-
return (0,
|
|
56883
|
+
const entryDir = import_node_path20.default.dirname((0, import_node_fs18.realpathSync)(process.argv[1]));
|
|
56884
|
+
const resolved = import_node_path20.default.resolve(entryDir, "./web");
|
|
56885
|
+
return (0, import_node_fs18.existsSync)(import_node_path20.default.join(resolved, "index.html")) ? resolved : void 0;
|
|
56872
56886
|
}
|
|
56873
|
-
const devStaticPath =
|
|
56874
|
-
return (0,
|
|
56887
|
+
const devStaticPath = import_node_path20.default.resolve(getDevPackageDir(), "../web/dist");
|
|
56888
|
+
return (0, import_node_fs18.existsSync)(import_node_path20.default.join(devStaticPath, "index.html")) ? devStaticPath : void 0;
|
|
56875
56889
|
}
|
|
56876
56890
|
function resolveBundledViewsPath() {
|
|
56877
56891
|
if (process.argv[1]) {
|
|
56878
|
-
const entryDir =
|
|
56879
|
-
const resolved =
|
|
56880
|
-
return (0,
|
|
56892
|
+
const entryDir = import_node_path20.default.dirname((0, import_node_fs18.realpathSync)(process.argv[1]));
|
|
56893
|
+
const resolved = import_node_path20.default.resolve(entryDir, "./views");
|
|
56894
|
+
return (0, import_node_fs18.existsSync)(resolved) ? resolved : void 0;
|
|
56881
56895
|
}
|
|
56882
|
-
const devViewsPath =
|
|
56883
|
-
return (0,
|
|
56896
|
+
const devViewsPath = import_node_path20.default.join(getDevPackageDir(), "dist/views");
|
|
56897
|
+
return (0, import_node_fs18.existsSync)(devViewsPath) ? devViewsPath : void 0;
|
|
56884
56898
|
}
|
|
56885
56899
|
function resolveCanonicalDir() {
|
|
56886
56900
|
if (process.argv[1]) {
|
|
56887
|
-
const entryDir =
|
|
56888
|
-
const resolved =
|
|
56889
|
-
return (0,
|
|
56901
|
+
const entryDir = import_node_path20.default.dirname((0, import_node_fs18.realpathSync)(process.argv[1]));
|
|
56902
|
+
const resolved = import_node_path20.default.resolve(entryDir, "./canonical");
|
|
56903
|
+
return (0, import_node_fs18.existsSync)(resolved) ? resolved : void 0;
|
|
56890
56904
|
}
|
|
56891
|
-
const devCanonicalPath =
|
|
56905
|
+
const devCanonicalPath = import_node_path20.default.resolve(
|
|
56892
56906
|
getDevPackageDir(),
|
|
56893
56907
|
"../server/dist/canonical"
|
|
56894
56908
|
);
|
|
56895
|
-
return (0,
|
|
56909
|
+
return (0, import_node_fs18.existsSync)(devCanonicalPath) ? devCanonicalPath : void 0;
|
|
56896
56910
|
}
|
|
56897
56911
|
function resolveOnboardingContentPath() {
|
|
56898
56912
|
if (process.argv[1]) {
|
|
56899
|
-
const entryDir =
|
|
56900
|
-
const resolved =
|
|
56901
|
-
return (0,
|
|
56913
|
+
const entryDir = import_node_path20.default.dirname((0, import_node_fs18.realpathSync)(process.argv[1]));
|
|
56914
|
+
const resolved = import_node_path20.default.resolve(entryDir, "./onboarding");
|
|
56915
|
+
return (0, import_node_fs18.existsSync)(resolved) ? resolved : void 0;
|
|
56902
56916
|
}
|
|
56903
|
-
const devPath =
|
|
56917
|
+
const devPath = import_node_path20.default.resolve(
|
|
56904
56918
|
getDevPackageDir(),
|
|
56905
56919
|
"../server/assets/onboarding-channels"
|
|
56906
56920
|
);
|
|
56907
|
-
return (0,
|
|
56921
|
+
return (0, import_node_fs18.existsSync)(devPath) ? devPath : void 0;
|
|
56908
56922
|
}
|
|
56909
56923
|
function resolveBundledThemesPath() {
|
|
56910
56924
|
if (process.argv[1]) {
|
|
56911
|
-
const entryDir =
|
|
56912
|
-
const resolved =
|
|
56913
|
-
return (0,
|
|
56925
|
+
const entryDir = import_node_path20.default.dirname((0, import_node_fs18.realpathSync)(process.argv[1]));
|
|
56926
|
+
const resolved = import_node_path20.default.resolve(entryDir, "./themes");
|
|
56927
|
+
return (0, import_node_fs18.existsSync)(resolved) ? resolved : void 0;
|
|
56914
56928
|
}
|
|
56915
|
-
const devPath =
|
|
56916
|
-
return (0,
|
|
56929
|
+
const devPath = import_node_path20.default.resolve(getDevPackageDir(), "../server/assets/themes");
|
|
56930
|
+
return (0, import_node_fs18.existsSync)(devPath) ? devPath : void 0;
|
|
56917
56931
|
}
|
|
56918
56932
|
function resolveBundledSkillsRoot() {
|
|
56919
|
-
const builtPath = typeof process.argv[1] === "string" ?
|
|
56920
|
-
if (builtPath && (0,
|
|
56933
|
+
const builtPath = typeof process.argv[1] === "string" ? import_node_path20.default.resolve(import_node_path20.default.dirname((0, import_node_fs18.realpathSync)(process.argv[1])), "./skills") : void 0;
|
|
56934
|
+
if (builtPath && (0, import_node_fs18.existsSync)(builtPath)) {
|
|
56921
56935
|
return builtPath;
|
|
56922
56936
|
}
|
|
56923
|
-
const devPath =
|
|
56924
|
-
return (0,
|
|
56937
|
+
const devPath = import_node_path20.default.resolve(getDevPackageDir(), "../skills/dist");
|
|
56938
|
+
return (0, import_node_fs18.existsSync)(devPath) ? devPath : void 0;
|
|
56925
56939
|
}
|
|
56926
56940
|
function copyBundledSkillsToDestination(bundledSkillsRoot, destinationRoot) {
|
|
56927
|
-
if ((0,
|
|
56941
|
+
if ((0, import_node_fs18.existsSync)(destinationRoot) && !(0, import_node_fs18.statSync)(destinationRoot).isDirectory()) {
|
|
56928
56942
|
throw new Error(`Skills destination is not a directory: ${destinationRoot}`);
|
|
56929
56943
|
}
|
|
56930
|
-
(0,
|
|
56931
|
-
(0,
|
|
56944
|
+
(0, import_node_fs18.mkdirSync)(destinationRoot, { recursive: true });
|
|
56945
|
+
(0, import_node_fs18.rmSync)(import_node_path20.default.join(destinationRoot, "tv-theme"), { recursive: true, force: true });
|
|
56932
56946
|
const copied = [];
|
|
56933
|
-
const entries = (0,
|
|
56947
|
+
const entries = (0, import_node_fs18.readdirSync)(bundledSkillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b2) => a.name.localeCompare(b2.name));
|
|
56934
56948
|
for (const entry of entries) {
|
|
56935
|
-
const sourcePath =
|
|
56936
|
-
const destinationPath =
|
|
56937
|
-
(0,
|
|
56938
|
-
(0,
|
|
56949
|
+
const sourcePath = import_node_path20.default.join(bundledSkillsRoot, entry.name);
|
|
56950
|
+
const destinationPath = import_node_path20.default.join(destinationRoot, entry.name);
|
|
56951
|
+
(0, import_node_fs18.rmSync)(destinationPath, { recursive: true, force: true });
|
|
56952
|
+
(0, import_node_fs18.cpSync)(sourcePath, destinationPath, { recursive: true });
|
|
56939
56953
|
copied.push({ name: entry.name, sourcePath, destinationPath });
|
|
56940
56954
|
}
|
|
56941
56955
|
return copied;
|
|
@@ -57018,11 +57032,11 @@ function formatCommanderError(argv, error48) {
|
|
|
57018
57032
|
return null;
|
|
57019
57033
|
}
|
|
57020
57034
|
function readAuthToken(storagePath) {
|
|
57021
|
-
const tokenPath =
|
|
57022
|
-
if (!(0,
|
|
57035
|
+
const tokenPath = import_node_path20.default.join(storagePath, "state", "token");
|
|
57036
|
+
if (!(0, import_node_fs18.existsSync)(tokenPath)) {
|
|
57023
57037
|
return void 0;
|
|
57024
57038
|
}
|
|
57025
|
-
const token = (0,
|
|
57039
|
+
const token = (0, import_node_fs18.readFileSync)(tokenPath, "utf8").trim();
|
|
57026
57040
|
return token.length > 0 ? token : void 0;
|
|
57027
57041
|
}
|
|
57028
57042
|
function readOrCreateAuthToken(storagePath) {
|
|
@@ -57101,7 +57115,7 @@ function createEnvironment(environment) {
|
|
|
57101
57115
|
resolveOnboardingContentPath: environment.resolveOnboardingContentPath ?? (() => resolveOnboardingContentPath()),
|
|
57102
57116
|
resolveBundledThemesPath: environment.resolveBundledThemesPath ?? (() => resolveBundledThemesPath()),
|
|
57103
57117
|
resolveBundledSkillsRoot: environment.resolveBundledSkillsRoot ?? (() => resolveBundledSkillsRoot()),
|
|
57104
|
-
resolveHomeDir: environment.resolveHomeDir ?? (() =>
|
|
57118
|
+
resolveHomeDir: environment.resolveHomeDir ?? (() => import_node_os6.default.homedir()),
|
|
57105
57119
|
runSkillsInstaller: environment.runSkillsInstaller ?? (async (args) => {
|
|
57106
57120
|
const vercelSkillsInstallerBin = resolveVercelSkillsInstallerBin();
|
|
57107
57121
|
const result = (0, import_node_child_process3.spawnSync)(process.execPath, [vercelSkillsInstallerBin, ...args], { stdio: "inherit" });
|
|
@@ -57182,7 +57196,7 @@ function createProgram(env, argv = []) {
|
|
|
57182
57196
|
);
|
|
57183
57197
|
}
|
|
57184
57198
|
const clientPort = resolveClientPort(opts.port);
|
|
57185
|
-
const storagePath =
|
|
57199
|
+
const storagePath = import_node_path20.default.resolve(opts.storagePath ?? getTelevisionStoragePath());
|
|
57186
57200
|
const profile2 = resolveACPAgentProfile(process.env);
|
|
57187
57201
|
const daemonEnv = buildPersistedACPEnvironment(process.env, { developerHome: env.resolveHomeDir() });
|
|
57188
57202
|
if (process.env.TELEVISION_PORT !== void 0 && process.env.TELEVISION_PORT !== "") {
|
|
@@ -57501,7 +57515,7 @@ function createProgram(env, argv = []) {
|
|
|
57501
57515
|
if (!bundledTelevisionSkillsCollectionRoot) {
|
|
57502
57516
|
throw new Error("Could not resolve the bundled Television skills root.");
|
|
57503
57517
|
}
|
|
57504
|
-
const destinationRoot =
|
|
57518
|
+
const destinationRoot = import_node_path20.default.resolve(inputPath);
|
|
57505
57519
|
const copied = copyBundledSkillsToDestination(bundledTelevisionSkillsCollectionRoot, destinationRoot);
|
|
57506
57520
|
writeLine(env.stdout, `Copied ${copied.length} bundled Television skill(s):`);
|
|
57507
57521
|
for (const skill of copied) {
|