@absolutejs/absolute 0.20.0-beta.177 → 0.20.0-beta.179
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/CHANGELOG.md +37 -0
- package/changelog.json +72 -0
- package/dist/angular/browser.js +17 -2
- package/dist/angular/browser.js.map +4 -4
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +100 -54
- package/dist/angular/index.js.map +10 -9
- package/dist/angular/server.js +100 -54
- package/dist/angular/server.js.map +10 -9
- package/dist/build/buildWorker.js +6 -5
- package/dist/build.js +595 -454
- package/dist/build.js.map +20 -20
- package/dist/cli/{add-ntg96znk.js → add-8gw9mk2b.js} +1 -1
- package/dist/cli/{compile-w2z6c9vt.js → compile-p5yv6ecp.js} +2 -2
- package/dist/cli/config/server.js +45 -12
- package/dist/cli/{dev-8br5mr7t.js → dev-2hbcsvkp.js} +1 -1
- package/dist/cli/{index-420h9hq7.js → index-1ewba8ye.js} +32 -3
- package/dist/cli/index-5q6k5mvr.js +86 -0
- package/dist/cli/{index-7z1hh3fg.js → index-9dzdbbfc.js} +1 -1
- package/dist/cli/index.js +9 -9
- package/dist/cli/{islands-bx67g15t.js → islands-6zgb7501.js} +1 -1
- package/dist/cli/{mobile-we5q51ey.js → mobile-93vaawcz.js} +3 -3
- package/dist/cli/{remove-4jh862qa.js → remove-x987pvd3.js} +1 -1
- package/dist/cli/{start-srs11bm8.js → start-asxb79rc.js} +2 -2
- package/dist/cli/{typecheck-7fvww3b7.js → typecheck-m2j4tkdk.js} +165 -35
- package/dist/client/chunks/{index-8m2qq61n.js → index-58svs66p.js} +13 -3
- package/dist/client/chunks/{index-8m2qq61n.js.map → index-58svs66p.js.map} +5 -4
- package/dist/client/chunks/{islands-mfjmdwnb.js → islands-tcadmgcx.js} +3 -6
- package/dist/client/chunks/{islands-mfjmdwnb.js.map → islands-tcadmgcx.js.map} +3 -4
- package/dist/client/chunks/{react-sprprqzs.js → react-khr6ewhr.js} +2 -2
- package/dist/client/index.js +82 -6
- package/dist/client/index.js.map +7 -6
- package/dist/dev/client/handlers/islands.ts +2 -0
- package/dist/dev/client/handlers/react.ts +92 -111
- package/dist/dev/client/handlers/reactUpdateQueue.ts +153 -0
- package/dist/index.js +568 -427
- package/dist/index.js.map +20 -20
- package/dist/islands/browser.js +2 -2
- package/dist/islands/browser.js.map +3 -3
- package/dist/islands/index.js +56 -27
- package/dist/islands/index.js.map +7 -6
- package/dist/react/browser.js +113 -12
- package/dist/react/browser.js.map +10 -7
- package/dist/react/components/index.js +31 -7
- package/dist/react/components/index.js.map +5 -4
- package/dist/react/components/server/index.js +22 -6
- package/dist/react/index.js +233 -67
- package/dist/react/index.js.map +16 -12
- package/dist/react/server.js +82 -23
- package/dist/react/server.js.map +11 -9
- package/dist/src/build/compileSvelte.d.ts +12 -1
- package/dist/src/build/compileVue.d.ts +1 -0
- package/dist/src/build/islandEntries.d.ts +3 -1
- package/dist/src/cli/add/dependencies.d.ts +34 -6
- package/dist/src/cli/scripts/typecheck.d.ts +8 -0
- package/dist/src/cli/scripts/typecheckDiagnostics.d.ts +17 -0
- package/dist/src/client/preserveIslandMarkup.d.ts +4 -0
- package/dist/src/core/islandManifest.d.ts +6 -0
- package/dist/src/core/islandStylesheet.d.ts +17 -0
- package/dist/src/react/Island.d.ts +9 -2
- package/dist/src/react/IslandStyleLink.d.ts +11 -0
- package/dist/src/react/createIsland.d.ts +1 -1
- package/dist/src/react/serverComponents/nodeRendererRef.d.ts +13 -0
- package/dist/src/utils/requestRenderUrl.d.ts +1 -0
- package/dist/src/utils/resolveConvention.d.ts +1 -0
- package/dist/src/vue/Island.browser.d.ts +3 -1
- package/dist/src/vue/Island.d.ts +2 -2
- package/dist/src/vue/createIsland.browser.d.ts +2 -2
- package/dist/src/vue/createIsland.d.ts +2 -2
- package/dist/src/vue/islandStyleLink.d.ts +30 -0
- package/dist/svelte/browser.js +2 -2
- package/dist/svelte/browser.js.map +3 -3
- package/dist/svelte/index.js +94 -70
- package/dist/svelte/index.js.map +10 -9
- package/dist/svelte/server.js +65 -59
- package/dist/svelte/server.js.map +9 -8
- package/dist/types/globals.d.ts +3 -0
- package/dist/vue/browser.js +105 -10
- package/dist/vue/browser.js.map +10 -7
- package/dist/vue/index.js +213 -68
- package/dist/vue/index.js.map +15 -12
- package/dist/vue/server.js +81 -22
- package/dist/vue/server.js.map +9 -7
- package/package.json +1 -1
- package/dist/cli/index-jjfbjv1z.js +0 -65
- /package/dist/cli/{index-6522t968.js → index-yd672jyq.js} +0 -0
- /package/dist/client/chunks/{react-sprprqzs.js.map → react-khr6ewhr.js.map} +0 -0
package/dist/react/browser.js
CHANGED
|
@@ -96,7 +96,7 @@ var ISLAND_BOOTSTRAP_MANIFEST_KEY = "AbsoluteIslandBootstrap", LEGACY_ISLAND_BOO
|
|
|
96
96
|
islands[framework] = entries;
|
|
97
97
|
}
|
|
98
98
|
return islands;
|
|
99
|
-
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
99
|
+
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`, ISLAND_STYLE_PREFIX = "IslandStyle", getIslandStyleManifestEntries = (manifest) => Object.entries(manifest).filter(([key]) => key.startsWith(ISLAND_STYLE_PREFIX)), getIslandStyleManifestKey = (framework, component) => `${ISLAND_STYLE_PREFIX}${toIslandFrameworkSegment(framework)}${component}`;
|
|
100
100
|
|
|
101
101
|
// src/core/islands.ts
|
|
102
102
|
function getIslandComponent(component) {
|
|
@@ -136,6 +136,20 @@ var init_islandMarkupAttributes = __esm(() => {
|
|
|
136
136
|
init_islands();
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
+
// src/utils/cspNonceRef.ts
|
|
140
|
+
var GETTER_KEY, nonceAttr = (nonce = readCspNonce()) => nonce ? ` nonce="${nonce}"` : "", nonceSvelteHeadStyles = (head, nonce = readCspNonce()) => nonce ? head.replace(/<style(?=\s+id="svelte-[^"]*")(?![^>]*\snonce=)/g, `<style nonce="${nonce}"`) : head, readCspNonce = () => {
|
|
141
|
+
const getter = Reflect.get(globalThis, GETTER_KEY);
|
|
142
|
+
if (typeof getter !== "function")
|
|
143
|
+
return;
|
|
144
|
+
const nonce = getter();
|
|
145
|
+
return typeof nonce === "string" ? nonce : undefined;
|
|
146
|
+
}, registerCspNonceGetter = (getter) => {
|
|
147
|
+
Reflect.set(globalThis, GETTER_KEY, getter);
|
|
148
|
+
};
|
|
149
|
+
var init_cspNonceRef = __esm(() => {
|
|
150
|
+
GETTER_KEY = Symbol.for("absolutejs.cspNonceGetter");
|
|
151
|
+
});
|
|
152
|
+
|
|
139
153
|
// src/client/preserveIslandMarkup.ts
|
|
140
154
|
init_islandMarkupAttributes();
|
|
141
155
|
var getSnapshotMap = () => {
|
|
@@ -188,6 +202,21 @@ var preserveIslandMarkup = (props) => {
|
|
|
188
202
|
innerHTML: liveCandidate.innerHTML
|
|
189
203
|
};
|
|
190
204
|
};
|
|
205
|
+
var claimedServerIslands = new WeakSet;
|
|
206
|
+
var claimServerIslandStyleLink = (props) => {
|
|
207
|
+
if (typeof document === "undefined")
|
|
208
|
+
return null;
|
|
209
|
+
const element = Array.from(document.querySelectorAll('[data-island="true"]')).find((candidate) => !claimedServerIslands.has(candidate) && isMatchingIslandElement(candidate, props));
|
|
210
|
+
if (!element)
|
|
211
|
+
return null;
|
|
212
|
+
claimedServerIslands.add(element);
|
|
213
|
+
const previous = element.previousSibling;
|
|
214
|
+
if (!(previous instanceof HTMLLinkElement))
|
|
215
|
+
return null;
|
|
216
|
+
const key = previous.dataset.islandStyle;
|
|
217
|
+
const href = previous.getAttribute("href");
|
|
218
|
+
return key && href ? { href, key } : null;
|
|
219
|
+
};
|
|
191
220
|
var innerHtmlObjects = new Map;
|
|
192
221
|
var getStableInnerHtml = (html) => {
|
|
193
222
|
const existing = innerHtmlObjects.get(html);
|
|
@@ -198,25 +227,97 @@ var getStableInnerHtml = (html) => {
|
|
|
198
227
|
return created;
|
|
199
228
|
};
|
|
200
229
|
|
|
230
|
+
// src/core/islandStylesheet.ts
|
|
231
|
+
init_cspNonceRef();
|
|
232
|
+
var INLINE_ISLAND_STYLES_CONTEXT_KEY = "__absoluteInlineIslandStyles";
|
|
233
|
+
var ISLAND_STYLE_PRECEDENCE = "absolute-islands";
|
|
234
|
+
var ISLAND_FRAMEWORKS = [
|
|
235
|
+
"react",
|
|
236
|
+
"svelte",
|
|
237
|
+
"vue",
|
|
238
|
+
"angular"
|
|
239
|
+
];
|
|
240
|
+
var toIslandFramework = (value) => ISLAND_FRAMEWORKS.find((framework) => framework === value);
|
|
241
|
+
var readIslandManifest = () => {
|
|
242
|
+
const manifest = typeof window === "undefined" ? Reflect.get(globalThis, "__absoluteManifest") : Reflect.get(window, "__ABSOLUTE_MANIFEST__");
|
|
243
|
+
return typeof manifest === "object" && manifest !== null ? manifest : undefined;
|
|
244
|
+
};
|
|
245
|
+
var findIslandStylesheet = (framework, component) => {
|
|
246
|
+
const islandFramework = toIslandFramework(framework);
|
|
247
|
+
const manifest = readIslandManifest();
|
|
248
|
+
if (!islandFramework || !manifest)
|
|
249
|
+
return;
|
|
250
|
+
const key = getIslandStyleManifestKey(islandFramework, component);
|
|
251
|
+
const href = Reflect.get(manifest, key);
|
|
252
|
+
return typeof href === "string" ? { href, key } : undefined;
|
|
253
|
+
};
|
|
254
|
+
var readIslandStyleNonce = () => {
|
|
255
|
+
if (typeof document === "undefined")
|
|
256
|
+
return readCspNonce() ?? "";
|
|
257
|
+
return Array.from(document.querySelectorAll("script[nonce]")).find((element) => element.nonce)?.nonce ?? "";
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// src/react/IslandStyleLink.tsx
|
|
261
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
262
|
+
var IslandStyleLink = ({
|
|
263
|
+
component,
|
|
264
|
+
framework
|
|
265
|
+
}) => {
|
|
266
|
+
const stylesheet = findIslandStylesheet(framework, component);
|
|
267
|
+
if (!stylesheet)
|
|
268
|
+
return null;
|
|
269
|
+
const nonce = readIslandStyleNonce();
|
|
270
|
+
return /* @__PURE__ */ jsx("link", {
|
|
271
|
+
"data-island-style": stylesheet.key,
|
|
272
|
+
href: stylesheet.href,
|
|
273
|
+
nonce: nonce || undefined,
|
|
274
|
+
precedence: ISLAND_STYLE_PRECEDENCE,
|
|
275
|
+
rel: "stylesheet"
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
var IslandWithStylesheet = ({
|
|
279
|
+
component,
|
|
280
|
+
framework,
|
|
281
|
+
marker
|
|
282
|
+
}) => /* @__PURE__ */ jsxs(Fragment, {
|
|
283
|
+
children: [
|
|
284
|
+
/* @__PURE__ */ jsx(IslandStyleLink, {
|
|
285
|
+
component,
|
|
286
|
+
framework
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ jsx("div", {
|
|
289
|
+
...marker
|
|
290
|
+
})
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
|
|
201
294
|
// src/react/Island.browser.tsx
|
|
202
|
-
import { jsx } from "react/jsx-runtime";
|
|
295
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
203
296
|
var Island = (props) => {
|
|
204
297
|
const { attributes, innerHTML } = preserveIslandMarkup(props);
|
|
205
|
-
return /* @__PURE__ */
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
298
|
+
return /* @__PURE__ */ jsx2(IslandWithStylesheet, {
|
|
299
|
+
component: props.component,
|
|
300
|
+
framework: props.framework,
|
|
301
|
+
marker: {
|
|
302
|
+
...attributes,
|
|
303
|
+
dangerouslySetInnerHTML: getStableInnerHtml(innerHTML),
|
|
304
|
+
suppressHydrationWarning: true
|
|
305
|
+
}
|
|
209
306
|
});
|
|
210
307
|
};
|
|
211
308
|
// src/react/createIsland.browser.tsx
|
|
212
|
-
import { jsx as
|
|
309
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
213
310
|
var createTypedIsland = (_registry) => {
|
|
214
311
|
const Island = (props) => {
|
|
215
312
|
const { attributes, innerHTML } = preserveIslandMarkup(props);
|
|
216
|
-
return /* @__PURE__ */
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
313
|
+
return /* @__PURE__ */ jsx3(IslandWithStylesheet, {
|
|
314
|
+
component: props.component,
|
|
315
|
+
framework: props.framework,
|
|
316
|
+
marker: {
|
|
317
|
+
...attributes,
|
|
318
|
+
dangerouslySetInnerHTML: getStableInnerHtml(innerHTML),
|
|
319
|
+
suppressHydrationWarning: true
|
|
320
|
+
}
|
|
220
321
|
});
|
|
221
322
|
};
|
|
222
323
|
return Island;
|
|
@@ -331,5 +432,5 @@ export {
|
|
|
331
432
|
useIslandStore
|
|
332
433
|
};
|
|
333
434
|
|
|
334
|
-
//# debugId=
|
|
435
|
+
//# debugId=C759A4F16D5FB34864756E2164756E21
|
|
335
436
|
//# sourceMappingURL=browser.js.map
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/islandManifest.ts", "../src/core/islands.ts", "../src/core/islandMarkupAttributes.ts", "../src/client/preserveIslandMarkup.ts", "../src/react/Island.browser.tsx", "../src/react/createIsland.browser.tsx", "../src/react/hooks/useIslandStore.ts", "../node_modules/zustand/esm/vanilla.mjs", "../node_modules/zustand/esm/middleware.mjs", "../src/client/islandStore.ts"],
|
|
3
|
+
"sources": ["../src/core/islandManifest.ts", "../src/core/islands.ts", "../src/core/islandMarkupAttributes.ts", "../src/utils/cspNonceRef.ts", "../src/client/preserveIslandMarkup.ts", "../src/core/islandStylesheet.ts", "../src/react/IslandStyleLink.tsx", "../src/react/Island.browser.tsx", "../src/react/createIsland.browser.tsx", "../src/react/hooks/useIslandStore.ts", "../node_modules/zustand/esm/vanilla.mjs", "../node_modules/zustand/esm/middleware.mjs", "../src/client/islandStore.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { IslandFramework } from '../../types/island';\n\n/** Manifest key the server injects as the islands bootstrap script on any\n * page with island markers. The build records the configured\n * `islands.bootstrap` (whatever its file name) or a generated default under\n * it — see build/islandBootstrap.ts. */\nexport const ISLAND_BOOTSTRAP_MANIFEST_KEY = 'AbsoluteIslandBootstrap';\n\n/** Key a bootstrap file named `bootstrapClient.*` gets naturally, which is\n * all the server used to look for. Still honored for manifests built\n * before the reserved key existed. */\nexport const LEGACY_ISLAND_BOOTSTRAP_MANIFEST_KEY = 'BootstrapClient';\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 getIslandBootstrapPath = (manifest: Record<string, string>) =>\n\tmanifest[ISLAND_BOOTSTRAP_MANIFEST_KEY] ??\n\tmanifest[LEGACY_ISLAND_BOOTSTRAP_MANIFEST_KEY];\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",
|
|
5
|
+
"import type { IslandFramework } from '../../types/island';\n\n/** Manifest key the server injects as the islands bootstrap script on any\n * page with island markers. The build records the configured\n * `islands.bootstrap` (whatever its file name) or a generated default under\n * it — see build/islandBootstrap.ts. */\nexport const ISLAND_BOOTSTRAP_MANIFEST_KEY = 'AbsoluteIslandBootstrap';\n\n/** Key a bootstrap file named `bootstrapClient.*` gets naturally, which is\n * all the server used to look for. Still honored for manifests built\n * before the reserved key existed. */\nexport const LEGACY_ISLAND_BOOTSTRAP_MANIFEST_KEY = 'BootstrapClient';\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 getIslandBootstrapPath = (manifest: Record<string, string>) =>\n\tmanifest[ISLAND_BOOTSTRAP_MANIFEST_KEY] ??\n\tmanifest[LEGACY_ISLAND_BOOTSTRAP_MANIFEST_KEY];\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\nconst ISLAND_STYLE_PREFIX = 'IslandStyle';\n\n/** Every island stylesheet in the manifest, by manifest key. */\nexport const getIslandStyleManifestEntries = (\n\tmanifest: Record<string, string>\n) =>\n\tObject.entries(manifest).filter(([key]) =>\n\t\tkey.startsWith(ISLAND_STYLE_PREFIX)\n\t);\n\n/** Manifest key of the stylesheet the island client pass emits for an\n * island (its Svelte/Vue component styles and any CSS it imports). The\n * server links it from every page that renders the island. */\nexport const getIslandStyleManifestKey = (\n\tframework: IslandFramework,\n\tcomponent: string\n) => `${ISLAND_STYLE_PREFIX}${toIslandFrameworkSegment(framework)}${component}`;\n",
|
|
6
6
|
"import type {\n\tIslandComponentDefinition,\n\tIslandRegistry,\n\tIslandRegistryInput\n} from '../../types/island';\n\nexport const defineIslandComponent = <Component>(\n\tcomponent: Component,\n\toptions: {\n\t\texport?: string;\n\t\tsource: string;\n\t}\n): IslandComponentDefinition<Component> => ({\n\tcomponent,\n\texport: options.export,\n\tsource: options.source\n});\nexport const defineIslandRegistry = <T extends IslandRegistryInput>(\n\tregistry: IslandRegistry<T>\n) => registry;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null;\n\nexport const getIslandBuildReference = <Component>(\n\tcomponent: Component | IslandComponentDefinition<Component>\n) => {\n\tif (!isIslandComponentDefinition(component)) return null;\n\n\treturn {\n\t\texport: component.export,\n\t\tsource: component.source\n\t};\n};\nexport const isIslandComponentDefinition = <Component>(\n\tvalue: Component | IslandComponentDefinition<Component>\n): value is IslandComponentDefinition<Component> =>\n\tisRecord(value) &&\n\t'component' in value &&\n\t'source' in value &&\n\ttypeof value.source === 'string';\n\nexport function getIslandComponent<Component>(component: Component): Component;\nexport function getIslandComponent<Component>(\n\tcomponent: IslandComponentDefinition<Component>\n): Component;\nexport function getIslandComponent<Component>(\n\tcomponent: Component | IslandComponentDefinition<Component>\n) {\n\tif (isIslandComponentDefinition(component)) {\n\t\treturn component.component;\n\t}\n\n\treturn component;\n}\nexport const parseIslandProps = (rawProps: string | null) => {\n\tif (!rawProps) return {};\n\n\treturn JSON.parse(rawProps);\n};\nexport const serializeIslandProps = (props: unknown) =>\n\tJSON.stringify(props ?? {});\n\nexport {\n\tgetIslandManifestEntries,\n\tgetIslandManifestKey\n} from './islandManifest';\n",
|
|
7
7
|
"import type { RuntimeIslandRenderProps } from '../../types/island';\nimport { serializeIslandProps } from './islands';\n\ntype IslandMarkerAttributes = {\n\t'data-component': string;\n\t'data-framework': string;\n\t'data-hydrate': string;\n\t'data-island': 'true';\n\t'data-island-id'?: string;\n\t'data-props': string;\n};\n\nexport const getIslandMarkerAttributes = (\n\tprops: RuntimeIslandRenderProps,\n\tislandId?: string\n): IslandMarkerAttributes => ({\n\t'data-component': props.component,\n\t'data-framework': props.framework,\n\t'data-hydrate': props.hydrate ?? 'load',\n\t'data-island': 'true',\n\t...(islandId ? { 'data-island-id': islandId } : {}),\n\t'data-props': serializeIslandProps(props.props)\n});\n\nconst escapeHtmlAttribute = (value: string) =>\n\tvalue\n\t\t.replaceAll('&', '&')\n\t\t.replaceAll('\"', '"')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>');\n\nexport const serializeIslandAttributes = (attributes: Record<string, string>) =>\n\tObject.entries(attributes)\n\t\t.map(([key, value]) => `${key}=\"${escapeHtmlAttribute(value)}\"`)\n\t\t.join(' ');\n",
|
|
8
|
-
"
|
|
9
|
-
"import type { RuntimeIslandRenderProps } from '../../types/island';\nimport {\n\
|
|
10
|
-
"import type {
|
|
8
|
+
"/* Dependency-free access to the current request's CSP nonce, for code that\n * also ships to the browser (streaming slots, Angular components) and so\n * can't import the server's request context. `secureHeaders()` registers\n * the getter (src/core/cspNonce.ts); in the browser, or with secure headers\n * off, there is none and these return undefined / ''. */\n\nconst GETTER_KEY = Symbol.for('absolutejs.cspNonceGetter');\n\n/** ` nonce=\"…\"` for an inline <script>/<style> tag, or '' without one. */\nexport const nonceAttr = (nonce: string | undefined = readCspNonce()) =>\n\tnonce ? ` nonce=\"${nonce}\"` : '';\n\n/** Adds the nonce to the <style id=\"svelte-…\"> tags Svelte renders into the\n * head for components compiled with injected CSS. Only those: a <style>\n * that arrived through {@html} stays without one. */\nexport const nonceSvelteHeadStyles = (\n\thead: string,\n\tnonce: string | undefined = readCspNonce()\n) =>\n\tnonce\n\t\t? head.replace(\n\t\t\t\t/<style(?=\\s+id=\"svelte-[^\"]*\")(?![^>]*\\snonce=)/g,\n\t\t\t\t`<style nonce=\"${nonce}\"`\n\t\t\t)\n\t\t: head;\n\nexport const readCspNonce = () => {\n\tconst getter: unknown = Reflect.get(globalThis, GETTER_KEY);\n\tif (typeof getter !== 'function') return undefined;\n\tconst nonce: unknown = getter();\n\n\treturn typeof nonce === 'string' ? nonce : undefined;\n};\n\nexport const registerCspNonceGetter = (getter: () => string | undefined) => {\n\tReflect.set(globalThis, GETTER_KEY, getter);\n};\n",
|
|
9
|
+
"import type { RuntimeIslandRenderProps } from '../../types/island';\nimport { getIslandMarkerAttributes } from '../core/islandMarkupAttributes';\n\ntype PreservedIslandMarkup = {\n\tattributes: Record<string, string>;\n\tinnerHTML: string;\n};\n\ntype IslandMarkerElement = HTMLElement & {\n\tdataset: DOMStringMap & {\n\t\tcomponent?: string;\n\t\tframework?: string;\n\t\thydrate?: string;\n\t\tisland?: string;\n\t\tislandId?: string;\n\t\tprops?: string;\n\t};\n};\n\nconst getSnapshotMap = () => {\n\tif (typeof window === 'undefined') {\n\t\treturn null;\n\t}\n\n\twindow.__ABS_SERVER_ISLAND_HTML__ ??= new Map<\n\t\tstring,\n\t\tPreservedIslandMarkup[]\n\t>();\n\n\treturn window.__ABS_SERVER_ISLAND_HTML__;\n};\n\nconst getIslandSignature = (props: RuntimeIslandRenderProps) => {\n\tconst attributes = getIslandMarkerAttributes(props);\n\n\treturn [\n\t\tattributes['data-component'],\n\t\tattributes['data-framework'],\n\t\tattributes['data-hydrate'],\n\t\tattributes['data-props']\n\t].join('::');\n};\n\nconst isMatchingIslandElement = (\n\telement: Element,\n\tprops: RuntimeIslandRenderProps\n): element is IslandMarkerElement => {\n\tif (!(element instanceof HTMLElement)) {\n\t\treturn false;\n\t}\n\n\tconst attributes = getIslandMarkerAttributes(props);\n\n\treturn (\n\t\telement.dataset.island === 'true' &&\n\t\telement.dataset.component === attributes['data-component'] &&\n\t\telement.dataset.framework === attributes['data-framework'] &&\n\t\t(element.dataset.hydrate ?? 'load') === attributes['data-hydrate'] &&\n\t\t(element.dataset.props ?? '{}') === attributes['data-props']\n\t);\n};\n\n/* Attributes the island runtime adds while hydrating. A host framework that\n * re-creates the marker (a remount, an HMR update) must not copy them, or the\n * runtime takes the new, unhydrated marker for a hydrated one and leaves it\n * dead. */\nconst RUNTIME_ISLAND_ATTRIBUTES = new Set(['data-error', 'data-hydrated']);\n\nconst readMarkerAttributes = (element: Element) =>\n\tObject.fromEntries(\n\t\telement\n\t\t\t.getAttributeNames()\n\t\t\t.filter((name) => !RUNTIME_ISLAND_ATTRIBUTES.has(name))\n\t\t\t.map((name) => [name, element.getAttribute(name) ?? ''])\n\t);\n\nconst snapshotIslandElement = (\n\telement: HTMLElement,\n\tsnapshotMap: Map<string, PreservedIslandMarkup[]>\n) => {\n\tconst signature = [\n\t\telement.dataset.component,\n\t\telement.dataset.framework,\n\t\telement.dataset.hydrate ?? 'load',\n\t\telement.dataset.props ?? '{}'\n\t].join('::');\n\tconst existing = snapshotMap.get(signature) ?? [];\n\texisting.push({\n\t\tattributes: readMarkerAttributes(element),\n\t\tinnerHTML: element.innerHTML\n\t});\n\tsnapshotMap.set(signature, existing);\n};\n\nexport const initializeIslandMarkupSnapshot = () => {\n\tif (typeof document === 'undefined') {\n\t\treturn;\n\t}\n\n\tconst snapshotMap = getSnapshotMap();\n\tif (!snapshotMap || snapshotMap.size > 0) {\n\t\treturn;\n\t}\n\n\tconst elements = Array.from(\n\t\tdocument.querySelectorAll<HTMLElement>('[data-island=\"true\"]')\n\t);\n\tfor (const element of elements) {\n\t\tsnapshotIslandElement(element, snapshotMap);\n\t}\n};\n\nexport const preserveIslandMarkup = (props: RuntimeIslandRenderProps) => {\n\tif (typeof document === 'undefined') {\n\t\treturn {\n\t\t\tattributes: getIslandMarkerAttributes(props),\n\t\t\tinnerHTML: ''\n\t\t};\n\t}\n\n\tconst snapshotMap = getSnapshotMap();\n\tconst signature = getIslandSignature(props);\n\t// Islands that share a signature (same component, framework, hydrate mode\n\t// and serialized props) produce byte-identical SSR markup, so the first\n\t// captured snapshot is correct for every instance. Returning it\n\t// unconditionally keeps this stateless: React may call the component many\n\t// times during a single hydration (StrictMode double-render, hydration\n\t// retries, mismatch regeneration), and a per-call claim counter would run\n\t// past the snapshot list and yield empty markup — making the host render\n\t// `dangerouslySetInnerHTML={{ __html: '' }}` and wipe the island's\n\t// server-rendered DOM before the island runtime can hydrate it.\n\tconst snapshotCandidate = snapshotMap?.get(signature)?.[0];\n\tif (snapshotCandidate) {\n\t\treturn snapshotCandidate;\n\t}\n\n\t// Snapshot not captured yet (the island runtime module hasn't evaluated):\n\t// fall back to reading the live SSR DOM directly.\n\tconst liveCandidate = Array.from(\n\t\tdocument.querySelectorAll('[data-island=\"true\"]')\n\t).find((element) => isMatchingIslandElement(element, props));\n\tif (!liveCandidate) {\n\t\treturn {\n\t\t\tattributes: getIslandMarkerAttributes(props),\n\t\t\tinnerHTML: ''\n\t\t};\n\t}\n\n\treturn {\n\t\tattributes: readMarkerAttributes(liveCandidate),\n\t\tinnerHTML: liveCandidate.innerHTML\n\t};\n};\n\nconst claimedServerIslands = new WeakSet<Element>();\n\n/* A host framework whose render must reproduce a stylesheet link the server\n * streamed right before an island (Vue, see vue/islandStyleLink.ts) asks\n * here whether its island has one. Each browser-side Island instance takes\n * the first server island element with its signature that no instance has\n * taken yet (instances set up in document order while hydrating), and gets\n * the `<link data-island-style>` just before it, if any. Reading the DOM\n * keeps hydration exact whatever order the server rendered the islands in.\n * Null on a browser-only render: no server element is left to take. */\nexport const claimServerIslandStyleLink = (props: RuntimeIslandRenderProps) => {\n\tif (typeof document === 'undefined') return null;\n\n\tconst element = Array.from(\n\t\tdocument.querySelectorAll('[data-island=\"true\"]')\n\t).find(\n\t\t(candidate) =>\n\t\t\t!claimedServerIslands.has(candidate) &&\n\t\t\tisMatchingIslandElement(candidate, props)\n\t);\n\tif (!element) return null;\n\tclaimedServerIslands.add(element);\n\n\tconst previous = element.previousSibling;\n\tif (!(previous instanceof HTMLLinkElement)) return null;\n\tconst key = previous.dataset.islandStyle;\n\tconst href = previous.getAttribute('href');\n\n\treturn key && href ? { href, key } : null;\n};\n\n/* React 19 compares `dangerouslySetInnerHTML` by object identity and rewrites\n * `innerHTML` whenever the object changes. A fresh `{ __html }` per render\n * made every host re-render (state change, Fast Refresh) replace the island's\n * hydrated DOM with its server markup, leaving a dead copy on screen. One\n * object per markup string keeps the boundary untouched. */\ntype InnerHtml = { __html: string };\n\nconst innerHtmlObjects = new Map<string, InnerHtml>();\n\nexport const getStableInnerHtml = (html: string) => {\n\tconst existing = innerHtmlObjects.get(html);\n\tif (existing) return existing;\n\tconst created: InnerHtml = { __html: html };\n\tinnerHtmlObjects.set(html, created);\n\n\treturn created;\n};\n",
|
|
10
|
+
"import type { IslandFramework } from '../../types/island';\nimport { readCspNonce } from '../utils/cspNonceRef';\nimport { getIslandStyleManifestKey } from './islandManifest';\n\n/* An island's built stylesheet, looked up where the host-side Island\n * components can see it: on the server the build manifest prepare()\n * recorded, in the browser the one the server injected into the page.\n * Shared by server and browser code, so nothing here imports server-only\n * modules. */\n\n/** Vue SSR context key under which a streamed Vue page render collects the\n * stylesheets its Islands have linked inline (see vue/islandStyleLink.ts). */\nexport const INLINE_ISLAND_STYLES_CONTEXT_KEY = '__absoluteInlineIslandStyles';\n\n/** React 19 stylesheet precedence for island stylesheets: React hoists\n * `<link rel=\"stylesheet\" precedence>` into the head and renders each href\n * once, however many islands ask for it. */\nexport const ISLAND_STYLE_PRECEDENCE = 'absolute-islands';\n\nconst ISLAND_FRAMEWORKS: readonly IslandFramework[] = [\n\t'react',\n\t'svelte',\n\t'vue',\n\t'angular'\n];\n\nconst toIslandFramework = (value: string) =>\n\tISLAND_FRAMEWORKS.find((framework) => framework === value);\n\nconst readIslandManifest = () => {\n\tconst manifest: unknown =\n\t\ttypeof window === 'undefined'\n\t\t\t? Reflect.get(globalThis, '__absoluteManifest')\n\t\t\t: Reflect.get(window, '__ABSOLUTE_MANIFEST__');\n\n\treturn typeof manifest === 'object' && manifest !== null\n\t\t? manifest\n\t\t: undefined;\n};\n\n/** The stylesheet the build emitted for an island, if it has one. */\nexport const findIslandStylesheet = (framework: string, component: string) => {\n\tconst islandFramework = toIslandFramework(framework);\n\tconst manifest = readIslandManifest();\n\tif (!islandFramework || !manifest) return undefined;\n\n\tconst key = getIslandStyleManifestKey(islandFramework, component);\n\tconst href: unknown = Reflect.get(manifest, key);\n\n\treturn typeof href === 'string' ? { href, key } : undefined;\n};\n\n/** The page's CSP nonce, for a stylesheet link a policy without 'self'\n * would otherwise refuse. On the server, the request's; in the browser,\n * read from a tag the server nonced (`.nonce`: browsers hide the\n * attribute once applied). '' when there is none. */\nexport const readIslandStyleNonce = () => {\n\tif (typeof document === 'undefined') return readCspNonce() ?? '';\n\n\treturn (\n\t\tArray.from(\n\t\t\tdocument.querySelectorAll<HTMLElement>('script[nonce]')\n\t\t).find((element) => element.nonce)?.nonce ?? ''\n\t);\n};\n",
|
|
11
|
+
"import type { ComponentProps } from 'react';\nimport type { RuntimeIslandRenderProps } from '../../types/island';\nimport {\n\tfindIslandStylesheet,\n\tISLAND_STYLE_PRECEDENCE,\n\treadIslandStyleNonce\n} from '../core/islandStylesheet';\n\ntype IslandStyleLinkProps = Pick<\n\tRuntimeIslandRenderProps,\n\t'component' | 'framework'\n>;\n\n/* An island's stylesheet, rendered next to the island. As a React 19\n * stylesheet resource (`precedence`), React hoists it into the head (in the\n * shell, or ahead of the Suspense boundary that holds the island) and\n * renders each href once, however many islands share it. A resource takes\n * no place in the hydrated tree, and the browser render adopts the\n * server's link by its href (it reads the manifest the server injected),\n * so hydration sees the same thing on both sides. */\nexport const IslandStyleLink = ({\n\tcomponent,\n\tframework\n}: IslandStyleLinkProps) => {\n\tconst stylesheet = findIslandStylesheet(framework, component);\n\tif (!stylesheet) return null;\n\tconst nonce = readIslandStyleNonce();\n\n\treturn (\n\t\t<link\n\t\t\tdata-island-style={stylesheet.key}\n\t\t\thref={stylesheet.href}\n\t\t\tnonce={nonce || undefined}\n\t\t\tprecedence={ISLAND_STYLE_PRECEDENCE}\n\t\t\trel=\"stylesheet\"\n\t\t/>\n\t);\n};\n\ntype IslandWithStylesheetProps = IslandStyleLinkProps & {\n\t/** Props of the island's marker element. */\n\tmarker: ComponentProps<'div'>;\n};\n\n/** An island's marker element, preceded by its stylesheet. */\nexport const IslandWithStylesheet = ({\n\tcomponent,\n\tframework,\n\tmarker\n}: IslandWithStylesheetProps) => (\n\t<>\n\t\t<IslandStyleLink component={component} framework={framework} />\n\t\t<div {...marker} />\n\t</>\n);\n",
|
|
12
|
+
"import type { RuntimeIslandRenderProps } from '../../types/island';\nimport {\n\tgetStableInnerHtml,\n\tpreserveIslandMarkup\n} from '../client/preserveIslandMarkup';\nimport { IslandWithStylesheet } from './IslandStyleLink';\n\nexport const Island = (props: RuntimeIslandRenderProps) => {\n\tconst { attributes, innerHTML } = preserveIslandMarkup(props);\n\n\treturn (\n\t\t<IslandWithStylesheet\n\t\t\tcomponent={props.component}\n\t\t\tframework={props.framework}\n\t\t\tmarker={{\n\t\t\t\t...attributes,\n\t\t\t\tdangerouslySetInnerHTML: getStableInnerHtml(innerHTML),\n\t\t\t\tsuppressHydrationWarning: true\n\t\t\t}}\n\t\t/>\n\t);\n};\n",
|
|
13
|
+
"import type {\n\tIslandRegistry,\n\tIslandRegistryInput,\n\tTypedIslandRenderProps\n} from '../../types/island';\nimport {\n\tgetStableInnerHtml,\n\tpreserveIslandMarkup\n} from '../client/preserveIslandMarkup';\nimport { IslandWithStylesheet } from './IslandStyleLink';\n\nexport const createTypedIsland = <T extends IslandRegistryInput>(\n\t_registry: IslandRegistry<T>\n) => {\n\tconst Island = (props: TypedIslandRenderProps<T>) => {\n\t\tconst { attributes, innerHTML } = preserveIslandMarkup(props);\n\n\t\treturn (\n\t\t\t<IslandWithStylesheet\n\t\t\t\tcomponent={props.component}\n\t\t\t\tframework={props.framework}\n\t\t\t\tmarker={{\n\t\t\t\t\t...attributes,\n\t\t\t\t\tdangerouslySetInnerHTML: getStableInnerHtml(innerHTML),\n\t\t\t\t\tsuppressHydrationWarning: true\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t};\n\n\treturn Island;\n};\n",
|
|
11
14
|
"import { useSyncExternalStore } from 'react';\nimport type { StoreApi } from 'zustand/vanilla';\nimport {\n\tgetIslandStoreServerSnapshot,\n\treadIslandStore,\n\tsubscribeIslandStore,\n\ttype IslandStoreState\n} from '../../client/islandStore';\n\nexport const useIslandStore = <TState extends IslandStoreState, TSelected>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected\n) =>\n\tuseSyncExternalStore(\n\t\t(listener) =>\n\t\t\tsubscribeIslandStore(store, selector, () => {\n\t\t\t\tlistener();\n\t\t\t}),\n\t\t() => readIslandStore(store, selector),\n\t\t() => getIslandStoreServerSnapshot(store, selector)\n\t);\n",
|
|
12
15
|
"const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\" || nextState === null) ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const getInitialState = () => initialState;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const api = { setState, getState, getInitialState, subscribe };\n const initialState = state = createState(setState, getState, api);\n return api;\n};\nconst createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);\n\nexport { createStore };\n",
|
|
13
16
|
"const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst shouldDispatchFromDevtools = (api) => !!api.dispatchFromDevtools && typeof api.dispatch === \"function\";\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if (!connectionInfo) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst findCallerName = (stack) => {\n var _a, _b;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return (_b = /.+ (.+) .+/.exec(callerLine)) == null ? void 0 : _b[1];\n};\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n api.devtools = {\n cleanup: () => {\n if (connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n removeStoreFromTrackedConnections(options.name, store);\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (shouldDispatchFromDevtools(api)) {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (shouldDispatchFromDevtools(api)) {\n api.dispatch(action);\n }\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => window.localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n let hydrationVersion = 0;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n const currentVersion = ++hydrationVersion;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n if (currentVersion !== hydrationVersion) {\n return;\n }\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nfunction ssrSafe(config, isSSR = typeof window === \"undefined\") {\n return (set, get, api) => {\n if (!isSSR) {\n return config(set, get, api);\n }\n const ssrSet = () => {\n throw new Error(\"Cannot set state of Zustand store in SSR\");\n };\n api.setState = ssrSet;\n return config(ssrSet, get, api);\n };\n}\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector, ssrSafe as unstable_ssrSafe };\n",
|
|
14
17
|
"import { createStore, type StateCreator, type StoreApi } from 'zustand/vanilla';\nimport { combine } from 'zustand/middleware';\n\nexport type IslandStoreState = object;\ntype IslandStoreSnapshot = Record<string, unknown>;\ntype IslandStoreShape<\n\tTState extends IslandStoreState,\n\tTActions extends object\n> = Omit<TState, keyof TActions> & TActions;\nexport type IslandStateSnapshot = Record<string, IslandStoreSnapshot>;\ntype AnyIslandStore = StoreApi<object>;\ntype IslandStoreInstance = {\n\tapplyExternalSnapshot: (snapshot: IslandStoreSnapshot) => void;\n\tstore: AnyIslandStore;\n};\n\nexport const ABSOLUTE_ISLAND_STATE = '__ABS_ISLAND_STATE__';\nexport const ABSOLUTE_ISLAND_STORES = '__ABS_ISLAND_STORES__';\n\ndeclare global {\n\tvar __ABS_ISLAND_STATE__: IslandStateSnapshot | undefined;\n\tvar __ABS_ISLAND_STORES__:\n\t\tMap<string, Set<IslandStoreInstance>> | undefined;\n}\n\nconst getIslandStoreSnapshot = () => {\n\tglobalThis.__ABS_ISLAND_STATE__ ??= {};\n\n\treturn globalThis.__ABS_ISLAND_STATE__;\n};\n\nconst getIslandStores = () => {\n\tglobalThis.__ABS_ISLAND_STORES__ ??= new Map();\n\n\treturn globalThis.__ABS_ISLAND_STORES__;\n};\n\nconst isSerializableValue = (value: unknown) =>\n\ttypeof value !== 'function' && value !== undefined;\n\nconst toSerializableState = <T extends object>(state: T) =>\n\tObject.fromEntries(\n\t\tObject.entries(state).filter(([, value]) => isSerializableValue(value))\n\t);\n\nconst applySnapshot = <T extends object>(\n\tstore: StoreApi<T>,\n\tsnapshot: IslandStoreSnapshot | undefined\n) => {\n\tif (!snapshot) {\n\t\treturn;\n\t}\n\n\tstore.setState({\n\t\t...store.getState(),\n\t\t...snapshot\n\t});\n};\n\nconst getPeerStores = (\n\tstoreInstances: Set<IslandStoreInstance>,\n\townerStore: AnyIslandStore\n) => [...storeInstances].filter((peer) => peer.store !== ownerStore);\n\nconst syncIslandSnapshot = <\n\tTState extends IslandStoreState,\n\tTActions extends object\n>(\n\tstoreId: string,\n\tstate: IslandStoreShape<TState, TActions>,\n\tstoreInstances: Set<IslandStoreInstance>,\n\townerStore: AnyIslandStore\n) => {\n\tconst nextSnapshot = toSerializableState(state);\n\tgetIslandStoreSnapshot()[storeId] = nextSnapshot;\n\n\tfor (const peerStore of getPeerStores(storeInstances, ownerStore)) {\n\t\tpeerStore.applyExternalSnapshot(nextSnapshot);\n\t}\n};\n\nexport const createIslandStore = <\n\tTState extends IslandStoreState,\n\tTActions extends object\n>(\n\tstoreId: string,\n\tinitialState: TState,\n\tcreateState: StateCreator<TState, [], [], TActions>\n) => {\n\tconst store = createStore(combine(initialState, createState));\n\tconst stores = getIslandStores();\n\tconst storeInstances =\n\t\tstores.get(storeId) ?? new Set<IslandStoreInstance>();\n\tconst initialSnapshot = getIslandStoreSnapshot()[storeId];\n\tapplySnapshot(store, initialSnapshot);\n\tlet isApplyingExternalSnapshot = false;\n\n\tconst applyExternalSnapshot = (snapshot: IslandStoreSnapshot) => {\n\t\tisApplyingExternalSnapshot = true;\n\t\tapplySnapshot(store, snapshot);\n\t};\n\n\tstoreInstances.add({\n\t\tapplyExternalSnapshot,\n\t\tstore\n\t});\n\tstores.set(storeId, storeInstances);\n\n\tsyncIslandSnapshot(storeId, store.getState(), storeInstances, store);\n\tstore.subscribe((state) => {\n\t\tif (isApplyingExternalSnapshot) {\n\t\t\tisApplyingExternalSnapshot = false;\n\n\t\t\treturn;\n\t\t}\n\n\t\tsyncIslandSnapshot(storeId, state, storeInstances, store);\n\t});\n\n\treturn store;\n};\nexport const getIslandStoreServerSnapshot = <\n\tTState extends IslandStoreState,\n\tTSelected\n>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected\n) => selector(store.getInitialState());\nconst applySnapshotToStoreInstances = (\n\tstoreId: string,\n\tinstances: Set<IslandStoreInstance>,\n\tsnapshot: IslandStateSnapshot\n) => {\n\tfor (const instance of instances) {\n\t\tinstance.applyExternalSnapshot(snapshot[storeId] ?? {});\n\t}\n};\n\nexport const initializeIslandStores = (state: IslandStateSnapshot) => {\n\tconst currentSnapshot = getIslandStoreSnapshot();\n\tconst nextSnapshot: IslandStateSnapshot = {\n\t\t...state,\n\t\t...currentSnapshot\n\t};\n\n\tglobalThis.__ABS_ISLAND_STATE__ = nextSnapshot;\n\n\tfor (const [storeId, store] of getIslandStores()) {\n\t\tapplySnapshotToStoreInstances(storeId, store, nextSnapshot);\n\t}\n};\nexport const readIslandStore = <TState extends IslandStoreState, TSelected>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected\n) => selector(store.getState());\nexport const resetIslandStoreForTesting = () => {\n\tdelete globalThis.__ABS_ISLAND_STATE__;\n\tdelete globalThis.__ABS_ISLAND_STORES__;\n};\nexport const subscribeIslandStore = <\n\tTState extends IslandStoreState,\n\tTSelected\n>(\n\tstore: StoreApi<TState>,\n\tselector: (state: TState) => TSelected,\n\tlistener: (value: TSelected) => void\n) => {\n\tlet currentSelection = selector(store.getState());\n\n\treturn store.subscribe((state) => {\n\t\tconst nextSelection = selector(state);\n\t\tif (Object.is(nextSelection, currentSelection)) {\n\t\t\treturn;\n\t\t}\n\n\t\tcurrentSelection = nextSelection;\n\t\tlistener(nextSelection);\n\t});\n};\n"
|
|
15
18
|
],
|
|
16
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMa,gCAAgC,2BAKhC,uCAAuC,mBAE9C,2BAA2B,CAAC,cACjC,UAAU,IAAI,YAAY,IAAI,UAAU,MAAM,CAAC,GAE1C,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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CAAC,aACA,qBAAqB,OAAO,UAAU,MAAM;AAAA,EAC3C,SAAS;AAAA,CACT,GACF,MAAM,gBAAgB,OAAO,QAAQ,GACrC,MAAM,6BAA6B,OAAO,QAAQ,CACnD;",
|
|
20
|
+
"debugId": "C759A4F16D5FB34864756E2164756E21",
|
|
18
21
|
"names": []
|
|
19
22
|
}
|
|
@@ -868,10 +868,33 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
|
868
868
|
getWarningController()?.maybeWarn(primitiveName);
|
|
869
869
|
};
|
|
870
870
|
|
|
871
|
+
// src/react/serverComponents/nodeRendererRef.ts
|
|
872
|
+
var STORAGE_KEY = Symbol.for("absolutejs.reactServerNodeRendererStorage");
|
|
873
|
+
var isRendererStorage = (value) => typeof value === "object" && value !== null && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
874
|
+
var isRenderer = (value) => typeof value === "function";
|
|
875
|
+
var readStorage = () => {
|
|
876
|
+
const storage = Reflect.get(globalThis, STORAGE_KEY);
|
|
877
|
+
return isRendererStorage(storage) ? storage : undefined;
|
|
878
|
+
};
|
|
879
|
+
var getReactServerNodeRenderer = () => {
|
|
880
|
+
const store = readStorage()?.getStore();
|
|
881
|
+
return isRenderer(store) ? store : undefined;
|
|
882
|
+
};
|
|
883
|
+
var runWithReactServerNodeRenderer = (renderer, createStorage, render) => {
|
|
884
|
+
let storage = readStorage();
|
|
885
|
+
if (!storage) {
|
|
886
|
+
storage = createStorage();
|
|
887
|
+
Reflect.set(globalThis, STORAGE_KEY, storage);
|
|
888
|
+
}
|
|
889
|
+
return storage.run(renderer, render);
|
|
890
|
+
};
|
|
891
|
+
|
|
871
892
|
// src/react/components/SuspenseSlot.tsx
|
|
872
893
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
873
894
|
var isLegacyProps = (props) => ("fallbackHtml" in props) || ("errorHtml" in props);
|
|
874
|
-
var renderReactNodeToHtml = async (node) => {
|
|
895
|
+
var renderReactNodeToHtml = async (node, serverNodeRenderer) => {
|
|
896
|
+
if (serverNodeRenderer)
|
|
897
|
+
return serverNodeRenderer(node);
|
|
875
898
|
const { Fragment } = await import("react");
|
|
876
899
|
const { renderToReadableStream } = await import("react-dom/server");
|
|
877
900
|
const stream = await renderToReadableStream(/* @__PURE__ */ jsx4(Fragment, {
|
|
@@ -899,12 +922,12 @@ async function resolveNodeSuspenseValue(props) {
|
|
|
899
922
|
}
|
|
900
923
|
return;
|
|
901
924
|
}
|
|
902
|
-
var renderErrorFallback = async (props, error) => {
|
|
925
|
+
var renderErrorFallback = async (props, error, serverNodeRenderer) => {
|
|
903
926
|
if (typeof props.errorFallback === "function") {
|
|
904
|
-
return renderReactNodeToHtml(props.errorFallback(error));
|
|
927
|
+
return renderReactNodeToHtml(props.errorFallback(error), serverNodeRenderer);
|
|
905
928
|
}
|
|
906
929
|
if (props.errorFallback !== undefined) {
|
|
907
|
-
return renderReactNodeToHtml(props.errorFallback);
|
|
930
|
+
return renderReactNodeToHtml(props.errorFallback, serverNodeRenderer);
|
|
908
931
|
}
|
|
909
932
|
throw error;
|
|
910
933
|
};
|
|
@@ -919,6 +942,7 @@ var registerLegacySuspenseSlot = (props) => {
|
|
|
919
942
|
});
|
|
920
943
|
};
|
|
921
944
|
var registerFrameworkSuspenseSlot = (props) => {
|
|
945
|
+
const serverNodeRenderer = getReactServerNodeRenderer();
|
|
922
946
|
registerStreamingSlot({
|
|
923
947
|
dynamic: props.dynamic,
|
|
924
948
|
id: props.id,
|
|
@@ -926,9 +950,9 @@ var registerFrameworkSuspenseSlot = (props) => {
|
|
|
926
950
|
resolve: async () => {
|
|
927
951
|
try {
|
|
928
952
|
const content = hasRenderChildren(props) ? props.children(await resolveRenderSuspenseValue(props)) : props.children ?? await resolveNodeSuspenseValue(props) ?? null;
|
|
929
|
-
return renderReactNodeToHtml(content);
|
|
953
|
+
return renderReactNodeToHtml(content, serverNodeRenderer);
|
|
930
954
|
} catch (error) {
|
|
931
|
-
return renderErrorFallback(props, error);
|
|
955
|
+
return renderErrorFallback(props, error, serverNodeRenderer);
|
|
932
956
|
}
|
|
933
957
|
}
|
|
934
958
|
});
|
|
@@ -1487,5 +1511,5 @@ export {
|
|
|
1487
1511
|
usePrefetch
|
|
1488
1512
|
};
|
|
1489
1513
|
|
|
1490
|
-
//# debugId=
|
|
1514
|
+
//# debugId=34234EAA9716CF6B64756E2164756E21
|
|
1491
1515
|
//# sourceMappingURL=index.js.map
|