@absolutejs/absolute 0.19.0-beta.808 → 0.19.0-beta.809
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/dist/angular/browser.js +9801 -57
- package/dist/angular/browser.js.map +246 -4
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +14877 -60
- package/dist/angular/index.js.map +281 -4
- package/dist/angular/server.js +5610 -45
- package/dist/angular/server.js.map +51 -3
- package/dist/build.js +18092 -45
- package/dist/build.js.map +99 -3
- package/dist/cli/index.js +317 -86
- package/dist/client/index.js +1100 -40
- package/dist/client/index.js.map +24 -4
- package/dist/core/streamingSlotRegistrar.js +108 -11
- package/dist/core/streamingSlotRegistrar.js.map +4 -3
- package/dist/core/streamingSlotRegistry.js +169 -7
- package/dist/core/streamingSlotRegistry.js.map +5 -3
- package/dist/index.js +19957 -547
- package/dist/index.js.map +116 -3
- package/dist/islands/browser.js +228 -9
- package/dist/islands/browser.js.map +9 -4
- package/dist/islands/index.js +1908 -17
- package/dist/islands/index.js.map +27 -3
- package/dist/react/browser.js +328 -12
- package/dist/react/browser.js.map +12 -4
- package/dist/react/components/index.js +167 -16
- package/dist/react/components/index.js.map +6 -3
- package/dist/react/hooks/index.js +183 -8
- package/dist/react/hooks/index.js.map +7 -3
- package/dist/react/index.js +3627 -36
- package/dist/react/index.js.map +45 -4
- package/dist/react/jsxDevRuntimeCompat.js +61 -2
- package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
- package/dist/react/server.js +1789 -18
- package/dist/react/server.js.map +21 -3
- package/dist/src/angular/injectorPatch.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/svelte/browser.js +247 -12
- package/dist/svelte/browser.js.map +10 -3
- package/dist/svelte/index.js +3732 -37
- package/dist/svelte/index.js.map +47 -4
- package/dist/svelte/server.js +2794 -21
- package/dist/svelte/server.js.map +27 -3
- package/dist/vue/browser.js +348 -12
- package/dist/vue/browser.js.map +12 -4
- package/dist/vue/components/Image.js +240 -7
- package/dist/vue/components/Image.js.map +6 -3
- package/dist/vue/components/index.js +544 -11
- package/dist/vue/components/index.js.map +9 -3
- package/dist/vue/index.js +4212 -52
- package/dist/vue/index.js.map +50 -4
- package/dist/vue/server.js +1849 -18
- package/dist/vue/server.js.map +21 -3
- package/package.json +1 -1
- package/dist/chunk-0867j0r0.js +0 -136
- package/dist/chunk-0867j0r0.js.map +0 -10
- package/dist/chunk-0kdc6r16.js +0 -20
- package/dist/chunk-0kdc6r16.js.map +0 -10
- package/dist/chunk-102fp7xe.js +0 -63
- package/dist/chunk-102fp7xe.js.map +0 -10
- package/dist/chunk-11zpfqz6.js +0 -19
- package/dist/chunk-11zpfqz6.js.map +0 -10
- package/dist/chunk-1rfh7hw9.js +0 -319
- package/dist/chunk-1rfh7hw9.js.map +0 -11
- package/dist/chunk-25v9t56f.js +0 -29
- package/dist/chunk-25v9t56f.js.map +0 -11
- package/dist/chunk-2f21eenc.js +0 -21
- package/dist/chunk-2f21eenc.js.map +0 -10
- package/dist/chunk-2ga2znex.js +0 -13
- package/dist/chunk-2ga2znex.js.map +0 -9
- package/dist/chunk-30yrw0f6.js +0 -33
- package/dist/chunk-30yrw0f6.js.map +0 -10
- package/dist/chunk-38jwhqcw.js +0 -4410
- package/dist/chunk-38jwhqcw.js.map +0 -28
- package/dist/chunk-3g91wb4f.js +0 -358
- package/dist/chunk-3g91wb4f.js.map +0 -10
- package/dist/chunk-3yjzpcne.js +0 -34
- package/dist/chunk-3yjzpcne.js.map +0 -10
- package/dist/chunk-41bf6aqt.js +0 -17
- package/dist/chunk-41bf6aqt.js.map +0 -9
- package/dist/chunk-4d39r92n.js +0 -81
- package/dist/chunk-4d39r92n.js.map +0 -10
- package/dist/chunk-5003emhv.js +0 -17
- package/dist/chunk-5003emhv.js.map +0 -10
- package/dist/chunk-5f67rsed.js +0 -466
- package/dist/chunk-5f67rsed.js.map +0 -10
- package/dist/chunk-5fhp1jap.js +0 -9169
- package/dist/chunk-5fhp1jap.js.map +0 -236
- package/dist/chunk-6pdj08z3.js +0 -73
- package/dist/chunk-6pdj08z3.js.map +0 -12
- package/dist/chunk-6qjbrt0k.js +0 -13
- package/dist/chunk-6qjbrt0k.js.map +0 -9
- package/dist/chunk-6sccb4jr.js +0 -14
- package/dist/chunk-6sccb4jr.js.map +0 -9
- package/dist/chunk-798spvzv.js +0 -50
- package/dist/chunk-798spvzv.js.map +0 -10
- package/dist/chunk-7fw6x3js.js +0 -131
- package/dist/chunk-7fw6x3js.js.map +0 -11
- package/dist/chunk-7kjj42xm.js +0 -11
- package/dist/chunk-7kjj42xm.js.map +0 -10
- package/dist/chunk-7mtstdqn.js +0 -90
- package/dist/chunk-7mtstdqn.js.map +0 -10
- package/dist/chunk-851whwc7.js +0 -17
- package/dist/chunk-851whwc7.js.map +0 -10
- package/dist/chunk-85n68sy6.js +0 -103
- package/dist/chunk-85n68sy6.js.map +0 -10
- package/dist/chunk-8kcfffry.js +0 -35
- package/dist/chunk-8kcfffry.js.map +0 -10
- package/dist/chunk-8qqxc1h2.js +0 -426
- package/dist/chunk-8qqxc1h2.js.map +0 -14
- package/dist/chunk-92fsjfpp.js +0 -1731
- package/dist/chunk-92fsjfpp.js.map +0 -11
- package/dist/chunk-93sqk7be.js +0 -139
- package/dist/chunk-93sqk7be.js.map +0 -12
- package/dist/chunk-94gvx0hg.js +0 -28
- package/dist/chunk-94gvx0hg.js.map +0 -10
- package/dist/chunk-9c5tj4k3.js +0 -130
- package/dist/chunk-9c5tj4k3.js.map +0 -10
- package/dist/chunk-9ve9jq72.js +0 -203
- package/dist/chunk-9ve9jq72.js.map +0 -10
- package/dist/chunk-9xrsjeem.js +0 -12
- package/dist/chunk-9xrsjeem.js.map +0 -9
- package/dist/chunk-a9mvyp04.js +0 -87
- package/dist/chunk-a9mvyp04.js.map +0 -10
- package/dist/chunk-b3gbnrwe.js +0 -21
- package/dist/chunk-b3gbnrwe.js.map +0 -10
- package/dist/chunk-bmgqm774.js +0 -65
- package/dist/chunk-bmgqm774.js.map +0 -9
- package/dist/chunk-bxfghpma.js +0 -69
- package/dist/chunk-bxfghpma.js.map +0 -10
- package/dist/chunk-c1jfjnka.js +0 -74
- package/dist/chunk-c1jfjnka.js.map +0 -10
- package/dist/chunk-cbkrwmvh.js +0 -80
- package/dist/chunk-cbkrwmvh.js.map +0 -10
- package/dist/chunk-cdxd7sy2.js +0 -71
- package/dist/chunk-cdxd7sy2.js.map +0 -10
- package/dist/chunk-cg95827x.js +0 -21
- package/dist/chunk-cg95827x.js.map +0 -10
- package/dist/chunk-cm0g4q6w.js +0 -149
- package/dist/chunk-cm0g4q6w.js.map +0 -10
- package/dist/chunk-cwfy538a.js +0 -51
- package/dist/chunk-cwfy538a.js.map +0 -9
- package/dist/chunk-d7mwkzry.js +0 -261
- package/dist/chunk-d7mwkzry.js.map +0 -10
- package/dist/chunk-d8w0qm28.js +0 -184
- package/dist/chunk-d8w0qm28.js.map +0 -11
- package/dist/chunk-d9c0am65.js +0 -12
- package/dist/chunk-d9c0am65.js.map +0 -10
- package/dist/chunk-daqghmg8.js +0 -12
- package/dist/chunk-daqghmg8.js.map +0 -9
- package/dist/chunk-e3r9fxaa.js +0 -149
- package/dist/chunk-e3r9fxaa.js.map +0 -10
- package/dist/chunk-e8eecyrq.js +0 -244
- package/dist/chunk-e8eecyrq.js.map +0 -10
- package/dist/chunk-ex2hxe0v.js +0 -160
- package/dist/chunk-ex2hxe0v.js.map +0 -11
- package/dist/chunk-fak944et.js +0 -91
- package/dist/chunk-fak944et.js.map +0 -10
- package/dist/chunk-ff70rnhd.js +0 -672
- package/dist/chunk-ff70rnhd.js.map +0 -15
- package/dist/chunk-fygx2ymm.js +0 -118
- package/dist/chunk-fygx2ymm.js.map +0 -12
- package/dist/chunk-g15qj669.js +0 -271
- package/dist/chunk-g15qj669.js.map +0 -11
- package/dist/chunk-gd6wmknh.js +0 -121
- package/dist/chunk-gd6wmknh.js.map +0 -11
- package/dist/chunk-gf0ygptk.js +0 -85
- package/dist/chunk-gf0ygptk.js.map +0 -11
- package/dist/chunk-gytkmthr.js +0 -220
- package/dist/chunk-gytkmthr.js.map +0 -10
- package/dist/chunk-h5bbfn3n.js +0 -28
- package/dist/chunk-h5bbfn3n.js.map +0 -11
- package/dist/chunk-h6mye9r3.js +0 -93
- package/dist/chunk-h6mye9r3.js.map +0 -10
- package/dist/chunk-hcsmxw1v.js +0 -85
- package/dist/chunk-hcsmxw1v.js.map +0 -10
- package/dist/chunk-hyjs4bqs.js +0 -8
- package/dist/chunk-hyjs4bqs.js.map +0 -10
- package/dist/chunk-j88z31ep.js +0 -25
- package/dist/chunk-j88z31ep.js.map +0 -10
- package/dist/chunk-jn91vzkh.js +0 -66
- package/dist/chunk-jn91vzkh.js.map +0 -10
- package/dist/chunk-jpkjdgsk.js +0 -167
- package/dist/chunk-jpkjdgsk.js.map +0 -11
- package/dist/chunk-jwxt8gnp.js +0 -13
- package/dist/chunk-jwxt8gnp.js.map +0 -9
- package/dist/chunk-kk8w9rh5.js +0 -195
- package/dist/chunk-kk8w9rh5.js.map +0 -10
- package/dist/chunk-m97ze5hz.js +0 -46
- package/dist/chunk-m97ze5hz.js.map +0 -10
- package/dist/chunk-mbazhahf.js +0 -60
- package/dist/chunk-mbazhahf.js.map +0 -10
- package/dist/chunk-mgfwq18r.js +0 -15
- package/dist/chunk-mgfwq18r.js.map +0 -9
- package/dist/chunk-mtgf69xn.js +0 -88
- package/dist/chunk-mtgf69xn.js.map +0 -10
- package/dist/chunk-mtxzyxpg.js +0 -102
- package/dist/chunk-mtxzyxpg.js.map +0 -10
- package/dist/chunk-nehhtthw.js +0 -225
- package/dist/chunk-nehhtthw.js.map +0 -10
- package/dist/chunk-p5504p14.js +0 -16
- package/dist/chunk-p5504p14.js.map +0 -10
- package/dist/chunk-pnscgw95.js +0 -90
- package/dist/chunk-pnscgw95.js.map +0 -10
- package/dist/chunk-pvpp4pvs.js +0 -17
- package/dist/chunk-pvpp4pvs.js.map +0 -10
- package/dist/chunk-qh75agse.js +0 -95
- package/dist/chunk-qh75agse.js.map +0 -10
- package/dist/chunk-qxq2zcty.js +0 -52
- package/dist/chunk-qxq2zcty.js.map +0 -10
- package/dist/chunk-r6e8pytx.js +0 -22
- package/dist/chunk-r6e8pytx.js.map +0 -9
- package/dist/chunk-r7jmgqnw.js +0 -114
- package/dist/chunk-r7jmgqnw.js.map +0 -10
- package/dist/chunk-s6defjk2.js +0 -116
- package/dist/chunk-s6defjk2.js.map +0 -10
- package/dist/chunk-sd39p726.js +0 -619
- package/dist/chunk-sd39p726.js.map +0 -10
- package/dist/chunk-swrnzs4c.js +0 -63
- package/dist/chunk-swrnzs4c.js.map +0 -10
- package/dist/chunk-tfe3sb44.js +0 -33
- package/dist/chunk-tfe3sb44.js.map +0 -10
- package/dist/chunk-tjr0kcev.js +0 -41
- package/dist/chunk-tjr0kcev.js.map +0 -9
- package/dist/chunk-tx9edm1x.js +0 -34
- package/dist/chunk-tx9edm1x.js.map +0 -10
- package/dist/chunk-txhm2vb5.js +0 -18
- package/dist/chunk-txhm2vb5.js.map +0 -9
- package/dist/chunk-v5vmsxmy.js +0 -526
- package/dist/chunk-v5vmsxmy.js.map +0 -12
- package/dist/chunk-vjhxm8n2.js +0 -29
- package/dist/chunk-vjhxm8n2.js.map +0 -9
- package/dist/chunk-vkrpm7kc.js +0 -247
- package/dist/chunk-vkrpm7kc.js.map +0 -12
- package/dist/chunk-w3m4m5we.js +0 -4925
- package/dist/chunk-w3m4m5we.js.map +0 -12
- package/dist/chunk-wrxtn9ve.js +0 -18
- package/dist/chunk-wrxtn9ve.js.map +0 -10
- package/dist/chunk-wwzvp0zn.js +0 -192
- package/dist/chunk-wwzvp0zn.js.map +0 -10
- package/dist/chunk-x09cskqd.js +0 -377
- package/dist/chunk-x09cskqd.js.map +0 -10
- package/dist/chunk-xnt8c6h2.js +0 -576
- package/dist/chunk-xnt8c6h2.js.map +0 -10
- package/dist/chunk-xw0tx842.js +0 -13
- package/dist/chunk-xw0tx842.js.map +0 -9
- package/dist/chunk-xx5b6b9m.js +0 -69
- package/dist/chunk-xx5b6b9m.js.map +0 -10
- package/dist/chunk-xz1kdswj.js +0 -21
- package/dist/chunk-xz1kdswj.js.map +0 -9
- package/dist/chunk-y84qnsd3.js +0 -32
- package/dist/chunk-y84qnsd3.js.map +0 -10
- package/dist/chunk-ywjn0rad.js +0 -14
- package/dist/chunk-ywjn0rad.js.map +0 -9
- package/dist/chunk-z9nvhm6r.js +0 -13
- package/dist/chunk-z9nvhm6r.js.map +0 -9
- package/dist/chunk-zhmvdpk6.js +0 -15
- package/dist/chunk-zhmvdpk6.js.map +0 -9
- package/dist/chunk-zrg9d4zw.js +0 -784
- package/dist/chunk-zrg9d4zw.js.map +0 -10
package/dist/chunk-3g91wb4f.js
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
toPascal
|
|
4
|
-
} from "./chunk-p5504p14.js";
|
|
5
|
-
|
|
6
|
-
// src/build/generateReactIndexes.ts
|
|
7
|
-
import { existsSync, mkdirSync } from "fs";
|
|
8
|
-
import { readdir, rm, writeFile } from "fs/promises";
|
|
9
|
-
import { basename, join, relative, resolve, sep } from "path";
|
|
10
|
-
var {Glob } = globalThis.Bun;
|
|
11
|
-
var indexContentCache = new Map;
|
|
12
|
-
var resolveDevClientDir = () => {
|
|
13
|
-
const projectRoot = process.cwd();
|
|
14
|
-
const fromSource = resolve(import.meta.dir, "../dev/client");
|
|
15
|
-
if (existsSync(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
16
|
-
return fromSource;
|
|
17
|
-
}
|
|
18
|
-
const fromNodeModules = resolve(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
19
|
-
if (existsSync(fromNodeModules))
|
|
20
|
-
return fromNodeModules;
|
|
21
|
-
return resolve(import.meta.dir, "./dev/client");
|
|
22
|
-
};
|
|
23
|
-
var devClientDir = resolveDevClientDir();
|
|
24
|
-
var errorOverlayPath = join(devClientDir, "errorOverlay.ts").replace(/\\/g, "/");
|
|
25
|
-
var hmrClientPath = join(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
|
|
26
|
-
var refreshSetupPath = join(devClientDir, "reactRefreshSetup.ts").replace(/\\/g, "/");
|
|
27
|
-
var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory, isDev = false) => {
|
|
28
|
-
if (!existsSync(reactIndexesDirectory)) {
|
|
29
|
-
mkdirSync(reactIndexesDirectory, { recursive: true });
|
|
30
|
-
}
|
|
31
|
-
const CONVENTION_RE = /^(?:(.+)\.)?(error|loading|not-found)\.[^.]+$/;
|
|
32
|
-
const pagesGlob = new Glob("*.{jsx,tsx}");
|
|
33
|
-
const files = [];
|
|
34
|
-
for await (const file of pagesGlob.scan({ cwd: reactPagesDirectory })) {
|
|
35
|
-
if (CONVENTION_RE.test(file))
|
|
36
|
-
continue;
|
|
37
|
-
files.push(file);
|
|
38
|
-
}
|
|
39
|
-
const currentPageNames = new Set(files.map((file) => basename(file).split(".")[0]));
|
|
40
|
-
const emptyStringArray = [];
|
|
41
|
-
const existingIndexes = await readdir(reactIndexesDirectory).catch(() => emptyStringArray);
|
|
42
|
-
const staleIndexes = existingIndexes.filter((indexFile) => {
|
|
43
|
-
const indexName = indexFile.replace(/\.tsx$/, "");
|
|
44
|
-
return indexName !== "_refresh" && !currentPageNames.has(indexName);
|
|
45
|
-
});
|
|
46
|
-
if (staleIndexes.length > 0) {
|
|
47
|
-
await Promise.all(staleIndexes.map((indexFile) => {
|
|
48
|
-
indexContentCache.delete(join(reactIndexesDirectory, indexFile));
|
|
49
|
-
return rm(join(reactIndexesDirectory, indexFile), {
|
|
50
|
-
force: true
|
|
51
|
-
});
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
const pagesRelPath = relative(resolve(reactIndexesDirectory), resolve(reactPagesDirectory)).split(sep).join("/");
|
|
55
|
-
const promises = files.map(async (file) => {
|
|
56
|
-
const fileName = basename(file);
|
|
57
|
-
const componentName = fileName.split(".")[0];
|
|
58
|
-
const pascalComponentName = toPascal(componentName);
|
|
59
|
-
const hmrPreamble = isDev ? [
|
|
60
|
-
`window.__HMR_FRAMEWORK__ = "react";`,
|
|
61
|
-
`window.__REACT_COMPONENT_KEY__ = "${componentName}Index";`,
|
|
62
|
-
`import '${refreshSetupPath}';`,
|
|
63
|
-
`import '${hmrClientPath}';`,
|
|
64
|
-
`import { showErrorOverlay, hideErrorOverlay } from '${errorOverlayPath}';
|
|
65
|
-
`
|
|
66
|
-
] : [];
|
|
67
|
-
const reactImports = isDev ? [
|
|
68
|
-
`import { hydrateRoot, createRoot } from 'react-dom/client';`,
|
|
69
|
-
`import { createElement, Component } from 'react';`
|
|
70
|
-
] : [
|
|
71
|
-
`import { hydrateRoot, createRoot } from 'react-dom/client';`,
|
|
72
|
-
`import { createElement } from 'react';`
|
|
73
|
-
];
|
|
74
|
-
const errorBoundaryDef = isDev ? [
|
|
75
|
-
`
|
|
76
|
-
// Dev-only Error Boundary to catch React render errors`,
|
|
77
|
-
`class ErrorBoundary extends Component {`,
|
|
78
|
-
` constructor(props) {`,
|
|
79
|
-
` super(props);`,
|
|
80
|
-
` this.state = { hasError: false };`,
|
|
81
|
-
` window.__ERROR_BOUNDARY__ = this;`,
|
|
82
|
-
` }`,
|
|
83
|
-
` static getDerivedStateFromError() {`,
|
|
84
|
-
` return { hasError: true };`,
|
|
85
|
-
` }`,
|
|
86
|
-
` componentDidCatch(error) {`,
|
|
87
|
-
` showErrorOverlay({`,
|
|
88
|
-
` framework: 'react',`,
|
|
89
|
-
` kind: 'runtime',`,
|
|
90
|
-
` message: error && error.stack ? error.stack : String(error)`,
|
|
91
|
-
` });`,
|
|
92
|
-
` }`,
|
|
93
|
-
` componentDidUpdate(prevProps, prevState) {`,
|
|
94
|
-
` if (prevState.hasError && !this.state.hasError) {`,
|
|
95
|
-
` hideErrorOverlay();`,
|
|
96
|
-
` }`,
|
|
97
|
-
` }`,
|
|
98
|
-
` reset() {`,
|
|
99
|
-
` this.setState({ hasError: false });`,
|
|
100
|
-
` }`,
|
|
101
|
-
` render() {`,
|
|
102
|
-
` if (this.state.hasError) return null;`,
|
|
103
|
-
``,
|
|
104
|
-
` return this.props.children;`,
|
|
105
|
-
` }`,
|
|
106
|
-
`}
|
|
107
|
-
`
|
|
108
|
-
] : [];
|
|
109
|
-
const content = [
|
|
110
|
-
...hmrPreamble,
|
|
111
|
-
...reactImports,
|
|
112
|
-
`import * as PageModule from '${pagesRelPath}/${componentName}';
|
|
113
|
-
`,
|
|
114
|
-
...errorBoundaryDef,
|
|
115
|
-
`// Hydration with error handling and fallback`,
|
|
116
|
-
`const isDev = ${isDev};`,
|
|
117
|
-
`const componentPath = '${pagesRelPath}/${componentName}';
|
|
118
|
-
`,
|
|
119
|
-
`function resolvePageComponent(module, candidateNames) {`,
|
|
120
|
-
` for (const name of candidateNames) {`,
|
|
121
|
-
` const value = module[name];`,
|
|
122
|
-
` if (typeof value === 'function' || (value && typeof value === 'object')) return value;`,
|
|
123
|
-
` }`,
|
|
124
|
-
` for (const [name, value] of Object.entries(module)) {`,
|
|
125
|
-
` if (!/^[A-Z]/.test(name)) continue;`,
|
|
126
|
-
` if (typeof value === 'function' || (value && typeof value === 'object')) return value;`,
|
|
127
|
-
` }`,
|
|
128
|
-
` throw new Error('React page module ' + componentPath + ' does not export a component. Expected default, ${pascalComponentName}, ${componentName}, or any PascalCase export.');`,
|
|
129
|
-
`}`,
|
|
130
|
-
`const PageComponent = resolvePageComponent(PageModule, ['default', '${pascalComponentName}', '${componentName}']);
|
|
131
|
-
`,
|
|
132
|
-
`function isHydrationError(error) {`,
|
|
133
|
-
` if (!error) return false;`,
|
|
134
|
-
` const errorMessage = error instanceof Error ? error.message : String(error);`,
|
|
135
|
-
` const errorString = String(error);`,
|
|
136
|
-
` const fullMessage = errorMessage + ' ' + errorString;`,
|
|
137
|
-
` const hydrationKeywords = ['hydration', 'Hydration', 'mismatch', 'Mismatch', 'did not match', 'server rendered HTML', 'server HTML', 'client HTML', 'Hydration failed'];`,
|
|
138
|
-
` const isHydration = hydrationKeywords.some(keyword => fullMessage.includes(keyword));`,
|
|
139
|
-
` `,
|
|
140
|
-
` // Ignore whitespace-only mismatches in <head> - these are harmless formatting differences`,
|
|
141
|
-
` // The error often shows: + <link...> vs - {"\\n "} which is just formatting`,
|
|
142
|
-
` if (isHydration) {`,
|
|
143
|
-
` // Check if this is a head/link/stylesheet related mismatch`,
|
|
144
|
-
` const isHeadRelated = fullMessage.includes('<head') || fullMessage.includes('</head>') || fullMessage.includes('head>') || fullMessage.includes('<link') || fullMessage.includes('link>') || fullMessage.includes('stylesheet') || fullMessage.includes('fonts.googleapis') || fullMessage.includes('rel="stylesheet"');`,
|
|
145
|
-
` `,
|
|
146
|
-
` // Check if the mismatch involves only whitespace/newlines`,
|
|
147
|
-
` // Pattern: looks for {"\\n"} or {"\\n "} or similar whitespace-only content`,
|
|
148
|
-
` // Also check for patterns like: - {"\\n "} or + <link...>`,
|
|
149
|
-
` const hasWhitespacePattern = /\\{\\s*["']\\\\n[^"']*["']\\s*\\}/.test(fullMessage) || /\\{\\s*["'][\\\\n\\\\r\\\\s]+["']\\s*\\}/.test(fullMessage) || /-\\s*\\{\\s*["'][\\\\n\\\\r\\\\s]+["']\\s*\\}/.test(fullMessage);`,
|
|
150
|
-
` const isWhitespaceOnly = /^[\\s\\n\\r]*$/.test(errorString) || /^[\\s\\n\\r]*$/.test(errorMessage);`,
|
|
151
|
-
` const hasNewlinePattern = fullMessage.includes('\\\\n') || fullMessage.includes('\\\\r') || fullMessage.includes('\\n') || fullMessage.includes('\\r');`,
|
|
152
|
-
` `,
|
|
153
|
-
` // If it's head-related and involves whitespace/newlines, ignore it`,
|
|
154
|
-
` if (isHeadRelated && (hasWhitespacePattern || isWhitespaceOnly || hasNewlinePattern)) {`,
|
|
155
|
-
` return false; // Don't treat whitespace-only head mismatches as errors`,
|
|
156
|
-
` }`,
|
|
157
|
-
` }`,
|
|
158
|
-
` return isHydration;`,
|
|
159
|
-
`}
|
|
160
|
-
`,
|
|
161
|
-
`function logHydrationError(error, componentName) {`,
|
|
162
|
-
` if (!isDev) return;`,
|
|
163
|
-
` if (window.__HMR_WS__ && window.__HMR_WS__.readyState === WebSocket.OPEN) {`,
|
|
164
|
-
` try {`,
|
|
165
|
-
` window.__HMR_WS__.send(JSON.stringify({`,
|
|
166
|
-
` type: 'hydration-error',`,
|
|
167
|
-
` data: {`,
|
|
168
|
-
` componentName: '${componentName}',`,
|
|
169
|
-
` componentPath: componentPath,`,
|
|
170
|
-
` error: error instanceof Error ? error.message : String(error),`,
|
|
171
|
-
` timestamp: Date.now()`,
|
|
172
|
-
` }`,
|
|
173
|
-
` }));`,
|
|
174
|
-
` } catch (err) {}`,
|
|
175
|
-
` }`,
|
|
176
|
-
`}
|
|
177
|
-
`,
|
|
178
|
-
`// Track if we've already switched to client-only mode`,
|
|
179
|
-
`let hasSwitchedToClientOnly = false;`,
|
|
180
|
-
`let hydrationErrorDetected = false;
|
|
181
|
-
`,
|
|
182
|
-
`function handleHydrationFallback(error) {`,
|
|
183
|
-
` if (hasSwitchedToClientOnly) return; // Already handled`,
|
|
184
|
-
` hasSwitchedToClientOnly = true;`,
|
|
185
|
-
` hydrationErrorDetected = true;
|
|
186
|
-
`,
|
|
187
|
-
` logHydrationError(error, '${componentName}');
|
|
188
|
-
`,
|
|
189
|
-
` // Fallback: client-only render (no hydration)`,
|
|
190
|
-
` try {`,
|
|
191
|
-
` // Unmount existing root if it exists`,
|
|
192
|
-
` if (window.__REACT_ROOT__ && typeof window.__REACT_ROOT__.unmount === 'function') {`,
|
|
193
|
-
` try {`,
|
|
194
|
-
` window.__REACT_ROOT__.unmount();`,
|
|
195
|
-
` } catch (e) {`,
|
|
196
|
-
` // Ignore unmount errors`,
|
|
197
|
-
` }`,
|
|
198
|
-
` }
|
|
199
|
-
`,
|
|
200
|
-
` // Render into the same root container when falling back to client-only`,
|
|
201
|
-
` const root = createRoot(container);`,
|
|
202
|
-
` root.render(${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`});`,
|
|
203
|
-
` window.__REACT_ROOT__ = root;`,
|
|
204
|
-
` window.__HMR_CLIENT_ONLY_MODE__ = true;`,
|
|
205
|
-
` } catch (fallbackError) {`,
|
|
206
|
-
` window.location.reload();`,
|
|
207
|
-
` }`,
|
|
208
|
-
`}
|
|
209
|
-
`,
|
|
210
|
-
`// HMR State Preservation: Check for preserved state and merge with initial props`,
|
|
211
|
-
`// This allows state to be preserved across HMR updates without modifying component files`,
|
|
212
|
-
`let preservedState = (typeof window !== 'undefined' && window.__HMR_PRESERVED_STATE__) ? window.__HMR_PRESERVED_STATE__ : {};
|
|
213
|
-
`,
|
|
214
|
-
`// Also check sessionStorage for state that survived a page reload (for React HMR)`,
|
|
215
|
-
`if (typeof window !== 'undefined' && typeof sessionStorage !== 'undefined') {`,
|
|
216
|
-
` const hmrStateJson = sessionStorage.getItem('__REACT_HMR_STATE__');`,
|
|
217
|
-
` if (hmrStateJson) {`,
|
|
218
|
-
` try {`,
|
|
219
|
-
` const hmrState = JSON.parse(hmrStateJson);`,
|
|
220
|
-
` preservedState = { ...preservedState, ...hmrState };`,
|
|
221
|
-
` sessionStorage.removeItem('__REACT_HMR_STATE__');`,
|
|
222
|
-
` } catch (e) {}`,
|
|
223
|
-
` }`,
|
|
224
|
-
`}
|
|
225
|
-
`,
|
|
226
|
-
`const mergedProps = { ...(window.__INITIAL_PROPS__ || {}), ...preservedState };`,
|
|
227
|
-
`// Clear preserved state after using it (so it doesn't persist across multiple updates)`,
|
|
228
|
-
`if (typeof window !== 'undefined') {`,
|
|
229
|
-
` window.__HMR_PRESERVED_STATE__ = undefined;`,
|
|
230
|
-
`}
|
|
231
|
-
`,
|
|
232
|
-
`// Attempt hydration with error handling`,
|
|
233
|
-
`// Use document (not document.body) when the page renders <html><head><body>`,
|
|
234
|
-
`// to avoid "In HTML, <html> cannot be a child of <body>" hydration error`,
|
|
235
|
-
`const container = typeof document !== 'undefined' ? document : null;`,
|
|
236
|
-
`if (!container) {`,
|
|
237
|
-
` throw new Error('React root container not found: document is null');`,
|
|
238
|
-
`}
|
|
239
|
-
`,
|
|
240
|
-
`// Guard: only hydrate on first load. During HMR re-imports, skip hydration`,
|
|
241
|
-
`// so React Fast Refresh can swap components in-place and preserve state.`,
|
|
242
|
-
`if (!window.__REACT_ROOT__) {`,
|
|
243
|
-
` let root;`,
|
|
244
|
-
` // After HMR, SSR is skipped to avoid stale content flash \u2014 render client-only`,
|
|
245
|
-
` if (window.__SSR_DIRTY__) {`,
|
|
246
|
-
` root = createRoot(container);`,
|
|
247
|
-
` root.render(${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`});`,
|
|
248
|
-
` window.__REACT_ROOT__ = root;`,
|
|
249
|
-
` } else {`,
|
|
250
|
-
` try {`,
|
|
251
|
-
` // Use onRecoverableError to catch hydration errors (React 19)`,
|
|
252
|
-
` root = hydrateRoot(`,
|
|
253
|
-
` container,`,
|
|
254
|
-
` ${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`},`,
|
|
255
|
-
` {`,
|
|
256
|
-
` onRecoverableError: (error) => {`,
|
|
257
|
-
` // Check if this is a hydration error (isHydrationError filters out whitespace-only head mismatches)`,
|
|
258
|
-
` if (isDev && isHydrationError(error)) {`,
|
|
259
|
-
` // Real hydration error - handle it`,
|
|
260
|
-
` handleHydrationFallback(error);`,
|
|
261
|
-
` } else {`,
|
|
262
|
-
` // Not a hydration error, or it's a whitespace-only mismatch that was filtered out`,
|
|
263
|
-
` // Check if it's a whitespace-only head mismatch using the same logic as isHydrationError`,
|
|
264
|
-
` const errorMessage = error instanceof Error ? error.message : String(error);`,
|
|
265
|
-
` const errorString = String(error);`,
|
|
266
|
-
` const fullMessage = errorMessage + ' ' + errorString;`,
|
|
267
|
-
` const hydrationKeywords = ['hydration', 'Hydration', 'mismatch', 'Mismatch', 'did not match', 'server rendered HTML', 'server HTML', 'client HTML', 'Hydration failed'];`,
|
|
268
|
-
` const isHydration = hydrationKeywords.some(keyword => fullMessage.includes(keyword));`,
|
|
269
|
-
` if (isHydration) {`,
|
|
270
|
-
` // Check if this is a head/link/stylesheet related mismatch`,
|
|
271
|
-
` const isHeadRelated = fullMessage.includes('<head') || fullMessage.includes('</head>') || fullMessage.includes('head>') || fullMessage.includes('<link') || fullMessage.includes('link>') || fullMessage.includes('stylesheet') || fullMessage.includes('fonts.googleapis') || fullMessage.includes('rel="stylesheet"');`,
|
|
272
|
-
` // Check if the mismatch involves only whitespace/newlines`,
|
|
273
|
-
` const hasWhitespacePattern = /\\{\\s*["']\\\\n[^"']*["']\\s*\\}/.test(fullMessage) || /\\{\\s*["'][\\\\n\\\\r\\\\s]+["']\\s*\\}/.test(fullMessage) || /-\\s*\\{\\s*["'][\\\\n\\\\r\\\\s]+["']\\s*\\}/.test(fullMessage);`,
|
|
274
|
-
` const isWhitespaceOnly = /^[\\s\\n\\r]*$/.test(errorString) || /^[\\s\\n\\r]*$/.test(errorMessage);`,
|
|
275
|
-
` const hasNewlinePattern = fullMessage.includes('\\\\n') || fullMessage.includes('\\\\r') || fullMessage.includes('\\n') || fullMessage.includes('\\r');`,
|
|
276
|
-
` // If it's head-related and involves whitespace/newlines, silently ignore it`,
|
|
277
|
-
` if (isHeadRelated && (hasWhitespacePattern || isWhitespaceOnly || hasNewlinePattern)) {`,
|
|
278
|
-
` // Already logged by isHydrationError, just return silently`,
|
|
279
|
-
` return;`,
|
|
280
|
-
` }`,
|
|
281
|
-
` }`,
|
|
282
|
-
` // Log other recoverable errors`,
|
|
283
|
-
` console.error('React recoverable error:', error);`,
|
|
284
|
-
` }`,
|
|
285
|
-
` }`,
|
|
286
|
-
` }`,
|
|
287
|
-
` );`,
|
|
288
|
-
` window.__REACT_ROOT__ = root;`,
|
|
289
|
-
` } catch (error) {`,
|
|
290
|
-
` // Catch synchronous errors (shouldn't happen with hydrateRoot, but safety net)`,
|
|
291
|
-
` if (isDev && isHydrationError(error)) {`,
|
|
292
|
-
` handleHydrationFallback(error);`,
|
|
293
|
-
` } else {`,
|
|
294
|
-
` throw error;`,
|
|
295
|
-
` }`,
|
|
296
|
-
` }`,
|
|
297
|
-
` } // end else (normal hydration path)
|
|
298
|
-
`,
|
|
299
|
-
` // Also listen for hydration errors via console.error (React logs them there)`,
|
|
300
|
-
` if (isDev) {`,
|
|
301
|
-
` const originalError = console.error;`,
|
|
302
|
-
` console.error = function(...args) {`,
|
|
303
|
-
` const errorMessage = args.map(arg => {`,
|
|
304
|
-
` if (arg instanceof Error) return arg.message;`,
|
|
305
|
-
` return String(arg);`,
|
|
306
|
-
` }).join(' ');`,
|
|
307
|
-
` `,
|
|
308
|
-
` // Check if this is a hydration error`,
|
|
309
|
-
` if (isHydrationError({ message: errorMessage }) && !hydrationErrorDetected) {`,
|
|
310
|
-
` hydrationErrorDetected = true;`,
|
|
311
|
-
` // Create a synthetic error for fallback`,
|
|
312
|
-
` const syntheticError = new Error(errorMessage);`,
|
|
313
|
-
` // Use setTimeout to ensure this happens after React's error handling`,
|
|
314
|
-
` setTimeout(() => {`,
|
|
315
|
-
` handleHydrationFallback(syntheticError);`,
|
|
316
|
-
` }, 0);`,
|
|
317
|
-
` }`,
|
|
318
|
-
` `,
|
|
319
|
-
` // Call original console.error`,
|
|
320
|
-
` originalError.apply(console, args);`,
|
|
321
|
-
` };`,
|
|
322
|
-
` }`,
|
|
323
|
-
`}`,
|
|
324
|
-
...isDev ? [
|
|
325
|
-
`
|
|
326
|
-
// Pre-warm: import the page module from the module server`,
|
|
327
|
-
`// immediately so the browser caches all /@src/ URLs.`,
|
|
328
|
-
`import('/@src/${relative(process.cwd(), resolve(reactPagesDirectory, `${componentName}.tsx`)).replace(/\\/g, "/")}').catch(() => {});`
|
|
329
|
-
] : []
|
|
330
|
-
].join(`
|
|
331
|
-
`);
|
|
332
|
-
const indexPath = join(reactIndexesDirectory, `${componentName}.tsx`);
|
|
333
|
-
const hasher = new Bun.CryptoHasher("md5");
|
|
334
|
-
hasher.update(content);
|
|
335
|
-
const contentHash = hasher.digest("hex");
|
|
336
|
-
if (indexContentCache.get(indexPath) === contentHash && existsSync(indexPath)) {
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
indexContentCache.set(indexPath, contentHash);
|
|
340
|
-
await writeFile(indexPath, content);
|
|
341
|
-
});
|
|
342
|
-
await Promise.all(promises);
|
|
343
|
-
if (!isDev) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const refreshPath = join(reactIndexesDirectory, "_refresh.tsx");
|
|
347
|
-
if (!existsSync(refreshPath)) {
|
|
348
|
-
await writeFile(refreshPath, `import '${refreshSetupPath}';
|
|
349
|
-
import 'react';
|
|
350
|
-
import 'react-dom/client';
|
|
351
|
-
`);
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
export { generateReactIndexFiles };
|
|
356
|
-
|
|
357
|
-
//# debugId=3CD4375ABE2D804864756E2164756E21
|
|
358
|
-
//# sourceMappingURL=chunk-3g91wb4f.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/build/generateReactIndexes.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { existsSync, mkdirSync } from 'fs';\nimport { readdir, rm, writeFile } from 'fs/promises';\nimport { basename, join, relative, resolve, sep } from 'path';\nimport { Glob } from 'bun';\nimport { toPascal } from '../utils/stringModifiers';\n\nconst indexContentCache = new Map<string, string>();\n\nconst resolveDevClientDir = () => {\n\tconst projectRoot = process.cwd();\n\tconst fromSource = resolve(import.meta.dir, '../dev/client');\n\n\t// Only use the source path if it exists AND is within the project root\n\t// (i.e., we're developing absolutejs itself, not using it as a dependency)\n\tif (existsSync(fromSource) && fromSource.startsWith(projectRoot)) {\n\t\treturn fromSource;\n\t}\n\n\t// When running from a published npm package, use the installed copy\n\tconst fromNodeModules = resolve(\n\t\tprojectRoot,\n\t\t'node_modules/@absolutejs/absolute/dist/dev/client'\n\t);\n\tif (existsSync(fromNodeModules)) return fromNodeModules;\n\n\treturn resolve(import.meta.dir, './dev/client');\n};\n\nconst devClientDir = resolveDevClientDir();\n\nconst errorOverlayPath = join(devClientDir, 'errorOverlay.ts').replace(\n\t/\\\\/g,\n\t'/'\n);\n\nconst hmrClientPath = join(devClientDir, 'hmrClient.ts').replace(/\\\\/g, '/');\n\nconst refreshSetupPath = join(devClientDir, 'reactRefreshSetup.ts').replace(\n\t/\\\\/g,\n\t'/'\n);\n\nexport const generateReactIndexFiles = async (\n\treactPagesDirectory: string,\n\treactIndexesDirectory: string,\n\tisDev = false\n) => {\n\tif (!existsSync(reactIndexesDirectory)) {\n\t\tmkdirSync(reactIndexesDirectory, { recursive: true });\n\t}\n\n\tconst CONVENTION_RE = /^(?:(.+)\\.)?(error|loading|not-found)\\.[^.]+$/;\n\tconst pagesGlob = new Glob('*.{jsx,tsx}');\n\tconst files: string[] = [];\n\tfor await (const file of pagesGlob.scan({ cwd: reactPagesDirectory })) {\n\t\tif (CONVENTION_RE.test(file)) continue;\n\t\tfiles.push(file);\n\t}\n\n\t// Remove stale indexes whose source pages no longer exist\n\tconst currentPageNames = new Set(\n\t\tfiles.map((file) => basename(file).split('.')[0])\n\t);\n\n\tconst emptyStringArray: string[] = [];\n\n\tconst existingIndexes = await readdir(reactIndexesDirectory).catch(\n\t\t() => emptyStringArray\n\t);\n\n\tconst staleIndexes = existingIndexes.filter((indexFile) => {\n\t\tconst indexName = indexFile.replace(/\\.tsx$/, '');\n\n\t\treturn indexName !== '_refresh' && !currentPageNames.has(indexName);\n\t});\n\n\tif (staleIndexes.length > 0) {\n\t\tawait Promise.all(\n\t\t\tstaleIndexes.map((indexFile) => {\n\t\t\t\tindexContentCache.delete(\n\t\t\t\t\tjoin(reactIndexesDirectory, indexFile)\n\t\t\t\t);\n\n\t\t\t\treturn rm(join(reactIndexesDirectory, indexFile), {\n\t\t\t\t\tforce: true\n\t\t\t\t});\n\t\t\t})\n\t\t);\n\t}\n\n\t// Compute relative path from indexes dir to pages dir for imports\n\tconst pagesRelPath = relative(\n\t\tresolve(reactIndexesDirectory),\n\t\tresolve(reactPagesDirectory)\n\t)\n\t\t.split(sep)\n\t\t.join('/');\n\n\tconst promises = files.map(async (file) => {\n\t\tconst fileName = basename(file);\n\t\tconst componentName = fileName.split('.')[0]!;\n\t\tconst pascalComponentName = toPascal(componentName);\n\n\t\tconst hmrPreamble = isDev\n\t\t\t? [\n\t\t\t\t\t`window.__HMR_FRAMEWORK__ = \"react\";`,\n\t\t\t\t\t`window.__REACT_COMPONENT_KEY__ = \"${componentName}Index\";`,\n\t\t\t\t\t`import '${refreshSetupPath}';`,\n\t\t\t\t\t`import '${hmrClientPath}';`,\n\t\t\t\t\t`import { showErrorOverlay, hideErrorOverlay } from '${errorOverlayPath}';\\n`\n\t\t\t\t]\n\t\t\t: [];\n\n\t\tconst reactImports = isDev\n\t\t\t? [\n\t\t\t\t\t`import { hydrateRoot, createRoot } from 'react-dom/client';`,\n\t\t\t\t\t`import { createElement, Component } from 'react';`\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t`import { hydrateRoot, createRoot } from 'react-dom/client';`,\n\t\t\t\t\t`import { createElement } from 'react';`\n\t\t\t\t];\n\n\t\tconst errorBoundaryDef = isDev\n\t\t\t? [\n\t\t\t\t\t`\\n// Dev-only Error Boundary to catch React render errors`,\n\t\t\t\t\t`class ErrorBoundary extends Component {`,\n\t\t\t\t\t`\\tconstructor(props) {`,\n\t\t\t\t\t`\\t\\tsuper(props);`,\n\t\t\t\t\t`\\t\\tthis.state = { hasError: false };`,\n\t\t\t\t\t`\\t\\twindow.__ERROR_BOUNDARY__ = this;`,\n\t\t\t\t\t`\\t}`,\n\t\t\t\t\t`\\tstatic getDerivedStateFromError() {`,\n\t\t\t\t\t`\\t\\treturn { hasError: true };`,\n\t\t\t\t\t`\\t}`,\n\t\t\t\t\t`\\tcomponentDidCatch(error) {`,\n\t\t\t\t\t`\\t\\tshowErrorOverlay({`,\n\t\t\t\t\t`\\t\\t\\tframework: 'react',`,\n\t\t\t\t\t`\\t\\t\\tkind: 'runtime',`,\n\t\t\t\t\t`\\t\\t\\tmessage: error && error.stack ? error.stack : String(error)`,\n\t\t\t\t\t`\\t\\t});`,\n\t\t\t\t\t`\\t}`,\n\t\t\t\t\t`\\tcomponentDidUpdate(prevProps, prevState) {`,\n\t\t\t\t\t`\\t\\tif (prevState.hasError && !this.state.hasError) {`,\n\t\t\t\t\t`\\t\\t\\thideErrorOverlay();`,\n\t\t\t\t\t`\\t\\t}`,\n\t\t\t\t\t`\\t}`,\n\t\t\t\t\t`\\treset() {`,\n\t\t\t\t\t`\\t\\tthis.setState({ hasError: false });`,\n\t\t\t\t\t`\\t}`,\n\t\t\t\t\t`\\trender() {`,\n\t\t\t\t\t`\\t\\tif (this.state.hasError) return null;`,\n\t\t\t\t\t``,\n\t\t\t\t\t`\\t\\treturn this.props.children;`,\n\t\t\t\t\t`\\t}`,\n\t\t\t\t\t`}\\n`\n\t\t\t\t]\n\t\t\t: [];\n\n\t\tconst content = [\n\t\t\t...hmrPreamble,\n\t\t\t...reactImports,\n\t\t\t`import * as PageModule from '${pagesRelPath}/${componentName}';\\n`,\n\t\t\t...errorBoundaryDef,\n\t\t\t`// Hydration with error handling and fallback`,\n\t\t\t`const isDev = ${isDev};`,\n\t\t\t`const componentPath = '${pagesRelPath}/${componentName}';\\n`,\n\t\t\t`function resolvePageComponent(module, candidateNames) {`,\n\t\t\t`\\tfor (const name of candidateNames) {`,\n\t\t\t`\\t\\tconst value = module[name];`,\n\t\t\t`\\t\\tif (typeof value === 'function' || (value && typeof value === 'object')) return value;`,\n\t\t\t`\\t}`,\n\t\t\t`\\tfor (const [name, value] of Object.entries(module)) {`,\n\t\t\t`\\t\\tif (!/^[A-Z]/.test(name)) continue;`,\n\t\t\t`\\t\\tif (typeof value === 'function' || (value && typeof value === 'object')) return value;`,\n\t\t\t`\\t}`,\n\t\t\t`\\tthrow new Error('React page module ' + componentPath + ' does not export a component. Expected default, ${pascalComponentName}, ${componentName}, or any PascalCase export.');`,\n\t\t\t`}`,\n\t\t\t`const PageComponent = resolvePageComponent(PageModule, ['default', '${pascalComponentName}', '${componentName}']);\\n`,\n\t\t\t`function isHydrationError(error) {`,\n\t\t\t`\\tif (!error) return false;`,\n\t\t\t`\\tconst errorMessage = error instanceof Error ? error.message : String(error);`,\n\t\t\t`\\tconst errorString = String(error);`,\n\t\t\t`\\tconst fullMessage = errorMessage + ' ' + errorString;`,\n\t\t\t`\\tconst hydrationKeywords = ['hydration', 'Hydration', 'mismatch', 'Mismatch', 'did not match', 'server rendered HTML', 'server HTML', 'client HTML', 'Hydration failed'];`,\n\t\t\t`\\tconst isHydration = hydrationKeywords.some(keyword => fullMessage.includes(keyword));`,\n\t\t\t`\\t`,\n\t\t\t`\\t// Ignore whitespace-only mismatches in <head> - these are harmless formatting differences`,\n\t\t\t`\\t// The error often shows: + <link...> vs - {\"\\\\n \"} which is just formatting`,\n\t\t\t`\\tif (isHydration) {`,\n\t\t\t`\\t\\t// Check if this is a head/link/stylesheet related mismatch`,\n\t\t\t`\\t\\tconst isHeadRelated = fullMessage.includes('<head') || fullMessage.includes('</head>') || fullMessage.includes('head>') || fullMessage.includes('<link') || fullMessage.includes('link>') || fullMessage.includes('stylesheet') || fullMessage.includes('fonts.googleapis') || fullMessage.includes('rel=\"stylesheet\"');`,\n\t\t\t`\\t\\t`,\n\t\t\t`\\t\\t// Check if the mismatch involves only whitespace/newlines`,\n\t\t\t`\\t\\t// Pattern: looks for {\"\\\\n\"} or {\"\\\\n \"} or similar whitespace-only content`,\n\t\t\t`\\t\\t// Also check for patterns like: - {\"\\\\n \"} or + <link...>`,\n\t\t\t`\\t\\tconst hasWhitespacePattern = /\\\\{\\\\s*[\"']\\\\\\\\n[^\"']*[\"']\\\\s*\\\\}/.test(fullMessage) || /\\\\{\\\\s*[\"'][\\\\\\\\n\\\\\\\\r\\\\\\\\s]+[\"']\\\\s*\\\\}/.test(fullMessage) || /-\\\\s*\\\\{\\\\s*[\"'][\\\\\\\\n\\\\\\\\r\\\\\\\\s]+[\"']\\\\s*\\\\}/.test(fullMessage);`,\n\t\t\t`\\t\\tconst isWhitespaceOnly = /^[\\\\s\\\\n\\\\r]*$/.test(errorString) || /^[\\\\s\\\\n\\\\r]*$/.test(errorMessage);`,\n\t\t\t`\\t\\tconst hasNewlinePattern = fullMessage.includes('\\\\\\\\n') || fullMessage.includes('\\\\\\\\r') || fullMessage.includes('\\\\n') || fullMessage.includes('\\\\r');`,\n\t\t\t`\\t\\t`,\n\t\t\t`\\t\\t// If it's head-related and involves whitespace/newlines, ignore it`,\n\t\t\t`\\t\\tif (isHeadRelated && (hasWhitespacePattern || isWhitespaceOnly || hasNewlinePattern)) {`,\n\t\t\t`\\t\\t\\treturn false; // Don't treat whitespace-only head mismatches as errors`,\n\t\t\t`\\t\\t}`,\n\t\t\t`\\t}`,\n\t\t\t`\\treturn isHydration;`,\n\t\t\t`}\\n`,\n\t\t\t`function logHydrationError(error, componentName) {`,\n\t\t\t`\\tif (!isDev) return;`,\n\t\t\t`\\tif (window.__HMR_WS__ && window.__HMR_WS__.readyState === WebSocket.OPEN) {`,\n\t\t\t`\\t\\ttry {`,\n\t\t\t`\\t\\t\\twindow.__HMR_WS__.send(JSON.stringify({`,\n\t\t\t`\\t\\t\\t\\ttype: 'hydration-error',`,\n\t\t\t`\\t\\t\\t\\tdata: {`,\n\t\t\t`\\t\\t\\t\\t\\tcomponentName: '${componentName}',`,\n\t\t\t`\\t\\t\\t\\t\\tcomponentPath: componentPath,`,\n\t\t\t`\\t\\t\\t\\t\\terror: error instanceof Error ? error.message : String(error),`,\n\t\t\t`\\t\\t\\t\\t\\ttimestamp: Date.now()`,\n\t\t\t`\\t\\t\\t\\t}`,\n\t\t\t`\\t\\t\\t}));`,\n\t\t\t`\\t\\t} catch (err) {}`,\n\t\t\t`\\t}`,\n\t\t\t`}\\n`,\n\t\t\t`// Track if we've already switched to client-only mode`,\n\t\t\t`let hasSwitchedToClientOnly = false;`,\n\t\t\t`let hydrationErrorDetected = false;\\n`,\n\t\t\t`function handleHydrationFallback(error) {`,\n\t\t\t`\\tif (hasSwitchedToClientOnly) return; // Already handled`,\n\t\t\t`\\thasSwitchedToClientOnly = true;`,\n\t\t\t`\\thydrationErrorDetected = true;\\n`,\n\t\t\t`\\tlogHydrationError(error, '${componentName}');\\n`,\n\t\t\t`\\t// Fallback: client-only render (no hydration)`,\n\t\t\t`\\ttry {`,\n\t\t\t`\\t\\t// Unmount existing root if it exists`,\n\t\t\t`\\t\\tif (window.__REACT_ROOT__ && typeof window.__REACT_ROOT__.unmount === 'function') {`,\n\t\t\t`\\t\\t\\ttry {`,\n\t\t\t`\\t\\t\\twindow.__REACT_ROOT__.unmount();`,\n\t\t\t`\\t\\t\\t} catch (e) {`,\n\t\t\t`\\t\\t\\t\\t// Ignore unmount errors`,\n\t\t\t`\\t\\t\\t}`,\n\t\t\t`\\t\\t}\\n`,\n\t\t\t`\\t\\t// Render into the same root container when falling back to client-only`,\n\t\t\t`\\t\\tconst root = createRoot(container);`,\n\t\t\t`\\t\\troot.render(${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`});`,\n\t\t\t`\\t\\twindow.__REACT_ROOT__ = root;`,\n\t\t\t`\\t\\twindow.__HMR_CLIENT_ONLY_MODE__ = true;`,\n\t\t\t`\\t} catch (fallbackError) {`,\n\t\t\t`\\t\\twindow.location.reload();`,\n\t\t\t`\\t}`,\n\t\t\t`}\\n`,\n\t\t\t`// HMR State Preservation: Check for preserved state and merge with initial props`,\n\t\t\t`// This allows state to be preserved across HMR updates without modifying component files`,\n\t\t\t`let preservedState = (typeof window !== 'undefined' && window.__HMR_PRESERVED_STATE__) ? window.__HMR_PRESERVED_STATE__ : {};\\n`,\n\t\t\t`// Also check sessionStorage for state that survived a page reload (for React HMR)`,\n\t\t\t`if (typeof window !== 'undefined' && typeof sessionStorage !== 'undefined') {`,\n\t\t\t`\\tconst hmrStateJson = sessionStorage.getItem('__REACT_HMR_STATE__');`,\n\t\t\t`\\tif (hmrStateJson) {`,\n\t\t\t`\\t\\ttry {`,\n\t\t\t`\\t\\t\\tconst hmrState = JSON.parse(hmrStateJson);`,\n\t\t\t`\\t\\t\\tpreservedState = { ...preservedState, ...hmrState };`,\n\t\t\t`\\t\\t\\tsessionStorage.removeItem('__REACT_HMR_STATE__');`,\n\t\t\t`\\t\\t} catch (e) {}`,\n\t\t\t`\\t}`,\n\t\t\t`}\\n`,\n\t\t\t`const mergedProps = { ...(window.__INITIAL_PROPS__ || {}), ...preservedState };`,\n\t\t\t`// Clear preserved state after using it (so it doesn't persist across multiple updates)`,\n\t\t\t`if (typeof window !== 'undefined') {`,\n\t\t\t`\\twindow.__HMR_PRESERVED_STATE__ = undefined;`,\n\t\t\t`}\\n`,\n\t\t\t`// Attempt hydration with error handling`,\n\t\t\t`// Use document (not document.body) when the page renders <html><head><body>`,\n\t\t\t`// to avoid \"In HTML, <html> cannot be a child of <body>\" hydration error`,\n\t\t\t`const container = typeof document !== 'undefined' ? document : null;`,\n\t\t\t`if (!container) {`,\n\t\t\t`\\tthrow new Error('React root container not found: document is null');`,\n\t\t\t`}\\n`,\n\t\t\t`// Guard: only hydrate on first load. During HMR re-imports, skip hydration`,\n\t\t\t`// so React Fast Refresh can swap components in-place and preserve state.`,\n\t\t\t`if (!window.__REACT_ROOT__) {`,\n\t\t\t`\\tlet root;`,\n\t\t\t`\\t// After HMR, SSR is skipped to avoid stale content flash — render client-only`,\n\t\t\t`\\tif (window.__SSR_DIRTY__) {`,\n\t\t\t`\\t\\troot = createRoot(container);`,\n\t\t\t`\\t\\troot.render(${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`});`,\n\t\t\t`\\t\\twindow.__REACT_ROOT__ = root;`,\n\t\t\t`\\t} else {`,\n\t\t\t`\\ttry {`,\n\t\t\t`\\t\\t// Use onRecoverableError to catch hydration errors (React 19)`,\n\t\t\t`\\t\\troot = hydrateRoot(`,\n\t\t\t`\\t\\t\\tcontainer,`,\n\t\t\t`\\t\\t\\t${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`},`,\n\t\t\t`\\t\\t\\t{`,\n\t\t\t`\\t\\t\\t\\tonRecoverableError: (error) => {`,\n\t\t\t`\\t\\t\\t\\t\\t// Check if this is a hydration error (isHydrationError filters out whitespace-only head mismatches)`,\n\t\t\t`\\t\\t\\t\\t\\tif (isDev && isHydrationError(error)) {`,\n\t\t\t`\\t\\t\\t\\t\\t\\t// Real hydration error - handle it`,\n\t\t\t`\\t\\t\\t\\t\\t\\thandleHydrationFallback(error);`,\n\t\t\t`\\t\\t\\t\\t\\t} else {`,\n\t\t\t`\\t\\t\\t\\t\\t\\t// Not a hydration error, or it's a whitespace-only mismatch that was filtered out`,\n\t\t\t`\\t\\t\\t\\t\\t\\t// Check if it's a whitespace-only head mismatch using the same logic as isHydrationError`,\n\t\t\t`\\t\\t\\t\\t\\t\\tconst errorMessage = error instanceof Error ? error.message : String(error);`,\n\t\t\t`\\t\\t\\t\\t\\t\\tconst errorString = String(error);`,\n\t\t\t`\\t\\t\\t\\t\\t\\tconst fullMessage = errorMessage + ' ' + errorString;`,\n\t\t\t`\\t\\t\\t\\t\\t\\tconst hydrationKeywords = ['hydration', 'Hydration', 'mismatch', 'Mismatch', 'did not match', 'server rendered HTML', 'server HTML', 'client HTML', 'Hydration failed'];`,\n\t\t\t`\\t\\t\\t\\t\\t\\tconst isHydration = hydrationKeywords.some(keyword => fullMessage.includes(keyword));`,\n\t\t\t`\\t\\t\\t\\t\\t\\tif (isHydration) {`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\t// Check if this is a head/link/stylesheet related mismatch`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\tconst isHeadRelated = fullMessage.includes('<head') || fullMessage.includes('</head>') || fullMessage.includes('head>') || fullMessage.includes('<link') || fullMessage.includes('link>') || fullMessage.includes('stylesheet') || fullMessage.includes('fonts.googleapis') || fullMessage.includes('rel=\"stylesheet\"');`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\t// Check if the mismatch involves only whitespace/newlines`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\tconst hasWhitespacePattern = /\\\\{\\\\s*[\"']\\\\\\\\n[^\"']*[\"']\\\\s*\\\\}/.test(fullMessage) || /\\\\{\\\\s*[\"'][\\\\\\\\n\\\\\\\\r\\\\\\\\s]+[\"']\\\\s*\\\\}/.test(fullMessage) || /-\\\\s*\\\\{\\\\s*[\"'][\\\\\\\\n\\\\\\\\r\\\\\\\\s]+[\"']\\\\s*\\\\}/.test(fullMessage);`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\tconst isWhitespaceOnly = /^[\\\\s\\\\n\\\\r]*$/.test(errorString) || /^[\\\\s\\\\n\\\\r]*$/.test(errorMessage);`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\tconst hasNewlinePattern = fullMessage.includes('\\\\\\\\n') || fullMessage.includes('\\\\\\\\r') || fullMessage.includes('\\\\n') || fullMessage.includes('\\\\r');`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\t// If it's head-related and involves whitespace/newlines, silently ignore it`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\tif (isHeadRelated && (hasWhitespacePattern || isWhitespaceOnly || hasNewlinePattern)) {`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\t\\t// Already logged by isHydrationError, just return silently`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\t\\treturn;`,\n\t\t\t`\\t\\t\\t\\t\\t\\t\\t}`,\n\t\t\t`\\t\\t\\t\\t\\t\\t}`,\n\t\t\t`\\t\\t\\t\\t\\t\\t// Log other recoverable errors`,\n\t\t\t`\\t\\t\\t\\t\\t\\tconsole.error('React recoverable error:', error);`,\n\t\t\t`\\t\\t\\t\\t\\t}`,\n\t\t\t`\\t\\t\\t\\t}`,\n\t\t\t`\\t\\t\\t}`,\n\t\t\t`\\t\\t);`,\n\t\t\t`\\t\\twindow.__REACT_ROOT__ = root;`,\n\t\t\t`\\t} catch (error) {`,\n\t\t\t`\\t\\t// Catch synchronous errors (shouldn't happen with hydrateRoot, but safety net)`,\n\t\t\t`\\t\\tif (isDev && isHydrationError(error)) {`,\n\t\t\t`\\t\\t\\thandleHydrationFallback(error);`,\n\t\t\t`\\t\\t} else {`,\n\t\t\t`\\t\\t\\tthrow error;`,\n\t\t\t`\\t\\t}`,\n\t\t\t`\\t}`,\n\t\t\t`\\t} // end else (normal hydration path)\\n`,\n\t\t\t`\\t// Also listen for hydration errors via console.error (React logs them there)`,\n\t\t\t`\\tif (isDev) {`,\n\t\t\t`\\t\\tconst originalError = console.error;`,\n\t\t\t`\\t\\tconsole.error = function(...args) {`,\n\t\t\t`\\t\\t\\tconst errorMessage = args.map(arg => {`,\n\t\t\t`\\t\\t\\t\\tif (arg instanceof Error) return arg.message;`,\n\t\t\t`\\t\\t\\t\\treturn String(arg);`,\n\t\t\t`\\t\\t\\t}).join(' ');`,\n\t\t\t`\\t\\t\\t`,\n\t\t\t`\\t\\t\\t// Check if this is a hydration error`,\n\t\t\t`\\t\\t\\tif (isHydrationError({ message: errorMessage }) && !hydrationErrorDetected) {`,\n\t\t\t`\\t\\t\\t\\thydrationErrorDetected = true;`,\n\t\t\t`\\t\\t\\t\\t// Create a synthetic error for fallback`,\n\t\t\t`\\t\\t\\t\\tconst syntheticError = new Error(errorMessage);`,\n\t\t\t`\\t\\t\\t\\t// Use setTimeout to ensure this happens after React's error handling`,\n\t\t\t`\\t\\t\\t\\tsetTimeout(() => {`,\n\t\t\t`\\t\\t\\t\\t\\thandleHydrationFallback(syntheticError);`,\n\t\t\t`\\t\\t\\t\\t}, 0);`,\n\t\t\t`\\t\\t\\t}`,\n\t\t\t`\\t\\t\\t`,\n\t\t\t`\\t\\t\\t// Call original console.error`,\n\t\t\t`\\t\\t\\toriginalError.apply(console, args);`,\n\t\t\t`\\t\\t};`,\n\t\t\t`\\t}`,\n\t\t\t`}`,\n\t\t\t...(isDev\n\t\t\t\t? [\n\t\t\t\t\t\t`\\n// Pre-warm: import the page module from the module server`,\n\t\t\t\t\t\t`// immediately so the browser caches all /@src/ URLs.`,\n\t\t\t\t\t\t`import('/@src/${relative(process.cwd(), resolve(reactPagesDirectory, `${componentName}.tsx`)).replace(/\\\\/g, '/')}').catch(() => {});`\n\t\t\t\t\t]\n\t\t\t\t: [])\n\t\t].join('\\n');\n\n\t\tconst indexPath = join(reactIndexesDirectory, `${componentName}.tsx`);\n\t\tconst hasher = new Bun.CryptoHasher('md5');\n\t\thasher.update(content);\n\t\tconst contentHash = hasher.digest('hex');\n\n\t\tif (\n\t\t\tindexContentCache.get(indexPath) === contentHash &&\n\t\t\texistsSync(indexPath)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tindexContentCache.set(indexPath, contentHash);\n\t\tawait writeFile(indexPath, content);\n\t});\n\tawait Promise.all(promises);\n\n\t// Generate a dummy entry that imports React so code splitting extracts\n\t// React into a shared chunk. This lets HMR re-import component entries\n\t// without creating a duplicate React instance.\n\t// IMPORTANT: reactRefreshSetup MUST be imported BEFORE react so that\n\t// injectIntoGlobalHook patches window.__REACT_DEVTOOLS_GLOBAL_HOOK__\n\t// before React initializes and checks it. Without this, the Refresh\n\t// Runtime can't reach React's reconciler and performReactRefresh()\n\t// silently does nothing.\n\tif (!isDev) {\n\t\treturn;\n\t}\n\n\tconst refreshPath = join(reactIndexesDirectory, '_refresh.tsx');\n\n\tif (!existsSync(refreshPath)) {\n\t\tawait writeFile(\n\t\t\trefreshPath,\n\t\t\t`import '${refreshS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2
|
-
// src/core/islandManifest.ts
|
|
3
|
-
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1);
|
|
4
|
-
var collectFrameworkIslands = (manifest, prefix) => {
|
|
5
|
-
const entries = {};
|
|
6
|
-
let found = false;
|
|
7
|
-
for (const [key, value] of Object.entries(manifest)) {
|
|
8
|
-
if (!key.startsWith(prefix))
|
|
9
|
-
continue;
|
|
10
|
-
const component = key.slice(prefix.length);
|
|
11
|
-
if (!component)
|
|
12
|
-
continue;
|
|
13
|
-
entries[component] = value;
|
|
14
|
-
found = true;
|
|
15
|
-
}
|
|
16
|
-
return found ? entries : undefined;
|
|
17
|
-
};
|
|
18
|
-
var getIslandManifestEntries = (manifest) => {
|
|
19
|
-
const islands = {};
|
|
20
|
-
const frameworks = ["react", "svelte", "vue", "angular"];
|
|
21
|
-
for (const framework of frameworks) {
|
|
22
|
-
const prefix = `Island${toIslandFrameworkSegment(framework)}`;
|
|
23
|
-
const entries = collectFrameworkIslands(manifest, prefix);
|
|
24
|
-
if (entries)
|
|
25
|
-
islands[framework] = entries;
|
|
26
|
-
}
|
|
27
|
-
return islands;
|
|
28
|
-
};
|
|
29
|
-
var getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
30
|
-
|
|
31
|
-
export { getIslandManifestEntries, getIslandManifestKey };
|
|
32
|
-
|
|
33
|
-
//# debugId=A4777F528EEB5C9A64756E2164756E21
|
|
34
|
-
//# sourceMappingURL=chunk-3yjzpcne.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/core/islandManifest.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { IslandFramework } from '../../types/island';\n\nconst toIslandFrameworkSegment = (framework: IslandFramework) =>\n\tframework[0]?.toUpperCase() + framework.slice(1);\n\nconst collectFrameworkIslands = (\n\tmanifest: Record<string, string>,\n\tprefix: string\n) => {\n\tconst entries: Record<string, string> = {};\n\tlet found = false;\n\n\tfor (const [key, value] of Object.entries(manifest)) {\n\t\tif (!key.startsWith(prefix)) continue;\n\n\t\tconst component = key.slice(prefix.length);\n\t\tif (!component) continue;\n\n\t\tentries[component] = value;\n\t\tfound = true;\n\t}\n\n\treturn found ? entries : undefined;\n};\n\nexport const getIslandManifestEntries = (manifest: Record<string, string>) => {\n\tconst islands: Partial<Record<IslandFramework, Record<string, string>>> =\n\t\t{};\n\tconst frameworks: IslandFramework[] = ['react', 'svelte', 'vue', 'angular'];\n\n\tfor (const framework of frameworks) {\n\t\tconst prefix = `Island${toIslandFrameworkSegment(framework)}`;\n\t\tconst entries = collectFrameworkIslands(manifest, prefix);\n\t\tif (entries) islands[framework] = entries;\n\t}\n\n\treturn islands;\n};\nexport const getIslandManifestKey = (\n\tframework: IslandFramework,\n\tcomponent: string\n) => `Island${toIslandFrameworkSegment(framework)}${component}`;\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;AAEA,IAAM,2BAA2B,CAAC,cACjC,UAAU,IAAI,YAAY,IAAI,UAAU,MAAM,CAAC;AAEhD,IAAM,0BAA0B,CAC/B,UACA,WACI;AAAA,EACJ,MAAM,UAAkC,CAAC;AAAA,EACzC,IAAI,QAAQ;AAAA,EAEZ,YAAY,KAAK,UAAU,OAAO,QAAQ,QAAQ,GAAG;AAAA,IACpD,IAAI,CAAC,IAAI,WAAW,MAAM;AAAA,MAAG;AAAA,IAE7B,MAAM,YAAY,IAAI,MAAM,OAAO,MAAM;AAAA,IACzC,IAAI,CAAC;AAAA,MAAW;AAAA,IAEhB,QAAQ,aAAa;AAAA,IACrB,QAAQ;AAAA,EACT;AAAA,EAEA,OAAO,QAAQ,UAAU;AAAA;AAGnB,IAAM,2BAA2B,CAAC,aAAqC;AAAA,EAC7E,MAAM,UACL,CAAC;AAAA,EACF,MAAM,aAAgC,CAAC,SAAS,UAAU,OAAO,SAAS;AAAA,EAE1E,WAAW,aAAa,YAAY;AAAA,IACnC,MAAM,SAAS,SAAS,yBAAyB,SAAS;AAAA,IAC1D,MAAM,UAAU,wBAAwB,UAAU,MAAM;AAAA,IACxD,IAAI;AAAA,MAAS,QAAQ,aAAa;AAAA,EACnC;AAAA,EAEA,OAAO;AAAA;AAED,IAAM,uBAAuB,CACnC,WACA,cACI,SAAS,yBAAyB,SAAS,IAAI;",
|
|
8
|
-
"debugId": "A4777F528EEB5C9A64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
package/dist/chunk-41bf6aqt.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
generateManifest
|
|
4
|
-
} from "./chunk-mtxzyxpg.js";
|
|
5
|
-
import"./chunk-hyjs4bqs.js";
|
|
6
|
-
import"./chunk-cbkrwmvh.js";
|
|
7
|
-
import"./chunk-gf0ygptk.js";
|
|
8
|
-
import"./chunk-p5504p14.js";
|
|
9
|
-
import"./chunk-qh75agse.js";
|
|
10
|
-
import"./chunk-3yjzpcne.js";
|
|
11
|
-
import"./chunk-bmgqm774.js";
|
|
12
|
-
export {
|
|
13
|
-
generateManifest
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//# debugId=C379B9CF434B0B1A64756E2164756E21
|
|
17
|
-
//# sourceMappingURL=chunk-41bf6aqt.js.map
|
package/dist/chunk-4d39r92n.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
scanEntryPoints
|
|
4
|
-
} from "./chunk-11zpfqz6.js";
|
|
5
|
-
import {
|
|
6
|
-
DEFAULT_QUALITY,
|
|
7
|
-
OPTIMIZATION_ENDPOINT,
|
|
8
|
-
buildOptimizedUrl,
|
|
9
|
-
getAllSizes
|
|
10
|
-
} from "./chunk-kk8w9rh5.js";
|
|
11
|
-
import {
|
|
12
|
-
IMAGE_DEFAULT_DEVICE_SIZES
|
|
13
|
-
} from "./chunk-qh75agse.js";
|
|
14
|
-
|
|
15
|
-
// src/build/optimizeHtmlImages.ts
|
|
16
|
-
import { readFile, writeFile } from "fs/promises";
|
|
17
|
-
var IMG_REGEX = /<img\s+([^>]*?)data-optimized([^>]*?)\/?>/gi;
|
|
18
|
-
var getAttr = (attrs, name) => {
|
|
19
|
-
const regex = new RegExp(`${name}\\s*=\\s*["']([^"']*)["']`, "i");
|
|
20
|
-
const match = regex.exec(attrs);
|
|
21
|
-
return match ? match[1] : undefined;
|
|
22
|
-
};
|
|
23
|
-
var removeAttr = (attrs, name) => attrs.replace(new RegExp(`\\s*${name}\\s*=\\s*["'][^"']*["']`, "gi"), "");
|
|
24
|
-
var transformImgTag = (fullMatch, before, after, config) => {
|
|
25
|
-
const attrs = before + after;
|
|
26
|
-
const src = getAttr(attrs, "src");
|
|
27
|
-
if (!src)
|
|
28
|
-
return fullMatch;
|
|
29
|
-
const widthStr = getAttr(attrs, "width");
|
|
30
|
-
const sizes = getAttr(attrs, "sizes");
|
|
31
|
-
const quality = config?.quality ?? DEFAULT_QUALITY;
|
|
32
|
-
const basePath = config?.path ?? OPTIMIZATION_ENDPOINT;
|
|
33
|
-
const width = widthStr ? parseInt(widthStr, 10) : undefined;
|
|
34
|
-
const optimizedSrc = buildOptimizedUrl(src, width ?? 0, quality, basePath);
|
|
35
|
-
let srcset;
|
|
36
|
-
if (sizes) {
|
|
37
|
-
const allSizes = getAllSizes(config);
|
|
38
|
-
srcset = allSizes.map((sizeWidth) => `${buildOptimizedUrl(src, sizeWidth, quality, basePath)} ${sizeWidth}w`).join(", ");
|
|
39
|
-
} else if (width) {
|
|
40
|
-
const allSizes = getAllSizes(config);
|
|
41
|
-
const w1x = snapUp(width, allSizes);
|
|
42
|
-
const w2x = snapUp(width * 2, allSizes);
|
|
43
|
-
srcset = `${buildOptimizedUrl(src, w1x, quality, basePath)} 1x, ${buildOptimizedUrl(src, w2x, quality, basePath)} 2x`;
|
|
44
|
-
} else {
|
|
45
|
-
const deviceSizes = config?.deviceSizes ?? IMAGE_DEFAULT_DEVICE_SIZES;
|
|
46
|
-
srcset = deviceSizes.map((sizeWidth) => `${buildOptimizedUrl(src, sizeWidth, quality, basePath)} ${sizeWidth}w`).join(", ");
|
|
47
|
-
}
|
|
48
|
-
let cleanAttrs = removeAttr(attrs, "data-optimized");
|
|
49
|
-
cleanAttrs = removeAttr(cleanAttrs, "src");
|
|
50
|
-
cleanAttrs = removeAttr(cleanAttrs, "loading");
|
|
51
|
-
cleanAttrs = removeAttr(cleanAttrs, "decoding");
|
|
52
|
-
cleanAttrs = cleanAttrs.trim();
|
|
53
|
-
const resolvedSizes = sizes ?? (width ? undefined : "100vw");
|
|
54
|
-
const sizesAttr = resolvedSizes ? ` sizes="${resolvedSizes}"` : "";
|
|
55
|
-
return `<img src="${optimizedSrc}" srcset="${srcset}"${sizesAttr} ${cleanAttrs} loading="lazy" decoding="async">`;
|
|
56
|
-
};
|
|
57
|
-
var snapUp = (target, sizes) => {
|
|
58
|
-
for (const size of sizes) {
|
|
59
|
-
if (size >= target)
|
|
60
|
-
return size;
|
|
61
|
-
}
|
|
62
|
-
return sizes[sizes.length - 1] ?? target;
|
|
63
|
-
};
|
|
64
|
-
var optimizeHtmlImages = async (directory, config) => {
|
|
65
|
-
const htmlFiles = await scanEntryPoints(directory, "*.html");
|
|
66
|
-
const tasks = htmlFiles.map(async (filePath) => {
|
|
67
|
-
const original = await readFile(filePath, "utf8");
|
|
68
|
-
if (!original.includes("data-optimized"))
|
|
69
|
-
return;
|
|
70
|
-
const updated = original.replace(IMG_REGEX, (match, before, after) => transformImgTag(match, before, after, config));
|
|
71
|
-
if (updated !== original) {
|
|
72
|
-
await writeFile(filePath, updated, "utf8");
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
await Promise.all(tasks);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export { optimizeHtmlImages };
|
|
79
|
-
|
|
80
|
-
//# debugId=C7780E76D47EF80B64756E2164756E21
|
|
81
|
-
//# sourceMappingURL=chunk-4d39r92n.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/build/optimizeHtmlImages.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { readFile, writeFile } from 'node:fs/promises';\nimport {\n\tDEFAULT_QUALITY,\n\tOPTIMIZATION_ENDPOINT,\n\tbuildOptimizedUrl,\n\tgetAllSizes\n} from '../utils/imageProcessing';\nimport { scanEntryPoints } from './scanEntryPoints';\nimport type { ImageConfig } from '../../types/image';\nimport { IMAGE_DEFAULT_DEVICE_SIZES } from '../constants';\n\n/**\n * Build-time transform for HTML files: finds `<img data-optimized ...>` tags\n * and rewrites them to use the optimization endpoint with responsive srcset.\n *\n * Example input:\n * <img data-optimized src=\"/photos/hero.jpg\" width=\"1200\" height=\"800\"\n * sizes=\"(max-width: 768px) 100vw, 50vw\" alt=\"Hero\">\n *\n * Output:\n * <img src=\"/_absolute/image?url=...&w=1200&q=75\"\n * srcset=\"/_absolute/image?url=...&w=640&q=75 640w, ...\"\n * sizes=\"(max-width: 768px) 100vw, 50vw\"\n * width=\"1200\" height=\"800\" alt=\"Hero\"\n * loading=\"lazy\" decoding=\"async\">\n */\n\nconst IMG_REGEX = /<img\\s+([^>]*?)data-optimized([^>]*?)\\/?>/gi;\n\nconst getAttr = (attrs: string, name: string) => {\n\tconst regex = new RegExp(`${name}\\\\s*=\\\\s*[\"']([^\"']*)[\"']`, 'i');\n\n\tconst match = regex.exec(attrs);\n\n\treturn match ? match[1] : undefined;\n};\n\nconst removeAttr = (attrs: string, name: string) =>\n\tattrs.replace(new RegExp(`\\\\s*${name}\\\\s*=\\\\s*[\"'][^\"']*[\"']`, 'gi'), '');\n\nconst transformImgTag = (fullMatch: string, before: string, after: string, config?: ImageConfig) => {\n\tconst attrs = before + after;\n\n\tconst src = getAttr(attrs, 'src');\n\n\tif (!src) return fullMatch;\n\n\tconst widthStr = getAttr(attrs, 'width');\n\n\tconst sizes = getAttr(attrs, 'sizes');\n\n\tconst quality = config?.quality ?? DEFAULT_QUALITY;\n\n\tconst basePath = config?.path ?? OPTIMIZATION_ENDPOINT;\n\n\tconst width = widthStr ? parseInt(widthStr, 10) : undefined;\n\n\t// Build optimized src\n\tconst optimizedSrc = buildOptimizedUrl(src, width ?? 0, quality, basePath);\n\n\t// Build srcset\n\tlet srcset: string;\n\n\tif (sizes) {\n\t\tconst allSizes = getAllSizes(config);\n\n\t\tsrcset = allSizes\n\t\t\t.map((sizeWidth) => `${buildOptimizedUrl(src, sizeWidth, quality, basePath)} ${sizeWidth}w`)\n\t\t\t.join(', ');\n\t} else if (width) {\n\t\t// 1x and 2x density descriptors\n\t\tconst allSizes = getAllSizes(config);\n\n\t\tconst w1x = snapUp(width, allSizes);\n\n\t\tconst w2x = snapUp(width * 2, allSizes);\n\n\t\tsrcset = `${buildOptimizedUrl(src, w1x, quality, basePath)} 1x, ${buildOptimizedUrl(src, w2x, quality, basePath)} 2x`;\n\t} else {\n\t\tconst deviceSizes = config?.deviceSizes ?? IMAGE_DEFAULT_DEVICE_SIZES;\n\n\t\tsrcset = deviceSizes\n\t\t\t.map((sizeWidth) => `${buildOptimizedUrl(src, sizeWidth, quality, basePath)} ${sizeWidth}w`)\n\t\t\t.join(', ');\n\t}\n\n\t// Clean original attributes — remove data-optimized and src (we'll re-add them)\n\tlet cleanAttrs = removeAttr(attrs, 'data-optimized');\n\n\tcleanAttrs = removeAttr(cleanAttrs, 'src');\n\n\t// Remove loading/decoding if present (we'll set our own)\n\tcleanAttrs = removeAttr(cleanAttrs, 'loading');\n\n\tcleanAttrs = removeAttr(cleanAttrs, 'decoding');\n\n\tcleanAttrs = cleanAttrs.trim();\n\n\tconst resolvedSizes = sizes ?? (width ? undefined : '100vw');\n\n\tconst sizesAttr = resolvedSizes ? ` sizes=\"${resolvedSizes}\"` : '';\n\n\treturn `<img src=\"${optimizedSrc}\" srcset=\"${srcset}\"${sizesAttr} ${cleanAttrs} loading=\"lazy\" decoding=\"async\">`;\n};\n\nconst snapUp = (target: number, sizes: number[]) => {\n\tfor (const size of sizes) {\n\t\tif (size >= target) return size;\n\t}\n\n\treturn sizes[sizes.length - 1] ?? target;\n};\n\nexport const optimizeHtmlImages = async (\n\tdirectory: string,\n\tconfig?: ImageConfig\n) => {\n\tconst htmlFiles = await scanEntryPoints(directory, '*.html');\n\n\tconst tasks = htmlFiles.map(async (filePath) => {\n\t\tconst original = await readFile(filePath, 'utf8');\n\n\t\tif (!original.includes('data-optimized')) return;\n\n\t\tconst updated = original.replace(\n\t\t\tIMG_REGEX,\n\t\t\t(match, before, after) => transformImgTag(match, before, after, config)\n\t\t);\n\n\t\tif (updated !== original) {\n\t\t\tawait writeFile(filePath, updated, 'utf8');\n\t\t}\n\t});\n\n\tawait Promise.all(tasks);\n};\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AA2BA,IAAM,YAAY;AAElB,IAAM,UAAU,CAAC,OAAe,SAAiB;AAAA,EAChD,MAAM,QAAQ,IAAI,OAAO,GAAG,iCAAiC,GAAG;AAAA,EAEhE,MAAM,QAAQ,MAAM,KAAK,KAAK;AAAA,EAE9B,OAAO,QAAQ,MAAM,KAAK;AAAA;AAG3B,IAAM,aAAa,CAAC,OAAe,SAClC,MAAM,QAAQ,IAAI,OAAO,OAAO,+BAA+B,IAAI,GAAG,EAAE;AAEzE,IAAM,kBAAkB,CAAC,WAAmB,QAAgB,OAAe,WAAyB;AAAA,EACnG,MAAM,QAAQ,SAAS;AAAA,EAEvB,MAAM,MAAM,QAAQ,OAAO,KAAK;AAAA,EAEhC,IAAI,CAAC;AAAA,IAAK,OAAO;AAAA,EAEjB,MAAM,WAAW,QAAQ,OAAO,OAAO;AAAA,EAEvC,MAAM,QAAQ,QAAQ,OAAO,OAAO;AAAA,EAEpC,MAAM,UAAU,QAAQ,WAAW;AAAA,EAEnC,MAAM,WAAW,QAAQ,QAAQ;AAAA,EAEj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SAAS,MAAM;AAAA;AAG5B,IAAM,qBAAqB,OACjC,WACA,WACI;AAAA,EACJ,MAAM,YAAY,MAAM,gBAAgB,WAAW,QAAQ;AAAA,EAE3D,MAAM,QAAQ,UAAU,IAAI,OAAO,aAAa;AAAA,IAC/C,MAAM,WAAW,MAAM,SAAS,UAAU,MAAM;AAAA,IAEhD,IAAI,CAAC,SAAS,SAAS,gBAAgB;AAAA,MAAG;AAAA,IAE1C,MAAM,UAAU,SAAS,QACxB,WACA,CAAC,OAAO,QAAQ,UAAU,gBAAgB,OAAO,QAAQ,OAAO,MAAM,CACvE;AAAA,IAEA,IAAI,YAAY,UAAU;AAAA,MACzB,MAAM,UAAU,UAAU,SAAS,MAAM;AAAA,IAC1C;AAAA,GACA;AAAA,EAED,MAAM,QAAQ,IAAI,KAAK;AAAA;",
|
|
8
|
-
"debugId": "C7780E76D47EF80B64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
package/dist/chunk-5003emhv.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// src/core/currentIslandRegistry.ts
|
|
3
|
-
var requireCurrentIslandRegistry = () => {
|
|
4
|
-
const registry = globalThis.__absoluteIslandRegistry;
|
|
5
|
-
if (!registry) {
|
|
6
|
-
throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
|
|
7
|
-
}
|
|
8
|
-
return registry;
|
|
9
|
-
};
|
|
10
|
-
var setCurrentIslandRegistry = (registry) => {
|
|
11
|
-
globalThis.__absoluteIslandRegistry = registry;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { requireCurrentIslandRegistry, setCurrentIslandRegistry };
|
|
15
|
-
|
|
16
|
-
//# debugId=97E6069773F416CD64756E2164756E21
|
|
17
|
-
//# sourceMappingURL=chunk-5003emhv.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/core/currentIslandRegistry.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { IslandRegistryInput } from '../../types/island';\n\ndeclare global {\n\tvar __absoluteIslandRegistry: IslandRegistryInput | undefined;\n}\n\nexport const getCurrentIslandRegistry = () =>\n\tglobalThis.__absoluteIslandRegistry;\nexport const requireCurrentIslandRegistry = () => {\n\tconst registry = globalThis.__absoluteIslandRegistry;\n\tif (!registry) {\n\t\tthrow new Error(\n\t\t\t'No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.'\n\t\t);\n\t}\n\n\treturn registry;\n};\nexport const setCurrentIslandRegistry = (\n\tregistry: IslandRegistryInput | undefined\n) => {\n\tglobalThis.__absoluteIslandRegistry = registry;\n};\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;AAQO,IAAM,+BAA+B,MAAM;AAAA,EACjD,MAAM,WAAW,WAAW;AAAA,EAC5B,IAAI,CAAC,UAAU;AAAA,IACd,MAAM,IAAI,MACT,+GACD;AAAA,EACD;AAAA,EAEA,OAAO;AAAA;AAED,IAAM,2BAA2B,CACvC,aACI;AAAA,EACJ,WAAW,2BAA2B;AAAA;",
|
|
8
|
-
"debugId": "97E6069773F416CD64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|