@absolutejs/absolute 0.20.0-beta.56 → 0.20.0-beta.58

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.
Files changed (58) hide show
  1. package/dist/angular/browser.js +1 -45
  2. package/dist/angular/browser.js.map +2 -2
  3. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  4. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  5. package/dist/angular/index.js +1 -17
  6. package/dist/angular/index.js.map +2 -2
  7. package/dist/build.js +8 -2
  8. package/dist/build.js.map +3 -3
  9. package/dist/cli/index.js +21 -3
  10. package/dist/client/chunks/angularPatch-arh4sr68.js +157 -0
  11. package/dist/client/chunks/angularPatch-arh4sr68.js.map +10 -0
  12. package/dist/client/chunks/index-5py90ctf.js +87 -0
  13. package/dist/client/chunks/index-5py90ctf.js.map +10 -0
  14. package/dist/client/chunks/index-m35nbkdp.js +374 -0
  15. package/dist/client/chunks/index-m35nbkdp.js.map +12 -0
  16. package/dist/client/chunks/index-qxjc7kc5.js +12 -0
  17. package/dist/client/chunks/index-qxjc7kc5.js.map +9 -0
  18. package/dist/client/chunks/islands-xj2n8nwf.js +281 -0
  19. package/dist/client/chunks/islands-xj2n8nwf.js.map +14 -0
  20. package/dist/client/chunks/react-pdg4325x.js +65 -0
  21. package/dist/client/chunks/react-pdg4325x.js.map +10 -0
  22. package/dist/client/chunks/svelte-s0c964kb.js +19 -0
  23. package/dist/client/chunks/svelte-s0c964kb.js.map +10 -0
  24. package/dist/client/chunks/vue-rdskrnyg.js +24 -0
  25. package/dist/client/chunks/vue-rdskrnyg.js.map +10 -0
  26. package/dist/client/index.js +56 -947
  27. package/dist/client/index.js.map +7 -22
  28. package/dist/index.js +8 -2
  29. package/dist/index.js.map +3 -3
  30. package/dist/islands/browser.js +1 -17
  31. package/dist/islands/browser.js.map +2 -2
  32. package/dist/islands/index.js +1 -17
  33. package/dist/islands/index.js.map +2 -2
  34. package/dist/mobile/browser.js +264 -2
  35. package/dist/mobile/browser.js.map +5 -4
  36. package/dist/mobile/index.js +276 -4
  37. package/dist/mobile/index.js.map +7 -6
  38. package/dist/mobile/remoteMacAgentEntry.js +13 -3
  39. package/dist/mobile/shellBootstrap.js +368 -29
  40. package/dist/mobile/uiPrimitives.js +264 -0
  41. package/dist/react/browser.js +1 -45
  42. package/dist/react/browser.js.map +2 -2
  43. package/dist/react/hooks/index.js +1 -17
  44. package/dist/react/hooks/index.js.map +2 -2
  45. package/dist/react/index.js +1 -17
  46. package/dist/react/index.js.map +2 -2
  47. package/dist/src/mobile/browser.d.ts +1 -0
  48. package/dist/src/mobile/index.d.ts +1 -0
  49. package/dist/src/mobile/uiPrimitives.d.ts +37 -0
  50. package/dist/svelte/browser.js +1 -17
  51. package/dist/svelte/browser.js.map +2 -2
  52. package/dist/svelte/index.js +1 -17
  53. package/dist/svelte/index.js.map +2 -2
  54. package/dist/vue/browser.js +84 -121
  55. package/dist/vue/browser.js.map +4 -4
  56. package/dist/vue/index.js +84 -121
  57. package/dist/vue/index.js.map +4 -4
  58. package/package.json +13 -7
package/dist/cli/index.js CHANGED
@@ -2192,6 +2192,11 @@ const bridgeBootstrap = (path: string, safeAreaInsets: { bottom: number; left: n
2192
2192
  send({ format: 3, kind: 'event', event: 'navigation', path });
2193
2193
  }
2194
2194
  };
