@lolyjs/core 0.2.0-alpha.32 → 0.2.0-alpha.33
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/README.md +63 -0
- package/dist/cli.cjs +316 -247
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +310 -241
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +282 -213
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +282 -213
- package/dist/index.js.map +1 -1
- package/dist/{index.types-JJ0KjvFU.d.mts → index.types-Duhjyfit.d.mts} +15 -1
- package/dist/{index.types-JJ0KjvFU.d.ts → index.types-Duhjyfit.d.ts} +15 -1
- package/dist/react/cache.d.mts +1 -1
- package/dist/react/cache.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9906,8 +9906,8 @@ __export(src_exports, {
|
|
|
9906
9906
|
module.exports = __toCommonJS(src_exports);
|
|
9907
9907
|
|
|
9908
9908
|
// src/server.ts
|
|
9909
|
-
var
|
|
9910
|
-
var
|
|
9909
|
+
var import_fs22 = __toESM(require("fs"));
|
|
9910
|
+
var import_path28 = __toESM(require("path"));
|
|
9911
9911
|
|
|
9912
9912
|
// modules/server/utils/server-dir.ts
|
|
9913
9913
|
var import_fs = __toESM(require("fs"));
|
|
@@ -12550,7 +12550,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
12550
12550
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
12551
12551
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
12552
12552
|
if (wantBigintFsStats) {
|
|
12553
|
-
this._stat = (
|
|
12553
|
+
this._stat = (path31) => statMethod(path31, { bigint: true });
|
|
12554
12554
|
} else {
|
|
12555
12555
|
this._stat = statMethod;
|
|
12556
12556
|
}
|
|
@@ -12575,8 +12575,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
12575
12575
|
const par = this.parent;
|
|
12576
12576
|
const fil = par && par.files;
|
|
12577
12577
|
if (fil && fil.length > 0) {
|
|
12578
|
-
const { path:
|
|
12579
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
12578
|
+
const { path: path31, depth } = par;
|
|
12579
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path31));
|
|
12580
12580
|
const awaited = await Promise.all(slice);
|
|
12581
12581
|
for (const entry of awaited) {
|
|
12582
12582
|
if (!entry)
|
|
@@ -12616,20 +12616,20 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
12616
12616
|
this.reading = false;
|
|
12617
12617
|
}
|
|
12618
12618
|
}
|
|
12619
|
-
async _exploreDir(
|
|
12619
|
+
async _exploreDir(path31, depth) {
|
|
12620
12620
|
let files;
|
|
12621
12621
|
try {
|
|
12622
|
-
files = await (0, import_promises.readdir)(
|
|
12622
|
+
files = await (0, import_promises.readdir)(path31, this._rdOptions);
|
|
12623
12623
|
} catch (error) {
|
|
12624
12624
|
this._onError(error);
|
|
12625
12625
|
}
|
|
12626
|
-
return { files, depth, path:
|
|
12626
|
+
return { files, depth, path: path31 };
|
|
12627
12627
|
}
|
|
12628
|
-
async _formatEntry(dirent,
|
|
12628
|
+
async _formatEntry(dirent, path31) {
|
|
12629
12629
|
let entry;
|
|
12630
12630
|
const basename3 = this._isDirent ? dirent.name : dirent;
|
|
12631
12631
|
try {
|
|
12632
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
12632
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path31, basename3));
|
|
12633
12633
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename3 };
|
|
12634
12634
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
12635
12635
|
} catch (err) {
|
|
@@ -13029,16 +13029,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
13029
13029
|
};
|
|
13030
13030
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
13031
13031
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
13032
|
-
function createFsWatchInstance(
|
|
13032
|
+
function createFsWatchInstance(path31, options, listener, errHandler, emitRaw) {
|
|
13033
13033
|
const handleEvent = (rawEvent, evPath) => {
|
|
13034
|
-
listener(
|
|
13035
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
13036
|
-
if (evPath &&
|
|
13037
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
13034
|
+
listener(path31);
|
|
13035
|
+
emitRaw(rawEvent, evPath, { watchedPath: path31 });
|
|
13036
|
+
if (evPath && path31 !== evPath) {
|
|
13037
|
+
fsWatchBroadcast(sysPath.resolve(path31, evPath), KEY_LISTENERS, sysPath.join(path31, evPath));
|
|
13038
13038
|
}
|
|
13039
13039
|
};
|
|
13040
13040
|
try {
|
|
13041
|
-
return (0, import_fs16.watch)(
|
|
13041
|
+
return (0, import_fs16.watch)(path31, {
|
|
13042
13042
|
persistent: options.persistent
|
|
13043
13043
|
}, handleEvent);
|
|
13044
13044
|
} catch (error) {
|
|
@@ -13054,12 +13054,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
13054
13054
|
listener(val1, val2, val3);
|
|
13055
13055
|
});
|
|
13056
13056
|
};
|
|
13057
|
-
var setFsWatchListener = (
|
|
13057
|
+
var setFsWatchListener = (path31, fullPath, options, handlers) => {
|
|
13058
13058
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
13059
13059
|
let cont = FsWatchInstances.get(fullPath);
|
|
13060
13060
|
let watcher;
|
|
13061
13061
|
if (!options.persistent) {
|
|
13062
|
-
watcher = createFsWatchInstance(
|
|
13062
|
+
watcher = createFsWatchInstance(path31, options, listener, errHandler, rawEmitter);
|
|
13063
13063
|
if (!watcher)
|
|
13064
13064
|
return;
|
|
13065
13065
|
return watcher.close.bind(watcher);
|
|
@@ -13070,7 +13070,7 @@ var setFsWatchListener = (path30, fullPath, options, handlers) => {
|
|
|
13070
13070
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
13071
13071
|
} else {
|
|
13072
13072
|
watcher = createFsWatchInstance(
|
|
13073
|
-
|
|
13073
|
+
path31,
|
|
13074
13074
|
options,
|
|
13075
13075
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
13076
13076
|
errHandler,
|
|
@@ -13085,7 +13085,7 @@ var setFsWatchListener = (path30, fullPath, options, handlers) => {
|
|
|
13085
13085
|
cont.watcherUnusable = true;
|
|
13086
13086
|
if (isWindows && error.code === "EPERM") {
|
|
13087
13087
|
try {
|
|
13088
|
-
const fd = await (0, import_promises2.open)(
|
|
13088
|
+
const fd = await (0, import_promises2.open)(path31, "r");
|
|
13089
13089
|
await fd.close();
|
|
13090
13090
|
broadcastErr(error);
|
|
13091
13091
|
} catch (err) {
|
|
@@ -13116,7 +13116,7 @@ var setFsWatchListener = (path30, fullPath, options, handlers) => {
|
|
|
13116
13116
|
};
|
|
13117
13117
|
};
|
|
13118
13118
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
13119
|
-
var setFsWatchFileListener = (
|
|
13119
|
+
var setFsWatchFileListener = (path31, fullPath, options, handlers) => {
|
|
13120
13120
|
const { listener, rawEmitter } = handlers;
|
|
13121
13121
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
13122
13122
|
const copts = cont && cont.options;
|
|
@@ -13138,7 +13138,7 @@ var setFsWatchFileListener = (path30, fullPath, options, handlers) => {
|
|
|
13138
13138
|
});
|
|
13139
13139
|
const currmtime = curr.mtimeMs;
|
|
13140
13140
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
13141
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
13141
|
+
foreach(cont.listeners, (listener2) => listener2(path31, curr));
|
|
13142
13142
|
}
|
|
13143
13143
|
})
|
|
13144
13144
|
};
|
|
@@ -13166,13 +13166,13 @@ var NodeFsHandler = class {
|
|
|
13166
13166
|
* @param listener on fs change
|
|
13167
13167
|
* @returns closer for the watcher instance
|
|
13168
13168
|
*/
|
|
13169
|
-
_watchWithNodeFs(
|
|
13169
|
+
_watchWithNodeFs(path31, listener) {
|
|
13170
13170
|
const opts = this.fsw.options;
|
|
13171
|
-
const directory = sysPath.dirname(
|
|
13172
|
-
const basename3 = sysPath.basename(
|
|
13171
|
+
const directory = sysPath.dirname(path31);
|
|
13172
|
+
const basename3 = sysPath.basename(path31);
|
|
13173
13173
|
const parent = this.fsw._getWatchedDir(directory);
|
|
13174
13174
|
parent.add(basename3);
|
|
13175
|
-
const absolutePath = sysPath.resolve(
|
|
13175
|
+
const absolutePath = sysPath.resolve(path31);
|
|
13176
13176
|
const options = {
|
|
13177
13177
|
persistent: opts.persistent
|
|
13178
13178
|
};
|
|
@@ -13182,12 +13182,12 @@ var NodeFsHandler = class {
|
|
|
13182
13182
|
if (opts.usePolling) {
|
|
13183
13183
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
13184
13184
|
options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
|
|
13185
|
-
closer = setFsWatchFileListener(
|
|
13185
|
+
closer = setFsWatchFileListener(path31, absolutePath, options, {
|
|
13186
13186
|
listener,
|
|
13187
13187
|
rawEmitter: this.fsw._emitRaw
|
|
13188
13188
|
});
|
|
13189
13189
|
} else {
|
|
13190
|
-
closer = setFsWatchListener(
|
|
13190
|
+
closer = setFsWatchListener(path31, absolutePath, options, {
|
|
13191
13191
|
listener,
|
|
13192
13192
|
errHandler: this._boundHandleError,
|
|
13193
13193
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -13209,7 +13209,7 @@ var NodeFsHandler = class {
|
|
|
13209
13209
|
let prevStats = stats;
|
|
13210
13210
|
if (parent.has(basename3))
|
|
13211
13211
|
return;
|
|
13212
|
-
const listener = async (
|
|
13212
|
+
const listener = async (path31, newStats) => {
|
|
13213
13213
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
13214
13214
|
return;
|
|
13215
13215
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -13223,11 +13223,11 @@ var NodeFsHandler = class {
|
|
|
13223
13223
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
13224
13224
|
}
|
|
13225
13225
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
13226
|
-
this.fsw._closeFile(
|
|
13226
|
+
this.fsw._closeFile(path31);
|
|
13227
13227
|
prevStats = newStats2;
|
|
13228
13228
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
13229
13229
|
if (closer2)
|
|
13230
|
-
this.fsw._addPathCloser(
|
|
13230
|
+
this.fsw._addPathCloser(path31, closer2);
|
|
13231
13231
|
} else {
|
|
13232
13232
|
prevStats = newStats2;
|
|
13233
13233
|
}
|
|
@@ -13259,7 +13259,7 @@ var NodeFsHandler = class {
|
|
|
13259
13259
|
* @param item basename of this item
|
|
13260
13260
|
* @returns true if no more processing is needed for this entry.
|
|
13261
13261
|
*/
|
|
13262
|
-
async _handleSymlink(entry, directory,
|
|
13262
|
+
async _handleSymlink(entry, directory, path31, item) {
|
|
13263
13263
|
if (this.fsw.closed) {
|
|
13264
13264
|
return;
|
|
13265
13265
|
}
|
|
@@ -13269,7 +13269,7 @@ var NodeFsHandler = class {
|
|
|
13269
13269
|
this.fsw._incrReadyCount();
|
|
13270
13270
|
let linkPath;
|
|
13271
13271
|
try {
|
|
13272
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
13272
|
+
linkPath = await (0, import_promises2.realpath)(path31);
|
|
13273
13273
|
} catch (e) {
|
|
13274
13274
|
this.fsw._emitReady();
|
|
13275
13275
|
return true;
|
|
@@ -13279,12 +13279,12 @@ var NodeFsHandler = class {
|
|
|
13279
13279
|
if (dir.has(item)) {
|
|
13280
13280
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
13281
13281
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
13282
|
-
this.fsw._emit(EV.CHANGE,
|
|
13282
|
+
this.fsw._emit(EV.CHANGE, path31, entry.stats);
|
|
13283
13283
|
}
|
|
13284
13284
|
} else {
|
|
13285
13285
|
dir.add(item);
|
|
13286
13286
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
13287
|
-
this.fsw._emit(EV.ADD,
|
|
13287
|
+
this.fsw._emit(EV.ADD, path31, entry.stats);
|
|
13288
13288
|
}
|
|
13289
13289
|
this.fsw._emitReady();
|
|
13290
13290
|
return true;
|
|
@@ -13313,9 +13313,9 @@ var NodeFsHandler = class {
|
|
|
13313
13313
|
return;
|
|
13314
13314
|
}
|
|
13315
13315
|
const item = entry.path;
|
|
13316
|
-
let
|
|
13316
|
+
let path31 = sysPath.join(directory, item);
|
|
13317
13317
|
current.add(item);
|
|
13318
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
13318
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path31, item)) {
|
|
13319
13319
|
return;
|
|
13320
13320
|
}
|
|
13321
13321
|
if (this.fsw.closed) {
|
|
@@ -13324,8 +13324,8 @@ var NodeFsHandler = class {
|
|
|
13324
13324
|
}
|
|
13325
13325
|
if (item === target || !target && !previous.has(item)) {
|
|
13326
13326
|
this.fsw._incrReadyCount();
|
|
13327
|
-
|
|
13328
|
-
this._addToNodeFs(
|
|
13327
|
+
path31 = sysPath.join(dir, sysPath.relative(dir, path31));
|
|
13328
|
+
this._addToNodeFs(path31, initialAdd, wh, depth + 1);
|
|
13329
13329
|
}
|
|
13330
13330
|
}).on(EV.ERROR, this._boundHandleError);
|
|
13331
13331
|
return new Promise((resolve3, reject) => {
|
|
@@ -13394,13 +13394,13 @@ var NodeFsHandler = class {
|
|
|
13394
13394
|
* @param depth Child path actually targeted for watch
|
|
13395
13395
|
* @param target Child path actually targeted for watch
|
|
13396
13396
|
*/
|
|
13397
|
-
async _addToNodeFs(
|
|
13397
|
+
async _addToNodeFs(path31, initialAdd, priorWh, depth, target) {
|
|
13398
13398
|
const ready = this.fsw._emitReady;
|
|
13399
|
-
if (this.fsw._isIgnored(
|
|
13399
|
+
if (this.fsw._isIgnored(path31) || this.fsw.closed) {
|
|
13400
13400
|
ready();
|
|
13401
13401
|
return false;
|
|
13402
13402
|
}
|
|
13403
|
-
const wh = this.fsw._getWatchHelpers(
|
|
13403
|
+
const wh = this.fsw._getWatchHelpers(path31);
|
|
13404
13404
|
if (priorWh) {
|
|
13405
13405
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
13406
13406
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -13416,8 +13416,8 @@ var NodeFsHandler = class {
|
|
|
13416
13416
|
const follow = this.fsw.options.followSymlinks;
|
|
13417
13417
|
let closer;
|
|
13418
13418
|
if (stats.isDirectory()) {
|
|
13419
|
-
const absPath = sysPath.resolve(
|
|
13420
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
13419
|
+
const absPath = sysPath.resolve(path31);
|
|
13420
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path31) : path31;
|
|
13421
13421
|
if (this.fsw.closed)
|
|
13422
13422
|
return;
|
|
13423
13423
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -13427,29 +13427,29 @@ var NodeFsHandler = class {
|
|
|
13427
13427
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
13428
13428
|
}
|
|
13429
13429
|
} else if (stats.isSymbolicLink()) {
|
|
13430
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
13430
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path31) : path31;
|
|
13431
13431
|
if (this.fsw.closed)
|
|
13432
13432
|
return;
|
|
13433
13433
|
const parent = sysPath.dirname(wh.watchPath);
|
|
13434
13434
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
13435
13435
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
13436
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
13436
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path31, wh, targetPath);
|
|
13437
13437
|
if (this.fsw.closed)
|
|
13438
13438
|
return;
|
|
13439
13439
|
if (targetPath !== void 0) {
|
|
13440
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
13440
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path31), targetPath);
|
|
13441
13441
|
}
|
|
13442
13442
|
} else {
|
|
13443
13443
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
13444
13444
|
}
|
|
13445
13445
|
ready();
|
|
13446
13446
|
if (closer)
|
|
13447
|
-
this.fsw._addPathCloser(
|
|
13447
|
+
this.fsw._addPathCloser(path31, closer);
|
|
13448
13448
|
return false;
|
|
13449
13449
|
} catch (error) {
|
|
13450
13450
|
if (this.fsw._handleError(error)) {
|
|
13451
13451
|
ready();
|
|
13452
|
-
return
|
|
13452
|
+
return path31;
|
|
13453
13453
|
}
|
|
13454
13454
|
}
|
|
13455
13455
|
}
|
|
@@ -13492,26 +13492,26 @@ function createPattern(matcher) {
|
|
|
13492
13492
|
}
|
|
13493
13493
|
return () => false;
|
|
13494
13494
|
}
|
|
13495
|
-
function normalizePath(
|
|
13496
|
-
if (typeof
|
|
13495
|
+
function normalizePath(path31) {
|
|
13496
|
+
if (typeof path31 !== "string")
|
|
13497
13497
|
throw new Error("string expected");
|
|
13498
|
-
|
|
13499
|
-
|
|
13498
|
+
path31 = sysPath2.normalize(path31);
|
|
13499
|
+
path31 = path31.replace(/\\/g, "/");
|
|
13500
13500
|
let prepend = false;
|
|
13501
|
-
if (
|
|
13501
|
+
if (path31.startsWith("//"))
|
|
13502
13502
|
prepend = true;
|
|
13503
13503
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
13504
|
-
while (
|
|
13505
|
-
|
|
13504
|
+
while (path31.match(DOUBLE_SLASH_RE2))
|
|
13505
|
+
path31 = path31.replace(DOUBLE_SLASH_RE2, "/");
|
|
13506
13506
|
if (prepend)
|
|
13507
|
-
|
|
13508
|
-
return
|
|
13507
|
+
path31 = "/" + path31;
|
|
13508
|
+
return path31;
|
|
13509
13509
|
}
|
|
13510
13510
|
function matchPatterns(patterns, testString, stats) {
|
|
13511
|
-
const
|
|
13511
|
+
const path31 = normalizePath(testString);
|
|
13512
13512
|
for (let index = 0; index < patterns.length; index++) {
|
|
13513
13513
|
const pattern = patterns[index];
|
|
13514
|
-
if (pattern(
|
|
13514
|
+
if (pattern(path31, stats)) {
|
|
13515
13515
|
return true;
|
|
13516
13516
|
}
|
|
13517
13517
|
}
|
|
@@ -13551,19 +13551,19 @@ var toUnix = (string) => {
|
|
|
13551
13551
|
}
|
|
13552
13552
|
return str;
|
|
13553
13553
|
};
|
|
13554
|
-
var normalizePathToUnix = (
|
|
13555
|
-
var normalizeIgnored = (cwd = "") => (
|
|
13556
|
-
if (typeof
|
|
13557
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
13554
|
+
var normalizePathToUnix = (path31) => toUnix(sysPath2.normalize(toUnix(path31)));
|
|
13555
|
+
var normalizeIgnored = (cwd = "") => (path31) => {
|
|
13556
|
+
if (typeof path31 === "string") {
|
|
13557
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path31) ? path31 : sysPath2.join(cwd, path31));
|
|
13558
13558
|
} else {
|
|
13559
|
-
return
|
|
13559
|
+
return path31;
|
|
13560
13560
|
}
|
|
13561
13561
|
};
|
|
13562
|
-
var getAbsolutePath = (
|
|
13563
|
-
if (sysPath2.isAbsolute(
|
|
13564
|
-
return
|
|
13562
|
+
var getAbsolutePath = (path31, cwd) => {
|
|
13563
|
+
if (sysPath2.isAbsolute(path31)) {
|
|
13564
|
+
return path31;
|
|
13565
13565
|
}
|
|
13566
|
-
return sysPath2.join(cwd,
|
|
13566
|
+
return sysPath2.join(cwd, path31);
|
|
13567
13567
|
};
|
|
13568
13568
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
13569
13569
|
var DirEntry = class {
|
|
@@ -13618,10 +13618,10 @@ var DirEntry = class {
|
|
|
13618
13618
|
var STAT_METHOD_F = "stat";
|
|
13619
13619
|
var STAT_METHOD_L = "lstat";
|
|
13620
13620
|
var WatchHelper = class {
|
|
13621
|
-
constructor(
|
|
13621
|
+
constructor(path31, follow, fsw) {
|
|
13622
13622
|
this.fsw = fsw;
|
|
13623
|
-
const watchPath =
|
|
13624
|
-
this.path =
|
|
13623
|
+
const watchPath = path31;
|
|
13624
|
+
this.path = path31 = path31.replace(REPLACER_RE, "");
|
|
13625
13625
|
this.watchPath = watchPath;
|
|
13626
13626
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
13627
13627
|
this.dirParts = [];
|
|
@@ -13743,20 +13743,20 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
13743
13743
|
this._closePromise = void 0;
|
|
13744
13744
|
let paths = unifyPaths(paths_);
|
|
13745
13745
|
if (cwd) {
|
|
13746
|
-
paths = paths.map((
|
|
13747
|
-
const absPath = getAbsolutePath(
|
|
13746
|
+
paths = paths.map((path31) => {
|
|
13747
|
+
const absPath = getAbsolutePath(path31, cwd);
|
|
13748
13748
|
return absPath;
|
|
13749
13749
|
});
|
|
13750
13750
|
}
|
|
13751
|
-
paths.forEach((
|
|
13752
|
-
this._removeIgnoredPath(
|
|
13751
|
+
paths.forEach((path31) => {
|
|
13752
|
+
this._removeIgnoredPath(path31);
|
|
13753
13753
|
});
|
|
13754
13754
|
this._userIgnored = void 0;
|
|
13755
13755
|
if (!this._readyCount)
|
|
13756
13756
|
this._readyCount = 0;
|
|
13757
13757
|
this._readyCount += paths.length;
|
|
13758
|
-
Promise.all(paths.map(async (
|
|
13759
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
13758
|
+
Promise.all(paths.map(async (path31) => {
|
|
13759
|
+
const res = await this._nodeFsHandler._addToNodeFs(path31, !_internal, void 0, 0, _origAdd);
|
|
13760
13760
|
if (res)
|
|
13761
13761
|
this._emitReady();
|
|
13762
13762
|
return res;
|
|
@@ -13778,17 +13778,17 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
13778
13778
|
return this;
|
|
13779
13779
|
const paths = unifyPaths(paths_);
|
|
13780
13780
|
const { cwd } = this.options;
|
|
13781
|
-
paths.forEach((
|
|
13782
|
-
if (!sysPath2.isAbsolute(
|
|
13781
|
+
paths.forEach((path31) => {
|
|
13782
|
+
if (!sysPath2.isAbsolute(path31) && !this._closers.has(path31)) {
|
|
13783
13783
|
if (cwd)
|
|
13784
|
-
|
|
13785
|
-
|
|
13784
|
+
path31 = sysPath2.join(cwd, path31);
|
|
13785
|
+
path31 = sysPath2.resolve(path31);
|
|
13786
13786
|
}
|
|
13787
|
-
this._closePath(
|
|
13788
|
-
this._addIgnoredPath(
|
|
13789
|
-
if (this._watched.has(
|
|
13787
|
+
this._closePath(path31);
|
|
13788
|
+
this._addIgnoredPath(path31);
|
|
13789
|
+
if (this._watched.has(path31)) {
|
|
13790
13790
|
this._addIgnoredPath({
|
|
13791
|
-
path:
|
|
13791
|
+
path: path31,
|
|
13792
13792
|
recursive: true
|
|
13793
13793
|
});
|
|
13794
13794
|
}
|
|
@@ -13852,38 +13852,38 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
13852
13852
|
* @param stats arguments to be passed with event
|
|
13853
13853
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
13854
13854
|
*/
|
|
13855
|
-
async _emit(event,
|
|
13855
|
+
async _emit(event, path31, stats) {
|
|
13856
13856
|
if (this.closed)
|
|
13857
13857
|
return;
|
|
13858
13858
|
const opts = this.options;
|
|
13859
13859
|
if (isWindows)
|
|
13860
|
-
|
|
13860
|
+
path31 = sysPath2.normalize(path31);
|
|
13861
13861
|
if (opts.cwd)
|
|
13862
|
-
|
|
13863
|
-
const args = [
|
|
13862
|
+
path31 = sysPath2.relative(opts.cwd, path31);
|
|
13863
|
+
const args = [path31];
|
|
13864
13864
|
if (stats != null)
|
|
13865
13865
|
args.push(stats);
|
|
13866
13866
|
const awf = opts.awaitWriteFinish;
|
|
13867
13867
|
let pw;
|
|
13868
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
13868
|
+
if (awf && (pw = this._pendingWrites.get(path31))) {
|
|
13869
13869
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
13870
13870
|
return this;
|
|
13871
13871
|
}
|
|
13872
13872
|
if (opts.atomic) {
|
|
13873
13873
|
if (event === EVENTS.UNLINK) {
|
|
13874
|
-
this._pendingUnlinks.set(
|
|
13874
|
+
this._pendingUnlinks.set(path31, [event, ...args]);
|
|
13875
13875
|
setTimeout(() => {
|
|
13876
|
-
this._pendingUnlinks.forEach((entry,
|
|
13876
|
+
this._pendingUnlinks.forEach((entry, path32) => {
|
|
13877
13877
|
this.emit(...entry);
|
|
13878
13878
|
this.emit(EVENTS.ALL, ...entry);
|
|
13879
|
-
this._pendingUnlinks.delete(
|
|
13879
|
+
this._pendingUnlinks.delete(path32);
|
|
13880
13880
|
});
|
|
13881
13881
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
13882
13882
|
return this;
|
|
13883
13883
|
}
|
|
13884
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
13884
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path31)) {
|
|
13885
13885
|
event = EVENTS.CHANGE;
|
|
13886
|
-
this._pendingUnlinks.delete(
|
|
13886
|
+
this._pendingUnlinks.delete(path31);
|
|
13887
13887
|
}
|
|
13888
13888
|
}
|
|
13889
13889
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -13901,16 +13901,16 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
13901
13901
|
this.emitWithAll(event, args);
|
|
13902
13902
|
}
|
|
13903
13903
|
};
|
|
13904
|
-
this._awaitWriteFinish(
|
|
13904
|
+
this._awaitWriteFinish(path31, awf.stabilityThreshold, event, awfEmit);
|
|
13905
13905
|
return this;
|
|
13906
13906
|
}
|
|
13907
13907
|
if (event === EVENTS.CHANGE) {
|
|
13908
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
13908
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path31, 50);
|
|
13909
13909
|
if (isThrottled)
|
|
13910
13910
|
return this;
|
|
13911
13911
|
}
|
|
13912
13912
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
13913
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
13913
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path31) : path31;
|
|
13914
13914
|
let stats2;
|
|
13915
13915
|
try {
|
|
13916
13916
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -13941,23 +13941,23 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
13941
13941
|
* @param timeout duration of time to suppress duplicate actions
|
|
13942
13942
|
* @returns tracking object or false if action should be suppressed
|
|
13943
13943
|
*/
|
|
13944
|
-
_throttle(actionType,
|
|
13944
|
+
_throttle(actionType, path31, timeout) {
|
|
13945
13945
|
if (!this._throttled.has(actionType)) {
|
|
13946
13946
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
13947
13947
|
}
|
|
13948
13948
|
const action = this._throttled.get(actionType);
|
|
13949
13949
|
if (!action)
|
|
13950
13950
|
throw new Error("invalid throttle");
|
|
13951
|
-
const actionPath = action.get(
|
|
13951
|
+
const actionPath = action.get(path31);
|
|
13952
13952
|
if (actionPath) {
|
|
13953
13953
|
actionPath.count++;
|
|
13954
13954
|
return false;
|
|
13955
13955
|
}
|
|
13956
13956
|
let timeoutObject;
|
|
13957
13957
|
const clear = () => {
|
|
13958
|
-
const item = action.get(
|
|
13958
|
+
const item = action.get(path31);
|
|
13959
13959
|
const count = item ? item.count : 0;
|
|
13960
|
-
action.delete(
|
|
13960
|
+
action.delete(path31);
|
|
13961
13961
|
clearTimeout(timeoutObject);
|
|
13962
13962
|
if (item)
|
|
13963
13963
|
clearTimeout(item.timeoutObject);
|
|
@@ -13965,7 +13965,7 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
13965
13965
|
};
|
|
13966
13966
|
timeoutObject = setTimeout(clear, timeout);
|
|
13967
13967
|
const thr = { timeoutObject, clear, count: 0 };
|
|
13968
|
-
action.set(
|
|
13968
|
+
action.set(path31, thr);
|
|
13969
13969
|
return thr;
|
|
13970
13970
|
}
|
|
13971
13971
|
_incrReadyCount() {
|
|
@@ -13979,44 +13979,44 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
13979
13979
|
* @param event
|
|
13980
13980
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
13981
13981
|
*/
|
|
13982
|
-
_awaitWriteFinish(
|
|
13982
|
+
_awaitWriteFinish(path31, threshold, event, awfEmit) {
|
|
13983
13983
|
const awf = this.options.awaitWriteFinish;
|
|
13984
13984
|
if (typeof awf !== "object")
|
|
13985
13985
|
return;
|
|
13986
13986
|
const pollInterval = awf.pollInterval;
|
|
13987
13987
|
let timeoutHandler;
|
|
13988
|
-
let fullPath =
|
|
13989
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
13990
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
13988
|
+
let fullPath = path31;
|
|
13989
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path31)) {
|
|
13990
|
+
fullPath = sysPath2.join(this.options.cwd, path31);
|
|
13991
13991
|
}
|
|
13992
13992
|
const now = /* @__PURE__ */ new Date();
|
|
13993
13993
|
const writes = this._pendingWrites;
|
|
13994
13994
|
function awaitWriteFinishFn(prevStat) {
|
|
13995
13995
|
(0, import_fs17.stat)(fullPath, (err, curStat) => {
|
|
13996
|
-
if (err || !writes.has(
|
|
13996
|
+
if (err || !writes.has(path31)) {
|
|
13997
13997
|
if (err && err.code !== "ENOENT")
|
|
13998
13998
|
awfEmit(err);
|
|
13999
13999
|
return;
|
|
14000
14000
|
}
|
|
14001
14001
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
14002
14002
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
14003
|
-
writes.get(
|
|
14003
|
+
writes.get(path31).lastChange = now2;
|
|
14004
14004
|
}
|
|
14005
|
-
const pw = writes.get(
|
|
14005
|
+
const pw = writes.get(path31);
|
|
14006
14006
|
const df = now2 - pw.lastChange;
|
|
14007
14007
|
if (df >= threshold) {
|
|
14008
|
-
writes.delete(
|
|
14008
|
+
writes.delete(path31);
|
|
14009
14009
|
awfEmit(void 0, curStat);
|
|
14010
14010
|
} else {
|
|
14011
14011
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
14012
14012
|
}
|
|
14013
14013
|
});
|
|
14014
14014
|
}
|
|
14015
|
-
if (!writes.has(
|
|
14016
|
-
writes.set(
|
|
14015
|
+
if (!writes.has(path31)) {
|
|
14016
|
+
writes.set(path31, {
|
|
14017
14017
|
lastChange: now,
|
|
14018
14018
|
cancelWait: () => {
|
|
14019
|
-
writes.delete(
|
|
14019
|
+
writes.delete(path31);
|
|
14020
14020
|
clearTimeout(timeoutHandler);
|
|
14021
14021
|
return event;
|
|
14022
14022
|
}
|
|
@@ -14027,8 +14027,8 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
14027
14027
|
/**
|
|
14028
14028
|
* Determines whether user has asked to ignore this path.
|
|
14029
14029
|
*/
|
|
14030
|
-
_isIgnored(
|
|
14031
|
-
if (this.options.atomic && DOT_RE.test(
|
|
14030
|
+
_isIgnored(path31, stats) {
|
|
14031
|
+
if (this.options.atomic && DOT_RE.test(path31))
|
|
14032
14032
|
return true;
|
|
14033
14033
|
if (!this._userIgnored) {
|
|
14034
14034
|
const { cwd } = this.options;
|
|
@@ -14038,17 +14038,17 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
14038
14038
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
14039
14039
|
this._userIgnored = anymatch(list, void 0);
|
|
14040
14040
|
}
|
|
14041
|
-
return this._userIgnored(
|
|
14041
|
+
return this._userIgnored(path31, stats);
|
|
14042
14042
|
}
|
|
14043
|
-
_isntIgnored(
|
|
14044
|
-
return !this._isIgnored(
|
|
14043
|
+
_isntIgnored(path31, stat4) {
|
|
14044
|
+
return !this._isIgnored(path31, stat4);
|
|
14045
14045
|
}
|
|
14046
14046
|
/**
|
|
14047
14047
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
14048
14048
|
* @param path file or directory pattern being watched
|
|
14049
14049
|
*/
|
|
14050
|
-
_getWatchHelpers(
|
|
14051
|
-
return new WatchHelper(
|
|
14050
|
+
_getWatchHelpers(path31) {
|
|
14051
|
+
return new WatchHelper(path31, this.options.followSymlinks, this);
|
|
14052
14052
|
}
|
|
14053
14053
|
// Directory helpers
|
|
14054
14054
|
// -----------------
|
|
@@ -14080,63 +14080,63 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
14080
14080
|
* @param item base path of item/directory
|
|
14081
14081
|
*/
|
|
14082
14082
|
_remove(directory, item, isDirectory) {
|
|
14083
|
-
const
|
|
14084
|
-
const fullPath = sysPath2.resolve(
|
|
14085
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
14086
|
-
if (!this._throttle("remove",
|
|
14083
|
+
const path31 = sysPath2.join(directory, item);
|
|
14084
|
+
const fullPath = sysPath2.resolve(path31);
|
|
14085
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path31) || this._watched.has(fullPath);
|
|
14086
|
+
if (!this._throttle("remove", path31, 100))
|
|
14087
14087
|
return;
|
|
14088
14088
|
if (!isDirectory && this._watched.size === 1) {
|
|
14089
14089
|
this.add(directory, item, true);
|
|
14090
14090
|
}
|
|
14091
|
-
const wp = this._getWatchedDir(
|
|
14091
|
+
const wp = this._getWatchedDir(path31);
|
|
14092
14092
|
const nestedDirectoryChildren = wp.getChildren();
|
|
14093
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
14093
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path31, nested));
|
|
14094
14094
|
const parent = this._getWatchedDir(directory);
|
|
14095
14095
|
const wasTracked = parent.has(item);
|
|
14096
14096
|
parent.remove(item);
|
|
14097
14097
|
if (this._symlinkPaths.has(fullPath)) {
|
|
14098
14098
|
this._symlinkPaths.delete(fullPath);
|
|
14099
14099
|
}
|
|
14100
|
-
let relPath =
|
|
14100
|
+
let relPath = path31;
|
|
14101
14101
|
if (this.options.cwd)
|
|
14102
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
14102
|
+
relPath = sysPath2.relative(this.options.cwd, path31);
|
|
14103
14103
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
14104
14104
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
14105
14105
|
if (event === EVENTS.ADD)
|
|
14106
14106
|
return;
|
|
14107
14107
|
}
|
|
14108
|
-
this._watched.delete(
|
|
14108
|
+
this._watched.delete(path31);
|
|
14109
14109
|
this._watched.delete(fullPath);
|
|
14110
14110
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
14111
|
-
if (wasTracked && !this._isIgnored(
|
|
14112
|
-
this._emit(eventName,
|
|
14113
|
-
this._closePath(
|
|
14111
|
+
if (wasTracked && !this._isIgnored(path31))
|
|
14112
|
+
this._emit(eventName, path31);
|
|
14113
|
+
this._closePath(path31);
|
|
14114
14114
|
}
|
|
14115
14115
|
/**
|
|
14116
14116
|
* Closes all watchers for a path
|
|
14117
14117
|
*/
|
|
14118
|
-
_closePath(
|
|
14119
|
-
this._closeFile(
|
|
14120
|
-
const dir = sysPath2.dirname(
|
|
14121
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
14118
|
+
_closePath(path31) {
|
|
14119
|
+
this._closeFile(path31);
|
|
14120
|
+
const dir = sysPath2.dirname(path31);
|
|
14121
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path31));
|
|
14122
14122
|
}
|
|
14123
14123
|
/**
|
|
14124
14124
|
* Closes only file-specific watchers
|
|
14125
14125
|
*/
|
|
14126
|
-
_closeFile(
|
|
14127
|
-
const closers = this._closers.get(
|
|
14126
|
+
_closeFile(path31) {
|
|
14127
|
+
const closers = this._closers.get(path31);
|
|
14128
14128
|
if (!closers)
|
|
14129
14129
|
return;
|
|
14130
14130
|
closers.forEach((closer) => closer());
|
|
14131
|
-
this._closers.delete(
|
|
14131
|
+
this._closers.delete(path31);
|
|
14132
14132
|
}
|
|
14133
|
-
_addPathCloser(
|
|
14133
|
+
_addPathCloser(path31, closer) {
|
|
14134
14134
|
if (!closer)
|
|
14135
14135
|
return;
|
|
14136
|
-
let list = this._closers.get(
|
|
14136
|
+
let list = this._closers.get(path31);
|
|
14137
14137
|
if (!list) {
|
|
14138
14138
|
list = [];
|
|
14139
|
-
this._closers.set(
|
|
14139
|
+
this._closers.set(path31, list);
|
|
14140
14140
|
}
|
|
14141
14141
|
list.push(closer);
|
|
14142
14142
|
}
|
|
@@ -14822,12 +14822,12 @@ var DEFAULT_IGNORED_PATHS = [
|
|
|
14822
14822
|
/^\/sockjs-node/
|
|
14823
14823
|
// Hot reload websocket
|
|
14824
14824
|
];
|
|
14825
|
-
function shouldIgnorePath(
|
|
14825
|
+
function shouldIgnorePath(path31, ignoredPaths) {
|
|
14826
14826
|
return ignoredPaths.some((pattern) => {
|
|
14827
14827
|
if (typeof pattern === "string") {
|
|
14828
|
-
return
|
|
14828
|
+
return path31 === pattern || path31.startsWith(pattern);
|
|
14829
14829
|
}
|
|
14830
|
-
return pattern.test(
|
|
14830
|
+
return pattern.test(path31);
|
|
14831
14831
|
});
|
|
14832
14832
|
}
|
|
14833
14833
|
function requestLoggerMiddleware(options = {}) {
|
|
@@ -14986,11 +14986,11 @@ function createStrictRateLimiterFromConfig(config) {
|
|
|
14986
14986
|
}
|
|
14987
14987
|
|
|
14988
14988
|
// modules/server/middleware/auto-rate-limit.ts
|
|
14989
|
-
function matchesStrictPattern(
|
|
14989
|
+
function matchesStrictPattern(path31, patterns) {
|
|
14990
14990
|
for (const pattern of patterns) {
|
|
14991
14991
|
const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
|
|
14992
14992
|
const regex = new RegExp(`^${regexPattern}$`);
|
|
14993
|
-
if (regex.test(
|
|
14993
|
+
if (regex.test(path31)) {
|
|
14994
14994
|
return true;
|
|
14995
14995
|
}
|
|
14996
14996
|
}
|
|
@@ -15689,25 +15689,89 @@ function handleNotFound(res, urlPath) {
|
|
|
15689
15689
|
}
|
|
15690
15690
|
}
|
|
15691
15691
|
|
|
15692
|
-
// modules/server/
|
|
15693
|
-
var import_fs20 = __toESM(require("fs"));
|
|
15692
|
+
// modules/server/global-middleware.ts
|
|
15694
15693
|
var import_path24 = __toESM(require("path"));
|
|
15694
|
+
var import_fs20 = __toESM(require("fs"));
|
|
15695
|
+
var cachedGlobalMiddlewares = null;
|
|
15696
|
+
async function loadGlobalMiddlewares(projectRoot) {
|
|
15697
|
+
if (cachedGlobalMiddlewares !== null) {
|
|
15698
|
+
return cachedGlobalMiddlewares;
|
|
15699
|
+
}
|
|
15700
|
+
const globalMiddlewareFile = import_path24.default.join(projectRoot, "global.middleware.ts");
|
|
15701
|
+
const globalMiddlewareFileJs = import_path24.default.join(projectRoot, "global.middleware.js");
|
|
15702
|
+
const file = import_fs20.default.existsSync(globalMiddlewareFile) ? globalMiddlewareFile : import_fs20.default.existsSync(globalMiddlewareFileJs) ? globalMiddlewareFileJs : null;
|
|
15703
|
+
if (!file) {
|
|
15704
|
+
cachedGlobalMiddlewares = [];
|
|
15705
|
+
return cachedGlobalMiddlewares;
|
|
15706
|
+
}
|
|
15707
|
+
if (file.endsWith(".ts") || file.endsWith(".tsx")) {
|
|
15708
|
+
try {
|
|
15709
|
+
require("tsx/cjs");
|
|
15710
|
+
} catch (e) {
|
|
15711
|
+
}
|
|
15712
|
+
}
|
|
15713
|
+
try {
|
|
15714
|
+
const mod = require(file);
|
|
15715
|
+
const middlewares = mod?.globalMiddlewares;
|
|
15716
|
+
if (Array.isArray(middlewares)) {
|
|
15717
|
+
const validMiddlewares = [];
|
|
15718
|
+
for (let i = 0; i < middlewares.length; i++) {
|
|
15719
|
+
const mw = middlewares[i];
|
|
15720
|
+
if (typeof mw === "function") {
|
|
15721
|
+
validMiddlewares.push(mw);
|
|
15722
|
+
} else {
|
|
15723
|
+
console.warn(
|
|
15724
|
+
`[framework][global-middleware] Middleware at index ${i} in global.middleware.ts is not a function, skipping`
|
|
15725
|
+
);
|
|
15726
|
+
}
|
|
15727
|
+
}
|
|
15728
|
+
cachedGlobalMiddlewares = validMiddlewares;
|
|
15729
|
+
return cachedGlobalMiddlewares;
|
|
15730
|
+
} else if (middlewares !== void 0) {
|
|
15731
|
+
console.warn(
|
|
15732
|
+
"[framework][global-middleware] globalMiddlewares must be an array in global.middleware.ts, ignoring invalid value"
|
|
15733
|
+
);
|
|
15734
|
+
}
|
|
15735
|
+
} catch (error) {
|
|
15736
|
+
console.error("[framework][global-middleware] Error loading global.middleware.ts:", error);
|
|
15737
|
+
}
|
|
15738
|
+
cachedGlobalMiddlewares = [];
|
|
15739
|
+
return cachedGlobalMiddlewares;
|
|
15740
|
+
}
|
|
15741
|
+
async function runGlobalMiddlewares(ctx, globalMiddlewares) {
|
|
15742
|
+
for (const mw of globalMiddlewares) {
|
|
15743
|
+
try {
|
|
15744
|
+
await Promise.resolve(mw(ctx, async () => {
|
|
15745
|
+
}));
|
|
15746
|
+
} catch (error) {
|
|
15747
|
+
console.error("[framework][global-middleware] Error in global middleware:", error);
|
|
15748
|
+
continue;
|
|
15749
|
+
}
|
|
15750
|
+
if (ctx.res.headersSent) {
|
|
15751
|
+
return;
|
|
15752
|
+
}
|
|
15753
|
+
}
|
|
15754
|
+
}
|
|
15755
|
+
|
|
15756
|
+
// modules/server/handlers/ssg.ts
|
|
15757
|
+
var import_fs21 = __toESM(require("fs"));
|
|
15758
|
+
var import_path25 = __toESM(require("path"));
|
|
15695
15759
|
var logger3 = createModuleLogger("ssg");
|
|
15696
15760
|
function getSsgDirForPath(baseDir, urlPath) {
|
|
15697
15761
|
const clean = urlPath === "/" ? "" : urlPath.replace(/^\/+/, "");
|
|
15698
|
-
return
|
|
15762
|
+
return import_path25.default.join(baseDir, clean);
|
|
15699
15763
|
}
|
|
15700
15764
|
function getSsgHtmlPath(baseDir, urlPath) {
|
|
15701
15765
|
const dir = getSsgDirForPath(baseDir, urlPath);
|
|
15702
|
-
return
|
|
15766
|
+
return import_path25.default.join(dir, "index.html");
|
|
15703
15767
|
}
|
|
15704
15768
|
function getSsgDataPath(baseDir, urlPath) {
|
|
15705
15769
|
const dir = getSsgDirForPath(baseDir, urlPath);
|
|
15706
|
-
return
|
|
15770
|
+
return import_path25.default.join(dir, "data.json");
|
|
15707
15771
|
}
|
|
15708
15772
|
function tryServeSsgHtml(res, ssgOutDir, urlPath) {
|
|
15709
15773
|
const ssgHtmlPath = getSsgHtmlPath(ssgOutDir, urlPath);
|
|
15710
|
-
if (!
|
|
15774
|
+
if (!import_fs21.default.existsSync(ssgHtmlPath)) {
|
|
15711
15775
|
return false;
|
|
15712
15776
|
}
|
|
15713
15777
|
logger3.info("Serving SSG HTML", { urlPath, ssgHtmlPath });
|
|
@@ -15717,17 +15781,17 @@ function tryServeSsgHtml(res, ssgOutDir, urlPath) {
|
|
|
15717
15781
|
);
|
|
15718
15782
|
res.statusCode = 200;
|
|
15719
15783
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
15720
|
-
const stream =
|
|
15784
|
+
const stream = import_fs21.default.createReadStream(ssgHtmlPath, { encoding: "utf-8" });
|
|
15721
15785
|
stream.pipe(res);
|
|
15722
15786
|
return true;
|
|
15723
15787
|
}
|
|
15724
15788
|
function tryServeSsgData(res, ssgOutDir, urlPath) {
|
|
15725
15789
|
const ssgDataPath = getSsgDataPath(ssgOutDir, urlPath);
|
|
15726
|
-
if (!
|
|
15790
|
+
if (!import_fs21.default.existsSync(ssgDataPath)) {
|
|
15727
15791
|
return false;
|
|
15728
15792
|
}
|
|
15729
15793
|
try {
|
|
15730
|
-
const raw =
|
|
15794
|
+
const raw = import_fs21.default.readFileSync(ssgDataPath, "utf-8");
|
|
15731
15795
|
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
15732
15796
|
res.status(200).end(raw);
|
|
15733
15797
|
return true;
|
|
@@ -15739,7 +15803,7 @@ function tryServeSsgData(res, ssgOutDir, urlPath) {
|
|
|
15739
15803
|
|
|
15740
15804
|
// modules/server/handlers/pages.ts
|
|
15741
15805
|
init_globals();
|
|
15742
|
-
var
|
|
15806
|
+
var import_path26 = __toESM(require("path"));
|
|
15743
15807
|
function mergeMetadata(base, override) {
|
|
15744
15808
|
if (!base && !override) return null;
|
|
15745
15809
|
if (!base) return override;
|
|
@@ -15797,7 +15861,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
|
|
|
15797
15861
|
} catch (error) {
|
|
15798
15862
|
const reqLogger = getRequestLogger(req);
|
|
15799
15863
|
const layoutFile = notFoundPage.layoutFiles[i];
|
|
15800
|
-
const relativeLayoutPath = layoutFile ?
|
|
15864
|
+
const relativeLayoutPath = layoutFile ? import_path26.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
15801
15865
|
reqLogger.error("Layout middleware failed for not-found page", error instanceof Error ? error : new Error(String(error)), {
|
|
15802
15866
|
layoutIndex: i,
|
|
15803
15867
|
layoutFile: relativeLayoutPath
|
|
@@ -15826,7 +15890,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
|
|
|
15826
15890
|
} catch (error) {
|
|
15827
15891
|
const reqLogger = getRequestLogger(req);
|
|
15828
15892
|
const layoutFile = notFoundPage.layoutFiles[i];
|
|
15829
|
-
const relativeLayoutPath = layoutFile ?
|
|
15893
|
+
const relativeLayoutPath = layoutFile ? import_path26.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
15830
15894
|
reqLogger.warn("Layout server hook failed for not-found page", {
|
|
15831
15895
|
error: error instanceof Error ? error.message : String(error),
|
|
15832
15896
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -16063,6 +16127,11 @@ async function handlePageRequestInternal(options) {
|
|
|
16063
16127
|
Redirect: (destination, permanent = false) => new RedirectResponse(destination, permanent),
|
|
16064
16128
|
NotFound: () => new NotFoundResponse()
|
|
16065
16129
|
};
|
|
16130
|
+
const globalMiddlewares = await loadGlobalMiddlewares(projectRoot || process.cwd());
|
|
16131
|
+
await runGlobalMiddlewares(ctx, globalMiddlewares);
|
|
16132
|
+
if (res.headersSent) {
|
|
16133
|
+
return;
|
|
16134
|
+
}
|
|
16066
16135
|
await runRouteMiddlewares(route, ctx);
|
|
16067
16136
|
if (res.headersSent) {
|
|
16068
16137
|
return;
|
|
@@ -16083,7 +16152,7 @@ async function handlePageRequestInternal(options) {
|
|
|
16083
16152
|
);
|
|
16084
16153
|
} catch (error) {
|
|
16085
16154
|
const layoutFile = route.layoutFiles[i];
|
|
16086
|
-
const relativeLayoutPath = layoutFile ?
|
|
16155
|
+
const relativeLayoutPath = layoutFile ? import_path26.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16087
16156
|
reqLogger.error("Layout middleware failed", error instanceof Error ? error : new Error(String(error)), {
|
|
16088
16157
|
route: route.pattern,
|
|
16089
16158
|
layoutIndex: i,
|
|
@@ -16149,7 +16218,7 @@ async function handlePageRequestInternal(options) {
|
|
|
16149
16218
|
}
|
|
16150
16219
|
} catch (error) {
|
|
16151
16220
|
const layoutFile = route.layoutFiles[i];
|
|
16152
|
-
const relativeLayoutPath = layoutFile ?
|
|
16221
|
+
const relativeLayoutPath = layoutFile ? import_path26.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16153
16222
|
reqLogger.warn("Layout server hook failed", {
|
|
16154
16223
|
error: error instanceof Error ? error.message : String(error),
|
|
16155
16224
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -16212,7 +16281,7 @@ async function handlePageRequestInternal(options) {
|
|
|
16212
16281
|
pageLoaderResult2.theme = theme;
|
|
16213
16282
|
}
|
|
16214
16283
|
} catch (error) {
|
|
16215
|
-
const relativePagePath = route.pageFile ?
|
|
16284
|
+
const relativePagePath = route.pageFile ? import_path26.default.relative(projectRoot || process.cwd(), route.pageFile) : "unknown";
|
|
16216
16285
|
reqLogger.error("Page server hook failed", {
|
|
16217
16286
|
error: error instanceof Error ? error.message : String(error),
|
|
16218
16287
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -16382,7 +16451,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
16382
16451
|
);
|
|
16383
16452
|
} catch (error2) {
|
|
16384
16453
|
const layoutFile = errorPage.layoutFiles[i];
|
|
16385
|
-
const relativeLayoutPath = layoutFile ?
|
|
16454
|
+
const relativeLayoutPath = layoutFile ? import_path26.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16386
16455
|
reqLogger.error("Layout middleware failed for error page", error2 instanceof Error ? error2 : new Error(String(error2)), {
|
|
16387
16456
|
layoutIndex: i,
|
|
16388
16457
|
layoutFile: relativeLayoutPath
|
|
@@ -16422,7 +16491,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
16422
16491
|
}
|
|
16423
16492
|
} catch (err) {
|
|
16424
16493
|
const layoutFile = errorPage.layoutFiles[i];
|
|
16425
|
-
const relativeLayoutPath = layoutFile ?
|
|
16494
|
+
const relativeLayoutPath = layoutFile ? import_path26.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16426
16495
|
reqLogger.warn("Layout server hook failed for error page", {
|
|
16427
16496
|
error: err instanceof Error ? err.message : String(err),
|
|
16428
16497
|
stack: err instanceof Error ? err.stack : void 0,
|
|
@@ -16745,7 +16814,7 @@ function validateRealtimeConfig(config) {
|
|
|
16745
16814
|
}
|
|
16746
16815
|
|
|
16747
16816
|
// modules/server/routes.ts
|
|
16748
|
-
var
|
|
16817
|
+
var import_path27 = __toESM(require("path"));
|
|
16749
16818
|
var cachedRewriteLoader = null;
|
|
16750
16819
|
var cachedProjectRoot = null;
|
|
16751
16820
|
var cachedIsDev = null;
|
|
@@ -16773,8 +16842,8 @@ function setupRoutes(options) {
|
|
|
16773
16842
|
} = options;
|
|
16774
16843
|
const routeChunks = routeLoader.loadRouteChunks();
|
|
16775
16844
|
const rewriteLoader = getRewriteLoader(projectRoot, isDev);
|
|
16776
|
-
const ssgOutDir =
|
|
16777
|
-
config ? getBuildDir(projectRoot, config) :
|
|
16845
|
+
const ssgOutDir = import_path27.default.join(
|
|
16846
|
+
config ? getBuildDir(projectRoot, config) : import_path27.default.join(projectRoot, BUILD_FOLDER_NAME),
|
|
16778
16847
|
"ssg"
|
|
16779
16848
|
);
|
|
16780
16849
|
app.all("/api/*", async (req, res) => {
|
|
@@ -18003,8 +18072,8 @@ var setupApplication = async ({
|
|
|
18003
18072
|
|
|
18004
18073
|
// src/server.ts
|
|
18005
18074
|
var import_dotenv2 = __toESM(require("dotenv"));
|
|
18006
|
-
var envPath =
|
|
18007
|
-
if (
|
|
18075
|
+
var envPath = import_path28.default.join(process.cwd(), ".env");
|
|
18076
|
+
if (import_fs22.default.existsSync(envPath)) {
|
|
18008
18077
|
import_dotenv2.default.config({ path: envPath });
|
|
18009
18078
|
} else {
|
|
18010
18079
|
import_dotenv2.default.config();
|
|
@@ -18025,8 +18094,8 @@ async function startServer(options = {}) {
|
|
|
18025
18094
|
}
|
|
18026
18095
|
const port = options.port ?? (process.env.PORT ? parseInt(process.env.PORT, 10) : void 0) ?? config.server.port;
|
|
18027
18096
|
const host = process.env.HOST ?? (!isDev ? "0.0.0.0" : void 0) ?? config.server.host;
|
|
18028
|
-
const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) :
|
|
18029
|
-
if (!isDev && !
|
|
18097
|
+
const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) : import_path28.default.join(getBuildDir(projectRoot, config), "server"));
|
|
18098
|
+
if (!isDev && !import_fs22.default.existsSync(appDir)) {
|
|
18030
18099
|
logger4.error("Compiled directory not found", void 0, {
|
|
18031
18100
|
buildDir: config.directories.build,
|
|
18032
18101
|
appDir,
|
|
@@ -18097,10 +18166,10 @@ async function startProdServer(options = {}) {
|
|
|
18097
18166
|
}
|
|
18098
18167
|
|
|
18099
18168
|
// modules/build/ssg/builder.ts
|
|
18100
|
-
var
|
|
18169
|
+
var import_path32 = __toESM(require("path"));
|
|
18101
18170
|
|
|
18102
18171
|
// modules/build/ssg/path.ts
|
|
18103
|
-
var
|
|
18172
|
+
var import_path29 = __toESM(require("path"));
|
|
18104
18173
|
function buildPathFromPattern(pattern, params) {
|
|
18105
18174
|
const segments = pattern.split("/").filter(Boolean);
|
|
18106
18175
|
const parts = [];
|
|
@@ -18129,12 +18198,12 @@ function buildPathFromPattern(pattern, params) {
|
|
|
18129
18198
|
}
|
|
18130
18199
|
function pathToOutDir(baseDir, urlPath) {
|
|
18131
18200
|
const clean = urlPath === "/" ? "" : urlPath.replace(/^\/+/, "");
|
|
18132
|
-
return
|
|
18201
|
+
return import_path29.default.join(baseDir, clean);
|
|
18133
18202
|
}
|
|
18134
18203
|
|
|
18135
18204
|
// modules/build/ssg/renderer.ts
|
|
18136
|
-
var
|
|
18137
|
-
var
|
|
18205
|
+
var import_fs23 = __toESM(require("fs"));
|
|
18206
|
+
var import_path30 = __toESM(require("path"));
|
|
18138
18207
|
var import_server3 = require("react-dom/server");
|
|
18139
18208
|
init_globals();
|
|
18140
18209
|
async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params, config) {
|
|
@@ -18270,16 +18339,16 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params,
|
|
|
18270
18339
|
const html = "<!DOCTYPE html>" + (0, import_server3.renderToString)(documentTree);
|
|
18271
18340
|
const dir = pathToOutDir(ssgOutDir, urlPath);
|
|
18272
18341
|
ensureDir(dir);
|
|
18273
|
-
const htmlFile =
|
|
18274
|
-
const dataFile =
|
|
18275
|
-
|
|
18276
|
-
|
|
18342
|
+
const htmlFile = import_path30.default.join(dir, "index.html");
|
|
18343
|
+
const dataFile = import_path30.default.join(dir, "data.json");
|
|
18344
|
+
import_fs23.default.writeFileSync(htmlFile, html, "utf-8");
|
|
18345
|
+
import_fs23.default.writeFileSync(dataFile, JSON.stringify(initialData, null, 2), "utf-8");
|
|
18277
18346
|
}
|
|
18278
18347
|
|
|
18279
18348
|
// modules/build/ssg/builder.ts
|
|
18280
18349
|
init_globals();
|
|
18281
18350
|
async function buildStaticPages(projectRoot, routes, config) {
|
|
18282
|
-
const ssgOutDir =
|
|
18351
|
+
const ssgOutDir = import_path32.default.join(projectRoot, BUILD_FOLDER_NAME, "ssg");
|
|
18283
18352
|
ensureDir(ssgOutDir);
|
|
18284
18353
|
for (const route of routes) {
|
|
18285
18354
|
if (route.dynamic !== "force-static") continue;
|
|
@@ -18334,36 +18403,36 @@ async function buildStaticPages(projectRoot, routes, config) {
|
|
|
18334
18403
|
}
|
|
18335
18404
|
|
|
18336
18405
|
// modules/build/bundler/server.ts
|
|
18337
|
-
var
|
|
18338
|
-
var
|
|
18406
|
+
var import_path34 = __toESM(require("path"));
|
|
18407
|
+
var import_fs24 = __toESM(require("fs"));
|
|
18339
18408
|
var import_esbuild = __toESM(require("esbuild"));
|
|
18340
18409
|
init_globals();
|
|
18341
18410
|
var SERVER_FILES = [INIT_FILE_NAME, CONFIG_FILE_NAME];
|
|
18342
18411
|
function createPathAliasPlugin(projectRoot, outDir) {
|
|
18343
18412
|
const aliases = loadAliasesFromTsconfig(projectRoot);
|
|
18344
|
-
const tsconfigPath =
|
|
18413
|
+
const tsconfigPath = import_path34.default.join(projectRoot, "tsconfig.json");
|
|
18345
18414
|
let baseUrl = ".";
|
|
18346
|
-
if (
|
|
18415
|
+
if (import_fs24.default.existsSync(tsconfigPath)) {
|
|
18347
18416
|
try {
|
|
18348
|
-
const tsconfig = JSON.parse(
|
|
18417
|
+
const tsconfig = JSON.parse(import_fs24.default.readFileSync(tsconfigPath, "utf-8"));
|
|
18349
18418
|
baseUrl = tsconfig.compilerOptions?.baseUrl ?? ".";
|
|
18350
18419
|
} catch {
|
|
18351
18420
|
}
|
|
18352
18421
|
}
|
|
18353
18422
|
function resolveAliasToRelative(importPath, sourceFile) {
|
|
18354
|
-
if (importPath.startsWith(".") || importPath.startsWith("/") ||
|
|
18423
|
+
if (importPath.startsWith(".") || importPath.startsWith("/") || import_path34.default.isAbsolute(importPath) || importPath.includes("node_modules")) {
|
|
18355
18424
|
return null;
|
|
18356
18425
|
}
|
|
18357
18426
|
for (const [aliasKey, aliasPath] of Object.entries(aliases)) {
|
|
18358
18427
|
if (importPath.startsWith(aliasKey + "/") || importPath === aliasKey) {
|
|
18359
18428
|
const restPath = importPath.startsWith(aliasKey + "/") ? importPath.slice(aliasKey.length + 1) : "";
|
|
18360
|
-
const resolvedPath = restPath ?
|
|
18429
|
+
const resolvedPath = restPath ? import_path34.default.join(aliasPath, restPath) : aliasPath;
|
|
18361
18430
|
let actualPath = null;
|
|
18362
18431
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
|
|
18363
|
-
if (
|
|
18432
|
+
if (import_fs24.default.existsSync(resolvedPath) && import_fs24.default.statSync(resolvedPath).isDirectory()) {
|
|
18364
18433
|
for (const ext of extensions) {
|
|
18365
|
-
const indexPath =
|
|
18366
|
-
if (
|
|
18434
|
+
const indexPath = import_path34.default.join(resolvedPath, `index${ext}`);
|
|
18435
|
+
if (import_fs24.default.existsSync(indexPath)) {
|
|
18367
18436
|
actualPath = indexPath;
|
|
18368
18437
|
break;
|
|
18369
18438
|
}
|
|
@@ -18371,20 +18440,20 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18371
18440
|
} else {
|
|
18372
18441
|
for (const ext of extensions) {
|
|
18373
18442
|
const filePath = resolvedPath + ext;
|
|
18374
|
-
if (
|
|
18443
|
+
if (import_fs24.default.existsSync(filePath)) {
|
|
18375
18444
|
actualPath = filePath;
|
|
18376
18445
|
break;
|
|
18377
18446
|
}
|
|
18378
18447
|
}
|
|
18379
|
-
if (!actualPath &&
|
|
18448
|
+
if (!actualPath && import_fs24.default.existsSync(resolvedPath)) {
|
|
18380
18449
|
actualPath = resolvedPath;
|
|
18381
18450
|
}
|
|
18382
18451
|
}
|
|
18383
18452
|
if (actualPath) {
|
|
18384
|
-
const relativePath =
|
|
18453
|
+
const relativePath = import_path34.default.relative(outDir, actualPath);
|
|
18385
18454
|
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
18386
18455
|
const finalPath = normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
|
|
18387
|
-
const ext =
|
|
18456
|
+
const ext = import_path34.default.extname(finalPath);
|
|
18388
18457
|
const pathWithoutExt = ext === ".json" ? finalPath : finalPath.slice(0, -ext.length);
|
|
18389
18458
|
return pathWithoutExt;
|
|
18390
18459
|
}
|
|
@@ -18396,13 +18465,13 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18396
18465
|
name: "path-alias-resolver",
|
|
18397
18466
|
setup(build) {
|
|
18398
18467
|
build.onLoad({ filter: /\.(ts|tsx|js|jsx)$/ }, (args) => {
|
|
18399
|
-
const fileName =
|
|
18468
|
+
const fileName = import_path34.default.basename(args.path);
|
|
18400
18469
|
const isServerFile = SERVER_FILES.some((f) => fileName === `${f}.ts` || fileName === `${f}.tsx` || fileName === `${f}.js` || fileName === `${f}.jsx`);
|
|
18401
|
-
const isInProjectRoot =
|
|
18470
|
+
const isInProjectRoot = import_path34.default.dirname(args.path) === projectRoot;
|
|
18402
18471
|
if (!isServerFile || !isInProjectRoot) {
|
|
18403
18472
|
return null;
|
|
18404
18473
|
}
|
|
18405
|
-
const contents =
|
|
18474
|
+
const contents = import_fs24.default.readFileSync(args.path, "utf-8");
|
|
18406
18475
|
let transformed = contents;
|
|
18407
18476
|
const aliasPatterns = Object.keys(aliases).sort((a, b) => b.length - a.length);
|
|
18408
18477
|
for (const aliasKey of aliasPatterns) {
|
|
@@ -18422,7 +18491,7 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18422
18491
|
}
|
|
18423
18492
|
return {
|
|
18424
18493
|
contents: transformed,
|
|
18425
|
-
loader:
|
|
18494
|
+
loader: import_path34.default.extname(args.path).slice(1)
|
|
18426
18495
|
};
|
|
18427
18496
|
});
|
|
18428
18497
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
@@ -18441,9 +18510,9 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18441
18510
|
function collectAppSources(appDir) {
|
|
18442
18511
|
const entries = [];
|
|
18443
18512
|
function walk(dir) {
|
|
18444
|
-
const items =
|
|
18513
|
+
const items = import_fs24.default.readdirSync(dir, { withFileTypes: true });
|
|
18445
18514
|
for (const item of items) {
|
|
18446
|
-
const full =
|
|
18515
|
+
const full = import_path34.default.join(dir, item.name);
|
|
18447
18516
|
if (item.isDirectory()) {
|
|
18448
18517
|
walk(full);
|
|
18449
18518
|
continue;
|
|
@@ -18460,7 +18529,7 @@ function collectAppSources(appDir) {
|
|
|
18460
18529
|
return entries;
|
|
18461
18530
|
}
|
|
18462
18531
|
async function buildServerApp(projectRoot, appDir) {
|
|
18463
|
-
const outDir =
|
|
18532
|
+
const outDir = import_path34.default.join(projectRoot, BUILD_FOLDER_NAME, "server");
|
|
18464
18533
|
const entryPoints = collectAppSources(appDir);
|
|
18465
18534
|
ensureDir(outDir);
|
|
18466
18535
|
if (entryPoints.length === 0) {
|
|
@@ -18478,14 +18547,14 @@ async function buildServerApp(projectRoot, appDir) {
|
|
|
18478
18547
|
bundle: true,
|
|
18479
18548
|
splitting: false,
|
|
18480
18549
|
logLevel: "info",
|
|
18481
|
-
tsconfig:
|
|
18550
|
+
tsconfig: import_path34.default.join(projectRoot, "tsconfig.json"),
|
|
18482
18551
|
packages: "external"
|
|
18483
18552
|
});
|
|
18484
18553
|
const pathAliasPlugin = createPathAliasPlugin(projectRoot, outDir);
|
|
18485
18554
|
for (const fileName of SERVER_FILES) {
|
|
18486
|
-
const initTS =
|
|
18487
|
-
const initJS =
|
|
18488
|
-
if (
|
|
18555
|
+
const initTS = import_path34.default.join(projectRoot, `${fileName}.ts`);
|
|
18556
|
+
const initJS = import_path34.default.join(outDir, `${fileName}.js`);
|
|
18557
|
+
if (import_fs24.default.existsSync(initTS)) {
|
|
18489
18558
|
await import_esbuild.default.build({
|
|
18490
18559
|
entryPoints: [initTS],
|
|
18491
18560
|
outfile: initJS,
|
|
@@ -18496,7 +18565,7 @@ async function buildServerApp(projectRoot, appDir) {
|
|
|
18496
18565
|
sourcemap: true,
|
|
18497
18566
|
bundle: false,
|
|
18498
18567
|
logLevel: "info",
|
|
18499
|
-
tsconfig:
|
|
18568
|
+
tsconfig: import_path34.default.join(projectRoot, "tsconfig.json"),
|
|
18500
18569
|
plugins: [pathAliasPlugin]
|
|
18501
18570
|
});
|
|
18502
18571
|
}
|
|
@@ -19783,11 +19852,11 @@ var ValidationError = class extends Error {
|
|
|
19783
19852
|
format() {
|
|
19784
19853
|
const formatted = {};
|
|
19785
19854
|
for (const error of this.errors) {
|
|
19786
|
-
const
|
|
19787
|
-
if (!formatted[
|
|
19788
|
-
formatted[
|
|
19855
|
+
const path31 = error.path.join(".");
|
|
19856
|
+
if (!formatted[path31]) {
|
|
19857
|
+
formatted[path31] = [];
|
|
19789
19858
|
}
|
|
19790
|
-
formatted[
|
|
19859
|
+
formatted[path31].push(error.message);
|
|
19791
19860
|
}
|
|
19792
19861
|
return formatted;
|
|
19793
19862
|
}
|