@haex-space/vault-sdk 1.0.0

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 (59) hide show
  1. package/README.md +1551 -0
  2. package/dist/cli/index.d.mts +1 -0
  3. package/dist/cli/index.d.ts +1 -0
  4. package/dist/cli/index.js +455 -0
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/cli/index.mjs +430 -0
  7. package/dist/cli/index.mjs.map +1 -0
  8. package/dist/client-O_JEOzfx.d.mts +491 -0
  9. package/dist/client-O_JEOzfx.d.ts +491 -0
  10. package/dist/index.d.mts +124 -0
  11. package/dist/index.d.ts +124 -0
  12. package/dist/index.js +1429 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/index.mjs +1409 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/dist/node.d.mts +25 -0
  17. package/dist/node.d.ts +25 -0
  18. package/dist/node.js +28 -0
  19. package/dist/node.js.map +1 -0
  20. package/dist/node.mjs +25 -0
  21. package/dist/node.mjs.map +1 -0
  22. package/dist/nuxt.d.mts +19 -0
  23. package/dist/nuxt.d.ts +19 -0
  24. package/dist/nuxt.js +473 -0
  25. package/dist/nuxt.js.map +1 -0
  26. package/dist/nuxt.mjs +470 -0
  27. package/dist/nuxt.mjs.map +1 -0
  28. package/dist/react.d.mts +28 -0
  29. package/dist/react.d.ts +28 -0
  30. package/dist/react.js +1389 -0
  31. package/dist/react.js.map +1 -0
  32. package/dist/react.mjs +1386 -0
  33. package/dist/react.mjs.map +1 -0
  34. package/dist/runtime/nuxt.plugin.client.d.mts +43 -0
  35. package/dist/runtime/nuxt.plugin.client.d.ts +43 -0
  36. package/dist/runtime/nuxt.plugin.client.js +1137 -0
  37. package/dist/runtime/nuxt.plugin.client.js.map +1 -0
  38. package/dist/runtime/nuxt.plugin.client.mjs +1135 -0
  39. package/dist/runtime/nuxt.plugin.client.mjs.map +1 -0
  40. package/dist/runtime/nuxt.types.d.ts +15 -0
  41. package/dist/svelte.d.mts +48 -0
  42. package/dist/svelte.d.ts +48 -0
  43. package/dist/svelte.js +1398 -0
  44. package/dist/svelte.js.map +1 -0
  45. package/dist/svelte.mjs +1391 -0
  46. package/dist/svelte.mjs.map +1 -0
  47. package/dist/vite.d.mts +37 -0
  48. package/dist/vite.d.ts +37 -0
  49. package/dist/vite.js +346 -0
  50. package/dist/vite.js.map +1 -0
  51. package/dist/vite.mjs +341 -0
  52. package/dist/vite.mjs.map +1 -0
  53. package/dist/vue.d.mts +49 -0
  54. package/dist/vue.d.ts +49 -0
  55. package/dist/vue.js +1388 -0
  56. package/dist/vue.js.map +1 -0
  57. package/dist/vue.mjs +1385 -0
  58. package/dist/vue.mjs.map +1 -0
  59. package/package.json +121 -0
