@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/index.mjs CHANGED
@@ -5,7 +5,7 @@ function installLocalStoragePolyfill() {
5
5
  if (typeof window === "undefined") {
6
6
  return;
7
7
  }
8
- console.log("[HaexHub] Storage Polyfill loading immediately");
8
+ console.log("[HaexSpace] Storage Polyfill loading immediately");
9
9
  let localStorageWorks = false;
10
10
  try {
11
11
  const testKey = "__ls_test__";
@@ -13,7 +13,7 @@ function installLocalStoragePolyfill() {
13
13
  localStorage.removeItem(testKey);
14
14
  localStorageWorks = true;
15
15
  } catch (e) {
16
- console.warn("[HaexHub] localStorage blocked \u2013 using in-memory fallback");
16
+ console.warn("[HaexSpace] localStorage blocked \u2013 using in-memory fallback");
17
17
  }
18
18
  if (!localStorageWorks) {
19
19
  const lsStorage = /* @__PURE__ */ new Map();
@@ -46,7 +46,7 @@ function installLocalStoragePolyfill() {
46
46
  } catch (e) {
47
47
  window.localStorage = localStoragePoly;
48
48
  }
49
- console.log("[HaexHub] localStorage replaced with in-memory polyfill");
49
+ console.log("[HaexSpace] localStorage replaced with in-memory polyfill");
50
50
  }
51
51
  }
52
52
  function installSessionStoragePolyfill() {
@@ -91,7 +91,7 @@ function installSessionStoragePolyfill() {
91
91
  key: () => null
92
92
  };
93
93
  }
94
- console.log("[HaexHub] sessionStorage polyfill installed");
94
+ console.log("[HaexSpace] sessionStorage polyfill installed");
95
95
  }
96
96
 
97
97
  // src/polyfills/cookies.ts
@@ -104,7 +104,7 @@ function installCookiePolyfill() {
104
104
  document.cookie = "__cookie_test__=1";
105
105
  cookiesWork = document.cookie.indexOf("__cookie_test__") !== -1;
106
106
  } catch (e) {
107
- console.warn("[HaexHub] Cookies blocked \u2013 using in-memory fallback");
107
+ console.warn("[HaexSpace] Cookies blocked \u2013 using in-memory fallback");
108
108
  }
109
109
  if (!cookiesWork) {
110
110
  const cookieStore = /* @__PURE__ */ new Map();
@@ -150,7 +150,7 @@ function installCookiePolyfill() {
150
150
  },
151
151
  configurable: true
152
152
  });
153
- console.log("[HaexHub] Cookie polyfill installed");
153
+ console.log("[HaexSpace] Cookie polyfill installed");
154
154
  }
155
155
  }
156
156
 
@@ -160,16 +160,16 @@ function installHistoryPolyfill() {
160
160
  return;
161
161
  }
