@lolyjs/core 0.2.0-alpha.31 → 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.cjs.map +1 -1
- package/dist/react/cache.d.mts +1 -1
- package/dist/react/cache.d.ts +1 -1
- package/dist/react/cache.js.map +1 -1
- package/dist/react/components.cjs.map +1 -1
- package/dist/react/components.js.map +1 -1
- package/dist/react/hooks.cjs.map +1 -1
- package/dist/react/hooks.js.map +1 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -9866,7 +9866,7 @@ var require_built3 = __commonJS({
|
|
|
9866
9866
|
});
|
|
9867
9867
|
|
|
9868
9868
|
// modules/cli/index.ts
|
|
9869
|
-
var
|
|
9869
|
+
var import_path35 = __toESM(require("path"));
|
|
9870
9870
|
var import_process = __toESM(require("process"));
|
|
9871
9871
|
|
|
9872
9872
|
// modules/router/loader-pages.ts
|
|
@@ -12394,7 +12394,7 @@ function buildClientBundle(projectRoot) {
|
|
|
12394
12394
|
}
|
|
12395
12395
|
|
|
12396
12396
|
// modules/build/ssg/builder.ts
|
|
12397
|
-
var
|
|
12397
|
+
var import_path25 = __toESM(require("path"));
|
|
12398
12398
|
|
|
12399
12399
|
// modules/build/ssg/path.ts
|
|
12400
12400
|
var import_path17 = __toESM(require("path"));
|
|
@@ -12430,8 +12430,8 @@ function pathToOutDir(baseDir, urlPath) {
|
|
|
12430
12430
|
}
|
|
12431
12431
|
|
|
12432
12432
|
// modules/build/ssg/renderer.ts
|
|
12433
|
-
var
|
|
12434
|
-
var
|
|
12433
|
+
var import_fs17 = __toESM(require("fs"));
|
|
12434
|
+
var import_path23 = __toESM(require("path"));
|
|
12435
12435
|
var import_server2 = require("react-dom/server");
|
|
12436
12436
|
|
|
12437
12437
|
// modules/rendering/createDocumentTree/index.ts
|
|
@@ -12986,12 +12986,12 @@ var DEFAULT_IGNORED_PATHS = [
|
|
|
12986
12986
|
/^\/sockjs-node/
|
|
12987
12987
|
// Hot reload websocket
|
|
12988
12988
|
];
|
|
12989
|
-
function shouldIgnorePath(
|
|
12989
|
+
function shouldIgnorePath(path32, ignoredPaths) {
|
|
12990
12990
|
return ignoredPaths.some((pattern) => {
|
|
12991
12991
|
if (typeof pattern === "string") {
|
|
12992
|
-
return
|
|
12992
|
+
return path32 === pattern || path32.startsWith(pattern);
|
|
12993
12993
|
}
|
|
12994
|
-
return pattern.test(
|
|
12994
|
+
return pattern.test(path32);
|
|
12995
12995
|
});
|
|
12996
12996
|
}
|
|
12997
12997
|
function requestLoggerMiddleware(options = {}) {
|
|
@@ -13161,25 +13161,89 @@ function handleNotFound(res, urlPath) {
|
|
|
13161
13161
|
}
|
|
13162
13162
|
}
|
|
13163
13163
|
|
|
13164
|
-
// modules/server/
|
|
13165
|
-
var import_fs15 = __toESM(require("fs"));
|
|
13164
|
+
// modules/server/global-middleware.ts
|
|
13166
13165
|
var import_path20 = __toESM(require("path"));
|
|
13166
|
+
var import_fs15 = __toESM(require("fs"));
|
|
13167
|
+
var cachedGlobalMiddlewares = null;
|
|
13168
|
+
async function loadGlobalMiddlewares(projectRoot) {
|
|
13169
|
+
if (cachedGlobalMiddlewares !== null) {
|
|
13170
|
+
return cachedGlobalMiddlewares;
|
|
13171
|
+
}
|
|
13172
|
+
const globalMiddlewareFile = import_path20.default.join(projectRoot, "global.middleware.ts");
|
|
13173
|
+
const globalMiddlewareFileJs = import_path20.default.join(projectRoot, "global.middleware.js");
|
|
13174
|
+
const file = import_fs15.default.existsSync(globalMiddlewareFile) ? globalMiddlewareFile : import_fs15.default.existsSync(globalMiddlewareFileJs) ? globalMiddlewareFileJs : null;
|
|
13175
|
+
if (!file) {
|
|
13176
|
+
cachedGlobalMiddlewares = [];
|
|
13177
|
+
return cachedGlobalMiddlewares;
|
|
13178
|
+
}
|
|
13179
|
+
if (file.endsWith(".ts") || file.endsWith(".tsx")) {
|
|
13180
|
+
try {
|
|
13181
|
+
require("tsx/cjs");
|
|
13182
|
+
} catch (e) {
|
|
13183
|
+
}
|
|
13184
|
+
}
|
|
13185
|
+
try {
|
|
13186
|
+
const mod = require(file);
|
|
13187
|
+
const middlewares = mod?.globalMiddlewares;
|
|
13188
|
+
if (Array.isArray(middlewares)) {
|
|
13189
|
+
const validMiddlewares = [];
|
|
13190
|
+
for (let i = 0; i < middlewares.length; i++) {
|
|
13191
|
+
const mw = middlewares[i];
|
|
13192
|
+
if (typeof mw === "function") {
|
|
13193
|
+
validMiddlewares.push(mw);
|
|
13194
|
+
} else {
|
|
13195
|
+
console.warn(
|
|
13196
|
+
`[framework][global-middleware] Middleware at index ${i} in global.middleware.ts is not a function, skipping`
|
|
13197
|
+
);
|
|
13198
|
+
}
|
|
13199
|
+
}
|
|
13200
|
+
cachedGlobalMiddlewares = validMiddlewares;
|
|
13201
|
+
return cachedGlobalMiddlewares;
|
|
13202
|
+
} else if (middlewares !== void 0) {
|
|
13203
|
+
console.warn(
|
|
13204
|
+
"[framework][global-middleware] globalMiddlewares must be an array in global.middleware.ts, ignoring invalid value"
|
|
13205
|
+
);
|
|
13206
|
+
}
|
|
13207
|
+
} catch (error) {
|
|
13208
|
+
console.error("[framework][global-middleware] Error loading global.middleware.ts:", error);
|
|
13209
|
+
}
|
|
13210
|
+
cachedGlobalMiddlewares = [];
|
|
13211
|
+
return cachedGlobalMiddlewares;
|
|
13212
|
+
}
|
|
13213
|
+
async function runGlobalMiddlewares(ctx, globalMiddlewares) {
|
|
13214
|
+
for (const mw of globalMiddlewares) {
|
|
13215
|
+
try {
|
|
13216
|
+
await Promise.resolve(mw(ctx, async () => {
|
|
13217
|
+
}));
|
|
13218
|
+
} catch (error) {
|
|
13219
|
+
console.error("[framework][global-middleware] Error in global middleware:", error);
|
|
13220
|
+
continue;
|
|
13221
|
+
}
|
|
13222
|
+
if (ctx.res.headersSent) {
|
|
13223
|
+
return;
|
|
13224
|
+
}
|
|
13225
|
+
}
|
|
13226
|
+
}
|
|
13227
|
+
|
|
13228
|
+
// modules/server/handlers/ssg.ts
|
|
13229
|
+
var import_fs16 = __toESM(require("fs"));
|
|
13230
|
+
var import_path21 = __toESM(require("path"));
|
|
13167
13231
|
var logger2 = createModuleLogger("ssg");
|
|
13168
13232
|
function getSsgDirForPath(baseDir, urlPath) {
|
|
13169
13233
|
const clean = urlPath === "/" ? "" : urlPath.replace(/^\/+/, "");
|
|
13170
|
-
return
|
|
13234
|
+
return import_path21.default.join(baseDir, clean);
|
|
13171
13235
|
}
|
|
13172
13236
|
function getSsgHtmlPath(baseDir, urlPath) {
|
|
13173
13237
|
const dir = getSsgDirForPath(baseDir, urlPath);
|
|
13174
|
-
return
|
|
13238
|
+
return import_path21.default.join(dir, "index.html");
|
|
13175
13239
|
}
|
|
13176
13240
|
function getSsgDataPath(baseDir, urlPath) {
|
|
13177
13241
|
const dir = getSsgDirForPath(baseDir, urlPath);
|
|
13178
|
-
return
|
|
13242
|
+
return import_path21.default.join(dir, "data.json");
|
|
13179
13243
|
}
|
|
13180
13244
|
function tryServeSsgHtml(res, ssgOutDir, urlPath) {
|
|
13181
13245
|
const ssgHtmlPath = getSsgHtmlPath(ssgOutDir, urlPath);
|
|
13182
|
-
if (!
|
|
13246
|
+
if (!import_fs16.default.existsSync(ssgHtmlPath)) {
|
|
13183
13247
|
return false;
|
|
13184
13248
|
}
|
|
13185
13249
|
logger2.info("Serving SSG HTML", { urlPath, ssgHtmlPath });
|
|
@@ -13189,17 +13253,17 @@ function tryServeSsgHtml(res, ssgOutDir, urlPath) {
|
|
|
13189
13253
|
);
|
|
13190
13254
|
res.statusCode = 200;
|
|
13191
13255
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
13192
|
-
const stream =
|
|
13256
|
+
const stream = import_fs16.default.createReadStream(ssgHtmlPath, { encoding: "utf-8" });
|
|
13193
13257
|
stream.pipe(res);
|
|
13194
13258
|
return true;
|
|
13195
13259
|
}
|
|
13196
13260
|
function tryServeSsgData(res, ssgOutDir, urlPath) {
|
|
13197
13261
|
const ssgDataPath = getSsgDataPath(ssgOutDir, urlPath);
|
|
13198
|
-
if (!
|
|
13262
|
+
if (!import_fs16.default.existsSync(ssgDataPath)) {
|
|
13199
13263
|
return false;
|
|
13200
13264
|
}
|
|
13201
13265
|
try {
|
|
13202
|
-
const raw =
|
|
13266
|
+
const raw = import_fs16.default.readFileSync(ssgDataPath, "utf-8");
|
|
13203
13267
|
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
13204
13268
|
res.status(200).end(raw);
|
|
13205
13269
|
return true;
|
|
@@ -13265,7 +13329,7 @@ function sanitizeQuery(query) {
|
|
|
13265
13329
|
}
|
|
13266
13330
|
|
|
13267
13331
|
// modules/server/handlers/pages.ts
|
|
13268
|
-
var
|
|
13332
|
+
var import_path22 = __toESM(require("path"));
|
|
13269
13333
|
function mergeMetadata(base, override) {
|
|
13270
13334
|
if (!base && !override) return null;
|
|
13271
13335
|
if (!base) return override;
|
|
@@ -13323,7 +13387,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
|
|
|
13323
13387
|
} catch (error) {
|
|
13324
13388
|
const reqLogger = getRequestLogger(req);
|
|
13325
13389
|
const layoutFile = notFoundPage.layoutFiles[i];
|
|
13326
|
-
const relativeLayoutPath = layoutFile ?
|
|
13390
|
+
const relativeLayoutPath = layoutFile ? import_path22.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
13327
13391
|
reqLogger.error("Layout middleware failed for not-found page", error instanceof Error ? error : new Error(String(error)), {
|
|
13328
13392
|
layoutIndex: i,
|
|
13329
13393
|
layoutFile: relativeLayoutPath
|
|
@@ -13352,7 +13416,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
|
|
|
13352
13416
|
} catch (error) {
|
|
13353
13417
|
const reqLogger = getRequestLogger(req);
|
|
13354
13418
|
const layoutFile = notFoundPage.layoutFiles[i];
|
|
13355
|
-
const relativeLayoutPath = layoutFile ?
|
|
13419
|
+
const relativeLayoutPath = layoutFile ? import_path22.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
13356
13420
|
reqLogger.warn("Layout server hook failed for not-found page", {
|
|
13357
13421
|
error: error instanceof Error ? error.message : String(error),
|
|
13358
13422
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -13589,6 +13653,11 @@ async function handlePageRequestInternal(options) {
|
|
|
13589
13653
|
Redirect: (destination, permanent = false) => new RedirectResponse(destination, permanent),
|
|
13590
13654
|
NotFound: () => new NotFoundResponse()
|
|
13591
13655
|
};
|
|
13656
|
+
const globalMiddlewares = await loadGlobalMiddlewares(projectRoot || process.cwd());
|
|
13657
|
+
await runGlobalMiddlewares(ctx, globalMiddlewares);
|
|
13658
|
+
if (res.headersSent) {
|
|
13659
|
+
return;
|
|
13660
|
+
}
|
|
13592
13661
|
await runRouteMiddlewares(route, ctx);
|
|
13593
13662
|
if (res.headersSent) {
|
|
13594
13663
|
return;
|
|
@@ -13609,7 +13678,7 @@ async function handlePageRequestInternal(options) {
|
|
|
13609
13678
|
);
|
|
13610
13679
|
} catch (error) {
|
|
13611
13680
|
const layoutFile = route.layoutFiles[i];
|
|
13612
|
-
const relativeLayoutPath = layoutFile ?
|
|
13681
|
+
const relativeLayoutPath = layoutFile ? import_path22.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
13613
13682
|
reqLogger.error("Layout middleware failed", error instanceof Error ? error : new Error(String(error)), {
|
|
13614
13683
|
route: route.pattern,
|
|
13615
13684
|
layoutIndex: i,
|
|
@@ -13675,7 +13744,7 @@ async function handlePageRequestInternal(options) {
|
|
|
13675
13744
|
}
|
|
13676
13745
|
} catch (error) {
|
|
13677
13746
|
const layoutFile = route.layoutFiles[i];
|
|
13678
|
-
const relativeLayoutPath = layoutFile ?
|
|
13747
|
+
const relativeLayoutPath = layoutFile ? import_path22.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
13679
13748
|
reqLogger.warn("Layout server hook failed", {
|
|
13680
13749
|
error: error instanceof Error ? error.message : String(error),
|
|
13681
13750
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -13738,7 +13807,7 @@ async function handlePageRequestInternal(options) {
|
|
|
13738
13807
|
pageLoaderResult2.theme = theme;
|
|
13739
13808
|
}
|
|
13740
13809
|
} catch (error) {
|
|
13741
|
-
const relativePagePath = route.pageFile ?
|
|
13810
|
+
const relativePagePath = route.pageFile ? import_path22.default.relative(projectRoot || process.cwd(), route.pageFile) : "unknown";
|
|
13742
13811
|
reqLogger.error("Page server hook failed", {
|
|
13743
13812
|
error: error instanceof Error ? error.message : String(error),
|
|
13744
13813
|
stack: error instanceof Error ? error.stack : void 0,
|
|
@@ -13908,7 +13977,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
13908
13977
|
);
|
|
13909
13978
|
} catch (error2) {
|
|
13910
13979
|
const layoutFile = errorPage.layoutFiles[i];
|
|
13911
|
-
const relativeLayoutPath = layoutFile ?
|
|
13980
|
+
const relativeLayoutPath = layoutFile ? import_path22.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
13912
13981
|
reqLogger.error("Layout middleware failed for error page", error2 instanceof Error ? error2 : new Error(String(error2)), {
|
|
13913
13982
|
layoutIndex: i,
|
|
13914
13983
|
layoutFile: relativeLayoutPath
|
|
@@ -13948,7 +14017,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
13948
14017
|
}
|
|
13949
14018
|
} catch (err) {
|
|
13950
14019
|
const layoutFile = errorPage.layoutFiles[i];
|
|
13951
|
-
const relativeLayoutPath = layoutFile ?
|
|
14020
|
+
const relativeLayoutPath = layoutFile ? import_path22.default.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
|
|
13952
14021
|
reqLogger.warn("Layout server hook failed for error page", {
|
|
13953
14022
|
error: err instanceof Error ? err.message : String(err),
|
|
13954
14023
|
stack: err instanceof Error ? err.stack : void 0,
|
|
@@ -14244,16 +14313,16 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params,
|
|
|
14244
14313
|
const html = "<!DOCTYPE html>" + (0, import_server2.renderToString)(documentTree);
|
|
14245
14314
|
const dir = pathToOutDir(ssgOutDir, urlPath);
|
|
14246
14315
|
ensureDir(dir);
|
|
14247
|
-
const htmlFile =
|
|
14248
|
-
const dataFile =
|
|
14249
|
-
|
|
14250
|
-
|
|
14316
|
+
const htmlFile = import_path23.default.join(dir, "index.html");
|
|
14317
|
+
const dataFile = import_path23.default.join(dir, "data.json");
|
|
14318
|
+
import_fs17.default.writeFileSync(htmlFile, html, "utf-8");
|
|
14319
|
+
import_fs17.default.writeFileSync(dataFile, JSON.stringify(initialData, null, 2), "utf-8");
|
|
14251
14320
|
}
|
|
14252
14321
|
|
|
14253
14322
|
// modules/build/ssg/builder.ts
|
|
14254
14323
|
init_globals();
|
|
14255
14324
|
async function buildStaticPages(projectRoot, routes, config) {
|
|
14256
|
-
const ssgOutDir =
|
|
14325
|
+
const ssgOutDir = import_path25.default.join(projectRoot, BUILD_FOLDER_NAME, "ssg");
|
|
14257
14326
|
ensureDir(ssgOutDir);
|
|
14258
14327
|
for (const route of routes) {
|
|
14259
14328
|
if (route.dynamic !== "force-static") continue;
|
|
@@ -14308,27 +14377,27 @@ async function buildStaticPages(projectRoot, routes, config) {
|
|
|
14308
14377
|
}
|
|
14309
14378
|
|
|
14310
14379
|
// modules/build/bundler/server.ts
|
|
14311
|
-
var
|
|
14312
|
-
var
|
|
14380
|
+
var import_path28 = __toESM(require("path"));
|
|
14381
|
+
var import_fs19 = __toESM(require("fs"));
|
|
14313
14382
|
var import_esbuild = __toESM(require("esbuild"));
|
|
14314
14383
|
|
|
14315
14384
|
// modules/server/utils/server-dir.ts
|
|
14316
|
-
var
|
|
14317
|
-
var
|
|
14385
|
+
var import_fs18 = __toESM(require("fs"));
|
|
14386
|
+
var import_path27 = __toESM(require("path"));
|
|
14318
14387
|
init_globals();
|
|
14319
14388
|
var getServerFile = async (projectRoot, fileName) => {
|
|
14320
|
-
const fileTS =
|
|
14321
|
-
const fileJS =
|
|
14389
|
+
const fileTS = import_path27.default.join(projectRoot, `${fileName}.ts`);
|
|
14390
|
+
const fileJS = import_path27.default.join(projectRoot, BUILD_FOLDER_NAME, "server", `${fileName}.js`);
|
|
14322
14391
|
const isDev = process.env.NODE_ENV === "development";
|
|
14323
14392
|
let mod = null;
|
|
14324
14393
|
if (isDev) {
|
|
14325
|
-
if (!
|
|
14394
|
+
if (!import_fs18.default.existsSync(fileTS)) {
|
|
14326
14395
|
return null;
|
|
14327
14396
|
}
|
|
14328
14397
|
require("tsx/cjs");
|
|
14329
14398
|
mod = require(fileTS);
|
|
14330
14399
|
} else {
|
|
14331
|
-
if (!
|
|
14400
|
+
if (!import_fs18.default.existsSync(fileJS)) {
|
|
14332
14401
|
return null;
|
|
14333
14402
|
}
|
|
14334
14403
|
mod = require(fileJS);
|
|
@@ -14510,29 +14579,29 @@ init_globals();
|
|
|
14510
14579
|
var SERVER_FILES = [INIT_FILE_NAME, CONFIG_FILE_NAME];
|
|
14511
14580
|
function createPathAliasPlugin(projectRoot, outDir) {
|
|
14512
14581
|
const aliases = loadAliasesFromTsconfig(projectRoot);
|
|
14513
|
-
const tsconfigPath =
|
|
14582
|
+
const tsconfigPath = import_path28.default.join(projectRoot, "tsconfig.json");
|
|
14514
14583
|
let baseUrl = ".";
|
|
14515
|
-
if (
|
|
14584
|
+
if (import_fs19.default.existsSync(tsconfigPath)) {
|
|
14516
14585
|
try {
|
|
14517
|
-
const tsconfig = JSON.parse(
|
|
14586
|
+
const tsconfig = JSON.parse(import_fs19.default.readFileSync(tsconfigPath, "utf-8"));
|
|
14518
14587
|
baseUrl = tsconfig.compilerOptions?.baseUrl ?? ".";
|
|
14519
14588
|
} catch {
|
|
14520
14589
|
}
|
|
14521
14590
|
}
|
|
14522
14591
|
function resolveAliasToRelative(importPath, sourceFile) {
|
|
14523
|
-
if (importPath.startsWith(".") || importPath.startsWith("/") ||
|
|
14592
|
+
if (importPath.startsWith(".") || importPath.startsWith("/") || import_path28.default.isAbsolute(importPath) || importPath.includes("node_modules")) {
|
|
14524
14593
|
return null;
|
|
14525
14594
|
}
|
|
14526
14595
|
for (const [aliasKey, aliasPath] of Object.entries(aliases)) {
|
|
14527
14596
|
if (importPath.startsWith(aliasKey + "/") || importPath === aliasKey) {
|
|
14528
14597
|
const restPath = importPath.startsWith(aliasKey + "/") ? importPath.slice(aliasKey.length + 1) : "";
|
|
14529
|
-
const resolvedPath = restPath ?
|
|
14598
|
+
const resolvedPath = restPath ? import_path28.default.join(aliasPath, restPath) : aliasPath;
|
|
14530
14599
|
let actualPath = null;
|
|
14531
14600
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
|
|
14532
|
-
if (
|
|
14601
|
+
if (import_fs19.default.existsSync(resolvedPath) && import_fs19.default.statSync(resolvedPath).isDirectory()) {
|
|
14533
14602
|
for (const ext of extensions) {
|
|
14534
|
-
const indexPath =
|
|
14535
|
-
if (
|
|
14603
|
+
const indexPath = import_path28.default.join(resolvedPath, `index${ext}`);
|
|
14604
|
+
if (import_fs19.default.existsSync(indexPath)) {
|
|
14536
14605
|
actualPath = indexPath;
|
|
14537
14606
|
break;
|
|
14538
14607
|
}
|
|
@@ -14540,20 +14609,20 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
14540
14609
|
} else {
|
|
14541
14610
|
for (const ext of extensions) {
|
|
14542
14611
|
const filePath = resolvedPath + ext;
|
|
14543
|
-
if (
|
|
14612
|
+
if (import_fs19.default.existsSync(filePath)) {
|
|
14544
14613
|
actualPath = filePath;
|
|
14545
14614
|
break;
|
|
14546
14615
|
}
|
|
14547
14616
|
}
|
|
14548
|
-
if (!actualPath &&
|
|
14617
|
+
if (!actualPath && import_fs19.default.existsSync(resolvedPath)) {
|
|
14549
14618
|
actualPath = resolvedPath;
|
|
14550
14619
|
}
|
|
14551
14620
|
}
|
|
14552
14621
|
if (actualPath) {
|
|
14553
|
-
const relativePath =
|
|
14622
|
+
const relativePath = import_path28.default.relative(outDir, actualPath);
|
|
14554
14623
|
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
14555
14624
|
const finalPath = normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
|
|
14556
|
-
const ext =
|
|
14625
|
+
const ext = import_path28.default.extname(finalPath);
|
|
14557
14626
|
const pathWithoutExt = ext === ".json" ? finalPath : finalPath.slice(0, -ext.length);
|
|
14558
14627
|
return pathWithoutExt;
|
|
14559
14628
|
}
|
|
@@ -14565,13 +14634,13 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
14565
14634
|
name: "path-alias-resolver",
|
|
14566
14635
|
setup(build) {
|
|
14567
14636
|
build.onLoad({ filter: /\.(ts|tsx|js|jsx)$/ }, (args) => {
|
|
14568
|
-
const fileName =
|
|
14637
|
+
const fileName = import_path28.default.basename(args.path);
|
|
14569
14638
|
const isServerFile = SERVER_FILES.some((f) => fileName === `${f}.ts` || fileName === `${f}.tsx` || fileName === `${f}.js` || fileName === `${f}.jsx`);
|
|
14570
|
-
const isInProjectRoot =
|
|
14639
|
+
const isInProjectRoot = import_path28.default.dirname(args.path) === projectRoot;
|
|
14571
14640
|
if (!isServerFile || !isInProjectRoot) {
|
|
14572
14641
|
return null;
|
|
14573
14642
|
}
|
|
14574
|
-
const contents =
|
|
14643
|
+
const contents = import_fs19.default.readFileSync(args.path, "utf-8");
|
|
14575
14644
|
let transformed = contents;
|
|
14576
14645
|
const aliasPatterns = Object.keys(aliases).sort((a, b) => b.length - a.length);
|
|
14577
14646
|
for (const aliasKey of aliasPatterns) {
|
|
@@ -14591,7 +14660,7 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
14591
14660
|
}
|
|
14592
14661
|
return {
|
|
14593
14662
|
contents: transformed,
|
|
14594
|
-
loader:
|
|
14663
|
+
loader: import_path28.default.extname(args.path).slice(1)
|
|
14595
14664
|
};
|
|
14596
14665
|
});
|
|
14597
14666
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
@@ -14610,9 +14679,9 @@ function createPathAliasPlugin(projectRoot, outDir) {
|
|
|
14610
14679
|
function collectAppSources(appDir) {
|
|
14611
14680
|
const entries = [];
|
|
14612
14681
|
function walk(dir) {
|
|
14613
|
-
const items =
|
|
14682
|
+
const items = import_fs19.default.readdirSync(dir, { withFileTypes: true });
|
|
14614
14683
|
for (const item of items) {
|
|
14615
|
-
const full =
|
|
14684
|
+
const full = import_path28.default.join(dir, item.name);
|
|
14616
14685
|
if (item.isDirectory()) {
|
|
14617
14686
|
walk(full);
|
|
14618
14687
|
continue;
|
|
@@ -14629,7 +14698,7 @@ function collectAppSources(appDir) {
|
|
|
14629
14698
|
return entries;
|
|
14630
14699
|
}
|
|
14631
14700
|
async function buildServerApp(projectRoot, appDir) {
|
|
14632
|
-
const outDir =
|
|
14701
|
+
const outDir = import_path28.default.join(projectRoot, BUILD_FOLDER_NAME, "server");
|
|
14633
14702
|
const entryPoints = collectAppSources(appDir);
|
|
14634
14703
|
ensureDir(outDir);
|
|
14635
14704
|
if (entryPoints.length === 0) {
|
|
@@ -14647,14 +14716,14 @@ async function buildServerApp(projectRoot, appDir) {
|
|
|
14647
14716
|
bundle: true,
|
|
14648
14717
|
splitting: false,
|
|
14649
14718
|
logLevel: "info",
|
|
14650
|
-
tsconfig:
|
|
14719
|
+
tsconfig: import_path28.default.join(projectRoot, "tsconfig.json"),
|
|
14651
14720
|
packages: "external"
|
|
14652
14721
|
});
|
|
14653
14722
|
const pathAliasPlugin = createPathAliasPlugin(projectRoot, outDir);
|
|
14654
14723
|
for (const fileName of SERVER_FILES) {
|
|
14655
|
-
const initTS =
|
|
14656
|
-
const initJS =
|
|
14657
|
-
if (
|
|
14724
|
+
const initTS = import_path28.default.join(projectRoot, `${fileName}.ts`);
|
|
14725
|
+
const initJS = import_path28.default.join(outDir, `${fileName}.js`);
|
|
14726
|
+
if (import_fs19.default.existsSync(initTS)) {
|
|
14658
14727
|
await import_esbuild.default.build({
|
|
14659
14728
|
entryPoints: [initTS],
|
|
14660
14729
|
outfile: initJS,
|
|
@@ -14665,7 +14734,7 @@ async function buildServerApp(projectRoot, appDir) {
|
|
|
14665
14734
|
sourcemap: true,
|
|
14666
14735
|
bundle: false,
|
|
14667
14736
|
logLevel: "info",
|
|
14668
|
-
tsconfig:
|
|
14737
|
+
tsconfig: import_path28.default.join(projectRoot, "tsconfig.json"),
|
|
14669
14738
|
plugins: [pathAliasPlugin]
|
|
14670
14739
|
});
|
|
14671
14740
|
}
|
|
@@ -14677,8 +14746,8 @@ async function buildServerApp(projectRoot, appDir) {
|
|
|
14677
14746
|
init_globals();
|
|
14678
14747
|
|
|
14679
14748
|
// src/config.ts
|
|
14680
|
-
var
|
|
14681
|
-
var
|
|
14749
|
+
var import_path29 = __toESM(require("path"));
|
|
14750
|
+
var import_fs20 = __toESM(require("fs"));
|
|
14682
14751
|
init_globals();
|
|
14683
14752
|
var DEFAULT_CONFIG2 = {
|
|
14684
14753
|
directories: {
|
|
@@ -14745,8 +14814,8 @@ function validateConfig(config, projectRoot) {
|
|
|
14745
14814
|
if (!config.directories.app || typeof config.directories.app !== "string") {
|
|
14746
14815
|
errors.push("config.directories.app must be a non-empty string");
|
|
14747
14816
|
} else {
|
|
14748
|
-
const appDir =
|
|
14749
|
-
if (!
|
|
14817
|
+
const appDir = import_path29.default.join(projectRoot, config.directories.app);
|
|
14818
|
+
if (!import_fs20.default.existsSync(appDir) && process.env.NODE_ENV !== "test") {
|
|
14750
14819
|
errors.push(
|
|
14751
14820
|
`App directory not found: ${config.directories.app}
|
|
14752
14821
|
Expected at: ${appDir}
|
|
@@ -14850,17 +14919,17 @@ function validateConfig(config, projectRoot) {
|
|
|
14850
14919
|
}
|
|
14851
14920
|
function loadConfig(projectRoot) {
|
|
14852
14921
|
const configFiles = [
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14922
|
+
import_path29.default.join(projectRoot, "loly.config.ts"),
|
|
14923
|
+
import_path29.default.join(projectRoot, "loly.config.js"),
|
|
14924
|
+
import_path29.default.join(projectRoot, "loly.config.json")
|
|
14856
14925
|
];
|
|
14857
14926
|
let userConfig = {};
|
|
14858
14927
|
let loadedConfigFile = null;
|
|
14859
14928
|
for (const configFile of configFiles) {
|
|
14860
|
-
if (
|
|
14929
|
+
if (import_fs20.default.existsSync(configFile)) {
|
|
14861
14930
|
try {
|
|
14862
14931
|
if (configFile.endsWith(".json")) {
|
|
14863
|
-
const content =
|
|
14932
|
+
const content = import_fs20.default.readFileSync(configFile, "utf-8");
|
|
14864
14933
|
userConfig = JSON.parse(content);
|
|
14865
14934
|
} else {
|
|
14866
14935
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -14869,12 +14938,12 @@ function loadConfig(projectRoot) {
|
|
|
14869
14938
|
const mod = require(configFile);
|
|
14870
14939
|
userConfig = typeof mod.default === "function" ? mod.default(process.env.NODE_ENV) : mod.default || mod.config || mod;
|
|
14871
14940
|
}
|
|
14872
|
-
loadedConfigFile =
|
|
14941
|
+
loadedConfigFile = import_path29.default.relative(projectRoot, configFile);
|
|
14873
14942
|
break;
|
|
14874
14943
|
} catch (error) {
|
|
14875
14944
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
14876
14945
|
throw new ConfigValidationError(
|
|
14877
|
-
`Failed to load configuration from ${
|
|
14946
|
+
`Failed to load configuration from ${import_path29.default.relative(projectRoot, configFile)}:
|
|
14878
14947
|
${errorMessage}
|
|
14879
14948
|
\u{1F4A1} Suggestion: Check that your config file exports a valid configuration object`
|
|
14880
14949
|
);
|
|
@@ -14898,13 +14967,13 @@ ${error.message}`;
|
|
|
14898
14967
|
return config;
|
|
14899
14968
|
}
|
|
14900
14969
|
function getAppDir(projectRoot, config) {
|
|
14901
|
-
return
|
|
14970
|
+
return import_path29.default.resolve(projectRoot, config.directories.app);
|
|
14902
14971
|
}
|
|
14903
14972
|
function getBuildDir(projectRoot, config) {
|
|
14904
|
-
return
|
|
14973
|
+
return import_path29.default.join(projectRoot, config.directories.build);
|
|
14905
14974
|
}
|
|
14906
14975
|
function getStaticDir(projectRoot, config) {
|
|
14907
|
-
return
|
|
14976
|
+
return import_path29.default.resolve(projectRoot, config.directories.static);
|
|
14908
14977
|
}
|
|
14909
14978
|
|
|
14910
14979
|
// modules/build/index.ts
|
|
@@ -14957,16 +15026,16 @@ async function buildApp(options = {}) {
|
|
|
14957
15026
|
}
|
|
14958
15027
|
|
|
14959
15028
|
// src/server.ts
|
|
14960
|
-
var
|
|
14961
|
-
var
|
|
15029
|
+
var import_fs24 = __toESM(require("fs"));
|
|
15030
|
+
var import_path34 = __toESM(require("path"));
|
|
14962
15031
|
|
|
14963
15032
|
// modules/server/setup.ts
|
|
14964
15033
|
var import_express = __toESM(require("express"));
|
|
14965
|
-
var
|
|
14966
|
-
var
|
|
15034
|
+
var import_path32 = __toESM(require("path"));
|
|
15035
|
+
var import_fs23 = __toESM(require("fs"));
|
|
14967
15036
|
|
|
14968
15037
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
14969
|
-
var
|
|
15038
|
+
var import_fs22 = require("fs");
|
|
14970
15039
|
var import_promises3 = require("fs/promises");
|
|
14971
15040
|
var import_events = require("events");
|
|
14972
15041
|
var sysPath2 = __toESM(require("path"), 1);
|
|
@@ -15041,7 +15110,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
15041
15110
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
15042
15111
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
15043
15112
|
if (wantBigintFsStats) {
|
|
15044
|
-
this._stat = (
|
|
15113
|
+
this._stat = (path32) => statMethod(path32, { bigint: true });
|
|
15045
15114
|
} else {
|
|
15046
15115
|
this._stat = statMethod;
|
|
15047
15116
|
}
|
|
@@ -15066,8 +15135,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
15066
15135
|
const par = this.parent;
|
|
15067
15136
|
const fil = par && par.files;
|
|
15068
15137
|
if (fil && fil.length > 0) {
|
|
15069
|
-
const { path:
|
|
15070
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
15138
|
+
const { path: path32, depth } = par;
|
|
15139
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path32));
|
|
15071
15140
|
const awaited = await Promise.all(slice);
|
|
15072
15141
|
for (const entry of awaited) {
|
|
15073
15142
|
if (!entry)
|
|
@@ -15107,20 +15176,20 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
15107
15176
|
this.reading = false;
|
|
15108
15177
|
}
|
|
15109
15178
|
}
|
|
15110
|
-
async _exploreDir(
|
|
15179
|
+
async _exploreDir(path32, depth) {
|
|
15111
15180
|
let files;
|
|
15112
15181
|
try {
|
|
15113
|
-
files = await (0, import_promises.readdir)(
|
|
15182
|
+
files = await (0, import_promises.readdir)(path32, this._rdOptions);
|
|
15114
15183
|
} catch (error) {
|
|
15115
15184
|
this._onError(error);
|
|
15116
15185
|
}
|
|
15117
|
-
return { files, depth, path:
|
|
15186
|
+
return { files, depth, path: path32 };
|
|
15118
15187
|
}
|
|
15119
|
-
async _formatEntry(dirent,
|
|
15188
|
+
async _formatEntry(dirent, path32) {
|
|
15120
15189
|
let entry;
|
|
15121
15190
|
const basename3 = this._isDirent ? dirent.name : dirent;
|
|
15122
15191
|
try {
|
|
15123
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
15192
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path32, basename3));
|
|
15124
15193
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename3 };
|
|
15125
15194
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
15126
15195
|
} catch (err) {
|
|
@@ -15191,7 +15260,7 @@ function readdirp(root, options = {}) {
|
|
|
15191
15260
|
}
|
|
15192
15261
|
|
|
15193
15262
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/handler.js
|
|
15194
|
-
var
|
|
15263
|
+
var import_fs21 = require("fs");
|
|
15195
15264
|
var import_promises2 = require("fs/promises");
|
|
15196
15265
|
var sysPath = __toESM(require("path"), 1);
|
|
15197
15266
|
var import_os = require("os");
|
|
@@ -15520,16 +15589,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
15520
15589
|
};
|
|
15521
15590
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
15522
15591
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
15523
|
-
function createFsWatchInstance(
|
|
15592
|
+
function createFsWatchInstance(path32, options, listener, errHandler, emitRaw) {
|
|
15524
15593
|
const handleEvent = (rawEvent, evPath) => {
|
|
15525
|
-
listener(
|
|
15526
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
15527
|
-
if (evPath &&
|
|
15528
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
15594
|
+
listener(path32);
|
|
15595
|
+
emitRaw(rawEvent, evPath, { watchedPath: path32 });
|
|
15596
|
+
if (evPath && path32 !== evPath) {
|
|
15597
|
+
fsWatchBroadcast(sysPath.resolve(path32, evPath), KEY_LISTENERS, sysPath.join(path32, evPath));
|
|
15529
15598
|
}
|
|
15530
15599
|
};
|
|
15531
15600
|
try {
|
|
15532
|
-
return (0,
|
|
15601
|
+
return (0, import_fs21.watch)(path32, {
|
|
15533
15602
|
persistent: options.persistent
|
|
15534
15603
|
}, handleEvent);
|
|
15535
15604
|
} catch (error) {
|
|
@@ -15545,12 +15614,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
15545
15614
|
listener(val1, val2, val3);
|
|
15546
15615
|
});
|
|
15547
15616
|
};
|
|
15548
|
-
var setFsWatchListener = (
|
|
15617
|
+
var setFsWatchListener = (path32, fullPath, options, handlers) => {
|
|
15549
15618
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
15550
15619
|
let cont = FsWatchInstances.get(fullPath);
|
|
15551
15620
|
let watcher;
|
|
15552
15621
|
if (!options.persistent) {
|
|
15553
|
-
watcher = createFsWatchInstance(
|
|
15622
|
+
watcher = createFsWatchInstance(path32, options, listener, errHandler, rawEmitter);
|
|
15554
15623
|
if (!watcher)
|
|
15555
15624
|
return;
|
|
15556
15625
|
return watcher.close.bind(watcher);
|
|
@@ -15561,7 +15630,7 @@ var setFsWatchListener = (path31, fullPath, options, handlers) => {
|
|
|
15561
15630
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
15562
15631
|
} else {
|
|
15563
15632
|
watcher = createFsWatchInstance(
|
|
15564
|
-
|
|
15633
|
+
path32,
|
|
15565
15634
|
options,
|
|
15566
15635
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
15567
15636
|
errHandler,
|
|
@@ -15576,7 +15645,7 @@ var setFsWatchListener = (path31, fullPath, options, handlers) => {
|
|
|
15576
15645
|
cont.watcherUnusable = true;
|
|
15577
15646
|
if (isWindows && error.code === "EPERM") {
|
|
15578
15647
|
try {
|
|
15579
|
-
const fd = await (0, import_promises2.open)(
|
|
15648
|
+
const fd = await (0, import_promises2.open)(path32, "r");
|
|
15580
15649
|
await fd.close();
|
|
15581
15650
|
broadcastErr(error);
|
|
15582
15651
|
} catch (err) {
|
|
@@ -15607,12 +15676,12 @@ var setFsWatchListener = (path31, fullPath, options, handlers) => {
|
|
|
15607
15676
|
};
|
|
15608
15677
|
};
|
|
15609
15678
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
15610
|
-
var setFsWatchFileListener = (
|
|
15679
|
+
var setFsWatchFileListener = (path32, fullPath, options, handlers) => {
|
|
15611
15680
|
const { listener, rawEmitter } = handlers;
|
|
15612
15681
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
15613
15682
|
const copts = cont && cont.options;
|
|
15614
15683
|
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
|
15615
|
-
(0,
|
|
15684
|
+
(0, import_fs21.unwatchFile)(fullPath);
|
|
15616
15685
|
cont = void 0;
|
|
15617
15686
|
}
|
|
15618
15687
|
if (cont) {
|
|
@@ -15623,13 +15692,13 @@ var setFsWatchFileListener = (path31, fullPath, options, handlers) => {
|
|
|
15623
15692
|
listeners: listener,
|
|
15624
15693
|
rawEmitters: rawEmitter,
|
|
15625
15694
|
options,
|
|
15626
|
-
watcher: (0,
|
|
15695
|
+
watcher: (0, import_fs21.watchFile)(fullPath, options, (curr, prev) => {
|
|
15627
15696
|
foreach(cont.rawEmitters, (rawEmitter2) => {
|
|
15628
15697
|
rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
|
|
15629
15698
|
});
|
|
15630
15699
|
const currmtime = curr.mtimeMs;
|
|
15631
15700
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
15632
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
15701
|
+
foreach(cont.listeners, (listener2) => listener2(path32, curr));
|
|
15633
15702
|
}
|
|
15634
15703
|
})
|
|
15635
15704
|
};
|
|
@@ -15640,7 +15709,7 @@ var setFsWatchFileListener = (path31, fullPath, options, handlers) => {
|
|
|
15640
15709
|
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
15641
15710
|
if (isEmptySet(cont.listeners)) {
|
|
15642
15711
|
FsWatchFileInstances.delete(fullPath);
|
|
15643
|
-
(0,
|
|
15712
|
+
(0, import_fs21.unwatchFile)(fullPath);
|
|
15644
15713
|
cont.options = cont.watcher = void 0;
|
|
15645
15714
|
Object.freeze(cont);
|
|
15646
15715
|
}
|
|
@@ -15657,13 +15726,13 @@ var NodeFsHandler = class {
|
|
|
15657
15726
|
* @param listener on fs change
|
|
15658
15727
|
* @returns closer for the watcher instance
|
|
15659
15728
|
*/
|
|
15660
|
-
_watchWithNodeFs(
|
|
15729
|
+
_watchWithNodeFs(path32, listener) {
|
|
15661
15730
|
const opts = this.fsw.options;
|
|
15662
|
-
const directory = sysPath.dirname(
|
|
15663
|
-
const basename3 = sysPath.basename(
|
|
15731
|
+
const directory = sysPath.dirname(path32);
|
|
15732
|
+
const basename3 = sysPath.basename(path32);
|
|
15664
15733
|
const parent = this.fsw._getWatchedDir(directory);
|
|
15665
15734
|
parent.add(basename3);
|
|
15666
|
-
const absolutePath = sysPath.resolve(
|
|
15735
|
+
const absolutePath = sysPath.resolve(path32);
|
|
15667
15736
|
const options = {
|
|
15668
15737
|
persistent: opts.persistent
|
|
15669
15738
|
};
|
|
@@ -15673,12 +15742,12 @@ var NodeFsHandler = class {
|
|
|
15673
15742
|
if (opts.usePolling) {
|
|
15674
15743
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
15675
15744
|
options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
|
|
15676
|
-
closer = setFsWatchFileListener(
|
|
15745
|
+
closer = setFsWatchFileListener(path32, absolutePath, options, {
|
|
15677
15746
|
listener,
|
|
15678
15747
|
rawEmitter: this.fsw._emitRaw
|
|
15679
15748
|
});
|
|
15680
15749
|
} else {
|
|
15681
|
-
closer = setFsWatchListener(
|
|
15750
|
+
closer = setFsWatchListener(path32, absolutePath, options, {
|
|
15682
15751
|
listener,
|
|
15683
15752
|
errHandler: this._boundHandleError,
|
|
15684
15753
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -15700,7 +15769,7 @@ var NodeFsHandler = class {
|
|
|
15700
15769
|
let prevStats = stats;
|
|
15701
15770
|
if (parent.has(basename3))
|
|
15702
15771
|
return;
|
|
15703
|
-
const listener = async (
|
|
15772
|
+
const listener = async (path32, newStats) => {
|
|
15704
15773
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
15705
15774
|
return;
|
|
15706
15775
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -15714,11 +15783,11 @@ var NodeFsHandler = class {
|
|
|
15714
15783
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
15715
15784
|
}
|
|
15716
15785
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
15717
|
-
this.fsw._closeFile(
|
|
15786
|
+
this.fsw._closeFile(path32);
|
|
15718
15787
|
prevStats = newStats2;
|
|
15719
15788
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
15720
15789
|
if (closer2)
|
|
15721
|
-
this.fsw._addPathCloser(
|
|
15790
|
+
this.fsw._addPathCloser(path32, closer2);
|
|
15722
15791
|
} else {
|
|
15723
15792
|
prevStats = newStats2;
|
|
15724
15793
|
}
|
|
@@ -15750,7 +15819,7 @@ var NodeFsHandler = class {
|
|
|
15750
15819
|
* @param item basename of this item
|
|
15751
15820
|
* @returns true if no more processing is needed for this entry.
|
|
15752
15821
|
*/
|
|
15753
|
-
async _handleSymlink(entry, directory,
|
|
15822
|
+
async _handleSymlink(entry, directory, path32, item) {
|
|
15754
15823
|
if (this.fsw.closed) {
|
|
15755
15824
|
return;
|
|
15756
15825
|
}
|
|
@@ -15760,7 +15829,7 @@ var NodeFsHandler = class {
|
|
|
15760
15829
|
this.fsw._incrReadyCount();
|
|
15761
15830
|
let linkPath;
|
|
15762
15831
|
try {
|
|
15763
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
15832
|
+
linkPath = await (0, import_promises2.realpath)(path32);
|
|
15764
15833
|
} catch (e) {
|
|
15765
15834
|
this.fsw._emitReady();
|
|
15766
15835
|
return true;
|
|
@@ -15770,12 +15839,12 @@ var NodeFsHandler = class {
|
|
|
15770
15839
|
if (dir.has(item)) {
|
|
15771
15840
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
15772
15841
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
15773
|
-
this.fsw._emit(EV.CHANGE,
|
|
15842
|
+
this.fsw._emit(EV.CHANGE, path32, entry.stats);
|
|
15774
15843
|
}
|
|
15775
15844
|
} else {
|
|
15776
15845
|
dir.add(item);
|
|
15777
15846
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
15778
|
-
this.fsw._emit(EV.ADD,
|
|
15847
|
+
this.fsw._emit(EV.ADD, path32, entry.stats);
|
|
15779
15848
|
}
|
|
15780
15849
|
this.fsw._emitReady();
|
|
15781
15850
|
return true;
|
|
@@ -15804,9 +15873,9 @@ var NodeFsHandler = class {
|
|
|
15804
15873
|
return;
|
|
15805
15874
|
}
|
|
15806
15875
|
const item = entry.path;
|
|
15807
|
-
let
|
|
15876
|
+
let path32 = sysPath.join(directory, item);
|
|
15808
15877
|
current.add(item);
|
|
15809
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
15878
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path32, item)) {
|
|
15810
15879
|
return;
|
|
15811
15880
|
}
|
|
15812
15881
|
if (this.fsw.closed) {
|
|
@@ -15815,8 +15884,8 @@ var NodeFsHandler = class {
|
|
|
15815
15884
|
}
|
|
15816
15885
|
if (item === target || !target && !previous.has(item)) {
|
|
15817
15886
|
this.fsw._incrReadyCount();
|
|
15818
|
-
|
|
15819
|
-
this._addToNodeFs(
|
|
15887
|
+
path32 = sysPath.join(dir, sysPath.relative(dir, path32));
|
|
15888
|
+
this._addToNodeFs(path32, initialAdd, wh, depth + 1);
|
|
15820
15889
|
}
|
|
15821
15890
|
}).on(EV.ERROR, this._boundHandleError);
|
|
15822
15891
|
return new Promise((resolve3, reject) => {
|
|
@@ -15885,13 +15954,13 @@ var NodeFsHandler = class {
|
|
|
15885
15954
|
* @param depth Child path actually targeted for watch
|
|
15886
15955
|
* @param target Child path actually targeted for watch
|
|
15887
15956
|
*/
|
|
15888
|
-
async _addToNodeFs(
|
|
15957
|
+
async _addToNodeFs(path32, initialAdd, priorWh, depth, target) {
|
|
15889
15958
|
const ready = this.fsw._emitReady;
|
|
15890
|
-
if (this.fsw._isIgnored(
|
|
15959
|
+
if (this.fsw._isIgnored(path32) || this.fsw.closed) {
|
|
15891
15960
|
ready();
|
|
15892
15961
|
return false;
|
|
15893
15962
|
}
|
|
15894
|
-
const wh = this.fsw._getWatchHelpers(
|
|
15963
|
+
const wh = this.fsw._getWatchHelpers(path32);
|
|
15895
15964
|
if (priorWh) {
|
|
15896
15965
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
15897
15966
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -15907,8 +15976,8 @@ var NodeFsHandler = class {
|
|
|
15907
15976
|
const follow = this.fsw.options.followSymlinks;
|
|
15908
15977
|
let closer;
|
|
15909
15978
|
if (stats.isDirectory()) {
|
|
15910
|
-
const absPath = sysPath.resolve(
|
|
15911
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
15979
|
+
const absPath = sysPath.resolve(path32);
|
|
15980
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path32) : path32;
|
|
15912
15981
|
if (this.fsw.closed)
|
|
15913
15982
|
return;
|
|
15914
15983
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -15918,29 +15987,29 @@ var NodeFsHandler = class {
|
|
|
15918
15987
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
15919
15988
|
}
|
|
15920
15989
|
} else if (stats.isSymbolicLink()) {
|
|
15921
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
15990
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path32) : path32;
|
|
15922
15991
|
if (this.fsw.closed)
|
|
15923
15992
|
return;
|
|
15924
15993
|
const parent = sysPath.dirname(wh.watchPath);
|
|
15925
15994
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
15926
15995
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
15927
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
15996
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path32, wh, targetPath);
|
|
15928
15997
|
if (this.fsw.closed)
|
|
15929
15998
|
return;
|
|
15930
15999
|
if (targetPath !== void 0) {
|
|
15931
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
16000
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path32), targetPath);
|
|
15932
16001
|
}
|
|
15933
16002
|
} else {
|
|
15934
16003
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
15935
16004
|
}
|
|
15936
16005
|
ready();
|
|
15937
16006
|
if (closer)
|
|
15938
|
-
this.fsw._addPathCloser(
|
|
16007
|
+
this.fsw._addPathCloser(path32, closer);
|
|
15939
16008
|
return false;
|
|
15940
16009
|
} catch (error) {
|
|
15941
16010
|
if (this.fsw._handleError(error)) {
|
|
15942
16011
|
ready();
|
|
15943
|
-
return
|
|
16012
|
+
return path32;
|
|
15944
16013
|
}
|
|
15945
16014
|
}
|
|
15946
16015
|
}
|
|
@@ -15983,26 +16052,26 @@ function createPattern(matcher) {
|
|
|
15983
16052
|
}
|
|
15984
16053
|
return () => false;
|
|
15985
16054
|
}
|
|
15986
|
-
function normalizePath(
|
|
15987
|
-
if (typeof
|
|
16055
|
+
function normalizePath(path32) {
|
|
16056
|
+
if (typeof path32 !== "string")
|
|
15988
16057
|
throw new Error("string expected");
|
|
15989
|
-
|
|
15990
|
-
|
|
16058
|
+
path32 = sysPath2.normalize(path32);
|
|
16059
|
+
path32 = path32.replace(/\\/g, "/");
|
|
15991
16060
|
let prepend = false;
|
|
15992
|
-
if (
|
|
16061
|
+
if (path32.startsWith("//"))
|
|
15993
16062
|
prepend = true;
|
|
15994
16063
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
15995
|
-
while (
|
|
15996
|
-
|
|
16064
|
+
while (path32.match(DOUBLE_SLASH_RE2))
|
|
16065
|
+
path32 = path32.replace(DOUBLE_SLASH_RE2, "/");
|
|
15997
16066
|
if (prepend)
|
|
15998
|
-
|
|
15999
|
-
return
|
|
16067
|
+
path32 = "/" + path32;
|
|
16068
|
+
return path32;
|
|
16000
16069
|
}
|
|
16001
16070
|
function matchPatterns(patterns, testString, stats) {
|
|
16002
|
-
const
|
|
16071
|
+
const path32 = normalizePath(testString);
|
|
16003
16072
|
for (let index = 0; index < patterns.length; index++) {
|
|
16004
16073
|
const pattern = patterns[index];
|
|
16005
|
-
if (pattern(
|
|
16074
|
+
if (pattern(path32, stats)) {
|
|
16006
16075
|
return true;
|
|
16007
16076
|
}
|
|
16008
16077
|
}
|
|
@@ -16042,19 +16111,19 @@ var toUnix = (string) => {
|
|
|
16042
16111
|
}
|
|
16043
16112
|
return str;
|
|
16044
16113
|
};
|
|
16045
|
-
var normalizePathToUnix = (
|
|
16046
|
-
var normalizeIgnored = (cwd = "") => (
|
|
16047
|
-
if (typeof
|
|
16048
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
16114
|
+
var normalizePathToUnix = (path32) => toUnix(sysPath2.normalize(toUnix(path32)));
|
|
16115
|
+
var normalizeIgnored = (cwd = "") => (path32) => {
|
|
16116
|
+
if (typeof path32 === "string") {
|
|
16117
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path32) ? path32 : sysPath2.join(cwd, path32));
|
|
16049
16118
|
} else {
|
|
16050
|
-
return
|
|
16119
|
+
return path32;
|
|
16051
16120
|
}
|
|
16052
16121
|
};
|
|
16053
|
-
var getAbsolutePath = (
|
|
16054
|
-
if (sysPath2.isAbsolute(
|
|
16055
|
-
return
|
|
16122
|
+
var getAbsolutePath = (path32, cwd) => {
|
|
16123
|
+
if (sysPath2.isAbsolute(path32)) {
|
|
16124
|
+
return path32;
|
|
16056
16125
|
}
|
|
16057
|
-
return sysPath2.join(cwd,
|
|
16126
|
+
return sysPath2.join(cwd, path32);
|
|
16058
16127
|
};
|
|
16059
16128
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
16060
16129
|
var DirEntry = class {
|
|
@@ -16109,10 +16178,10 @@ var DirEntry = class {
|
|
|
16109
16178
|
var STAT_METHOD_F = "stat";
|
|
16110
16179
|
var STAT_METHOD_L = "lstat";
|
|
16111
16180
|
var WatchHelper = class {
|
|
16112
|
-
constructor(
|
|
16181
|
+
constructor(path32, follow, fsw) {
|
|
16113
16182
|
this.fsw = fsw;
|
|
16114
|
-
const watchPath =
|
|
16115
|
-
this.path =
|
|
16183
|
+
const watchPath = path32;
|
|
16184
|
+
this.path = path32 = path32.replace(REPLACER_RE, "");
|
|
16116
16185
|
this.watchPath = watchPath;
|
|
16117
16186
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
16118
16187
|
this.dirParts = [];
|
|
@@ -16234,20 +16303,20 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16234
16303
|
this._closePromise = void 0;
|
|
16235
16304
|
let paths = unifyPaths(paths_);
|
|
16236
16305
|
if (cwd) {
|
|
16237
|
-
paths = paths.map((
|
|
16238
|
-
const absPath = getAbsolutePath(
|
|
16306
|
+
paths = paths.map((path32) => {
|
|
16307
|
+
const absPath = getAbsolutePath(path32, cwd);
|
|
16239
16308
|
return absPath;
|
|
16240
16309
|
});
|
|
16241
16310
|
}
|
|
16242
|
-
paths.forEach((
|
|
16243
|
-
this._removeIgnoredPath(
|
|
16311
|
+
paths.forEach((path32) => {
|
|
16312
|
+
this._removeIgnoredPath(path32);
|
|
16244
16313
|
});
|
|
16245
16314
|
this._userIgnored = void 0;
|
|
16246
16315
|
if (!this._readyCount)
|
|
16247
16316
|
this._readyCount = 0;
|
|
16248
16317
|
this._readyCount += paths.length;
|
|
16249
|
-
Promise.all(paths.map(async (
|
|
16250
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
16318
|
+
Promise.all(paths.map(async (path32) => {
|
|
16319
|
+
const res = await this._nodeFsHandler._addToNodeFs(path32, !_internal, void 0, 0, _origAdd);
|
|
16251
16320
|
if (res)
|
|
16252
16321
|
this._emitReady();
|
|
16253
16322
|
return res;
|
|
@@ -16269,17 +16338,17 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16269
16338
|
return this;
|
|
16270
16339
|
const paths = unifyPaths(paths_);
|
|
16271
16340
|
const { cwd } = this.options;
|
|
16272
|
-
paths.forEach((
|
|
16273
|
-
if (!sysPath2.isAbsolute(
|
|
16341
|
+
paths.forEach((path32) => {
|
|
16342
|
+
if (!sysPath2.isAbsolute(path32) && !this._closers.has(path32)) {
|
|
16274
16343
|
if (cwd)
|
|
16275
|
-
|
|
16276
|
-
|
|
16344
|
+
path32 = sysPath2.join(cwd, path32);
|
|
16345
|
+
path32 = sysPath2.resolve(path32);
|
|
16277
16346
|
}
|
|
16278
|
-
this._closePath(
|
|
16279
|
-
this._addIgnoredPath(
|
|
16280
|
-
if (this._watched.has(
|
|
16347
|
+
this._closePath(path32);
|
|
16348
|
+
this._addIgnoredPath(path32);
|
|
16349
|
+
if (this._watched.has(path32)) {
|
|
16281
16350
|
this._addIgnoredPath({
|
|
16282
|
-
path:
|
|
16351
|
+
path: path32,
|
|
16283
16352
|
recursive: true
|
|
16284
16353
|
});
|
|
16285
16354
|
}
|
|
@@ -16343,38 +16412,38 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16343
16412
|
* @param stats arguments to be passed with event
|
|
16344
16413
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
16345
16414
|
*/
|
|
16346
|
-
async _emit(event,
|
|
16415
|
+
async _emit(event, path32, stats) {
|
|
16347
16416
|
if (this.closed)
|
|
16348
16417
|
return;
|
|
16349
16418
|
const opts = this.options;
|
|
16350
16419
|
if (isWindows)
|
|
16351
|
-
|
|
16420
|
+
path32 = sysPath2.normalize(path32);
|
|
16352
16421
|
if (opts.cwd)
|
|
16353
|
-
|
|
16354
|
-
const args = [
|
|
16422
|
+
path32 = sysPath2.relative(opts.cwd, path32);
|
|
16423
|
+
const args = [path32];
|
|
16355
16424
|
if (stats != null)
|
|
16356
16425
|
args.push(stats);
|
|
16357
16426
|
const awf = opts.awaitWriteFinish;
|
|
16358
16427
|
let pw;
|
|
16359
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
16428
|
+
if (awf && (pw = this._pendingWrites.get(path32))) {
|
|
16360
16429
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
16361
16430
|
return this;
|
|
16362
16431
|
}
|
|
16363
16432
|
if (opts.atomic) {
|
|
16364
16433
|
if (event === EVENTS.UNLINK) {
|
|
16365
|
-
this._pendingUnlinks.set(
|
|
16434
|
+
this._pendingUnlinks.set(path32, [event, ...args]);
|
|
16366
16435
|
setTimeout(() => {
|
|
16367
|
-
this._pendingUnlinks.forEach((entry,
|
|
16436
|
+
this._pendingUnlinks.forEach((entry, path33) => {
|
|
16368
16437
|
this.emit(...entry);
|
|
16369
16438
|
this.emit(EVENTS.ALL, ...entry);
|
|
16370
|
-
this._pendingUnlinks.delete(
|
|
16439
|
+
this._pendingUnlinks.delete(path33);
|
|
16371
16440
|
});
|
|
16372
16441
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
16373
16442
|
return this;
|
|
16374
16443
|
}
|
|
16375
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
16444
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path32)) {
|
|
16376
16445
|
event = EVENTS.CHANGE;
|
|
16377
|
-
this._pendingUnlinks.delete(
|
|
16446
|
+
this._pendingUnlinks.delete(path32);
|
|
16378
16447
|
}
|
|
16379
16448
|
}
|
|
16380
16449
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -16392,16 +16461,16 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16392
16461
|
this.emitWithAll(event, args);
|
|
16393
16462
|
}
|
|
16394
16463
|
};
|
|
16395
|
-
this._awaitWriteFinish(
|
|
16464
|
+
this._awaitWriteFinish(path32, awf.stabilityThreshold, event, awfEmit);
|
|
16396
16465
|
return this;
|
|
16397
16466
|
}
|
|
16398
16467
|
if (event === EVENTS.CHANGE) {
|
|
16399
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
16468
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path32, 50);
|
|
16400
16469
|
if (isThrottled)
|
|
16401
16470
|
return this;
|
|
16402
16471
|
}
|
|
16403
16472
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
16404
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
16473
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path32) : path32;
|
|
16405
16474
|
let stats2;
|
|
16406
16475
|
try {
|
|
16407
16476
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -16432,23 +16501,23 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16432
16501
|
* @param timeout duration of time to suppress duplicate actions
|
|
16433
16502
|
* @returns tracking object or false if action should be suppressed
|
|
16434
16503
|
*/
|
|
16435
|
-
_throttle(actionType,
|
|
16504
|
+
_throttle(actionType, path32, timeout) {
|
|
16436
16505
|
if (!this._throttled.has(actionType)) {
|
|
16437
16506
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
16438
16507
|
}
|
|
16439
16508
|
const action = this._throttled.get(actionType);
|
|
16440
16509
|
if (!action)
|
|
16441
16510
|
throw new Error("invalid throttle");
|
|
16442
|
-
const actionPath = action.get(
|
|
16511
|
+
const actionPath = action.get(path32);
|
|
16443
16512
|
if (actionPath) {
|
|
16444
16513
|
actionPath.count++;
|
|
16445
16514
|
return false;
|
|
16446
16515
|
}
|
|
16447
16516
|
let timeoutObject;
|
|
16448
16517
|
const clear = () => {
|
|
16449
|
-
const item = action.get(
|
|
16518
|
+
const item = action.get(path32);
|
|
16450
16519
|
const count = item ? item.count : 0;
|
|
16451
|
-
action.delete(
|
|
16520
|
+
action.delete(path32);
|
|
16452
16521
|
clearTimeout(timeoutObject);
|
|
16453
16522
|
if (item)
|
|
16454
16523
|
clearTimeout(item.timeoutObject);
|
|
@@ -16456,7 +16525,7 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16456
16525
|
};
|
|
16457
16526
|
timeoutObject = setTimeout(clear, timeout);
|
|
16458
16527
|
const thr = { timeoutObject, clear, count: 0 };
|
|
16459
|
-
action.set(
|
|
16528
|
+
action.set(path32, thr);
|
|
16460
16529
|
return thr;
|
|
16461
16530
|
}
|
|
16462
16531
|
_incrReadyCount() {
|
|
@@ -16470,44 +16539,44 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16470
16539
|
* @param event
|
|
16471
16540
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
16472
16541
|
*/
|
|
16473
|
-
_awaitWriteFinish(
|
|
16542
|
+
_awaitWriteFinish(path32, threshold, event, awfEmit) {
|
|
16474
16543
|
const awf = this.options.awaitWriteFinish;
|
|
16475
16544
|
if (typeof awf !== "object")
|
|
16476
16545
|
return;
|
|
16477
16546
|
const pollInterval = awf.pollInterval;
|
|
16478
16547
|
let timeoutHandler;
|
|
16479
|
-
let fullPath =
|
|
16480
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
16481
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
16548
|
+
let fullPath = path32;
|
|
16549
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path32)) {
|
|
16550
|
+
fullPath = sysPath2.join(this.options.cwd, path32);
|
|
16482
16551
|
}
|
|
16483
16552
|
const now = /* @__PURE__ */ new Date();
|
|
16484
16553
|
const writes = this._pendingWrites;
|
|
16485
16554
|
function awaitWriteFinishFn(prevStat) {
|
|
16486
|
-
(0,
|
|
16487
|
-
if (err || !writes.has(
|
|
16555
|
+
(0, import_fs22.stat)(fullPath, (err, curStat) => {
|
|
16556
|
+
if (err || !writes.has(path32)) {
|
|
16488
16557
|
if (err && err.code !== "ENOENT")
|
|
16489
16558
|
awfEmit(err);
|
|
16490
16559
|
return;
|
|
16491
16560
|
}
|
|
16492
16561
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
16493
16562
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
16494
|
-
writes.get(
|
|
16563
|
+
writes.get(path32).lastChange = now2;
|
|
16495
16564
|
}
|
|
16496
|
-
const pw = writes.get(
|
|
16565
|
+
const pw = writes.get(path32);
|
|
16497
16566
|
const df = now2 - pw.lastChange;
|
|
16498
16567
|
if (df >= threshold) {
|
|
16499
|
-
writes.delete(
|
|
16568
|
+
writes.delete(path32);
|
|
16500
16569
|
awfEmit(void 0, curStat);
|
|
16501
16570
|
} else {
|
|
16502
16571
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
16503
16572
|
}
|
|
16504
16573
|
});
|
|
16505
16574
|
}
|
|
16506
|
-
if (!writes.has(
|
|
16507
|
-
writes.set(
|
|
16575
|
+
if (!writes.has(path32)) {
|
|
16576
|
+
writes.set(path32, {
|
|
16508
16577
|
lastChange: now,
|
|
16509
16578
|
cancelWait: () => {
|
|
16510
|
-
writes.delete(
|
|
16579
|
+
writes.delete(path32);
|
|
16511
16580
|
clearTimeout(timeoutHandler);
|
|
16512
16581
|
return event;
|
|
16513
16582
|
}
|
|
@@ -16518,8 +16587,8 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16518
16587
|
/**
|
|
16519
16588
|
* Determines whether user has asked to ignore this path.
|
|
16520
16589
|
*/
|
|
16521
|
-
_isIgnored(
|
|
16522
|
-
if (this.options.atomic && DOT_RE.test(
|
|
16590
|
+
_isIgnored(path32, stats) {
|
|
16591
|
+
if (this.options.atomic && DOT_RE.test(path32))
|
|
16523
16592
|
return true;
|
|
16524
16593
|
if (!this._userIgnored) {
|
|
16525
16594
|
const { cwd } = this.options;
|
|
@@ -16529,17 +16598,17 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16529
16598
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
16530
16599
|
this._userIgnored = anymatch(list, void 0);
|
|
16531
16600
|
}
|
|
16532
|
-
return this._userIgnored(
|
|
16601
|
+
return this._userIgnored(path32, stats);
|
|
16533
16602
|
}
|
|
16534
|
-
_isntIgnored(
|
|
16535
|
-
return !this._isIgnored(
|
|
16603
|
+
_isntIgnored(path32, stat4) {
|
|
16604
|
+
return !this._isIgnored(path32, stat4);
|
|
16536
16605
|
}
|
|
16537
16606
|
/**
|
|
16538
16607
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
16539
16608
|
* @param path file or directory pattern being watched
|
|
16540
16609
|
*/
|
|
16541
|
-
_getWatchHelpers(
|
|
16542
|
-
return new WatchHelper(
|
|
16610
|
+
_getWatchHelpers(path32) {
|
|
16611
|
+
return new WatchHelper(path32, this.options.followSymlinks, this);
|
|
16543
16612
|
}
|
|
16544
16613
|
// Directory helpers
|
|
16545
16614
|
// -----------------
|
|
@@ -16571,63 +16640,63 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
16571
16640
|
* @param item base path of item/directory
|
|
16572
16641
|
*/
|
|
16573
16642
|
_remove(directory, item, isDirectory) {
|
|
16574
|
-
const
|
|
16575
|
-
const fullPath = sysPath2.resolve(
|
|
16576
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
16577
|
-
if (!this._throttle("remove",
|
|
16643
|
+
const path32 = sysPath2.join(directory, item);
|
|
16644
|
+
const fullPath = sysPath2.resolve(path32);
|
|
16645
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path32) || this._watched.has(fullPath);
|
|
16646
|
+
if (!this._throttle("remove", path32, 100))
|
|
16578
16647
|
return;
|
|
16579
16648
|
if (!isDirectory && this._watched.size === 1) {
|
|
16580
16649
|
this.add(directory, item, true);
|
|
16581
16650
|
}
|
|
16582
|
-
const wp = this._getWatchedDir(
|
|
16651
|
+
const wp = this._getWatchedDir(path32);
|
|
16583
16652
|
const nestedDirectoryChildren = wp.getChildren();
|
|
16584
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
16653
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path32, nested));
|
|
16585
16654
|
const parent = this._getWatchedDir(directory);
|
|
16586
16655
|
const wasTracked = parent.has(item);
|
|
16587
16656
|
parent.remove(item);
|
|
16588
16657
|
if (this._symlinkPaths.has(fullPath)) {
|
|
16589
16658
|
this._symlinkPaths.delete(fullPath);
|
|
16590
16659
|
}
|
|
16591
|
-
let relPath =
|
|
16660
|
+
let relPath = path32;
|
|
16592
16661
|
if (this.options.cwd)
|
|
16593
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
16662
|
+
relPath = sysPath2.relative(this.options.cwd, path32);
|
|
16594
16663
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
16595
16664
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
16596
16665
|
if (event === EVENTS.ADD)
|
|
16597
16666
|
return;
|
|
16598
16667
|
}
|
|
16599
|
-
this._watched.delete(
|
|
16668
|
+
this._watched.delete(path32);
|
|
16600
16669
|
this._watched.delete(fullPath);
|
|
16601
16670
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
16602
|
-
if (wasTracked && !this._isIgnored(
|
|
16603
|
-
this._emit(eventName,
|
|
16604
|
-
this._closePath(
|
|
16671
|
+
if (wasTracked && !this._isIgnored(path32))
|
|
16672
|
+
this._emit(eventName, path32);
|
|
16673
|
+
this._closePath(path32);
|
|
16605
16674
|
}
|
|
16606
16675
|
/**
|
|
16607
16676
|
* Closes all watchers for a path
|
|
16608
16677
|
*/
|
|
16609
|
-
_closePath(
|
|
16610
|
-
this._closeFile(
|
|
16611
|
-
const dir = sysPath2.dirname(
|
|
16612
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
16678
|
+
_closePath(path32) {
|
|
16679
|
+
this._closeFile(path32);
|
|
16680
|
+
const dir = sysPath2.dirname(path32);
|
|
16681
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path32));
|
|
16613
16682
|
}
|
|
16614
16683
|
/**
|
|
16615
16684
|
* Closes only file-specific watchers
|
|
16616
16685
|
*/
|
|
16617
|
-
_closeFile(
|
|
16618
|
-
const closers = this._closers.get(
|
|
16686
|
+
_closeFile(path32) {
|
|
16687
|
+
const closers = this._closers.get(path32);
|
|
16619
16688
|
if (!closers)
|
|
16620
16689
|
return;
|
|
16621
16690
|
closers.forEach((closer) => closer());
|
|
16622
|
-
this._closers.delete(
|
|
16691
|
+
this._closers.delete(path32);
|
|
16623
16692
|
}
|
|
16624
|
-
_addPathCloser(
|
|
16693
|
+
_addPathCloser(path32, closer) {
|
|
16625
16694
|
if (!closer)
|
|
16626
16695
|
return;
|
|
16627
|
-
let list = this._closers.get(
|
|
16696
|
+
let list = this._closers.get(path32);
|
|
16628
16697
|
if (!list) {
|
|
16629
16698
|
list = [];
|
|
16630
|
-
this._closers.set(
|
|
16699
|
+
this._closers.set(path32, list);
|
|
16631
16700
|
}
|
|
16632
16701
|
list.push(closer);
|
|
16633
16702
|
}
|
|
@@ -16657,7 +16726,7 @@ function watch(paths, options = {}) {
|
|
|
16657
16726
|
var esm_default = { watch, FSWatcher };
|
|
16658
16727
|
|
|
16659
16728
|
// modules/dev/hot-reload-client/index.ts
|
|
16660
|
-
var
|
|
16729
|
+
var import_path30 = __toESM(require("path"));
|
|
16661
16730
|
init_globals();
|
|
16662
16731
|
function setupHotReload({
|
|
16663
16732
|
app,
|
|
@@ -16699,7 +16768,7 @@ function setupHotReload({
|
|
|
16699
16768
|
});
|
|
16700
16769
|
});
|
|
16701
16770
|
console.log(`[hot-reload-server] \u2705 SSE endpoint registered at ${route}`);
|
|
16702
|
-
const resolvedProjectRoot = projectRoot ?
|
|
16771
|
+
const resolvedProjectRoot = projectRoot ? import_path30.default.resolve(projectRoot) : import_path30.default.dirname(import_path30.default.resolve(appDir));
|
|
16703
16772
|
const watcher = esm_default.watch(resolvedProjectRoot, {
|
|
16704
16773
|
ignoreInitial: true,
|
|
16705
16774
|
ignored: [
|
|
@@ -16739,11 +16808,11 @@ function setupHotReload({
|
|
|
16739
16808
|
let broadcastTimeout = null;
|
|
16740
16809
|
const BROADCAST_DEBOUNCE_MS = 300;
|
|
16741
16810
|
async function broadcastReload(reason, filePath) {
|
|
16742
|
-
const normalizedPath =
|
|
16811
|
+
const normalizedPath = import_path30.default.normalize(filePath);
|
|
16743
16812
|
if (normalizedPath.includes(BUILD_FOLDER_NAME) || normalizedPath.includes(".loly") || normalizedPath.endsWith(".map") || normalizedPath.endsWith(".log") || normalizedPath.includes("route-chunks.json") || normalizedPath.includes("routes-client.ts") || normalizedPath.includes("/client/route-")) {
|
|
16744
16813
|
return;
|
|
16745
16814
|
}
|
|
16746
|
-
const rel =
|
|
16815
|
+
const rel = import_path30.default.relative(appDir, filePath);
|
|
16747
16816
|
console.log(`[hot-reload] ${reason}: ${rel}`);
|
|
16748
16817
|
if (broadcastTimeout) {
|
|
16749
16818
|
clearTimeout(broadcastTimeout);
|
|
@@ -16793,9 +16862,9 @@ data: reload:${rel}
|
|
|
16793
16862
|
}
|
|
16794
16863
|
|
|
16795
16864
|
// modules/dev/hot-reload-server/index.ts
|
|
16796
|
-
var
|
|
16865
|
+
var import_path31 = __toESM(require("path"));
|
|
16797
16866
|
function clearAppRequireCache(appDir) {
|
|
16798
|
-
const appDirNormalized =
|
|
16867
|
+
const appDirNormalized = import_path31.default.resolve(appDir);
|
|
16799
16868
|
for (const id of Object.keys(require.cache)) {
|
|
16800
16869
|
if (id.startsWith(appDirNormalized)) {
|
|
16801
16870
|
delete require.cache[id];
|
|
@@ -16808,7 +16877,7 @@ init_globals();
|
|
|
16808
16877
|
function setupStaticFiles(app, projectRoot, config) {
|
|
16809
16878
|
if (!config) return;
|
|
16810
16879
|
const staticDir = getStaticDir(projectRoot, config);
|
|
16811
|
-
if (
|
|
16880
|
+
if (import_fs23.default.existsSync(staticDir)) {
|
|
16812
16881
|
app.use(
|
|
16813
16882
|
import_express.default.static(staticDir, {
|
|
16814
16883
|
// In production, add caching headers for better performance
|
|
@@ -16834,7 +16903,7 @@ function setupServer(app, options) {
|
|
|
16834
16903
|
var getRoutes = getRoutes2;
|
|
16835
16904
|
const { outDir, waitForBuild } = startClientBundler(projectRoot, "development");
|
|
16836
16905
|
const onFileChange = async (filePath) => {
|
|
16837
|
-
const rel =
|
|
16906
|
+
const rel = import_path32.default.relative(appDir, filePath);
|
|
16838
16907
|
const isPageFile = filePath.includes("page.tsx") || filePath.includes("page.ts") || filePath.includes("layout.tsx") || filePath.includes("layout.ts") || filePath.includes("_not-found") || filePath.includes("_error");
|
|
16839
16908
|
const isTsFile = filePath.endsWith(".ts") || filePath.endsWith(".tsx");
|
|
16840
16909
|
if (isTsFile) {
|
|
@@ -16870,8 +16939,8 @@ function setupServer(app, options) {
|
|
|
16870
16939
|
const wssRoutes = routeLoader.loadWssRoutes();
|
|
16871
16940
|
const notFoundPage = routeLoader.loadNotFoundRoute();
|
|
16872
16941
|
const errorPage = routeLoader.loadErrorRoute();
|
|
16873
|
-
const buildDir = config ? getBuildDir(projectRoot, config) :
|
|
16874
|
-
const clientOutDir =
|
|
16942
|
+
const buildDir = config ? getBuildDir(projectRoot, config) : import_path32.default.join(projectRoot, BUILD_FOLDER_NAME);
|
|
16943
|
+
const clientOutDir = import_path32.default.join(buildDir, "client");
|
|
16875
16944
|
app.use(
|
|
16876
16945
|
"/static",
|
|
16877
16946
|
import_express.default.static(clientOutDir, {
|
|
@@ -16998,11 +17067,11 @@ function createStrictRateLimiterFromConfig(config) {
|
|
|
16998
17067
|
}
|
|
16999
17068
|
|
|
17000
17069
|
// modules/server/middleware/auto-rate-limit.ts
|
|
17001
|
-
function matchesStrictPattern(
|
|
17070
|
+
function matchesStrictPattern(path32, patterns) {
|
|
17002
17071
|
for (const pattern of patterns) {
|
|
17003
17072
|
const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
|
|
17004
17073
|
const regex = new RegExp(`^${regexPattern}$`);
|
|
17005
|
-
if (regex.test(
|
|
17074
|
+
if (regex.test(path32)) {
|
|
17006
17075
|
return true;
|
|
17007
17076
|
}
|
|
17008
17077
|
}
|
|
@@ -17167,7 +17236,7 @@ async function handleApiRequest(options) {
|
|
|
17167
17236
|
|
|
17168
17237
|
// modules/server/routes.ts
|
|
17169
17238
|
init_globals();
|
|
17170
|
-
var
|
|
17239
|
+
var import_path33 = __toESM(require("path"));
|
|
17171
17240
|
var cachedRewriteLoader = null;
|
|
17172
17241
|
var cachedProjectRoot = null;
|
|
17173
17242
|
var cachedIsDev = null;
|
|
@@ -17195,8 +17264,8 @@ function setupRoutes(options) {
|
|
|
17195
17264
|
} = options;
|
|
17196
17265
|
const routeChunks = routeLoader.loadRouteChunks();
|
|
17197
17266
|
const rewriteLoader = getRewriteLoader(projectRoot, isDev);
|
|
17198
|
-
const ssgOutDir =
|
|
17199
|
-
config ? getBuildDir(projectRoot, config) :
|
|
17267
|
+
const ssgOutDir = import_path33.default.join(
|
|
17268
|
+
config ? getBuildDir(projectRoot, config) : import_path33.default.join(projectRoot, BUILD_FOLDER_NAME),
|
|
17200
17269
|
"ssg"
|
|
17201
17270
|
);
|
|
17202
17271
|
app.all("/api/*", async (req, res) => {
|
|
@@ -18425,8 +18494,8 @@ var setupApplication = async ({
|
|
|
18425
18494
|
|
|
18426
18495
|
// src/server.ts
|
|
18427
18496
|
var import_dotenv2 = __toESM(require("dotenv"));
|
|
18428
|
-
var envPath =
|
|
18429
|
-
if (
|
|
18497
|
+
var envPath = import_path34.default.join(process.cwd(), ".env");
|
|
18498
|
+
if (import_fs24.default.existsSync(envPath)) {
|
|
18430
18499
|
import_dotenv2.default.config({ path: envPath });
|
|
18431
18500
|
} else {
|
|
18432
18501
|
import_dotenv2.default.config();
|
|
@@ -18447,8 +18516,8 @@ async function startServer(options = {}) {
|
|
|
18447
18516
|
}
|
|
18448
18517
|
const port = options.port ?? (process.env.PORT ? parseInt(process.env.PORT, 10) : void 0) ?? config.server.port;
|
|
18449
18518
|
const host = process.env.HOST ?? (!isDev ? "0.0.0.0" : void 0) ?? config.server.host;
|
|
18450
|
-
const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) :
|
|
18451
|
-
if (!isDev && !
|
|
18519
|
+
const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) : import_path34.default.join(getBuildDir(projectRoot, config), "server"));
|
|
18520
|
+
if (!isDev && !import_fs24.default.existsSync(appDir)) {
|
|
18452
18521
|
logger4.error("Compiled directory not found", void 0, {
|
|
18453
18522
|
buildDir: config.directories.build,
|
|
18454
18523
|
appDir,
|
|
@@ -18644,7 +18713,7 @@ async function run() {
|
|
|
18644
18713
|
}
|
|
18645
18714
|
const args = parseArgs(argv.slice(1));
|
|
18646
18715
|
const projectRoot = import_process.default.cwd();
|
|
18647
|
-
const appDir =
|
|
18716
|
+
const appDir = import_path35.default.resolve(projectRoot, args.appDir || "app");
|
|
18648
18717
|
const port = typeof args.port === "string" && args.port.trim().length > 0 ? Number(args.port) : 3e3;
|
|
18649
18718
|
switch (command) {
|
|
18650
18719
|
case "dev": {
|