@absolutejs/absolute 0.19.0-beta.102 → 0.19.0-beta.104
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 +119 -87
- package/dist/build.js.map +5 -5
- package/dist/dev/client/handlers/react.ts +0 -12
- package/dist/index.js +122 -90
- package/dist/index.js.map +5 -5
- package/package.json +1 -1
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");
|
|
@@ -412,42 +412,7 @@ var indexContentCache, resolveDevClientDir = () => {
|
|
|
412
412
|
` originalError.apply(console, args);`,
|
|
413
413
|
` };`,
|
|
414
414
|
` }`,
|
|
415
|
-
`}
|
|
416
|
-
...isDev ? [
|
|
417
|
-
`
|
|
418
|
-
// HMR: re-import the page component and re-render the root.`,
|
|
419
|
-
`// This is the Vite-style approach \u2014 the index file is the`,
|
|
420
|
-
`// HMR boundary. Works for all patterns: dynamic imports,`,
|
|
421
|
-
`// lazy loading, portals, data files.`,
|
|
422
|
-
`if (window.__HMR_WS__ && window.__REACT_ROOT__ && !window.__HMR_ROOT_ACCEPT__) {`,
|
|
423
|
-
` window.__HMR_ROOT_ACCEPT__ = true;`,
|
|
424
|
-
` const origOnMessage = window.__HMR_WS__.onmessage;`,
|
|
425
|
-
` window.__HMR_WS__.onmessage = function(event) {`,
|
|
426
|
-
` if (origOnMessage) origOnMessage.call(this, event);`,
|
|
427
|
-
` try {`,
|
|
428
|
-
` const msg = JSON.parse(event.data);`,
|
|
429
|
-
` if (msg.type === 'react-update' && msg.data?.primarySource && !msg.data.primarySource.endsWith('.tsx') && !msg.data.primarySource.endsWith('.jsx')) {`,
|
|
430
|
-
` const url = "/@src/${relative(process.cwd(), resolve(reactPagesDirectory, componentName + ".tsx")).replace(/\\/g, "/")}";`,
|
|
431
|
-
` const start = performance.now();`,
|
|
432
|
-
` import(url + '?t=' + Date.now()).then(mod => {`,
|
|
433
|
-
` const Comp = mod.${componentName} || mod.default;`,
|
|
434
|
-
` if (Comp && window.__REACT_ROOT__) {`,
|
|
435
|
-
` const props = window.__INITIAL_PROPS__ || {};`,
|
|
436
|
-
` window.__REACT_ROOT__.render(`,
|
|
437
|
-
` ${isDev ? `createElement(ErrorBoundary, null, createElement(Comp, props))` : `createElement(Comp, props)`}`,
|
|
438
|
-
` );`,
|
|
439
|
-
` if (window.__HMR_WS__) {`,
|
|
440
|
-
` const ms = Math.round(performance.now() - start);`,
|
|
441
|
-
` const total = (msg.data.serverDuration || 0) + ms;`,
|
|
442
|
-
` window.__HMR_WS__.send(JSON.stringify({ type: 'hmr-timing', duration: total }));`,
|
|
443
|
-
` }`,
|
|
444
|
-
` }`,
|
|
445
|
-
` }).catch(() => {});`,
|
|
446
|
-
` }`,
|
|
447
|
-
` } catch {}`,
|
|
448
|
-
` };`,
|
|
449
|
-
`}`
|
|
450
|
-
] : []
|
|
415
|
+
`}`
|
|
451
416
|
].join(`
|
|
452
417
|
`);
|
|
453
418
|
const indexPath = join(reactIndexesDirectory, `${componentName}.tsx`);
|
|
@@ -901,7 +866,7 @@ var devVendorPaths = null, getDevVendorPaths = () => devVendorPaths, setDevVendo
|
|
|
901
866
|
|
|
902
867
|
// src/build/angularLinkerPlugin.ts
|
|
903
868
|
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
904
|
-
import { dirname as dirname2, join as join4, relative
|
|
869
|
+
import { dirname as dirname2, join as join4, relative, resolve as resolve4 } from "path";
|
|
905
870
|
import { createHash } from "crypto";
|
|
906
871
|
var CACHE_DIR, angularLinkerPlugin;
|
|
907
872
|
var init_angularLinkerPlugin = __esm(() => {
|
|
@@ -944,7 +909,7 @@ var init_angularLinkerPlugin = __esm(() => {
|
|
|
944
909
|
dirname: dirname2,
|
|
945
910
|
exists: existsSync7,
|
|
946
911
|
readFile: readFileSync3,
|
|
947
|
-
relative
|
|
912
|
+
relative,
|
|
948
913
|
resolve: resolve4
|
|
949
914
|
},
|
|
950
915
|
linkerJitMode: false,
|
|
@@ -985,11 +950,11 @@ var HASHED_FILE_PATTERN, cleanStaleOutputs = async (buildPath, currentOutputPath
|
|
|
985
950
|
const currentPaths = new Set(currentOutputPaths.map((path) => resolve5(path)));
|
|
986
951
|
const glob = new Glob4("**/*");
|
|
987
952
|
const removals = [];
|
|
988
|
-
for (const
|
|
989
|
-
const absolute = resolve5(buildPath,
|
|
953
|
+
for (const relative2 of glob.scanSync({ cwd: buildPath })) {
|
|
954
|
+
const absolute = resolve5(buildPath, relative2);
|
|
990
955
|
if (currentPaths.has(absolute))
|
|
991
956
|
continue;
|
|
992
|
-
if (!HASHED_FILE_PATTERN.test(
|
|
957
|
+
if (!HASHED_FILE_PATTERN.test(relative2))
|
|
993
958
|
continue;
|
|
994
959
|
removals.push(rm2(absolute, { force: true }));
|
|
995
960
|
}
|
|
@@ -1143,12 +1108,12 @@ var init_startupBanner = __esm(() => {
|
|
|
1143
1108
|
// src/utils/logger.ts
|
|
1144
1109
|
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
1145
1110
|
const cwd = process.cwd();
|
|
1146
|
-
let
|
|
1147
|
-
|
|
1148
|
-
if (!
|
|
1149
|
-
|
|
1111
|
+
let relative2 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
1112
|
+
relative2 = relative2.replace(/\\/g, "/");
|
|
1113
|
+
if (!relative2.startsWith("/")) {
|
|
1114
|
+
relative2 = `/${relative2}`;
|
|
1150
1115
|
}
|
|
1151
|
-
return
|
|
1116
|
+
return relative2;
|
|
1152
1117
|
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
1153
1118
|
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1154
1119
|
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
@@ -1207,11 +1172,11 @@ var init_logger = __esm(() => {
|
|
|
1207
1172
|
});
|
|
1208
1173
|
|
|
1209
1174
|
// src/utils/validateSafePath.ts
|
|
1210
|
-
import { resolve as resolve6, relative as
|
|
1175
|
+
import { resolve as resolve6, relative as relative2 } from "path";
|
|
1211
1176
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
1212
1177
|
const absoluteBase = resolve6(baseDirectory);
|
|
1213
1178
|
const absoluteTarget = resolve6(baseDirectory, targetPath);
|
|
1214
|
-
const relativePath = normalizePath(
|
|
1179
|
+
const relativePath = normalizePath(relative2(absoluteBase, absoluteTarget));
|
|
1215
1180
|
if (relativePath.startsWith("../") || relativePath === "..") {
|
|
1216
1181
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
1217
1182
|
}
|
|
@@ -1233,7 +1198,7 @@ import {
|
|
|
1233
1198
|
basename as basename2,
|
|
1234
1199
|
extname as extname2,
|
|
1235
1200
|
resolve as resolve7,
|
|
1236
|
-
relative as
|
|
1201
|
+
relative as relative3,
|
|
1237
1202
|
sep
|
|
1238
1203
|
} from "path";
|
|
1239
1204
|
import { env } from "process";
|
|
@@ -1297,7 +1262,7 @@ var resolveDevClientDir2 = () => {
|
|
|
1297
1262
|
const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
|
|
1298
1263
|
const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
|
|
1299
1264
|
const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
|
|
1300
|
-
const relDir = dirname3(
|
|
1265
|
+
const relDir = dirname3(relative3(svelteRoot, src)).replace(/\\/g, "/");
|
|
1301
1266
|
const baseName = basename2(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
1302
1267
|
const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
1303
1268
|
const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
|
|
@@ -1316,7 +1281,7 @@ var resolveDevClientDir2 = () => {
|
|
|
1316
1281
|
}).js.code;
|
|
1317
1282
|
let code = raw2.replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
1318
1283
|
if (mode === "client" && isDev) {
|
|
1319
|
-
const moduleKey = `/@src/${
|
|
1284
|
+
const moduleKey = `/@src/${relative3(process.cwd(), src).replace(/\\/g, "/")}`;
|
|
1320
1285
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
1321
1286
|
if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
1322
1287
|
var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleKey)}] = cb; };`);
|
|
@@ -1351,10 +1316,10 @@ var resolveDevClientDir2 = () => {
|
|
|
1351
1316
|
};
|
|
1352
1317
|
const roots = await Promise.all(entryPoints.map(build));
|
|
1353
1318
|
await Promise.all(roots.map(async ({ client }) => {
|
|
1354
|
-
const relClientDir = dirname3(
|
|
1319
|
+
const relClientDir = dirname3(relative3(clientDir, client));
|
|
1355
1320
|
const name = basename2(client, extname2(client));
|
|
1356
1321
|
const indexPath = join6(indexDir, relClientDir, `${name}.js`);
|
|
1357
|
-
const importRaw =
|
|
1322
|
+
const importRaw = relative3(dirname3(indexPath), client).split(sep).join("/");
|
|
1358
1323
|
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
1359
1324
|
const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
1360
1325
|
import "${hmrClientPath3}";
|
|
@@ -1394,7 +1359,7 @@ if (typeof window !== "undefined") {
|
|
|
1394
1359
|
return {
|
|
1395
1360
|
svelteClientPaths: roots.map(({ client }) => client),
|
|
1396
1361
|
svelteIndexPaths: roots.map(({ client }) => {
|
|
1397
|
-
const rel = dirname3(
|
|
1362
|
+
const rel = dirname3(relative3(clientDir, client));
|
|
1398
1363
|
return join6(indexDir, rel, basename2(client));
|
|
1399
1364
|
}),
|
|
1400
1365
|
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
@@ -1419,7 +1384,7 @@ __export(exports_compileVue, {
|
|
|
1419
1384
|
});
|
|
1420
1385
|
import { existsSync as existsSync9 } from "fs";
|
|
1421
1386
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
1422
|
-
import { basename as basename3, dirname as dirname4, join as join7, relative as
|
|
1387
|
+
import { basename as basename3, dirname as dirname4, join as join7, relative as relative4, resolve as resolve8 } from "path";
|
|
1423
1388
|
var {file: file2, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
|
|
1424
1389
|
var resolveDevClientDir3 = () => {
|
|
1425
1390
|
const fromSource = resolve8(import.meta.dir, "../dev/client");
|
|
@@ -1464,7 +1429,7 @@ var resolveDevClientDir3 = () => {
|
|
|
1464
1429
|
return "template-only";
|
|
1465
1430
|
}
|
|
1466
1431
|
return "full";
|
|
1467
|
-
}, generateVueHmrId = (sourceFilePath, vueRootDir) =>
|
|
1432
|
+
}, 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) => {
|
|
1468
1433
|
if (filePath.endsWith(".vue"))
|
|
1469
1434
|
return filePath.replace(/\.vue$/, ".js");
|
|
1470
1435
|
if (filePath.endsWith(".ts"))
|
|
@@ -1491,7 +1456,7 @@ var resolveDevClientDir3 = () => {
|
|
|
1491
1456
|
const cachedResult = cacheMap.get(sourceFilePath);
|
|
1492
1457
|
if (cachedResult)
|
|
1493
1458
|
return cachedResult;
|
|
1494
|
-
const relativeFilePath =
|
|
1459
|
+
const relativeFilePath = relative4(vueRootDir, sourceFilePath).replace(/\\/g, "/");
|
|
1495
1460
|
const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
|
|
1496
1461
|
const fileBaseName = basename3(sourceFilePath, ".vue");
|
|
1497
1462
|
const componentId = toKebab(fileBaseName);
|
|
@@ -1620,7 +1585,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
1620
1585
|
result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
|
|
1621
1586
|
const entryBaseName = basename3(entryPath, ".vue");
|
|
1622
1587
|
const indexOutputFile = join7(indexOutputDir, `${entryBaseName}.js`);
|
|
1623
|
-
const clientOutputFile = join7(clientOutputDir,
|
|
1588
|
+
const clientOutputFile = join7(clientOutputDir, relative4(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
|
|
1624
1589
|
await mkdir2(dirname4(indexOutputFile), { recursive: true });
|
|
1625
1590
|
const vueHmrImports = isDev ? [
|
|
1626
1591
|
`window.__HMR_FRAMEWORK__ = "vue";`,
|
|
@@ -1628,7 +1593,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
1628
1593
|
] : [];
|
|
1629
1594
|
await write2(indexOutputFile, [
|
|
1630
1595
|
...vueHmrImports,
|
|
1631
|
-
`import Comp from "${
|
|
1596
|
+
`import Comp from "${relative4(dirname4(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
|
|
1632
1597
|
'import { createSSRApp, createApp } from "vue";',
|
|
1633
1598
|
"",
|
|
1634
1599
|
"// HMR State Preservation: Check for preserved state from HMR",
|
|
@@ -1728,7 +1693,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
1728
1693
|
await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
|
|
1729
1694
|
const sourceCode = await file2(tsPath).text();
|
|
1730
1695
|
const transpiledCode = transpiler2.transformSync(sourceCode);
|
|
1731
|
-
const relativeJsPath =
|
|
1696
|
+
const relativeJsPath = relative4(vueRootDir, tsPath).replace(/\.ts$/, ".js");
|
|
1732
1697
|
const outClientPath = join7(clientOutputDir, relativeJsPath);
|
|
1733
1698
|
const outServerPath = join7(serverOutputDir, relativeJsPath);
|
|
1734
1699
|
await mkdir2(dirname4(outClientPath), { recursive: true });
|
|
@@ -10618,11 +10583,11 @@ ${lanes.join(`
|
|
|
10618
10583
|
return toComponents;
|
|
10619
10584
|
}
|
|
10620
10585
|
const components = toComponents.slice(start);
|
|
10621
|
-
const
|
|
10586
|
+
const relative5 = [];
|
|
10622
10587
|
for (;start < fromComponents.length; start++) {
|
|
10623
|
-
|
|
10588
|
+
relative5.push("..");
|
|
10624
10589
|
}
|
|
10625
|
-
return ["", ...
|
|
10590
|
+
return ["", ...relative5, ...components];
|
|
10626
10591
|
}
|
|
10627
10592
|
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
10628
10593
|
Debug.assert(getRootLength(fromDirectory) > 0 === getRootLength(to) > 0, "Paths must either both be absolute or both be relative");
|
|
@@ -47918,9 +47883,9 @@ ${lanes.join(`
|
|
|
47918
47883
|
if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
|
|
47919
47884
|
return;
|
|
47920
47885
|
}
|
|
47921
|
-
const
|
|
47886
|
+
const relative5 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
|
|
47922
47887
|
for (const symlinkDirectory of symlinkDirectories) {
|
|
47923
|
-
const option = resolvePath(symlinkDirectory,
|
|
47888
|
+
const option = resolvePath(symlinkDirectory, relative5);
|
|
47924
47889
|
const result2 = cb(option, target === referenceRedirect);
|
|
47925
47890
|
shouldFilterIgnoredPaths = true;
|
|
47926
47891
|
if (result2)
|
|
@@ -170486,7 +170451,7 @@ __export(exports_compileAngular, {
|
|
|
170486
170451
|
compileAngular: () => compileAngular
|
|
170487
170452
|
});
|
|
170488
170453
|
import { existsSync as existsSync10, readFileSync as readFileSync4, promises as fs } from "fs";
|
|
170489
|
-
import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve9, relative as
|
|
170454
|
+
import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve9, relative as relative5 } from "path";
|
|
170490
170455
|
import { createHash as createHash2 } from "crypto";
|
|
170491
170456
|
var import_typescript, computeConfigHash = () => {
|
|
170492
170457
|
try {
|
|
@@ -170795,7 +170760,7 @@ export default ${componentClassName};
|
|
|
170795
170760
|
await fs.writeFile(ssrDepsFile, ssrDepsContent, "utf-8");
|
|
170796
170761
|
}
|
|
170797
170762
|
await fs.writeFile(rawServerFile, rewritten, "utf-8");
|
|
170798
|
-
const relativePath =
|
|
170763
|
+
const relativePath = relative5(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
170799
170764
|
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
170800
170765
|
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
170801
170766
|
import "${hmrRuntimePath}";
|
|
@@ -171174,7 +171139,7 @@ import {
|
|
|
171174
171139
|
rmSync,
|
|
171175
171140
|
writeFileSync as writeFileSync3
|
|
171176
171141
|
} from "fs";
|
|
171177
|
-
import { basename as basename5, join as join13, relative as
|
|
171142
|
+
import { basename as basename5, join as join13, relative as relative6, resolve as resolve10 } from "path";
|
|
171178
171143
|
import { cwd, env as env2, exit } from "process";
|
|
171179
171144
|
var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
|
|
171180
171145
|
var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
|
|
@@ -171596,6 +171561,21 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
|
|
|
171596
171561
|
}
|
|
171597
171562
|
const reactClientLogs = reactClientResult?.logs ?? [];
|
|
171598
171563
|
const reactClientOutputs = reactClientResult?.outputs ?? [];
|
|
171564
|
+
if (hmr && reactClientOutputs.length > 0) {
|
|
171565
|
+
const REFRESH_NOOP_RE = /window\.\$RefreshReg\$\|\|\(window\.\$RefreshReg\$=function\(\)\{\}\);window\.\$RefreshSig\$\|\|\(window\.\$RefreshSig\$=function\(\)\{return function\(t\)\{return t\}\}\);?\n?/g;
|
|
171566
|
+
for (const output of reactClientOutputs) {
|
|
171567
|
+
if (output.kind !== "entry-point")
|
|
171568
|
+
continue;
|
|
171569
|
+
try {
|
|
171570
|
+
const content = await Bun.file(output.path).text();
|
|
171571
|
+
if (REFRESH_NOOP_RE.test(content)) {
|
|
171572
|
+
REFRESH_NOOP_RE.lastIndex = 0;
|
|
171573
|
+
const stripped = content.replace(REFRESH_NOOP_RE, "");
|
|
171574
|
+
writeFileSync3(output.path, stripped);
|
|
171575
|
+
}
|
|
171576
|
+
} catch {}
|
|
171577
|
+
}
|
|
171578
|
+
}
|
|
171599
171579
|
if (reactClientResult && !reactClientResult.success && reactClientLogs.length > 0) {
|
|
171600
171580
|
extractBuildError(reactClientLogs, "react-client", "React client", frameworkNames, isIncremental, throwOnError);
|
|
171601
171581
|
}
|
|
@@ -171739,7 +171719,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
|
|
|
171739
171719
|
const devIndexDir = join13(buildPath, "_src_indexes");
|
|
171740
171720
|
mkdirSync8(devIndexDir, { recursive: true });
|
|
171741
171721
|
const indexFiles = readDir(reactIndexesPath).filter((f) => f.endsWith(".tsx"));
|
|
171742
|
-
const pagesRel =
|
|
171722
|
+
const pagesRel = relative6(process.cwd(), resolve10(reactPagesPath)).replace(/\\/g, "/");
|
|
171743
171723
|
for (const file3 of indexFiles) {
|
|
171744
171724
|
let content = readFileSync5(join13(reactIndexesPath, file3), "utf-8");
|
|
171745
171725
|
content = content.replace(/from\s*['"]\.\.\/pages\/([^'"]+)['"]/g, `from '/@src/${pagesRel}/$1'`);
|
|
@@ -202357,6 +202337,15 @@ var init_pageHandler = __esm(() => {
|
|
|
202357
202337
|
});
|
|
202358
202338
|
|
|
202359
202339
|
// src/dev/transformCache.ts
|
|
202340
|
+
var exports_transformCache = {};
|
|
202341
|
+
__export(exports_transformCache, {
|
|
202342
|
+
setTransformed: () => setTransformed,
|
|
202343
|
+
invalidateAll: () => invalidateAll,
|
|
202344
|
+
invalidate: () => invalidate,
|
|
202345
|
+
getTransformed: () => getTransformed,
|
|
202346
|
+
getInvalidationVersion: () => getInvalidationVersion,
|
|
202347
|
+
findNearestComponent: () => findNearestComponent
|
|
202348
|
+
});
|
|
202360
202349
|
var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
|
|
202361
202350
|
const resolvedImports = imports ?? [];
|
|
202362
202351
|
cache.set(filePath, { content, imports: resolvedImports, mtime });
|
|
@@ -202375,6 +202364,28 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
|
|
|
202375
202364
|
cache.delete(parent);
|
|
202376
202365
|
}
|
|
202377
202366
|
}
|
|
202367
|
+
}, invalidateAll = () => {
|
|
202368
|
+
cache.clear();
|
|
202369
|
+
importers.clear();
|
|
202370
|
+
}, findNearestComponent = (filePath) => {
|
|
202371
|
+
const visited = new Set;
|
|
202372
|
+
const queue = [filePath];
|
|
202373
|
+
while (queue.length > 0) {
|
|
202374
|
+
const current = queue.shift();
|
|
202375
|
+
if (visited.has(current))
|
|
202376
|
+
continue;
|
|
202377
|
+
visited.add(current);
|
|
202378
|
+
const parents = importers.get(current);
|
|
202379
|
+
if (!parents)
|
|
202380
|
+
continue;
|
|
202381
|
+
for (const parent of parents) {
|
|
202382
|
+
if (parent.endsWith(".tsx") || parent.endsWith(".jsx")) {
|
|
202383
|
+
return parent;
|
|
202384
|
+
}
|
|
202385
|
+
queue.push(parent);
|
|
202386
|
+
}
|
|
202387
|
+
}
|
|
202388
|
+
return;
|
|
202378
202389
|
};
|
|
202379
202390
|
var init_transformCache = __esm(() => {
|
|
202380
202391
|
globalStore = globalThis;
|
|
@@ -202397,7 +202408,7 @@ __export(exports_moduleServer, {
|
|
|
202397
202408
|
SRC_URL_PREFIX: () => SRC_URL_PREFIX
|
|
202398
202409
|
});
|
|
202399
202410
|
import { existsSync as existsSync13, readFileSync as readFileSync9, statSync } from "fs";
|
|
202400
|
-
import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve17, relative as
|
|
202411
|
+
import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve17, relative as relative7 } from "path";
|
|
202401
202412
|
var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
|
|
202402
202413
|
const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
|
|
202403
202414
|
const allExports = [];
|
|
@@ -202460,7 +202471,7 @@ ${stubs}
|
|
|
202460
202471
|
const fileDir = dirname7(filePath);
|
|
202461
202472
|
result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => {
|
|
202462
202473
|
const absPath = resolve17(fileDir, relPath);
|
|
202463
|
-
const rel =
|
|
202474
|
+
const rel = relative7(projectRoot, absPath);
|
|
202464
202475
|
let srcPath = rel;
|
|
202465
202476
|
if (!extname3(srcPath)) {
|
|
202466
202477
|
const extensions = [
|
|
@@ -202481,19 +202492,19 @@ ${stubs}
|
|
|
202481
202492
|
}
|
|
202482
202493
|
if (extname3(srcPath) === ".svelte") {
|
|
202483
202494
|
const resolved = resolveSvelteModulePath(resolve17(projectRoot, srcPath));
|
|
202484
|
-
const resolvedRel =
|
|
202495
|
+
const resolvedRel = relative7(projectRoot, resolved);
|
|
202485
202496
|
srcPath = resolvedRel;
|
|
202486
202497
|
}
|
|
202487
202498
|
return `${prefix}${srcUrl(srcPath, projectRoot)}${suffix}`;
|
|
202488
202499
|
});
|
|
202489
202500
|
result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => {
|
|
202490
202501
|
const absPath = resolve17(fileDir, relPath);
|
|
202491
|
-
const rel =
|
|
202502
|
+
const rel = relative7(projectRoot, absPath);
|
|
202492
202503
|
return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
|
|
202493
202504
|
});
|
|
202494
202505
|
result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => {
|
|
202495
202506
|
const absPath = resolve17(fileDir, relPath);
|
|
202496
|
-
const rel =
|
|
202507
|
+
const rel = relative7(projectRoot, absPath);
|
|
202497
202508
|
let srcPath = rel;
|
|
202498
202509
|
if (!extname3(srcPath)) {
|
|
202499
202510
|
const extensions = [
|
|
@@ -202517,10 +202528,10 @@ ${stubs}
|
|
|
202517
202528
|
});
|
|
202518
202529
|
result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, (_match, prefix, absPath, _ext, suffix) => {
|
|
202519
202530
|
if (absPath.startsWith(projectRoot)) {
|
|
202520
|
-
const rel2 =
|
|
202531
|
+
const rel2 = relative7(projectRoot, absPath).replace(/\\/g, "/");
|
|
202521
202532
|
return `${prefix}${srcUrl(rel2, projectRoot)}${suffix}`;
|
|
202522
202533
|
}
|
|
202523
|
-
const rel =
|
|
202534
|
+
const rel = relative7(projectRoot, absPath).replace(/\\/g, "/");
|
|
202524
202535
|
if (!rel.startsWith("..")) {
|
|
202525
202536
|
return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
|
|
202526
202537
|
}
|
|
@@ -202562,7 +202573,7 @@ ${stubs}
|
|
|
202562
202573
|
transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
|
|
202563
202574
|
` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
|
|
202564
202575
|
` + transpiled;
|
|
202565
|
-
const relPath =
|
|
202576
|
+
const relPath = relative7(projectRoot, filePath).replace(/\\/g, "/");
|
|
202566
202577
|
transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
|
|
202567
202578
|
return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
|
|
202568
202579
|
}, transformPlainFile = (filePath, projectRoot, rewriter) => {
|
|
@@ -202629,11 +202640,11 @@ ${stubs}
|
|
|
202629
202640
|
if (compiled.css?.code) {
|
|
202630
202641
|
const cssPath = `${filePath}.css`;
|
|
202631
202642
|
svelteExternalCss.set(cssPath, compiled.css.code);
|
|
202632
|
-
const cssUrl = srcUrl(
|
|
202643
|
+
const cssUrl = srcUrl(relative7(projectRoot, cssPath), projectRoot);
|
|
202633
202644
|
code = `import "${cssUrl}";
|
|
202634
202645
|
${code}`;
|
|
202635
202646
|
}
|
|
202636
|
-
const moduleUrl = `${SRC_PREFIX}${
|
|
202647
|
+
const moduleUrl = `${SRC_PREFIX}${relative7(projectRoot, filePath).replace(/\\/g, "/")}`;
|
|
202637
202648
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
202638
202649
|
if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
202639
202650
|
var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
|
|
@@ -202697,7 +202708,7 @@ ${code}`;
|
|
|
202697
202708
|
}
|
|
202698
202709
|
code = tsTranspiler2.transformSync(code);
|
|
202699
202710
|
const hmrBase = vueDir ? resolve17(vueDir) : projectRoot;
|
|
202700
|
-
const hmrId =
|
|
202711
|
+
const hmrId = relative7(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
|
|
202701
202712
|
code = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
|
|
202702
202713
|
code += [
|
|
202703
202714
|
"",
|
|
@@ -203060,7 +203071,7 @@ var init_simpleHTMXHMR = () => {};
|
|
|
203060
203071
|
// src/dev/rebuildTrigger.ts
|
|
203061
203072
|
import { existsSync as existsSync14 } from "fs";
|
|
203062
203073
|
import { rm as rm8 } from "fs/promises";
|
|
203063
|
-
import { basename as basename8, relative as
|
|
203074
|
+
import { basename as basename8, relative as relative8, resolve as resolve20 } from "path";
|
|
203064
203075
|
var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
|
|
203065
203076
|
const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
|
|
203066
203077
|
if (pathLineCol) {
|
|
@@ -203488,13 +203499,26 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203488
203499
|
if (vendorPaths) {
|
|
203489
203500
|
await rewriteReactImports2(clientResult.outputs.map((art) => art.path), vendorPaths);
|
|
203490
203501
|
}
|
|
203502
|
+
const { readFileSync: readFs, writeFileSync: writeFs } = await import("fs");
|
|
203503
|
+
const NOOP_RE = /window\.\$RefreshReg\$\|\|\(window\.\$RefreshReg\$=function\(\)\{\}\);window\.\$RefreshSig\$\|\|\(window\.\$RefreshSig\$=function\(\)\{return function\(t\)\{return t\}\}\);?\n?/g;
|
|
203504
|
+
for (const output of clientResult.outputs) {
|
|
203505
|
+
if (output.kind !== "entry-point")
|
|
203506
|
+
continue;
|
|
203507
|
+
try {
|
|
203508
|
+
const content = readFs(output.path, "utf-8");
|
|
203509
|
+
if (NOOP_RE.test(content)) {
|
|
203510
|
+
NOOP_RE.lastIndex = 0;
|
|
203511
|
+
writeFs(output.path, content.replace(NOOP_RE, ""));
|
|
203512
|
+
}
|
|
203513
|
+
} catch {}
|
|
203514
|
+
}
|
|
203491
203515
|
const clientManifest = generateManifest2(clientResult.outputs, buildDir);
|
|
203492
203516
|
Object.assign(state.manifest, clientManifest);
|
|
203493
203517
|
await populateAssetStore(state.assetStore, clientManifest, buildDir);
|
|
203494
203518
|
}, getModuleUrl = async (pageFile) => {
|
|
203495
203519
|
const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
|
|
203496
203520
|
invalidateModule2(pageFile);
|
|
203497
|
-
const rel =
|
|
203521
|
+
const rel = relative8(process.cwd(), pageFile).replace(/\\/g, "/");
|
|
203498
203522
|
const url = `${SRC_URL_PREFIX2}${rel}`;
|
|
203499
203523
|
warmCache2(url);
|
|
203500
203524
|
return url;
|
|
@@ -203520,10 +203544,18 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203520
203544
|
for (const file3 of reactFiles) {
|
|
203521
203545
|
invalidateModule2(file3);
|
|
203522
203546
|
}
|
|
203523
|
-
const
|
|
203547
|
+
const isComponentFile = primaryFile.endsWith(".tsx") || primaryFile.endsWith(".jsx");
|
|
203548
|
+
let broadcastTarget = primaryFile;
|
|
203549
|
+
if (!isComponentFile) {
|
|
203550
|
+
const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
|
|
203551
|
+
const nearest = findNearestComponent2(resolve20(primaryFile));
|
|
203552
|
+
if (nearest)
|
|
203553
|
+
broadcastTarget = nearest;
|
|
203554
|
+
}
|
|
203555
|
+
const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
|
|
203524
203556
|
if (pageModuleUrl) {
|
|
203525
203557
|
const serverDuration = Date.now() - startTime;
|
|
203526
|
-
state.lastHmrPath =
|
|
203558
|
+
state.lastHmrPath = relative8(process.cwd(), primaryFile).replace(/\\/g, "/");
|
|
203527
203559
|
state.lastHmrFramework = "react";
|
|
203528
203560
|
broadcastToClients(state, {
|
|
203529
203561
|
data: {
|
|
@@ -203909,7 +203941,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203909
203941
|
const baseName = fileName.replace(/\.vue$/, "");
|
|
203910
203942
|
const pascalName = toPascal(baseName);
|
|
203911
203943
|
const vueRoot = config.vueDirectory;
|
|
203912
|
-
const hmrId = vueRoot ?
|
|
203944
|
+
const hmrId = vueRoot ? relative8(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
|
|
203913
203945
|
const cssKey = `${pascalName}CSS`;
|
|
203914
203946
|
const cssUrl = manifest[cssKey] || null;
|
|
203915
203947
|
const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
|
|
@@ -204903,5 +204935,5 @@ export {
|
|
|
204903
204935
|
build
|
|
204904
204936
|
};
|
|
204905
204937
|
|
|
204906
|
-
//# debugId=
|
|
204938
|
+
//# debugId=681F07D8C4E18D9B64756E2164756E21
|
|
204907
204939
|
//# sourceMappingURL=build.js.map
|