@absolutejs/absolute 0.19.0-beta.782 → 0.19.0-beta.784

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 (254) hide show
  1. package/dist/angular/browser.js +57 -9801
  2. package/dist/angular/browser.js.map +4 -246
  3. package/dist/angular/index.js +61 -14880
  4. package/dist/angular/index.js.map +4 -282
  5. package/dist/angular/server.js +46 -5613
  6. package/dist/angular/server.js.map +3 -52
  7. package/dist/build.js +45 -17902
  8. package/dist/build.js.map +3 -100
  9. package/dist/chunk-102fp7xe.js +63 -0
  10. package/dist/chunk-102fp7xe.js.map +10 -0
  11. package/dist/chunk-11zpfqz6.js +19 -0
  12. package/dist/chunk-11zpfqz6.js.map +10 -0
  13. package/dist/chunk-1e9vsfyh.js +100 -0
  14. package/dist/chunk-1e9vsfyh.js.map +10 -0
  15. package/dist/chunk-25v9t56f.js +29 -0
  16. package/dist/chunk-25v9t56f.js.map +11 -0
  17. package/dist/chunk-2f21eenc.js +21 -0
  18. package/dist/chunk-2f21eenc.js.map +10 -0
  19. package/dist/chunk-2ga2znex.js +13 -0
  20. package/dist/chunk-2ga2znex.js.map +9 -0
  21. package/dist/chunk-30yrw0f6.js +33 -0
  22. package/dist/chunk-30yrw0f6.js.map +10 -0
  23. package/dist/chunk-3c7mpj3m.js +784 -0
  24. package/dist/chunk-3c7mpj3m.js.map +10 -0
  25. package/dist/chunk-3g91wb4f.js +358 -0
  26. package/dist/chunk-3g91wb4f.js.map +10 -0
  27. package/dist/chunk-3yjzpcne.js +34 -0
  28. package/dist/chunk-3yjzpcne.js.map +10 -0
  29. package/dist/chunk-4bq79t8v.js +136 -0
  30. package/dist/chunk-4bq79t8v.js.map +10 -0
  31. package/dist/chunk-4d39r92n.js +81 -0
  32. package/dist/chunk-4d39r92n.js.map +10 -0
  33. package/dist/chunk-4m75s5xf.js +184 -0
  34. package/dist/chunk-4m75s5xf.js.map +11 -0
  35. package/dist/chunk-5003emhv.js +17 -0
  36. package/dist/chunk-5003emhv.js.map +10 -0
  37. package/dist/chunk-5fhp1jap.js +9169 -0
  38. package/dist/chunk-5fhp1jap.js.map +236 -0
  39. package/dist/chunk-6fkgm9s5.js +569 -0
  40. package/dist/chunk-6fkgm9s5.js.map +10 -0
  41. package/dist/chunk-6pdj08z3.js +73 -0
  42. package/dist/chunk-6pdj08z3.js.map +12 -0
  43. package/dist/chunk-6qjbrt0k.js +13 -0
  44. package/dist/chunk-6qjbrt0k.js.map +9 -0
  45. package/dist/chunk-6sccb4jr.js +14 -0
  46. package/dist/chunk-6sccb4jr.js.map +9 -0
  47. package/dist/chunk-73brtyw5.js +16 -0
  48. package/dist/chunk-73brtyw5.js.map +9 -0
  49. package/dist/chunk-77cqkarb.js +25 -0
  50. package/dist/chunk-77cqkarb.js.map +9 -0
  51. package/dist/chunk-798spvzv.js +50 -0
  52. package/dist/chunk-798spvzv.js.map +10 -0
  53. package/dist/chunk-7fw6x3js.js +131 -0
  54. package/dist/chunk-7fw6x3js.js.map +11 -0
  55. package/dist/chunk-7kjj42xm.js +11 -0
  56. package/dist/chunk-7kjj42xm.js.map +10 -0
  57. package/dist/chunk-851whwc7.js +17 -0
  58. package/dist/chunk-851whwc7.js.map +10 -0
  59. package/dist/chunk-85n68sy6.js +103 -0
  60. package/dist/chunk-85n68sy6.js.map +10 -0
  61. package/dist/chunk-8feq2qek.js +17 -0
  62. package/dist/chunk-8feq2qek.js.map +9 -0
  63. package/dist/chunk-8kcfffry.js +35 -0
  64. package/dist/chunk-8kcfffry.js.map +10 -0
  65. package/dist/chunk-93sqk7be.js +139 -0
  66. package/dist/chunk-93sqk7be.js.map +12 -0
  67. package/dist/chunk-97572s32.js +262 -0
  68. package/dist/chunk-97572s32.js.map +12 -0
  69. package/dist/chunk-9a307ca6.js +1742 -0
  70. package/dist/chunk-9a307ca6.js.map +11 -0
  71. package/dist/chunk-9c5tj4k3.js +130 -0
  72. package/dist/chunk-9c5tj4k3.js.map +10 -0
  73. package/dist/chunk-9xrsjeem.js +12 -0
  74. package/dist/chunk-9xrsjeem.js.map +9 -0
  75. package/dist/chunk-a9mvyp04.js +87 -0
  76. package/dist/chunk-a9mvyp04.js.map +10 -0
  77. package/dist/chunk-b3gbnrwe.js +21 -0
  78. package/dist/chunk-b3gbnrwe.js.map +10 -0
  79. package/dist/chunk-bmgqm774.js +65 -0
  80. package/dist/chunk-bmgqm774.js.map +9 -0
  81. package/dist/chunk-bxfghpma.js +69 -0
  82. package/dist/chunk-bxfghpma.js.map +10 -0
  83. package/dist/chunk-c1jfjnka.js +74 -0
  84. package/dist/chunk-c1jfjnka.js.map +10 -0
  85. package/dist/chunk-cbkrwmvh.js +80 -0
  86. package/dist/chunk-cbkrwmvh.js.map +10 -0
  87. package/dist/chunk-cdxd7sy2.js +71 -0
  88. package/dist/chunk-cdxd7sy2.js.map +10 -0
  89. package/dist/chunk-cg95827x.js +21 -0
  90. package/dist/chunk-cg95827x.js.map +10 -0
  91. package/dist/chunk-d9c0am65.js +12 -0
  92. package/dist/chunk-d9c0am65.js.map +10 -0
  93. package/dist/chunk-daqghmg8.js +12 -0
  94. package/dist/chunk-daqghmg8.js.map +9 -0
  95. package/dist/chunk-dr9yqsdb.js +203 -0
  96. package/dist/chunk-dr9yqsdb.js.map +10 -0
  97. package/dist/chunk-e8eecyrq.js +244 -0
  98. package/dist/chunk-e8eecyrq.js.map +10 -0
  99. package/dist/chunk-ex2hxe0v.js +160 -0
  100. package/dist/chunk-ex2hxe0v.js.map +11 -0
  101. package/dist/chunk-ey5hs6x6.js +253 -0
  102. package/dist/chunk-ey5hs6x6.js.map +11 -0
  103. package/dist/chunk-fak944et.js +91 -0
  104. package/dist/chunk-fak944et.js.map +10 -0
  105. package/dist/chunk-fygx2ymm.js +118 -0
  106. package/dist/chunk-fygx2ymm.js.map +12 -0
  107. package/dist/chunk-g15qj669.js +271 -0
  108. package/dist/chunk-g15qj669.js.map +11 -0
  109. package/dist/chunk-g3j22qf6.js +51 -0
  110. package/dist/chunk-g3j22qf6.js.map +9 -0
  111. package/dist/chunk-gd6wmknh.js +121 -0
  112. package/dist/chunk-gd6wmknh.js.map +11 -0
  113. package/dist/chunk-gf0ygptk.js +85 -0
  114. package/dist/chunk-gf0ygptk.js.map +11 -0
  115. package/dist/chunk-gq0zxpm0.js +90 -0
  116. package/dist/chunk-gq0zxpm0.js.map +10 -0
  117. package/dist/chunk-gytkmthr.js +220 -0
  118. package/dist/chunk-gytkmthr.js.map +10 -0
  119. package/dist/chunk-h5bbfn3n.js +28 -0
  120. package/dist/chunk-h5bbfn3n.js.map +11 -0
  121. package/dist/chunk-h6mye9r3.js +93 -0
  122. package/dist/chunk-h6mye9r3.js.map +10 -0
  123. package/dist/chunk-hcsmxw1v.js +85 -0
  124. package/dist/chunk-hcsmxw1v.js.map +10 -0
  125. package/dist/chunk-hep68ja7.js +4444 -0
  126. package/dist/chunk-hep68ja7.js.map +29 -0
  127. package/dist/chunk-hhqh49fz.js +149 -0
  128. package/dist/chunk-hhqh49fz.js.map +10 -0
  129. package/dist/chunk-hyjs4bqs.js +8 -0
  130. package/dist/chunk-hyjs4bqs.js.map +10 -0
  131. package/dist/chunk-hza0n8qm.js +20 -0
  132. package/dist/chunk-hza0n8qm.js.map +9 -0
  133. package/dist/chunk-jn91vzkh.js +66 -0
  134. package/dist/chunk-jn91vzkh.js.map +10 -0
  135. package/dist/chunk-jwxt8gnp.js +13 -0
  136. package/dist/chunk-jwxt8gnp.js.map +9 -0
  137. package/dist/chunk-kk8w9rh5.js +195 -0
  138. package/dist/chunk-kk8w9rh5.js.map +10 -0
  139. package/dist/chunk-kndkjsya.js +261 -0
  140. package/dist/chunk-kndkjsya.js.map +10 -0
  141. package/dist/chunk-kvq01j35.js +36 -0
  142. package/dist/chunk-kvq01j35.js.map +10 -0
  143. package/dist/chunk-mbazhahf.js +60 -0
  144. package/dist/chunk-mbazhahf.js.map +10 -0
  145. package/dist/chunk-mgfwq18r.js +15 -0
  146. package/dist/chunk-mgfwq18r.js.map +9 -0
  147. package/dist/chunk-mtgf69xn.js +88 -0
  148. package/dist/chunk-mtgf69xn.js.map +10 -0
  149. package/dist/chunk-nehhtthw.js +225 -0
  150. package/dist/chunk-nehhtthw.js.map +10 -0
  151. package/dist/chunk-nhzf4az4.js +149 -0
  152. package/dist/chunk-nhzf4az4.js.map +10 -0
  153. package/dist/chunk-p5504p14.js +16 -0
  154. package/dist/chunk-p5504p14.js.map +10 -0
  155. package/dist/chunk-pnscgw95.js +90 -0
  156. package/dist/chunk-pnscgw95.js.map +10 -0
  157. package/dist/chunk-pvpp4pvs.js +17 -0
  158. package/dist/chunk-pvpp4pvs.js.map +10 -0
  159. package/dist/chunk-qh75agse.js +95 -0
  160. package/dist/chunk-qh75agse.js.map +10 -0
  161. package/dist/chunk-qk8kd3hr.js +526 -0
  162. package/dist/chunk-qk8kd3hr.js.map +12 -0
  163. package/dist/chunk-qxq2zcty.js +52 -0
  164. package/dist/chunk-qxq2zcty.js.map +10 -0
  165. package/dist/chunk-r7jmgqnw.js +114 -0
  166. package/dist/chunk-r7jmgqnw.js.map +10 -0
  167. package/dist/chunk-s6defjk2.js +116 -0
  168. package/dist/chunk-s6defjk2.js.map +10 -0
  169. package/dist/chunk-sd39p726.js +619 -0
  170. package/dist/chunk-sd39p726.js.map +10 -0
  171. package/dist/chunk-smgj0epn.js +18 -0
  172. package/dist/chunk-smgj0epn.js.map +9 -0
  173. package/dist/chunk-swrnzs4c.js +63 -0
  174. package/dist/chunk-swrnzs4c.js.map +10 -0
  175. package/dist/chunk-t81a331y.js +27 -0
  176. package/dist/chunk-t81a331y.js.map +10 -0
  177. package/dist/chunk-tfe3sb44.js +33 -0
  178. package/dist/chunk-tfe3sb44.js.map +10 -0
  179. package/dist/chunk-tx9edm1x.js +34 -0
  180. package/dist/chunk-tx9edm1x.js.map +10 -0
  181. package/dist/chunk-vkrpm7kc.js +247 -0
  182. package/dist/chunk-vkrpm7kc.js.map +12 -0
  183. package/dist/chunk-vvz7dcvq.js +434 -0
  184. package/dist/chunk-vvz7dcvq.js.map +13 -0
  185. package/dist/chunk-w3m4m5we.js +4925 -0
  186. package/dist/chunk-w3m4m5we.js.map +12 -0
  187. package/dist/chunk-wrxtn9ve.js +18 -0
  188. package/dist/chunk-wrxtn9ve.js.map +10 -0
  189. package/dist/chunk-xpkjbmd3.js +428 -0
  190. package/dist/chunk-xpkjbmd3.js.map +14 -0
  191. package/dist/chunk-xrmjy8kk.js +454 -0
  192. package/dist/chunk-xrmjy8kk.js.map +10 -0
  193. package/dist/chunk-xw0tx842.js +13 -0
  194. package/dist/chunk-xw0tx842.js.map +9 -0
  195. package/dist/chunk-xx5b6b9m.js +69 -0
  196. package/dist/chunk-xx5b6b9m.js.map +10 -0
  197. package/dist/chunk-xz1kdswj.js +21 -0
  198. package/dist/chunk-xz1kdswj.js.map +9 -0
  199. package/dist/chunk-xzvy9hr4.js +377 -0
  200. package/dist/chunk-xzvy9hr4.js.map +10 -0
  201. package/dist/chunk-yfqhr31t.js +39 -0
  202. package/dist/chunk-yfqhr31t.js.map +9 -0
  203. package/dist/chunk-ygzd5s4z.js +184 -0
  204. package/dist/chunk-ygzd5s4z.js.map +10 -0
  205. package/dist/chunk-ywjn0rad.js +14 -0
  206. package/dist/chunk-ywjn0rad.js.map +9 -0
  207. package/dist/chunk-z9nvhm6r.js +13 -0
  208. package/dist/chunk-z9nvhm6r.js.map +9 -0
  209. package/dist/chunk-zhmvdpk6.js +15 -0
  210. package/dist/chunk-zhmvdpk6.js.map +9 -0
  211. package/dist/cli/index.js +6 -3
  212. package/dist/client/index.js +32 -1112
  213. package/dist/client/index.js.map +4 -22
  214. package/dist/core/streamingSlotRegistrar.js +11 -108
  215. package/dist/core/streamingSlotRegistrar.js.map +3 -4
  216. package/dist/core/streamingSlotRegistry.js +7 -169
  217. package/dist/core/streamingSlotRegistry.js.map +3 -5
  218. package/dist/index.js +537 -19714
  219. package/dist/index.js.map +3 -117
  220. package/dist/islands/browser.js +9 -228
  221. package/dist/islands/browser.js.map +4 -9
  222. package/dist/islands/index.js +18 -1900
  223. package/dist/islands/index.js.map +3 -28
  224. package/dist/react/browser.js +12 -328
  225. package/dist/react/browser.js.map +4 -12
  226. package/dist/react/components/index.js +16 -167
  227. package/dist/react/components/index.js.map +3 -6
  228. package/dist/react/hooks/index.js +8 -183
  229. package/dist/react/hooks/index.js.map +3 -7
  230. package/dist/react/index.js +37 -3619
  231. package/dist/react/index.js.map +4 -46
  232. package/dist/react/jsxDevRuntimeCompat.js +2 -61
  233. package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
  234. package/dist/react/server.js +18 -1789
  235. package/dist/react/server.js.map +3 -21
  236. package/dist/src/build/stylePreprocessor.d.ts +3 -0
  237. package/dist/src/core/index.d.ts +0 -2
  238. package/dist/svelte/browser.js +12 -247
  239. package/dist/svelte/browser.js.map +3 -10
  240. package/dist/svelte/index.js +38 -3724
  241. package/dist/svelte/index.js.map +4 -48
  242. package/dist/svelte/server.js +22 -2701
  243. package/dist/svelte/server.js.map +3 -27
  244. package/dist/vue/browser.js +12 -348
  245. package/dist/vue/browser.js.map +4 -12
  246. package/dist/vue/components/Image.js +7 -240
  247. package/dist/vue/components/Image.js.map +3 -6
  248. package/dist/vue/components/index.js +11 -544
  249. package/dist/vue/components/index.js.map +3 -9
  250. package/dist/vue/index.js +53 -4204
  251. package/dist/vue/index.js.map +4 -51
  252. package/dist/vue/server.js +18 -1849
  253. package/dist/vue/server.js.map +3 -21
  254. package/package.json +7 -7
