@absolutejs/absolute 0.18.3 → 0.18.4
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/eslint-cache +1 -1
- package/.absolutejs/prettier.cache.json +16 -15
- package/.absolutejs/tsconfig.tsbuildinfo +1 -1
- package/dist/build.js +43 -40
- package/dist/build.js.map +3 -3
- package/dist/index.js +88 -43
- package/dist/index.js.map +7 -6
- package/dist/react/index.js +2 -3
- package/dist/react/index.js.map +3 -3
- package/dist/src/react/bridgeInternals.d.ts +1 -0
- package/package.json +1 -1
- package/types/globals.d.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -173552,18 +173552,21 @@ __export(exports_devBuild, {
|
|
|
173552
173552
|
import { readdir as readdir2 } from "fs/promises";
|
|
173553
173553
|
import { statSync } from "fs";
|
|
173554
173554
|
import { resolve as resolve20 } from "path";
|
|
173555
|
-
var FRAMEWORK_DIR_KEYS,
|
|
173555
|
+
var FRAMEWORK_DIR_KEYS, parseDirectoryConfig = (source) => {
|
|
173556
|
+
const config = {};
|
|
173557
|
+
const dirPattern = /(\w+Directory)\s*:\s*['"]([^'"]+)['"]/g;
|
|
173558
|
+
let match;
|
|
173559
|
+
while ((match = dirPattern.exec(source)) !== null) {
|
|
173560
|
+
const [, key, value] = match;
|
|
173561
|
+
if (key && value)
|
|
173562
|
+
Object.assign(config, { [key]: value });
|
|
173563
|
+
}
|
|
173564
|
+
return Object.keys(config).length > 0 ? config : null;
|
|
173565
|
+
}, reloadConfig = async () => {
|
|
173556
173566
|
try {
|
|
173557
173567
|
const configPath2 = resolve20(process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
|
|
173558
173568
|
const source = await Bun.file(configPath2).text();
|
|
173559
|
-
|
|
173560
|
-
const dirPattern = /(\w+Directory)\s*:\s*['"]([^'"]+)['"]/g;
|
|
173561
|
-
let match;
|
|
173562
|
-
while ((match = dirPattern.exec(source)) !== null) {
|
|
173563
|
-
const [, key, value] = match;
|
|
173564
|
-
config[key] = value;
|
|
173565
|
-
}
|
|
173566
|
-
return Object.keys(config).length > 0 ? config : null;
|
|
173569
|
+
return parseDirectoryConfig(source);
|
|
173567
173570
|
} catch {
|
|
173568
173571
|
return null;
|
|
173569
173572
|
}
|
|
@@ -173573,13 +173576,7 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
|
|
|
173573
173576
|
return;
|
|
173574
173577
|
const state = cached.hmrState;
|
|
173575
173578
|
const oldConfig = state.config;
|
|
173576
|
-
|
|
173577
|
-
for (const key of FRAMEWORK_DIR_KEYS) {
|
|
173578
|
-
if (newConfig[key] !== oldConfig[key]) {
|
|
173579
|
-
hasChanges = true;
|
|
173580
|
-
break;
|
|
173581
|
-
}
|
|
173582
|
-
}
|
|
173579
|
+
const hasChanges = FRAMEWORK_DIR_KEYS.some((key) => newConfig[key] !== oldConfig[key]);
|
|
173583
173580
|
if (!hasChanges)
|
|
173584
173581
|
return;
|
|
173585
173582
|
const oldWatchPaths = new Set(getWatchPaths(oldConfig, state.resolvedPaths));
|
|
@@ -173594,7 +173591,7 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
|
|
|
173594
173591
|
setAngularVendorPaths(computeAngularVendorPaths());
|
|
173595
173592
|
}
|
|
173596
173593
|
const newWatchPaths = getWatchPaths(state.config, state.resolvedPaths);
|
|
173597
|
-
const addedPaths = newWatchPaths.filter((
|
|
173594
|
+
const addedPaths = newWatchPaths.filter((path) => !oldWatchPaths.has(path));
|
|
173598
173595
|
if (addedPaths.length > 0) {
|
|
173599
173596
|
buildInitialDependencyGraph(state.dependencyGraph, addedPaths);
|
|
173600
173597
|
addFileWatchers(state, addedPaths, (filePath) => {
|
|
@@ -173604,11 +173601,18 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
|
|
|
173604
173601
|
});
|
|
173605
173602
|
});
|
|
173606
173603
|
}
|
|
173607
|
-
},
|
|
173608
|
-
const
|
|
173604
|
+
}, removeStaleKeys = (target, source) => {
|
|
173605
|
+
for (const key of Object.keys(target)) {
|
|
173606
|
+
if (!(key in source))
|
|
173607
|
+
delete target[key];
|
|
173608
|
+
}
|
|
173609
|
+
}, REBUILD_POLL_MS = 10, waitForRebuild = async (state) => {
|
|
173609
173610
|
while (state.isRebuilding) {
|
|
173610
|
-
await Bun.sleep(
|
|
173611
|
+
await Bun.sleep(REBUILD_POLL_MS);
|
|
173611
173612
|
}
|
|
173613
|
+
}, rebuildManifest = async (cached) => {
|
|
173614
|
+
const state = cached.hmrState;
|
|
173615
|
+
await waitForRebuild(state);
|
|
173612
173616
|
state.isRebuilding = true;
|
|
173613
173617
|
try {
|
|
173614
173618
|
const newManifest = await build2({
|
|
@@ -173620,19 +173624,15 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
|
|
|
173620
173624
|
throwOnError: true
|
|
173621
173625
|
}
|
|
173622
173626
|
});
|
|
173623
|
-
if (newManifest)
|
|
173624
|
-
|
|
173625
|
-
|
|
173626
|
-
|
|
173627
|
-
|
|
173628
|
-
|
|
173629
|
-
|
|
173630
|
-
state.manifest = cached.manifest;
|
|
173631
|
-
await populateAssetStore(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
|
|
173632
|
-
await cleanStaleAssets(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
|
|
173633
|
-
}
|
|
173634
|
-
state.rebuildCount++;
|
|
173627
|
+
if (!newManifest)
|
|
173628
|
+
return;
|
|
173629
|
+
removeStaleKeys(cached.manifest, newManifest);
|
|
173630
|
+
Object.assign(cached.manifest, newManifest);
|
|
173631
|
+
state.manifest = cached.manifest;
|
|
173632
|
+
await populateAssetStore(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
|
|
173633
|
+
await cleanStaleAssets(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
|
|
173635
173634
|
} catch {} finally {
|
|
173635
|
+
state.rebuildCount++;
|
|
173636
173636
|
state.isRebuilding = false;
|
|
173637
173637
|
state.fileChangeQueue.clear();
|
|
173638
173638
|
}
|
|
@@ -173647,15 +173647,15 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
|
|
|
173647
173647
|
if (cached?.hmrState.config.angularDirectory) {
|
|
173648
173648
|
setAngularVendorPaths(computeAngularVendorPaths());
|
|
173649
173649
|
}
|
|
173650
|
-
if (serverMtime
|
|
173651
|
-
logServerReload();
|
|
173652
|
-
if (cached) {
|
|
173653
|
-
await detectConfigChanges(cached);
|
|
173654
|
-
await rebuildManifest(cached);
|
|
173655
|
-
}
|
|
173656
|
-
} else {
|
|
173650
|
+
if (serverMtime === lastMtime) {
|
|
173657
173651
|
globalThis.__hmrSkipServerRestart = true;
|
|
173652
|
+
return;
|
|
173658
173653
|
}
|
|
173654
|
+
logServerReload();
|
|
173655
|
+
if (!cached)
|
|
173656
|
+
return;
|
|
173657
|
+
await detectConfigChanges(cached);
|
|
173658
|
+
await rebuildManifest(cached);
|
|
173659
173659
|
}, tryReadPackageVersion = async (path) => {
|
|
173660
173660
|
const pkg = await Bun.file(path).json().catch(() => null);
|
|
173661
173661
|
if (!pkg || pkg.name !== "@absolutejs/absolute") {
|
|
@@ -173717,6 +173717,9 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
|
|
|
173717
173717
|
const vendorDir = resolve20(state.resolvedPaths.buildDir, "react", "vendor");
|
|
173718
173718
|
await loadVendorFiles(state.assetStore, vendorDir, "react");
|
|
173719
173719
|
}
|
|
173720
|
+
if (config.reactDirectory && !globalThis.__reactModuleRef) {
|
|
173721
|
+
globalThis.__reactModuleRef = await import("react");
|
|
173722
|
+
}
|
|
173720
173723
|
if (config.angularDirectory) {
|
|
173721
173724
|
await buildAngularVendor(state.resolvedPaths.buildDir);
|
|
173722
173725
|
const vendorDir = resolve20(state.resolvedPaths.buildDir, "angular", "vendor");
|
|
@@ -173760,6 +173763,45 @@ var init_devBuild = __esm(() => {
|
|
|
173760
173763
|
];
|
|
173761
173764
|
});
|
|
173762
173765
|
|
|
173766
|
+
// src/react/bridgeInternals.ts
|
|
173767
|
+
var INTERNALS_KEYS, isRecord = (val) => typeof val === "object" && val !== null, findInternals = (mod) => {
|
|
173768
|
+
for (const key of INTERNALS_KEYS) {
|
|
173769
|
+
const val = mod[key];
|
|
173770
|
+
if (isRecord(val))
|
|
173771
|
+
return val;
|
|
173772
|
+
}
|
|
173773
|
+
return;
|
|
173774
|
+
}, bridgeReactInternals = async () => {
|
|
173775
|
+
const pinned = globalThis.__reactModuleRef;
|
|
173776
|
+
if (!pinned)
|
|
173777
|
+
return;
|
|
173778
|
+
const react = await import("react");
|
|
173779
|
+
if (pinned === react)
|
|
173780
|
+
return;
|
|
173781
|
+
const pinnedInternals = findInternals(pinned);
|
|
173782
|
+
const currentInternals = findInternals(react);
|
|
173783
|
+
if (!pinnedInternals || !currentInternals || pinnedInternals === currentInternals)
|
|
173784
|
+
return;
|
|
173785
|
+
for (const prop of Object.keys(pinnedInternals)) {
|
|
173786
|
+
Object.defineProperty(currentInternals, prop, {
|
|
173787
|
+
configurable: true,
|
|
173788
|
+
enumerable: true,
|
|
173789
|
+
get() {
|
|
173790
|
+
return pinnedInternals[prop];
|
|
173791
|
+
},
|
|
173792
|
+
set(value) {
|
|
173793
|
+
pinnedInternals[prop] = value;
|
|
173794
|
+
}
|
|
173795
|
+
});
|
|
173796
|
+
}
|
|
173797
|
+
};
|
|
173798
|
+
var init_bridgeInternals = __esm(() => {
|
|
173799
|
+
INTERNALS_KEYS = [
|
|
173800
|
+
"__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE",
|
|
173801
|
+
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"
|
|
173802
|
+
];
|
|
173803
|
+
});
|
|
173804
|
+
|
|
173763
173805
|
// src/plugins/hmr.ts
|
|
173764
173806
|
var exports_hmr = {};
|
|
173765
173807
|
__export(exports_hmr, {
|
|
@@ -173778,7 +173820,10 @@ var STORE_KEY = "__elysiaStore", getGlobalValue = (key) => Reflect.get(globalThi
|
|
|
173778
173820
|
Reflect.set(globalThis, STORE_KEY, app.store);
|
|
173779
173821
|
}, hmr = (hmrState2, manifest) => (app) => {
|
|
173780
173822
|
restoreStore(app);
|
|
173781
|
-
return app.onBeforeHandle(({ request }) => {
|
|
173823
|
+
return app.onBeforeHandle(async ({ request }) => {
|
|
173824
|
+
if (globalThis.__reactModuleRef) {
|
|
173825
|
+
await bridgeReactInternals();
|
|
173826
|
+
}
|
|
173782
173827
|
const rawUrl = request.url;
|
|
173783
173828
|
const qIdx = rawUrl.indexOf("?");
|
|
173784
173829
|
const pathEnd = qIdx === UNFOUND_INDEX ? rawUrl.length : qIdx;
|
|
@@ -173810,6 +173855,7 @@ var STORE_KEY = "__elysiaStore", getGlobalValue = (key) => Reflect.get(globalThi
|
|
|
173810
173855
|
var init_hmr = __esm(() => {
|
|
173811
173856
|
init_constants();
|
|
173812
173857
|
init_assetStore();
|
|
173858
|
+
init_bridgeInternals();
|
|
173813
173859
|
init_webSocket();
|
|
173814
173860
|
});
|
|
173815
173861
|
// types/client.ts
|
|
@@ -173893,11 +173939,10 @@ var handleReactPageRequest = async (PageComponent, index, ...props) => {
|
|
|
173893
173939
|
const { createElement } = await import("react");
|
|
173894
173940
|
const { renderToReadableStream } = await import("react-dom/server");
|
|
173895
173941
|
const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
|
|
173896
|
-
const refreshStubs = "window.$RefreshReg$=function(){};window.$RefreshSig$=function(){return function(t){return t}};";
|
|
173897
173942
|
const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}` : "";
|
|
173898
173943
|
const stream = await renderToReadableStream(element, {
|
|
173899
173944
|
bootstrapModules: [index],
|
|
173900
|
-
bootstrapScriptContent:
|
|
173945
|
+
bootstrapScriptContent: propsScript || undefined,
|
|
173901
173946
|
onError(error) {
|
|
173902
173947
|
console.error("[SSR] React streaming error:", error);
|
|
173903
173948
|
}
|
|
@@ -174192,5 +174237,5 @@ export {
|
|
|
174192
174237
|
ANGULAR_INIT_TIMEOUT_MS
|
|
174193
174238
|
};
|
|
174194
174239
|
|
|
174195
|
-
//# debugId=
|
|
174240
|
+
//# debugId=9D6F07D79897397964756E2164756E21
|
|
174196
174241
|
//# sourceMappingURL=index.js.map
|