elit 3.5.9 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +1 -1
- package/dist/build.cjs +11 -4
- package/dist/build.d.ts +1 -1
- package/dist/build.js +11 -4
- package/dist/build.mjs +11 -4
- package/dist/cli.cjs +170 -93
- package/dist/cli.mjs +170 -93
- package/dist/config.cjs +7 -2
- package/dist/config.d.ts +1 -1
- package/dist/config.js +7 -2
- package/dist/config.mjs +7 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/desktop-auto-render.d.ts +1 -1
- package/dist/render-context.d.ts +1 -1
- package/dist/{server-FCdUqabc.d.ts → server-CcBFc2F5.d.ts} +1 -1
- package/dist/server.cjs +147 -84
- package/dist/server.d.ts +1 -1
- package/dist/server.js +147 -84
- package/dist/server.mjs +147 -84
- package/package.json +66 -35
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -955,7 +955,7 @@ The package also exports `elit/test`, `elit/test-runtime`, and `elit/test-report
|
|
|
955
955
|
|
|
956
956
|
Latest release notes live in [CHANGELOG.md](CHANGELOG.md).
|
|
957
957
|
|
|
958
|
-
Highlights in `v3.
|
|
958
|
+
Highlights in `v3.6.0`:
|
|
959
959
|
|
|
960
960
|
- Added `elit pm` for detached background process management of shell commands, file targets, and WAPK apps.
|
|
961
961
|
- Added `pm.apps[]` and `pm.dataDir` in `elit.config.*` for config-first process manager workflows.
|
package/dist/build.cjs
CHANGED
|
@@ -418,7 +418,11 @@ function findInstalledPackageRoot(startDir, packageName) {
|
|
|
418
418
|
}
|
|
419
419
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
420
420
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
421
|
-
const builtCandidates = [
|
|
421
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
422
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
423
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
424
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
425
|
+
] : [
|
|
422
426
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
423
427
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
424
428
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -463,12 +467,12 @@ function readFileAsString(filePath) {
|
|
|
463
467
|
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
464
468
|
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
465
469
|
}
|
|
466
|
-
function createWorkspacePackagePlugin(entryDir) {
|
|
470
|
+
function createWorkspacePackagePlugin(entryDir, options = {}) {
|
|
467
471
|
return {
|
|
468
472
|
name: "workspace-package-self-reference",
|
|
469
473
|
setup(build2) {
|
|
470
474
|
build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
|
|
471
|
-
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir);
|
|
475
|
+
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir, options);
|
|
472
476
|
return resolved ? { path: resolved } : void 0;
|
|
473
477
|
});
|
|
474
478
|
}
|
|
@@ -542,7 +546,10 @@ async function build(options) {
|
|
|
542
546
|
};
|
|
543
547
|
try {
|
|
544
548
|
const platform = config.platform || (config.format === "cjs" ? "node" : "browser");
|
|
545
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath)
|
|
549
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
|
|
550
|
+
preferBuilt: platform === "browser",
|
|
551
|
+
preferredBuiltFormat: platform === "browser" ? "esm" : void 0
|
|
552
|
+
});
|
|
546
553
|
const plugins = platform === "browser" ? [workspacePackagePlugin, browserOnlyPlugin] : [workspacePackagePlugin];
|
|
547
554
|
const define = {};
|
|
548
555
|
if (config.env) {
|
package/dist/build.d.ts
CHANGED
package/dist/build.js
CHANGED
|
@@ -2917,7 +2917,11 @@ error: ${text}`);
|
|
|
2917
2917
|
}
|
|
2918
2918
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
2919
2919
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
2920
|
-
const builtCandidates = [
|
|
2920
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
2921
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
2922
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
2923
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
2924
|
+
] : [
|
|
2921
2925
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
2922
2926
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
2923
2927
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -2962,12 +2966,12 @@ error: ${text}`);
|
|
|
2962
2966
|
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
2963
2967
|
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
2964
2968
|
}
|
|
2965
|
-
function createWorkspacePackagePlugin(entryDir) {
|
|
2969
|
+
function createWorkspacePackagePlugin(entryDir, options = {}) {
|
|
2966
2970
|
return {
|
|
2967
2971
|
name: "workspace-package-self-reference",
|
|
2968
2972
|
setup(build2) {
|
|
2969
2973
|
build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
|
|
2970
|
-
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir);
|
|
2974
|
+
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir, options);
|
|
2971
2975
|
return resolved ? { path: resolved } : void 0;
|
|
2972
2976
|
});
|
|
2973
2977
|
}
|
|
@@ -3041,7 +3045,10 @@ error: ${text}`);
|
|
|
3041
3045
|
};
|
|
3042
3046
|
try {
|
|
3043
3047
|
const platform = config.platform || (config.format === "cjs" ? "node" : "browser");
|
|
3044
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath)
|
|
3048
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
|
|
3049
|
+
preferBuilt: platform === "browser",
|
|
3050
|
+
preferredBuiltFormat: platform === "browser" ? "esm" : void 0
|
|
3051
|
+
});
|
|
3045
3052
|
const plugins = platform === "browser" ? [workspacePackagePlugin, browserOnlyPlugin] : [workspacePackagePlugin];
|
|
3046
3053
|
const define = {};
|
|
3047
3054
|
if (config.env) {
|
package/dist/build.mjs
CHANGED
|
@@ -390,7 +390,11 @@ function findInstalledPackageRoot(startDir, packageName) {
|
|
|
390
390
|
}
|
|
391
391
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
392
392
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
393
|
-
const builtCandidates = [
|
|
393
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
394
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
395
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
396
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
397
|
+
] : [
|
|
394
398
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
395
399
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
396
400
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -435,12 +439,12 @@ function readFileAsString(filePath) {
|
|
|
435
439
|
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
436
440
|
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
437
441
|
}
|
|
438
|
-
function createWorkspacePackagePlugin(entryDir) {
|
|
442
|
+
function createWorkspacePackagePlugin(entryDir, options = {}) {
|
|
439
443
|
return {
|
|
440
444
|
name: "workspace-package-self-reference",
|
|
441
445
|
setup(build2) {
|
|
442
446
|
build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
|
|
443
|
-
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir);
|
|
447
|
+
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir, options);
|
|
444
448
|
return resolved ? { path: resolved } : void 0;
|
|
445
449
|
});
|
|
446
450
|
}
|
|
@@ -514,7 +518,10 @@ async function build(options) {
|
|
|
514
518
|
};
|
|
515
519
|
try {
|
|
516
520
|
const platform = config.platform || (config.format === "cjs" ? "node" : "browser");
|
|
517
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath)
|
|
521
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
|
|
522
|
+
preferBuilt: platform === "browser",
|
|
523
|
+
preferredBuiltFormat: platform === "browser" ? "esm" : void 0
|
|
524
|
+
});
|
|
518
525
|
const plugins = platform === "browser" ? [workspacePackagePlugin, browserOnlyPlugin] : [workspacePackagePlugin];
|
|
519
526
|
const define = {};
|
|
520
527
|
if (config.env) {
|
package/dist/cli.cjs
CHANGED
|
@@ -59462,7 +59462,11 @@ function findInstalledPackageRoot(startDir, packageName) {
|
|
|
59462
59462
|
}
|
|
59463
59463
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
59464
59464
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
59465
|
-
const builtCandidates = [
|
|
59465
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
59466
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
59467
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
59468
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
59469
|
+
] : [
|
|
59466
59470
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
59467
59471
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
59468
59472
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -59594,7 +59598,8 @@ async function loadConfigFile(configPath) {
|
|
|
59594
59598
|
setup(build3) {
|
|
59595
59599
|
build3.onResolve({ filter: /.*/ }, (args) => {
|
|
59596
59600
|
const workspacePackageImport = resolveWorkspacePackageImport(args.path, args.resolveDir || configDir, {
|
|
59597
|
-
preferBuilt: true
|
|
59601
|
+
preferBuilt: true,
|
|
59602
|
+
preferredBuiltFormat: "esm"
|
|
59598
59603
|
});
|
|
59599
59604
|
if (workspacePackageImport) {
|
|
59600
59605
|
return {
|
|
@@ -61325,35 +61330,42 @@ var sendError = (res, code, msg) => {
|
|
|
61325
61330
|
var send404 = (res, msg = "Not Found") => sendError(res, 404, msg);
|
|
61326
61331
|
var send403 = (res, msg = "Forbidden") => sendError(res, 403, msg);
|
|
61327
61332
|
var send500 = (res, msg = "Internal Server Error") => sendError(res, 500, msg);
|
|
61328
|
-
async function resolveWorkspaceElitImportBasePath(rootDir, basePath,
|
|
61333
|
+
async function resolveWorkspaceElitImportBasePath(rootDir, basePath, _mode) {
|
|
61329
61334
|
const resolvedRootDir = await realpath(resolve(rootDir));
|
|
61330
61335
|
try {
|
|
61331
61336
|
const packageJsonBuffer = await readFile(join(resolvedRootDir, "package.json"));
|
|
61332
61337
|
const packageJson = JSON.parse(packageJsonBuffer.toString());
|
|
61333
61338
|
if (packageJson.name === "elit") {
|
|
61334
|
-
|
|
61335
|
-
return basePath ? `${basePath}/${workspaceDir}` : `/${workspaceDir}`;
|
|
61339
|
+
return basePath ? `${basePath}/dist` : "/dist";
|
|
61336
61340
|
}
|
|
61337
61341
|
} catch {
|
|
61338
61342
|
}
|
|
61339
61343
|
return void 0;
|
|
61340
61344
|
}
|
|
61345
|
+
var BROWSER_SAFE_ELIT_IMPORTS = {
|
|
61346
|
+
"elit": "index",
|
|
61347
|
+
"elit/dom": "dom",
|
|
61348
|
+
"elit/el": "el",
|
|
61349
|
+
"elit/native": "native",
|
|
61350
|
+
"elit/universal": "universal",
|
|
61351
|
+
"elit/router": "router",
|
|
61352
|
+
"elit/state": "state",
|
|
61353
|
+
"elit/style": "style",
|
|
61354
|
+
"elit/hmr": "hmr",
|
|
61355
|
+
"elit/types": "types"
|
|
61356
|
+
};
|
|
61357
|
+
function createBrowserSafeElitImports(basePath, fileExt) {
|
|
61358
|
+
return Object.fromEntries(
|
|
61359
|
+
Object.entries(BROWSER_SAFE_ELIT_IMPORTS).map(([specifier, outputName]) => [
|
|
61360
|
+
specifier,
|
|
61361
|
+
`${basePath}/${outputName}${fileExt}`
|
|
61362
|
+
])
|
|
61363
|
+
);
|
|
61364
|
+
}
|
|
61341
61365
|
var createElitImportMap = async (rootDir, basePath = "", mode = "dev") => {
|
|
61342
61366
|
const workspaceImportBasePath = await resolveWorkspaceElitImportBasePath(rootDir, basePath, mode);
|
|
61343
|
-
const fileExt =
|
|
61344
|
-
const elitImports = workspaceImportBasePath ? {
|
|
61345
|
-
"elit": `${workspaceImportBasePath}/index${fileExt}`,
|
|
61346
|
-
"elit/": `${workspaceImportBasePath}/`,
|
|
61347
|
-
"elit/dom": `${workspaceImportBasePath}/dom${fileExt}`,
|
|
61348
|
-
"elit/state": `${workspaceImportBasePath}/state${fileExt}`,
|
|
61349
|
-
"elit/style": `${workspaceImportBasePath}/style${fileExt}`,
|
|
61350
|
-
"elit/el": `${workspaceImportBasePath}/el${fileExt}`,
|
|
61351
|
-
"elit/universal": `${workspaceImportBasePath}/universal${fileExt}`,
|
|
61352
|
-
"elit/router": `${workspaceImportBasePath}/router${fileExt}`,
|
|
61353
|
-
"elit/hmr": `${workspaceImportBasePath}/hmr${fileExt}`,
|
|
61354
|
-
"elit/types": `${workspaceImportBasePath}/types${fileExt}`,
|
|
61355
|
-
"elit/native": `${workspaceImportBasePath}/native${fileExt}`
|
|
61356
|
-
} : {};
|
|
61367
|
+
const fileExt = ".mjs";
|
|
61368
|
+
const elitImports = workspaceImportBasePath ? createBrowserSafeElitImports(workspaceImportBasePath, fileExt) : {};
|
|
61357
61369
|
const externalImports = await generateExternalImportMaps(rootDir, basePath);
|
|
61358
61370
|
const allImports = { ...externalImports, ...elitImports };
|
|
61359
61371
|
return `<script type="importmap">${JSON.stringify({ imports: allImports }, null, 2)}</script>`;
|
|
@@ -61624,6 +61636,29 @@ async function processPackage(nodeModulesPath, pkgName, importMap, basePath) {
|
|
|
61624
61636
|
}
|
|
61625
61637
|
}
|
|
61626
61638
|
function processExportsField(pkgName, exports2, baseUrl, importMap) {
|
|
61639
|
+
if (pkgName === "elit") {
|
|
61640
|
+
if (typeof exports2 !== "object" || exports2 === null) {
|
|
61641
|
+
return;
|
|
61642
|
+
}
|
|
61643
|
+
const elitExports = exports2;
|
|
61644
|
+
const browserSafeImports = {};
|
|
61645
|
+
const rootResolved = "." in elitExports ? resolveExport(elitExports["."]) : "import" in elitExports ? resolveExport(elitExports) : null;
|
|
61646
|
+
if (rootResolved) {
|
|
61647
|
+
browserSafeImports.elit = `${baseUrl}/${rootResolved}`;
|
|
61648
|
+
}
|
|
61649
|
+
const allowedSubpaths = Object.keys(BROWSER_SAFE_ELIT_IMPORTS).filter((specifier) => specifier !== "elit").map((specifier) => ({
|
|
61650
|
+
exportKey: `./${specifier.slice("elit/".length)}`,
|
|
61651
|
+
importName: specifier
|
|
61652
|
+
}));
|
|
61653
|
+
for (const { exportKey, importName } of allowedSubpaths) {
|
|
61654
|
+
const resolved = resolveExport(elitExports[exportKey]);
|
|
61655
|
+
if (resolved) {
|
|
61656
|
+
browserSafeImports[importName] = `${baseUrl}/${resolved}`;
|
|
61657
|
+
}
|
|
61658
|
+
}
|
|
61659
|
+
Object.assign(importMap, browserSafeImports);
|
|
61660
|
+
return;
|
|
61661
|
+
}
|
|
61627
61662
|
if (typeof exports2 === "string") {
|
|
61628
61663
|
importMap[pkgName] = `${baseUrl}/${exports2}`;
|
|
61629
61664
|
importMap[`${pkgName}/`] = `${baseUrl}/`;
|
|
@@ -61867,6 +61902,85 @@ function shouldUseClientFallbackRoot(primaryRoot, fallbackRoot, indexPath) {
|
|
|
61867
61902
|
const primaryHasRuntimeSources = existsSync(join(resolvedPrimaryRoot, "src")) || existsSync(join(resolvedPrimaryRoot, "public")) || existsSync(join(resolvedPrimaryRoot, normalizedIndexPath));
|
|
61868
61903
|
return !primaryHasRuntimeSources;
|
|
61869
61904
|
}
|
|
61905
|
+
function isPathWithinRoot(filePath, rootDir) {
|
|
61906
|
+
return filePath === rootDir || filePath.startsWith(rootDir.endsWith(sep) ? rootDir : `${rootDir}${sep}`);
|
|
61907
|
+
}
|
|
61908
|
+
async function getAllowedClientRoots(client) {
|
|
61909
|
+
const allowedRoots = [];
|
|
61910
|
+
for (const candidateRoot of [client.root, client.fallbackRoot]) {
|
|
61911
|
+
if (!candidateRoot) {
|
|
61912
|
+
continue;
|
|
61913
|
+
}
|
|
61914
|
+
try {
|
|
61915
|
+
const resolvedRoot = await realpath(resolve(candidateRoot));
|
|
61916
|
+
if (!allowedRoots.includes(resolvedRoot)) {
|
|
61917
|
+
allowedRoots.push(resolvedRoot);
|
|
61918
|
+
}
|
|
61919
|
+
} catch {
|
|
61920
|
+
}
|
|
61921
|
+
}
|
|
61922
|
+
return allowedRoots;
|
|
61923
|
+
}
|
|
61924
|
+
async function getClientBaseDirs(client, isDistRequest, isNodeModulesRequest) {
|
|
61925
|
+
const baseDirs = [];
|
|
61926
|
+
for (const candidateRoot of [client.root, client.fallbackRoot]) {
|
|
61927
|
+
if (!candidateRoot) {
|
|
61928
|
+
continue;
|
|
61929
|
+
}
|
|
61930
|
+
try {
|
|
61931
|
+
const resolvedRoot = await realpath(resolve(candidateRoot));
|
|
61932
|
+
let baseDir = resolvedRoot;
|
|
61933
|
+
if (isDistRequest || isNodeModulesRequest) {
|
|
61934
|
+
const targetDir = isDistRequest ? "dist" : "node_modules";
|
|
61935
|
+
const foundDir = await findSpecialDir(candidateRoot, targetDir);
|
|
61936
|
+
baseDir = foundDir ? await realpath(foundDir) : resolvedRoot;
|
|
61937
|
+
}
|
|
61938
|
+
if (!baseDirs.includes(baseDir)) {
|
|
61939
|
+
baseDirs.push(baseDir);
|
|
61940
|
+
}
|
|
61941
|
+
} catch {
|
|
61942
|
+
}
|
|
61943
|
+
}
|
|
61944
|
+
return baseDirs;
|
|
61945
|
+
}
|
|
61946
|
+
async function resolveClientPathFromBaseDir(baseDir, normalizedPath) {
|
|
61947
|
+
const tryRealpathWithinBaseDir = async (relativePath2) => {
|
|
61948
|
+
const unresolvedPath = resolve(join(baseDir, relativePath2));
|
|
61949
|
+
if (!isPathWithinRoot(unresolvedPath, baseDir)) {
|
|
61950
|
+
return void 0;
|
|
61951
|
+
}
|
|
61952
|
+
try {
|
|
61953
|
+
return await realpath(unresolvedPath);
|
|
61954
|
+
} catch {
|
|
61955
|
+
return void 0;
|
|
61956
|
+
}
|
|
61957
|
+
};
|
|
61958
|
+
const exactPath = await tryRealpathWithinBaseDir(normalizedPath);
|
|
61959
|
+
if (exactPath) {
|
|
61960
|
+
return exactPath;
|
|
61961
|
+
}
|
|
61962
|
+
if (normalizedPath.endsWith(".js")) {
|
|
61963
|
+
const tsPath = await tryRealpathWithinBaseDir(normalizedPath.replace(/\.js$/, ".ts"));
|
|
61964
|
+
if (tsPath) {
|
|
61965
|
+
return tsPath;
|
|
61966
|
+
}
|
|
61967
|
+
}
|
|
61968
|
+
if (normalizedPath.includes(".")) {
|
|
61969
|
+
return void 0;
|
|
61970
|
+
}
|
|
61971
|
+
for (const candidatePath of [
|
|
61972
|
+
`${normalizedPath}.ts`,
|
|
61973
|
+
`${normalizedPath}.js`,
|
|
61974
|
+
join(normalizedPath, "index.ts"),
|
|
61975
|
+
join(normalizedPath, "index.js")
|
|
61976
|
+
]) {
|
|
61977
|
+
const resolvedPath = await tryRealpathWithinBaseDir(candidatePath);
|
|
61978
|
+
if (resolvedPath) {
|
|
61979
|
+
return resolvedPath;
|
|
61980
|
+
}
|
|
61981
|
+
}
|
|
61982
|
+
return void 0;
|
|
61983
|
+
}
|
|
61870
61984
|
function createDevServer(options) {
|
|
61871
61985
|
const config = { ...defaultOptions, ...options };
|
|
61872
61986
|
const wsClients = /* @__PURE__ */ new Set();
|
|
@@ -61896,6 +62010,7 @@ function createDevServer(options) {
|
|
|
61896
62010
|
const activeRoot = useFallbackRoot ? client.fallbackRoot || client.root : client.root;
|
|
61897
62011
|
return {
|
|
61898
62012
|
root: activeRoot,
|
|
62013
|
+
fallbackRoot: useFallbackRoot ? void 0 : client.fallbackRoot,
|
|
61899
62014
|
basePath,
|
|
61900
62015
|
index: useFallbackRoot ? void 0 : indexPath,
|
|
61901
62016
|
ssr: useFallbackRoot ? void 0 : client.ssr,
|
|
@@ -61997,75 +62112,26 @@ function createDevServer(options) {
|
|
|
61997
62112
|
return send403(res, "403 Forbidden");
|
|
61998
62113
|
}
|
|
61999
62114
|
normalizedPath = tempPath;
|
|
62000
|
-
const rootDir = await realpath(resolve(matchedClient.root));
|
|
62001
|
-
let baseDir = rootDir;
|
|
62002
|
-
if (isDistRequest || isNodeModulesRequest) {
|
|
62003
|
-
const targetDir = isDistRequest ? "dist" : "node_modules";
|
|
62004
|
-
const foundDir = await findSpecialDir(matchedClient.root, targetDir);
|
|
62005
|
-
baseDir = foundDir ? await realpath(foundDir) : rootDir;
|
|
62006
|
-
}
|
|
62007
62115
|
let fullPath;
|
|
62008
|
-
|
|
62009
|
-
|
|
62010
|
-
|
|
62011
|
-
|
|
62012
|
-
|
|
62013
|
-
|
|
62014
|
-
fullPath = await realpath(unresolvedPath);
|
|
62015
|
-
if (config.logging && filePath === "/src/pages") {
|
|
62016
|
-
console.log(`[DEBUG] Initial resolve succeeded: ${fullPath}`);
|
|
62017
|
-
}
|
|
62018
|
-
} catch (firstError) {
|
|
62019
|
-
let resolvedPath;
|
|
62020
|
-
if (config.logging && !normalizedPath.includes(".")) {
|
|
62021
|
-
console.log(`[DEBUG] File not found: ${normalizedPath}, trying extensions...`);
|
|
62022
|
-
}
|
|
62023
|
-
if (normalizedPath.endsWith(".js")) {
|
|
62024
|
-
const tsPath = normalizedPath.replace(/\.js$/, ".ts");
|
|
62025
|
-
try {
|
|
62026
|
-
const tsFullPath = await realpath(resolve(join(baseDir, tsPath)));
|
|
62027
|
-
if (!tsFullPath.startsWith(baseDir.endsWith(sep) ? baseDir : baseDir + sep)) {
|
|
62028
|
-
if (config.logging) console.log(`[403] Fallback TS path outside of root: ${tsFullPath}`);
|
|
62029
|
-
return send403(res, "403 Forbidden");
|
|
62030
|
-
}
|
|
62031
|
-
resolvedPath = tsFullPath;
|
|
62032
|
-
} catch {
|
|
62033
|
-
}
|
|
62034
|
-
}
|
|
62035
|
-
if (!resolvedPath && !normalizedPath.includes(".")) {
|
|
62036
|
-
try {
|
|
62037
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath + ".ts")));
|
|
62038
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}.ts`);
|
|
62039
|
-
} catch {
|
|
62040
|
-
try {
|
|
62041
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath + ".js")));
|
|
62042
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}.js`);
|
|
62043
|
-
} catch {
|
|
62044
|
-
try {
|
|
62045
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath, "index.ts")));
|
|
62046
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}/index.ts`);
|
|
62047
|
-
} catch {
|
|
62048
|
-
try {
|
|
62049
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath, "index.js")));
|
|
62050
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}/index.js`);
|
|
62051
|
-
} catch {
|
|
62052
|
-
if (config.logging) console.log(`[DEBUG] Not found: all attempts failed for ${normalizedPath}`);
|
|
62053
|
-
}
|
|
62054
|
-
}
|
|
62055
|
-
}
|
|
62116
|
+
const baseDirs = await getClientBaseDirs(matchedClient, isDistRequest, isNodeModulesRequest);
|
|
62117
|
+
for (const baseDir of baseDirs) {
|
|
62118
|
+
fullPath = await resolveClientPathFromBaseDir(baseDir, normalizedPath);
|
|
62119
|
+
if (fullPath) {
|
|
62120
|
+
if (config.logging && filePath === "/src/pages") {
|
|
62121
|
+
console.log(`[DEBUG] Initial resolve succeeded: ${fullPath}`);
|
|
62056
62122
|
}
|
|
62123
|
+
break;
|
|
62057
62124
|
}
|
|
62058
|
-
|
|
62059
|
-
|
|
62060
|
-
|
|
62061
|
-
|
|
62062
|
-
|
|
62063
|
-
if (config.logging) console.log(`[404] ${filePath}`);
|
|
62064
|
-
return send404(res, "404 Not Found");
|
|
62125
|
+
}
|
|
62126
|
+
if (!fullPath) {
|
|
62127
|
+
if (!res.headersSent) {
|
|
62128
|
+
if (filePath === "/index.html" && matchedClient.ssr) {
|
|
62129
|
+
return await serveSSR(res, matchedClient);
|
|
62065
62130
|
}
|
|
62066
|
-
|
|
62131
|
+
if (config.logging) console.log(`[404] ${filePath}`);
|
|
62132
|
+
return send404(res, "404 Not Found");
|
|
62067
62133
|
}
|
|
62068
|
-
|
|
62134
|
+
return;
|
|
62069
62135
|
}
|
|
62070
62136
|
try {
|
|
62071
62137
|
const stats = await stat(fullPath);
|
|
@@ -62094,11 +62160,12 @@ function createDevServer(options) {
|
|
|
62094
62160
|
return send404(res, "404 Not Found");
|
|
62095
62161
|
}
|
|
62096
62162
|
try {
|
|
62163
|
+
const allowedRoots = await getAllowedClientRoots(matchedClient);
|
|
62097
62164
|
const stats = await stat(fullPath);
|
|
62098
62165
|
if (stats.isDirectory()) {
|
|
62099
62166
|
try {
|
|
62100
62167
|
const indexPath = await realpath(resolve(join(fullPath, "index.html")));
|
|
62101
|
-
if (!indexPath.
|
|
62168
|
+
if (!isPathWithinRoot(indexPath, fullPath) && !allowedRoots.some((rootDir) => isPathWithinRoot(indexPath, rootDir))) {
|
|
62102
62169
|
return send403(res, "403 Forbidden");
|
|
62103
62170
|
}
|
|
62104
62171
|
await stat(indexPath);
|
|
@@ -62120,10 +62187,11 @@ function createDevServer(options) {
|
|
|
62120
62187
|
return input.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
62121
62188
|
}
|
|
62122
62189
|
try {
|
|
62123
|
-
const
|
|
62190
|
+
const allowedRoots = await getAllowedClientRoots(client);
|
|
62191
|
+
const rootDir = allowedRoots[0] || await realpath(resolve(client.root));
|
|
62124
62192
|
const unresolvedPath = resolve(filePath);
|
|
62125
62193
|
if (!isNodeModulesOrDist) {
|
|
62126
|
-
if (!
|
|
62194
|
+
if (!allowedRoots.some((allowedRoot) => isPathWithinRoot(unresolvedPath, allowedRoot))) {
|
|
62127
62195
|
if (config.logging) console.log(`[403] Attempted to serve file outside allowed directories: ${filePath}`);
|
|
62128
62196
|
return send403(res, "403 Forbidden");
|
|
62129
62197
|
}
|
|
@@ -62545,12 +62613,12 @@ function readFileAsString2(filePath) {
|
|
|
62545
62613
|
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
62546
62614
|
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
62547
62615
|
}
|
|
62548
|
-
function createWorkspacePackagePlugin(entryDir) {
|
|
62616
|
+
function createWorkspacePackagePlugin(entryDir, options = {}) {
|
|
62549
62617
|
return {
|
|
62550
62618
|
name: "workspace-package-self-reference",
|
|
62551
62619
|
setup(build2) {
|
|
62552
62620
|
build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
|
|
62553
|
-
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir);
|
|
62621
|
+
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir, options);
|
|
62554
62622
|
return resolved ? { path: resolved } : void 0;
|
|
62555
62623
|
});
|
|
62556
62624
|
}
|
|
@@ -62624,7 +62692,10 @@ async function build(options) {
|
|
|
62624
62692
|
};
|
|
62625
62693
|
try {
|
|
62626
62694
|
const platform = config.platform || (config.format === "cjs" ? "node" : "browser");
|
|
62627
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath)
|
|
62695
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
|
|
62696
|
+
preferBuilt: platform === "browser",
|
|
62697
|
+
preferredBuiltFormat: platform === "browser" ? "esm" : void 0
|
|
62698
|
+
});
|
|
62628
62699
|
const plugins = platform === "browser" ? [workspacePackagePlugin, browserOnlyPlugin] : [workspacePackagePlugin];
|
|
62629
62700
|
const define2 = {};
|
|
62630
62701
|
if (config.env) {
|
|
@@ -81838,12 +81909,12 @@ init_path();
|
|
|
81838
81909
|
// src/preview-build.ts
|
|
81839
81910
|
init_fs();
|
|
81840
81911
|
init_path();
|
|
81841
|
-
function createWorkspacePackagePlugin3(resolveDir) {
|
|
81912
|
+
function createWorkspacePackagePlugin3(resolveDir, options = {}) {
|
|
81842
81913
|
return {
|
|
81843
81914
|
name: "workspace-package-self-reference",
|
|
81844
81915
|
setup(build2) {
|
|
81845
81916
|
build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
|
|
81846
|
-
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || resolveDir);
|
|
81917
|
+
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || resolveDir, options);
|
|
81847
81918
|
return resolved ? { path: resolved } : void 0;
|
|
81848
81919
|
});
|
|
81849
81920
|
}
|
|
@@ -82025,7 +82096,10 @@ async function buildStandalonePreviewServer(options) {
|
|
|
82025
82096
|
const outputDir = dirname(plan.outputPath);
|
|
82026
82097
|
mkdirSync(outputDir, { recursive: true });
|
|
82027
82098
|
const { build: build2 } = await import("esbuild");
|
|
82028
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd
|
|
82099
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd, {
|
|
82100
|
+
preferBuilt: true,
|
|
82101
|
+
preferredBuiltFormat: "cjs"
|
|
82102
|
+
});
|
|
82029
82103
|
const entrySource = createStandalonePreviewEntrySource(options.configPath, plan, options.previewConfig);
|
|
82030
82104
|
await build2({
|
|
82031
82105
|
stdin: {
|
|
@@ -82253,7 +82327,10 @@ async function buildStandaloneDevServer(options) {
|
|
|
82253
82327
|
const outputDir = dirname(plan.outputPath);
|
|
82254
82328
|
mkdirSync(outputDir, { recursive: true });
|
|
82255
82329
|
const { build: build2, version } = await import("esbuild");
|
|
82256
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd
|
|
82330
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd, {
|
|
82331
|
+
preferBuilt: true,
|
|
82332
|
+
preferredBuiltFormat: "cjs"
|
|
82333
|
+
});
|
|
82257
82334
|
const entrySource = createStandaloneDevEntrySource(options.configPath, plan, options.devConfig, {
|
|
82258
82335
|
cwd,
|
|
82259
82336
|
buildConfig: options.buildConfig,
|