package/dist/vite.js ADDED
@@ -0,0 +1,346 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ // src/polyfills/localStorage.ts
6
+ function installLocalStoragePolyfill() {
7
+ if (typeof window === "undefined") {
8
+ return;
9
+ }
10
+ console.log("[HaexHub] Storage Polyfill loading immediately");
11
+ let localStorageWorks = false;
12
+ try {
13
+ const testKey = "__ls_test__";
14
+ localStorage.setItem(testKey, testKey);
15
+ localStorage.removeItem(testKey);
16
+ localStorageWorks = true;
17
+ } catch (e) {
18
+ console.warn("[HaexHub] localStorage blocked \u2013 using in-memory fallback");
19
+ }
20
+ if (!localStorageWorks) {
21
+ const lsStorage = /* @__PURE__ */ new Map();
22
+ const localStoragePoly = {
23
+ getItem(key) {
24
+ return lsStorage.get(key) || null;
25
+ },
26
+ setItem(key, value) {
27
+ lsStorage.set(key, String(value));
28
+ },
29
+ removeItem(key) {
30
+ lsStorage.delete(key);
31
+ },
32
+ clear() {
33
+ lsStorage.clear();
34
+ },
35
+ get length() {
36
+ return lsStorage.size;
37
+ },
38
+ key(index) {
39
+ return Array.from(lsStorage.keys())[index] || null;
40
+ }
41
+ };
42
+ try {
43
+ Object.defineProperty(window, "localStorage", {
44
+ value: localStoragePoly,
45
+ writable: true,
46
+ configurable: true
47
+ });
48
+ } catch (e) {
49
+ window.localStorage = localStoragePoly;
50
+ }
51
+ console.log("[HaexHub] localStorage replaced with in-memory polyfill");
52
+ }
53
+ }
54
+ function installSessionStoragePolyfill() {
55
+ if (typeof window === "undefined") {
56
+ return;
57
+ }
58
+ try {
59
+ const sessionStoragePoly = {
60
+ getItem() {
61
+ return null;
62
+ },
63
+ setItem() {
64
+ },
65
+ removeItem() {
66
+ },
67
+ clear() {
68
+ },
69
+ get length() {
70
+ return 0;
71
+ },
72
+ key() {
73
+ return null;
74
+ }
75
+ };
76
+ Object.defineProperty(window, "sessionStorage", {
77
+ value: sessionStoragePoly,
78
+ writable: true,
79
+ configurable: true
80
+ });
81
+ } catch (e) {
82
+ window.sessionStorage = {
83
+ getItem: () => null,
84
+ setItem: () => {
85
+ },
86
+ removeItem: () => {
87
+ },
88
+ clear: () => {
89
+ },
90
+ get length() {
91
+ return 0;
92
+ },
93
+ key: () => null
94
+ };
95
+ }
96
+ console.log("[HaexHub] sessionStorage polyfill installed");
97
+ }
98
+
99
+ // src/polyfills/cookies.ts
100
+ function installCookiePolyfill() {
101
+ if (typeof window === "undefined" || typeof document === "undefined") {
102
+ return;
103
+ }
104
+ let cookiesWork = false;
105
+ try {
106
+ document.cookie = "__cookie_test__=1";
107
+ cookiesWork = document.cookie.indexOf("__cookie_test__") !== -1;
108
+ } catch (e) {
109
+ console.warn("[HaexHub] Cookies blocked \u2013 using in-memory fallback");
110
+ }
111
+ if (!cookiesWork) {
112
+ const cookieStore = /* @__PURE__ */ new Map();
113
+ Object.defineProperty(document, "cookie", {
114
+ get() {
115
+ const cookies = [];
116
+ cookieStore.forEach((value, key) => {
117
+ cookies.push(`${key}=${value}`);
118
+ });
119
+ return cookies.join("; ");
120
+ },
121
+ set(cookieString) {
122
+ const parts = cookieString.split(";").map((p) => p.trim());
123
+ const [keyValue] = parts;
124
+ if (!keyValue) return;
125
+ const [key, value] = keyValue.split("=");
126
+ if (!key) return;
127
+ const options = {};
128
+ for (let i = 1; i < parts.length; i++) {
129
+ const part = parts[i];
130
+ if (!part) continue;
131
+ const parts_split = part.split("=");
132
+ const optKey = parts_split[0];
133
+ const optValue = parts_split[1];
134
+ if (optKey) {
135
+ options[optKey.toLowerCase()] = optValue || true;
136
+ }
137
+ }
138
+ const expiresValue = options.expires;
139
+ if (expiresValue && typeof expiresValue === "string") {
140
+ const expiresDate = new Date(expiresValue);
141
+ if (expiresDate < /* @__PURE__ */ new Date()) {
142
+ cookieStore.delete(key);
143
+ return;
144
+ }
145
+ }
146
+ const maxAgeValue = options["max-age"];
147
+ if (typeof maxAgeValue === "string" && maxAgeValue === "0") {
148
+ cookieStore.delete(key);
149
+ return;
150
+ }
151
+ cookieStore.set(key, value || "");
152
+ },
153
+ configurable: true
154
+ });
155
+ console.log("[HaexHub] Cookie polyfill installed");
156
+ }
157
+ }
158
+
159
+ // src/polyfills/history.ts
160
+ function installHistoryPolyfill() {
161
+ if (typeof window === "undefined" || typeof history === "undefined") {
162
+ return;
163
+ }
164
+ const install = () => {
165
+ console.log("[HaexHub] History Patch loading");
166
+ const originalPushState = history.pushState;
167
+ const originalReplaceState = history.replaceState;
168
+ let skipNextPush = false;
169
+ let skipNextReplace = false;
170
+ history.pushState = function(state, title, url) {
171
+ console.log("[HaexHub] pushState called:", url, "skip:", skipNextPush);
172
+ if (skipNextPush) {
173
+ skipNextPush = false;
174
+ console.log("[HaexHub] pushState skipped");
175
+ return;
176
+ }
177
+ try {
178
+ return originalPushState.call(this, state, title, url);
179
+ } catch (e) {
180
+ if (e.name === "SecurityError" && url) {
181
+ const urlString = url.toString();
182
+ let hashUrl = urlString.replace(/^\/#/, "");
183
+ hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
184
+ console.log("[HaexHub] SecurityError - setting hash to:", hashUrl);
185
+ skipNextPush = true;
186
+ window.location.hash = hashUrl.replace(/^#/, "");
187
+ return;
188
+ }
189
+ throw e;
190
+ }
191
+ };
192
+ history.replaceState = function(state, title, url) {
193
+ console.log("[HaexHub] replaceState called:", url, "skip:", skipNextReplace);
194
+ if (skipNextReplace) {
195
+ skipNextReplace = false;
196
+ console.log("[HaexHub] replaceState skipped");
197
+ return;
198
+ }
199
+ try {
200
+ return originalReplaceState.call(this, state, title, url);
201
+ } catch (e) {
202
+ if (e.name === "SecurityError" && url) {
203
+ const urlString = url.toString();
204
+ let hashUrl = urlString.replace(/^\/#/, "");
205
+ hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
206
+ console.log("[HaexHub] SecurityError - setting hash to:", hashUrl);
207
+ skipNextReplace = true;
208
+ window.location.hash = hashUrl.replace(/^#/, "");
209
+ return;
210
+ }
211
+ throw e;
212
+ }
213
+ };
214
+ console.log("[HaexHub] History API patched");
215
+ };
216
+ if (document.readyState === "loading") {
217
+ document.addEventListener("DOMContentLoaded", install, { once: true });
218
+ } else {
219
+ install();
220
+ }
221
+ }
222
+
223
+ // src/polyfills/debug.ts
224
+ function installDebugDiagnostics() {
225
+ if (typeof window === "undefined") {
226
+ return;
227
+ }
228
+ const hasParent = window.parent && window.parent !== window;
229
+ console.log("[HaexHub] hasParent:", hasParent);
230
+ if (hasParent) {
231
+ console.log("[HaexHub] Attempting to send debug message to parent...");
232
+ window.parent.postMessage({
233
+ type: "haexhub:debug",
234
+ data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`
235
+ }, "*");
236
+ console.log("[HaexHub] Debug message sent!");
237
+ } else {
238
+ console.log("[HaexHub] No parent window or parent === window");
239
+ }
240
+ }
241
+
242
+ // src/polyfills/standalone.ts
243
+ function getPolyfillCode() {
244
+ const iife = `(function() {
245
+ 'use strict';
246
+
247
+ console.log('[HaexHub] Storage Polyfill loading immediately');
248
+
249
+ // localStorage Polyfill
250
+ (${installLocalStoragePolyfill.toString()})();
251
+
252
+ // sessionStorage Polyfill
253
+ (${installSessionStoragePolyfill.toString()})();
254
+
255
+ // Cookie Polyfill
256
+ (${installCookiePolyfill.toString()})();
257
+
258
+ // History API Polyfill
259
+ (${installHistoryPolyfill.toString()})();
260
+
261
+ // Note: Base tag is injected at build-time by Vite plugin, not at runtime
262
+
263
+ console.log('[HaexHub] All polyfills loaded successfully');
264
+
265
+ // Debug diagnostics for Android debugging
266
+ (${installDebugDiagnostics.toString()})();
267
+ })();`;
268
+ return iife;
269
+ }
270
+
271
+ // src/cors.ts
272
+ var HAEXHUB_CORS_HEADERS = {
273
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
274
+ "Access-Control-Allow-Headers": "*",
275
+ "Access-Control-Allow-Credentials": "true"
276
+ };
277
+ function applyCorsHeaders(res, origin) {
278
+ res.setHeader("Access-Control-Allow-Origin", origin || "*");
279
+ res.setHeader("Access-Control-Allow-Methods", HAEXHUB_CORS_HEADERS["Access-Control-Allow-Methods"]);
280
+ res.setHeader("Access-Control-Allow-Headers", HAEXHUB_CORS_HEADERS["Access-Control-Allow-Headers"]);
281
+ res.setHeader("Access-Control-Allow-Credentials", HAEXHUB_CORS_HEADERS["Access-Control-Allow-Credentials"]);
282
+ }
283
+
284
+ // src/vite.ts
285
+ function haexhubPlugin(options = {}) {
286
+ const { injectPolyfills = true, configureCors = true } = options;
287
+ let polyfillCode = null;
288
+ return {
289
+ name: "@haexhub/sdk",
290
+ enforce: "post",
291
+ // Run after other plugins
292
+ configResolved(config) {
293
+ if (injectPolyfills) {
294
+ try {
295
+ polyfillCode = getPolyfillCode();
296
+ console.log("\u2713 [@haexhub/sdk] Polyfills initialized");
297
+ } catch (error) {
298
+ console.error("[@haexhub/sdk] Failed to initialize:", error);
299
+ throw error;
300
+ }
301
+ }
302
+ if (configureCors && config.command === "serve") {
303
+ console.log("\u2713 [@haexhub/sdk] CORS configured for HaexHub development");
304
+ console.log(" - Allowing all origins (required for custom protocols)");
305
+ console.log(" - Allowing credentials");
306
+ }
307
+ },
308
+ configureServer(server) {
309
+ if (!configureCors) return;
310
+ server.middlewares.use((req, res, next) => {
311
+ applyCorsHeaders(res, req.headers.origin);
312
+ if (req.method === "OPTIONS") {
313
+ res.statusCode = 200;
314
+ res.end();
315
+ return;
316
+ }
317
+ next();
318
+ });
319
+ },
320
+ transformIndexHtml: {
321
+ order: "pre",
322
+ // Inject before other transformations
323
+ handler(html) {
324
+ if (!injectPolyfills || !polyfillCode) {
325
+ return html;
326
+ }
327
+ const headPos = html.indexOf("<head>");
328
+ if (headPos === -1) {
329
+ console.warn("[@haexhub/sdk] No <head> tag found in HTML");
330
+ return html;
331
+ }
332
+ const insertPos = headPos + 6;
333
+ const polyfillScript = `<script>${polyfillCode}</script>`;
334
+ const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos);
335
+ console.log("\u2713 [@haexhub/sdk] Polyfill injected into HTML");
336
+ return modifiedHtml;
337
+ }
338
+ }
339
+ };
340
+ }
341
+ var vite_default = haexhubPlugin;
342
+
343
+ exports.default = vite_default;
344
+ exports.haexhubPlugin = haexhubPlugin;
345
+ //# sourceMappingURL=vite.js.map
346
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/polyfills/localStorage.ts","../src/polyfills/cookies.ts","../src/polyfills/history.ts","../src/polyfills/debug.ts","../src/polyfills/standalone.ts","../src/cors.ts","../src/vite.ts"],"names":[],"mappings":";;;;;AAOO,SAAS,2BAAA,GAAoC;AAClD,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA;AAAA,EACF;AAEA,EAAA,OAAA,CAAQ,IAAI,gDAAgD,CAAA;AAG5D,EAAA,IAAI,iBAAA,GAAoB,KAAA;AACxB,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,aAAA;AAChB,IAAA,YAAA,CAAa,OAAA,CAAQ,SAAS,OAAO,CAAA;AACrC,IAAA,YAAA,CAAa,WAAW,OAAO,CAAA;AAC/B,IAAA,iBAAA,GAAoB,IAAA;AA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W,SAAA,EAAW;AAC5B,UAAA,GAAA,CAAI,UAAA,GAAa,GAAA;AACjB,UAAA,GAAA,CAAI,GAAA,EAAI;AACR,UAAA;AAAA,QACF;AAEA,QAAA,IAAA,EAAK;AAAA,MACP,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IAEA,kBAAA,EAAoB;AAAA,MAClB,KAAA,EAAO,KAAA;AAAA;AAAA,MACP,QAAQ,IAAA,EAAc;AACpB,QAAA,IAAI,CAAC,eAAA,IAAmB,CAAC,YAAA,EAAc;AACrC,UAAA,OAAO,IAAA;AAAA,QACT;AAGA,QAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACrC,QAAA,IAAI,YAAY,EAAA,EAAI;AAClB,UAAA,OAAA,CAAQ,KAAK,4CAA4C,CAAA;AACzD,UAAA,OAAO,IAAA;AAAA,QACT;AAEA,QAAA,MAAM,YAAY,OAAA,GAAU,CAAA;AAG5B,QAAA,MAAM,cAAA,GAAiB,WAAW,YAAY,CAAA,SAAA,CAAA;AAC9C,QAAA,MAAM,YAAA,GAAe,KAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,GAAI,cAAA,GAAiB,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA;AAErF,QAAA,OAAA,CAAQ,IAAI,mDAA8C,CAAA;AAE1D,QAAA,OAAO,YAAA;AAAA,MACT;AAAA;AACF,GACF;AACF;AAGA,IAAO,YAAA,GAAQ","file":"vite.js","sourcesContent":["/**\n * localStorage Polyfill for HaexHub Extensions\n *\n * Provides an in-memory fallback when localStorage is blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installLocalStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n console.log('[HaexHub] Storage Polyfill loading immediately');\n\n // Test if localStorage is available\n let localStorageWorks = false;\n try {\n const testKey = '__ls_test__';\n localStorage.setItem(testKey, testKey);\n localStorage.removeItem(testKey);\n localStorageWorks = true;\n } catch (e) {\n console.warn('[HaexHub] localStorage blocked – using in-memory fallback');\n }\n\n // If blocked: Replace with In-Memory Storage\n if (!localStorageWorks) {\n const lsStorage = new Map<string, string>();\n\n const localStoragePoly: Storage = {\n getItem(key: string): string | null {\n return lsStorage.get(key) || null;\n },\n setItem(key: string, value: string): void {\n lsStorage.set(key, String(value));\n },\n removeItem(key: string): void {\n lsStorage.delete(key);\n },\n clear(): void {\n lsStorage.clear();\n },\n get length(): number {\n return lsStorage.size;\n },\n key(index: number): string | null {\n return Array.from(lsStorage.keys())[index] || null;\n }\n };\n\n try {\n Object.defineProperty(window, 'localStorage', {\n value: localStoragePoly,\n writable: true,\n configurable: true\n });\n } catch (e) {\n // Fallback: Direct assignment\n (window as any).localStorage = localStoragePoly;\n }\n\n console.log('[HaexHub] localStorage replaced with in-memory polyfill');\n }\n}\n\n/**\n * sessionStorage Polyfill for HaexHub Extensions\n *\n * Provides a no-op implementation as session state doesn't work\n * reliably in custom protocol contexts\n */\nexport function installSessionStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n try {\n const sessionStoragePoly: Storage = {\n getItem(): null {\n return null;\n },\n setItem(): void {},\n removeItem(): void {},\n clear(): void {},\n get length(): number {\n return 0;\n },\n key(): null {\n return null;\n }\n };\n\n Object.defineProperty(window, 'sessionStorage', {\n value: sessionStoragePoly,\n writable: true,\n configurable: true\n });\n } catch (e) {\n // Fallback: Direct assignment\n (window as any).sessionStorage = {\n getItem: () => null,\n setItem: () => {},\n removeItem: () => {},\n clear: () => {},\n get length() { return 0; },\n key: () => null\n };\n }\n\n console.log('[HaexHub] sessionStorage polyfill installed');\n}\n","/**\n * Cookie Polyfill for HaexHub Extensions\n *\n * Provides an in-memory cookie implementation when cookies are blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installCookiePolyfill(): void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return; // Skip in Node.js environment\n }\n\n // Test if cookies are available\n let cookiesWork = false;\n try {\n document.cookie = \"__cookie_test__=1\";\n cookiesWork = document.cookie.indexOf(\"__cookie_test__\") !== -1;\n } catch (e) {\n console.warn(\"[HaexHub] Cookies blocked – using in-memory fallback\");\n }\n\n if (!cookiesWork) {\n const cookieStore = new Map<string, string>();\n\n Object.defineProperty(document, \"cookie\", {\n get(): string {\n const cookies: string[] = [];\n cookieStore.forEach((value, key) => {\n cookies.push(`${key}=${value}`);\n });\n return cookies.join(\"; \");\n },\n set(cookieString: string): void {\n const parts = cookieString.split(\";\").map((p) => p.trim());\n const [keyValue] = parts;\n\n if (!keyValue) return;\n\n const [key, value] = keyValue.split(\"=\");\n if (!key) return;\n\n // Parse options\n const options: Record<string, string | boolean> = {};\n for (let i = 1; i < parts.length; i++) {\n const part = parts[i];\n if (!part) continue;\n const parts_split = part.split(\"=\");\n const optKey = parts_split[0];\n const optValue = parts_split[1];\n if (optKey) {\n options[optKey.toLowerCase()] = optValue || true;\n }\n }\n\n // Check for deletion (expires in past)\n const expiresValue = options.expires;\n if (expiresValue && typeof expiresValue === \"string\") {\n const expiresDate = new Date(expiresValue);\n if (expiresDate < new Date()) {\n cookieStore.delete(key);\n return;\n }\n }\n\n // Check for max-age=0 deletion\n const maxAgeValue = options[\"max-age\"];\n if (typeof maxAgeValue === \"string\" && maxAgeValue === \"0\") {\n cookieStore.delete(key);\n return;\n }\n\n // Store cookie\n cookieStore.set(key, value || \"\");\n },\n configurable: true,\n });\n\n console.log(\"[HaexHub] Cookie polyfill installed\");\n }\n}\n","/**\n * History API Polyfill for HaexHub Extensions\n *\n * Works around SecurityError when using pushState/replaceState\n * in custom protocol contexts (haex-extension://)\n *\n * Falls back to hash-based routing when necessary\n */\n\nexport function installHistoryPolyfill(): void {\n if (typeof window === 'undefined' || typeof history === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n // Install after DOM is ready to avoid race conditions\n const install = () => {\n console.log('[HaexHub] History Patch loading');\n\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n let skipNextPush = false;\n let skipNextReplace = false;\n\n // Patch pushState\n history.pushState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexHub] pushState called:', url, 'skip:', skipNextPush);\n\n if (skipNextPush) {\n skipNextPush = false;\n console.log('[HaexHub] pushState skipped');\n return;\n }\n\n try {\n return originalPushState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexHub] SecurityError - setting hash to:', hashUrl);\n skipNextPush = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n // Patch replaceState\n history.replaceState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexHub] replaceState called:', url, 'skip:', skipNextReplace);\n\n if (skipNextReplace) {\n skipNextReplace = false;\n console.log('[HaexHub] replaceState skipped');\n return;\n }\n\n try {\n return originalReplaceState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexHub] SecurityError - setting hash to:', hashUrl);\n skipNextReplace = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n console.log('[HaexHub] History API patched');\n };\n\n // Install after DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', install, { once: true });\n } else {\n // DOM already loaded, install immediately\n install();\n }\n}\n","/**\n * Debug diagnostics for Android debugging\n * Tests window.parent availability and postMessage functionality\n */\nexport function installDebugDiagnostics(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n const hasParent = window.parent && window.parent !== window;\n console.log('[HaexHub] hasParent:', hasParent);\n\n if (hasParent) {\n console.log('[HaexHub] Attempting to send debug message to parent...');\n window.parent.postMessage({\n type: 'haexhub:debug',\n data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`\n }, '*');\n console.log('[HaexHub] Debug message sent!');\n } else {\n console.log('[HaexHub] No parent window or parent === window');\n }\n}\n","/**\n * Generates standalone polyfill code for HTML injection\n * This wraps the modular polyfills into an IIFE for immediate execution\n */\nimport {\n installLocalStoragePolyfill,\n installSessionStoragePolyfill,\n} from './localStorage'\nimport { installCookiePolyfill } from './cookies'\nimport { installHistoryPolyfill } from './history'\nimport { installDebugDiagnostics } from './debug'\n\n/**\n * Get the standalone polyfill code as a string\n * This is used by the Nuxt and Vite plugins to inject polyfills into HTML\n *\n * Note: Base tag is injected statically by the Vite plugin, not at runtime\n */\nexport function getPolyfillCode(): string {\n // Convert functions to string and wrap in IIFE\n const iife = `(function() {\n 'use strict';\n\n console.log('[HaexHub] Storage Polyfill loading immediately');\n\n // localStorage Polyfill\n (${installLocalStoragePolyfill.toString()})();\n\n // sessionStorage Polyfill\n (${installSessionStoragePolyfill.toString()})();\n\n // Cookie Polyfill\n (${installCookiePolyfill.toString()})();\n\n // History API Polyfill\n (${installHistoryPolyfill.toString()})();\n\n // Note: Base tag is injected at build-time by Vite plugin, not at runtime\n\n console.log('[HaexHub] All polyfills loaded successfully');\n\n // Debug diagnostics for Android debugging\n (${installDebugDiagnostics.toString()})();\n})();`\n\n return iife\n}\n","/**\n * CORS Configuration for HaexHub Extensions\n * Used by both Vite and Nuxt plugins to ensure consistent CORS headers\n */\n\n/**\n * Standard CORS headers for HaexHub dev servers\n * Allows extensions to be loaded in custom protocol iframes (haex-extension://)\n */\nexport const HAEXHUB_CORS_HEADERS = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': '*',\n 'Access-Control-Allow-Credentials': 'true',\n} as const\n\n/**\n * Apply CORS headers to a Node.js response object\n * Used in Vite middleware\n */\nexport function applyCorsHeaders(\n res: { setHeader: (name: string, value: string) => void },\n origin?: string\n) {\n res.setHeader('Access-Control-Allow-Origin', origin || '*')\n res.setHeader('Access-Control-Allow-Methods', HAEXHUB_CORS_HEADERS['Access-Control-Allow-Methods'])\n res.setHeader('Access-Control-Allow-Headers', HAEXHUB_CORS_HEADERS['Access-Control-Allow-Headers'])\n res.setHeader('Access-Control-Allow-Credentials', HAEXHUB_CORS_HEADERS['Access-Control-Allow-Credentials'])\n}\n\n/**\n * Get CORS headers as a plain object\n * Used in Vite/Nuxt config\n */\nexport function getCorsHeaders(origin?: string): Record<string, string> {\n return {\n 'Access-Control-Allow-Origin': origin || HAEXHUB_CORS_HEADERS['Access-Control-Allow-Origin'],\n 'Access-Control-Allow-Methods': HAEXHUB_CORS_HEADERS['Access-Control-Allow-Methods'],\n 'Access-Control-Allow-Headers': HAEXHUB_CORS_HEADERS['Access-Control-Allow-Headers'],\n 'Access-Control-Allow-Credentials': HAEXHUB_CORS_HEADERS['Access-Control-Allow-Credentials'],\n }\n}\n","/**\n * Vite Plugin for HaexHub SDK\n * Automatically injects polyfills into HTML files\n * Works with React, Vue, Svelte, and any other Vite-based project\n */\nimport type { Plugin } from 'vite'\nimport { getPolyfillCode } from './polyfills/standalone'\nimport { applyCorsHeaders } from './cors'\n\nexport interface VitePluginOptions {\n /**\n * Enable/disable polyfill injection\n * @default true\n */\n injectPolyfills?: boolean\n\n /**\n * Configure CORS for dev server\n * @default true\n */\n configureCors?: boolean\n}\n\n/**\n * HaexHub Vite Plugin\n * Injects browser API polyfills for extensions running in custom protocols\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { haexhubPlugin } from '@haexhub/sdk/vite'\n *\n * export default {\n * plugins: [haexhubPlugin()]\n * }\n * ```\n */\nexport function haexhubPlugin(options: VitePluginOptions = {}): Plugin {\n const { injectPolyfills = true, configureCors = true } = options\n\n let polyfillCode: string | null = null\n\n return {\n name: '@haexhub/sdk',\n enforce: 'post', // Run after other plugins\n\n configResolved(config) {\n if (injectPolyfills) {\n try {\n // Get polyfill code from modular polyfills\n polyfillCode = getPolyfillCode()\n console.log('✓ [@haexhub/sdk] Polyfills initialized')\n } catch (error) {\n console.error('[@haexhub/sdk] Failed to initialize:', error)\n throw error\n }\n }\n\n // Log CORS configuration\n if (configureCors && config.command === 'serve') {\n console.log('✓ [@haexhub/sdk] CORS configured for HaexHub development')\n console.log(' - Allowing all origins (required for custom protocols)')\n console.log(' - Allowing credentials')\n }\n },\n\n configureServer(server) {\n if (!configureCors) return\n\n // Add CORS middleware for HaexHub using shared CORS configuration\n server.middlewares.use((req, res, next) => {\n // Apply CORS headers (allows custom protocols like haex-extension://)\n applyCorsHeaders(res, req.headers.origin)\n\n // Handle preflight requests\n if (req.method === 'OPTIONS') {\n res.statusCode = 200\n res.end()\n return\n }\n\n next()\n })\n },\n\n transformIndexHtml: {\n order: 'pre', // Inject before other transformations\n handler(html: string) {\n if (!injectPolyfills || !polyfillCode) {\n return html\n }\n\n // Inject polyfill script directly after <head>\n const headPos = html.indexOf('<head>')\n if (headPos === -1) {\n console.warn('[@haexhub/sdk] No <head> tag found in HTML')\n return html\n }\n\n const insertPos = headPos + 6 // after <head>\n\n // Inject polyfill only (no base tag needed)\n const polyfillScript = `<script>${polyfillCode}</script>`\n const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos)\n\n console.log('✓ [@haexhub/sdk] Polyfill injected into HTML')\n\n return modifiedHtml\n }\n }\n }\n}\n\n// Default export for convenience\nexport default haexhubPlugin\n"]}