2195
+ globalThis.__absoluteRequestBack = () => {
2196
+ const event = new CustomEvent('absolute:back-request', { cancelable: true });
2197
+ if (!dispatchEvent(event)) return;
2198
+ send({ format: 3, kind: 'event', event: 'back-unhandled', path: currentPath });
2199
+ };
2195
2200
  if (\${DEV_ORIGIN ? 'true' : 'false'}) {
2196
2201
  const publishPath = () => {
2197
2202
  const path = location.pathname + location.search + location.hash;
@@ -2300,12 +2305,12 @@ export function AbsoluteWebHost() {
2300
2305
  }, [safeAreaInsets.bottom, safeAreaInsets.left, safeAreaInsets.right, safeAreaInsets.top]);
2301
2306
  useEffect(() => {
2302
2307
  const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
2303
- if (!canGoBack) return false;
2304
- webView.current?.goBack();
2308
+ if (!indexUri) return false;
2309
+ webView.current?.injectJavaScript('globalThis.__absoluteRequestBack?.(); true;');
2305
2310
  return true;
2306
2311
  });
2307
2312
  return () => subscription.remove();
2308
- }, [canGoBack]);
2313
+ }, [indexUri]);
2309
2314
 
2310
2315
  const respond = (message: Record<string, unknown>) => {
2311
2316
  const source = JSON.stringify(message).replaceAll('\\u2028', '\\\\u2028').replaceAll('\\u2029', '\\\\u2029');
@@ -2345,6 +2350,11 @@ export function AbsoluteWebHost() {
2345
2350
  else activeWebPath.current = message.path;
2346
2351
  return;
2347
2352
  }
2353
+ if (message.kind === 'event' && message.event === 'back-unhandled') {
2354
+ if (canGoBack) webView.current?.goBack();
2355
+ else BackHandler.exitApp();
2356
+ return;
2357
+ }
2348
2358
  if (message.kind !== 'request' || typeof message.id !== 'string' || message.path !== activeWebPath.current) return;
2349
2359
  try {
2350
2360
  if (typeof message.params !== 'object' || message.params === null || Array.isArray(message.params)) throw new Error('Expo bridge method params are invalid.');
@@ -21384,6 +21394,10 @@ var init_iosTestReport = __esm(() => {
21384
21394
  "ADAPT-04",
21385
21395
  "Confirm automatic system-bar appearance and unchanged author layout."
21386
21396
  ],
21397
+ ...Array.from({ length: 5 }, (_, index) => [
21398
+ `MOBILE-UI-${String(index + 1).padStart(2, "0")}`,
21399
+ `Complete framework-neutral mobile UI runbook check MOBILE-UI-${String(index + 1).padStart(2, "0")}.`
21400
+ ]),
21387
21401
  ...Array.from({ length: 10 }, (_, index) => [
21388
21402
  `DEVICEDEV-${String(index + 1).padStart(2, "0")}`,
21389
21403
  `Complete physical-device development runbook check DEVICEDEV-${String(index + 1).padStart(2, "0")}.`
@@ -21485,6 +21499,10 @@ var init_androidTestReport = __esm(() => {
21485
21499
  "ADAPT-04",
21486
21500
  "Confirm automatic system-bar appearance and unchanged author layout."
21487
21501
  ],
21502
+ ...Array.from({ length: 5 }, (_, index) => [
21503
+ `MOBILE-UI-${String(index + 1).padStart(2, "0")}`,
21504
+ `Complete framework-neutral mobile UI runbook check MOBILE-UI-${String(index + 1).padStart(2, "0")}.`
21505
+ ]),
21488
21506
  ["CAP-01", "Complete automatic device-capability provisioning checks."],
21489
21507
  [
21490
21508
  "SYSUI-01",
@@ -0,0 +1,157 @@
1
+ import {
2
+ isProductionRuntime,
3
+ resolveAngularRuntimePath
4
+ } from "./index-m35nbkdp.js";
5
+ import"./index-qxjc7kc5.js";
6
+
7
+ // src/angular/angularPatch.ts
8
+ var ensureHead = (doc) => {
9
+ if (!doc || doc.head || !doc.documentElement) {
10
+ return;
11
+ }
12
+ const head = doc.createElement("head");
13
+ doc.documentElement.insertBefore(head, doc.documentElement.firstChild);
14
+ };
15
+ var SSR_LAYOUT_RECT = Object.freeze({
16
+ bottom: 0,
17
+ height: 0,
18
+ left: 0,
19
+ right: 0,
20
+ top: 0,
21
+ width: 0,
22
+ x: 0,
23
+ y: 0,
24
+ toJSON() {
25
+ return this;
26
+ }
27
+ });
28
+ var layoutPatchApplied = false;
29
+ var collectPrototypeChain = (instance) => {
30
+ const protos = [];
31
+ let current = instance ? Object.getPrototypeOf(instance) : null;
32
+ while (current && current !== Object.prototype) {
33
+ protos.push(current);
34
+ current = Object.getPrototypeOf(current);
35
+ }
36
+ return protos;
37
+ };
38
+ var patchElementLayout = (doc) => {
39
+ if (layoutPatchApplied || !doc) {
40
+ return;
41
+ }
42
+ let element;
43
+ try {
44
+ element = doc.createElement("div");
45
+ } catch {
46
+ return;
47
+ }
48
+ const protos = collectPrototypeChain(element);
49
+ if (protos.length === 0)
50
+ return;
51
+ const copyLayoutRect = (rect) => ({ ...rect });
52
+ const createLayoutRect = () => copyLayoutRect(SSR_LAYOUT_RECT);
53
+ const getClientRects = () => [];
54
+ const noop = () => {
55
+ return;
56
+ };
57
+ const numericProps = [
58
+ "clientWidth",
59
+ "clientHeight",
60
+ "clientLeft",
61
+ "clientTop",
62
+ "offsetWidth",
63
+ "offsetHeight",
64
+ "offsetLeft",
65
+ "offsetTop",
66
+ "scrollWidth",
67
+ "scrollHeight",
68
+ "scrollLeft",
69
+ "scrollTop"
70
+ ];
71
+ for (const proto of protos) {
72
+ const define = (name, value) => {
73
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
74
+ if (typeof descriptor?.value === "function")
75
+ return;
76
+ Object.defineProperty(proto, name, {
77
+ configurable: true,
78
+ value,
79
+ writable: true
80
+ });
81
+ };
82
+ define("getBoundingClientRect", createLayoutRect);
83
+ define("getClientRects", getClientRects);
84
+ define("scrollTo", noop);
85
+ define("scrollBy", noop);
86
+ define("scrollIntoView", noop);
87
+ define("focus", noop);
88
+ define("blur", noop);
89
+ for (const prop of numericProps) {
90
+ const desc = Object.getOwnPropertyDescriptor(proto, prop);
91
+ if (desc)
92
+ continue;
93
+ Object.defineProperty(proto, prop, {
94
+ configurable: true,
95
+ get: () => 0
96
+ });
97
+ }
98
+ }
99
+ layoutPatchApplied = true;
100
+ };
101
+ var applyPatches = async () => {
102
+ const spec = isProductionRuntime() ? resolveAngularRuntimePath("@angular/platform-server") : "@angular/platform-server";
103
+ const { ɵDominoAdapter } = await import(spec);
104
+ if (!ɵDominoAdapter?.prototype) {
105
+ console.warn("[Angular Patch] ɵDominoAdapter not found, skipping patches");
106
+ return false;
107
+ }
108
+ try {
109
+ const adapter = new ɵDominoAdapter;
110
+ const resolveSeedDoc = () => {
111
+ if (typeof adapter.createHtmlDocument === "function")
112
+ return adapter.createHtmlDocument();
113
+ if (typeof adapter.getDefaultDocument === "function")
114
+ return adapter.getDefaultDocument();
115
+ return null;
116
+ };
117
+ const seedDoc = resolveSeedDoc();
118
+ if (seedDoc) {
119
+ patchElementLayout(seedDoc);
120
+ const probe = seedDoc.createElement("div");
121
+ if (typeof probe.getBoundingClientRect !== "function") {
122
+ console.warn("[Angular Patch] Layout shim did not stick on probe element prototype chain");
123
+ }
124
+ }
125
+ } catch (error) {
126
+ console.warn("[Angular Patch] Could not eagerly patch Element prototypes:", error);
127
+ }
128
+ const proto = ɵDominoAdapter.prototype;
129
+ const origGetBaseHref = proto.getBaseHref;
130
+ proto.getBaseHref = function(doc) {
131
+ if (!doc || !doc.head || typeof doc.head.children === "undefined") {
132
+ return "";
133
+ }
134
+ return origGetBaseHref.call(this, doc);
135
+ };
136
+ const origCreateHtmlDocument = proto.createHtmlDocument;
137
+ proto.createHtmlDocument = function() {
138
+ const doc = origCreateHtmlDocument.call(this);
139
+ ensureHead(doc);
140
+ patchElementLayout(doc);
141
+ return doc;
142
+ };
143
+ const origGetDefaultDocument = proto.getDefaultDocument;
144
+ proto.getDefaultDocument = function() {
145
+ const doc = origGetDefaultDocument.call(this);
146
+ ensureHead(doc);
147
+ patchElementLayout(doc);
148
+ return doc;
149
+ };
150
+ return true;
151
+ };
152
+ export {
153
+ applyPatches
154
+ };
155
+
156
+ //# debugId=CE12054E3565B4C864756E2164756E21
157
+ //# sourceMappingURL=angularPatch-arh4sr68.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/angular/angularPatch.ts"],
4
+ "sourcesContent": [
5
+ "import { resolveAngularRuntimePath } from './resolveAngularPackage';\nimport { isProductionRuntime } from '../utils/runtimeMode';\n\n// Patches Angular SSR's DominoAdapter to guard against null doc.head\n\nconst ensureHead = (doc: Document) => {\n\tif (!doc || doc.head || !doc.documentElement) {\n\t\treturn;\n\t}\n\n\tconst head = doc.createElement('head');\n\tdoc.documentElement.insertBefore(head, doc.documentElement.firstChild);\n};\n\n// Domino's Element does not implement layout APIs that browser components\n// (e.g. ngx-datatable, swiper, drag-drop) call eagerly during change detection.\n// Returning a zeroed DOMRect lets those components render in SSR without\n// crashing — the real values get computed once the page hydrates client-side.\nconst SSR_LAYOUT_RECT = Object.freeze({\n\tbottom: 0,\n\theight: 0,\n\tleft: 0,\n\tright: 0,\n\ttop: 0,\n\twidth: 0,\n\tx: 0,\n\ty: 0,\n\ttoJSON() {\n\t\treturn this;\n\t}\n});\nlet layoutPatchApplied = false;\nconst collectPrototypeChain = (instance: object | null) => {\n\tconst protos: object[] = [];\n\tlet current: object | null = instance\n\t\t? Object.getPrototypeOf(instance)\n\t\t: null;\n\twhile (current && current !== Object.prototype) {\n\t\tprotos.push(current);\n\t\tcurrent = Object.getPrototypeOf(current);\n\t}\n\n\treturn protos;\n};\n\nconst patchElementLayout = (doc: Document) => {\n\tif (layoutPatchApplied || !doc) {\n\t\treturn;\n\t}\n\tlet element: Element;\n\ttry {\n\t\telement = doc.createElement('div');\n\t} catch {\n\t\treturn;\n\t}\n\t// Walk the entire prototype chain so HTMLElement → Element → Node all get\n\t// the layout shims. Domino's base Element.prototype is several hops above\n\t// HTMLDivElement.prototype, and 3rd-party libs call methods anywhere along\n\t// the chain.\n\tconst protos = collectPrototypeChain(element);\n\tif (protos.length === 0) return;\n\n\tconst copyLayoutRect = (rect: typeof SSR_LAYOUT_RECT) => ({ ...rect });\n\tconst createLayoutRect = () => copyLayoutRect(SSR_LAYOUT_RECT);\n\tconst getClientRects = () => [];\n\tconst noop = () => undefined;\n\tconst numericProps = [\n\t\t'clientWidth',\n\t\t'clientHeight',\n\t\t'clientLeft',\n\t\t'clientTop',\n\t\t'offsetWidth',\n\t\t'offsetHeight',\n\t\t'offsetLeft',\n\t\t'offsetTop',\n\t\t'scrollWidth',\n\t\t'scrollHeight',\n\t\t'scrollLeft',\n\t\t'scrollTop'\n\t];\n\n\tfor (const proto of protos) {\n\t\tconst define = (name: string, value: unknown) => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(proto, name);\n\t\t\tif (typeof descriptor?.value === 'function') return;\n\n\t\t\tObject.defineProperty(proto, name, {\n\t\t\t\tconfigurable: true,\n\t\t\t\tvalue,\n\t\t\t\twritable: true\n\t\t\t});\n\t\t};\n\n\t\tdefine('getBoundingClientRect', createLayoutRect);\n\t\tdefine('getClientRects', getClientRects);\n\t\tdefine('scrollTo', noop);\n\t\tdefine('scrollBy', noop);\n\t\tdefine('scrollIntoView', noop);\n\t\tdefine('focus', noop);\n\t\tdefine('blur', noop);\n\n\t\tfor (const prop of numericProps) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop);\n\t\t\tif (desc) continue;\n\t\t\tObject.defineProperty(proto, prop, {\n\t\t\t\tconfigurable: true,\n\t\t\t\tget: () => 0\n\t\t\t});\n\t\t}\n\t}\n\n\tlayoutPatchApplied = true;\n};\n\nexport const applyPatches = async () => {\n\t// §1.1 — bare specifier in dev shares Bun's module cache with bundled\n\t// server pages. Production stays on the resolved vendor path. Use\n\t// `isProductionRuntime()` instead of a direct `process.env.NODE_ENV`\n\t// read so Bun's bundler doesn't constant-fold this branch out of\n\t// dist/ at absolutejs build time.\n\tconst spec = isProductionRuntime()\n\t\t? resolveAngularRuntimePath('@angular/platform-server')\n\t\t: '@angular/platform-server';\n\tconst { ɵDominoAdapter } = await import(spec);\n\tif (!ɵDominoAdapter?.prototype) {\n\t\tconsole.warn(\n\t\t\t'[Angular Patch] ɵDominoAdapter not found, skipping patches'\n\t\t);\n\n\t\treturn false;\n\t}\n\n\t// Patch the layout shims onto Domino's Element prototypes immediately\n\t// (don't wait for the first createHtmlDocument call). Components that\n\t// hold an ElementRef from the very first change-detection pass call\n\t// these methods before the lazy patch path would have run.\n\ttry {\n\t\tconst adapter = new ɵDominoAdapter();\n\t\tconst resolveSeedDoc = () => {\n\t\t\tif (typeof adapter.createHtmlDocument === 'function')\n\t\t\t\treturn adapter.createHtmlDocument();\n\t\t\tif (typeof adapter.getDefaultDocument === 'function')\n\t\t\t\treturn adapter.getDefaultDocument();\n\n\t\t\treturn null;\n\t\t};\n\t\tconst seedDoc = resolveSeedDoc();\n\t\tif (seedDoc) {\n\t\t\tpatchElementLayout(seedDoc);\n\t\t\tconst probe = seedDoc.createElement('div');\n\t\t\tif (typeof probe.getBoundingClientRect !== 'function') {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'[Angular Patch] Layout shim did not stick on probe element prototype chain'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconsole.warn(\n\t\t\t'[Angular Patch] Could not eagerly patch Element prototypes:',\n\t\t\terror\n\t\t);\n\t}\n\n\tconst proto = ɵDominoAdapter.prototype;\n\n\tconst origGetBaseHref = proto.getBaseHref;\n\tproto.getBaseHref = function (doc: Document) {\n\t\tif (!doc || !doc.head || typeof doc.head.children === 'undefined') {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn origGetBaseHref.call(this, doc);\n\t};\n\n\tconst origCreateHtmlDocument = proto.createHtmlDocument;\n\tproto.createHtmlDocument = function () {\n\t\tconst doc = origCreateHtmlDocument.call(this);\n\t\tensureHead(doc);\n\t\tpatchElementLayout(doc);\n\n\t\treturn doc;\n\t};\n\n\tconst origGetDefaultDocument = proto.getDefaultDocument;\n\tproto.getDefaultDocument = function () {\n\t\tconst doc = origGetDefaultDocument.call(this);\n\t\tensureHead(doc);\n\t\tpatchElementLayout(doc);\n\n\t\treturn doc;\n\t};\n\n\treturn true;\n};\n"
6
+ ],
7
+ "mappings": ";;;;;;;AAKA,IAAM,aAAa,CAAC,QAAkB;AAAA,EACrC,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,iBAAiB;AAAA,IAC7C;AAAA,EACD;AAAA,EAEA,MAAM,OAAO,IAAI,cAAc,MAAM;AAAA,EACrC,IAAI,gBAAgB,aAAa,MAAM,IAAI,gBAAgB,UAAU;AAAA;AAOtE,IAAM,kBAAkB,OAAO,OAAO;AAAA,EACrC,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,OAAO;AAAA,EACP,GAAG;AAAA,EACH,GAAG;AAAA,EACH,MAAM,GAAG;AAAA,IACR,OAAO;AAAA;AAET,CAAC;AACD,IAAI,qBAAqB;AACzB,IAAM,wBAAwB,CAAC,aAA4B;AAAA,EAC1D,MAAM,SAAmB,CAAC;AAAA,EAC1B,IAAI,UAAyB,WAC1B,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AAC,IAAI,QAAQ,OAAO,IAAI,KAAK,aAAa,aAAa;AAAA,MAClE,OAAO;AAAA,IACR;AAAA,IAEA,OAAO,gBAAgB,KAAK,MAAM,GAAG;AAAA;AAAA,EAGtC,MAAM,yBAAyB,MAAM;AAAA,EACrC,MAAM,qBAAqB,QAAS,GAAG;AAAA,IACtC,MAAM,MAAM,uBAAuB,KAAK,IAAI;AAAA,IAC5C,WAAW,GAAG;AAAA,IACd,mBAAmB,GAAG;AAAA,IAEtB,OAAO;AAAA;AAAA,EAGR,MAAM,yBAAyB,MAAM;AAAA,EACrC,MAAM,qBAAqB,QAAS,GAAG;AAAA,IACtC,MAAM,MAAM,uBAAuB,KAAK,IAAI;AAAA,IAC5C,WAAW,GAAG;AAAA,IACd,mBAAmB,GAAG;AAAA,IAEtB,OAAO;AAAA;AAAA,EAGR,OAAO;AAAA;",
8
+ "debugId": "CE12054E3565B4C864756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,87 @@
1
+ // src/client/browserTranslation.ts
2
+ var translationRestorer = (restore, hasTranslation) => Object.assign(restore, { hasTranslation });
3
+ var emptyTranslationRestorer = () => translationRestorer(() => {
4
+ return;
5
+ }, false);
6
+ var textNodeAt = (parent, index) => {
7
+ const node = parent.childNodes[index];
8
+ return node instanceof Text ? node : undefined;
9
+ };
10
+ var visitElements = (root, visit) => {
11
+ visit(root);
12
+ for (const element of root.querySelectorAll("*"))
13
+ visit(element);
14
+ };
15
+ var elementPath = (root, element) => {
16
+ const path = [];
17
+ let current = element;
18
+ while (current !== root) {
19
+ const parent = current.parentElement;
20
+ if (parent === null)
21
+ return null;
22
+ path.unshift([...parent.children].indexOf(current));
23
+ current = parent;
24
+ }
25
+ return path;
26
+ };
27
+ var elementAtPath = (root, path) => {
28
+ let current = root;
29
+ for (const index of path) {
30
+ const child = current.children[index];
31
+ if (!(child instanceof Element))
32
+ return null;
33
+ current = child;
34
+ }
35
+ return current;
36
+ };
37
+ var captureSsrTextBaselines = (root) => {
38
+ if (root === null || typeof window === "undefined")
39
+ return;
40
+ const baselines = window.__ABSOLUTE_SSR_TEXT_BASELINES__ ?? new WeakMap;
41
+ visitElements(root, (element) => {
42
+ const text = new Map;
43
+ for (const [index, node] of [...element.childNodes].entries()) {
44
+ if (node.nodeType === Node.TEXT_NODE)
45
+ text.set(index, node.nodeValue ?? "");
46
+ }
47
+ if (text.size > 0)
48
+ baselines.set(element, text);
49
+ });
50
+ window.__ABSOLUTE_SSR_TEXT_BASELINES__ = baselines;
51
+ };
52
+ var prepareBrowserTranslationHydration = (root) => {
53
+ if (root === null || typeof window === "undefined")
54
+ return emptyTranslationRestorer();
55
+ const baselines = window.__ABSOLUTE_SSR_TEXT_BASELINES__;
56
+ if (baselines === undefined)
57
+ return emptyTranslationRestorer();
58
+ const translated = [];
59
+ visitElements(root, (element) => {
60
+ const text = baselines.get(element);
61
+ const path = elementPath(root, element);
62
+ if (text === undefined || path === null)
63
+ return;
64
+ for (const [index, baseline] of text) {
65
+ const node = textNodeAt(element, index);
66
+ if (node === undefined || node.data === baseline)
67
+ continue;
68
+ translated.push({ baseline, index, path, translated: node.data });
69
+ node.data = baseline;
70
+ }
71
+ });
72
+ return translationRestorer(() => {
73
+ for (const snapshot of translated) {
74
+ const parent = elementAtPath(root, snapshot.path);
75
+ if (parent === null)
76
+ continue;
77
+ const node = textNodeAt(parent, snapshot.index);
78
+ if (node !== undefined && node.data === snapshot.baseline)
79
+ node.data = snapshot.translated;
80
+ }
81
+ }, translated.length > 0);
82
+ };
83
+
84
+ export { captureSsrTextBaselines, prepareBrowserTranslationHydration };
85
+
86
+ //# debugId=7A942374163F685B64756E2164756E21
87
+ //# sourceMappingURL=index-5py90ctf.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/client/browserTranslation.ts"],
4
+ "sourcesContent": [
5
+ "type TextBaseline = ReadonlyMap<number, string>;\ntype SsrTextBaselines = WeakMap<Element, TextBaseline>;\n\ndeclare global {\n\t// Window augmentation requires interface declaration merging.\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n\tinterface Window {\n\t\t__ABSOLUTE_SSR_TEXT_BASELINES__?: SsrTextBaselines;\n\t}\n}\n\ntype TranslatedText = {\n\tbaseline: string;\n\tindex: number;\n\tpath: number[];\n\ttranslated: string;\n};\n\nconst translationRestorer = (restore: () => void, hasTranslation: boolean) =>\n\tObject.assign(restore, { hasTranslation });\n\nconst emptyTranslationRestorer = () =>\n\ttranslationRestorer(() => undefined, false);\n\nconst textNodeAt = (parent: Element, index: number) => {\n\tconst node = parent.childNodes[index];\n\n\treturn node instanceof Text ? node : undefined;\n};\n\nconst visitElements = (root: Element, visit: (element: Element) => void) => {\n\tvisit(root);\n\tfor (const element of root.querySelectorAll('*')) visit(element);\n};\n\nconst elementPath = (root: Element, element: Element) => {\n\tconst path: number[] = [];\n\tlet current = element;\n\twhile (current !== root) {\n\t\tconst parent = current.parentElement;\n\t\tif (parent === null) return null;\n\t\tpath.unshift([...parent.children].indexOf(current));\n\t\tcurrent = parent;\n\t}\n\n\treturn path;\n};\n\nconst elementAtPath = (root: Element, path: number[]) => {\n\tlet current = root;\n\tfor (const index of path) {\n\t\tconst child = current.children[index];\n\t\tif (!(child instanceof Element)) return null;\n\t\tcurrent = child;\n\t}\n\n\treturn current;\n};\n\n/** Capture server-authored text before client modules load. Absolute page\n * handlers install the same snapshot inline; this export supports custom\n * documents and non-standard bootstraps. */\nexport const captureSsrTextBaselines = (root: Element | null) => {\n\tif (root === null || typeof window === 'undefined') return;\n\tconst baselines: SsrTextBaselines =\n\t\twindow.__ABSOLUTE_SSR_TEXT_BASELINES__ ?? new WeakMap();\n\tvisitElements(root, (element) => {\n\t\tconst text = new Map<number, string>();\n\t\tfor (const [index, node] of [...element.childNodes].entries()) {\n\t\t\tif (node.nodeType === Node.TEXT_NODE)\n\t\t\t\ttext.set(index, node.nodeValue ?? '');\n\t\t}\n\t\tif (text.size > 0) baselines.set(element, text);\n\t});\n\twindow.__ABSOLUTE_SSR_TEXT_BASELINES__ = baselines;\n};\n\n/** Temporarily restore server text while a framework attaches to SSR DOM,\n * then reapply translated text. Paths preserve translations even when a\n * framework replaces nodes while mounting. Genuine server/client mismatches\n * are left unchanged. */\nexport const prepareBrowserTranslationHydration = (root: Element | null) => {\n\tif (root === null || typeof window === 'undefined')\n\t\treturn emptyTranslationRestorer();\n\tconst baselines = window.__ABSOLUTE_SSR_TEXT_BASELINES__;\n\tif (baselines === undefined) return emptyTranslationRestorer();\n\tconst translated: TranslatedText[] = [];\n\tvisitElements(root, (element) => {\n\t\tconst text = baselines.get(element);\n\t\tconst path = elementPath(root, element);\n\t\tif (text === undefined || path === null) return;\n\t\tfor (const [index, baseline] of text) {\n\t\t\tconst node = textNodeAt(element, index);\n\t\t\tif (node === undefined || node.data === baseline) continue;\n\t\t\ttranslated.push({ baseline, index, path, translated: node.data });\n\t\t\tnode.data = baseline;\n\t\t}\n\t});\n\n\treturn translationRestorer(() => {\n\t\tfor (const snapshot of translated) {\n\t\t\tconst parent = elementAtPath(root, snapshot.path);\n\t\t\tif (parent === null) continue;\n\t\t\tconst node = textNodeAt(parent, snapshot.index);\n\t\t\tif (node !== undefined && node.data === snapshot.baseline)\n\t\t\t\tnode.data = snapshot.translated;\n\t\t}\n\t}, translated.length > 0);\n};\n"
6
+ ],
7
+ "mappings": ";AAkBA,IAAM,sBAAsB,CAAC,SAAqB,mBACjD,OAAO,OAAO,SAAS,EAAE,eAAe,CAAC;AAE1C,IAAM,2BAA2B,MAChC,oBAAoB,MAAG;AAAA,EAAG;AAAA,GAAW,KAAK;AAE3C,IAAM,aAAa,CAAC,QAAiB,UAAkB;AAAA,EACtD,MAAM,OAAO,OAAO,WAAW;AAAA,EAE/B,OAAO,gBAAgB,OAAO,OAAO;AAAA;AAGtC,IAAM,gBAAgB,CAAC,MAAe,UAAsC;AAAA,EAC3E,MAAM,IAAI;AAAA,EACV,WAAW,WAAW,KAAK,iBAAiB,GAAG;AAAA,IAA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