@absolutejs/absolute 0.19.0-beta.65 → 0.19.0-beta.67
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/.claude/settings.local.json +5 -1
- package/dist/build.js +88 -12
- package/dist/build.js.map +5 -5
- package/dist/dev/client/handlers/react.ts +16 -41
- package/dist/index.js +88 -12
- package/dist/index.js.map +5 -5
- package/dist/src/dev/transformCache.d.ts +3 -1
- package/package.json +1 -1
|
@@ -8,7 +8,6 @@ import { detectCurrentFramework } from '../frameworkDetect';
|
|
|
8
8
|
|
|
9
9
|
export const handleReactUpdate = (message: {
|
|
10
10
|
data: {
|
|
11
|
-
dataModuleUrl?: string;
|
|
12
11
|
hasCSSChanges?: boolean;
|
|
13
12
|
hasComponentChanges?: boolean;
|
|
14
13
|
manifest?: Record<string, string>;
|
|
@@ -33,25 +32,8 @@ export const handleReactUpdate = (message: {
|
|
|
33
32
|
|
|
34
33
|
const refreshRuntime = window.$RefreshRuntime$;
|
|
35
34
|
const serverDuration = message.data.serverDuration;
|
|
36
|
-
const dataModuleUrl = message.data.dataModuleUrl;
|
|
37
35
|
const pageModuleUrl = message.data.pageModuleUrl;
|
|
38
36
|
|
|
39
|
-
// Non-component file: import the data file first (cache bust),
|
|
40
|
-
// then re-import the page so the component re-renders with new data.
|
|
41
|
-
if (dataModuleUrl && refreshRuntime) {
|
|
42
|
-
const pageUrl = window.__REACT_PAGE_MODULE__;
|
|
43
|
-
if (pageUrl) {
|
|
44
|
-
applyDataThenPage(
|
|
45
|
-
dataModuleUrl,
|
|
46
|
-
pageUrl,
|
|
47
|
-
refreshRuntime,
|
|
48
|
-
serverDuration
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
37
|
if (pageModuleUrl && refreshRuntime) {
|
|
56
38
|
applyRefreshImport(pageModuleUrl, refreshRuntime, serverDuration);
|
|
57
39
|
|
|
@@ -93,33 +75,26 @@ const applyRefreshImport = (
|
|
|
93
75
|
const clientStart = performance.now();
|
|
94
76
|
import(`${moduleUrl}?t=${Date.now()}`)
|
|
95
77
|
.then(() => {
|
|
96
|
-
refreshRuntime.performReactRefresh();
|
|
97
|
-
|
|
78
|
+
const result = refreshRuntime.performReactRefresh();
|
|
79
|
+
|
|
80
|
+
// If Fast Refresh was a no-op (data/utility file with no
|
|
81
|
+
// component exports), re-import the page entry so the
|
|
82
|
+
// component tree re-renders with the updated data.
|
|
83
|
+
// Chain invalidation ensures all intermediate modules have
|
|
84
|
+
// fresh ?v= params, so the browser re-fetches the whole chain.
|
|
85
|
+
if (!result && window.__REACT_PAGE_MODULE__) {
|
|
86
|
+
return import(
|
|
87
|
+
`${window.__REACT_PAGE_MODULE__}?t=${Date.now()}`
|
|
88
|
+
).then(() => {
|
|
89
|
+
refreshRuntime.performReactRefresh();
|
|
90
|
+
|
|
91
|
+
return undefined;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
98
94
|
|
|
99
95
|
return undefined;
|
|
100
96
|
})
|
|
101
|
-
.catch((err) => {
|
|
102
|
-
console.warn(
|
|
103
|
-
'[HMR] React Fast Refresh failed, falling back to reload:',
|
|
104
|
-
err
|
|
105
|
-
);
|
|
106
|
-
window.location.reload();
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const applyDataThenPage = (
|
|
111
|
-
dataUrl: string,
|
|
112
|
-
pageUrl: string,
|
|
113
|
-
refreshRuntime: { performReactRefresh: () => unknown },
|
|
114
|
-
serverDuration?: number
|
|
115
|
-
) => {
|
|
116
|
-
const clientStart = performance.now();
|
|
117
|
-
// Import the changed data file first to bust the browser cache,
|
|
118
|
-
// then re-import the page so the component re-renders with new data.
|
|
119
|
-
import(`${dataUrl}?t=${Date.now()}`)
|
|
120
|
-
.then(() => import(`${pageUrl}?t=${Date.now()}`))
|
|
121
97
|
.then(() => {
|
|
122
|
-
refreshRuntime.performReactRefresh();
|
|
123
98
|
sendTiming(clientStart, serverDuration);
|
|
124
99
|
|
|
125
100
|
return undefined;
|
package/dist/index.js
CHANGED
|
@@ -202323,15 +202323,74 @@ var init_pageHandler = __esm(() => {
|
|
|
202323
202323
|
});
|
|
202324
202324
|
|
|
202325
202325
|
// src/dev/transformCache.ts
|
|
202326
|
-
var
|
|
202327
|
-
|
|
202328
|
-
|
|
202329
|
-
|
|
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
|
+
var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
|
|
202336
|
+
const resolvedImports = imports ?? [];
|
|
202337
|
+
cache.set(filePath, { content, imports: resolvedImports, mtime });
|
|
202338
|
+
for (const imp of resolvedImports) {
|
|
202339
|
+
if (!importers.has(imp)) {
|
|
202340
|
+
importers.set(imp, new Set);
|
|
202341
|
+
}
|
|
202342
|
+
importers.get(imp).add(filePath);
|
|
202343
|
+
}
|
|
202344
|
+
}, invalidationVersions, getInvalidationVersion = (filePath) => invalidationVersions.get(filePath) ?? 0, invalidate = (filePath) => {
|
|
202345
|
+
const queue = [filePath];
|
|
202346
|
+
const visited = new Set;
|
|
202347
|
+
while (queue.length > 0) {
|
|
202348
|
+
const current = queue.pop();
|
|
202349
|
+
if (visited.has(current))
|
|
202350
|
+
continue;
|
|
202351
|
+
visited.add(current);
|
|
202352
|
+
cache.delete(current);
|
|
202353
|
+
if (current !== filePath) {
|
|
202354
|
+
invalidationVersions.set(current, (invalidationVersions.get(current) ?? 0) + 1);
|
|
202355
|
+
}
|
|
202356
|
+
const parents = importers.get(current);
|
|
202357
|
+
if (parents) {
|
|
202358
|
+
for (const parent of parents) {
|
|
202359
|
+
queue.push(parent);
|
|
202360
|
+
}
|
|
202361
|
+
}
|
|
202362
|
+
}
|
|
202363
|
+
}, invalidateAll = () => {
|
|
202364
|
+
cache.clear();
|
|
202365
|
+
importers.clear();
|
|
202366
|
+
}, findNearestComponent = (filePath) => {
|
|
202367
|
+
const visited = new Set;
|
|
202368
|
+
const queue = [filePath];
|
|
202369
|
+
while (queue.length > 0) {
|
|
202370
|
+
const current = queue.shift();
|
|
202371
|
+
if (visited.has(current))
|
|
202372
|
+
continue;
|
|
202373
|
+
visited.add(current);
|
|
202374
|
+
const parents = importers.get(current);
|
|
202375
|
+
if (!parents)
|
|
202376
|
+
continue;
|
|
202377
|
+
for (const parent of parents) {
|
|
202378
|
+
if (parent.endsWith(".tsx") || parent.endsWith(".jsx")) {
|
|
202379
|
+
return parent;
|
|
202380
|
+
}
|
|
202381
|
+
queue.push(parent);
|
|
202382
|
+
}
|
|
202383
|
+
}
|
|
202384
|
+
return;
|
|
202330
202385
|
};
|
|
202331
202386
|
var init_transformCache = __esm(() => {
|
|
202332
202387
|
globalStore = globalThis;
|
|
202333
202388
|
cache = globalStore.__transformCache ?? new Map;
|
|
202334
202389
|
globalStore.__transformCache = cache;
|
|
202390
|
+
importers = globalStore.__transformImporters ?? new Map;
|
|
202391
|
+
globalStore.__transformImporters = importers;
|
|
202392
|
+
invalidationVersions = globalStore.__transformInvalidationVersions ?? new Map;
|
|
202393
|
+
globalStore.__transformInvalidationVersions = invalidationVersions;
|
|
202335
202394
|
});
|
|
202336
202395
|
|
|
202337
202396
|
// src/dev/moduleServer.ts
|
|
@@ -202384,7 +202443,9 @@ ${stubs}
|
|
|
202384
202443
|
return base;
|
|
202385
202444
|
}
|
|
202386
202445
|
}
|
|
202387
|
-
|
|
202446
|
+
const iv = getInvalidationVersion(absPath);
|
|
202447
|
+
const version = iv > 0 ? `${mtime}.${iv}` : `${mtime}`;
|
|
202448
|
+
return `${base}?v=${version}`;
|
|
202388
202449
|
}, rewriteImports2 = (code, filePath, projectRoot, rewriter) => {
|
|
202389
202450
|
let result = code;
|
|
202390
202451
|
if (rewriter) {
|
|
@@ -202827,7 +202888,7 @@ export default {};
|
|
|
202827
202888
|
return jsResponse(cached2);
|
|
202828
202889
|
const stat3 = statSync(filePath);
|
|
202829
202890
|
const content2 = await transformSvelteFile(filePath, projectRoot, rewriter);
|
|
202830
|
-
setTransformed(filePath, content2, stat3.mtimeMs);
|
|
202891
|
+
setTransformed(filePath, content2, stat3.mtimeMs, extractImportedFiles(content2, projectRoot));
|
|
202831
202892
|
return jsResponse(content2);
|
|
202832
202893
|
}
|
|
202833
202894
|
if (ext === ".vue") {
|
|
@@ -202836,7 +202897,7 @@ export default {};
|
|
|
202836
202897
|
return jsResponse(cached2);
|
|
202837
202898
|
const stat3 = statSync(filePath);
|
|
202838
202899
|
const content2 = await transformVueFile(filePath, projectRoot, rewriter, frameworkDirs?.vue);
|
|
202839
|
-
setTransformed(filePath, content2, stat3.mtimeMs);
|
|
202900
|
+
setTransformed(filePath, content2, stat3.mtimeMs, extractImportedFiles(content2, projectRoot));
|
|
202840
202901
|
return jsResponse(content2);
|
|
202841
202902
|
}
|
|
202842
202903
|
if (!TRANSPILABLE.has(ext))
|
|
@@ -202846,7 +202907,7 @@ export default {};
|
|
|
202846
202907
|
return jsResponse(cached);
|
|
202847
202908
|
const stat2 = statSync(filePath);
|
|
202848
202909
|
const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter);
|
|
202849
|
-
setTransformed(filePath, content, stat2.mtimeMs);
|
|
202910
|
+
setTransformed(filePath, content, stat2.mtimeMs, extractImportedFiles(content, projectRoot));
|
|
202850
202911
|
return jsResponse(content);
|
|
202851
202912
|
} catch (err) {
|
|
202852
202913
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
@@ -202856,6 +202917,15 @@ export default {};
|
|
|
202856
202917
|
});
|
|
202857
202918
|
}
|
|
202858
202919
|
};
|
|
202920
|
+
}, SRC_IMPORT_RE, extractImportedFiles = (content, projectRoot) => {
|
|
202921
|
+
const files = [];
|
|
202922
|
+
let match;
|
|
202923
|
+
SRC_IMPORT_RE.lastIndex = 0;
|
|
202924
|
+
while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
|
|
202925
|
+
if (match[1])
|
|
202926
|
+
files.push(resolve18(projectRoot, match[1]));
|
|
202927
|
+
}
|
|
202928
|
+
return files;
|
|
202859
202929
|
}, invalidateModule = (filePath) => {
|
|
202860
202930
|
invalidate(filePath);
|
|
202861
202931
|
mtimeCache.delete(filePath);
|
|
@@ -202923,6 +202993,7 @@ var init_moduleServer = __esm(() => {
|
|
|
202923
202993
|
trimUnusedImports: true
|
|
202924
202994
|
});
|
|
202925
202995
|
svelteExternalCss = new Map;
|
|
202996
|
+
SRC_IMPORT_RE = /\/@src\/([^"'?\s]+)/g;
|
|
202926
202997
|
SRC_URL_PREFIX = SRC_PREFIX;
|
|
202927
202998
|
});
|
|
202928
202999
|
|
|
@@ -203450,15 +203521,20 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203450
203521
|
invalidateModule2(file4);
|
|
203451
203522
|
}
|
|
203452
203523
|
const isComponentFile = primaryFile.endsWith(".tsx") || primaryFile.endsWith(".jsx");
|
|
203453
|
-
|
|
203454
|
-
|
|
203524
|
+
let broadcastTarget = primaryFile;
|
|
203525
|
+
if (!isComponentFile) {
|
|
203526
|
+
const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
|
|
203527
|
+
const nearest = findNearestComponent2(resolve21(primaryFile));
|
|
203528
|
+
if (nearest)
|
|
203529
|
+
broadcastTarget = nearest;
|
|
203530
|
+
}
|
|
203531
|
+
const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
|
|
203455
203532
|
if (pageModuleUrl) {
|
|
203456
203533
|
const serverDuration = Date.now() - startTime;
|
|
203457
203534
|
state.lastHmrPath = relative9(process.cwd(), primaryFile).replace(/\\/g, "/");
|
|
203458
203535
|
state.lastHmrFramework = "react";
|
|
203459
203536
|
broadcastToClients(state, {
|
|
203460
203537
|
data: {
|
|
203461
|
-
dataModuleUrl,
|
|
203462
203538
|
framework: "react",
|
|
203463
203539
|
hasComponentChanges: true,
|
|
203464
203540
|
hasCSSChanges: false,
|
|
@@ -205222,5 +205298,5 @@ export {
|
|
|
205222
205298
|
ANGULAR_INIT_TIMEOUT_MS
|
|
205223
205299
|
};
|
|
205224
205300
|
|
|
205225
|
-
//# debugId=
|
|
205301
|
+
//# debugId=38B222B3DCDB342564756E2164756E21
|
|
205226
205302
|
//# sourceMappingURL=index.js.map
|