@absolutejs/absolute 0.19.0-beta.326 → 0.19.0-beta.327

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.
@@ -29866,6 +29866,19 @@ var defineIslandRegistry = (registry) => registry, defineIslandComponent = (comp
29866
29866
  };
29867
29867
  var init_islands2 = () => {};
29868
29868
 
29869
+ // src/core/islandMarkupAttributes.ts
29870
+ var getIslandMarkerAttributes = (props, islandId) => ({
29871
+ "data-component": props.component,
29872
+ "data-framework": props.framework,
29873
+ "data-hydrate": props.hydrate ?? "load",
29874
+ "data-island": "true",
29875
+ ...islandId ? { "data-island-id": islandId } : {},
29876
+ "data-props": serializeIslandProps(props.props)
29877
+ }), escapeHtmlAttribute = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"), serializeIslandAttributes = (attributes) => Object.entries(attributes).map(([key, value]) => `${key}="${escapeHtmlAttribute(value)}"`).join(" ");
29878
+ var init_islandMarkupAttributes = __esm(() => {
29879
+ init_islands2();
29880
+ });
29881
+
29869
29882
  // src/client/islandResolver.ts
29870
29883
  var createIslandManifestResolver = (manifest) => {
29871
29884
  const islandManifest = getIslandManifestEntries(manifest);
@@ -29958,6 +29971,88 @@ import { createElement } from "react";
29958
29971
  import { hydrateRoot } from "react-dom/client";
29959
29972
  import { hydrate as hydrateSvelte } from "svelte";
29960
29973
  import { createSSRApp, h } from "vue";
29974
+
29975
+ // src/client/preserveIslandMarkup.ts
29976
+ init_islandMarkupAttributes();
29977
+ var getClaimMap = () => {
29978
+ if (typeof window === "undefined") {
29979
+ return null;
29980
+ }
29981
+ window.__ABS_CLAIMED_ISLAND_MARKUP__ ??= new Map;
29982
+ return window.__ABS_CLAIMED_ISLAND_MARKUP__;
29983
+ };
29984
+ var getSnapshotMap = () => {
29985
+ if (typeof window === "undefined") {
29986
+ return null;
29987
+ }
29988
+ window.__ABS_SERVER_ISLAND_HTML__ ??= new Map;
29989
+ return window.__ABS_SERVER_ISLAND_HTML__;
29990
+ };
29991
+ var getIslandSignature = (props) => {
29992
+ const attributes = getIslandMarkerAttributes(props);
29993
+ return [
29994
+ attributes["data-component"],
29995
+ attributes["data-framework"],
29996
+ attributes["data-hydrate"],
29997
+ attributes["data-props"]
29998
+ ].join("::");
29999
+ };
30000
+ var isMatchingIslandElement = (element2, props) => {
30001
+ if (!(element2 instanceof HTMLElement)) {
30002
+ return false;
30003
+ }
30004
+ const attributes = getIslandMarkerAttributes(props);
30005
+ return element2.dataset.island === "true" && element2.dataset.component === attributes["data-component"] && element2.dataset.framework === attributes["data-framework"] && (element2.dataset.hydrate ?? "load") === attributes["data-hydrate"] && (element2.dataset.props ?? "{}") === attributes["data-props"];
30006
+ };
30007
+ var initializeIslandMarkupSnapshot = () => {
30008
+ if (typeof document === "undefined") {
30009
+ return;
30010
+ }
30011
+ const snapshotMap = getSnapshotMap();
30012
+ if (!snapshotMap || snapshotMap.size > 0) {
30013
+ return;
30014
+ }
30015
+ const elements = Array.from(document.querySelectorAll('[data-island="true"]'));
30016
+ for (const element2 of elements) {
30017
+ if (!(element2 instanceof HTMLElement)) {
30018
+ continue;
30019
+ }
30020
+ const signature = [
30021
+ element2.dataset.component,
30022
+ element2.dataset.framework,
30023
+ element2.dataset.hydrate ?? "load",
30024
+ element2.dataset.props ?? "{}"
30025
+ ].join("::");
30026
+ const existing = snapshotMap.get(signature) ?? [];
30027
+ existing.push(element2.innerHTML);
30028
+ snapshotMap.set(signature, existing);
30029
+ }
30030
+ };
30031
+ var preserveIslandMarkup = (props) => {
30032
+ if (typeof document === "undefined") {
30033
+ return {
30034
+ attributes: getIslandMarkerAttributes(props),
30035
+ innerHTML: ""
30036
+ };
30037
+ }
30038
+ const claimMap = getClaimMap();
30039
+ const snapshotMap = getSnapshotMap();
30040
+ const signature = getIslandSignature(props);
30041
+ const claimedCount = claimMap?.get(signature) ?? 0;
30042
+ const snapshotCandidate = snapshotMap?.get(signature)?.[claimedCount];
30043
+ const candidates = Array.from(document.querySelectorAll('[data-island="true"]')).filter((element2) => isMatchingIslandElement(element2, props));
30044
+ const candidate = candidates[claimedCount];
30045
+ if (claimMap) {
30046
+ claimMap.set(signature, claimedCount + 1);
30047
+ }
30048
+ return {
30049
+ attributes: getIslandMarkerAttributes(props),
30050
+ innerHTML: snapshotCandidate ?? candidate?.innerHTML ?? ""
30051
+ };
30052
+ };
30053
+
30054
+ // src/client/islandRuntime.ts
30055
+ initializeIslandMarkupSnapshot();
29961
30056
  var createIdleDeadline = () => ({
29962
30057
  didTimeout: false,
29963
30058
  timeRemaining: () => 0
@@ -30136,5 +30231,5 @@ export {
30136
30231
  createIslandManifestResolver
30137
30232
  };
30138
30233
 
30139
- //# debugId=69A4B3384029082564756E2164756E21
30234
+ //# debugId=BC78E98C53567CCD64756E2164756E21
30140
30235
  //# sourceMappingURL=index.js.map