@absolutejs/absolute 0.19.0-beta.96 → 0.19.0-beta.98
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/.absolutejs/tsconfig.tsbuildinfo +1 -1
- package/dist/build.js +146 -94
- package/dist/build.js.map +6 -6
- package/dist/dev/client/handlers/react.ts +19 -35
- package/dist/index.js +149 -97
- package/dist/index.js.map +6 -6
- package/dist/src/dev/transformCache.d.ts +2 -0
- package/package.json +2 -2
- package/types/globals.d.ts +0 -1
- package/dist/freshBuildWorker.js +0 -559
- package/dist/src/build/freshBuildWorker.d.ts +0 -1
- package/dist/src/build/freshReadPlugin.d.ts +0 -2
package/dist/build.js
CHANGED
|
@@ -123,7 +123,7 @@ __export(exports_generateReactIndexes, {
|
|
|
123
123
|
});
|
|
124
124
|
import { existsSync, mkdirSync } from "fs";
|
|
125
125
|
import { readdir, rm, writeFile } from "fs/promises";
|
|
126
|
-
import { basename, join,
|
|
126
|
+
import { basename, join, resolve } from "path";
|
|
127
127
|
var {Glob } = globalThis.Bun;
|
|
128
128
|
var indexContentCache, resolveDevClientDir = () => {
|
|
129
129
|
const fromSource = resolve(import.meta.dir, "../dev/client");
|
|
@@ -160,7 +160,6 @@ var indexContentCache, resolveDevClientDir = () => {
|
|
|
160
160
|
const hmrPreamble = isDev ? [
|
|
161
161
|
`window.__HMR_FRAMEWORK__ = "react";`,
|
|
162
162
|
`window.__REACT_COMPONENT_KEY__ = "${componentName}Index";`,
|
|
163
|
-
`window.__REACT_PAGE_MODULE__ = "/@src/${relative(process.cwd(), resolve(reactPagesDirectory, componentName + ".tsx")).replace(/\\\\/g, "/")}";`,
|
|
164
163
|
`import '${refreshSetupPath}';`,
|
|
165
164
|
`import '${hmrClientPath}';`,
|
|
166
165
|
`import { showErrorOverlay, hideErrorOverlay } from '${errorOverlayPath}';
|
|
@@ -200,6 +199,9 @@ var indexContentCache, resolveDevClientDir = () => {
|
|
|
200
199
|
` reset() {`,
|
|
201
200
|
` this.setState({ hasError: false });`,
|
|
202
201
|
` }`,
|
|
202
|
+
` hmrUpdate() {`,
|
|
203
|
+
` this.forceUpdate();`,
|
|
204
|
+
` }`,
|
|
203
205
|
` render() {`,
|
|
204
206
|
` if (this.state.hasError) return null;`,
|
|
205
207
|
``,
|
|
@@ -867,7 +869,7 @@ var devVendorPaths = null, getDevVendorPaths = () => devVendorPaths, setDevVendo
|
|
|
867
869
|
|
|
868
870
|
// src/build/angularLinkerPlugin.ts
|
|
869
871
|
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
870
|
-
import { dirname as dirname2, join as join4, relative
|
|
872
|
+
import { dirname as dirname2, join as join4, relative, resolve as resolve4 } from "path";
|
|
871
873
|
import { createHash } from "crypto";
|
|
872
874
|
var CACHE_DIR, angularLinkerPlugin;
|
|
873
875
|
var init_angularLinkerPlugin = __esm(() => {
|
|
@@ -910,7 +912,7 @@ var init_angularLinkerPlugin = __esm(() => {
|
|
|
910
912
|
dirname: dirname2,
|
|
911
913
|
exists: existsSync7,
|
|
912
914
|
readFile: readFileSync3,
|
|
913
|
-
relative
|
|
915
|
+
relative,
|
|
914
916
|
resolve: resolve4
|
|
915
917
|
},
|
|
916
918
|
linkerJitMode: false,
|
|
@@ -951,11 +953,11 @@ var HASHED_FILE_PATTERN, cleanStaleOutputs = async (buildPath, currentOutputPath
|
|
|
951
953
|
const currentPaths = new Set(currentOutputPaths.map((path) => resolve5(path)));
|
|
952
954
|
const glob = new Glob4("**/*");
|
|
953
955
|
const removals = [];
|
|
954
|
-
for (const
|
|
955
|
-
const absolute = resolve5(buildPath,
|
|
956
|
+
for (const relative2 of glob.scanSync({ cwd: buildPath })) {
|
|
957
|
+
const absolute = resolve5(buildPath, relative2);
|
|
956
958
|
if (currentPaths.has(absolute))
|
|
957
959
|
continue;
|
|
958
|
-
if (!HASHED_FILE_PATTERN.test(
|
|
960
|
+
if (!HASHED_FILE_PATTERN.test(relative2))
|
|
959
961
|
continue;
|
|
960
962
|
removals.push(rm2(absolute, { force: true }));
|
|
961
963
|
}
|
|
@@ -1109,12 +1111,12 @@ var init_startupBanner = __esm(() => {
|
|
|
1109
1111
|
// src/utils/logger.ts
|
|
1110
1112
|
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
1111
1113
|
const cwd = process.cwd();
|
|
1112
|
-
let
|
|
1113
|
-
|
|
1114
|
-
if (!
|
|
1115
|
-
|
|
1114
|
+
let relative2 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
1115
|
+
relative2 = relative2.replace(/\\/g, "/");
|
|
1116
|
+
if (!relative2.startsWith("/")) {
|
|
1117
|
+
relative2 = `/${relative2}`;
|
|
1116
1118
|
}
|
|
1117
|
-
return
|
|
1119
|
+
return relative2;
|
|
1118
1120
|
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
1119
1121
|
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1120
1122
|
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
@@ -1173,11 +1175,11 @@ var init_logger = __esm(() => {
|
|
|
1173
1175
|
});
|
|
1174
1176
|
|
|
1175
1177
|
// src/utils/validateSafePath.ts
|
|
1176
|
-
import { resolve as resolve6, relative as
|
|
1178
|
+
import { resolve as resolve6, relative as relative2 } from "path";
|
|
1177
1179
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
1178
1180
|
const absoluteBase = resolve6(baseDirectory);
|
|
1179
1181
|
const absoluteTarget = resolve6(baseDirectory, targetPath);
|
|
1180
|
-
const relativePath = normalizePath(
|
|
1182
|
+
const relativePath = normalizePath(relative2(absoluteBase, absoluteTarget));
|
|
1181
1183
|
if (relativePath.startsWith("../") || relativePath === "..") {
|
|
1182
1184
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
1183
1185
|
}
|
|
@@ -1199,7 +1201,7 @@ import {
|
|
|
1199
1201
|
basename as basename2,
|
|
1200
1202
|
extname as extname2,
|
|
1201
1203
|
resolve as resolve7,
|
|
1202
|
-
relative as
|
|
1204
|
+
relative as relative3,
|
|
1203
1205
|
sep
|
|
1204
1206
|
} from "path";
|
|
1205
1207
|
import { env } from "process";
|
|
@@ -1263,7 +1265,7 @@ var resolveDevClientDir2 = () => {
|
|
|
1263
1265
|
const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
|
|
1264
1266
|
const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
|
|
1265
1267
|
const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
|
|
1266
|
-
const relDir = dirname3(
|
|
1268
|
+
const relDir = dirname3(relative3(svelteRoot, src)).replace(/\\/g, "/");
|
|
1267
1269
|
const baseName = basename2(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
1268
1270
|
const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
1269
1271
|
const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
|
|
@@ -1282,7 +1284,7 @@ var resolveDevClientDir2 = () => {
|
|
|
1282
1284
|
}).js.code;
|
|
1283
1285
|
let code = raw2.replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
1284
1286
|
if (mode === "client" && isDev) {
|
|
1285
|
-
const moduleKey = `/@src/${
|
|
1287
|
+
const moduleKey = `/@src/${relative3(process.cwd(), src).replace(/\\/g, "/")}`;
|
|
1286
1288
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
1287
1289
|
if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
1288
1290
|
var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleKey)}] = cb; };`);
|
|
@@ -1317,10 +1319,10 @@ var resolveDevClientDir2 = () => {
|
|
|
1317
1319
|
};
|
|
1318
1320
|
const roots = await Promise.all(entryPoints.map(build));
|
|
1319
1321
|
await Promise.all(roots.map(async ({ client }) => {
|
|
1320
|
-
const relClientDir = dirname3(
|
|
1322
|
+
const relClientDir = dirname3(relative3(clientDir, client));
|
|
1321
1323
|
const name = basename2(client, extname2(client));
|
|
1322
1324
|
const indexPath = join6(indexDir, relClientDir, `${name}.js`);
|
|
1323
|
-
const importRaw =
|
|
1325
|
+
const importRaw = relative3(dirname3(indexPath), client).split(sep).join("/");
|
|
1324
1326
|
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
1325
1327
|
const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
1326
1328
|
import "${hmrClientPath3}";
|
|
@@ -1360,7 +1362,7 @@ if (typeof window !== "undefined") {
|
|
|
1360
1362
|
return {
|
|
1361
1363
|
svelteClientPaths: roots.map(({ client }) => client),
|
|
1362
1364
|
svelteIndexPaths: roots.map(({ client }) => {
|
|
1363
|
-
const rel = dirname3(
|
|
1365
|
+
const rel = dirname3(relative3(clientDir, client));
|
|
1364
1366
|
return join6(indexDir, rel, basename2(client));
|
|
1365
1367
|
}),
|
|
1366
1368
|
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
@@ -1385,7 +1387,7 @@ __export(exports_compileVue, {
|
|
|
1385
1387
|
});
|
|
1386
1388
|
import { existsSync as existsSync9 } from "fs";
|
|
1387
1389
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
1388
|
-
import { basename as basename3, dirname as dirname4, join as join7, relative as
|
|
1390
|
+
import { basename as basename3, dirname as dirname4, join as join7, relative as relative4, resolve as resolve8 } from "path";
|
|
1389
1391
|
var {file: file2, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
|
|
1390
1392
|
var resolveDevClientDir3 = () => {
|
|
1391
1393
|
const fromSource = resolve8(import.meta.dir, "../dev/client");
|
|
@@ -1430,7 +1432,7 @@ var resolveDevClientDir3 = () => {
|
|
|
1430
1432
|
return "template-only";
|
|
1431
1433
|
}
|
|
1432
1434
|
return "full";
|
|
1433
|
-
}, generateVueHmrId = (sourceFilePath, vueRootDir) =>
|
|
1435
|
+
}, generateVueHmrId = (sourceFilePath, vueRootDir) => relative4(vueRootDir, sourceFilePath).replace(/\\/g, "/").replace(/\.vue$/, ""), extractImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => importPath !== undefined), toJs = (filePath) => {
|
|
1434
1436
|
if (filePath.endsWith(".vue"))
|
|
1435
1437
|
return filePath.replace(/\.vue$/, ".js");
|
|
1436
1438
|
if (filePath.endsWith(".ts"))
|
|
@@ -1457,7 +1459,7 @@ var resolveDevClientDir3 = () => {
|
|
|
1457
1459
|
const cachedResult = cacheMap.get(sourceFilePath);
|
|
1458
1460
|
if (cachedResult)
|
|
1459
1461
|
return cachedResult;
|
|
1460
|
-
const relativeFilePath =
|
|
1462
|
+
const relativeFilePath = relative4(vueRootDir, sourceFilePath).replace(/\\/g, "/");
|
|
1461
1463
|
const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
|
|
1462
1464
|
const fileBaseName = basename3(sourceFilePath, ".vue");
|
|
1463
1465
|
const componentId = toKebab(fileBaseName);
|
|
@@ -1586,7 +1588,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
1586
1588
|
result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
|
|
1587
1589
|
const entryBaseName = basename3(entryPath, ".vue");
|
|
1588
1590
|
const indexOutputFile = join7(indexOutputDir, `${entryBaseName}.js`);
|
|
1589
|
-
const clientOutputFile = join7(clientOutputDir,
|
|
1591
|
+
const clientOutputFile = join7(clientOutputDir, relative4(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
|
|
1590
1592
|
await mkdir2(dirname4(indexOutputFile), { recursive: true });
|
|
1591
1593
|
const vueHmrImports = isDev ? [
|
|
1592
1594
|
`window.__HMR_FRAMEWORK__ = "vue";`,
|
|
@@ -1594,7 +1596,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
1594
1596
|
] : [];
|
|
1595
1597
|
await write2(indexOutputFile, [
|
|
1596
1598
|
...vueHmrImports,
|
|
1597
|
-
`import Comp from "${
|
|
1599
|
+
`import Comp from "${relative4(dirname4(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
|
|
1598
1600
|
'import { createSSRApp, createApp } from "vue";',
|
|
1599
1601
|
"",
|
|
1600
1602
|
"// HMR State Preservation: Check for preserved state from HMR",
|
|
@@ -1694,7 +1696,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
1694
1696
|
await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
|
|
1695
1697
|
const sourceCode = await file2(tsPath).text();
|
|
1696
1698
|
const transpiledCode = transpiler2.transformSync(sourceCode);
|
|
1697
|
-
const relativeJsPath =
|
|
1699
|
+
const relativeJsPath = relative4(vueRootDir, tsPath).replace(/\.ts$/, ".js");
|
|
1698
1700
|
const outClientPath = join7(clientOutputDir, relativeJsPath);
|
|
1699
1701
|
const outServerPath = join7(serverOutputDir, relativeJsPath);
|
|
1700
1702
|
await mkdir2(dirname4(outClientPath), { recursive: true });
|
|
@@ -10584,11 +10586,11 @@ ${lanes.join(`
|
|
|
10584
10586
|
return toComponents;
|
|
10585
10587
|
}
|
|
10586
10588
|
const components = toComponents.slice(start);
|
|
10587
|
-
const
|
|
10589
|
+
const relative5 = [];
|
|
10588
10590
|
for (;start < fromComponents.length; start++) {
|
|
10589
|
-
|
|
10591
|
+
relative5.push("..");
|
|
10590
10592
|
}
|
|
10591
|
-
return ["", ...
|
|
10593
|
+
return ["", ...relative5, ...components];
|
|
10592
10594
|
}
|
|
10593
10595
|
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
10594
10596
|
Debug.assert(getRootLength(fromDirectory) > 0 === getRootLength(to) > 0, "Paths must either both be absolute or both be relative");
|
|
@@ -47884,9 +47886,9 @@ ${lanes.join(`
|
|
|
47884
47886
|
if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
|
|
47885
47887
|
return;
|
|
47886
47888
|
}
|
|
47887
|
-
const
|
|
47889
|
+
const relative5 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
|
|
47888
47890
|
for (const symlinkDirectory of symlinkDirectories) {
|
|
47889
|
-
const option = resolvePath(symlinkDirectory,
|
|
47891
|
+
const option = resolvePath(symlinkDirectory, relative5);
|
|
47890
47892
|
const result2 = cb(option, target === referenceRedirect);
|
|
47891
47893
|
shouldFilterIgnoredPaths = true;
|
|
47892
47894
|
if (result2)
|
|
@@ -170452,7 +170454,7 @@ __export(exports_compileAngular, {
|
|
|
170452
170454
|
compileAngular: () => compileAngular
|
|
170453
170455
|
});
|
|
170454
170456
|
import { existsSync as existsSync10, readFileSync as readFileSync4, promises as fs } from "fs";
|
|
170455
|
-
import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve9, relative as
|
|
170457
|
+
import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve9, relative as relative5 } from "path";
|
|
170456
170458
|
import { createHash as createHash2 } from "crypto";
|
|
170457
170459
|
var import_typescript, computeConfigHash = () => {
|
|
170458
170460
|
try {
|
|
@@ -170761,7 +170763,7 @@ export default ${componentClassName};
|
|
|
170761
170763
|
await fs.writeFile(ssrDepsFile, ssrDepsContent, "utf-8");
|
|
170762
170764
|
}
|
|
170763
170765
|
await fs.writeFile(rawServerFile, rewritten, "utf-8");
|
|
170764
|
-
const relativePath =
|
|
170766
|
+
const relativePath = relative5(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
170765
170767
|
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
170766
170768
|
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
170767
170769
|
import "${hmrRuntimePath}";
|
|
@@ -171140,7 +171142,7 @@ import {
|
|
|
171140
171142
|
rmSync,
|
|
171141
171143
|
writeFileSync as writeFileSync3
|
|
171142
171144
|
} from "fs";
|
|
171143
|
-
import { basename as basename5, join as join13, relative as
|
|
171145
|
+
import { basename as basename5, join as join13, relative as relative6, resolve as resolve10 } from "path";
|
|
171144
171146
|
import { cwd, env as env2, exit } from "process";
|
|
171145
171147
|
var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
|
|
171146
171148
|
var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
|
|
@@ -171705,7 +171707,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
|
|
|
171705
171707
|
const devIndexDir = join13(buildPath, "_src_indexes");
|
|
171706
171708
|
mkdirSync8(devIndexDir, { recursive: true });
|
|
171707
171709
|
const indexFiles = readDir(reactIndexesPath).filter((f) => f.endsWith(".tsx"));
|
|
171708
|
-
const pagesRel =
|
|
171710
|
+
const pagesRel = relative6(process.cwd(), resolve10(reactPagesPath)).replace(/\\/g, "/");
|
|
171709
171711
|
for (const file3 of indexFiles) {
|
|
171710
171712
|
let content = readFileSync5(join13(reactIndexesPath, file3), "utf-8");
|
|
171711
171713
|
content = content.replace(/from\s*['"]\.\.\/pages\/([^'"]+)['"]/g, `from '/@src/${pagesRel}/$1'`);
|
|
@@ -202323,15 +202325,6 @@ var init_pageHandler = __esm(() => {
|
|
|
202323
202325
|
});
|
|
202324
202326
|
|
|
202325
202327
|
// src/dev/transformCache.ts
|
|
202326
|
-
var exports_transformCache = {};
|
|
202327
|
-
__export(exports_transformCache, {
|
|
202328
|
-
setTransformed: () => setTransformed,
|
|
202329
|
-
invalidateAll: () => invalidateAll,
|
|
202330
|
-
invalidate: () => invalidate,
|
|
202331
|
-
getTransformed: () => getTransformed,
|
|
202332
|
-
getInvalidationVersion: () => getInvalidationVersion,
|
|
202333
|
-
findNearestComponent: () => findNearestComponent
|
|
202334
|
-
});
|
|
202335
202328
|
var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
|
|
202336
202329
|
const resolvedImports = imports ?? [];
|
|
202337
202330
|
cache.set(filePath, { content, imports: resolvedImports, mtime });
|
|
@@ -202350,29 +202343,9 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
|
|
|
202350
202343
|
cache.delete(parent);
|
|
202351
202344
|
}
|
|
202352
202345
|
}
|
|
202353
|
-
},
|
|
202354
|
-
|
|
202355
|
-
|
|
202356
|
-
}, findNearestComponent = (filePath) => {
|
|
202357
|
-
const visited = new Set;
|
|
202358
|
-
const queue = [filePath];
|
|
202359
|
-
while (queue.length > 0) {
|
|
202360
|
-
const current = queue.shift();
|
|
202361
|
-
if (visited.has(current))
|
|
202362
|
-
continue;
|
|
202363
|
-
visited.add(current);
|
|
202364
|
-
const parents = importers.get(current);
|
|
202365
|
-
if (!parents)
|
|
202366
|
-
continue;
|
|
202367
|
-
for (const parent of parents) {
|
|
202368
|
-
if (parent.endsWith(".tsx") || parent.endsWith(".jsx")) {
|
|
202369
|
-
return parent;
|
|
202370
|
-
}
|
|
202371
|
-
queue.push(parent);
|
|
202372
|
-
}
|
|
202373
|
-
}
|
|
202374
|
-
return;
|
|
202375
|
-
};
|
|
202346
|
+
}, dataFiles, markAsDataFile = (filePath) => {
|
|
202347
|
+
dataFiles.add(filePath);
|
|
202348
|
+
}, isDataFile = (filePath) => dataFiles.has(filePath);
|
|
202376
202349
|
var init_transformCache = __esm(() => {
|
|
202377
202350
|
globalStore = globalThis;
|
|
202378
202351
|
cache = globalStore.__transformCache ?? new Map;
|
|
@@ -202381,6 +202354,8 @@ var init_transformCache = __esm(() => {
|
|
|
202381
202354
|
globalStore.__transformImporters = importers;
|
|
202382
202355
|
invalidationVersions = globalStore.__transformInvalidationVersions ?? new Map;
|
|
202383
202356
|
globalStore.__transformInvalidationVersions = invalidationVersions;
|
|
202357
|
+
dataFiles = globalStore.__transformDataFiles ?? new Set;
|
|
202358
|
+
globalStore.__transformDataFiles = dataFiles;
|
|
202384
202359
|
});
|
|
202385
202360
|
|
|
202386
202361
|
// src/dev/moduleServer.ts
|
|
@@ -202394,7 +202369,7 @@ __export(exports_moduleServer, {
|
|
|
202394
202369
|
SRC_URL_PREFIX: () => SRC_URL_PREFIX
|
|
202395
202370
|
});
|
|
202396
202371
|
import { existsSync as existsSync13, readFileSync as readFileSync9, statSync } from "fs";
|
|
202397
|
-
import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve17, relative as
|
|
202372
|
+
import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve17, relative as relative7 } from "path";
|
|
202398
202373
|
var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
|
|
202399
202374
|
const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
|
|
202400
202375
|
const allExports = [];
|
|
@@ -202457,7 +202432,7 @@ ${stubs}
|
|
|
202457
202432
|
const fileDir = dirname7(filePath);
|
|
202458
202433
|
result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => {
|
|
202459
202434
|
const absPath = resolve17(fileDir, relPath);
|
|
202460
|
-
const rel =
|
|
202435
|
+
const rel = relative7(projectRoot, absPath);
|
|
202461
202436
|
let srcPath = rel;
|
|
202462
202437
|
if (!extname3(srcPath)) {
|
|
202463
202438
|
const extensions = [
|
|
@@ -202478,19 +202453,19 @@ ${stubs}
|
|
|
202478
202453
|
}
|
|
202479
202454
|
if (extname3(srcPath) === ".svelte") {
|
|
202480
202455
|
const resolved = resolveSvelteModulePath(resolve17(projectRoot, srcPath));
|
|
202481
|
-
const resolvedRel =
|
|
202456
|
+
const resolvedRel = relative7(projectRoot, resolved);
|
|
202482
202457
|
srcPath = resolvedRel;
|
|
202483
202458
|
}
|
|
202484
202459
|
return `${prefix}${srcUrl(srcPath, projectRoot)}${suffix}`;
|
|
202485
202460
|
});
|
|
202486
202461
|
result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => {
|
|
202487
202462
|
const absPath = resolve17(fileDir, relPath);
|
|
202488
|
-
const rel =
|
|
202463
|
+
const rel = relative7(projectRoot, absPath);
|
|
202489
202464
|
return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
|
|
202490
202465
|
});
|
|
202491
202466
|
result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => {
|
|
202492
202467
|
const absPath = resolve17(fileDir, relPath);
|
|
202493
|
-
const rel =
|
|
202468
|
+
const rel = relative7(projectRoot, absPath);
|
|
202494
202469
|
let srcPath = rel;
|
|
202495
202470
|
if (!extname3(srcPath)) {
|
|
202496
202471
|
const extensions = [
|
|
@@ -202514,16 +202489,65 @@ ${stubs}
|
|
|
202514
202489
|
});
|
|
202515
202490
|
result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, (_match, prefix, absPath, _ext, suffix) => {
|
|
202516
202491
|
if (absPath.startsWith(projectRoot)) {
|
|
202517
|
-
const rel2 =
|
|
202492
|
+
const rel2 = relative7(projectRoot, absPath).replace(/\\/g, "/");
|
|
202518
202493
|
return `${prefix}${srcUrl(rel2, projectRoot)}${suffix}`;
|
|
202519
202494
|
}
|
|
202520
|
-
const rel =
|
|
202495
|
+
const rel = relative7(projectRoot, absPath).replace(/\\/g, "/");
|
|
202521
202496
|
if (!rel.startsWith("..")) {
|
|
202522
202497
|
return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
|
|
202523
202498
|
}
|
|
202524
202499
|
return _match;
|
|
202525
202500
|
});
|
|
202526
202501
|
return result;
|
|
202502
|
+
}, NAMED_IMPORT_RE, rewriteDataImports = (code, projectRoot) => {
|
|
202503
|
+
const rewrites = [];
|
|
202504
|
+
let counter = 0;
|
|
202505
|
+
let m;
|
|
202506
|
+
NAMED_IMPORT_RE.lastIndex = 0;
|
|
202507
|
+
while ((m = NAMED_IMPORT_RE.exec(code)) !== null) {
|
|
202508
|
+
const [fullMatch, names, q1, srcUrl2, q2] = m;
|
|
202509
|
+
if (!names || !srcUrl2)
|
|
202510
|
+
continue;
|
|
202511
|
+
const urlPath = srcUrl2.replace(/^\/@src\//, "").split("?")[0];
|
|
202512
|
+
if (!urlPath || !urlPath.endsWith(".ts") || urlPath.endsWith(".d.ts"))
|
|
202513
|
+
continue;
|
|
202514
|
+
const absPath = resolve17(projectRoot, urlPath);
|
|
202515
|
+
if (!isDataFile(absPath)) {
|
|
202516
|
+
if (!urlPath.endsWith(".tsx") && existsSync13(absPath)) {
|
|
202517
|
+
try {
|
|
202518
|
+
const src = readFileSync9(absPath, "utf-8");
|
|
202519
|
+
const exps = tsTranspiler2.scan(src).exports;
|
|
202520
|
+
if (isDataOnlyFile(exps, src, absPath))
|
|
202521
|
+
markAsDataFile(absPath);
|
|
202522
|
+
} catch {}
|
|
202523
|
+
}
|
|
202524
|
+
if (!isDataFile(absPath))
|
|
202525
|
+
continue;
|
|
202526
|
+
}
|
|
202527
|
+
const alias = `__hmr_${counter++}`;
|
|
202528
|
+
const importedNames = names.split(",").map((n) => n.trim().split(/\s+as\s+/)).filter(([n]) => n).map(([orig, asName]) => ({
|
|
202529
|
+
local: (asName ?? orig).trim(),
|
|
202530
|
+
orig: orig.trim()
|
|
202531
|
+
}));
|
|
202532
|
+
rewrites.push({
|
|
202533
|
+
alias,
|
|
202534
|
+
fullMatch,
|
|
202535
|
+
importLine: `import ${alias} from ${q1}${srcUrl2}${q2}`,
|
|
202536
|
+
names: importedNames
|
|
202537
|
+
});
|
|
202538
|
+
}
|
|
202539
|
+
if (rewrites.length === 0)
|
|
202540
|
+
return code;
|
|
202541
|
+
let result = code;
|
|
202542
|
+
for (const r of rewrites) {
|
|
202543
|
+
result = result.replace(r.fullMatch, r.importLine);
|
|
202544
|
+
}
|
|
202545
|
+
for (const r of rewrites) {
|
|
202546
|
+
for (const { orig, local } of r.names) {
|
|
202547
|
+
result = result.replace(new RegExp(`(?<![.\\w])${local}(?![\\w])`, "g"), `${r.alias}.${orig}`);
|
|
202548
|
+
}
|
|
202549
|
+
}
|
|
202550
|
+
return result;
|
|
202527
202551
|
}, HOOK_NAMES, REFRESH_PREAMBLE, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
|
|
202528
202552
|
const imports = [];
|
|
202529
202553
|
const jsxDevMatch = JSX_AUTO_RE.exec(code);
|
|
@@ -202559,9 +202583,38 @@ ${stubs}
|
|
|
202559
202583
|
transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
|
|
202560
202584
|
` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
|
|
202561
202585
|
` + transpiled;
|
|
202562
|
-
const relPath =
|
|
202586
|
+
const relPath = relative7(projectRoot, filePath).replace(/\\/g, "/");
|
|
202563
202587
|
transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
|
|
202564
|
-
|
|
202588
|
+
let result = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
|
|
202589
|
+
result = rewriteDataImports(result, projectRoot);
|
|
202590
|
+
return result;
|
|
202591
|
+
}, isDataOnlyFile = (exports, _source, filePath) => {
|
|
202592
|
+
if (exports.length === 0)
|
|
202593
|
+
return false;
|
|
202594
|
+
if (filePath) {
|
|
202595
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
202596
|
+
if (!normalized.includes("/data/"))
|
|
202597
|
+
return false;
|
|
202598
|
+
}
|
|
202599
|
+
if (exports.some((e) => /^[A-Z]/.test(e) || /^use[A-Z]/.test(e)))
|
|
202600
|
+
return false;
|
|
202601
|
+
return true;
|
|
202602
|
+
}, wrapDataExports = (transpiled, filePath, exports) => {
|
|
202603
|
+
const storeKey = filePath.replace(/\\/g, "/");
|
|
202604
|
+
let result = transpiled;
|
|
202605
|
+
for (const name of exports) {
|
|
202606
|
+
result = result.replace(new RegExp(`export\\s+(const|let|var)\\s+${name}\\s*=`), `$1 ${name} =`);
|
|
202607
|
+
}
|
|
202608
|
+
const preamble = `const __hmr = ((globalThis.__HMR_DATA__ ??= {})[${JSON.stringify(storeKey)}] ??= {});
|
|
202609
|
+
`;
|
|
202610
|
+
const storeWrites = exports.map((name) => `__hmr.${name} = ${name};`).join(`
|
|
202611
|
+
`);
|
|
202612
|
+
const namedExport = exports.length > 0 ? `export { ${exports.join(", ")} };
|
|
202613
|
+
` : "";
|
|
202614
|
+
return preamble + result + `
|
|
202615
|
+
` + storeWrites + `
|
|
202616
|
+
` + namedExport + `export default __hmr;
|
|
202617
|
+
`;
|
|
202565
202618
|
}, transformPlainFile = (filePath, projectRoot, rewriter) => {
|
|
202566
202619
|
const raw = readFileSync9(filePath, "utf-8");
|
|
202567
202620
|
const ext = extname3(filePath);
|
|
@@ -202573,7 +202626,13 @@ ${stubs}
|
|
|
202573
202626
|
if (isTS) {
|
|
202574
202627
|
transpiled = preserveTypeExports(raw, transpiled, valueExports);
|
|
202575
202628
|
}
|
|
202576
|
-
|
|
202629
|
+
if (isTS && !isTSX && isDataOnlyFile(valueExports, transpiled, filePath)) {
|
|
202630
|
+
transpiled = wrapDataExports(transpiled, filePath, valueExports);
|
|
202631
|
+
markAsDataFile(filePath);
|
|
202632
|
+
}
|
|
202633
|
+
let result = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
|
|
202634
|
+
result = rewriteDataImports(result, projectRoot);
|
|
202635
|
+
return result;
|
|
202577
202636
|
}, svelteExternalCss, svelteCompiler = null, vueCompiler = null, warmCompilers = async (frameworks) => {
|
|
202578
202637
|
const [sc, vc] = await Promise.all([
|
|
202579
202638
|
frameworks.svelte ? import("svelte/compiler") : undefined,
|
|
@@ -202626,11 +202685,11 @@ ${stubs}
|
|
|
202626
202685
|
if (compiled.css?.code) {
|
|
202627
202686
|
const cssPath = `${filePath}.css`;
|
|
202628
202687
|
svelteExternalCss.set(cssPath, compiled.css.code);
|
|
202629
|
-
const cssUrl = srcUrl(
|
|
202688
|
+
const cssUrl = srcUrl(relative7(projectRoot, cssPath), projectRoot);
|
|
202630
202689
|
code = `import "${cssUrl}";
|
|
202631
202690
|
${code}`;
|
|
202632
202691
|
}
|
|
202633
|
-
const moduleUrl = `${SRC_PREFIX}${
|
|
202692
|
+
const moduleUrl = `${SRC_PREFIX}${relative7(projectRoot, filePath).replace(/\\/g, "/")}`;
|
|
202634
202693
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
202635
202694
|
if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
202636
202695
|
var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
|
|
@@ -202694,7 +202753,7 @@ ${code}`;
|
|
|
202694
202753
|
}
|
|
202695
202754
|
code = tsTranspiler2.transformSync(code);
|
|
202696
202755
|
const hmrBase = vueDir ? resolve17(vueDir) : projectRoot;
|
|
202697
|
-
const hmrId =
|
|
202756
|
+
const hmrId = relative7(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
|
|
202698
202757
|
code = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
|
|
202699
202758
|
code += [
|
|
202700
202759
|
"",
|
|
@@ -202951,6 +203010,7 @@ var init_moduleServer = __esm(() => {
|
|
|
202951
203010
|
STRING_CONTENTS_RE = /`(?:[^`\\]|\\.)*`|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/gs;
|
|
202952
203011
|
REACT_EXTENSIONS = new Set([".tsx", ".jsx"]);
|
|
202953
203012
|
mtimeCache = new Map;
|
|
203013
|
+
NAMED_IMPORT_RE = /import\s*\{([^}]+)\}\s*from\s*(["'])(\/\@src\/[^"']+)(["']);?/g;
|
|
202954
203014
|
HOOK_NAMES = new Set([
|
|
202955
203015
|
"useState",
|
|
202956
203016
|
"useReducer",
|
|
@@ -203053,7 +203113,7 @@ var init_simpleHTMXHMR = () => {};
|
|
|
203053
203113
|
// src/dev/rebuildTrigger.ts
|
|
203054
203114
|
import { existsSync as existsSync14 } from "fs";
|
|
203055
203115
|
import { rm as rm8 } from "fs/promises";
|
|
203056
|
-
import { basename as basename8, relative as
|
|
203116
|
+
import { basename as basename8, relative as relative8, resolve as resolve20 } from "path";
|
|
203057
203117
|
var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
|
|
203058
203118
|
const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
|
|
203059
203119
|
if (pathLineCol) {
|
|
@@ -203487,7 +203547,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203487
203547
|
}, getModuleUrl = async (pageFile) => {
|
|
203488
203548
|
const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
|
|
203489
203549
|
invalidateModule2(pageFile);
|
|
203490
|
-
const rel =
|
|
203550
|
+
const rel = relative8(process.cwd(), pageFile).replace(/\\/g, "/");
|
|
203491
203551
|
const url = `${SRC_URL_PREFIX2}${rel}`;
|
|
203492
203552
|
warmCache2(url);
|
|
203493
203553
|
return url;
|
|
@@ -203513,18 +203573,10 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203513
203573
|
for (const file3 of reactFiles) {
|
|
203514
203574
|
invalidateModule2(file3);
|
|
203515
203575
|
}
|
|
203516
|
-
const
|
|
203517
|
-
let broadcastTarget = primaryFile;
|
|
203518
|
-
if (!isComponentFile) {
|
|
203519
|
-
const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
|
|
203520
|
-
const nearest = findNearestComponent2(resolve20(primaryFile));
|
|
203521
|
-
if (nearest)
|
|
203522
|
-
broadcastTarget = nearest;
|
|
203523
|
-
}
|
|
203524
|
-
const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
|
|
203576
|
+
const pageModuleUrl = await getReactModuleUrl(primaryFile);
|
|
203525
203577
|
if (pageModuleUrl) {
|
|
203526
203578
|
const serverDuration = Date.now() - startTime;
|
|
203527
|
-
state.lastHmrPath =
|
|
203579
|
+
state.lastHmrPath = relative8(process.cwd(), primaryFile).replace(/\\/g, "/");
|
|
203528
203580
|
state.lastHmrFramework = "react";
|
|
203529
203581
|
broadcastToClients(state, {
|
|
203530
203582
|
data: {
|
|
@@ -203910,7 +203962,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203910
203962
|
const baseName = fileName.replace(/\.vue$/, "");
|
|
203911
203963
|
const pascalName = toPascal(baseName);
|
|
203912
203964
|
const vueRoot = config.vueDirectory;
|
|
203913
|
-
const hmrId = vueRoot ?
|
|
203965
|
+
const hmrId = vueRoot ? relative8(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
|
|
203914
203966
|
const cssKey = `${pascalName}CSS`;
|
|
203915
203967
|
const cssUrl = manifest[cssKey] || null;
|
|
203916
203968
|
const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
|
|
@@ -204904,5 +204956,5 @@ export {
|
|
|
204904
204956
|
build
|
|
204905
204957
|
};
|
|
204906
204958
|
|
|
204907
|
-
//# debugId=
|
|
204959
|
+
//# debugId=41B0D1EA4875F1DA64756E2164756E21
|
|
204908
204960
|
//# sourceMappingURL=build.js.map
|