@haex-space/vault-sdk 2.2.7 → 2.3.1
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.
- package/dist/cli/index.js +5 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +5 -5
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +23 -8
- package/dist/index.d.ts +23 -8
- package/dist/index.js +53 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -45
- package/dist/index.mjs.map +1 -1
- package/dist/node.js +5 -5
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +5 -5
- package/dist/node.mjs.map +1 -1
- package/dist/nuxt.js +36 -31
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +36 -31
- package/dist/nuxt.mjs.map +1 -1
- package/dist/react.js +44 -36
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +44 -36
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.js +24 -16
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +24 -16
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.js +44 -36
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +44 -36
- package/dist/svelte.mjs.map +1 -1
- package/dist/vite.d.mts +6 -6
- package/dist/vite.d.ts +6 -6
- package/dist/vite.js +39 -34
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +39 -34
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +44 -36
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +44 -36
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/vite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Vite Plugin for
|
|
4
|
+
* Vite Plugin for HaexSpace SDK
|
|
5
5
|
* Automatically injects polyfills into HTML files
|
|
6
6
|
* Works with React, Vue, Svelte, and any other Vite-based project
|
|
7
7
|
*/
|
|
@@ -19,19 +19,19 @@ interface VitePluginOptions {
|
|
|
19
19
|
configureCors?: boolean;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* HaexSpace Vite Plugin
|
|
23
23
|
* Injects browser API polyfills for extensions running in custom protocols
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
27
27
|
* // vite.config.ts
|
|
28
|
-
* import {
|
|
28
|
+
* import { haexspacePlugin } from '@haex-space/vault-sdk/vite'
|
|
29
29
|
*
|
|
30
30
|
* export default {
|
|
31
|
-
* plugins: [
|
|
31
|
+
* plugins: [haexspacePlugin()]
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
declare function
|
|
35
|
+
declare function haexspacePlugin(options?: VitePluginOptions): Plugin;
|
|
36
36
|
|
|
37
|
-
export { type VitePluginOptions,
|
|
37
|
+
export { type VitePluginOptions, haexspacePlugin as default, haexspacePlugin };
|
package/dist/vite.js
CHANGED
|
@@ -7,7 +7,7 @@ function installLocalStoragePolyfill() {
|
|
|
7
7
|
if (typeof window === "undefined") {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
console.log("[
|
|
10
|
+
console.log("[HaexSpace] Storage Polyfill loading immediately");
|
|
11
11
|
let localStorageWorks = false;
|
|
12
12
|
try {
|
|
13
13
|
const testKey = "__ls_test__";
|
|
@@ -15,7 +15,7 @@ function installLocalStoragePolyfill() {
|
|
|
15
15
|
localStorage.removeItem(testKey);
|
|
16
16
|
localStorageWorks = true;
|
|
17
17
|
} catch (e) {
|
|
18
|
-
console.warn("[
|
|
18
|
+
console.warn("[HaexSpace] localStorage blocked \u2013 using in-memory fallback");
|
|
19
19
|
}
|
|
20
20
|
if (!localStorageWorks) {
|
|
21
21
|
const lsStorage = /* @__PURE__ */ new Map();
|
|
@@ -48,7 +48,7 @@ function installLocalStoragePolyfill() {
|
|
|
48
48
|
} catch (e) {
|
|
49
49
|
window.localStorage = localStoragePoly;
|
|
50
50
|
}
|
|
51
|
-
console.log("[
|
|
51
|
+
console.log("[HaexSpace] localStorage replaced with in-memory polyfill");
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function installSessionStoragePolyfill() {
|
|
@@ -93,7 +93,7 @@ function installSessionStoragePolyfill() {
|
|
|
93
93
|
key: () => null
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
console.log("[
|
|
96
|
+
console.log("[HaexSpace] sessionStorage polyfill installed");
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// src/polyfills/cookies.ts
|
|
@@ -106,7 +106,7 @@ function installCookiePolyfill() {
|
|
|
106
106
|
document.cookie = "__cookie_test__=1";
|
|
107
107
|
cookiesWork = document.cookie.indexOf("__cookie_test__") !== -1;
|
|
108
108
|
} catch (e) {
|
|
109
|
-
console.warn("[
|
|
109
|
+
console.warn("[HaexSpace] Cookies blocked \u2013 using in-memory fallback");
|
|
110
110
|
}
|
|
111
111
|
if (!cookiesWork) {
|
|
112
112
|
const cookieStore = /* @__PURE__ */ new Map();
|
|
@@ -152,7 +152,7 @@ function installCookiePolyfill() {
|
|
|
152
152
|
},
|
|
153
153
|
configurable: true
|
|
154
154
|
});
|
|
155
|
-
console.log("[
|
|
155
|
+
console.log("[HaexSpace] Cookie polyfill installed");
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -162,16 +162,16 @@ function installHistoryPolyfill() {
|
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
const install = () => {
|
|
165
|
-
console.log("[
|
|
165
|
+
console.log("[HaexSpace] History Patch loading");
|
|
166
166
|
const originalPushState = history.pushState;
|
|
167
167
|
const originalReplaceState = history.replaceState;
|
|
168
168
|
let skipNextPush = false;
|
|
169
169
|
let skipNextReplace = false;
|
|
170
170
|
history.pushState = function(state, title, url) {
|
|
171
|
-
console.log("[
|
|
171
|
+
console.log("[HaexSpace] pushState called:", url, "skip:", skipNextPush);
|
|
172
172
|
if (skipNextPush) {
|
|
173
173
|
skipNextPush = false;
|
|
174
|
-
console.log("[
|
|
174
|
+
console.log("[HaexSpace] pushState skipped");
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
try {
|
|
@@ -181,7 +181,7 @@ function installHistoryPolyfill() {
|
|
|
181
181
|
const urlString = url.toString();
|
|
182
182
|
let hashUrl = urlString.replace(/^\/#/, "");
|
|
183
183
|
hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
|
|
184
|
-
console.log("[
|
|
184
|
+
console.log("[HaexSpace] SecurityError - setting hash to:", hashUrl);
|
|
185
185
|
skipNextPush = true;
|
|
186
186
|
window.location.hash = hashUrl.replace(/^#/, "");
|
|
187
187
|
return;
|
|
@@ -190,10 +190,10 @@ function installHistoryPolyfill() {
|
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
history.replaceState = function(state, title, url) {
|
|
193
|
-
console.log("[
|
|
193
|
+
console.log("[HaexSpace] replaceState called:", url, "skip:", skipNextReplace);
|
|
194
194
|
if (skipNextReplace) {
|
|
195
195
|
skipNextReplace = false;
|
|
196
|
-
console.log("[
|
|
196
|
+
console.log("[HaexSpace] replaceState skipped");
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
try {
|
|
@@ -203,7 +203,7 @@ function installHistoryPolyfill() {
|
|
|
203
203
|
const urlString = url.toString();
|
|
204
204
|
let hashUrl = urlString.replace(/^\/#/, "");
|
|
205
205
|
hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
|
|
206
|
-
console.log("[
|
|
206
|
+
console.log("[HaexSpace] SecurityError - setting hash to:", hashUrl);
|
|
207
207
|
skipNextReplace = true;
|
|
208
208
|
window.location.hash = hashUrl.replace(/^#/, "");
|
|
209
209
|
return;
|
|
@@ -211,7 +211,7 @@ function installHistoryPolyfill() {
|
|
|
211
211
|
throw e;
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
|
-
console.log("[
|
|
214
|
+
console.log("[HaexSpace] History API patched");
|
|
215
215
|
};
|
|
216
216
|
if (document.readyState === "loading") {
|
|
217
217
|
document.addEventListener("DOMContentLoaded", install, { once: true });
|
|
@@ -220,22 +220,27 @@ function installHistoryPolyfill() {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
// src/messages.ts
|
|
224
|
+
var HAEXSPACE_MESSAGE_TYPES = {
|
|
225
|
+
/** Debug message for development/troubleshooting */
|
|
226
|
+
DEBUG: "haexspace:debug"};
|
|
227
|
+
|
|
223
228
|
// src/polyfills/debug.ts
|
|
224
229
|
function installDebugDiagnostics() {
|
|
225
230
|
if (typeof window === "undefined") {
|
|
226
231
|
return;
|
|
227
232
|
}
|
|
228
233
|
const hasParent = window.parent && window.parent !== window;
|
|
229
|
-
console.log("[
|
|
234
|
+
console.log("[HaexSpace] hasParent:", hasParent);
|
|
230
235
|
if (hasParent) {
|
|
231
|
-
console.log("[
|
|
236
|
+
console.log("[HaexSpace] Attempting to send debug message to parent...");
|
|
232
237
|
window.parent.postMessage({
|
|
233
|
-
type:
|
|
238
|
+
type: HAEXSPACE_MESSAGE_TYPES.DEBUG,
|
|
234
239
|
data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`
|
|
235
240
|
}, "*");
|
|
236
|
-
console.log("[
|
|
241
|
+
console.log("[HaexSpace] Debug message sent!");
|
|
237
242
|
} else {
|
|
238
|
-
console.log("[
|
|
243
|
+
console.log("[HaexSpace] No parent window or parent === window");
|
|
239
244
|
}
|
|
240
245
|
}
|
|
241
246
|
|
|
@@ -244,7 +249,7 @@ function getPolyfillCode() {
|
|
|
244
249
|
const iife = `(function() {
|
|
245
250
|
'use strict';
|
|
246
251
|
|
|
247
|
-
console.log('[
|
|
252
|
+
console.log('[HaexSpace] Storage Polyfill loading immediately');
|
|
248
253
|
|
|
249
254
|
// localStorage Polyfill
|
|
250
255
|
(${installLocalStoragePolyfill.toString()})();
|
|
@@ -260,7 +265,7 @@ function getPolyfillCode() {
|
|
|
260
265
|
|
|
261
266
|
// Note: Base tag is injected at build-time by Vite plugin, not at runtime
|
|
262
267
|
|
|
263
|
-
console.log('[
|
|
268
|
+
console.log('[HaexSpace] All polyfills loaded successfully');
|
|
264
269
|
|
|
265
270
|
// Debug diagnostics for Android debugging
|
|
266
271
|
(${installDebugDiagnostics.toString()})();
|
|
@@ -269,38 +274,38 @@ function getPolyfillCode() {
|
|
|
269
274
|
}
|
|
270
275
|
|
|
271
276
|
// src/cors.ts
|
|
272
|
-
var
|
|
277
|
+
var HAEXSPACE_CORS_HEADERS = {
|
|
273
278
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
274
279
|
"Access-Control-Allow-Headers": "*",
|
|
275
280
|
"Access-Control-Allow-Credentials": "true"
|
|
276
281
|
};
|
|
277
282
|
function applyCorsHeaders(res, origin) {
|
|
278
283
|
res.setHeader("Access-Control-Allow-Origin", origin || "*");
|
|
279
|
-
res.setHeader("Access-Control-Allow-Methods",
|
|
280
|
-
res.setHeader("Access-Control-Allow-Headers",
|
|
281
|
-
res.setHeader("Access-Control-Allow-Credentials",
|
|
284
|
+
res.setHeader("Access-Control-Allow-Methods", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Methods"]);
|
|
285
|
+
res.setHeader("Access-Control-Allow-Headers", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Headers"]);
|
|
286
|
+
res.setHeader("Access-Control-Allow-Credentials", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Credentials"]);
|
|
282
287
|
}
|
|
283
288
|
|
|
284
289
|
// src/vite.ts
|
|
285
|
-
function
|
|
290
|
+
function haexspacePlugin(options = {}) {
|
|
286
291
|
const { injectPolyfills = true, configureCors = true } = options;
|
|
287
292
|
let polyfillCode = null;
|
|
288
293
|
return {
|
|
289
|
-
name: "@
|
|
294
|
+
name: "@haex-space/vault-sdk",
|
|
290
295
|
enforce: "post",
|
|
291
296
|
// Run after other plugins
|
|
292
297
|
configResolved(config) {
|
|
293
298
|
if (injectPolyfills) {
|
|
294
299
|
try {
|
|
295
300
|
polyfillCode = getPolyfillCode();
|
|
296
|
-
console.log("\u2713 [@
|
|
301
|
+
console.log("\u2713 [@haex-space/vault-sdk] Polyfills initialized");
|
|
297
302
|
} catch (error) {
|
|
298
|
-
console.error("[@
|
|
303
|
+
console.error("[@haex-space/vault-sdk] Failed to initialize:", error);
|
|
299
304
|
throw error;
|
|
300
305
|
}
|
|
301
306
|
}
|
|
302
307
|
if (configureCors && config.command === "serve") {
|
|
303
|
-
console.log("\u2713 [@
|
|
308
|
+
console.log("\u2713 [@haex-space/vault-sdk] CORS configured for HaexSpace development");
|
|
304
309
|
console.log(" - Allowing all origins (required for custom protocols)");
|
|
305
310
|
console.log(" - Allowing credentials");
|
|
306
311
|
}
|
|
@@ -326,21 +331,21 @@ function haexhubPlugin(options = {}) {
|
|
|
326
331
|
}
|
|
327
332
|
const headPos = html.indexOf("<head>");
|
|
328
333
|
if (headPos === -1) {
|
|
329
|
-
console.warn("[@
|
|
334
|
+
console.warn("[@haex-space/vault-sdk] No <head> tag found in HTML");
|
|
330
335
|
return html;
|
|
331
336
|
}
|
|
332
337
|
const insertPos = headPos + 6;
|
|
333
338
|
const polyfillScript = `<script>${polyfillCode}</script>`;
|
|
334
339
|
const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos);
|
|
335
|
-
console.log("\u2713 [@
|
|
340
|
+
console.log("\u2713 [@haex-space/vault-sdk] Polyfill injected into HTML");
|
|
336
341
|
return modifiedHtml;
|
|
337
342
|
}
|
|
338
343
|
}
|
|
339
344
|
};
|
|
340
345
|
}
|
|
341
|
-
var vite_default =
|
|
346
|
+
var vite_default = haexspacePlugin;
|
|
342
347
|
|
|
343
348
|
exports.default = vite_default;
|
|
344
|
-
exports.
|
|
349
|
+
exports.haexspacePlugin = haexspacePlugin;
|
|
345
350
|
//# sourceMappingURL=vite.js.map
|
|
346
351
|
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +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;AAAA,EACtB,SAAS,CAAA,EAAG;AACV,IAAA,OAAA,CAAQ,KAAK,gEAA2D,CAAA;AAAA,EAC1E;AAGA,EAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,IAAA,MAAM,SAAA,uBAAgB,GAAA,EAAoB;AAE1C,IAAA,MAAM,gBAAA,GAA4B;AAAA,MAChC,QAAQ,GAAA,EAA4B;AAClC,QAAA,OAAO,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,IAAK,IAAA;AAAA,MAC/B,CAAA;AAAA,MACA,OAAA,CAAQ,KAAa,KAAA,EAAqB;AACxC,QAAA,SAAA,CAAU,GAAA,CAAI,GAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,MAClC,CAAA;AAAA,MACA,WAAW,GAAA,EAAmB;AAC5B,QAAA,SAAA,CAAU,OAAO,GAAG,CAAA;AAAA,MACtB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T;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"]}
|
|
1
|
+
{"version":3,"sources":["../src/polyfills/localStorage.ts","../src/polyfills/cookies.ts","../src/polyfills/history.ts","../src/messages.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,kDAAkD,CAAA;AAG9D,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;AAAA,EACtB,SAAS,CAAA,EAAG;AACV,IAAA,OAAA,CAAQ,KAAK,kEAA6D,CAAA;AAAA,EAC5E;AAGA,EAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,IAAA,MAAM,SAAA,uBAAgB,GAAA,EAAoB;AAE1C,IAAA,MAAM,gBAAA,GAA4B;AAAA,MAChC,QAAQ,GAA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;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,qDAAqD,CAAA;AAClE,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,4DAAuD,CAAA;AAEnE,QAAA,OAAO,YAAA;AAAA,MACT;AAAA;AACF,GACF;AACF;AAGA,IAAO,YAAA,GAAQ","file":"vite.js","sourcesContent":["/**\n * localStorage Polyfill for HaexSpace 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('[HaexSpace] 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('[HaexSpace] 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('[HaexSpace] localStorage replaced with in-memory polyfill');\n }\n}\n\n/**\n * sessionStorage Polyfill for HaexSpace 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('[HaexSpace] sessionStorage polyfill installed');\n}\n","/**\n * Cookie Polyfill for HaexSpace 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(\"[HaexSpace] 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(\"[HaexSpace] Cookie polyfill installed\");\n }\n}\n","/**\n * History API Polyfill for HaexSpace 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('[HaexSpace] 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('[HaexSpace] pushState called:', url, 'skip:', skipNextPush);\n\n if (skipNextPush) {\n skipNextPush = false;\n console.log('[HaexSpace] 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('[HaexSpace] 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('[HaexSpace] replaceState called:', url, 'skip:', skipNextReplace);\n\n if (skipNextReplace) {\n skipNextReplace = false;\n console.log('[HaexSpace] 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('[HaexSpace] 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('[HaexSpace] 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 * Central message type definitions for HaexSpace SDK\n *\n * Message Naming Schema: haexspace:{subject}\n *\n * These are used for internal communication between extensions and HaexSpace\n */\n\nexport const HAEXSPACE_MESSAGE_TYPES = {\n /** Debug message for development/troubleshooting */\n DEBUG: 'haexspace:debug',\n\n /** Console forwarding from extension iframe */\n CONSOLE_FORWARD: 'console.forward',\n} as const;\n\nexport type HaexspaceMessageType =\n (typeof HAEXSPACE_MESSAGE_TYPES)[keyof typeof HAEXSPACE_MESSAGE_TYPES];\n","import { HAEXSPACE_MESSAGE_TYPES } from '../messages';\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('[HaexSpace] hasParent:', hasParent);\n\n if (hasParent) {\n console.log('[HaexSpace] Attempting to send debug message to parent...');\n window.parent.postMessage({\n type: HAEXSPACE_MESSAGE_TYPES.DEBUG,\n data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`\n }, '*');\n console.log('[HaexSpace] Debug message sent!');\n } else {\n console.log('[HaexSpace] 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('[HaexSpace] 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('[HaexSpace] 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 HaexSpace Extensions\n * Used by both Vite and Nuxt plugins to ensure consistent CORS headers\n */\n\n/**\n * Standard CORS headers for HaexSpace dev servers\n * Allows extensions to be loaded in custom protocol iframes (haex-extension://)\n */\nexport const HAEXSPACE_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', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'])\n res.setHeader('Access-Control-Allow-Headers', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'])\n res.setHeader('Access-Control-Allow-Credentials', HAEXSPACE_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 || HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Origin'],\n 'Access-Control-Allow-Methods': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'],\n 'Access-Control-Allow-Headers': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'],\n 'Access-Control-Allow-Credentials': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Credentials'],\n }\n}\n","/**\n * Vite Plugin for HaexSpace 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 * HaexSpace Vite Plugin\n * Injects browser API polyfills for extensions running in custom protocols\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { haexspacePlugin } from '@haex-space/vault-sdk/vite'\n *\n * export default {\n * plugins: [haexspacePlugin()]\n * }\n * ```\n */\nexport function haexspacePlugin(options: VitePluginOptions = {}): Plugin {\n const { injectPolyfills = true, configureCors = true } = options\n\n let polyfillCode: string | null = null\n\n return {\n name: '@haex-space/vault-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('✓ [@haex-space/vault-sdk] Polyfills initialized')\n } catch (error) {\n console.error('[@haex-space/vault-sdk] Failed to initialize:', error)\n throw error\n }\n }\n\n // Log CORS configuration\n if (configureCors && config.command === 'serve') {\n console.log('✓ [@haex-space/vault-sdk] CORS configured for HaexSpace 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 HaexSpace 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('[@haex-space/vault-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('✓ [@haex-space/vault-sdk] Polyfill injected into HTML')\n\n return modifiedHtml\n }\n }\n }\n}\n\n// Default export for convenience\nexport default haexspacePlugin\n"]}
|
package/dist/vite.mjs
CHANGED
|
@@ -3,7 +3,7 @@ function installLocalStoragePolyfill() {
|
|
|
3
3
|
if (typeof window === "undefined") {
|
|
4
4
|
return;
|
|
5
5
|
}
|
|
6
|
-
console.log("[
|
|
6
|
+
console.log("[HaexSpace] Storage Polyfill loading immediately");
|
|
7
7
|
let localStorageWorks = false;
|
|
8
8
|
try {
|
|
9
9
|
const testKey = "__ls_test__";
|
|
@@ -11,7 +11,7 @@ function installLocalStoragePolyfill() {
|
|
|
11
11
|
localStorage.removeItem(testKey);
|
|
12
12
|
localStorageWorks = true;
|
|
13
13
|
} catch (e) {
|
|
14
|
-
console.warn("[
|
|
14
|
+
console.warn("[HaexSpace] localStorage blocked \u2013 using in-memory fallback");
|
|
15
15
|
}
|
|
16
16
|
if (!localStorageWorks) {
|
|
17
17
|
const lsStorage = /* @__PURE__ */ new Map();
|
|
@@ -44,7 +44,7 @@ function installLocalStoragePolyfill() {
|
|
|
44
44
|
} catch (e) {
|
|
45
45
|
window.localStorage = localStoragePoly;
|
|
46
46
|
}
|
|
47
|
-
console.log("[
|
|
47
|
+
console.log("[HaexSpace] localStorage replaced with in-memory polyfill");
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
function installSessionStoragePolyfill() {
|
|
@@ -89,7 +89,7 @@ function installSessionStoragePolyfill() {
|
|
|
89
89
|
key: () => null
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
console.log("[
|
|
92
|
+
console.log("[HaexSpace] sessionStorage polyfill installed");
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// src/polyfills/cookies.ts
|
|
@@ -102,7 +102,7 @@ function installCookiePolyfill() {
|
|
|
102
102
|
document.cookie = "__cookie_test__=1";
|
|
103
103
|
cookiesWork = document.cookie.indexOf("__cookie_test__") !== -1;
|
|
104
104
|
} catch (e) {
|
|
105
|
-
console.warn("[
|
|
105
|
+
console.warn("[HaexSpace] Cookies blocked \u2013 using in-memory fallback");
|
|
106
106
|
}
|
|
107
107
|
if (!cookiesWork) {
|
|
108
108
|
const cookieStore = /* @__PURE__ */ new Map();
|
|
@@ -148,7 +148,7 @@ function installCookiePolyfill() {
|
|
|
148
148
|
},
|
|
149
149
|
configurable: true
|
|
150
150
|
});
|
|
151
|
-
console.log("[
|
|
151
|
+
console.log("[HaexSpace] Cookie polyfill installed");
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -158,16 +158,16 @@ function installHistoryPolyfill() {
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
const install = () => {
|
|
161
|
-
console.log("[
|
|
161
|
+
console.log("[HaexSpace] History Patch loading");
|
|
162
162
|
const originalPushState = history.pushState;
|
|
163
163
|
const originalReplaceState = history.replaceState;
|
|
164
164
|
let skipNextPush = false;
|
|
165
165
|
let skipNextReplace = false;
|
|
166
166
|
history.pushState = function(state, title, url) {
|
|
167
|
-
console.log("[
|
|
167
|
+
console.log("[HaexSpace] pushState called:", url, "skip:", skipNextPush);
|
|
168
168
|
if (skipNextPush) {
|
|
169
169
|
skipNextPush = false;
|
|
170
|
-
console.log("[
|
|
170
|
+
console.log("[HaexSpace] pushState skipped");
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
173
|
try {
|
|
@@ -177,7 +177,7 @@ function installHistoryPolyfill() {
|
|
|
177
177
|
const urlString = url.toString();
|
|
178
178
|
let hashUrl = urlString.replace(/^\/#/, "");
|
|
179
179
|
hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
|
|
180
|
-
console.log("[
|
|
180
|
+
console.log("[HaexSpace] SecurityError - setting hash to:", hashUrl);
|
|
181
181
|
skipNextPush = true;
|
|
182
182
|
window.location.hash = hashUrl.replace(/^#/, "");
|
|
183
183
|
return;
|
|
@@ -186,10 +186,10 @@ function installHistoryPolyfill() {
|
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
188
|
history.replaceState = function(state, title, url) {
|
|
189
|
-
console.log("[
|
|
189
|
+
console.log("[HaexSpace] replaceState called:", url, "skip:", skipNextReplace);
|
|
190
190
|
if (skipNextReplace) {
|
|
191
191
|
skipNextReplace = false;
|
|
192
|
-
console.log("[
|
|
192
|
+
console.log("[HaexSpace] replaceState skipped");
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
195
|
try {
|
|
@@ -199,7 +199,7 @@ function installHistoryPolyfill() {
|
|
|
199
199
|
const urlString = url.toString();
|
|
200
200
|
let hashUrl = urlString.replace(/^\/#/, "");
|
|
201
201
|
hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
|
|
202
|
-
console.log("[
|
|
202
|
+
console.log("[HaexSpace] SecurityError - setting hash to:", hashUrl);
|
|
203
203
|
skipNextReplace = true;
|
|
204
204
|
window.location.hash = hashUrl.replace(/^#/, "");
|
|
205
205
|
return;
|
|
@@ -207,7 +207,7 @@ function installHistoryPolyfill() {
|
|
|
207
207
|
throw e;
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
|
-
console.log("[
|
|
210
|
+
console.log("[HaexSpace] History API patched");
|
|
211
211
|
};
|
|
212
212
|
if (document.readyState === "loading") {
|
|
213
213
|
document.addEventListener("DOMContentLoaded", install, { once: true });
|
|
@@ -216,22 +216,27 @@ function installHistoryPolyfill() {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
// src/messages.ts
|
|
220
|
+
var HAEXSPACE_MESSAGE_TYPES = {
|
|
221
|
+
/** Debug message for development/troubleshooting */
|
|
222
|
+
DEBUG: "haexspace:debug"};
|
|
223
|
+
|
|
219
224
|
// src/polyfills/debug.ts
|
|
220
225
|
function installDebugDiagnostics() {
|
|
221
226
|
if (typeof window === "undefined") {
|
|
222
227
|
return;
|
|
223
228
|
}
|
|
224
229
|
const hasParent = window.parent && window.parent !== window;
|
|
225
|
-
console.log("[
|
|
230
|
+
console.log("[HaexSpace] hasParent:", hasParent);
|
|
226
231
|
if (hasParent) {
|
|
227
|
-
console.log("[
|
|
232
|
+
console.log("[HaexSpace] Attempting to send debug message to parent...");
|
|
228
233
|
window.parent.postMessage({
|
|
229
|
-
type:
|
|
234
|
+
type: HAEXSPACE_MESSAGE_TYPES.DEBUG,
|
|
230
235
|
data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`
|
|
231
236
|
}, "*");
|
|
232
|
-
console.log("[
|
|
237
|
+
console.log("[HaexSpace] Debug message sent!");
|
|
233
238
|
} else {
|
|
234
|
-
console.log("[
|
|
239
|
+
console.log("[HaexSpace] No parent window or parent === window");
|
|
235
240
|
}
|
|
236
241
|
}
|
|
237
242
|
|
|
@@ -240,7 +245,7 @@ function getPolyfillCode() {
|
|
|
240
245
|
const iife = `(function() {
|
|
241
246
|
'use strict';
|
|
242
247
|
|
|
243
|
-
console.log('[
|
|
248
|
+
console.log('[HaexSpace] Storage Polyfill loading immediately');
|
|
244
249
|
|
|
245
250
|
// localStorage Polyfill
|
|
246
251
|
(${installLocalStoragePolyfill.toString()})();
|
|
@@ -256,7 +261,7 @@ function getPolyfillCode() {
|
|
|
256
261
|
|
|
257
262
|
// Note: Base tag is injected at build-time by Vite plugin, not at runtime
|
|
258
263
|
|
|
259
|
-
console.log('[
|
|
264
|
+
console.log('[HaexSpace] All polyfills loaded successfully');
|
|
260
265
|
|
|
261
266
|
// Debug diagnostics for Android debugging
|
|
262
267
|
(${installDebugDiagnostics.toString()})();
|
|
@@ -265,38 +270,38 @@ function getPolyfillCode() {
|
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
// src/cors.ts
|
|
268
|
-
var
|
|
273
|
+
var HAEXSPACE_CORS_HEADERS = {
|
|
269
274
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
270
275
|
"Access-Control-Allow-Headers": "*",
|
|
271
276
|
"Access-Control-Allow-Credentials": "true"
|
|
272
277
|
};
|
|
273
278
|
function applyCorsHeaders(res, origin) {
|
|
274
279
|
res.setHeader("Access-Control-Allow-Origin", origin || "*");
|
|
275
|
-
res.setHeader("Access-Control-Allow-Methods",
|
|
276
|
-
res.setHeader("Access-Control-Allow-Headers",
|
|
277
|
-
res.setHeader("Access-Control-Allow-Credentials",
|
|
280
|
+
res.setHeader("Access-Control-Allow-Methods", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Methods"]);
|
|
281
|
+
res.setHeader("Access-Control-Allow-Headers", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Headers"]);
|
|
282
|
+
res.setHeader("Access-Control-Allow-Credentials", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Credentials"]);
|
|
278
283
|
}
|
|
279
284
|
|
|
280
285
|
// src/vite.ts
|
|
281
|
-
function
|
|
286
|
+
function haexspacePlugin(options = {}) {
|
|
282
287
|
const { injectPolyfills = true, configureCors = true } = options;
|
|
283
288
|
let polyfillCode = null;
|
|
284
289
|
return {
|
|
285
|
-
name: "@
|
|
290
|
+
name: "@haex-space/vault-sdk",
|
|
286
291
|
enforce: "post",
|
|
287
292
|
// Run after other plugins
|
|
288
293
|
configResolved(config) {
|
|
289
294
|
if (injectPolyfills) {
|
|
290
295
|
try {
|
|
291
296
|
polyfillCode = getPolyfillCode();
|
|
292
|
-
console.log("\u2713 [@
|
|
297
|
+
console.log("\u2713 [@haex-space/vault-sdk] Polyfills initialized");
|
|
293
298
|
} catch (error) {
|
|
294
|
-
console.error("[@
|
|
299
|
+
console.error("[@haex-space/vault-sdk] Failed to initialize:", error);
|
|
295
300
|
throw error;
|
|
296
301
|
}
|
|
297
302
|
}
|
|
298
303
|
if (configureCors && config.command === "serve") {
|
|
299
|
-
console.log("\u2713 [@
|
|
304
|
+
console.log("\u2713 [@haex-space/vault-sdk] CORS configured for HaexSpace development");
|
|
300
305
|
console.log(" - Allowing all origins (required for custom protocols)");
|
|
301
306
|
console.log(" - Allowing credentials");
|
|
302
307
|
}
|
|
@@ -322,20 +327,20 @@ function haexhubPlugin(options = {}) {
|
|
|
322
327
|
}
|
|
323
328
|
const headPos = html.indexOf("<head>");
|
|
324
329
|
if (headPos === -1) {
|
|
325
|
-
console.warn("[@
|
|
330
|
+
console.warn("[@haex-space/vault-sdk] No <head> tag found in HTML");
|
|
326
331
|
return html;
|
|
327
332
|
}
|
|
328
333
|
const insertPos = headPos + 6;
|
|
329
334
|
const polyfillScript = `<script>${polyfillCode}</script>`;
|
|
330
335
|
const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos);
|
|
331
|
-
console.log("\u2713 [@
|
|
336
|
+
console.log("\u2713 [@haex-space/vault-sdk] Polyfill injected into HTML");
|
|
332
337
|
return modifiedHtml;
|
|
333
338
|
}
|
|
334
339
|
}
|
|
335
340
|
};
|
|
336
341
|
}
|
|
337
|
-
var vite_default =
|
|
342
|
+
var vite_default = haexspacePlugin;
|
|
338
343
|
|
|
339
|
-
export { vite_default as default,
|
|
344
|
+
export { vite_default as default, haexspacePlugin };
|
|
340
345
|
//# sourceMappingURL=vite.mjs.map
|
|
341
346
|
//# sourceMappingURL=vite.mjs.map
|