162
162
  const install = () => {
163
- console.log("[HaexHub] History Patch loading");
163
+ console.log("[HaexSpace] History Patch loading");
164
164
  const originalPushState = history.pushState;
165
165
  const originalReplaceState = history.replaceState;
166
166
  let skipNextPush = false;
167
167
  let skipNextReplace = false;
168
168
  history.pushState = function(state, title, url) {
169
- console.log("[HaexHub] pushState called:", url, "skip:", skipNextPush);
169
+ console.log("[HaexSpace] pushState called:", url, "skip:", skipNextPush);
170
170
  if (skipNextPush) {
171
171
  skipNextPush = false;
172
- console.log("[HaexHub] pushState skipped");
172
+ console.log("[HaexSpace] pushState skipped");
173
173
  return;
174
174
  }
175
175
  try {
@@ -179,7 +179,7 @@ function installHistoryPolyfill() {
179
179
  const urlString = url.toString();
180
180
  let hashUrl = urlString.replace(/^\/#/, "");
181
181
  hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
182
- console.log("[HaexHub] SecurityError - setting hash to:", hashUrl);
182
+ console.log("[HaexSpace] SecurityError - setting hash to:", hashUrl);
183
183
  skipNextPush = true;
184
184
  window.location.hash = hashUrl.replace(/^#/, "");
185
185
  return;
@@ -188,10 +188,10 @@ function installHistoryPolyfill() {
188
188
  }
189
189
  };
190
190
  history.replaceState = function(state, title, url) {
191
- console.log("[HaexHub] replaceState called:", url, "skip:", skipNextReplace);
191
+ console.log("[HaexSpace] replaceState called:", url, "skip:", skipNextReplace);
192
192
  if (skipNextReplace) {
193
193
  skipNextReplace = false;
194
- console.log("[HaexHub] replaceState skipped");
194
+ console.log("[HaexSpace] replaceState skipped");
195
195
  return;
196
196
  }
197
197
  try {
@@ -201,7 +201,7 @@ function installHistoryPolyfill() {
201
201
  const urlString = url.toString();
202
202
  let hashUrl = urlString.replace(/^\/#/, "");
203
203
  hashUrl = hashUrl.startsWith("#") ? hashUrl : "#" + hashUrl;
204
- console.log("[HaexHub] SecurityError - setting hash to:", hashUrl);
204
+ console.log("[HaexSpace] SecurityError - setting hash to:", hashUrl);
205
205
  skipNextReplace = true;
206
206
  window.location.hash = hashUrl.replace(/^#/, "");
207
207
  return;
@@ -209,7 +209,7 @@ function installHistoryPolyfill() {
209
209
  throw e;
210
210
  }
211
211
  };
212
- console.log("[HaexHub] History API patched");
212
+ console.log("[HaexSpace] History API patched");
213
213
  };
214
214
  if (document.readyState === "loading") {
215
215
  document.addEventListener("DOMContentLoaded", install, { once: true });
@@ -218,22 +218,30 @@ function installHistoryPolyfill() {
218
218
  }
219
219
  }
220
220
 
221
+ // src/messages.ts
222
+ var HAEXSPACE_MESSAGE_TYPES = {
223
+ /** Debug message for development/troubleshooting */
224
+ DEBUG: "haexspace:debug",
225
+ /** Console forwarding from extension iframe */
226
+ CONSOLE_FORWARD: "console.forward"
227
+ };
228
+
221
229
  // src/polyfills/debug.ts
222
230
  function installDebugDiagnostics() {
223
231
  if (typeof window === "undefined") {
224
232
  return;
225
233
  }
226
234
  const hasParent = window.parent && window.parent !== window;
227
- console.log("[HaexHub] hasParent:", hasParent);
235
+ console.log("[HaexSpace] hasParent:", hasParent);
228
236
  if (hasParent) {
229
- console.log("[HaexHub] Attempting to send debug message to parent...");
237
+ console.log("[HaexSpace] Attempting to send debug message to parent...");
230
238
  window.parent.postMessage({
231
- type: "haexhub:debug",
239
+ type: HAEXSPACE_MESSAGE_TYPES.DEBUG,
232
240
  data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`
233
241
  }, "*");
234
- console.log("[HaexHub] Debug message sent!");
242
+ console.log("[HaexSpace] Debug message sent!");
235
243
  } else {
236
- console.log("[HaexHub] No parent window or parent === window");
244
+ console.log("[HaexSpace] No parent window or parent === window");
237
245
  }
238
246
  }
239
247
 
@@ -243,27 +251,27 @@ function installBaseTag() {
243
251
  return;
244
252
  }
245
253
  if (window.__HAEXHUB_BASE_TAG_INSTALLING__) {
246
- console.log("[HaexHub] Base tag installation already in progress, skipping");
254
+ console.log("[HaexSpace] Base tag installation already in progress, skipping");
247
255
  return;
248
256
  }
249
- console.log("[HaexHub] Base tag installation starting");
257
+ console.log("[HaexSpace] Base tag installation starting");
250
258
  if (window.self === window.top) {
251
- console.log("[HaexHub] Not in iframe, skipping base tag");
259
+ console.log("[HaexSpace] Not in iframe, skipping base tag");
252
260
  return;
253
261
  }
254
262
  const existingBaseTag = document.querySelector("base#haexhub-base");
255
263
  if (existingBaseTag && existingBaseTag.href && existingBaseTag.href !== window.location.origin + "/") {
256
- console.log("[HaexHub] Base tag already configured, skipping");
264
+ console.log("[HaexSpace] Base tag already configured, skipping");
257
265
  return;
258
266
  }
259
267
  window.__HAEXHUB_BASE_TAG_INSTALLING__ = true;
260
268
  const pathname = window.location.pathname;
261
269
  const lastSlashIndex = pathname.lastIndexOf("/");
262
270
  const basePath = lastSlashIndex !== -1 ? pathname.substring(0, lastSlashIndex + 1) : "/";
263
- console.log("[HaexHub] Extracted base path from location:", basePath);
271
+ console.log("[HaexSpace] Extracted base path from location:", basePath);
264
272
  if (existingBaseTag) {
265
273
  existingBaseTag.href = basePath;
266
- console.log(`[HaexHub] Base tag updated: ${existingBaseTag.href}`);
274
+ console.log(`[HaexSpace] Base tag updated: ${existingBaseTag.href}`);
267
275
  } else {
268
276
  const baseTag = document.createElement("base");
269
277
  baseTag.id = "haexhub-base";
@@ -271,9 +279,9 @@ function installBaseTag() {
271
279
  const head = document.head || document.querySelector("head");
272
280
  if (head) {
273
281
  head.insertBefore(baseTag, head.firstChild);
274
- console.log(`[HaexHub] Base tag created: ${baseTag.href}`);
282
+ console.log(`[HaexSpace] Base tag created: ${baseTag.href}`);
275
283
  } else {
276
- console.warn("[HaexHub] No <head> found, cannot inject base tag");
284
+ console.warn("[HaexSpace] No <head> found, cannot inject base tag");
277
285
  }
278
286
  }
279
287
  }
@@ -309,7 +317,7 @@ function interceptConsole(level) {
309
317
  const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString();
310
318
  window.parent.postMessage(
311
319
  {
312
- type: "console.forward",
320
+ type: HAEXSPACE_MESSAGE_TYPES.CONSOLE_FORWARD,
313
321
  data: {
314
322
  timestamp,
315
323
  level,
@@ -320,7 +328,7 @@ function interceptConsole(level) {
320
328
  "*"
321
329
  );
322
330
  } catch (error) {
323
- originalConsole.error("[HaexHub] Failed to forward console message:", error);
331
+ originalConsole.error("[HaexSpace] Failed to forward console message:", error);
324
332
  }
325
333
  }
326
334
  };
@@ -333,7 +341,7 @@ function installConsoleForwarding(debug = false) {
333
341
  return;
334
342
  }
335
343
  if (!debug) {
336
- console.log("[HaexHub] Console forwarding disabled (not in debug mode)");
344
+ console.log("[HaexSpace] Console forwarding disabled (not in debug mode)");
337
345
  return;
338
346
  }
339
347
  interceptConsole("log");
@@ -341,7 +349,7 @@ function installConsoleForwarding(debug = false) {
341
349
  interceptConsole("warn");
342
350
  interceptConsole("error");
343
351
  interceptConsole("debug");
344
- console.log("[HaexHub] Console forwarding installed");
352
+ console.log("[HaexSpace] Console forwarding installed");
345
353
  }
346
354
 
347
355
  // src/polyfills/index.ts
@@ -353,7 +361,7 @@ function installPolyfills() {
353
361
  installSessionStoragePolyfill();
354
362
  installCookiePolyfill();
355
363
  installHistoryPolyfill();
356
- console.log("[HaexHub] All polyfills loaded successfully");
364
+ console.log("[HaexSpace] All polyfills loaded successfully");
357
365
  installDebugDiagnostics();
358
366
  }
359
367
  if (typeof window !== "undefined") {
@@ -878,13 +886,13 @@ var HaexVaultClient = class {
878
886
  async runSetupAsync() {
879
887
  if (!this.setupHook) return;
880
888
  try {
881
- this.log("[HaexHub] Running setup hook...");
889
+ this.log("[HaexSpace] Running setup hook...");
882
890
  await this.setupHook();
883
891
  this._setupCompleted = true;
884
- this.log("[HaexHub] Setup completed successfully");
892
+ this.log("[HaexSpace] Setup completed successfully");
885
893
  this.notifySubscribers();
886
894
  } catch (error) {
887
- this.log("[HaexHub] Setup failed:", error);
895
+ this.log("[HaexSpace] Setup failed:", error);
888
896
  throw error;
889
897
  }
890
898
  }
@@ -1213,26 +1221,26 @@ var HaexVaultClient = class {
1213
1221
  this.log("Application context:", this._context);
1214
1222
  this.notifySubscribers();
1215
1223
  const { listen } = window.__TAURI__.event;
1216
- console.log("[HaexHub SDK] Setting up Tauri event listener for:", HAEXTENSION_EVENTS.CONTEXT_CHANGED);
1224
+ console.log("[HaexSpace SDK] Setting up Tauri event listener for:", HAEXTENSION_EVENTS.CONTEXT_CHANGED);
1217
1225
  try {
1218
1226
  await listen(HAEXTENSION_EVENTS.CONTEXT_CHANGED, (event) => {
1219
- console.log("[HaexHub SDK] Received Tauri event:", HAEXTENSION_EVENTS.CONTEXT_CHANGED, event);
1227
+ console.log("[HaexSpace SDK] Received Tauri event:", HAEXTENSION_EVENTS.CONTEXT_CHANGED, event);
1220
1228
  this.log("Received context change event:", event);
1221
1229
  if (event.payload?.context) {
1222
1230
  this._context = event.payload.context;
1223
- console.log("[HaexHub SDK] Updated context to:", this._context);
1231
+ console.log("[HaexSpace SDK] Updated context to:", this._context);
1224
1232
  this.handleEvent({
1225
1233
  type: HAEXTENSION_EVENTS.CONTEXT_CHANGED,
1226
1234
  data: { context: this._context },
1227
1235
  timestamp: Date.now()
1228
1236
  });
1229
1237
  } else {
1230
- console.warn("[HaexHub SDK] Event received but no context in payload:", event);
1238
+ console.warn("[HaexSpace SDK] Event received but no context in payload:", event);
1231
1239
  }
1232
1240
  });
1233
- console.log("[HaexHub SDK] Context change listener registered successfully");
1241
+ console.log("[HaexSpace SDK] Context change listener registered successfully");
1234
1242
  } catch (error) {
1235
- console.error("[HaexHub SDK] Failed to setup context change listener:", error);
1243
+ console.error("[HaexSpace SDK] Failed to setup context change listener:", error);
1236
1244
  this.log("Failed to setup context change listener:", error);
1237
1245
  }
1238
1246
  this.resolveReady();
@@ -1249,7 +1257,7 @@ var HaexVaultClient = class {
1249
1257
  window.addEventListener("message", this.messageHandler);
1250
1258
  this.isNativeWindow = false;
1251
1259
  this.initialized = true;
1252
- this.log("HaexHub SDK initialized in iframe mode");
1260
+ this.log("HaexSpace SDK initialized in iframe mode");
1253
1261
  try {
1254
1262
  if (this.config.manifest) {
1255
1263
  this._extensionInfo = {
@@ -1268,7 +1276,7 @@ window.parent === window: ${window.parent === window}
1268
1276
  window.self === window.top: ${window.self === window.top}`;
1269
1277
  try {
1270
1278
  window.parent.postMessage({
1271
- type: "haexhub:debug",
1279
+ type: HAEXSPACE_MESSAGE_TYPES.DEBUG,
1272
1280
  data: debugInfo
1273
1281
  }, "*");
1274
1282
  } catch (e) {
@@ -1417,7 +1425,7 @@ postMessage error: ${e}`);
1417
1425
  }
1418
1426
  log(...args) {
1419
1427
  if (this.config.debug) {
1420
- console.log("[HaexHub SDK]", ...args);
1428
+ console.log("[HaexSpace SDK]", ...args);
1421
1429
  }
1422
1430
  }
1423
1431
  };
@@ -1427,6 +1435,6 @@ function createHaexVaultClient(config = {}) {
1427
1435
  return new HaexVaultClient(config);
1428
1436
  }
1429
1437
 
1430
- export { DEFAULT_TIMEOUT, DatabaseAPI, ErrorCode, FilesystemAPI, HAEXTENSION_EVENTS, HAEXTENSION_METHODS, HaexHubError, HaexVaultClient, PermissionStatus, PermissionsAPI, TABLE_SEPARATOR, WebAPI, createHaexVaultClient, getTableName, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill };
1438
+ export { DEFAULT_TIMEOUT, DatabaseAPI, ErrorCode, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HAEXTENSION_METHODS, HaexHubError, HaexVaultClient, PermissionStatus, PermissionsAPI, TABLE_SEPARATOR, WebAPI, createHaexVaultClient, getTableName, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill };
1431
1439
  //# sourceMappingURL=index.mjs.map
1432
1440
  //# sourceMappingURL=index.mjs.map