@lolyjs/core 0.2.0-alpha.32 → 0.2.0-alpha.34
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 +345 -248
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +339 -242
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +311 -214
- 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 +311 -214
- 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.js
CHANGED
|
@@ -9871,8 +9871,8 @@ var require_built3 = __commonJS({
|
|
|
9871
9871
|
});
|
|
9872
9872
|
|
|
9873
9873
|
// src/server.ts
|
|
9874
|
-
import
|
|
9875
|
-
import
|
|
9874
|
+
import fs20 from "fs";
|
|
9875
|
+
import path26 from "path";
|
|
9876
9876
|
|
|
9877
9877
|
// modules/server/utils/server-dir.ts
|
|
9878
9878
|
init_globals();
|
|
@@ -10455,7 +10455,7 @@ function matchApiRoute(routes, pathname) {
|
|
|
10455
10455
|
if (!match) continue;
|
|
10456
10456
|
const params = {};
|
|
10457
10457
|
r.paramNames.forEach((name, idx) => {
|
|
10458
|
-
params[name] = match[idx + 1];
|
|
10458
|
+
params[name] = decodeURIComponent(match[idx + 1] || "");
|
|
10459
10459
|
});
|
|
10460
10460
|
return { route: r, params };
|
|
10461
10461
|
}
|
|
@@ -12515,7 +12515,7 @@ var ReaddirpStream = class extends Readable {
|
|
|
12515
12515
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
12516
12516
|
const statMethod = opts.lstat ? lstat : stat;
|
|
12517
12517
|
if (wantBigintFsStats) {
|
|
12518
|
-
this._stat = (
|
|
12518
|
+
this._stat = (path31) => statMethod(path31, { bigint: true });
|
|
12519
12519
|
} else {
|
|
12520
12520
|
this._stat = statMethod;
|
|
12521
12521
|
}
|
|
@@ -12540,8 +12540,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
12540
12540
|
const par = this.parent;
|
|
12541
12541
|
const fil = par && par.files;
|
|
12542
12542
|
if (fil && fil.length > 0) {
|
|
12543
|
-
const { path:
|
|
12544
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
12543
|
+
const { path: path31, depth } = par;
|
|
12544
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path31));
|
|
12545
12545
|
const awaited = await Promise.all(slice);
|
|
12546
12546
|
for (const entry of awaited) {
|
|
12547
12547
|
if (!entry)
|
|
@@ -12581,20 +12581,20 @@ var ReaddirpStream = class extends Readable {
|
|
|
12581
12581
|
this.reading = false;
|
|
12582
12582
|
}
|
|
12583
12583
|
}
|
|
12584
|
-
async _exploreDir(
|
|
12584
|
+
async _exploreDir(path31, depth) {
|
|
12585
12585
|
let files;
|
|
12586
12586
|
try {
|
|
12587
|
-
files = await readdir(
|
|
12587
|
+
files = await readdir(path31, this._rdOptions);
|
|
12588
12588
|
} catch (error) {
|
|
12589
12589
|
this._onError(error);
|
|
12590
12590
|
}
|
|
12591
|
-
return { files, depth, path:
|
|
12591
|
+
return { files, depth, path: path31 };
|
|
12592
12592
|
}
|
|
12593
|
-
async _formatEntry(dirent,
|
|
12593
|
+
async _formatEntry(dirent, path31) {
|
|
12594
12594
|
let entry;
|
|
12595
12595
|
const basename3 = this._isDirent ? dirent.name : dirent;
|
|
12596
12596
|
try {
|
|
12597
|
-
const fullPath = presolve(pjoin(
|
|
12597
|
+
const fullPath = presolve(pjoin(path31, basename3));
|
|
12598
12598
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename3 };
|
|
12599
12599
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
12600
12600
|
} catch (err) {
|
|
@@ -12994,16 +12994,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
12994
12994
|
};
|
|
12995
12995
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
12996
12996
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
12997
|
-
function createFsWatchInstance(
|
|
12997
|
+
function createFsWatchInstance(path31, options, listener, errHandler, emitRaw) {
|
|
12998
12998
|
const handleEvent = (rawEvent, evPath) => {
|
|
12999
|
-
listener(
|
|
13000
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
13001
|
-
if (evPath &&
|
|
13002
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
12999
|
+
listener(path31);
|
|
13000
|
+
emitRaw(rawEvent, evPath, { watchedPath: path31 });
|
|
13001
|
+
if (evPath && path31 !== evPath) {
|
|
13002
|
+
fsWatchBroadcast(sysPath.resolve(path31, evPath), KEY_LISTENERS, sysPath.join(path31, evPath));
|
|
13003
13003
|
}
|
|
13004
13004
|
};
|
|
13005
13005
|
try {
|
|
13006
|
-
return fs_watch(
|
|
13006
|
+
return fs_watch(path31, {
|
|
13007
13007
|
persistent: options.persistent
|
|
13008
13008
|
}, handleEvent);
|
|
13009
13009
|
} catch (error) {
|
|
@@ -13019,12 +13019,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
13019
13019
|
listener(val1, val2, val3);
|
|
13020
13020
|
});
|
|
13021
13021
|
};
|
|
13022
|
-
var setFsWatchListener = (
|
|
13022
|
+
var setFsWatchListener = (path31, fullPath, options, handlers) => {
|
|
13023
13023
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
13024
13024
|
let cont = FsWatchInstances.get(fullPath);
|
|
13025
13025
|
let watcher;
|
|
13026
13026
|
if (!options.persistent) {
|
|
13027
|
-
watcher = createFsWatchInstance(
|
|
13027
|
+
watcher = createFsWatchInstance(path31, options, listener, errHandler, rawEmitter);
|
|
13028
13028
|
if (!watcher)
|
|
13029
13029
|
return;
|
|
13030
13030
|
return watcher.close.bind(watcher);
|
|
@@ -13035,7 +13035,7 @@ var setFsWatchListener = (path30, fullPath, options, handlers) => {
|
|
|
13035
13035
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
13036
13036
|
} else {
|
|
13037
13037
|
watcher = createFsWatchInstance(
|
|
13038
|
-
|
|
13038
|
+
path31,
|
|
13039
13039
|
options,
|
|
13040
13040
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
13041
13041
|
errHandler,
|
|
@@ -13050,7 +13050,7 @@ var setFsWatchListener = (path30, fullPath, options, handlers) => {
|
|
|
13050
13050
|
cont.watcherUnusable = true;
|
|
13051
13051
|
if (isWindows && error.code === "EPERM") {
|
|
13052
13052
|
try {
|
|
13053
|
-
const fd = await open(
|
|
13053
|
+
const fd = await open(path31, "r");
|
|
13054
13054
|
await fd.close();
|
|
13055
13055
|
broadcastErr(error);
|
|
13056
13056
|
} catch (err) {
|
|
@@ -13081,7 +13081,7 @@ var setFsWatchListener = (path30, fullPath, options, handlers) => {
|
|
|
13081
13081
|
};
|
|
13082
13082
|
};
|
|
13083
13083
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
13084
|
-
var setFsWatchFileListener = (
|
|
13084
|
+
var setFsWatchFileListener = (path31, fullPath, options, handlers) => {
|
|
13085
13085
|
const { listener, rawEmitter } = handlers;
|
|
13086
13086
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
13087
13087
|
const copts = cont && cont.options;
|
|
@@ -13103,7 +13103,7 @@ var setFsWatchFileListener = (path30, fullPath, options, handlers) => {
|
|
|
13103
13103
|
});
|
|
13104
13104
|
const currmtime = curr.mtimeMs;
|
|
13105
13105
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
13106
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
13106
|
+
foreach(cont.listeners, (listener2) => listener2(path31, curr));
|
|
13107
13107
|
}
|
|
13108
13108
|
})
|
|
13109
13109
|
};
|
|
@@ -13131,13 +13131,13 @@ var NodeFsHandler = class {
|
|
|
13131
13131
|
* @param listener on fs change
|
|
13132
13132
|
* @returns closer for the watcher instance
|
|
13133
13133
|
*/
|
|
13134
|
-
_watchWithNodeFs(
|
|
13134
|
+
_watchWithNodeFs(path31, listener) {
|
|
13135
13135
|
const opts = this.fsw.options;
|
|
13136
|
-
const directory = sysPath.dirname(
|
|
13137
|
-
const basename3 = sysPath.basename(
|
|
13136
|
+
const directory = sysPath.dirname(path31);
|
|
13137
|
+
const basename3 = sysPath.basename(path31);
|
|
13138
13138
|
const parent = this.fsw._getWatchedDir(directory);
|
|
13139
13139
|
parent.add(basename3);
|
|
13140
|
-
const absolutePath = sysPath.resolve(
|
|
13140
|
+
const absolutePath = sysPath.resolve(path31);
|
|
13141
13141
|
const options = {
|
|
13142
13142
|
persistent: opts.persistent
|
|
13143
13143
|
};
|
|
@@ -13147,12 +13147,12 @@ var NodeFsHandler = class {
|
|
|
13147
13147
|
if (opts.usePolling) {
|
|
13148
13148
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
13149
13149
|
options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
|
|
13150
|
-
closer = setFsWatchFileListener(
|
|
13150
|
+
closer = setFsWatchFileListener(path31, absolutePath, options, {
|
|
13151
13151
|
listener,
|
|
13152
13152
|
rawEmitter: this.fsw._emitRaw
|
|
13153
13153
|
});
|
|
13154
13154
|
} else {
|
|
13155
|
-
closer = setFsWatchListener(
|
|
13155
|
+
closer = setFsWatchListener(path31, absolutePath, options, {
|
|
13156
13156
|
listener,
|
|
13157
13157
|
errHandler: this._boundHandleError,
|
|
13158
13158
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -13174,7 +13174,7 @@ var NodeFsHandler = class {
|
|
|
13174
13174
|
let prevStats = stats;
|
|
13175
13175
|
if (parent.has(basename3))
|
|
13176
13176
|
return;
|
|
13177
|
-
const listener = async (
|
|
13177
|
+
const listener = async (path31, newStats) => {
|
|
13178
13178
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
13179
13179
|
return;
|
|
13180
13180
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -13188,11 +13188,11 @@ var NodeFsHandler = class {
|
|
|
13188
13188
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
13189
13189
|
}
|
|
13190
13190
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
13191
|
-
this.fsw._closeFile(
|
|
13191
|
+
this.fsw._closeFile(path31);
|
|
13192
13192
|
prevStats = newStats2;
|
|
13193
13193
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
13194
13194
|
if (closer2)
|
|
13195
|
-
this.fsw._addPathCloser(
|
|
13195
|
+
this.fsw._addPathCloser(path31, closer2);
|
|
13196
13196
|
} else {
|
|
13197
13197
|
prevStats = newStats2;
|
|
13198
13198
|
}
|
|
@@ -13224,7 +13224,7 @@ var NodeFsHandler = class {
|
|
|
13224
13224
|
* @param item basename of this item
|
|
13225
13225
|
* @returns true if no more processing is needed for this entry.
|
|
13226
13226
|
*/
|
|
13227
|
-
async _handleSymlink(entry, directory,
|
|
13227
|
+
async _handleSymlink(entry, directory, path31, item) {
|
|
13228
13228
|
if (this.fsw.closed) {
|
|
13229
13229
|
return;
|
|
13230
13230
|
}
|
|
@@ -13234,7 +13234,7 @@ var NodeFsHandler = class {
|
|
|
13234
13234
|
this.fsw._incrReadyCount();
|
|
13235
13235
|
let linkPath;
|
|
13236
13236
|
try {
|
|
13237
|
-
linkPath = await fsrealpath(
|
|
13237
|
+
linkPath = await fsrealpath(path31);
|
|
13238
13238
|
} catch (e) {
|
|
13239
13239
|
this.fsw._emitReady();
|
|
13240
13240
|
return true;
|
|
@@ -13244,12 +13244,12 @@ var NodeFsHandler = class {
|
|
|
13244
13244
|
if (dir.has(item)) {
|
|
13245
13245
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
13246
13246
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
13247
|
-
this.fsw._emit(EV.CHANGE,
|
|
13247
|
+
this.fsw._emit(EV.CHANGE, path31, entry.stats);
|
|
13248
13248
|
}
|
|
13249
13249
|
} else {
|
|
13250
13250
|
dir.add(item);
|
|
13251
13251
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
13252
|
-
this.fsw._emit(EV.ADD,
|
|
13252
|
+
this.fsw._emit(EV.ADD, path31, entry.stats);
|
|
13253
13253
|
}
|
|
13254
13254
|
this.fsw._emitReady();
|
|
13255
13255
|
return true;
|
|
@@ -13278,9 +13278,9 @@ var NodeFsHandler = class {
|
|
|
13278
13278
|
return;
|
|
13279
13279
|
}
|
|
13280
13280
|
const item = entry.path;
|
|
13281
|
-
let
|
|
13281
|
+
let path31 = sysPath.join(directory, item);
|
|
13282
13282
|
current.add(item);
|
|
13283
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
13283
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path31, item)) {
|
|
13284
13284
|
return;
|
|
13285
13285
|
}
|
|
13286
13286
|
if (this.fsw.closed) {
|
|
@@ -13289,8 +13289,8 @@ var NodeFsHandler = class {
|
|
|
13289
13289
|
}
|
|
13290
13290
|
if (item === target || !target && !previous.has(item)) {
|
|
13291
13291
|
this.fsw._incrReadyCount();
|
|
13292
|
-
|
|
13293
|
-
this._addToNodeFs(
|
|
13292
|
+
path31 = sysPath.join(dir, sysPath.relative(dir, path31));
|
|
13293
|
+
this._addToNodeFs(path31, initialAdd, wh, depth + 1);
|
|
13294
13294
|
}
|
|
13295
13295
|
}).on(EV.ERROR, this._boundHandleError);
|
|
13296
13296
|
return new Promise((resolve3, reject) => {
|
|
@@ -13359,13 +13359,13 @@ var NodeFsHandler = class {
|
|
|
13359
13359
|
* @param depth Child path actually targeted for watch
|
|
13360
13360
|
* @param target Child path actually targeted for watch
|
|
13361
13361
|
*/
|
|
13362
|
-
async _addToNodeFs(
|
|
13362
|
+
async _addToNodeFs(path31, initialAdd, priorWh, depth, target) {
|
|
13363
13363
|
const ready = this.fsw._emitReady;
|
|
13364
|
-
if (this.fsw._isIgnored(
|
|
13364
|
+
if (this.fsw._isIgnored(path31) || this.fsw.closed) {
|
|
13365
13365
|
ready();
|
|
13366
13366
|
return false;
|
|
13367
13367
|
}
|
|
13368
|
-
const wh = this.fsw._getWatchHelpers(
|
|
13368
|
+
const wh = this.fsw._getWatchHelpers(path31);
|
|
13369
13369
|
if (priorWh) {
|
|
13370
13370
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
13371
13371
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -13381,8 +13381,8 @@ var NodeFsHandler = class {
|
|
|
13381
13381
|
const follow = this.fsw.options.followSymlinks;
|
|
13382
13382
|
let closer;
|
|
13383
13383
|
if (stats.isDirectory()) {
|
|
13384
|
-
const absPath = sysPath.resolve(
|
|
13385
|
-
const targetPath = follow ? await fsrealpath(
|
|
13384
|
+
const absPath = sysPath.resolve(path31);
|
|
13385
|
+
const targetPath = follow ? await fsrealpath(path31) : path31;
|
|
13386
13386
|
if (this.fsw.closed)
|
|
13387
13387
|
return;
|
|
13388
13388
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -13392,29 +13392,29 @@ var NodeFsHandler = class {
|
|
|
13392
13392
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
13393
13393
|
}
|
|
13394
13394
|
} else if (stats.isSymbolicLink()) {
|
|
13395
|
-
const targetPath = follow ? await fsrealpath(
|
|
13395
|
+
const targetPath = follow ? await fsrealpath(path31) : path31;
|
|
13396
13396
|
if (this.fsw.closed)
|
|
13397
13397
|
return;
|
|
13398
13398
|
const parent = sysPath.dirname(wh.watchPath);
|
|
13399
13399
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
13400
13400
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
13401
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
13401
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path31, wh, targetPath);
|
|
13402
13402
|
if (this.fsw.closed)
|
|
13403
13403
|
return;
|
|
13404
13404
|
if (targetPath !== void 0) {
|
|
13405
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
13405
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path31), targetPath);
|
|
13406
13406
|
}
|
|
13407
13407
|
} else {
|
|
13408
13408
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
13409
13409
|
}
|
|
13410
13410
|
ready();
|
|
13411
13411
|
if (closer)
|
|
13412
|
-
this.fsw._addPathCloser(
|
|
13412
|
+
this.fsw._addPathCloser(path31, closer);
|
|
13413
13413
|
return false;
|
|
13414
13414
|
} catch (error) {
|
|
13415
13415
|
if (this.fsw._handleError(error)) {
|
|
13416
13416
|
ready();
|
|
13417
|
-
return
|
|
13417
|
+
return path31;
|
|
13418
13418
|
}
|
|
13419
13419
|
}
|
|
13420
13420
|
}
|
|
@@ -13457,26 +13457,26 @@ function createPattern(matcher) {
|
|
|
13457
13457
|
}
|
|
13458
13458
|
return () => false;
|
|
13459
13459
|
}
|
|
13460
|
-
function normalizePath(
|
|
13461
|
-
if (typeof
|
|
13460
|
+
function normalizePath(path31) {
|
|
13461
|
+
if (typeof path31 !== "string")
|
|
13462
13462
|
throw new Error("string expected");
|
|
13463
|
-
|
|
13464
|
-
|
|
13463
|
+
path31 = sysPath2.normalize(path31);
|
|
13464
|
+
path31 = path31.replace(/\\/g, "/");
|
|
13465
13465
|
let prepend = false;
|
|
13466
|
-
if (
|
|
13466
|
+
if (path31.startsWith("//"))
|
|
13467
13467
|
prepend = true;
|
|
13468
13468
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
13469
|
-
while (
|
|
13470
|
-
|
|
13469
|
+
while (path31.match(DOUBLE_SLASH_RE2))
|
|
13470
|
+
path31 = path31.replace(DOUBLE_SLASH_RE2, "/");
|
|
13471
13471
|
if (prepend)
|
|
13472
|
-
|
|
13473
|
-
return
|
|
13472
|
+
path31 = "/" + path31;
|
|
13473
|
+
return path31;
|
|
13474
13474
|
}
|
|
13475
13475
|
function matchPatterns(patterns, testString, stats) {
|
|
13476
|
-
const
|
|
13476
|
+
const path31 = normalizePath(testString);
|
|
13477
13477
|
for (let index = 0; index < patterns.length; index++) {
|
|
13478
13478
|
const pattern = patterns[index];
|
|
13479
|
-
if (pattern(
|
|
13479
|
+
if (pattern(path31, stats)) {
|
|
13480
13480
|
return true;
|
|
13481
13481
|
}
|
|
13482
13482
|
}
|
|
@@ -13516,19 +13516,19 @@ var toUnix = (string) => {
|
|
|
13516
13516
|
}
|
|
13517
13517
|
return str;
|
|
13518
13518
|
};
|
|
13519
|
-
var normalizePathToUnix = (
|
|
13520
|
-
var normalizeIgnored = (cwd = "") => (
|
|
13521
|
-
if (typeof
|
|
13522
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
13519
|
+
var normalizePathToUnix = (path31) => toUnix(sysPath2.normalize(toUnix(path31)));
|
|
13520
|
+
var normalizeIgnored = (cwd = "") => (path31) => {
|
|
13521
|
+
if (typeof path31 === "string") {
|
|
13522
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path31) ? path31 : sysPath2.join(cwd, path31));
|
|
13523
13523
|
} else {
|
|
13524
|
-
return
|
|
13524
|
+
return path31;
|
|
13525
13525
|
}
|
|
13526
13526
|
};
|
|
13527
|
-
var getAbsolutePath = (
|
|
13528
|
-
if (sysPath2.isAbsolute(
|
|
13529
|
-
return
|
|
13527
|
+
var getAbsolutePath = (path31, cwd) => {
|
|
13528
|
+
if (sysPath2.isAbsolute(path31)) {
|
|
13529
|
+
return path31;
|
|
13530
13530
|
}
|
|
13531
|
-
return sysPath2.join(cwd,
|
|
13531
|
+
return sysPath2.join(cwd, path31);
|
|
13532
13532
|
};
|
|
13533
13533
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
13534
13534
|
var DirEntry = class {
|
|
@@ -13583,10 +13583,10 @@ var DirEntry = class {
|
|
|
13583
13583
|
var STAT_METHOD_F = "stat";
|
|
13584
13584
|
var STAT_METHOD_L = "lstat";
|
|
13585
13585
|
var WatchHelper = class {
|
|
13586
|
-
constructor(
|
|
13586
|
+
constructor(path31, follow, fsw) {
|
|
13587
13587
|
this.fsw = fsw;
|
|
13588
|
-
const watchPath =
|
|
13589
|
-
this.path =
|
|
13588
|
+
const watchPath = path31;
|
|
13589
|
+
this.path = path31 = path31.replace(REPLACER_RE, "");
|
|
13590
13590
|
this.watchPath = watchPath;
|
|
13591
13591
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
13592
13592
|
this.dirParts = [];
|
|
@@ -13708,20 +13708,20 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13708
13708
|
this._closePromise = void 0;
|
|
13709
13709
|
let paths = unifyPaths(paths_);
|
|
13710
13710
|
if (cwd) {
|
|
13711
|
-
paths = paths.map((
|
|
13712
|
-
const absPath = getAbsolutePath(
|
|
13711
|
+
paths = paths.map((path31) => {
|
|
13712
|
+
const absPath = getAbsolutePath(path31, cwd);
|
|
13713
13713
|
return absPath;
|
|
13714
13714
|
});
|
|
13715
13715
|
}
|
|
13716
|
-
paths.forEach((
|
|
13717
|
-
this._removeIgnoredPath(
|
|
13716
|
+
paths.forEach((path31) => {
|
|
13717
|
+
this._removeIgnoredPath(path31);
|
|
13718
13718
|
});
|
|
13719
13719
|
this._userIgnored = void 0;
|
|
13720
13720
|
if (!this._readyCount)
|
|
13721
13721
|
this._readyCount = 0;
|
|
13722
13722
|
this._readyCount += paths.length;
|
|
13723
|
-
Promise.all(paths.map(async (
|
|
13724
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
13723
|
+
Promise.all(paths.map(async (path31) => {
|
|
13724
|
+
const res = await this._nodeFsHandler._addToNodeFs(path31, !_internal, void 0, 0, _origAdd);
|
|
13725
13725
|
if (res)
|
|
13726
13726
|
this._emitReady();
|
|
13727
13727
|
return res;
|
|
@@ -13743,17 +13743,17 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13743
13743
|
return this;
|
|
13744
13744
|
const paths = unifyPaths(paths_);
|
|
13745
13745
|
const { cwd } = this.options;
|
|
13746
|
-
paths.forEach((
|
|
13747
|
-
if (!sysPath2.isAbsolute(
|
|
13746
|
+
paths.forEach((path31) => {
|
|
13747
|
+
if (!sysPath2.isAbsolute(path31) && !this._closers.has(path31)) {
|
|
13748
13748
|
if (cwd)
|
|
13749
|
-
|
|
13750
|
-
|
|
13749
|
+
path31 = sysPath2.join(cwd, path31);
|
|
13750
|
+
path31 = sysPath2.resolve(path31);
|
|
13751
13751
|
}
|
|
13752
|
-
this._closePath(
|
|
13753
|
-
this._addIgnoredPath(
|
|
13754
|
-
if (this._watched.has(
|
|
13752
|
+
this._closePath(path31);
|
|
13753
|
+
this._addIgnoredPath(path31);
|
|
13754
|
+
if (this._watched.has(path31)) {
|
|
13755
13755
|
this._addIgnoredPath({
|
|
13756
|
-
path:
|
|
13756
|
+
path: path31,
|
|
13757
13757
|
recursive: true
|
|
13758
13758
|
});
|
|
13759
13759
|
}
|
|
@@ -13817,38 +13817,38 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13817
13817
|
* @param stats arguments to be passed with event
|
|
13818
13818
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
13819
13819
|
*/
|
|
13820
|
-
async _emit(event,
|
|
13820
|
+
async _emit(event, path31, stats) {
|
|
13821
13821
|
if (this.closed)
|
|
13822
13822
|
return;
|
|
13823
13823
|
const opts = this.options;
|
|
13824
13824
|
if (isWindows)
|
|
13825
|
-
|
|
13825
|
+
path31 = sysPath2.normalize(path31);
|
|
13826
13826
|
if (opts.cwd)
|
|
13827
|
-
|
|
13828
|
-
const args = [
|
|
13827
|
+
path31 = sysPath2.relative(opts.cwd, path31);
|
|
13828
|
+
const args = [path31];
|
|
13829
13829
|
if (stats != null)
|
|
13830
13830
|
args.push(stats);
|
|
13831
13831
|
const awf = opts.awaitWriteFinish;
|
|
13832
13832
|
let pw;
|
|
13833
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
13833
|
+
if (awf && (pw = this._pendingWrites.get(path31))) {
|
|
13834
13834
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
13835
13835
|
return this;
|
|
13836
13836
|
}
|
|
13837
13837
|
if (opts.atomic) {
|
|
13838
13838
|
if (event === EVENTS.UNLINK) {
|
|
13839
|
-
this._pendingUnlinks.set(
|
|
13839
|
+
this._pendingUnlinks.set(path31, [event, ...args]);
|
|
13840
13840
|
setTimeout(() => {
|
|
13841
|
-
this._pendingUnlinks.forEach((entry,
|
|
13841
|
+
this._pendingUnlinks.forEach((entry, path32) => {
|
|
13842
13842
|
this.emit(...entry);
|
|
13843
13843
|
this.emit(EVENTS.ALL, ...entry);
|
|
13844
|
-
this._pendingUnlinks.delete(
|
|
13844
|
+
this._pendingUnlinks.delete(path32);
|
|
13845
13845
|
});
|
|
13846
13846
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
13847
13847
|
return this;
|
|
13848
13848
|
}
|
|
13849
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
13849
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path31)) {
|
|
13850
13850
|
event = EVENTS.CHANGE;
|
|
13851
|
-
this._pendingUnlinks.delete(
|
|
13851
|
+
this._pendingUnlinks.delete(path31);
|
|
13852
13852
|
}
|
|
13853
13853
|
}
|
|
13854
13854
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -13866,16 +13866,16 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13866
13866
|
this.emitWithAll(event, args);
|
|
13867
13867
|
}
|
|
13868
13868
|
};
|
|
13869
|
-
this._awaitWriteFinish(
|
|
13869
|
+
this._awaitWriteFinish(path31, awf.stabilityThreshold, event, awfEmit);
|
|
13870
13870
|
return this;
|
|
13871
13871
|
}
|
|
13872
13872
|
if (event === EVENTS.CHANGE) {
|
|
13873
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
13873
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path31, 50);
|
|
13874
13874
|
if (isThrottled)
|
|
13875
13875
|
return this;
|
|
13876
13876
|
}
|
|
13877
13877
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
13878
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
13878
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path31) : path31;
|
|
13879
13879
|
let stats2;
|
|
13880
13880
|
try {
|
|
13881
13881
|
stats2 = await stat3(fullPath);
|
|
@@ -13906,23 +13906,23 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13906
13906
|
* @param timeout duration of time to suppress duplicate actions
|
|
13907
13907
|
* @returns tracking object or false if action should be suppressed
|
|
13908
13908
|
*/
|
|
13909
|
-
_throttle(actionType,
|
|
13909
|
+
_throttle(actionType, path31, timeout) {
|
|
13910
13910
|
if (!this._throttled.has(actionType)) {
|
|
13911
13911
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
13912
13912
|
}
|
|
13913
13913
|
const action = this._throttled.get(actionType);
|
|
13914
13914
|
if (!action)
|
|
13915
13915
|
throw new Error("invalid throttle");
|
|
13916
|
-
const actionPath = action.get(
|
|
13916
|
+
const actionPath = action.get(path31);
|
|
13917
13917
|
if (actionPath) {
|
|
13918
13918
|
actionPath.count++;
|
|
13919
13919
|
return false;
|
|
13920
13920
|
}
|
|
13921
13921
|
let timeoutObject;
|
|
13922
13922
|
const clear = () => {
|
|
13923
|
-
const item = action.get(
|
|
13923
|
+
const item = action.get(path31);
|
|
13924
13924
|
const count = item ? item.count : 0;
|
|
13925
|
-
action.delete(
|
|
13925
|
+
action.delete(path31);
|
|
13926
13926
|
clearTimeout(timeoutObject);
|
|
13927
13927
|
if (item)
|
|
13928
13928
|
clearTimeout(item.timeoutObject);
|
|
@@ -13930,7 +13930,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13930
13930
|
};
|
|
13931
13931
|
timeoutObject = setTimeout(clear, timeout);
|
|
13932
13932
|
const thr = { timeoutObject, clear, count: 0 };
|
|
13933
|
-
action.set(
|
|
13933
|
+
action.set(path31, thr);
|
|
13934
13934
|
return thr;
|
|
13935
13935
|
}
|
|
13936
13936
|
_incrReadyCount() {
|
|
@@ -13944,44 +13944,44 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13944
13944
|
* @param event
|
|
13945
13945
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
13946
13946
|
*/
|
|
13947
|
-
_awaitWriteFinish(
|
|
13947
|
+
_awaitWriteFinish(path31, threshold, event, awfEmit) {
|
|
13948
13948
|
const awf = this.options.awaitWriteFinish;
|
|
13949
13949
|
if (typeof awf !== "object")
|
|
13950
13950
|
return;
|
|
13951
13951
|
const pollInterval = awf.pollInterval;
|
|
13952
13952
|
let timeoutHandler;
|
|
13953
|
-
let fullPath =
|
|
13954
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
13955
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
13953
|
+
let fullPath = path31;
|
|
13954
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path31)) {
|
|
13955
|
+
fullPath = sysPath2.join(this.options.cwd, path31);
|
|
13956
13956
|
}
|
|
13957
13957
|
const now = /* @__PURE__ */ new Date();
|
|
13958
13958
|
const writes = this._pendingWrites;
|
|
13959
13959
|
function awaitWriteFinishFn(prevStat) {
|
|
13960
13960
|
statcb(fullPath, (err, curStat) => {
|
|
13961
|
-
if (err || !writes.has(
|
|
13961
|
+
if (err || !writes.has(path31)) {
|
|
13962
13962
|
if (err && err.code !== "ENOENT")
|
|
13963
13963
|
awfEmit(err);
|
|
13964
13964
|
return;
|
|
13965
13965
|
}
|
|
13966
13966
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
13967
13967
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
13968
|
-
writes.get(
|
|
13968
|
+
writes.get(path31).lastChange = now2;
|
|
13969
13969
|
}
|
|
13970
|
-
const pw = writes.get(
|
|
13970
|
+
const pw = writes.get(path31);
|
|
13971
13971
|
const df = now2 - pw.lastChange;
|
|
13972
13972
|
if (df >= threshold) {
|
|
13973
|
-
writes.delete(
|
|
13973
|
+
writes.delete(path31);
|
|
13974
13974
|
awfEmit(void 0, curStat);
|
|
13975
13975
|
} else {
|
|
13976
13976
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
13977
13977
|
}
|
|
13978
13978
|
});
|
|
13979
13979
|
}
|
|
13980
|
-
if (!writes.has(
|
|
13981
|
-
writes.set(
|
|
13980
|
+
if (!writes.has(path31)) {
|
|
13981
|
+
writes.set(path31, {
|
|
13982
13982
|
lastChange: now,
|
|
13983
13983
|
cancelWait: () => {
|
|
13984
|
-
writes.delete(
|
|
13984
|
+
writes.delete(path31);
|
|
13985
13985
|
clearTimeout(timeoutHandler);
|
|
13986
13986
|
return event;
|
|
13987
13987
|
}
|
|
@@ -13992,8 +13992,8 @@ var FSWatcher = class extends EventEmitter {
|
|
|
13992
13992
|
/**
|
|
13993
13993
|
* Determines whether user has asked to ignore this path.
|
|
13994
13994
|
*/
|
|
13995
|
-
_isIgnored(
|
|
13996
|
-
if (this.options.atomic && DOT_RE.test(
|
|
13995
|
+
_isIgnored(path31, stats) {
|
|
13996
|
+
if (this.options.atomic && DOT_RE.test(path31))
|
|
13997
13997
|
return true;
|
|
13998
13998
|
if (!this._userIgnored) {
|
|
13999
13999
|
const { cwd } = this.options;
|
|
@@ -14003,17 +14003,17 @@ var FSWatcher = class extends EventEmitter {
|
|
|
14003
14003
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
14004
14004
|
this._userIgnored = anymatch(list, void 0);
|
|
14005
14005
|
}
|
|
14006
|
-
return this._userIgnored(
|
|
14006
|
+
return this._userIgnored(path31, stats);
|
|
14007
14007
|
}
|
|
14008
|
-
_isntIgnored(
|
|
14009
|
-
return !this._isIgnored(
|
|
14008
|
+
_isntIgnored(path31, stat4) {
|
|
14009
|
+
return !this._isIgnored(path31, stat4);
|
|
14010
14010
|
}
|
|
14011
14011
|
/**
|
|
14012
14012
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
14013
14013
|
* @param path file or directory pattern being watched
|
|
14014
14014
|
*/
|
|
14015
|
-
_getWatchHelpers(
|
|
14016
|
-
return new WatchHelper(
|
|
14015
|
+
_getWatchHelpers(path31) {
|
|
14016
|
+
return new WatchHelper(path31, this.options.followSymlinks, this);
|
|
14017
14017
|
}
|
|
14018
14018
|
// Directory helpers
|
|
14019
14019
|
// -----------------
|
|
@@ -14045,63 +14045,63 @@ var FSWatcher = class extends EventEmitter {
|
|
|
14045
14045
|
* @param item base path of item/directory
|
|
14046
14046
|
*/
|
|
14047
14047
|
_remove(directory, item, isDirectory) {
|
|
14048
|
-
const
|
|
14049
|
-
const fullPath = sysPath2.resolve(
|
|
14050
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
14051
|
-
if (!this._throttle("remove",
|
|
14048
|
+
const path31 = sysPath2.join(directory, item);
|
|
14049
|
+
const fullPath = sysPath2.resolve(path31);
|
|
14050
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path31) || this._watched.has(fullPath);
|
|
14051
|
+
if (!this._throttle("remove", path31, 100))
|
|
14052
14052
|
return;
|
|
14053
14053
|
if (!isDirectory && this._watched.size === 1) {
|
|
14054
14054
|
this.add(directory, item, true);
|
|
14055
14055
|
}
|
|
14056
|
-
const wp = this._getWatchedDir(
|
|
14056
|
+
const wp = this._getWatchedDir(path31);
|
|
14057
14057
|
const nestedDirectoryChildren = wp.getChildren();
|
|
14058
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
14058
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path31, nested));
|
|
14059
14059
|
const parent = this._getWatchedDir(directory);
|
|
14060
14060
|
const wasTracked = parent.has(item);
|
|
14061
14061
|
parent.remove(item);
|
|
14062
14062
|
if (this._symlinkPaths.has(fullPath)) {
|
|
14063
14063
|
this._symlinkPaths.delete(fullPath);
|
|
14064
14064
|
}
|
|
14065
|
-
let relPath =
|
|
14065
|
+
let relPath = path31;
|
|
14066
14066
|
if (this.options.cwd)
|
|
14067
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
14067
|
+
relPath = sysPath2.relative(this.options.cwd, path31);
|
|
14068
14068
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
14069
14069
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
14070
14070
|
if (event === EVENTS.ADD)
|
|
14071
14071
|
return;
|
|
14072
14072
|
}
|
|
14073
|
-
this._watched.delete(
|
|
14073
|
+
this._watched.delete(path31);
|
|
14074
14074
|
this._watched.delete(fullPath);
|
|
14075
14075
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
14076
|
-
if (wasTracked && !this._isIgnored(
|
|
14077
|
-
this._emit(eventName,
|
|
14078
|
-
this._closePath(
|
|
14076
|
+
if (wasTracked && !this._isIgnored(path31))
|
|
14077
|
+
this._emit(eventName, path31);
|
|
14078
|
+
this._closePath(path31);
|
|
14079
14079
|
}
|
|
14080
14080
|
/**
|
|
14081
14081
|
* Closes all watchers for a path
|
|
14082
14082
|
*/
|
|
14083
|
-
_closePath(
|
|
14084
|
-
this._closeFile(
|
|
14085
|
-
const dir = sysPath2.dirname(
|
|
14086
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
14083
|
+
_closePath(path31) {
|
|
14084
|
+
this._closeFile(path31);
|
|
14085
|
+
const dir = sysPath2.dirname(path31);
|
|
14086
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path31));
|
|
14087
14087
|
}
|
|
14088
14088
|
/**
|
|
14089
14089
|
* Closes only file-specific watchers
|
|
14090
14090
|
*/
|
|
14091
|
-
_closeFile(
|
|
14092
|
-
const closers = this._closers.get(
|
|
14091
|
+
_closeFile(path31) {
|
|
14092
|
+
const closers = this._closers.get(path31);
|
|
14093
14093
|
if (!closers)
|
|
14094
14094
|
return;
|
|
14095
14095
|
closers.forEach((closer) => closer());
|
|
14096
|
-
this._closers.delete(
|
|
14096
|
+
this._closers.delete(path31);
|
|
14097
14097
|
}
|
|
14098
|
-
_addPathCloser(
|
|
14098
|
+
_addPathCloser(path31, closer) {
|
|
14099
14099
|
if (!closer)
|
|
14100
14100
|
return;
|
|
14101
|
-
let list = this._closers.get(
|
|
14101
|
+
let list = this._closers.get(path31);
|
|
14102
14102
|
if (!list) {
|
|
14103
14103
|
list = [];
|
|
14104
|
-
this._closers.set(
|
|
14104
|
+
this._closers.set(path31, list);
|
|
14105
14105
|
}
|
|
14106
14106
|
list.push(closer);
|
|
14107
14107
|
}
|
|
@@ -14787,12 +14787,12 @@ var DEFAULT_IGNORED_PATHS = [
|
|
|
14787
14787
|
/^\/sockjs-node/
|
|
14788
14788
|
// Hot reload websocket
|
|
14789
14789
|
];
|
|
14790
|
-
function shouldIgnorePath(
|
|
14790
|
+
function shouldIgnorePath(path31, ignoredPaths) {
|
|
14791
14791
|
return ignoredPaths.some((pattern) => {
|
|
14792
14792
|
if (typeof pattern === "string") {
|
|
14793
|
-
return
|
|
14793
|
+
return path31 === pattern || path31.startsWith(pattern);
|
|
14794
14794
|
}
|
|
14795
|
-
return pattern.test(
|
|
14795
|
+
return pattern.test(path31);
|
|
14796
14796
|
});
|
|
14797
14797
|
}
|
|
14798
14798
|
function requestLoggerMiddleware(options = {}) {
|
|
@@ -14951,11 +14951,11 @@ function createStrictRateLimiterFromConfig(config) {
|
|
|
14951
14951
|
}
|
|
14952
14952
|
|
|
14953
14953
|
// modules/server/middleware/auto-rate-limit.ts
|
|
14954
|
-
function matchesStrictPattern(
|
|
14954
|
+
function matchesStrictPattern(path31, patterns) {
|
|
14955
14955
|
for (const pattern of patterns) {
|
|
14956
14956
|
const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
|
|
14957
14957
|
const regex = new RegExp(`^${regexPattern}$`);
|
|
14958
|
-
if (regex.test(
|
|
14958
|
+
if (regex.test(path31)) {
|
|
14959
14959
|
return true;
|
|
14960
14960
|
}
|
|
14961
14961
|
}
|
|
@@ -14991,6 +14991,7 @@ function getAutoRateLimiter(route, strictPatterns = [], rateLimitConfig) {
|
|
|
14991
14991
|
// modules/server/handlers/api.ts
|
|
14992
14992
|
async function handleApiRequest(options) {
|
|
14993
14993
|
const { apiRoutes, urlPath, req, res, env = "dev", rewriteLoader } = options;
|
|
14994
|
+
const originalUrlPath = urlPath;
|
|
14994
14995
|
let finalUrlPath = urlPath;
|
|
14995
14996
|
let extractedParams = {};
|
|
14996
14997
|
if (rewriteLoader) {
|
|
@@ -15029,6 +15030,33 @@ async function handleApiRequest(options) {
|
|
|
15029
15030
|
}
|
|
15030
15031
|
const sanitizedParams = sanitizeParams(params);
|
|
15031
15032
|
const sanitizedQuery = sanitizeQuery(req.query);
|
|
15033
|
+
function reconstructPathFromParams(routePattern, params2) {
|
|
15034
|
+
let reconstructed = routePattern;
|
|
15035
|
+
for (const [key, value] of Object.entries(params2)) {
|
|
15036
|
+
const catchAllPattern = `[...${key}]`;
|
|
15037
|
+
if (reconstructed.includes(catchAllPattern)) {
|
|
15038
|
+
reconstructed = reconstructed.replace(catchAllPattern, value);
|
|
15039
|
+
} else {
|
|
15040
|
+
const normalPattern = `[${key}]`;
|
|
15041
|
+
if (reconstructed.includes(normalPattern)) {
|
|
15042
|
+
reconstructed = reconstructed.replace(normalPattern, value);
|
|
15043
|
+
}
|
|
15044
|
+
}
|
|
15045
|
+
}
|
|
15046
|
+
return reconstructed;
|
|
15047
|
+
}
|
|
15048
|
+
const reconstructedPath = reconstructPathFromParams(route.pattern, sanitizedParams);
|
|
15049
|
+
const queryString = req.url?.includes("?") ? req.url.split("?")[1] : "";
|
|
15050
|
+
const originalUrl = queryString ? `${reconstructedPath}?${queryString}` : reconstructedPath;
|
|
15051
|
+
if (!req.originalUrl) {
|
|
15052
|
+
req.originalUrl = originalUrl;
|
|
15053
|
+
}
|
|
15054
|
+
if (!req.params) {
|
|
15055
|
+
req.params = {};
|
|
15056
|
+
}
|
|
15057
|
+
for (const [key, value] of Object.entries(sanitizedParams)) {
|
|
15058
|
+
req.params[key] = value;
|
|
15059
|
+
}
|
|
15032
15060
|
const ctx = {
|
|
15033
15061
|
req,
|
|
15034
15062
|
res,
|
|
@@ -15654,25 +15682,89 @@ function handleNotFound(res, urlPath) {
|
|
|
15654
15682
|
}
|
|
15655
15683
|
}
|
|
15656
15684
|
|
|
15657
|
-
// modules/server/
|
|
15658
|
-
import fs18 from "fs";
|
|
15685
|
+
// modules/server/global-middleware.ts
|
|
15659
15686
|
import path22 from "path";
|
|
15687
|
+
import fs18 from "fs";
|
|
15688
|
+
var cachedGlobalMiddlewares = null;
|
|
15689
|
+
async function loadGlobalMiddlewares(projectRoot) {
|
|
15690
|
+
if (cachedGlobalMiddlewares !== null) {
|
|
15691
|
+
return cachedGlobalMiddlewares;
|
|
15692
|
+
}
|
|
15693
|
+
const globalMiddlewareFile = path22.join(projectRoot, "global.middleware.ts");
|
|
15694
|
+
const globalMiddlewareFileJs = path22.join(projectRoot, "global.middleware.js");
|
|
15695
|
+
const file = fs18.existsSync(globalMiddlewareFile) ? globalMiddlewareFile : fs18.existsSync(globalMiddlewareFileJs) ? globalMiddlewareFileJs : null;
|
|
15696
|
+
if (!file) {
|
|
15697
|
+
cachedGlobalMiddlewares = [];
|
|
15698
|
+
return cachedGlobalMiddlewares;
|
|
15699
|
+
}
|
|
15700
|
+
if (file.endsWith(".ts") || file.endsWith(".tsx")) {
|
|
15701
|
+
try {
|
|
15702
|
+
__require("tsx/cjs");
|
|
15703
|
+
} catch (e) {
|
|
15704
|
+
}
|
|
15705
|
+
}
|
|
15706
|
+
try {
|
|
15707
|
+
const mod = __require(file);
|
|
15708
|
+
const middlewares = mod?.globalMiddlewares;
|
|
15709
|
+
if (Array.isArray(middlewares)) {
|
|
15710
|
+
const validMiddlewares = [];
|
|
15711
|
+
for (let i = 0; i < middlewares.length; i++) {
|
|
15712
|
+
const mw = middlewares[i];
|
|
15713
|
+
if (typeof mw === "function") {
|
|
15714
|
+
validMiddlewares.push(mw);
|
|
15715
|
+
} else {
|
|
15716
|
+
console.warn(
|
|
15717
|
+
`[framework][global-middleware] Middleware at index ${i} in global.middleware.ts is not a function, skipping`
|
|
15718
|
+
);
|
|
15719
|
+
}
|
|
15720
|
+
}
|
|
15721
|
+
cachedGlobalMiddlewares = validMiddlewares;
|
|
15722
|
+
return cachedGlobalMiddlewares;
|
|
15723
|
+
} else if (middlewares !== void 0) {
|
|
15724
|
+
console.warn(
|
|
15725
|
+
"[framework][global-middleware] globalMiddlewares must be an array in global.middleware.ts, ignoring invalid value"
|
|
15726
|
+
);
|
|
15727
|
+
}
|
|
15728
|
+
} catch (error) {
|
|
15729
|
+
console.error("[framework][global-middleware] Error loading global.middleware.ts:", error);
|
|
15730
|
+
}
|
|
15731
|
+
cachedGlobalMiddlewares = [];
|
|
15732
|
+
return cachedGlobalMiddlewares;
|
|
15733
|
+
}
|
|
15734
|
+
async function runGlobalMiddlewares(ctx, globalMiddlewares) {
|
|
15735
|
+
for (const mw of globalMiddlewares) {
|
|
15736
|
+
try {
|
|
15737
|
+
await Promise.resolve(mw(ctx, async () => {
|
|
15738
|
+
}));
|
|
15739
|
+
} catch (error) {
|
|
15740
|
+
console.error("[framework][global-middleware] Error in global middleware:", error);
|
|
15741
|
+
continue;
|
|
15742
|
+
}
|
|
15743
|
+
if (ctx.res.headersSent) {
|
|
15744
|
+
return;
|
|
15745
|
+
}
|
|
15746
|
+
}
|
|
15747
|
+
}
|
|
15748
|
+
|
|
15749
|
+
// modules/server/handlers/ssg.ts
|
|
15750
|
+
import fs19 from "fs";
|
|
15751
|
+
import path23 from "path";
|
|
15660
15752
|
var logger3 = createModuleLogger("ssg");
|
|
15661
15753
|
function getSsgDirForPath(baseDir, urlPath) {
|
|
15662
15754
|
const clean = urlPath === "/" ? "" : urlPath.replace(/^\/+/, "");
|
|
15663
|
-
return
|
|
15755
|
+
return path23.join(baseDir, clean);
|
|
15664
15756
|
}
|
|
15665
15757
|
function getSsgHtmlPath(baseDir, urlPath) {
|
|
15666
15758
|
const dir = getSsgDirForPath(baseDir, urlPath);
|
|
15667
|
-
return
|
|
15759
|
+
return path23.join(dir, "index.html");
|
|
15668
15760
|
}
|
|
15669
15761
|
function getSsgDataPath(baseDir, urlPath) {
|
|
15670
15762
|
const dir = getSsgDirForPath(baseDir, urlPath);
|
|
15671
|
-
return
|
|
15763
|
+
return path23.join(dir, "data.json");
|
|
15672
15764
|
}
|
|
15673
15765
|
function tryServeSsgHtml(res, ssgOutDir, urlPath) {
|
|
15674
15766
|
const ssgHtmlPath = getSsgHtmlPath(ssgOutDir, urlPath);
|
|
15675
|
-
if (!
|
|
15767
|
+
if (!fs19.existsSync(ssgHtmlPath)) {
|
|
15676
15768
|
return false;
|
|
15677
15769
|
}
|
|
15678
15770
|
logger3.info("Serving SSG HTML", { urlPath, ssgHtmlPath });
|
|
@@ -15682,17 +15774,17 @@ function tryServeSsgHtml(res, ssgOutDir, urlPath) {
|
|
|
15682
15774
|
);
|
|
15683
15775
|
res.statusCode = 200;
|
|
15684
15776
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
15685
|
-
const stream =
|
|
15777
|
+
const stream = fs19.createReadStream(ssgHtmlPath, { encoding: "utf-8" });
|
|
15686
15778
|
stream.pipe(res);
|
|
15687
15779
|
return true;
|
|
15688
15780
|
}
|
|
15689
15781
|
function tryServeSsgData(res, ssgOutDir, urlPath) {
|
|
15690
15782
|
const ssgDataPath = getSsgDataPath(ssgOutDir, urlPath);
|
|
15691
|
-
if (!
|
|
15783
|
+
if (!fs19.existsSync(ssgDataPath)) {
|
|
15692
15784
|
return false;
|
|
15693
15785
|
}
|
|
15694
15786
|
try {
|
|
15695
|
-
const raw =
|
|
15787
|
+
const raw = fs19.readFileSync(ssgDataPath, "utf-8");
|
|
15696
15788
|
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
15697
15789
|
res.status(200).end(raw);
|
|
15698
15790
|
return true;
|
|
@@ -15704,7 +15796,7 @@ function tryServeSsgData(res, ssgOutDir, urlPath) {
|
|
|
15704
15796
|
|
|
15705
15797
|
// modules/server/handlers/pages.ts
|
|
15706
15798
|
init_globals();
|
|
15707
|
-
import
|
|
15799
|
+
import path24 from "path";
|
|
15708
15800
|
function mergeMetadata(base, override) {
|
|
15709
15801
|
if (!base && !override) return null;
|
|
15710
15802
|
if (!base) return override;
|
|
@@ -15762,7 +15854,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
|
|
|
15762
15854
|
} catch (error) {
|
|
15763
15855
|
const reqLogger = getRequestLogger(req);
|
|
15764
15856
|
const layoutFile = notFoundPage.layoutFiles[i];
|
|
15765
|
-
const relativeLayoutPath = layoutFile ?
|
|
15857
|
+
const relativeLayoutPath = layoutFile ? path24.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
15766
15858
|
reqLogger.error("Layout middleware failed for not-found page", error instanceof Error ? error : new Error(String(error)), {
|
|
15767
15859
|
layoutIndex: i,
|
|
15768
15860
|
layoutFile: relativeLayoutPath
|
|
@@ -15791,7 +15883,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
|
|
|
15791
15883
|
} catch (error) {
|
|
15792
15884
|
const reqLogger = getRequestLogger(req);
|
|
15793
15885
|
const layoutFile = notFoundPage.layoutFiles[i];
|
|
15794
|
-
const relativeLayoutPath = layoutFile ?
|
|
15886
|
+
const relativeLayoutPath = layoutFile ? path24.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
15795
15887
|
reqLogger.warn("Layout server hook failed for not-found page", {
|
|
15796
15888
|
error: error instanceof Error ? error.message : String(error),
|
|
15797
15889
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -16028,6 +16120,11 @@ async function handlePageRequestInternal(options) {
|
|
|
16028
16120
|
Redirect: (destination, permanent = false) => new RedirectResponse(destination, permanent),
|
|
16029
16121
|
NotFound: () => new NotFoundResponse()
|
|
16030
16122
|
};
|
|
16123
|
+
const globalMiddlewares = await loadGlobalMiddlewares(projectRoot || process.cwd());
|
|
16124
|
+
await runGlobalMiddlewares(ctx, globalMiddlewares);
|
|
16125
|
+
if (res.headersSent) {
|
|
16126
|
+
return;
|
|
16127
|
+
}
|
|
16031
16128
|
await runRouteMiddlewares(route, ctx);
|
|
16032
16129
|
if (res.headersSent) {
|
|
16033
16130
|
return;
|
|
@@ -16048,7 +16145,7 @@ async function handlePageRequestInternal(options) {
|
|
|
16048
16145
|
);
|
|
16049
16146
|
} catch (error) {
|
|
16050
16147
|
const layoutFile = route.layoutFiles[i];
|
|
16051
|
-
const relativeLayoutPath = layoutFile ?
|
|
16148
|
+
const relativeLayoutPath = layoutFile ? path24.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16052
16149
|
reqLogger.error("Layout middleware failed", error instanceof Error ? error : new Error(String(error)), {
|
|
16053
16150
|
route: route.pattern,
|
|
16054
16151
|
layoutIndex: i,
|
|
@@ -16114,7 +16211,7 @@ async function handlePageRequestInternal(options) {
|
|
|
16114
16211
|
}
|
|
16115
16212
|
} catch (error) {
|
|
16116
16213
|
const layoutFile = route.layoutFiles[i];
|
|
16117
|
-
const relativeLayoutPath = layoutFile ?
|
|
16214
|
+
const relativeLayoutPath = layoutFile ? path24.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16118
16215
|
reqLogger.warn("Layout server hook failed", {
|
|
16119
16216
|
error: error instanceof Error ? error.message : String(error),
|
|
16120
16217
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -16177,7 +16274,7 @@ async function handlePageRequestInternal(options) {
|
|
|
16177
16274
|
pageLoaderResult2.theme = theme;
|
|
16178
16275
|
}
|
|
16179
16276
|
} catch (error) {
|
|
16180
|
-
const relativePagePath = route.pageFile ?
|
|
16277
|
+
const relativePagePath = route.pageFile ? path24.relative(projectRoot || process.cwd(), route.pageFile) : "unknown";
|
|
16181
16278
|
reqLogger.error("Page server hook failed", {
|
|
16182
16279
|
error: error instanceof Error ? error.message : String(error),
|
|
16183
16280
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -16347,7 +16444,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
16347
16444
|
);
|
|
16348
16445
|
} catch (error2) {
|
|
16349
16446
|
const layoutFile = errorPage.layoutFiles[i];
|
|
16350
|
-
const relativeLayoutPath = layoutFile ?
|
|
16447
|
+
const relativeLayoutPath = layoutFile ? path24.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16351
16448
|
reqLogger.error("Layout middleware failed for error page", error2 instanceof Error ? error2 : new Error(String(error2)), {
|
|
16352
16449
|
layoutIndex: i,
|
|
16353
16450
|
layoutFile: relativeLayoutPath
|
|
@@ -16387,7 +16484,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
16387
16484
|
}
|
|
16388
16485
|
} catch (err) {
|
|
16389
16486
|
const layoutFile = errorPage.layoutFiles[i];
|
|
16390
|
-
const relativeLayoutPath = layoutFile ?
|
|
16487
|
+
const relativeLayoutPath = layoutFile ? path24.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
16391
16488
|
reqLogger.warn("Layout server hook failed for error page", {
|
|
16392
16489
|
error: err instanceof Error ? err.message : String(err),
|
|
16393
16490
|
stack: err instanceof Error ? err.stack : void 0,
|
|
@@ -16710,7 +16807,7 @@ function validateRealtimeConfig(config) {
|
|
|
16710
16807
|
}
|
|
16711
16808
|
|
|
16712
16809
|
// modules/server/routes.ts
|
|
16713
|
-
import
|
|
16810
|
+
import path25 from "path";
|
|
16714
16811
|
var cachedRewriteLoader = null;
|
|
16715
16812
|
var cachedProjectRoot = null;
|
|
16716
16813
|
var cachedIsDev = null;
|
|
@@ -16738,8 +16835,8 @@ function setupRoutes(options) {
|
|
|
16738
16835
|
} = options;
|
|
16739
16836
|
const routeChunks = routeLoader.loadRouteChunks();
|
|
16740
16837
|
const rewriteLoader = getRewriteLoader(projectRoot, isDev);
|
|
16741
|
-
const ssgOutDir =
|
|
16742
|
-
config ? getBuildDir(projectRoot, config) :
|
|
16838
|
+
const ssgOutDir = path25.join(
|
|
16839
|
+
config ? getBuildDir(projectRoot, config) : path25.join(projectRoot, BUILD_FOLDER_NAME),
|
|
16743
16840
|
"ssg"
|
|
16744
16841
|
);
|
|
16745
16842
|
app.all("/api/*", async (req, res) => {
|
|
@@ -17968,8 +18065,8 @@ var setupApplication = async ({
|
|
|
17968
18065
|
|
|
17969
18066
|
// src/server.ts
|
|
17970
18067
|
import dotenv2 from "dotenv";
|
|
17971
|
-
var envPath =
|
|
17972
|
-
if (
|
|
18068
|
+
var envPath = path26.join(process.cwd(), ".env");
|
|
18069
|
+
if (fs20.existsSync(envPath)) {
|
|
17973
18070
|
dotenv2.config({ path: envPath });
|
|
17974
18071
|
} else {
|
|
17975
18072
|
dotenv2.config();
|
|
@@ -17990,8 +18087,8 @@ async function startServer(options = {}) {
|
|
|
17990
18087
|
}
|
|
17991
18088
|
const port = options.port ?? (process.env.PORT ? parseInt(process.env.PORT, 10) : void 0) ?? config.server.port;
|
|
17992
18089
|
const host = process.env.HOST ?? (!isDev ? "0.0.0.0" : void 0) ?? config.server.host;
|
|
17993
|
-
const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) :
|
|
17994
|
-
if (!isDev && !
|
|
18090
|
+
const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) : path26.join(getBuildDir(projectRoot, config), "server"));
|
|
18091
|
+
if (!isDev && !fs20.existsSync(appDir)) {
|
|
17995
18092
|
logger4.error("Compiled directory not found", void 0, {
|
|
17996
18093
|
buildDir: config.directories.build,
|
|
17997
18094
|
appDir,
|
|
@@ -18062,10 +18159,10 @@ async function startProdServer(options = {}) {
|
|
|
18062
18159
|
}
|
|
18063
18160
|
|
|
18064
18161
|
// modules/build/ssg/builder.ts
|
|
18065
|
-
import
|
|
18162
|
+
import path29 from "path";
|
|
18066
18163
|
|
|
18067
18164
|
// modules/build/ssg/path.ts
|
|
18068
|
-
import
|
|
18165
|
+
import path27 from "path";
|
|
18069
18166
|
function buildPathFromPattern(pattern, params) {
|
|
18070
18167
|
const segments = pattern.split("/").filter(Boolean);
|
|
18071
18168
|
const parts = [];
|
|
@@ -18094,12 +18191,12 @@ function buildPathFromPattern(pattern, params) {
|
|
|
18094
18191
|
}
|
|
18095
18192
|
function pathToOutDir(baseDir, urlPath) {
|
|
18096
18193
|
const clean = urlPath === "/" ? "" : urlPath.replace(/^\/+/, "");
|
|
18097
|
-
return
|
|
18194
|
+
return path27.join(baseDir, clean);
|
|
18098
18195
|
}
|
|
18099
18196
|
|
|
18100
18197
|
// modules/build/ssg/renderer.ts
|
|
18101
|
-
import
|
|
18102
|
-
import
|
|
18198
|
+
import fs21 from "fs";
|
|
18199
|
+
import path28 from "path";
|
|
18103
18200
|
import { renderToString } from "react-dom/server";
|
|
18104
18201
|
init_globals();
|
|
18105
18202
|
async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params, config) {
|
|
@@ -18235,16 +18332,16 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params,
|
|
|
18235
18332
|
const html = "<!DOCTYPE html>" + renderToString(documentTree);
|
|
18236
18333
|
const dir = pathToOutDir(ssgOutDir, urlPath);
|
|
18237
18334
|
ensureDir(dir);
|
|
18238
|
-
const htmlFile =
|
|
18239
|
-
const dataFile =
|
|
18240
|
-
|
|
18241
|
-
|
|
18335
|
+
const htmlFile = path28.join(dir, "index.html");
|
|
18336
|
+
const dataFile = path28.join(dir, "data.json");
|
|
18337
|
+
fs21.writeFileSync(htmlFile, html, "utf-8");
|
|
18338
|
+
fs21.writeFileSync(dataFile, JSON.stringify(initialData, null, 2), "utf-8");
|
|
18242
18339
|
}
|
|
18243
18340
|
|
|
18244
18341
|
// modules/build/ssg/builder.ts
|
|
18245
18342
|
init_globals();
|
|
18246
18343
|
async function buildStaticPages(projectRoot, routes, config) {
|
|
18247
|
-
const ssgOutDir =
|
|
18344
|
+
const ssgOutDir = path29.join(projectRoot, BUILD_FOLDER_NAME, "ssg");
|
|
18248
18345
|
ensureDir(ssgOutDir);
|
|
18249
18346
|
for (const route of routes) {
|
|
18250
18347
|
if (route.dynamic !== "force-static") continue;
|
|
@@ -18299,36 +18396,36 @@ async function buildStaticPages(projectRoot, routes, config) {
|
|
|
18299
18396
|
}
|
|
18300
18397
|
|
|
18301
18398
|
// modules/build/bundler/server.ts
|
|
18302
|
-
import
|
|
18303
|
-
import
|
|
18399
|
+
import path30 from "path";
|
|
18400
|
+
import fs22 from "fs";
|
|
18304
18401
|
import esbuild from "esbuild";
|
|
18305
18402
|
init_globals();
|
|
18306
18403
|
var SERVER_FILES = [INIT_FILE_NAME, CONFIG_FILE_NAME];
|
|
18307
18404
|
function createPathAliasPlugin(projectRoot, outDir) {
|
|
18308
18405
|
const aliases = loadAliasesFromTsconfig(projectRoot);
|
|
18309
|
-
const tsconfigPath =
|
|
18406
|
+
const tsconfigPath = path30.join(projectRoot, "tsconfig.json");
|
|
18310
18407
|
let baseUrl = ".";
|
|
18311
|
-
if (
|
|
18408
|
+
if (fs22.existsSync(tsconfigPath)) {
|
|
18312
18409
|
try {
|
|
18313
|
-
const tsconfig = JSON.parse(
|
|
18410
|
+
const tsconfig = JSON.parse(fs22.readFileSync(tsconfigPath, "utf-8"));
|
|
18314
18411
|
baseUrl = tsconfig.compilerOptions?.baseUrl ?? ".";
|
|
18315
18412
|
} catch {
|
|
18316
18413
|
}
|
|
18317
18414
|
}
|
|
18318
18415
|
function resolveAliasToRelative(importPath, sourceFile) {
|
|
18319
|
-
if (importPath.startsWith(".") || importPath.startsWith("/") ||
|
|
18416
|
+
if (importPath.startsWith(".") || importPath.startsWith("/") || path30.isAbsolute(importPath) || importPath.includes("node_modules")) {
|
|
18320
18417
|
return null;
|
|
18321
18418
|
}
|
|
18322
18419
|
for (const [aliasKey, aliasPath] of Object.entries(aliases)) {
|
|
18323
18420
|
if (importPath.startsWith(aliasKey + "/") || importPath === aliasKey) {
|
|
18324
18421
|
const restPath = importPath.startsWith(aliasKey + "/") ? importPath.slice(aliasKey.length + 1) : "";
|
|
18325
|
-
const resolvedPath = restPath ?
|
|
18422
|
+
const resolvedPath = restPath ? path30.join(aliasPath, restPath) : aliasPath;
|
|
18326
18423
|
let actualPath = null;
|
|
18327
18424
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
|
|
18328
|
-
if (
|
|
18425
|
+
if (fs22.existsSync(resolvedPath) && fs22.statSync(resolvedPath).isDirectory()) {
|
|
18329
18426
|
for (const ext of extensions) {
|
|
18330
|
-
const indexPath =
|
|
18331
|
-
if (
|
|
18427
|
+
const indexPath = path30.join(resolvedPath, `index${ext}`);
|
|
18428
|
+
if (fs22.existsSync(indexPath)) {
|
|
18332
18429
|
actualPath = indexPath;
|
|
18333
18430
|
break;
|
|
18334
18431
|
}
|
|
@@ -18336,20 +18433,20 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18336
18433
|
} else {
|
|
18337
18434
|
for (const ext of extensions) {
|
|
18338
18435
|
const filePath = resolvedPath + ext;
|
|
18339
|
-
if (
|
|
18436
|
+
if (fs22.existsSync(filePath)) {
|
|
18340
18437
|
actualPath = filePath;
|
|
18341
18438
|
break;
|
|
18342
18439
|
}
|
|
18343
18440
|
}
|
|
18344
|
-
if (!actualPath &&
|
|
18441
|
+
if (!actualPath && fs22.existsSync(resolvedPath)) {
|
|
18345
18442
|
actualPath = resolvedPath;
|
|
18346
18443
|
}
|
|
18347
18444
|
}
|
|
18348
18445
|
if (actualPath) {
|
|
18349
|
-
const relativePath =
|
|
18446
|
+
const relativePath = path30.relative(outDir, actualPath);
|
|
18350
18447
|
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
18351
18448
|
const finalPath = normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
|
|
18352
|
-
const ext =
|
|
18449
|
+
const ext = path30.extname(finalPath);
|
|
18353
18450
|
const pathWithoutExt = ext === ".json" ? finalPath : finalPath.slice(0, -ext.length);
|
|
18354
18451
|
return pathWithoutExt;
|
|
18355
18452
|
}
|
|
@@ -18361,13 +18458,13 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18361
18458
|
name: "path-alias-resolver",
|
|
18362
18459
|
setup(build) {
|
|
18363
18460
|
build.onLoad({ filter: /\.(ts|tsx|js|jsx)$/ }, (args) => {
|
|
18364
|
-
const fileName =
|
|
18461
|
+
const fileName = path30.basename(args.path);
|
|
18365
18462
|
const isServerFile = SERVER_FILES.some((f) => fileName === `${f}.ts` || fileName === `${f}.tsx` || fileName === `${f}.js` || fileName === `${f}.jsx`);
|
|
18366
|
-
const isInProjectRoot =
|
|
18463
|
+
const isInProjectRoot = path30.dirname(args.path) === projectRoot;
|
|
18367
18464
|
if (!isServerFile || !isInProjectRoot) {
|
|
18368
18465
|
return null;
|
|
18369
18466
|
}
|
|
18370
|
-
const contents =
|
|
18467
|
+
const contents = fs22.readFileSync(args.path, "utf-8");
|
|
18371
18468
|
let transformed = contents;
|
|
18372
18469
|
const aliasPatterns = Object.keys(aliases).sort((a, b) => b.length - a.length);
|
|
18373
18470
|
for (const aliasKey of aliasPatterns) {
|
|
@@ -18387,7 +18484,7 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18387
18484
|
}
|
|
18388
18485
|
return {
|
|
18389
18486
|
contents: transformed,
|
|
18390
|
-
loader:
|
|
18487
|
+
loader: path30.extname(args.path).slice(1)
|
|
18391
18488
|
};
|
|
18392
18489
|
});
|
|
18393
18490
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
@@ -18406,9 +18503,9 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
18406
18503
|
function collectAppSources(appDir) {
|
|
18407
18504
|
const entries = [];
|
|
18408
18505
|
function walk(dir) {
|
|
18409
|
-
const items =
|
|
18506
|
+
const items = fs22.readdirSync(dir, { withFileTypes: true });
|
|
18410
18507
|
for (const item of items) {
|
|
18411
|
-
const full =
|
|
18508
|
+
const full = path30.join(dir, item.name);
|
|
18412
18509
|
if (item.isDirectory()) {
|
|
18413
18510
|
walk(full);
|
|
18414
18511
|
continue;
|
|
@@ -18425,7 +18522,7 @@ function collectAppSources(appDir) {
|
|
|
18425
18522
|
return entries;
|
|
18426
18523
|
}
|
|
18427
18524
|
async function buildServerApp(projectRoot, appDir) {
|
|
18428
|
-
const outDir =
|
|
18525
|
+
const outDir = path30.join(projectRoot, BUILD_FOLDER_NAME, "server");
|
|
18429
18526
|
const entryPoints = collectAppSources(appDir);
|
|
18430
18527
|
ensureDir(outDir);
|
|
18431
18528
|
if (entryPoints.length === 0) {
|
|
@@ -18443,14 +18540,14 @@ async function buildServerApp(projectRoot, appDir) {
|
|
|
18443
18540
|
bundle: true,
|
|
18444
18541
|
splitting: false,
|
|
18445
18542
|
logLevel: "info",
|
|
18446
|
-
tsconfig:
|
|
18543
|
+
tsconfig: path30.join(projectRoot, "tsconfig.json"),
|
|
18447
18544
|
packages: "external"
|
|
18448
18545
|
});
|
|
18449
18546
|
const pathAliasPlugin = createPathAliasPlugin(projectRoot, outDir);
|
|
18450
18547
|
for (const fileName of SERVER_FILES) {
|
|
18451
|
-
const initTS =
|
|
18452
|
-
const initJS =
|
|
18453
|
-
if (
|
|
18548
|
+
const initTS = path30.join(projectRoot, `${fileName}.ts`);
|
|
18549
|
+
const initJS = path30.join(outDir, `${fileName}.js`);
|
|
18550
|
+
if (fs22.existsSync(initTS)) {
|
|
18454
18551
|
await esbuild.build({
|
|
18455
18552
|
entryPoints: [initTS],
|
|
18456
18553
|
outfile: initJS,
|
|
@@ -18461,7 +18558,7 @@ async function buildServerApp(projectRoot, appDir) {
|
|
|
18461
18558
|
sourcemap: true,
|
|
18462
18559
|
bundle: false,
|
|
18463
18560
|
logLevel: "info",
|
|
18464
|
-
tsconfig:
|
|
18561
|
+
tsconfig: path30.join(projectRoot, "tsconfig.json"),
|
|
18465
18562
|
plugins: [pathAliasPlugin]
|
|
18466
18563
|
});
|
|
18467
18564
|
}
|
|
@@ -19748,11 +19845,11 @@ var ValidationError = class extends Error {
|
|
|
19748
19845
|
format() {
|
|
19749
19846
|
const formatted = {};
|
|
19750
19847
|
for (const error of this.errors) {
|
|
19751
|
-
const
|
|
19752
|
-
if (!formatted[
|
|
19753
|
-
formatted[
|
|
19848
|
+
const path31 = error.path.join(".");
|
|
19849
|
+
if (!formatted[path31]) {
|
|
19850
|
+
formatted[path31] = [];
|
|
19754
19851
|
}
|
|
19755
|
-
formatted[
|
|
19852
|
+
formatted[path31].push(error.message);
|
|
19756
19853
|
}
|
|
19757
19854
|
return formatted;
|
|
19758
19855
|
}
|