@@ -0,0 +1,160 @@
1
+ // @bun
2
+ import {
3
+ getMimeType,
4
+ handleClientConnect,
5
+ handleClientDisconnect,
6
+ handleHMRMessage,
7
+ lookupAsset
8
+ } from "./chunk-vkrpm7kc.js";
9
+ import"./chunk-h5bbfn3n.js";
10
+ import"./chunk-cbkrwmvh.js";
11
+ import"./chunk-gf0ygptk.js";
12
+ import {
13
+ UNFOUND_INDEX
14
+ } from "./chunk-qh75agse.js";
15
+ import {
16
+ __require
17
+ } from "./chunk-bmgqm774.js";
18
+
19
+ // src/plugins/hmr.ts
20
+ import Elysia from "elysia";
21
+
22
+ // src/react/bridgeInternals.ts
23
+ var INTERNALS_KEYS = [
24
+ "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE",
25
+ "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"
26
+ ];
27
+ var isRecord = (val) => typeof val === "object" && val !== null;
28
+ var findInternals = (mod) => {
29
+ for (const key of INTERNALS_KEYS) {
30
+ const val = mod[key];
31
+ if (isRecord(val))
32
+ return val;
33
+ }
34
+ return;
35
+ };
36
+ var bridgeReactInternals = async () => {
37
+ const pinnedRef = globalThis.__reactModuleRef;
38
+ if (!isRecord(pinnedRef))
39
+ return;
40
+ const react = await import("react");
41
+ if (pinnedRef === react)
42
+ return;
43
+ const pinnedInternals = findInternals(pinnedRef);
44
+ const currentInternals = findInternals(react);
45
+ if (!pinnedInternals || !currentInternals || pinnedInternals === currentInternals)
46
+ return;
47
+ for (const prop of Object.keys(pinnedInternals)) {
48
+ Object.defineProperty(currentInternals, prop, {
49
+ configurable: true,
50
+ enumerable: true,
51
+ get() {
52
+ return pinnedInternals[prop];
53
+ },
54
+ set(value) {
55
+ pinnedInternals[prop] = value;
56
+ }
57
+ });
58
+ }
59
+ };
60
+
61
+ // src/plugins/hmr.ts
62
+ var STORE_KEY = "__elysiaStore";
63
+ var getGlobalValue = (key) => Reflect.get(globalThis, key);
64
+ var restoreStore = (store) => {
65
+ const saved = getGlobalValue(STORE_KEY);
66
+ if (saved && typeof saved === "object") {
67
+ restoreSavedStoreValues(store, saved);
68
+ }
69
+ if (store && typeof store === "object") {
70
+ Reflect.set(globalThis, STORE_KEY, store);
71
+ }
72
+ };
73
+ var restoreSavedStoreValues = (store, saved) => {
74
+ if (!store || typeof store !== "object") {
75
+ return;
76
+ }
77
+ Object.entries(saved).forEach(([key, value]) => {
78
+ Reflect.set(store, key, value);
79
+ });
80
+ };
81
+ var resolveModuleResponse = (moduleResponse, ifNoneMatch) => {
82
+ const etag = moduleResponse.headers.get("ETag");
83
+ if (etag && ifNoneMatch === etag) {
84
+ return new Response(null, { headers: { ETag: etag }, status: 304 });
85
+ }
86
+ return moduleResponse;
87
+ };
88
+ var resolveRequestPathname = (request) => {
89
+ const rawUrl = request.url;
90
+ const qIdx = rawUrl.indexOf("?");
91
+ const pathEnd = qIdx === UNFOUND_INDEX ? rawUrl.length : qIdx;
92
+ const pathStart = rawUrl.indexOf("/", rawUrl.indexOf("//") + 2);
93
+ return rawUrl.slice(pathStart, pathEnd);
94
+ };
95
+ var resolveDevAssetResponse = async (request, hmrState, moduleServerHandler) => {
96
+ const pathname = resolveRequestPathname(request);
97
+ if (moduleServerHandler) {
98
+ const moduleResponse = await moduleServerHandler(pathname);
99
+ if (moduleResponse) {
100
+ return resolveModuleResponse(moduleResponse, request.headers.get("If-None-Match"));
101
+ }
102
+ }
103
+ const bytes = lookupAsset(hmrState.assetStore, pathname);
104
+ if (bytes) {
105
+ return new Response(new Uint8Array(bytes).buffer, {
106
+ headers: {
107
+ "Cache-Control": "no-cache",
108
+ "Content-Type": getMimeType(pathname)
109
+ }
110
+ });
111
+ }
112
+ const aliasedTarget = resolveHashlessAlias(hmrState, pathname);
113
+ if (aliasedTarget) {
114
+ return new Response(null, {
115
+ headers: {
116
+ "Cache-Control": "no-cache",
117
+ Location: aliasedTarget
118
+ },
119
+ status: 302
120
+ });
121
+ }
122
+ return;
123
+ };
124
+ var HASHLESS_INDEX_PATH_PATTERN = /^(\/[^/]+)?\/indexes\/([^/.]+)\/?$/;
125
+ var resolveHashlessAlias = (hmrState, pathname) => {
126
+ const match = pathname.match(HASHLESS_INDEX_PATH_PATTERN);
127
+ if (!match)
128
+ return null;
129
+ const prefix = `${match[1] ?? ""}/indexes/${match[2]}.`;
130
+ for (const candidate of hmrState.assetStore.keys()) {
131
+ if (candidate.startsWith(prefix))
132
+ return candidate;
133
+ }
134
+ return null;
135
+ };
136
+ var hmr = (hmrState, manifest, moduleServerHandler) => new Elysia({ name: "absolutejs-hmr" }).onStart(({ store }) => {
137
+ restoreStore(store);
138
+ }).onRequest(async ({ request }) => {
139
+ if (globalThis.__reactModuleRef) {
140
+ await bridgeReactInternals();
141
+ }
142
+ return resolveDevAssetResponse(request, hmrState, moduleServerHandler);
143
+ }).get("/@src/*", ({ request }) => resolveDevAssetResponse(request, hmrState, moduleServerHandler)).get("/@stub/*", ({ request }) => resolveDevAssetResponse(request, hmrState, moduleServerHandler)).get("/@hmr/*", ({ request }) => resolveDevAssetResponse(request, hmrState, moduleServerHandler)).ws("/hmr", {
144
+ close: (ws) => handleClientDisconnect(hmrState, ws),
145
+ message: (ws, msg) => handleHMRMessage(hmrState, ws, msg),
146
+ open: (ws) => handleClientConnect(hmrState, ws, manifest)
147
+ }).get("/hmr-status", () => ({
148
+ connectedClients: hmrState.connectedClients.size,
149
+ isRebuilding: hmrState.isRebuilding,
150
+ manifestKeys: Object.keys(manifest),
151
+ rebuildCount: hmrState.rebuildCount,
152
+ rebuildQueue: Array.from(hmrState.rebuildQueue),
153
+ timestamp: Date.now()
154
+ }));
155
+ export {
156
+ hmr
157
+ };
158
+
159
+ //# debugId=4B480B1E52FA111664756E2164756E21
160
+ //# sourceMappingURL=chunk-ex2hxe0v.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/plugins/hmr.ts", "../src/react/bridgeInternals.ts"],
4
+ "sourcesContent": [
5
+ "import Elysia from 'elysia';\nimport { UNFOUND_INDEX } from '../constants';\nimport type { HMRState } from '../dev/clientManager';\nimport { getMimeType, lookupAsset } from '../dev/assetStore';\nimport { bridgeReactInternals } from '../react/bridgeInternals';\nimport {\n\thandleClientConnect,\n\thandleClientDisconnect,\n\thandleHMRMessage\n} from '../dev/webSocket';\n\nconst STORE_KEY = '__elysiaStore';\n\n/* Preserve Elysia store across bun --hot reloads.\n globalThis survives re-evaluation, so we save the store reference\n before each reload and restore values into the fresh instance. */\nconst getGlobalValue = (key: string) => Reflect.get(globalThis, key);\n\nconst restoreStore = (store: unknown) => {\n\tconst saved = getGlobalValue(STORE_KEY);\n\n\tif (saved && typeof saved === 'object') {\n\t\trestoreSavedStoreValues(store, saved);\n\t}\n\n\tif (store && typeof store === 'object') {\n\t\tReflect.set(globalThis, STORE_KEY, store);\n\t}\n};\n\nconst restoreSavedStoreValues = (store: unknown, saved: object) => {\n\tif (!store || typeof store !== 'object') {\n\t\treturn;\n\t}\n\n\tObject.entries(saved).forEach(([key, value]) => {\n\t\tReflect.set(store, key, value);\n\t});\n};\n\nconst resolveModuleResponse = (\n\tmoduleResponse: Response,\n\tifNoneMatch: string | null\n) => {\n\tconst etag = moduleResponse.headers.get('ETag');\n\n\tif (etag && ifNoneMatch === etag) {\n\t\treturn new Response(null, { headers: { ETag: etag }, status: 304 });\n\t}\n\n\treturn moduleResponse;\n};\n\nconst resolveRequestPathname = (request: Request) => {\n\tconst rawUrl = request.url;\n\tconst qIdx = rawUrl.indexOf('?');\n\tconst pathEnd = qIdx === UNFOUND_INDEX ? rawUrl.length : qIdx;\n\tconst pathStart = rawUrl.indexOf('/', rawUrl.indexOf('//') + 2);\n\n\treturn rawUrl.slice(pathStart, pathEnd);\n};\n\nconst resolveDevAssetResponse = async (\n\trequest: Request,\n\thmrState: HMRState,\n\tmoduleServerHandler?: (\n\t\tpathname: string\n\t) => Promise<Response | undefined> | Response | undefined\n) => {\n\tconst pathname = resolveRequestPathname(request);\n\n\tif (moduleServerHandler) {\n\t\tconst moduleResponse = await moduleServerHandler(pathname);\n\n\t\tif (moduleResponse) {\n\t\t\treturn resolveModuleResponse(\n\t\t\t\tmoduleResponse,\n\t\t\t\trequest.headers.get('If-None-Match')\n\t\t\t);\n\t\t}\n\t\t// Fall through: moduleServerHandler only handles /@src/, /@stub/,\n\t\t// /@hmr/ prefixes. Other paths (like /generated/indexes/<hash>.js\n\t\t// emitted by HMR rebuilds) need to be served from the asset store —\n\t\t// the upstream `staticPlugin({ alwaysStatic: true })` only registers\n\t\t// files that existed at server start, so HMR-emitted chunks aren't\n\t\t// in those routes.\n\t}\n\n\tconst bytes = lookupAsset(hmrState.assetStore, pathname);\n\tif (bytes) {\n\t\treturn new Response(new Uint8Array(bytes).buffer, {\n\t\t\theaders: {\n\t\t\t\t'Cache-Control': 'no-cache',\n\t\t\t\t'Content-Type': getMimeType(pathname)\n\t\t\t}\n\t\t});\n\t}\n\n\t// Fallback for hashless asset URLs like `/indexes/less-page` (no `.css`,\n\t// no hash). These can show up briefly when an HMR client tracks a\n\t// stylesheet by base name and the hash rotated between when the link\n\t// was rendered and when the request was issued. Redirect to the current\n\t// hashed path so the browser still gets the right CSS instead of a 404.\n\tconst aliasedTarget = resolveHashlessAlias(hmrState, pathname);\n\tif (aliasedTarget) {\n\t\treturn new Response(null, {\n\t\t\theaders: {\n\t\t\t\t'Cache-Control': 'no-cache',\n\t\t\t\tLocation: aliasedTarget\n\t\t\t},\n\t\t\tstatus: 302\n\t\t});\n\t}\n\n\treturn undefined;\n};\n\nconst HASHLESS_INDEX_PATH_PATTERN = /^(\\/[^/]+)?\\/indexes\\/([^/.]+)\\/?$/;\n\n/* If the pathname looks like `/indexes/<base>` (or `/<framework>/indexes/<base>`)\n with no extension, look for an asset whose path prefix matches and return\n that path. Returns null if there's no match — caller falls back to 404. */\nconst resolveHashlessAlias = (hmrState: HMRState, pathname: string) => {\n\tconst match = pathname.match(HASHLESS_INDEX_PATH_PATTERN);\n\tif (!match) return null;\n\tconst prefix = `${match[1] ?? ''}/indexes/${match[2]}.`;\n\tfor (const candidate of hmrState.assetStore.keys()) {\n\t\tif (candidate.startsWith(prefix)) return candidate;\n\t}\n\n\treturn null;\n};\n\n/* HMR plugin for Elysia\n Adds WebSocket endpoint and status endpoint.\n HMR client code is baked into framework index files (React/Svelte/Vue)\n and injected into HTML/HTMX files at build time.\n Also preserves Elysia store state across hot reloads. */\nexport const hmr = (\n\thmrState: HMRState,\n\tmanifest: Record<string, string>,\n\tmoduleServerHandler?: (\n\t\tpathname: string\n\t) => Promise<Response | undefined> | Response | undefined\n) =>\n\tnew Elysia({ name: 'absolutejs-hmr' })\n\t\t.onStart(({ store }) => {\n\t\t\trestoreStore(store);\n\t\t})\n\t\t// In HTTP/2 mode, WebSocket is handled by the http2Bridge\n\t\t// so we skip Elysia's .ws() registration\n\t\t// `onRequest` (not `onBeforeHandle`) is required: HMR-emitted chunks\n\t\t// like /generated/indexes/<hash>.js have no matching Elysia route\n\t\t// (the upstream `staticPlugin({ alwaysStatic })` only registers\n\t\t// files that existed at server start, so anything emitted by HMR\n\t\t// later is unrouted). `onBeforeHandle` only fires when a route\n\t\t// matches, so it would never see those requests; `onRequest` fires\n\t\t// before routing and lets us serve them from the asset store.\n\t\t.onRequest(async ({ request }) => {\n\t\t\t// Bridge React internals if bun install created a duplicate instance.\n\t\t\t// Runs before any route handler so page handlers stay clean.\n\t\t\tif (globalThis.__reactModuleRef) {\n\t\t\t\tawait bridgeReactInternals();\n\t\t\t}\n\n\t\t\t/* Fast path: only parse URL for requests that could be assets.\n\t\t\t\t Asset paths always start with / and contain a dot (extension).\n\t\t\t\t Skip API routes, WebSocket upgrades, and page navigations. */\n\t\t\treturn resolveDevAssetResponse(\n\t\t\t\trequest,\n\t\t\t\thmrState,\n\t\t\t\tmoduleServerHandler\n\t\t\t);\n\t\t})\n\t\t.get('/@src/*', ({ request }) =>\n\t\t\tresolveDevAssetResponse(request, hmrState, moduleServerHandler)\n\t\t)\n\t\t.get('/@stub/*', ({ request }) =>\n\t\t\tresolveDevAssetResponse(request, hmrState, moduleServerHandler)\n\t\t)\n\t\t.get('/@hmr/*', ({ request }) =>\n\t\t\tresolveDevAssetResponse(request, hmrState, moduleServerHandler)\n\t\t)\n\t\t// Always register WebSocket for HMR. When HTTP/2 bridge is\n\t\t// fully implemented it can take over, but Elysia's native\n\t\t// WebSocket works fine over both HTTP and HTTPS.\n\t\t.ws('/hmr', {\n\t\t\tclose: (ws) => handleClientDisconnect(hmrState, ws),\n\t\t\tmessage: (ws, msg) => handleHMRMessage(hmrState, ws, msg),\n\t\t\topen: (ws) => handleClientConnect(hmrState, ws, manifest)\n\t\t})\n\t\t.get('/hmr-status', () => ({\n\t\t\tconnectedClients: hmrState.connectedClients.size,\n\t\t\tisRebuilding: hmrState.isRebuilding,\n\t\t\tmanifestKeys: Object.keys(manifest),\n\t\t\trebuildCount: hmrState.rebuildCount,\n\t\t\trebuildQueue: Array.from(hmrState.rebuildQueue),\n\t\t\ttimestamp: Date.now()\n\t\t}));\n",
6
+ "/**\n * After `bun install` adds new packages, Bun's module cache can resolve\n * `react` to a new instance while `react-dom/server` still holds the original.\n * The two copies have separate shared-internals objects, so the hook dispatcher\n * set by react-dom is invisible to hooks in user components — \"Invalid hook call\".\n *\n * This bridges the new React's internals to the pinned (original) instance via\n * property descriptors so both share one dispatcher.\n *\n * React 19 renamed the internals key from\n * `__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED` to\n * `__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`.\n * We try both so the fix works across versions.\n */\nconst INTERNALS_KEYS = [\n\t'__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE',\n\t'__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED'\n] as const;\n\nconst isRecord = (val: unknown): val is Record<string, unknown> =>\n\ttypeof val === 'object' && val !== null;\n\nconst findInternals = (mod: Record<string, unknown>) => {\n\tfor (const key of INTERNALS_KEYS) {\n\t\tconst val = mod[key];\n\t\tif (isRecord(val)) return val;\n\t}\n\n\treturn undefined;\n};\n\nexport const bridgeReactInternals = async () => {\n\tconst pinnedRef = globalThis.__reactModuleRef;\n\tif (!isRecord(pinnedRef)) return;\n\n\tconst react: Record<string, unknown> = await import('react');\n\tif (pinnedRef === react) return;\n\n\tconst pinnedInternals = findInternals(pinnedRef);\n\tconst currentInternals = findInternals(react);\n\n\tif (\n\t\t!pinnedInternals ||\n\t\t!currentInternals ||\n\t\tpinnedInternals === currentInternals\n\t)\n\t\treturn;\n\n\tfor (const prop of Object.keys(pinnedInternals)) {\n\t\tObject.defineProperty(currentInternals, prop, {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tget() {\n\t\t\t\treturn pinnedInternals[prop];\n\t\t\t},\n\t\t\tset(value: unknown) {\n\t\t\t\tpinnedInternals[prop] = value;\n\t\t\t}\n\t\t});\n\t}\n};\n"
7
+ ],
8
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;ACcA,IAAM,iBAAiB;AAAA,EACtB;AAAA,EACA;AACD;AAEA,IAAM,WAAW,CAAC,QACjB,OAAO,QAAQ,YAAY,QAAQ;AAEpC,IAAM,gBAAgB,CAAC,QAAiC;AAAA,EACvD,WAAW,OAAO,gBAAgB;AAAA,IACjC,MAAM,MAAM,IAAI;AAAA,IAChB,IAAI,SAAS,GAAG;AAAA,MAAG,OAAO;AAAA,EAC3B;AAAA,EAEA;AAAA;AAGM,IAAM,uBAAuB,YAAY;AAAA,EAC/C,MAAM,YAAY,WAAW;AAAA,EAC7B,IAAI,CAAC,SAAS,SAAS;AAAA,IAAG;AAAA,EAE1B,MAAM,QAAiC,MAAa;AAAA,EACpD,IAAI,cAAc;AAAA,IAAO;AAAA,EAEzB,MAAM,kBAAkB,cAAc,SAAS;AAAA,EAC/C,MAAM,mBAAmB,cAAc,KAAK;AAAA,EAE5C,IACC,CAAC,mBACD,CAAC,oBACD,oBAAoB;AAAA,IAEpB;AAAA,EAED,WAAW,QAAQ,OAAO,KAAK,eAAe,GAAG;AAAA,IAChD,OAAO,eAAe,kBAAkB,MAAM;AAAA,MAC7C,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,GAAG,GAAG;AAAA,QACL,OAAO,gBAAgB;AAAA;AAAA,MAExB,GAAG,CAAC,OAAgB;AAAA,QACnB,gBAAgB,QAAQ;AAAA;A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IAChC,MAAM,qBAAqB;AAAA,EAC5B;AAAA,EAKA,OAAO,wBACN,SACA,UACA,mBACD;AAAA,CACA,EACA,IAAI,WAAW,GAAG,cAClB,wBAAwB,SAAS,UAAU,mBAAmB,CAC/D,EACC,IAAI,YAAY,GAAG,cACnB,wBAAwB,SAAS,UAAU,mBAAmB,CAC/D,EACC,IAAI,WAAW,GAAG,cAClB,wBAAwB,SAAS,UAAU,mBAAmB,CAC/D,EAIC,GAAG,QAAQ;AAAA,EACX,OAAO,CAAC,OAAO,uBAAuB,UAAU,EAAE;AAAA,EAClD,SAAS,CAAC,IAAI,QAAQ,iBAAiB,UAAU,IAAI,GAAG;AAAA,EACxD,MAAM,CAAC,OAAO,oBAAoB,UAAU,IAAI,QAAQ;AACzD,CAAC,EACA,IAAI,eAAe,OAAO;AAAA,EAC1B,kBAAkB,SAAS,iBAAiB;AAAA,EAC5C,cAAc,SAAS;AAAA,EACvB,cAAc,OAAO,KAAK,QAAQ;AAAA,EAClC,cAAc,SAAS;AAAA,EACvB,cAAc,MAAM,KAAK,SAAS,YAAY;AAAA,EAC9C,WAAW,KAAK,IAAI;AACrB,EAAE;",
9
+ "debugId": "4B480B1E52FA111664756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,253 @@
1
+ // @bun
2
+ import {
3
+ generateVendorEntrySource
4
+ } from "./chunk-7kjj42xm.js";
5
+ import {
6
+ __require
7
+ } from "./chunk-bmgqm774.js";
8
+
9
+ // src/build/buildAngularVendor.ts
10
+ import { mkdirSync as mkdirSync2 } from "fs";
11
+ import { join as join2 } from "path";
12
+ import { rm } from "fs/promises";
13
+ var {build: bunBuild, Glob } = globalThis.Bun;
14
+
15
+ // src/build/angularLinkerPlugin.ts
16
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
17
+ import { dirname, join, relative, resolve } from "path";
18
+ import { createHash } from "crypto";
19
+ var CACHE_ROOT = resolve(".absolutejs", "cache", "angular-linker");
20
+ var createAngularLinkerPlugin = (linkerJitMode) => ({
21
+ name: "angular-linker",
22
+ setup(bld) {
23
+ let needsLinking;
24
+ let babelTransform;
25
+ let linkerPlugin;
26
+ const cacheDir = join(CACHE_ROOT, linkerJitMode ? "jit" : "aot");
27
+ bld.onLoad({ filter: /[\\/]@angular[\\/].*\.m?js$/ }, async (args) => {
28
+ const source = await Bun.file(args.path).text();
29
+ if (!needsLinking) {
30
+ const specifier = "@angular/compiler-cli/linker";
31
+ const mod = await import(specifier);
32
+ ({ needsLinking } = mod);
33
+ }
34
+ const checkLink = needsLinking;
35
+ if (!checkLink || !checkLink(args.path, source)) {
36
+ return;
37
+ }
38
+ const hash = createHash("md5").update(source).digest("hex");
39
+ const cachePath = join(cacheDir, `${hash}.js`);
40
+ if (existsSync(cachePath)) {
41
+ return {
42
+ contents: readFileSync(cachePath, "utf-8"),
43
+ loader: "js"
44
+ };
45
+ }
46
+ if (!babelTransform) {
47
+ const babelSpecifier = "@babel/core";
48
+ const babel = await import(babelSpecifier);
49
+ babelTransform = babel.transformSync;
50
+ }
51
+ if (!linkerPlugin) {
52
+ const linkerSpecifier = "@angular/compiler-cli/linker/babel";
53
+ const mod = await import(linkerSpecifier);
54
+ linkerPlugin = mod.createEs2015LinkerPlugin({
55
+ fileSystem: {
56
+ dirname,
57
+ exists: existsSync,
58
+ readFile: readFileSync,
59
+ relative,
60
+ resolve
61
+ },
62
+ linkerJitMode,
63
+ logger: {
64
+ error: console.error,
65
+ level: 1,
66
+ warn: console.warn,
67
+ debug: () => {},
68
+ info: () => {}
69
+ }
70
+ });
71
+ }
72
+ const transform = babelTransform;
73
+ if (!transform) {
74
+ return { contents: source, loader: "js" };
75
+ }
76
+ const result = transform(source, {
77
+ compact: false,
78
+ filename: args.path,
79
+ filenameRelative: args.path,
80
+ plugins: [linkerPlugin],
81
+ sourceMaps: false
82
+ });
83
+ const linked = result?.code ?? source;
84
+ mkdirSync(cacheDir, { recursive: true });
85
+ writeFileSync(cachePath, linked, "utf-8");
86
+ return { contents: linked, loader: "js" };
87
+ });
88
+ }
89
+ });
90
+ var angularLinkerPlugin = createAngularLinkerPlugin(false);
91
+
92
+ // src/build/buildAngularVendor.ts
93
+ var REQUIRED_ANGULAR_SPECIFIERS = [
94
+ "@angular/core",
95
+ "@angular/compiler",
96
+ "@angular/common",
97
+ "@angular/common/http",
98
+ "@angular/platform-browser"
99
+ ];
100
+ var SERVER_ONLY_ANGULAR_SPECIFIERS = new Set([
101
+ "@angular/platform-server",
102
+ "@angular/ssr",
103
+ "@angular/compiler-cli"
104
+ ]);
105
+ var SCAN_SKIP_DIRS = new Set([
106
+ "node_modules",
107
+ "build",
108
+ "dist",
109
+ ".absolutejs",
110
+ "generated"
111
+ ]);
112
+ var isResolvable = (specifier) => {
113
+ try {
114
+ Bun.resolveSync(specifier, process.cwd());
115
+ return true;
116
+ } catch {
117
+ return false;
118
+ }
119
+ };
120
+ var isBareSpecifier = (spec) => !spec.startsWith(".") && !spec.startsWith("/") && !spec.startsWith("@src/");
121
+ var isAngularBrowserSpecifier = (spec) => spec.startsWith("@angular/") && !SERVER_ONLY_ANGULAR_SPECIFIERS.has(spec);
122
+ var scanSourceImports = async (directories) => {
123
+ const angular = new Set;
124
+ const transitiveRoots = new Set;
125
+ const transpiler = new Bun.Transpiler({ loader: "tsx" });
126
+ const glob = new Glob("**/*.{ts,tsx,js,jsx}");
127
+ for (const dir of directories) {
128
+ try {
129
+ for await (const file of glob.scan({ absolute: true, cwd: dir })) {
130
+ const rel = file.slice(dir.length + 1);
131
+ const [first] = rel.split("/");
132
+ if (first && SCAN_SKIP_DIRS.has(first))
133
+ continue;
134
+ try {
135
+ const content = await Bun.file(file).text();
136
+ for (const imp of transpiler.scanImports(content)) {
137
+ if (isAngularBrowserSpecifier(imp.path)) {
138
+ angular.add(imp.path);
139
+ } else if (isBareSpecifier(imp.path)) {
140
+ transitiveRoots.add(imp.path);
141
+ }
142
+ }
143
+ } catch {}
144
+ }
145
+ } catch {}
146
+ }
147
+ return { angular, transitiveRoots };
148
+ };
149
+ var collectTransitiveAngularSpecs = async (roots, angularFound) => {
150
+ const { readFileSync: readFileSync2 } = await import("fs");
151
+ const transpiler = new Bun.Transpiler({ loader: "js" });
152
+ const visited = new Set;
153
+ const frontier = [];
154
+ for (const r of roots)
155
+ frontier.push(r);
156
+ const MAX_PASSES = 5;
157
+ for (let pass = 0;pass < MAX_PASSES; pass++) {
158
+ const next = [];
159
+ for (const spec of frontier) {
160
+ if (visited.has(spec))
161
+ continue;
162
+ visited.add(spec);
163
+ let resolved;
164
+ try {
165
+ resolved = Bun.resolveSync(spec, process.cwd());
166
+ } catch {
167
+ continue;
168
+ }
169
+ let content;
170
+ try {
171
+ content = readFileSync2(resolved, "utf-8");
172
+ } catch {
173
+ continue;
174
+ }
175
+ let imports;
176
+ try {
177
+ imports = transpiler.scanImports(content);
178
+ } catch {
179
+ continue;
180
+ }
181
+ for (const imp of imports) {
182
+ const child = imp.path;
183
+ if (!isBareSpecifier(child))
184
+ continue;
185
+ if (visited.has(child))
186
+ continue;
187
+ if (isAngularBrowserSpecifier(child)) {
188
+ angularFound.add(child);
189
+ }
190
+ next.push(child);
191
+ }
192
+ }
193
+ if (next.length === 0)
194
+ break;
195
+ frontier.length = 0;
196
+ for (const s of next)
197
+ frontier.push(s);
198
+ }
199
+ };
200
+ var toSafeFileName = (specifier) => specifier.replace(/^@/, "").replace(/\//g, "_");
201
+ var resolveAngularSpecifiers = async (directories) => {
202
+ const { angular, transitiveRoots } = await scanSourceImports(directories);
203
+ for (const spec of REQUIRED_ANGULAR_SPECIFIERS)
204
+ angular.add(spec);
205
+ await collectTransitiveAngularSpecs([...angular, ...transitiveRoots], angular);
206
+ return Array.from(angular).filter(isResolvable);
207
+ };
208
+ var buildAngularVendor = async (buildDir, directories = [], linkerJitMode = false, depVendorSpecifiers = []) => {
209
+ const vendorDir = join2(buildDir, "angular", "vendor");
210
+ mkdirSync2(vendorDir, { recursive: true });
211
+ const tmpDir = join2(buildDir, "_angular_vendor_tmp");
212
+ mkdirSync2(tmpDir, { recursive: true });
213
+ const specifiers = await resolveAngularSpecifiers(directories);
214
+ const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
215
+ const safeName = toSafeFileName(specifier);
216
+ const entryPath = join2(tmpDir, `${safeName}.ts`);
217
+ await Bun.write(entryPath, generateVendorEntrySource(specifier));
218
+ return entryPath;
219
+ }));
220
+ const result = await bunBuild({
221
+ entrypoints,
222
+ external: depVendorSpecifiers,
223
+ format: "esm",
224
+ minify: false,
225
+ naming: "[name].[ext]",
226
+ outdir: vendorDir,
227
+ plugins: [createAngularLinkerPlugin(linkerJitMode)],
228
+ splitting: true,
229
+ target: "browser",
230
+ throw: false
231
+ });
232
+ await rm(tmpDir, { force: true, recursive: true });
233
+ if (!result.success) {
234
+ console.warn("\u26A0\uFE0F Angular vendor build had errors:", result.logs);
235
+ }
236
+ return specifiers;
237
+ };
238
+ var computeAngularVendorPaths = (specifiers = REQUIRED_ANGULAR_SPECIFIERS) => {
239
+ const paths = {};
240
+ for (const specifier of specifiers) {
241
+ paths[specifier] = `/angular/vendor/${toSafeFileName(specifier)}.js`;
242
+ }
243
+ return paths;
244
+ };
245
+ var computeAngularVendorPathsAsync = async (directories = []) => {
246
+ const specifiers = await resolveAngularSpecifiers(directories);
247
+ return computeAngularVendorPaths(specifiers);
248
+ };
249
+
250
+ export { createAngularLinkerPlugin, buildAngularVendor, computeAngularVendorPaths, computeAngularVendorPathsAsync };
251
+
252
+ //# debugId=6E97B8F47726EBE564756E2164756E21
253
+ //# sourceMappingURL=chunk-ey5hs6x6.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/build/buildAngularVendor.ts", "../src/build/angularLinkerPlugin.ts"],
4
+ "sourcesContent": [
5
+ "import { mkdirSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { rm } from 'node:fs/promises';\nimport { build as bunBuild, Glob } from 'bun';\nimport { createAngularLinkerPlugin } from './angularLinkerPlugin';\nimport { generateVendorEntrySource } from './vendorEntrySource';\n\n/** Always-vendored Angular packages.\n * Required for any Angular page even if not imported in user code: the runtime\n * needs them to bootstrap. Server-only packages (@angular/platform-server) are\n * excluded. Additional @angular/* packages are auto-discovered from source. */\nconst REQUIRED_ANGULAR_SPECIFIERS = [\n\t'@angular/core',\n\t'@angular/compiler',\n\t'@angular/common',\n\t'@angular/common/http',\n\t'@angular/platform-browser'\n];\n\n/** Build-only / server-only specifiers that should never be browser-vendored. */\nconst SERVER_ONLY_ANGULAR_SPECIFIERS = new Set([\n\t'@angular/platform-server',\n\t'@angular/ssr',\n\t'@angular/compiler-cli'\n]);\n\nconst SCAN_SKIP_DIRS = new Set([\n\t'node_modules',\n\t'build',\n\t'dist',\n\t'.absolutejs',\n\t'generated'\n]);\n\nconst isResolvable = (specifier: string) => {\n\ttry {\n\t\tBun.resolveSync(specifier, process.cwd());\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst isBareSpecifier = (spec: string) =>\n\t!spec.startsWith('.') && !spec.startsWith('/') && !spec.startsWith('@src/');\n\nconst isAngularBrowserSpecifier = (spec: string) =>\n\tspec.startsWith('@angular/') && !SERVER_ONLY_ANGULAR_SPECIFIERS.has(spec);\n\n/** Scan user source for any imports — both @angular/* (kept) and other bare\n * specs (returned as transitive scan seeds). Finding angular subpaths only\n * reachable through deps (e.g. `@angular/core/rxjs-interop` from\n * `@angular/fire/compat/auth`) requires walking through non-angular roots. */\nconst scanSourceImports = async (directories: string[]) => {\n\tconst angular = new Set<string>();\n\tconst transitiveRoots = new Set<string>();\n\tconst transpiler = new Bun.Transpiler({ loader: 'tsx' });\n\tconst glob = new Glob('**/*.{ts,tsx,js,jsx}');\n\n\tfor (const dir of directories) {\n\t\ttry {\n\t\t\tfor await (const file of glob.scan({ absolute: true, cwd: dir })) {\n\t\t\t\tconst rel = file.slice(dir.length + 1);\n\t\t\t\tconst [first] = rel.split('/');\n\t\t\t\tif (first && SCAN_SKIP_DIRS.has(first)) continue;\n\t\t\t\ttry {\n\t\t\t\t\tconst content = await Bun.file(file).text();\n\t\t\t\t\tfor (const imp of transpiler.scanImports(content)) {\n\t\t\t\t\t\tif (isAngularBrowserSpecifier(imp.path)) {\n\t\t\t\t\t\t\tangular.add(imp.path);\n\t\t\t\t\t\t} else if (isBareSpecifier(imp.path)) {\n\t\t\t\t\t\t\ttransitiveRoots.add(imp.path);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// unreadable file, skip\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// missing dir, skip\n\t\t}\n\t}\n\n\treturn { angular, transitiveRoots };\n};\n\n/** Walk through transitive deps and harvest any @angular/* subpaths reachable\n * via non-angular packages (e.g. firebase imports `@angular/core/rxjs-interop`\n * through @angular/fire). Mirrors buildDepVendor's framework-root traversal. */\nconst collectTransitiveAngularSpecs = async (\n\troots: Iterable<string>,\n\tangularFound: Set<string>\n) => {\n\tconst { readFileSync } = await import('node:fs');\n\tconst transpiler = new Bun.Transpiler({ loader: 'js' });\n\tconst visited = new Set<string>();\n\tconst frontier: string[] = [];\n\tfor (const r of roots) frontier.push(r);\n\n\tconst MAX_PASSES = 5;\n\tfor (let pass = 0; pass < MAX_PASSES; pass++) {\n\t\tconst next: string[] = [];\n\t\tfor (const spec of frontier) {\n\t\t\tif (visited.has(spec)) continue;\n\t\t\tvisited.add(spec);\n\t\t\tlet resolved: string;\n\t\t\ttry {\n\t\t\t\tresolved = Bun.resolveSync(spec, process.cwd());\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet content: string;\n\t\t\ttry {\n\t\t\t\tcontent = readFileSync(resolved, 'utf-8');\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet imports;\n\t\t\ttry {\n\t\t\t\timports = transpiler.scanImports(content);\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const imp of imports) {\n\t\t\t\tconst child = imp.path;\n\t\t\t\tif (!isBareSpecifier(child)) continue;\n\t\t\t\tif (visited.has(child)) continue;\n\t\t\t\tif (isAngularBrowserSpecifier(child)) {\n\t\t\t\t\tangularFound.add(child);\n\t\t\t\t}\n\t\t\t\tnext.push(child);\n\t\t\t}\n\t\t}\n\t\tif (next.length === 0) break;\n\t\tfrontier.length = 0;\n\t\tfor (const s of next) frontier.push(s);\n\t}\n};\n\n/** Convert a bare specifier to a safe filename:\n * @angular/common/http → angular_common_http */\nconst toSafeFileName = (specifier: string) =>\n\tspecifier.replace(/^@/, '').replace(/\\//g, '_');\n\nconst resolveAngularSpecifiers = async (directories: string[]) => {\n\tconst { angular, transitiveRoots } = await scanSourceImports(directories);\n\tfor (const spec of REQUIRED_ANGULAR_SPECIFIERS) angular.add(spec);\n\tawait collectTransitiveAngularSpecs(\n\t\t[...angular, ...transitiveRoots],\n\t\tangular\n\t);\n\n\treturn Array.from(angular).filter(isResolvable);\n};\n\n/** Build vendor bundles for every @angular/* package the project imports.\n * `linkerJitMode` controls whether NgModule definitions retain their\n * declarations/exports — required when consumer (user) components are\n * runtime-compiled by `@angular/compiler` (dev/HMR via compileAngularFileJIT).\n * Production AOT builds set this to false to match AOT'd user components.\n *\n * `depVendorSpecifiers` are non-framework packages that are also vendored\n * separately (by `buildDepVendor`). They MUST be externalized here too —\n * otherwise transitive imports like `@angular/fire/compat/auth` →\n * `firebase/compat/auth` get bundled twice, creating duplicate\n * @firebase/app-compat instances. The angular-vendor copy registers\n * `firebase.auth.*` on its own firebase singleton, leaving the user's\n * `import firebase from 'firebase/compat/app'` with `firebase.auth` undefined.\n * Externalizing forces both pipelines to share the same /vendor chunks. */\nexport const buildAngularVendor = async (\n\tbuildDir: string,\n\tdirectories: string[] = [],\n\tlinkerJitMode = false,\n\tdepVendorSpecifiers: string[] = []\n) => {\n\tconst vendorDir = join(buildDir, 'angular', 'vendor');\n\tmkdirSync(vendorDir, { recursive: true });\n\n\tconst tmpDir = join(buildDir, '_angular_vendor_tmp');\n\tmkdirSync(tmpDir, { recursive: true });\n\n\tconst specifiers = await resolveAngularSpecifiers(directories);\n\n\t// Angular packages are proper ESM. `export *` re-exports only NAMED exports\n\t// per ECMA spec, so we use the namespace-default-fallback pattern that's\n\t// safe regardless of whether the package has a default export.\n\tconst entrypoints = await Promise.all(\n\t\tspecifiers.map(async (specifier) => {\n\t\t\tconst safeName = toSafeFileName(specifier);\n\t\t\tconst entryPath = join(tmpDir, `${safeName}.ts`);\n\t\t\tawait Bun.write(entryPath, generateVendorEntrySource(specifier));\n\n\t\t\treturn entryPath;\n\t\t})\n\t);\n\n\tconst result = await bunBuild({\n\t\tentrypoints,\n\t\texternal: depVendorSpecifiers,\n\t\tformat: 'esm',\n\t\tminify: false,\n\t\tnaming: '[name].[ext]',\n\t\toutdir: vendorDir,\n\t\tplugins: [createAngularLinkerPlugin(linkerJitMode)],\n\t\tsplitting: true,\n\t\ttarget: 'browser',\n\t\tthrow: false\n\t});\n\n\tawait rm(tmpDir, { force: true, recursive: true });\n\n\tif (!result.success) {\n\t\tconsole.warn('⚠️ Angular vendor build had errors:', result.logs);\n\t}\n\n\treturn specifiers;\n};\nexport const computeAngularVendorPaths = (\n\tspecifiers: string[] = REQUIRED_ANGULAR_SPECIFIERS\n) => {\n\tconst paths: Record<string, string> = {};\n\tfor (const specifier of specifiers) {\n\t\tpaths[specifier] = `/angular/vendor/${toSafeFileName(specifier)}.js`;\n\t}\n\n\treturn paths;\n};\n\n/** Async variant that scans source + transitive deps before producing the\n * vendor path map. Use this when the page-bundle build needs the full set of\n * angular specs in its rewrite map (otherwise transitively-discovered subpaths\n * like `@angular/core/rxjs-interop` end up as bare specifiers in the output). */\nexport const computeAngularVendorPathsAsync = async (\n\tdirectories: string[] = []\n) => {\n\tconst specifiers = await resolveAngularSpecifiers(directories);\n\n\treturn computeAngularVendorPaths(specifiers);\n};\n",
6
+ "import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport type { BunPlugin } from 'bun';\n\nconst CACHE_ROOT = resolve('.absolutejs', 'cache', 'angular-linker');\n\n/**\n * Bun bundler plugin that runs the Angular Linker on partially compiled\n * Angular libraries at build time. Converts ɵɵngDeclare* declarations\n * into fully linked code.\n *\n * The `linkerJitMode` flag controls whether NgModule definitions retain\n * `declarations`/`exports` (JIT-mode, required when consumer code is\n * runtime-compiled) or strip them (AOT-mode, smaller output but only\n * correct when consumer components have ɵcmp.dependencies baked in by\n * the Angular compiler-cli).\n *\n * In AbsoluteJS dev/HMR, user components are TypeScript-transpiled via\n * `compileAngularFileJIT` and rely on @angular/compiler at runtime —\n * that runtime JIT path reads `NgModule.ɵmod.declarations` to find\n * directives like FormGroupDirective. Linking vendor code in AOT mode\n * (the default) silently breaks dev because declarations get stripped\n * and runtime JIT then can't resolve `[formGroup]`, `[ngIf]`, etc. So\n * dev/HMR builds must use `linkerJitMode: true`. Production AOT builds\n * use `linkerJitMode: false` (matches AOT'd user components).\n *\n * Cache key includes mode so dev and prod artifacts don't collide.\n */\nexport const createAngularLinkerPlugin = (\n\tlinkerJitMode: boolean\n): BunPlugin => ({\n\tname: 'angular-linker',\n\tsetup(bld) {\n\t\tlet needsLinking: ((path: string, source: string) => boolean) | undefined;\n\t\tlet babelTransform: ((source: string, options: Record<string, unknown>) => { code?: string } | null) | undefined;\n\t\tlet linkerPlugin: unknown;\n\n\t\tconst cacheDir = join(CACHE_ROOT, linkerJitMode ? 'jit' : 'aot');\n\n\t\tbld.onLoad(\n\t\t\t{ filter: /[\\\\/]@angular[\\\\/].*\\.m?js$/ },\n\t\t\tasync (args) => {\n\t\t\t\tconst source = await Bun.file(args.path).text();\n\n\t\t\t\tif (!needsLinking) {\n\t\t\t\t\tconst specifier = '@angular/compiler-cli/linker';\n\t\t\t\t\tconst mod = await import(specifier);\n\t\t\t\t\t({ needsLinking } = mod);\n\t\t\t\t}\n\n\t\t\t\tconst checkLink = needsLinking;\n\t\t\t\tif (!checkLink || !checkLink(args.path, source)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst hash = createHash('md5')\n\t\t\t\t\t.update(source)\n\t\t\t\t\t.digest('hex');\n\t\t\t\tconst cachePath = join(cacheDir, `${hash}.js`);\n\n\t\t\t\tif (existsSync(cachePath)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontents: readFileSync(cachePath, 'utf-8'),\n\t\t\t\t\t\tloader: 'js'\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (!babelTransform) {\n\t\t\t\t\tconst babelSpecifier = '@babel/core';\n\t\t\t\t\tconst babel = await import(babelSpecifier);\n\t\t\t\t\tbabelTransform = babel.transformSync;\n\t\t\t\t}\n\t\t\t\tif (!linkerPlugin) {\n\t\t\t\t\tconst linkerSpecifier = '@angular/compiler-cli/linker/babel';\n\t\t\t\t\tconst mod = await import(linkerSpecifier);\n\t\t\t\t\tlinkerPlugin = mod.createEs2015LinkerPlugin({\n\t\t\t\t\t\tfileSystem: {\n\t\t\t\t\t\t\tdirname,\n\t\t\t\t\t\t\texists: existsSync,\n\t\t\t\t\t\t\treadFile: readFileSync,\n\t\t\t\t\t\t\trelative,\n\t\t\t\t\t\t\tresolve\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlinkerJitMode,\n\t\t\t\t\t\tlogger: {\n\t\t\t\t\t\t\terror: console.error,\n\t\t\t\t\t\t\tlevel: 1,\n\t\t\t\t\t\t\twarn: console.warn,\n\t\t\t\t\t\t\tdebug: () => { /* noop */ },\n\t\t\t\t\t\t\tinfo: () => { /* noop */ }\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst transform = babelTransform;\n\t\t\t\tif (!transform) {\n\t\t\t\t\treturn { contents: source, loader: 'js' };\n\t\t\t\t}\n\n\t\t\t\tconst result = transform(source, {\n\t\t\t\t\tcompact: false,\n\t\t\t\t\tfilename: args.path,\n\t\t\t\t\tfilenameRelative: args.path,\n\t\t\t\t\tplugins: [linkerPlugin],\n\t\t\t\t\tsourceMaps: false\n\t\t\t\t});\n\n\t\t\t\tconst linked = result?.code ?? source;\n\n\t\t\t\tmkdirSync(cacheDir, { recursive: true });\n\t\t\t\twriteFileSync(cachePath, linked, 'utf-8');\n\n\t\t\t\treturn { contents: linked, loader: 'js' };\n\t\t\t}\n\t\t);\n\t}\n});\n\n/** Default AOT-mode plugin instance — keep for callers that don't need\n * to choose. Production AOT builds and any callsite that AOT-compiles\n * user components alongside vendor should use this. */\nexport const angularLinkerPlugin: BunPlugin = createAngularLinkerPlugin(false);\n"
7
+ ],
8
+ "mappings": ";;;;;;;;;AAAA,sBAAS;AACT,iBAAS;AACT;AACA;;;ACHA;AACA;AACA;AAGA,IAAM,aAAa,QAAQ,eAAe,SAAS,gBAAgB;AAwB5D,IAAM,4BAA4B,CACxC,mBACgB;AAAA,EAChB,MAAM;AAAA,EACN,KAAK,CAAC,KAAK;AAAA,IACV,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IAEJ,MAAM,WAAW,KAAK,YAAY,gBAAgB,QAAQ,KAAK;AAAA,IAE/D,IAAI,OACH,EAAE,QAAQ,8BAA8B,GACxC,OAAO,SAAS;AAAA,MACf,MAAM,SAAS,MAAM,IAAI,KAAK,KAAK,IAAI,EAAE,KAAK;AAAA,MAE9C,IAAI,CAAC,cAAc;AAAA,QAClB,MAAM,YAAY;AAAA,QAClB,MAAM,MAAM,MAAa;AAAA,SACxB,EAAE,aAAa,IAAI;AAAA,MACrB;AAAA,MAEA,MAAM,YAAY;AAAA,MAClB,IAAI,CAAC,aAAa,CAAC,UAAU,KAAK,MAAM,MAAM,GAAG;AAAA,QAChD;AAAA,MACD;AAAA,MAEA,MAAM,OAAO,WAAW,KAAK,EAC3B,OAAO,MAAM,EACb,OAAO,KAAK;AAAA,MACd,MAAM,YAAY,KAAK,UAAU,GAAG,SAAS;AAAA,MA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7B;AAAA,IACA,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS,CAAC,0BAA0B,aAAa,CAAC;AAAA,IAClD,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,EACR,CAAC;AAAA,EAED,MAAM,GAAG,QAAQ,EAAE,OAAO,MAAM,WAAW,KAAK,CAAC;AAAA,EAEjD,IAAI,CAAC,OAAO,SAAS;AAAA,IACpB,QAAQ,KAAK,iDAAsC,OAAO,IAAI;AAAA,EAC/D;AAAA,EAEA,OAAO;AAAA;AAED,IAAM,4BAA4B,CACxC,aAAuB,gCACnB;AAAA,EACJ,MAAM,QAAgC,CAAC;AAAA,EACvC,WAAW,aAAa,YAAY;AAAA,IACnC,MAAM,aAAa,mBAAmB,eAAe,SAAS;AAAA,EAC/D;AAAA,EAEA,OAAO;AAAA;AAOD,IAAM,iCAAiC,OAC7C,cAAwB,CAAC,MACrB;AAAA,EACJ,MAAM,aAAa,MAAM,yBAAyB,WAAW;AAAA,EAE7D,OAAO,0BAA0B,UAAU;AAAA;",
9
+ "debugId": "6E97B8F47726EBE564756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,91 @@
1
+ // @bun
2
+ import {
3
+ getIslandMarkerAttributes
4
+ } from "./chunk-2f21eenc.js";
5
+
6
+ // src/client/preserveIslandMarkup.ts
7
+ var getClaimMap = () => {
8
+ if (typeof window === "undefined") {
9
+ return null;
10
+ }
11
+ window.__ABS_CLAIMED_ISLAND_MARKUP__ ??= new Map;
12
+ return window.__ABS_CLAIMED_ISLAND_MARKUP__;
13
+ };
14
+ var getSnapshotMap = () => {
15
+ if (typeof window === "undefined") {
16
+ return null;
17
+ }
18
+ window.__ABS_SERVER_ISLAND_HTML__ ??= new Map;
19
+ return window.__ABS_SERVER_ISLAND_HTML__;
20
+ };
21
+ var getIslandSignature = (props) => {
22
+ const attributes = getIslandMarkerAttributes(props);
23
+ return [
24
+ attributes["data-component"],
25
+ attributes["data-framework"],
26
+ attributes["data-hydrate"],
27
+ attributes["data-props"]
28
+ ].join("::");
29
+ };
30
+ var isMatchingIslandElement = (element, props) => {
31
+ if (!(element instanceof HTMLElement)) {
32
+ return false;
33
+ }
34
+ const attributes = getIslandMarkerAttributes(props);
35
+ return element.dataset.island === "true" && element.dataset.component === attributes["data-component"] && element.dataset.framework === attributes["data-framework"] && (element.dataset.hydrate ?? "load") === attributes["data-hydrate"] && (element.dataset.props ?? "{}") === attributes["data-props"];
36
+ };
37
+ var snapshotIslandElement = (element, snapshotMap) => {
38
+ const signature = [
39
+ element.dataset.component,
40
+ element.dataset.framework,
41
+ element.dataset.hydrate ?? "load",
42
+ element.dataset.props ?? "{}"
43
+ ].join("::");
44
+ const existing = snapshotMap.get(signature) ?? [];
45
+ const attributes = Object.fromEntries(element.getAttributeNames().map((name) => [name, element.getAttribute(name) ?? ""]));
46
+ existing.push({
47
+ attributes,
48
+ innerHTML: element.innerHTML
49
+ });
50
+ snapshotMap.set(signature, existing);
51
+ };
52
+ var initializeIslandMarkupSnapshot = () => {
53
+ if (typeof document === "undefined") {
54
+ return;
55
+ }
56
+ const snapshotMap = getSnapshotMap();
57
+ if (!snapshotMap || snapshotMap.size > 0) {
58
+ return;
59
+ }
60
+ const elements = Array.from(document.querySelectorAll('[data-island="true"]'));
61
+ for (const element of elements) {
62
+ snapshotIslandElement(element, snapshotMap);
63
+ }
64
+ };
65
+ var preserveIslandMarkup = (props) => {
66
+ if (typeof document === "undefined") {
67
+ return {
68
+ attributes: getIslandMarkerAttributes(props),
69
+ innerHTML: ""
70
+ };
71
+ }
72
+ const claimMap = getClaimMap();
73
+ const snapshotMap = getSnapshotMap();
74
+ const signature = getIslandSignature(props);
75
+ const claimedCount = claimMap?.get(signature) ?? 0;
76
+ const snapshotCandidate = snapshotMap?.get(signature)?.[claimedCount];
77
+ const candidates = Array.from(document.querySelectorAll('[data-island="true"]')).filter((element) => isMatchingIslandElement(element, props));
78
+ const candidate = candidates[claimedCount];
79
+ if (claimMap) {
80
+ claimMap.set(signature, claimedCount + 1);
81
+ }
82
+ return {
83
+ attributes: snapshotCandidate?.attributes ?? getIslandMarkerAttributes(props),
84
+ innerHTML: snapshotCandidate?.innerHTML ?? candidate?.innerHTML ?? ""
85
+ };
86
+ };
87
+
88
+ export { initializeIslandMarkupSnapshot, preserveIslandMarkup };
89
+
90
+ //# debugId=73AD256A75D98ACE64756E2164756E21
91
+ //# sourceMappingURL=chunk-fak944et.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/client/preserveIslandMarkup.ts"],
4
+ "sourcesContent": [
5
+ "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 getClaimMap = () => {\n\tif (typeof window === 'undefined') {\n\t\treturn null;\n\t}\n\n\twindow.__ABS_CLAIMED_ISLAND_MARKUP__ ??= new Map<string, number>();\n\n\treturn window.__ABS_CLAIMED_ISLAND_MARKUP__;\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\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\tconst attributes = Object.fromEntries(\n\t\telement\n\t\t\t.getAttributeNames()\n\t\t\t.map((name) => [name, element.getAttribute(name) ?? ''])\n\t);\n\texisting.push({\n\t\tattributes,\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 claimMap = getClaimMap();\n\tconst snapshotMap = getSnapshotMap();\n\tconst signature = getIslandSignature(props);\n\tconst claimedCount = claimMap?.get(signature) ?? 0;\n\tconst snapshotCandidate = snapshotMap?.get(signature)?.[claimedCount];\n\tconst candidates = Array.from(\n\t\tdocument.querySelectorAll('[data-island=\"true\"]')\n\t).filter((element) => isMatchingIslandElement(element, props));\n\tconst candidate = candidates[claimedCount];\n\tif (claimMap) {\n\t\tclaimMap.set(signature, claimedCount + 1);\n\t}\n\n\treturn {\n\t\tattributes:\n\t\t\tsnapshotCandidate?.attributes ?? getIslandMarkerAttributes(props),\n\t\tinnerHTML: snapshotCandidate?.innerHTML ?? candidate?.innerHTML ?? ''\n\t};\n};\n"
6
+ ],
7
+ "mappings": ";;;;;;AAmBA,IAAM,cAAc,MAAM;AAAA,EACzB,IAAI,OAAO,WAAW,aAAa;AAAA,IAClC,OAAO;AAAA,EACR;AAAA,EAEA,OAAO,kCAAkC,IAAI;AAAA,EAE7C,OAAO,OAAO;AAAA;AAGf,IAAM,iBAAiB,MAAM;AAAA,EAC5B,IAAI,OAAO,WAAW,aAAa;AAAA,IAClC,OAAO;AAAA,EACR;AAAA,EAEA,OAAO,+BAA+B,IAAI;AAAA,EAK1C,OAAO,OAAO;AAAA;AAGf,IAAM,qBAAqB,CAAC,UAAoC;AAAA,EAC/D,MAAM,aAAa,0BAA0B,KAAK;AAAA,EAElD,OAAO;AAAA,IACN,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,EACZ,EAAE,KAAK,IAAI;AAAA;AAGZ,IAAM,0BAA0B,CAC/B,SACA,UACoC;AAAA,EACpC,IAAI,EAAE,mBAAmB,cAAc;AAAA,IACtC,OAAO;AAAA,EACR;AAAA,EAEA,MAAM,aAAa,0BAA0B,KAAK;AAAA,EAElD,OACC,QAAQ,QAAQ,WAAW,UAC3B,QAAQ,QAAQ,cAAc,WAAW,qBACzC,QAAQ,QAAQ,cAAc,WAAW,sBACxC,QAAQ,QAAQ,WAAW,YAAY,WAAW,oBAClD,QAAQ,QAAQ,SAA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