@absolutejs/absolute 0.19.0-beta.64 → 0.19.0-beta.66
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 +50 -41
- package/dist/build.js.map +5 -5
- package/dist/dev/client/handlers/react.ts +16 -38
- package/dist/index.js +50 -41
- package/dist/index.js.map +5 -5
- package/dist/src/dev/transformCache.d.ts +2 -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,22 +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.
|
|
41
|
-
if (dataModuleUrl && pageModuleUrl && refreshRuntime) {
|
|
42
|
-
applyDataThenPage(
|
|
43
|
-
dataModuleUrl,
|
|
44
|
-
pageModuleUrl,
|
|
45
|
-
refreshRuntime,
|
|
46
|
-
serverDuration
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
37
|
if (pageModuleUrl && refreshRuntime) {
|
|
53
38
|
applyRefreshImport(pageModuleUrl, refreshRuntime, serverDuration);
|
|
54
39
|
|
|
@@ -90,33 +75,26 @@ const applyRefreshImport = (
|
|
|
90
75
|
const clientStart = performance.now();
|
|
91
76
|
import(`${moduleUrl}?t=${Date.now()}`)
|
|
92
77
|
.then(() => {
|
|
93
|
-
refreshRuntime.performReactRefresh();
|
|
94
|
-
|
|
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
|
+
}
|
|
95
94
|
|
|
96
95
|
return undefined;
|
|
97
96
|
})
|
|
98
|
-
.catch((err) => {
|
|
99
|
-
console.warn(
|
|
100
|
-
'[HMR] React Fast Refresh failed, falling back to reload:',
|
|
101
|
-
err
|
|
102
|
-
);
|
|
103
|
-
window.location.reload();
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const applyDataThenPage = (
|
|
108
|
-
dataUrl: string,
|
|
109
|
-
pageUrl: string,
|
|
110
|
-
refreshRuntime: { performReactRefresh: () => unknown },
|
|
111
|
-
serverDuration?: number
|
|
112
|
-
) => {
|
|
113
|
-
const clientStart = performance.now();
|
|
114
|
-
// Import the changed data file first to bust the browser cache,
|
|
115
|
-
// then re-import the page so the component re-renders with new data.
|
|
116
|
-
import(`${dataUrl}?t=${Date.now()}`)
|
|
117
|
-
.then(() => import(`${pageUrl}?t=${Date.now()}`))
|
|
118
97
|
.then(() => {
|
|
119
|
-
refreshRuntime.performReactRefresh();
|
|
120
98
|
sendTiming(clientStart, serverDuration);
|
|
121
99
|
|
|
122
100
|
return undefined;
|
package/dist/index.js
CHANGED
|
@@ -202323,15 +202323,43 @@ var init_pageHandler = __esm(() => {
|
|
|
202323
202323
|
});
|
|
202324
202324
|
|
|
202325
202325
|
// src/dev/transformCache.ts
|
|
202326
|
-
var globalStore, cache, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime) => {
|
|
202327
|
-
|
|
202328
|
-
|
|
202329
|
-
|
|
202326
|
+
var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
|
|
202327
|
+
const resolvedImports = imports ?? [];
|
|
202328
|
+
cache.set(filePath, { content, imports: resolvedImports, mtime });
|
|
202329
|
+
for (const imp of resolvedImports) {
|
|
202330
|
+
if (!importers.has(imp)) {
|
|
202331
|
+
importers.set(imp, new Set);
|
|
202332
|
+
}
|
|
202333
|
+
importers.get(imp).add(filePath);
|
|
202334
|
+
}
|
|
202335
|
+
}, invalidationVersions, getInvalidationVersion = (filePath) => invalidationVersions.get(filePath) ?? 0, invalidate = (filePath) => {
|
|
202336
|
+
const queue = [filePath];
|
|
202337
|
+
const visited = new Set;
|
|
202338
|
+
while (queue.length > 0) {
|
|
202339
|
+
const current = queue.pop();
|
|
202340
|
+
if (visited.has(current))
|
|
202341
|
+
continue;
|
|
202342
|
+
visited.add(current);
|
|
202343
|
+
cache.delete(current);
|
|
202344
|
+
if (current !== filePath) {
|
|
202345
|
+
invalidationVersions.set(current, (invalidationVersions.get(current) ?? 0) + 1);
|
|
202346
|
+
}
|
|
202347
|
+
const parents = importers.get(current);
|
|
202348
|
+
if (parents) {
|
|
202349
|
+
for (const parent of parents) {
|
|
202350
|
+
queue.push(parent);
|
|
202351
|
+
}
|
|
202352
|
+
}
|
|
202353
|
+
}
|
|
202330
202354
|
};
|
|
202331
202355
|
var init_transformCache = __esm(() => {
|
|
202332
202356
|
globalStore = globalThis;
|
|
202333
202357
|
cache = globalStore.__transformCache ?? new Map;
|
|
202334
202358
|
globalStore.__transformCache = cache;
|
|
202359
|
+
importers = globalStore.__transformImporters ?? new Map;
|
|
202360
|
+
globalStore.__transformImporters = importers;
|
|
202361
|
+
invalidationVersions = globalStore.__transformInvalidationVersions ?? new Map;
|
|
202362
|
+
globalStore.__transformInvalidationVersions = invalidationVersions;
|
|
202335
202363
|
});
|
|
202336
202364
|
|
|
202337
202365
|
// src/dev/moduleServer.ts
|
|
@@ -202384,7 +202412,9 @@ ${stubs}
|
|
|
202384
202412
|
return base;
|
|
202385
202413
|
}
|
|
202386
202414
|
}
|
|
202387
|
-
|
|
202415
|
+
const iv = getInvalidationVersion(absPath);
|
|
202416
|
+
const version = iv > 0 ? `${mtime}.${iv}` : `${mtime}`;
|
|
202417
|
+
return `${base}?v=${version}`;
|
|
202388
202418
|
}, rewriteImports2 = (code, filePath, projectRoot, rewriter) => {
|
|
202389
202419
|
let result = code;
|
|
202390
202420
|
if (rewriter) {
|
|
@@ -202827,7 +202857,7 @@ export default {};
|
|
|
202827
202857
|
return jsResponse(cached2);
|
|
202828
202858
|
const stat3 = statSync(filePath);
|
|
202829
202859
|
const content2 = await transformSvelteFile(filePath, projectRoot, rewriter);
|
|
202830
|
-
setTransformed(filePath, content2, stat3.mtimeMs);
|
|
202860
|
+
setTransformed(filePath, content2, stat3.mtimeMs, extractImportedFiles(content2, projectRoot));
|
|
202831
202861
|
return jsResponse(content2);
|
|
202832
202862
|
}
|
|
202833
202863
|
if (ext === ".vue") {
|
|
@@ -202836,7 +202866,7 @@ export default {};
|
|
|
202836
202866
|
return jsResponse(cached2);
|
|
202837
202867
|
const stat3 = statSync(filePath);
|
|
202838
202868
|
const content2 = await transformVueFile(filePath, projectRoot, rewriter, frameworkDirs?.vue);
|
|
202839
|
-
setTransformed(filePath, content2, stat3.mtimeMs);
|
|
202869
|
+
setTransformed(filePath, content2, stat3.mtimeMs, extractImportedFiles(content2, projectRoot));
|
|
202840
202870
|
return jsResponse(content2);
|
|
202841
202871
|
}
|
|
202842
202872
|
if (!TRANSPILABLE.has(ext))
|
|
@@ -202846,7 +202876,7 @@ export default {};
|
|
|
202846
202876
|
return jsResponse(cached);
|
|
202847
202877
|
const stat2 = statSync(filePath);
|
|
202848
202878
|
const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter);
|
|
202849
|
-
setTransformed(filePath, content, stat2.mtimeMs);
|
|
202879
|
+
setTransformed(filePath, content, stat2.mtimeMs, extractImportedFiles(content, projectRoot));
|
|
202850
202880
|
return jsResponse(content);
|
|
202851
202881
|
} catch (err) {
|
|
202852
202882
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
@@ -202856,6 +202886,15 @@ export default {};
|
|
|
202856
202886
|
});
|
|
202857
202887
|
}
|
|
202858
202888
|
};
|
|
202889
|
+
}, SRC_IMPORT_RE, extractImportedFiles = (content, projectRoot) => {
|
|
202890
|
+
const files = [];
|
|
202891
|
+
let match;
|
|
202892
|
+
SRC_IMPORT_RE.lastIndex = 0;
|
|
202893
|
+
while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
|
|
202894
|
+
if (match[1])
|
|
202895
|
+
files.push(resolve18(projectRoot, match[1]));
|
|
202896
|
+
}
|
|
202897
|
+
return files;
|
|
202859
202898
|
}, invalidateModule = (filePath) => {
|
|
202860
202899
|
invalidate(filePath);
|
|
202861
202900
|
mtimeCache.delete(filePath);
|
|
@@ -202923,6 +202962,7 @@ var init_moduleServer = __esm(() => {
|
|
|
202923
202962
|
trimUnusedImports: true
|
|
202924
202963
|
});
|
|
202925
202964
|
svelteExternalCss = new Map;
|
|
202965
|
+
SRC_IMPORT_RE = /\/@src\/([^"'?\s]+)/g;
|
|
202926
202966
|
SRC_URL_PREFIX = SRC_PREFIX;
|
|
202927
202967
|
});
|
|
202928
202968
|
|
|
@@ -203449,44 +203489,13 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
203449
203489
|
for (const file4 of reactFiles) {
|
|
203450
203490
|
invalidateModule2(file4);
|
|
203451
203491
|
}
|
|
203452
|
-
const
|
|
203453
|
-
let broadcastFile = primaryFile;
|
|
203454
|
-
if (!isComponentFile) {
|
|
203455
|
-
const pageFile = reactFiles.find((f) => f.replace(/\\/g, "/").includes("/pages/") && (f.endsWith(".tsx") || f.endsWith(".jsx")));
|
|
203456
|
-
if (pageFile) {
|
|
203457
|
-
broadcastFile = pageFile;
|
|
203458
|
-
} else {
|
|
203459
|
-
const visited = new Set;
|
|
203460
|
-
const queue = [resolve21(primaryFile)];
|
|
203461
|
-
while (queue.length > 0) {
|
|
203462
|
-
const current = queue.shift();
|
|
203463
|
-
if (visited.has(current))
|
|
203464
|
-
continue;
|
|
203465
|
-
visited.add(current);
|
|
203466
|
-
if (current.replace(/\\/g, "/").includes("/pages/") && (current.endsWith(".tsx") || current.endsWith(".jsx"))) {
|
|
203467
|
-
broadcastFile = current;
|
|
203468
|
-
break;
|
|
203469
|
-
}
|
|
203470
|
-
const deps = state.dependencyGraph.dependents.get(current);
|
|
203471
|
-
if (deps) {
|
|
203472
|
-
for (const dep of deps)
|
|
203473
|
-
queue.push(dep);
|
|
203474
|
-
}
|
|
203475
|
-
}
|
|
203476
|
-
}
|
|
203477
|
-
}
|
|
203478
|
-
const pageModuleUrl = await getReactModuleUrl(broadcastFile);
|
|
203479
|
-
let dataModuleUrl;
|
|
203480
|
-
if (!isComponentFile && broadcastFile !== primaryFile) {
|
|
203481
|
-
dataModuleUrl = await getReactModuleUrl(primaryFile);
|
|
203482
|
-
}
|
|
203492
|
+
const pageModuleUrl = await getReactModuleUrl(primaryFile);
|
|
203483
203493
|
if (pageModuleUrl) {
|
|
203484
203494
|
const serverDuration = Date.now() - startTime;
|
|
203485
203495
|
state.lastHmrPath = relative9(process.cwd(), primaryFile).replace(/\\/g, "/");
|
|
203486
203496
|
state.lastHmrFramework = "react";
|
|
203487
203497
|
broadcastToClients(state, {
|
|
203488
203498
|
data: {
|
|
203489
|
-
dataModuleUrl,
|
|
203490
203499
|
framework: "react",
|
|
203491
203500
|
hasComponentChanges: true,
|
|
203492
203501
|
hasCSSChanges: false,
|
|
@@ -205250,5 +205259,5 @@ export {
|
|
|
205250
205259
|
ANGULAR_INIT_TIMEOUT_MS
|
|
205251
205260
|
};
|
|
205252
205261
|
|
|
205253
|
-
//# debugId=
|
|
205262
|
+
//# debugId=364C554C5D92BFFF64756E2164756E21
|
|
205254
205263
|
//# sourceMappingURL=index.js.map
|