@absolutejs/absolute 0.19.0-beta.98 → 0.19.0-beta.99
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 +54 -103
- package/dist/build.js.map +6 -6
- package/dist/dev/client/handlers/react.ts +1 -22
- package/dist/index.js +66 -104
- package/dist/index.js.map +7 -7
- package/dist/src/dev/transformCache.d.ts +0 -2
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -199,9 +199,6 @@ var indexContentCache, resolveDevClientDir = () => {
|
|
|
199
199
|
` reset() {`,
|
|
200
200
|
` this.setState({ hasError: false });`,
|
|
201
201
|
` }`,
|
|
202
|
-
` hmrUpdate() {`,
|
|
203
|
-
` this.forceUpdate();`,
|
|
204
|
-
` }`,
|
|
205
202
|
` render() {`,
|
|
206
203
|
` if (this.state.hasError) return null;`,
|
|
207
204
|
``,
|
|
@@ -202325,6 +202322,15 @@ var init_pageHandler = __esm(() => {
|
|
|
202325
202322
|
});
|
|
202326
202323
|
|
|
202327
202324
|
// src/dev/transformCache.ts
|
|
202325
|
+
var exports_transformCache = {};
|
|
202326
|
+
__export(exports_transformCache, {
|
|
202327
|
+
setTransformed: () => setTransformed,
|
|
202328
|
+
invalidateAll: () => invalidateAll,
|
|
202329
|
+
invalidate: () => invalidate,
|
|
202330
|
+
getTransformed: () => getTransformed,
|
|
202331
|
+
getInvalidationVersion: () => getInvalidationVersion,
|
|
202332
|
+
findNearestComponent: () => findNearestComponent
|
|
202333
|
+
});
|
|
202328
202334
|
var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
|
|
202329
202335
|
const resolvedImports = imports ?? [];
|
|
202330
202336
|
cache.set(filePath, { content, imports: resolvedImports, mtime });
|
|
@@ -202343,9 +202349,29 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
|
|
|
202343
202349
|
cache.delete(parent);
|
|
202344
202350
|
}
|
|
202345
202351
|
}
|
|
202346
|
-
},
|
|
202347
|
-
|
|
202348
|
-
|
|
202352
|
+
}, invalidateAll = () => {
|
|
202353
|
+
cache.clear();
|
|
202354
|
+
importers.clear();
|
|
202355
|
+
}, findNearestComponent = (filePath) => {
|
|
202356
|
+
const visited = new Set;
|
|
202357
|
+
const queue = [filePath];
|
|
202358
|
+
while (queue.length > 0) {
|
|
202359
|
+
const current = queue.shift();
|
|
202360
|
+
if (visited.has(current))
|
|
202361
|
+
continue;
|
|
202362
|
+
visited.add(current);
|
|
202363
|
+
const parents = importers.get(current);
|
|
202364
|
+
if (!parents)
|
|
202365
|
+
continue;
|
|
202366
|
+
for (const parent of parents) {
|
|
202367
|
+
if (parent.endsWith(".tsx") || parent.endsWith(".jsx")) {
|
|
202368
|
+
return parent;
|
|
202369
|
+
}
|
|
202370
|
+
queue.push(parent);
|
|
202371
|
+
}
|
|
202372
|
+
}
|
|
202373
|
+
return;
|
|
202374
|
+
};
|
|
202349
202375
|
var init_transformCache = __esm(() => {
|
|
202350
202376
|
globalStore = globalThis;
|
|
202351
202377
|
cache = globalStore.__transformCache ?? new Map;
|
|
@@ -202354,8 +202380,6 @@ var init_transformCache = __esm(() => {
|
|
|
202354
202380
|
globalStore.__transformImporters = importers;
|
|
202355
202381
|
invalidationVersions = globalStore.__transformInvalidationVersions ?? new Map;
|
|
202356
202382
|
globalStore.__transformInvalidationVersions = invalidationVersions;
|
|
202357
|
-
dataFiles = globalStore.__transformDataFiles ?? new Set;
|
|
202358
|
-
globalStore.__transformDataFiles = dataFiles;
|
|
202359
202383
|
});
|
|
202360
202384
|
|
|
202361
202385
|
// src/dev/moduleServer.ts
|
|
@@ -202499,55 +202523,6 @@ ${stubs}
|
|
|
202499
202523
|
return _match;
|
|
202500
202524
|
});
|
|
202501
202525
|
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;
|
|
202551
202526
|
}, HOOK_NAMES, REFRESH_PREAMBLE, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
|
|
202552
202527
|
const imports = [];
|
|
202553
202528
|
const jsxDevMatch = JSX_AUTO_RE.exec(code);
|
|
@@ -202585,36 +202560,7 @@ ${stubs}
|
|
|
202585
202560
|
` + transpiled;
|
|
202586
202561
|
const relPath = relative7(projectRoot, filePath).replace(/\\/g, "/");
|
|
202587
202562
|
transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
|
|
202588
|
-
|
|
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
|
-
`;
|
|
202563
|
+
return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
|
|
202618
202564
|
}, transformPlainFile = (filePath, projectRoot, rewriter) => {
|
|
202619
202565
|
const raw = readFileSync9(filePath, "utf-8");
|
|
202620
202566
|
const ext = extname3(filePath);
|
|
@@ -202626,13 +202572,7 @@ ${stubs}
|
|
|
202626
202572
|
if (isTS) {
|
|
202627
202573
|
transpiled = preserveTypeExports(raw, transpiled, valueExports);
|
|
202628
202574
|
}
|
|
202629
|
-
|
|
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;
|
|
202575
|
+
return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
|
|
202636
202576
|
}, svelteExternalCss, svelteCompiler = null, vueCompiler = null, warmCompilers = async (frameworks) => {
|
|
202637
202577
|
const [sc, vc] = await Promise.all([
|
|
202638
202578
|
frameworks.svelte ? import("svelte/compiler") : undefined,
|
|
@@ -202774,12 +202714,16 @@ ${code}`;
|
|
|
202774
202714
|
if (existsSync13(`${path}.js`))
|
|
202775
202715
|
return `${path}.js`;
|
|
202776
202716
|
return path;
|
|
202777
|
-
}, jsResponse = (body) =>
|
|
202778
|
-
|
|
202779
|
-
|
|
202780
|
-
|
|
202781
|
-
|
|
202782
|
-
|
|
202717
|
+
}, jsResponse = (body) => {
|
|
202718
|
+
const etag = `"${Bun.hash(body).toString(36)}"`;
|
|
202719
|
+
return new Response(body, {
|
|
202720
|
+
headers: {
|
|
202721
|
+
"Cache-Control": "no-cache",
|
|
202722
|
+
"Content-Type": "application/javascript",
|
|
202723
|
+
ETag: etag
|
|
202724
|
+
}
|
|
202725
|
+
});
|
|
202726
|
+
}, handleCssRequest = (filePath) => {
|
|
202783
202727
|
const raw = readFileSync9(filePath, "utf-8");
|
|
202784
202728
|
const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
|
|
202785
202729
|
return [
|
|
@@ -203010,7 +202954,6 @@ var init_moduleServer = __esm(() => {
|
|
|
203010
202954
|
STRING_CONTENTS_RE = /`(?:[^`\\]|\\.)*`|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/gs;
|
|
203011
202955
|
REACT_EXTENSIONS = new Set([".tsx", ".jsx"]);
|
|
203012
202956
|
mtimeCache = new Map;
|
|
203013
|
-
NAMED_IMPORT_RE = /import\s*\{([^}]+)\}\s*from\s*(["'])(\/\@src\/[^"']+)(["']);?/g;
|
|
203014
202957
|
HOOK_NAMES = new Set([
|
|
203015
202958
|
"useState",
|
|
203016
202959
|
"useReducer",
|
|
@@ -203573,7 +203516,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203573
203516
|
for (const file3 of reactFiles) {
|
|
203574
203517
|
invalidateModule2(file3);
|
|
203575
203518
|
}
|
|
203576
|
-
const
|
|
203519
|
+
const isComponentFile = primaryFile.endsWith(".tsx") || primaryFile.endsWith(".jsx");
|
|
203520
|
+
let broadcastTarget = primaryFile;
|
|
203521
|
+
if (!isComponentFile) {
|
|
203522
|
+
const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
|
|
203523
|
+
const nearest = findNearestComponent2(resolve20(primaryFile));
|
|
203524
|
+
if (nearest)
|
|
203525
|
+
broadcastTarget = nearest;
|
|
203526
|
+
}
|
|
203527
|
+
const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
|
|
203577
203528
|
if (pageModuleUrl) {
|
|
203578
203529
|
const serverDuration = Date.now() - startTime;
|
|
203579
203530
|
state.lastHmrPath = relative8(process.cwd(), primaryFile).replace(/\\/g, "/");
|
|
@@ -204956,5 +204907,5 @@ export {
|
|
|
204956
204907
|
build
|
|
204957
204908
|
};
|
|
204958
204909
|
|
|
204959
|
-
//# debugId=
|
|
204910
|
+
//# debugId=C820298FC4C29C7664756E2164756E21
|
|
204960
204911
|
//# sourceMappingURL=build.js.map
|