@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/nuxt.js ADDED
@@ -0,0 +1,473 @@
1
+ 'use strict';
2
+
3
+ var kit = require('@nuxt/kit');
4
+ var path = require('path');
5
+ var fs = require('fs');
6
+
7
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
8
+ // src/nuxt.ts
9
+
10
+ // src/cors.ts
11
+ var HAEXHUB_CORS_HEADERS = {
12
+ "Access-Control-Allow-Origin": "*",
13
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
14
+ "Access-Control-Allow-Headers": "*",
15
+ "Access-Control-Allow-Credentials": "true"
16
+ };
17
+ function getCorsHeaders(origin) {
18
+ return {
19
+ "Access-Control-Allow-Origin": origin || HAEXHUB_CORS_HEADERS["Access-Control-Allow-Origin"],
20
+ "Access-Control-Allow-Methods": HAEXHUB_CORS_HEADERS["Access-Control-Allow-Methods"],
21
+ "Access-Control-Allow-Headers": HAEXHUB_CORS_HEADERS["Access-Control-Allow-Headers"],
22
+ "Access-Control-Allow-Credentials": HAEXHUB_CORS_HEADERS["Access-Control-Allow-Credentials"]
23
+ };
24
+ }
25
+
26
+ // src/polyfills/localStorage.ts
27
+ function installLocalStoragePolyfill() {
28
+ if (typeof window === "undefined") {
29
+ return;
30
+ }
31
+ console.log("[HaexHub] Storage Polyfill loading immediately");
32
+ let localStorageWorks = false;
33
+ try {
34
+ const testKey = "__ls_test__";
35
+ localStorage.setItem(testKey, testKey);
36
+ localStorage.removeItem(testKey);
37
+ localStorageWorks = true;
38
+ } catch (e) {
39
+ console.warn("[HaexHub] localStorage blocked \u2013 using in-memory fallback");
40
+ }
41
+ if (!localStorageWorks) {
42
+ const lsStorage = /* @__PURE__ */ new Map();
43
+ const localStoragePoly = {
44
+ getItem(key) {
45
+ return lsStorage.get(key) || null;
46
+ },
47
+ setItem(key, value) {
48
+ lsStorage.set(key, String(value));
49
+ },
50
+ removeItem(key) {
51
+ lsStorage.delete(key);
52
+ },
53
+ clear() {
54
+ lsStorage.clear();
55
+ },
56
+ get length() {
57
+ return lsStorage.size;
58
+ },
59
+ key(index) {
60
+ return Array.from(lsStorage.keys())[index] || null;
61
+ }
62
+ };
63
+ try {
64
+ Object.defineProperty(window, "localStorage", {
65
+ value: localStoragePoly,
66
+ writable: true,
67
+ configurable: true
68
+ });
69
+ } catch (e) {
70
+ window.localStorage = localStoragePoly;
71
+ }
72
+ console.log("[HaexHub] localStorage replaced with in-memory polyfill");
73
+ }
74
+ }
75
+ function installSessionStoragePolyfill() {
76
+ if (typeof window === "undefined") {
77
+ return;
78
+ }
79
+ try {
80
+ const sessionStoragePoly = {
81
+ getItem() {
82
+ return null;
83
+ },
84
+ setItem() {
85
+ },
86
+ removeItem() {
87
+ },
88
+ clear() {
89
+ },
90
+ get length() {
91
+ return 0;
92
+ },
93
+ key() {
94
+ return null;
95
+ }
96
+ };
97
+ Object.defineProperty(window, "sessionStorage", {
98
+ value: sessionStoragePoly,
99
+ writable: true,
100
+ configurable: true
101
+ });
102
+ } catch (e) {
103
+ window.sessionStorage = {
104
+ getItem: () => null,
105
+ setItem: () => {
106
+ },
107
+ removeItem: () => {
108
+ },
109
+ clear: () => {
110
+ },
111
+ get length() {
112
+ return 0;
113
+ },
114
+ key: () => null
115
+ };
116
+ }
117
+ console.log("[HaexHub] sessionStorage polyfill installed");
118
+ }
119
+
120
+ // src/polyfills/cookies.ts
121
+ function installCookiePolyfill() {
122
+ if (typeof window === "undefined" || typeof document === "undefined") {
123
+ return;
124
+ }
125
+ let cookiesWork = false;
126
+ try {
127
+ document.cookie = "__cookie_test__=1";
128
+ cookiesWork = document.cookie.indexOf("__cookie_test__") !== -1;
129
+ } catch (e) {
130
+ console.warn("[HaexHub] Cookies blocked \u2013 using in-memory fallback");
131
+ }
132
+ if (!cookiesWork) {
133
+ const cookieStore = /* @__PURE__ */ new Map();
134
+ Object.defineProperty(document, "cookie", {
135
+ get() {
136
+ const cookies = [];
137
+ cookieStore.forEach((value, key) => {
138
+ cookies.push(`${key}=${value}`);
139
+ });
140
+ return cookies.join("; ");
141
+ },
142
+ set(cookieString) {
143
+ const parts = cookieString.split(";").map((p) => p.trim());
144
+ const [keyValue] = parts;
145
+ if (!keyValue) return;
146
+ const [key, value] = keyValue.split("=");
147
+ if (!key) return;
148
+ const options = {};
149
+ for (let i = 1; i < parts.length; i++) {
150
+ const part = parts[i];
151
+ if (!part) continue;
152
+ const parts_split = part.split("=");
153
+ const optKey = parts_split[0];
154
+ const optValue = parts_split[1];
155
+ if (optKey) {
156
+ options[optKey.toLowerCase()] = optValue || true;
157
+ }
158
+ }
159
+ const expiresValue = options.expires;
160
+ if (expiresValue && typeof expiresValue === "string") {
161
+ const expiresDate = new Date(expiresValue);
162
+ if (expiresDate < /* @__PURE__ */ new Date()) {
163
+ cookieStore.delete(key);
164
+ return;
165
+ }
166
+ }
167
+ const maxAgeValue = options["max-age"];
168
+ if (typeof maxAgeValue === "string" && maxAgeValue === "0") {
169
+ cookieStore.delete(key);
170
+ return;
171
+ }
172
+ cookieStore.set(key, value || "");
173
+ },
174
+ configurable: true
175
+ });
176
+ console.log("[HaexHub] Cookie polyfill installed");
177
+ }
178
+ }
179
+
180
+ // src/polyfills/history.ts
181
+ function installHistoryPolyfill() {
182
+ if (typeof window === "undefined" || typeof history === "undefined") {
183
+ return;
184
+ }
185
+ const install = () => {
186
+ console.log("[HaexHub] History Patch loading");
187
+ const originalPushState = history.pushState;
188
+ const originalReplaceState = history.replaceState;
189
+ let skipNextPush = false;
190
+ let skipNextReplace = false;
191
+ history.pushState = function(state, title, url) {
192
+ console.log("[HaexHub] pushState called:", url, "skip:", skipNextPush);
193
+ if (skipNextPush) {
194
+ skipNextPush = false;
195
+ console.log("[HaexHub] pushState skipped");
196
+ return;
197
+ }
198
+ try {
199
+ return originalPushState.call(this, state, title, url);
200
+ } catch (e) {
201
+ if (e.name === "SecurityError" && url) {
202
+ const urlString = url.toString();
203
+ let hashUrl = urlString.replace(/^\/#/, "");
204
+ hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
205
+ console.log("[HaexHub] SecurityError - setting hash to:", hashUrl);
206
+ skipNextPush = true;
207
+ window.location.hash = hashUrl.replace(/^#/, "");
208
+ return;
209
+ }
210
+ throw e;
211
+ }
212
+ };
213
+ history.replaceState = function(state, title, url) {
214
+ console.log("[HaexHub] replaceState called:", url, "skip:", skipNextReplace);
215
+ if (skipNextReplace) {
216
+ skipNextReplace = false;
217
+ console.log("[HaexHub] replaceState skipped");
218
+ return;
219
+ }
220
+ try {
221
+ return originalReplaceState.call(this, state, title, url);
222
+ } catch (e) {
223
+ if (e.name === "SecurityError" && url) {
224
+ const urlString = url.toString();
225
+ let hashUrl = urlString.replace(/^\/#/, "");
226
+ hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
227
+ console.log("[HaexHub] SecurityError - setting hash to:", hashUrl);
228
+ skipNextReplace = true;
229
+ window.location.hash = hashUrl.replace(/^#/, "");
230
+ return;
231
+ }
232
+ throw e;
233
+ }
234
+ };
235
+ console.log("[HaexHub] History API patched");
236
+ };
237
+ if (document.readyState === "loading") {
238
+ document.addEventListener("DOMContentLoaded", install, { once: true });
239
+ } else {
240
+ install();
241
+ }
242
+ }
243
+
244
+ // src/polyfills/debug.ts
245
+ function installDebugDiagnostics() {
246
+ if (typeof window === "undefined") {
247
+ return;
248
+ }
249
+ const hasParent = window.parent && window.parent !== window;
250
+ console.log("[HaexHub] hasParent:", hasParent);
251
+ if (hasParent) {
252
+ console.log("[HaexHub] Attempting to send debug message to parent...");
253
+ window.parent.postMessage({
254
+ type: "haexhub:debug",
255
+ data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`
256
+ }, "*");
257
+ console.log("[HaexHub] Debug message sent!");
258
+ } else {
259
+ console.log("[HaexHub] No parent window or parent === window");
260
+ }
261
+ }
262
+
263
+ // src/polyfills/standalone.ts
264
+ function getPolyfillCode() {
265
+ const iife = `(function() {
266
+ 'use strict';
267
+
268
+ console.log('[HaexHub] Storage Polyfill loading immediately');
269
+
270
+ // localStorage Polyfill
271
+ (${installLocalStoragePolyfill.toString()})();
272
+
273
+ // sessionStorage Polyfill
274
+ (${installSessionStoragePolyfill.toString()})();
275
+
276
+ // Cookie Polyfill
277
+ (${installCookiePolyfill.toString()})();
278
+
279
+ // History API Polyfill
280
+ (${installHistoryPolyfill.toString()})();
281
+
282
+ // Note: Base tag is injected at build-time by Vite plugin, not at runtime
283
+
284
+ console.log('[HaexHub] All polyfills loaded successfully');
285
+
286
+ // Debug diagnostics for Android debugging
287
+ (${installDebugDiagnostics.toString()})();
288
+ })();`;
289
+ return iife;
290
+ }
291
+ function readHaextensionConfig(rootDir = process.cwd()) {
292
+ const configPath = path.resolve(rootDir, "haextension.config.json");
293
+ if (!fs.existsSync(configPath)) {
294
+ return null;
295
+ }
296
+ try {
297
+ const content = fs.readFileSync(configPath, "utf-8");
298
+ return JSON.parse(content);
299
+ } catch (error) {
300
+ console.warn(`Failed to parse haextension.config.json: ${error}`);
301
+ return null;
302
+ }
303
+ }
304
+ function readManifest(options) {
305
+ const { rootDir, manifestPath, extensionDir = "haextension" } = options;
306
+ const resolvedManifestPath = manifestPath ? path.resolve(rootDir, manifestPath) : path.resolve(rootDir, extensionDir, "manifest.json");
307
+ try {
308
+ const manifestContent = fs.readFileSync(resolvedManifestPath, "utf-8");
309
+ const parsed = JSON.parse(manifestContent);
310
+ let version = parsed.version;
311
+ if (!version) {
312
+ try {
313
+ const packageJsonPath = path.resolve(rootDir, "package.json");
314
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
315
+ version = packageJson.version;
316
+ console.log(`\u2713 [@haexhub/sdk] Using version from package.json: ${version}`);
317
+ } catch (pkgError) {
318
+ console.warn(`[@haexhub/sdk] Warning: Could not read version from package.json`);
319
+ }
320
+ }
321
+ const manifest = {
322
+ name: parsed.name,
323
+ version,
324
+ author: parsed.author ?? null,
325
+ entry: parsed.entry ?? null,
326
+ icon: parsed.icon ?? null,
327
+ public_key: parsed.public_key,
328
+ signature: parsed.signature || "",
329
+ permissions: parsed.permissions || {
330
+ database: [],
331
+ filesystem: [],
332
+ http: [],
333
+ shell: []
334
+ },
335
+ homepage: parsed.homepage ?? null,
336
+ description: parsed.description ?? null,
337
+ single_instance: parsed.single_instance ?? null,
338
+ display_mode: parsed.display_mode ?? null
339
+ };
340
+ console.log(`\u2713 [@haexhub/sdk] Loaded ${resolvedManifestPath}`);
341
+ return manifest;
342
+ } catch (error) {
343
+ console.warn(
344
+ `[@haexhub/sdk] Warning: manifest.json not found at ${resolvedManifestPath}, extension info will not be available`
345
+ );
346
+ return null;
347
+ }
348
+ }
349
+
350
+ // src/nuxt.ts
351
+ var nuxt_default = kit.defineNuxtModule({
352
+ meta: {
353
+ name: "@haexhub/sdk",
354
+ configKey: "haexhub",
355
+ compatibility: {
356
+ nuxt: "^3.0.0 || ^4.0.0"
357
+ }
358
+ },
359
+ defaults: {
360
+ injectPolyfills: true,
361
+ extensionDir: "haextension"
362
+ },
363
+ async setup(options, nuxt) {
364
+ const { resolve: resolve2 } = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('nuxt.js', document.baseURI).href)));
365
+ nuxt.hook("prepare:types", ({ references }) => {
366
+ references.push({ path: resolve2("./runtime/nuxt.types.d.ts") });
367
+ });
368
+ const config = readHaextensionConfig(nuxt.options.rootDir);
369
+ const extensionDir = options.extensionDir || config?.dev?.haextension_dir || "haextension";
370
+ const manifest = readManifest({
371
+ rootDir: nuxt.options.rootDir,
372
+ manifestPath: options.manifestPath,
373
+ extensionDir
374
+ });
375
+ nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
376
+ nuxt.options.runtimeConfig.public.haexhubManifest = manifest;
377
+ kit.addPlugin({
378
+ src: resolve2("./runtime/nuxt.plugin.client.mjs"),
379
+ mode: "client"
380
+ });
381
+ if (options.injectPolyfills && nuxt.options.dev) {
382
+ nuxt.hook("nitro:config", (nitroConfig) => {
383
+ nitroConfig.hooks = nitroConfig.hooks || {};
384
+ nitroConfig.hooks["render:html"] = nitroConfig.hooks["render:html"] || [];
385
+ const polyfillCode = getPolyfillCode();
386
+ const polyfillScript = `<script data-haexhub-polyfill>${polyfillCode}</script>`;
387
+ nitroConfig.hooks["render:html"].unshift((html) => {
388
+ if (html.head && Array.isArray(html.head)) {
389
+ html.head.unshift(polyfillScript);
390
+ }
391
+ });
392
+ });
393
+ console.log(
394
+ "\u2713 [@haexhub/sdk] Dev mode: Priority polyfill injection configured"
395
+ );
396
+ }
397
+ if (nuxt.options.dev) {
398
+ nuxt.options.app.baseURL = "/";
399
+ nuxt.options.app.buildAssetsDir = "/_nuxt/";
400
+ nuxt.options.vite = nuxt.options.vite || {};
401
+ nuxt.options.vite.server = nuxt.options.vite.server || {};
402
+ nuxt.options.vite.server.cors = true;
403
+ nuxt.options.vite.server.headers = getCorsHeaders();
404
+ console.log(
405
+ "\u2713 [@haexhub/sdk] Dev mode: Set app.baseURL to / (absolute paths for dev server)"
406
+ );
407
+ console.log("\u2713 [@haexhub/sdk] Dev mode: Enabled CORS headers");
408
+ } else {
409
+ nuxt.options.app.baseURL = "./";
410
+ nuxt.options.app.buildAssetsDir = "_nuxt/";
411
+ console.log(
412
+ "\u2713 [@haexhub/sdk] Build mode: Set app.baseURL to relative path (./)"
413
+ );
414
+ console.log(
415
+ "\u2713 [@haexhub/sdk] Build mode: Set buildAssetsDir to relative path (_nuxt/)"
416
+ );
417
+ }
418
+ nuxt.options.experimental = nuxt.options.experimental || {};
419
+ nuxt.options.experimental.appManifest = false;
420
+ nuxt.options.experimental.payloadExtraction = false;
421
+ console.log(
422
+ "\u2713 [@haexhub/sdk] Disabled appManifest (not needed for extensions)"
423
+ );
424
+ console.log(
425
+ "\u2713 [@haexhub/sdk] Disabled payloadExtraction (not needed for SPAs)"
426
+ );
427
+ if (!options.injectPolyfills || nuxt.options.dev) {
428
+ return;
429
+ }
430
+ nuxt.hook("nitro:build:public-assets", async () => {
431
+ try {
432
+ const nitroOutput = nuxt.options.nitro?.output || {};
433
+ const outputDir = nitroOutput.dir || ".output";
434
+ const publicDir = nitroOutput.publicDir || "public";
435
+ const distDir = path.resolve(nuxt.options.rootDir, outputDir, publicDir);
436
+ const polyfillCode = getPolyfillCode();
437
+ const polyfillScript = `<script>${polyfillCode}</script>`;
438
+ const htmlFiles = fs.readdirSync(distDir).filter(
439
+ (f) => f.endsWith(".html")
440
+ );
441
+ for (const file of htmlFiles) {
442
+ const filePath = path.join(distDir, file);
443
+ let html = fs.readFileSync(filePath, "utf-8");
444
+ const headPos = html.indexOf("<head>");
445
+ if (headPos !== -1) {
446
+ const insertPos = headPos + 6;
447
+ html = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos);
448
+ }
449
+ html = html.replace(/\b(href|src)="\/_nuxt\//g, '$1="_nuxt/');
450
+ html = html.replace(
451
+ /"imports":\{"#entry":"\/_nuxt\//g,
452
+ '"imports":{"#entry":"./_nuxt/'
453
+ );
454
+ html = html.replace(
455
+ /buildAssetsDir:"\/_nuxt\/"/g,
456
+ 'buildAssetsDir:"./_nuxt/"'
457
+ );
458
+ html = html.replace(/"\/_nuxt\//g, '"./_nuxt/');
459
+ fs.writeFileSync(filePath, html);
460
+ console.log(
461
+ `\u2713 [@haexhub/sdk] Polyfill and relative paths applied to ${file}`
462
+ );
463
+ }
464
+ } catch (error) {
465
+ console.error("[@haexhub/sdk] Failed to inject polyfill:", error);
466
+ }
467
+ });
468
+ }
469
+ });
470
+
471
+ module.exports = nuxt_default;
472
+ //# sourceMappingURL=nuxt.js.map
473
+ //# sourceMappingURL=nuxt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cors.ts","../src/polyfills/localStorage.ts","../src/polyfills/cookies.ts","../src/polyfills/history.ts","../src/polyfills/debug.ts","../src/polyfills/standalone.ts","../src/config.ts","../src/manifest.ts","../src/nuxt.ts"],"names":["resolve","existsSync","readFileSync","resolvePath","defineNuxtModule","createResolver","addPlugin","readdirSync","join","writeFileSync"],"mappings":";;;;;;;;;;AASO,IAAM,oBAAA,GAAuB;AAAA,EAClC,6BAAA,EAA+B,GAAA;AAAA,EAC/B,8BAAA,EAAgC,wCAAA;AAAA,EAChC,8BAAA,EAAgC,GAAA;AAAA,EAChC,kCAAA,EAAoC;AACtC,CAAA;AAoBO,SAAS,eAAe,MAAA,EAAyC;AACtE,EAAA,OAAO;AAAA,IACL,6BAAA,EAA+B,MAAA,IAAU,oBAAA,CAAqB,6BAA6B,CAAA;AAAA,IAC3F,8BAAA,EAAgC,qBAAqB,8BAA8B,CAAA;AAAA,IACnF,8BAAA,EAAgC,qBAAqB,8BAA8B,CAAA;AAAA,IACnF,kCAAA,EAAoC,qBAAqB,kCAAkC;AAAA,GAC7F;AACF;;;AClCO,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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IAAI,CAAA;AACnC,UAAA,IAAI,IAAA,GAAON,eAAAA,CAAa,QAAA,EAAU,OAAO,CAAA;AAGzC,UAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACrC,UAAA,IAAI,YAAY,CAAA,CAAA,EAAI;AAClB,YAAA,MAAM,YAAY,OAAA,GAAU,CAAA;AAC5B,YAAA,IAAA,GACE,IAAA,CAAK,MAAM,CAAA,EAAG,SAAS,IAAI,cAAA,GAAiB,IAAA,CAAK,MAAM,SAAS,CAAA;AAAA,UACpE;AAMA,UAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,0BAAA,EAA4B,YAAY,CAAA;AAG5D,UAAA,IAAA,GAAO,IAAA,CAAK,OAAA;AAAA,YACV,kCAAA;AAAA,YACA;AAAA,WACF;AAGA,UAAA,IAAA,GAAO,IAAA,CAAK,OAAA;AAAA,YACV,6BAAA;AAAA,YACA;AAAA,WACF;AAGA,UAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,aAAA,EAAe,WAAW,CAAA;AAE9C,UAAAO,gBAAA,CAAc,UAAU,IAAI,CAAA;AAC5B,UAAA,OAAA,CAAQ,GAAA;AAAA,YACN,gEAA2D,IAAI,CAAA;AAAA,WACjE;AAAA,QACF;AAAA,MACF,SAAS,KAAA,EAAgB;AACvB,QAAA,OAAA,CAAQ,KAAA,CAAM,6CAA6C,KAAK,CAAA;AAAA,MAClE;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC","file":"nuxt.js","sourcesContent":["/**\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 * 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 * Utility to read haextension.config.json\n */\nimport { readFileSync, existsSync } from 'fs'\nimport { resolve } from 'path'\n\nexport interface HaextensionConfig {\n dev?: {\n port?: number\n host?: string\n haextension_dir?: string\n }\n keys?: {\n public_key_path?: string\n private_key_path?: string\n }\n build?: {\n distDir?: string\n }\n}\n\n/**\n * Read haextension.config.json from the project root\n * Returns null if file doesn't exist\n */\nexport function readHaextensionConfig(rootDir: string = process.cwd()): HaextensionConfig | null {\n const configPath = resolve(rootDir, 'haextension.config.json')\n \n if (!existsSync(configPath)) {\n return null\n }\n\n try {\n const content = readFileSync(configPath, 'utf-8')\n return JSON.parse(content)\n } catch (error) {\n console.warn(`Failed to parse haextension.config.json: ${error}`)\n return null\n }\n}\n\n/**\n * Get extension directory from config or use default\n */\nexport function getExtensionDir(rootDir: string = process.cwd()): string {\n const config = readHaextensionConfig(rootDir)\n return config?.dev?.haextension_dir || 'haextension'\n}\n","/**\n * Utility for reading and processing extension manifest files\n */\nimport { readFileSync } from \"node:fs\";\nimport { resolve as resolvePath } from \"node:path\";\nimport type { ExtensionManifest } from \"./types\";\n\nexport interface ReadManifestOptions {\n /** Root directory of the project */\n rootDir: string;\n /** Path to manifest.json (if not provided, will use extensionDir) */\n manifestPath?: string;\n /** Directory containing extension files (default: \"haextension\") */\n extensionDir?: string;\n}\n\n/**\n * Reads and processes the extension manifest.json file\n * Falls back to package.json version if manifest doesn't specify one\n */\nexport function readManifest(options: ReadManifestOptions): ExtensionManifest | null {\n const { rootDir, manifestPath, extensionDir = \"haextension\" } = options;\n\n // Determine manifest path\n const resolvedManifestPath = manifestPath\n ? resolvePath(rootDir, manifestPath)\n : resolvePath(rootDir, extensionDir, \"manifest.json\");\n\n try {\n const manifestContent = readFileSync(resolvedManifestPath, \"utf-8\");\n const parsed = JSON.parse(manifestContent);\n\n // Read version from package.json if not provided in manifest\n let version = parsed.version;\n if (!version) {\n try {\n const packageJsonPath = resolvePath(rootDir, \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n version = packageJson.version;\n console.log(`✓ [@haexhub/sdk] Using version from package.json: ${version}`);\n } catch (pkgError) {\n console.warn(`[@haexhub/sdk] Warning: Could not read version from package.json`);\n }\n }\n\n const manifest: ExtensionManifest = {\n name: parsed.name,\n version: version,\n author: parsed.author ?? null,\n entry: parsed.entry ?? null,\n icon: parsed.icon ?? null,\n public_key: parsed.public_key,\n signature: parsed.signature || \"\",\n permissions: parsed.permissions || {\n database: [],\n filesystem: [],\n http: [],\n shell: [],\n },\n homepage: parsed.homepage ?? null,\n description: parsed.description ?? null,\n single_instance: parsed.single_instance ?? null,\n display_mode: parsed.display_mode ?? null,\n };\n\n console.log(`✓ [@haexhub/sdk] Loaded ${resolvedManifestPath}`);\n return manifest;\n } catch (error) {\n console.warn(\n `[@haexhub/sdk] Warning: manifest.json not found at ${resolvedManifestPath}, extension info will not be available`\n );\n return null;\n }\n}\n","/**\n * Nuxt Module for HaexHub SDK\n * Automatically injects polyfills into the built HTML files\n */\nimport { addPlugin, createResolver, defineNuxtModule } from \"@nuxt/kit\";\nimport { getCorsHeaders } from \"./cors\";\nimport { getPolyfillCode } from \"./polyfills/standalone\";\nimport { join, resolve as resolvePath } from \"node:path\";\nimport { readFileSync, writeFileSync, readdirSync } from \"node:fs\";\nimport type { Nuxt } from \"@nuxt/schema\";\nimport { readHaextensionConfig } from \"./config\";\nimport { readManifest } from \"./manifest\";\n\nexport interface ModuleOptions {\n injectPolyfills?: boolean;\n /**\n * Directory containing extension files (manifest.json, public.key, private.key)\n * Default: \"haextension\"\n */\n extensionDir?: string;\n /** Path to manifest.json (overrides extensionDir if specified) */\n manifestPath?: string;\n /** Path to public.key (overrides extensionDir if specified) */\n publicKeyPath?: string;\n /** Path to private.key (overrides extensionDir if specified) */\n privateKeyPath?: string;\n}\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: \"@haexhub/sdk\",\n configKey: \"haexhub\",\n compatibility: {\n nuxt: \"^3.0.0 || ^4.0.0\",\n },\n },\n\n defaults: {\n injectPolyfills: true,\n extensionDir: \"haextension\",\n },\n\n async setup(options: ModuleOptions, nuxt: Nuxt) {\n const { resolve } = createResolver(import.meta.url);\n\n // Add type declaration for $haexhub\n nuxt.hook('prepare:types', ({ references }) => {\n references.push({ path: resolve('./runtime/nuxt.types.d.ts') })\n })\n\n // Read haextension.config.json if available\n const config = readHaextensionConfig(nuxt.options.rootDir);\n\n // Use config values as defaults if not explicitly set in options\n const extensionDir = options.extensionDir || config?.dev?.haextension_dir || \"haextension\";\n\n // Read manifest.json using shared utility\n const manifest = readManifest({\n rootDir: nuxt.options.rootDir,\n manifestPath: options.manifestPath,\n extensionDir,\n });\n\n // Inject manifest into public runtime config\n nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};\n nuxt.options.runtimeConfig.public.haexhubManifest = manifest;\n\n addPlugin({\n src: resolve(\"./runtime/nuxt.plugin.client.mjs\"),\n mode: \"client\",\n });\n // CRITICAL: Install polyfill hook BEFORE any other module\n // This ensures polyfills load before color-mode or any other script\n if (options.injectPolyfills && nuxt.options.dev) {\n nuxt.hook(\"nitro:config\", (nitroConfig: any) => {\n nitroConfig.hooks = nitroConfig.hooks || {};\n nitroConfig.hooks[\"render:html\"] =\n nitroConfig.hooks[\"render:html\"] || [];\n\n // Prepend (unshift) to run before ALL other hooks\n const polyfillCode = getPolyfillCode();\n const polyfillScript = `<script data-haexhub-polyfill>${polyfillCode}</script>`;\n\n nitroConfig.hooks[\"render:html\"].unshift((html: any) => {\n // Inject at the very beginning of <head>\n if (html.head && Array.isArray(html.head)) {\n html.head.unshift(polyfillScript);\n }\n });\n });\n console.log(\n \"✓ [@haexhub/sdk] Dev mode: Priority polyfill injection configured\"\n );\n }\n\n // Configure Nuxt differently for dev vs production\n if (nuxt.options.dev) {\n // DEV MODE: Use absolute paths for dev server\n nuxt.options.app.baseURL = \"/\";\n nuxt.options.app.buildAssetsDir = \"/_nuxt/\";\n\n // Enable CORS for dev server using shared CORS configuration\n nuxt.options.vite = nuxt.options.vite || {};\n nuxt.options.vite.server = nuxt.options.vite.server || {};\n nuxt.options.vite.server.cors = true;\n nuxt.options.vite.server.headers = getCorsHeaders();\n\n console.log(\n \"✓ [@haexhub/sdk] Dev mode: Set app.baseURL to / (absolute paths for dev server)\"\n );\n console.log(\"✓ [@haexhub/sdk] Dev mode: Enabled CORS headers\");\n } else {\n // PRODUCTION BUILD: Use relative paths\n nuxt.options.app.baseURL = \"./\";\n nuxt.options.app.buildAssetsDir = \"_nuxt/\"; // Remove leading slash\n\n console.log(\n \"✓ [@haexhub/sdk] Build mode: Set app.baseURL to relative path (./)\"\n );\n console.log(\n \"✓ [@haexhub/sdk] Build mode: Set buildAssetsDir to relative path (_nuxt/)\"\n );\n }\n\n // Disable app manifest feature (generates /_nuxt/builds/meta/*.json)\n // This is not needed for extensions and causes 404 errors\n nuxt.options.experimental = nuxt.options.experimental || {};\n nuxt.options.experimental.appManifest = false;\n\n // Disable payload extraction for SPAs (extensions don't need SSR payload)\n // This prevents \"Cannot load payload\" errors for _payload.json files\n nuxt.options.experimental.payloadExtraction = false;\n\n console.log(\n \"✓ [@haexhub/sdk] Disabled appManifest (not needed for extensions)\"\n );\n console.log(\n \"✓ [@haexhub/sdk] Disabled payloadExtraction (not needed for SPAs)\"\n );\n\n // Only inject polyfills if enabled and building for production\n if (!options.injectPolyfills || nuxt.options.dev) {\n return;\n }\n\n // Add hook to inject polyfills after HTML generation\n nuxt.hook(\"nitro:build:public-assets\", async () => {\n try {\n // Use Nuxt's configured output directory\n const nitroOutput = nuxt.options.nitro?.output || {};\n const outputDir = nitroOutput.dir || \".output\";\n const publicDir = nitroOutput.publicDir || \"public\";\n const distDir = resolvePath(nuxt.options.rootDir, outputDir, publicDir);\n\n // Get polyfill code from modular polyfills\n const polyfillCode = getPolyfillCode();\n const polyfillScript = `<script>${polyfillCode}</script>`;\n\n // Find all HTML files in the output directory\n const htmlFiles = readdirSync(distDir).filter((f: string) =>\n f.endsWith(\".html\")\n );\n\n for (const file of htmlFiles) {\n const filePath = join(distDir, file);\n let html = readFileSync(filePath, \"utf-8\");\n\n // Inject polyfill directly after <head>\n const headPos = html.indexOf(\"<head>\");\n if (headPos !== -1) {\n const insertPos = headPos + 6; // after <head>\n html =\n html.slice(0, insertPos) + polyfillScript + html.slice(insertPos);\n }\n\n // IMPORTANT: Convert all absolute asset paths to relative paths\n // Replace all occurrences of /_nuxt/ with _nuxt/ to make paths relative\n\n // Fix <link> and <script> tags\n html = html.replace(/\\b(href|src)=\"\\/_nuxt\\//g, '$1=\"_nuxt/');\n\n // Fix import maps - need to keep it absolute or use ./ prefix for module resolution\n html = html.replace(\n /\"imports\":\\{\"#entry\":\"\\/_nuxt\\//g,\n '\"imports\":{\"#entry\":\"./_nuxt/'\n );\n\n // Fix buildAssetsDir in runtime config\n html = html.replace(\n /buildAssetsDir:\"\\/_nuxt\\/\"/g,\n 'buildAssetsDir:\"./_nuxt/\"'\n );\n\n // Fix any remaining absolute /_nuxt/ references in JSON/JS\n html = html.replace(/\"\\/_nuxt\\//g, '\"./_nuxt/');\n\n writeFileSync(filePath, html);\n console.log(\n `✓ [@haexhub/sdk] Polyfill and relative paths applied to ${file}`\n );\n }\n } catch (error: unknown) {\n console.error(\"[@haexhub/sdk] Failed to inject polyfill:\", error);\n }\n });\n },\n});\n"]}