@haex-space/vault-sdk 2.3.16 → 2.5.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.
- package/dist/{client-ChH7wiuU.d.ts → client-BNq2TcVs.d.ts} +25 -95
- package/dist/{client-8eGxojZ1.d.mts → client-DQ6VwHic.d.mts} +25 -95
- package/dist/index.d.mts +75 -5
- package/dist/index.d.ts +75 -5
- package/dist/index.js +1076 -680
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1074 -680
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1025 -658
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1025 -658
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
- package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
- package/dist/runtime/nuxt.plugin.client.js +1034 -667
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +1034 -667
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +1027 -660
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +1027 -660
- package/dist/svelte.mjs.map +1 -1
- package/dist/{types-DBF83o_W.d.mts → types-Bw5uc1vm.d.mts} +70 -11
- package/dist/{types-DBF83o_W.d.ts → types-Bw5uc1vm.d.ts} +70 -11
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +1025 -658
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +1025 -658
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -373,70 +373,13 @@ var HAEXTENSION_EVENTS = {
|
|
|
373
373
|
/** Context (theme, locale, platform) has changed */
|
|
374
374
|
CONTEXT_CHANGED: "haextension:context:changed",
|
|
375
375
|
/** Search request from HaexHub */
|
|
376
|
-
SEARCH_REQUEST: "haextension:search:request"
|
|
377
|
-
/** External request from authorized client (browser extension, CLI, server, etc.) */
|
|
378
|
-
EXTERNAL_REQUEST: "haextension:external:request"
|
|
376
|
+
SEARCH_REQUEST: "haextension:search:request"
|
|
379
377
|
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
database: {
|
|
387
|
-
query: "haextension:database:query",
|
|
388
|
-
execute: "haextension:database:execute",
|
|
389
|
-
transaction: "haextension:database:transaction",
|
|
390
|
-
registerMigrations: "haextension:database:register-migrations"
|
|
391
|
-
},
|
|
392
|
-
filesystem: {
|
|
393
|
-
saveFile: "haextension:filesystem:save-file",
|
|
394
|
-
openFile: "haextension:filesystem:open-file",
|
|
395
|
-
showImage: "haextension:filesystem:show-image",
|
|
396
|
-
sync: {
|
|
397
|
-
// Spaces
|
|
398
|
-
listSpaces: "haextension:filesystem:sync:list-spaces",
|
|
399
|
-
createSpace: "haextension:filesystem:sync:create-space",
|
|
400
|
-
deleteSpace: "haextension:filesystem:sync:delete-space",
|
|
401
|
-
// Files
|
|
402
|
-
listFiles: "haextension:filesystem:sync:list-files",
|
|
403
|
-
getFile: "haextension:filesystem:sync:get-file",
|
|
404
|
-
uploadFile: "haextension:filesystem:sync:upload-file",
|
|
405
|
-
downloadFile: "haextension:filesystem:sync:download-file",
|
|
406
|
-
deleteFile: "haextension:filesystem:sync:delete-file",
|
|
407
|
-
// Backends
|
|
408
|
-
listBackends: "haextension:filesystem:sync:list-backends",
|
|
409
|
-
addBackend: "haextension:filesystem:sync:add-backend",
|
|
410
|
-
removeBackend: "haextension:filesystem:sync:remove-backend",
|
|
411
|
-
testBackend: "haextension:filesystem:sync:test-backend",
|
|
412
|
-
// Sync Rules
|
|
413
|
-
listSyncRules: "haextension:filesystem:sync:list-sync-rules",
|
|
414
|
-
addSyncRule: "haextension:filesystem:sync:add-sync-rule",
|
|
415
|
-
removeSyncRule: "haextension:filesystem:sync:remove-sync-rule",
|
|
416
|
-
// Sync Operations
|
|
417
|
-
getSyncStatus: "haextension:filesystem:sync:get-sync-status",
|
|
418
|
-
triggerSync: "haextension:filesystem:sync:trigger-sync",
|
|
419
|
-
pauseSync: "haextension:filesystem:sync:pause-sync",
|
|
420
|
-
resumeSync: "haextension:filesystem:sync:resume-sync",
|
|
421
|
-
// Conflict Resolution
|
|
422
|
-
resolveConflict: "haextension:filesystem:sync:resolve-conflict",
|
|
423
|
-
// UI Helpers
|
|
424
|
-
selectFolder: "haextension:filesystem:sync:select-folder"
|
|
425
|
-
}
|
|
426
|
-
},
|
|
427
|
-
storage: {
|
|
428
|
-
getItem: "haextension:storage:get-item",
|
|
429
|
-
setItem: "haextension:storage:set-item",
|
|
430
|
-
removeItem: "haextension:storage:remove-item",
|
|
431
|
-
clear: "haextension:storage:clear",
|
|
432
|
-
keys: "haextension:storage:keys"
|
|
433
|
-
},
|
|
434
|
-
web: {
|
|
435
|
-
fetch: "haextension:web:fetch"
|
|
436
|
-
},
|
|
437
|
-
application: {
|
|
438
|
-
open: "haextension:application:open"
|
|
439
|
-
}
|
|
378
|
+
var EXTERNAL_EVENTS = {
|
|
379
|
+
/** External request from authorized client */
|
|
380
|
+
REQUEST: "haextension:external:request",
|
|
381
|
+
/** New external client requesting authorization */
|
|
382
|
+
AUTHORIZATION_REQUEST: "external:authorization-request"
|
|
440
383
|
};
|
|
441
384
|
|
|
442
385
|
// src/types.ts
|
|
@@ -468,13 +411,13 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
|
468
411
|
ErrorCode2["WEB_ERROR"] = "WEB_ERROR";
|
|
469
412
|
return ErrorCode2;
|
|
470
413
|
})(ErrorCode || {});
|
|
471
|
-
var
|
|
414
|
+
var HaexVaultSdkError = class extends Error {
|
|
472
415
|
constructor(code, messageKey, details) {
|
|
473
416
|
super(messageKey);
|
|
474
417
|
this.code = code;
|
|
475
418
|
this.messageKey = messageKey;
|
|
476
419
|
this.details = details;
|
|
477
|
-
this.name = "
|
|
420
|
+
this.name = "HaexVaultSdkError";
|
|
478
421
|
}
|
|
479
422
|
/**
|
|
480
423
|
* Get localized error message
|
|
@@ -502,6 +445,67 @@ var HaexHubError = class extends Error {
|
|
|
502
445
|
}
|
|
503
446
|
};
|
|
504
447
|
|
|
448
|
+
// src/methods.ts
|
|
449
|
+
var HAEXTENSION_METHODS = {
|
|
450
|
+
context: {
|
|
451
|
+
get: "haextension:context:get"
|
|
452
|
+
},
|
|
453
|
+
database: {
|
|
454
|
+
query: "haextension:database:query",
|
|
455
|
+
execute: "haextension:database:execute",
|
|
456
|
+
transaction: "haextension:database:transaction",
|
|
457
|
+
registerMigrations: "haextension:database:register-migrations"
|
|
458
|
+
},
|
|
459
|
+
filesystem: {
|
|
460
|
+
saveFile: "haextension:filesystem:save-file",
|
|
461
|
+
openFile: "haextension:filesystem:open-file",
|
|
462
|
+
showImage: "haextension:filesystem:show-image",
|
|
463
|
+
sync: {
|
|
464
|
+
// Spaces
|
|
465
|
+
listSpaces: "haextension:filesystem:sync:list-spaces",
|
|
466
|
+
createSpace: "haextension:filesystem:sync:create-space",
|
|
467
|
+
deleteSpace: "haextension:filesystem:sync:delete-space",
|
|
468
|
+
// Files
|
|
469
|
+
listFiles: "haextension:filesystem:sync:list-files",
|
|
470
|
+
getFile: "haextension:filesystem:sync:get-file",
|
|
471
|
+
uploadFile: "haextension:filesystem:sync:upload-file",
|
|
472
|
+
downloadFile: "haextension:filesystem:sync:download-file",
|
|
473
|
+
deleteFile: "haextension:filesystem:sync:delete-file",
|
|
474
|
+
// Backends
|
|
475
|
+
listBackends: "haextension:filesystem:sync:list-backends",
|
|
476
|
+
addBackend: "haextension:filesystem:sync:add-backend",
|
|
477
|
+
removeBackend: "haextension:filesystem:sync:remove-backend",
|
|
478
|
+
testBackend: "haextension:filesystem:sync:test-backend",
|
|
479
|
+
// Sync Rules
|
|
480
|
+
listSyncRules: "haextension:filesystem:sync:list-sync-rules",
|
|
481
|
+
addSyncRule: "haextension:filesystem:sync:add-sync-rule",
|
|
482
|
+
removeSyncRule: "haextension:filesystem:sync:remove-sync-rule",
|
|
483
|
+
// Sync Operations
|
|
484
|
+
getSyncStatus: "haextension:filesystem:sync:get-sync-status",
|
|
485
|
+
triggerSync: "haextension:filesystem:sync:trigger-sync",
|
|
486
|
+
pauseSync: "haextension:filesystem:sync:pause-sync",
|
|
487
|
+
resumeSync: "haextension:filesystem:sync:resume-sync",
|
|
488
|
+
// Conflict Resolution
|
|
489
|
+
resolveConflict: "haextension:filesystem:sync:resolve-conflict",
|
|
490
|
+
// UI Helpers
|
|
491
|
+
selectFolder: "haextension:filesystem:sync:select-folder"
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
storage: {
|
|
495
|
+
getItem: "haextension:storage:get-item",
|
|
496
|
+
setItem: "haextension:storage:set-item",
|
|
497
|
+
removeItem: "haextension:storage:remove-item",
|
|
498
|
+
clear: "haextension:storage:clear",
|
|
499
|
+
keys: "haextension:storage:keys"
|
|
500
|
+
},
|
|
501
|
+
web: {
|
|
502
|
+
fetch: "haextension:web:fetch"
|
|
503
|
+
},
|
|
504
|
+
application: {
|
|
505
|
+
open: "haextension:application:open"
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
|
|
505
509
|
// src/api/storage.ts
|
|
506
510
|
var StorageAPI = class {
|
|
507
511
|
constructor(client) {
|
|
@@ -1044,548 +1048,564 @@ var PermissionsAPI = class {
|
|
|
1044
1048
|
return response.status === "granted";
|
|
1045
1049
|
}
|
|
1046
1050
|
};
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
this._context = null;
|
|
1057
|
-
this.reactiveSubscribers = /* @__PURE__ */ new Set();
|
|
1058
|
-
this.isNativeWindow = false;
|
|
1059
|
-
// Wird im Konstruktor initialisiert
|
|
1060
|
-
this.setupPromise = null;
|
|
1061
|
-
this.setupHook = null;
|
|
1062
|
-
this._setupCompleted = false;
|
|
1063
|
-
this.orm = null;
|
|
1064
|
-
this.config = {
|
|
1065
|
-
debug: config.debug ?? false,
|
|
1066
|
-
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
1067
|
-
manifest: config.manifest
|
|
1068
|
-
};
|
|
1069
|
-
this.storage = new StorageAPI(this);
|
|
1070
|
-
this.database = new DatabaseAPI(this);
|
|
1071
|
-
this.filesystem = new FilesystemAPI(this);
|
|
1072
|
-
this.web = new WebAPI(this);
|
|
1073
|
-
this.permissions = new PermissionsAPI(this);
|
|
1074
|
-
installConsoleForwarding(this.config.debug);
|
|
1075
|
-
this.readyPromise = new Promise((resolve) => {
|
|
1076
|
-
this.resolveReady = resolve;
|
|
1077
|
-
});
|
|
1078
|
-
this.init();
|
|
1079
|
-
}
|
|
1080
|
-
/**
|
|
1081
|
-
* Gibt ein Promise zurück, das aufgelöst wird, sobald der Client
|
|
1082
|
-
* initialisiert ist und Extension-Infos empfangen hat.
|
|
1083
|
-
*/
|
|
1084
|
-
async ready() {
|
|
1085
|
-
return this.readyPromise;
|
|
1086
|
-
}
|
|
1087
|
-
/**
|
|
1088
|
-
* Gibt zurück, ob das Setup bereits abgeschlossen wurde.
|
|
1089
|
-
*/
|
|
1090
|
-
get setupCompleted() {
|
|
1091
|
-
return this._setupCompleted;
|
|
1051
|
+
|
|
1052
|
+
// src/client/tableName.ts
|
|
1053
|
+
function validatePublicKey(publicKey) {
|
|
1054
|
+
if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
|
|
1055
|
+
throw new HaexVaultSdkError(
|
|
1056
|
+
"INVALID_PUBLIC_KEY" /* INVALID_PUBLIC_KEY */,
|
|
1057
|
+
"errors.invalid_public_key",
|
|
1058
|
+
{ publicKey }
|
|
1059
|
+
);
|
|
1092
1060
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
}
|
|
1102
|
-
this.setupHook = setupFn;
|
|
1061
|
+
}
|
|
1062
|
+
function validateExtensionName(extensionName) {
|
|
1063
|
+
if (!extensionName || !/^[a-z][a-z0-9-]*$/i.test(extensionName)) {
|
|
1064
|
+
throw new HaexVaultSdkError(
|
|
1065
|
+
"INVALID_EXTENSION_NAME" /* INVALID_EXTENSION_NAME */,
|
|
1066
|
+
"errors.invalid_extension_name",
|
|
1067
|
+
{ extensionName }
|
|
1068
|
+
);
|
|
1103
1069
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
await this.readyPromise;
|
|
1111
|
-
if (!this.setupHook || this.setupCompleted) {
|
|
1112
|
-
return;
|
|
1113
|
-
}
|
|
1114
|
-
if (!this.setupPromise) {
|
|
1115
|
-
this.setupPromise = this.runSetupAsync();
|
|
1116
|
-
}
|
|
1117
|
-
return this.setupPromise;
|
|
1070
|
+
if (extensionName.includes(TABLE_SEPARATOR)) {
|
|
1071
|
+
throw new HaexVaultSdkError(
|
|
1072
|
+
"INVALID_EXTENSION_NAME" /* INVALID_EXTENSION_NAME */,
|
|
1073
|
+
"errors.extension_name_contains_separator",
|
|
1074
|
+
{ extensionName, separator: TABLE_SEPARATOR }
|
|
1075
|
+
);
|
|
1118
1076
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
this.notifySubscribers();
|
|
1127
|
-
} catch (error) {
|
|
1128
|
-
this.log("[HaexSpace] Setup failed:", error);
|
|
1129
|
-
throw error;
|
|
1130
|
-
}
|
|
1077
|
+
}
|
|
1078
|
+
function validateTableName(tableName) {
|
|
1079
|
+
if (!tableName || typeof tableName !== "string") {
|
|
1080
|
+
throw new HaexVaultSdkError(
|
|
1081
|
+
"INVALID_TABLE_NAME" /* INVALID_TABLE_NAME */,
|
|
1082
|
+
"errors.table_name_empty"
|
|
1083
|
+
);
|
|
1131
1084
|
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
*/
|
|
1138
|
-
initializeDatabase(schema) {
|
|
1139
|
-
if (!this._extensionInfo) {
|
|
1140
|
-
throw new HaexHubError(
|
|
1141
|
-
"EXTENSION_INFO_UNAVAILABLE" /* EXTENSION_INFO_UNAVAILABLE */,
|
|
1142
|
-
"errors.client_not_ready"
|
|
1143
|
-
);
|
|
1144
|
-
}
|
|
1145
|
-
const dbInstance = drizzle(
|
|
1146
|
-
async (sql, params, method) => {
|
|
1147
|
-
try {
|
|
1148
|
-
if (method === "run" || method === "all") {
|
|
1149
|
-
const result2 = await this.request(
|
|
1150
|
-
HAEXTENSION_METHODS.database.execute,
|
|
1151
|
-
{
|
|
1152
|
-
query: sql,
|
|
1153
|
-
params
|
|
1154
|
-
}
|
|
1155
|
-
);
|
|
1156
|
-
if (method === "all") {
|
|
1157
|
-
return { rows: result2.rows || [] };
|
|
1158
|
-
}
|
|
1159
|
-
if (result2.rows && Array.isArray(result2.rows) && result2.rows.length > 0) {
|
|
1160
|
-
return { rows: result2.rows };
|
|
1161
|
-
}
|
|
1162
|
-
return result2;
|
|
1163
|
-
}
|
|
1164
|
-
const result = await this.request(HAEXTENSION_METHODS.database.query, {
|
|
1165
|
-
query: sql,
|
|
1166
|
-
params
|
|
1167
|
-
});
|
|
1168
|
-
const rows = result.rows;
|
|
1169
|
-
if (method === "get") {
|
|
1170
|
-
return { rows: rows.length > 0 ? rows.at(0) : void 0 };
|
|
1171
|
-
}
|
|
1172
|
-
return { rows };
|
|
1173
|
-
} catch (error) {
|
|
1174
|
-
this.log("Database operation failed:", error);
|
|
1175
|
-
throw error;
|
|
1176
|
-
}
|
|
1177
|
-
},
|
|
1178
|
-
{
|
|
1179
|
-
schema,
|
|
1180
|
-
logger: false
|
|
1181
|
-
}
|
|
1085
|
+
if (tableName.includes(TABLE_SEPARATOR)) {
|
|
1086
|
+
throw new HaexVaultSdkError(
|
|
1087
|
+
"INVALID_TABLE_NAME" /* INVALID_TABLE_NAME */,
|
|
1088
|
+
"errors.table_name_contains_separator",
|
|
1089
|
+
{ tableName, separator: TABLE_SEPARATOR }
|
|
1182
1090
|
);
|
|
1183
|
-
this.orm = dbInstance;
|
|
1184
|
-
return dbInstance;
|
|
1185
1091
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1092
|
+
if (!/^[a-z][a-z0-9-_]*$/i.test(tableName)) {
|
|
1093
|
+
throw new HaexVaultSdkError(
|
|
1094
|
+
"INVALID_TABLE_NAME" /* INVALID_TABLE_NAME */,
|
|
1095
|
+
"errors.table_name_format",
|
|
1096
|
+
{ tableName }
|
|
1097
|
+
);
|
|
1188
1098
|
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1099
|
+
}
|
|
1100
|
+
function getExtensionTableName(extensionInfo, tableName) {
|
|
1101
|
+
if (!extensionInfo) {
|
|
1102
|
+
throw new HaexVaultSdkError(
|
|
1103
|
+
"EXTENSION_INFO_UNAVAILABLE" /* EXTENSION_INFO_UNAVAILABLE */,
|
|
1104
|
+
"errors.extension_info_unavailable"
|
|
1105
|
+
);
|
|
1191
1106
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1107
|
+
validateTableName(tableName);
|
|
1108
|
+
const { publicKey, name } = extensionInfo;
|
|
1109
|
+
return `"${getTableName(publicKey, name, tableName)}"`;
|
|
1110
|
+
}
|
|
1111
|
+
function getDependencyTableName(publicKey, extensionName, tableName) {
|
|
1112
|
+
validatePublicKey(publicKey);
|
|
1113
|
+
validateExtensionName(extensionName);
|
|
1114
|
+
validateTableName(tableName);
|
|
1115
|
+
return `"${getTableName(publicKey, extensionName, tableName)}"`;
|
|
1116
|
+
}
|
|
1117
|
+
function parseTableName(fullTableName) {
|
|
1118
|
+
let cleanTableName = fullTableName;
|
|
1119
|
+
if (cleanTableName.startsWith('"') && cleanTableName.endsWith('"')) {
|
|
1120
|
+
cleanTableName = cleanTableName.slice(1, -1);
|
|
1197
1121
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1122
|
+
const parts = cleanTableName.split(TABLE_SEPARATOR);
|
|
1123
|
+
if (parts.length !== 3) {
|
|
1124
|
+
return null;
|
|
1200
1125
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1126
|
+
const [publicKey, extensionName, tableName] = parts;
|
|
1127
|
+
if (!publicKey || !extensionName || !tableName) {
|
|
1128
|
+
return null;
|
|
1203
1129
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1130
|
+
return {
|
|
1131
|
+
publicKey,
|
|
1132
|
+
extensionName,
|
|
1133
|
+
tableName
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
// src/client/init.ts
|
|
1138
|
+
function isInIframe() {
|
|
1139
|
+
return window.self !== window.top;
|
|
1140
|
+
}
|
|
1141
|
+
function hasTauri() {
|
|
1142
|
+
return typeof window.__TAURI__ !== "undefined";
|
|
1143
|
+
}
|
|
1144
|
+
function getTauriCore() {
|
|
1145
|
+
return window.__TAURI__.core;
|
|
1146
|
+
}
|
|
1147
|
+
function getTauriEvent() {
|
|
1148
|
+
return window.__TAURI__.event;
|
|
1149
|
+
}
|
|
1150
|
+
async function initNativeMode(ctx, log, onEvent, onContextChange) {
|
|
1151
|
+
const { invoke } = getTauriCore();
|
|
1152
|
+
const extensionInfo = await invoke("webview_extension_get_info");
|
|
1153
|
+
const context = await invoke("webview_extension_context_get");
|
|
1154
|
+
ctx.state.isNativeWindow = true;
|
|
1155
|
+
ctx.state.initialized = true;
|
|
1156
|
+
ctx.state.extensionInfo = extensionInfo;
|
|
1157
|
+
ctx.state.context = context;
|
|
1158
|
+
log("HaexVault SDK initialized in native WebViewWindow mode");
|
|
1159
|
+
log("Extension info:", extensionInfo);
|
|
1160
|
+
log("Application context:", context);
|
|
1161
|
+
await setupTauriEventListeners(ctx, log, onEvent, onContextChange);
|
|
1162
|
+
return { extensionInfo, context };
|
|
1163
|
+
}
|
|
1164
|
+
async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
1165
|
+
const { listen } = getTauriEvent();
|
|
1166
|
+
console.log("[HaexVault SDK] Setting up Tauri event listener for:", HAEXTENSION_EVENTS.CONTEXT_CHANGED);
|
|
1167
|
+
try {
|
|
1168
|
+
await listen(HAEXTENSION_EVENTS.CONTEXT_CHANGED, (event) => {
|
|
1169
|
+
console.log("[HaexVault SDK] Received Tauri event:", HAEXTENSION_EVENTS.CONTEXT_CHANGED, event);
|
|
1170
|
+
log("Received context change event:", event);
|
|
1171
|
+
const payload = event.payload;
|
|
1172
|
+
if (payload?.context) {
|
|
1173
|
+
ctx.state.context = payload.context;
|
|
1174
|
+
console.log("[HaexVault SDK] Updated context to:", ctx.state.context);
|
|
1175
|
+
onContextChange(payload.context);
|
|
1176
|
+
onEvent({
|
|
1177
|
+
type: HAEXTENSION_EVENTS.CONTEXT_CHANGED,
|
|
1178
|
+
data: { context: ctx.state.context },
|
|
1179
|
+
timestamp: Date.now()
|
|
1180
|
+
});
|
|
1181
|
+
} else {
|
|
1182
|
+
console.warn("[HaexVault SDK] Event received but no context in payload:", event);
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
console.log("[HaexVault SDK] Context change listener registered successfully");
|
|
1186
|
+
} catch (error) {
|
|
1187
|
+
console.error("[HaexVault SDK] Failed to setup context change listener:", error);
|
|
1188
|
+
log("Failed to setup context change listener:", error);
|
|
1214
1189
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1190
|
+
try {
|
|
1191
|
+
await listen(HAEXTENSION_EVENTS.EXTERNAL_REQUEST, (event) => {
|
|
1192
|
+
log("Received external request event:", event);
|
|
1193
|
+
if (event.payload) {
|
|
1194
|
+
onEvent({
|
|
1195
|
+
type: HAEXTENSION_EVENTS.EXTERNAL_REQUEST,
|
|
1196
|
+
data: event.payload,
|
|
1197
|
+
timestamp: Date.now()
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
console.log("[HaexVault SDK] External request listener registered successfully");
|
|
1202
|
+
} catch (error) {
|
|
1203
|
+
console.error("[HaexVault SDK] Failed to setup external request listener:", error);
|
|
1204
|
+
log("Failed to setup external request listener:", error);
|
|
1220
1205
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
tableName
|
|
1206
|
+
}
|
|
1207
|
+
async function initIframeMode(ctx, log, messageHandler, request) {
|
|
1208
|
+
if (!isInIframe()) {
|
|
1209
|
+
throw new HaexVaultSdkError("NOT_IN_IFRAME" /* NOT_IN_IFRAME */, "errors.not_in_iframe");
|
|
1210
|
+
}
|
|
1211
|
+
ctx.handlers.messageHandler = messageHandler;
|
|
1212
|
+
window.addEventListener("message", messageHandler);
|
|
1213
|
+
ctx.state.isNativeWindow = false;
|
|
1214
|
+
ctx.state.initialized = true;
|
|
1215
|
+
log("HaexVault SDK initialized in iframe mode");
|
|
1216
|
+
if (ctx.config.manifest) {
|
|
1217
|
+
ctx.state.extensionInfo = {
|
|
1218
|
+
publicKey: ctx.config.manifest.publicKey,
|
|
1219
|
+
name: ctx.config.manifest.name,
|
|
1220
|
+
version: ctx.config.manifest.version,
|
|
1221
|
+
displayName: ctx.config.manifest.name
|
|
1238
1222
|
};
|
|
1223
|
+
log("Extension info loaded from manifest:", ctx.state.extensionInfo);
|
|
1239
1224
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
* Execute a raw SQL statement (INSERT, UPDATE, DELETE, CREATE, etc.)
|
|
1262
|
-
* Returns rowsAffected and lastInsertId
|
|
1263
|
-
*/
|
|
1264
|
-
async execute(sql, params = []) {
|
|
1265
|
-
const result = await this.request(
|
|
1266
|
-
HAEXTENSION_METHODS.database.execute,
|
|
1267
|
-
{ query: sql, params }
|
|
1268
|
-
);
|
|
1269
|
-
return {
|
|
1270
|
-
rowsAffected: result.rowsAffected,
|
|
1271
|
-
lastInsertId: result.lastInsertId
|
|
1272
|
-
};
|
|
1273
|
-
}
|
|
1274
|
-
/**
|
|
1275
|
-
* Registers and applies extension migrations with HaexVault
|
|
1276
|
-
*
|
|
1277
|
-
* HaexVault will:
|
|
1278
|
-
* 1. Validate all SQL statements (ensure only extension's own tables are accessed)
|
|
1279
|
-
* 2. Store migrations with applied_at = NULL
|
|
1280
|
-
* 3. Query pending migrations sorted by name
|
|
1281
|
-
* 4. Apply pending migrations and set up CRDT triggers
|
|
1282
|
-
* 5. Mark successful migrations with applied_at timestamp
|
|
1283
|
-
*
|
|
1284
|
-
* @param extensionVersion - The version of the extension
|
|
1285
|
-
* @param migrations - Array of migration objects with name and SQL content
|
|
1286
|
-
* @returns Promise with migration result (applied count, already applied count, applied migration names)
|
|
1287
|
-
*/
|
|
1288
|
-
async registerMigrationsAsync(extensionVersion, migrations) {
|
|
1289
|
-
return this.database.registerMigrationsAsync(extensionVersion, migrations);
|
|
1290
|
-
}
|
|
1291
|
-
async requestDatabasePermission(request) {
|
|
1292
|
-
return this.request("permissions.database.request", {
|
|
1293
|
-
resource: request.resource,
|
|
1294
|
-
operation: request.operation,
|
|
1295
|
-
reason: request.reason
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
|
-
async checkDatabasePermission(resource, operation) {
|
|
1299
|
-
const response = await this.request(
|
|
1300
|
-
"permissions.database.check",
|
|
1301
|
-
{
|
|
1302
|
-
resource,
|
|
1303
|
-
operation
|
|
1304
|
-
}
|
|
1305
|
-
);
|
|
1306
|
-
return response.status === "granted";
|
|
1307
|
-
}
|
|
1308
|
-
async respondToSearch(requestId, results) {
|
|
1309
|
-
await this.request("search.respond", {
|
|
1310
|
-
requestId,
|
|
1311
|
-
results
|
|
1312
|
-
});
|
|
1225
|
+
sendDebugInfo(ctx.config);
|
|
1226
|
+
const context = await request(HAEXTENSION_METHODS.context.get);
|
|
1227
|
+
ctx.state.context = context;
|
|
1228
|
+
log("Application context received:", context);
|
|
1229
|
+
return { context };
|
|
1230
|
+
}
|
|
1231
|
+
function sendDebugInfo(config) {
|
|
1232
|
+
if (!config.debug) return;
|
|
1233
|
+
if (typeof window === "undefined" || !window.parent) return;
|
|
1234
|
+
const debugInfo = `SDK Debug:
|
|
1235
|
+
window.parent exists: ${!!window.parent}
|
|
1236
|
+
window.parent === window: ${window.parent === window}
|
|
1237
|
+
window.self === window.top: ${window.self === window.top}`;
|
|
1238
|
+
try {
|
|
1239
|
+
window.parent.postMessage({
|
|
1240
|
+
type: HAEXSPACE_MESSAGE_TYPES.DEBUG,
|
|
1241
|
+
data: debugInfo
|
|
1242
|
+
}, "*");
|
|
1243
|
+
} catch (e) {
|
|
1244
|
+
alert(debugInfo + `
|
|
1245
|
+
postMessage error: ${e}`);
|
|
1313
1246
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
// src/commands.ts
|
|
1250
|
+
var TAURI_COMMANDS = {
|
|
1251
|
+
database: {
|
|
1252
|
+
query: "webview_extension_db_query",
|
|
1253
|
+
execute: "webview_extension_db_execute",
|
|
1254
|
+
registerMigrations: "webview_extension_db_register_migrations"
|
|
1255
|
+
},
|
|
1256
|
+
permissions: {
|
|
1257
|
+
checkWeb: "webview_extension_check_web_permission",
|
|
1258
|
+
checkDatabase: "webview_extension_check_database_permission",
|
|
1259
|
+
checkFilesystem: "webview_extension_check_filesystem_permission"
|
|
1260
|
+
},
|
|
1261
|
+
web: {
|
|
1262
|
+
open: "webview_extension_web_open",
|
|
1263
|
+
fetch: "webview_extension_web_request"
|
|
1264
|
+
},
|
|
1265
|
+
filesystem: {
|
|
1266
|
+
saveFile: "webview_extension_fs_save_file",
|
|
1267
|
+
openFile: "webview_extension_fs_open_file",
|
|
1268
|
+
showImage: "webview_extension_fs_show_image"
|
|
1269
|
+
},
|
|
1270
|
+
external: {
|
|
1271
|
+
// Response handling (called by extensions)
|
|
1272
|
+
respond: "external_respond",
|
|
1273
|
+
// Bridge server management
|
|
1274
|
+
bridgeStart: "external_bridge_start",
|
|
1275
|
+
bridgeStop: "external_bridge_stop",
|
|
1276
|
+
bridgeGetStatus: "external_bridge_get_status",
|
|
1277
|
+
// Client authorization (unified API with remember flag)
|
|
1278
|
+
clientAllow: "external_client_allow",
|
|
1279
|
+
clientBlock: "external_client_block",
|
|
1280
|
+
// Authorized clients management
|
|
1281
|
+
getAuthorizedClients: "external_get_authorized_clients",
|
|
1282
|
+
revokeClient: "external_revoke_client",
|
|
1283
|
+
// Blocked clients management
|
|
1284
|
+
getBlockedClients: "external_get_blocked_clients",
|
|
1285
|
+
unblockClient: "external_unblock_client",
|
|
1286
|
+
isClientBlocked: "external_is_client_blocked",
|
|
1287
|
+
// Pending authorizations
|
|
1288
|
+
getPendingAuthorizations: "external_get_pending_authorizations"
|
|
1289
|
+
},
|
|
1290
|
+
extension: {
|
|
1291
|
+
getInfo: "webview_extension_get_info",
|
|
1292
|
+
getContext: "webview_extension_context_get"
|
|
1293
|
+
},
|
|
1294
|
+
filesync: {
|
|
1295
|
+
// Spaces
|
|
1296
|
+
listSpaces: "filesync_list_spaces",
|
|
1297
|
+
createSpace: "filesync_create_space",
|
|
1298
|
+
deleteSpace: "filesync_delete_space",
|
|
1299
|
+
// Files
|
|
1300
|
+
listFiles: "filesync_list_files",
|
|
1301
|
+
getFile: "filesync_get_file",
|
|
1302
|
+
uploadFile: "filesync_upload_file",
|
|
1303
|
+
downloadFile: "filesync_download_file",
|
|
1304
|
+
deleteFile: "filesync_delete_file",
|
|
1305
|
+
// Backends
|
|
1306
|
+
listBackends: "filesync_list_backends",
|
|
1307
|
+
addBackend: "filesync_add_backend",
|
|
1308
|
+
removeBackend: "filesync_remove_backend",
|
|
1309
|
+
testBackend: "filesync_test_backend",
|
|
1310
|
+
// Sync Rules
|
|
1311
|
+
listSyncRules: "filesync_list_sync_rules",
|
|
1312
|
+
addSyncRule: "filesync_add_sync_rule",
|
|
1313
|
+
removeSyncRule: "filesync_remove_sync_rule",
|
|
1314
|
+
// Sync Operations
|
|
1315
|
+
getSyncStatus: "filesync_get_sync_status",
|
|
1316
|
+
triggerSync: "filesync_trigger_sync",
|
|
1317
|
+
pauseSync: "filesync_pause_sync",
|
|
1318
|
+
resumeSync: "filesync_resume_sync",
|
|
1319
|
+
// Conflict Resolution
|
|
1320
|
+
resolveConflict: "filesync_resolve_conflict",
|
|
1321
|
+
// UI Helpers
|
|
1322
|
+
selectFolder: "filesync_select_folder"
|
|
1340
1323
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
// src/transport/handlers/database.ts
|
|
1327
|
+
var databaseHandlers = {
|
|
1328
|
+
[HAEXTENSION_METHODS.database.query]: {
|
|
1329
|
+
command: TAURI_COMMANDS.database.query,
|
|
1330
|
+
args: (p) => ({
|
|
1331
|
+
query: p.query,
|
|
1332
|
+
params: p.params || []
|
|
1333
|
+
})
|
|
1334
|
+
},
|
|
1335
|
+
[HAEXTENSION_METHODS.database.execute]: {
|
|
1336
|
+
command: TAURI_COMMANDS.database.execute,
|
|
1337
|
+
args: (p) => ({
|
|
1338
|
+
query: p.query,
|
|
1339
|
+
params: p.params || []
|
|
1340
|
+
})
|
|
1341
|
+
},
|
|
1342
|
+
[HAEXTENSION_METHODS.database.registerMigrations]: {
|
|
1343
|
+
command: TAURI_COMMANDS.database.registerMigrations,
|
|
1344
|
+
args: (p) => ({
|
|
1345
|
+
extensionVersion: p.extensionVersion,
|
|
1346
|
+
migrations: p.migrations
|
|
1347
|
+
})
|
|
1347
1348
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
this.pendingRequests.set(requestId, { resolve, reject, timeout });
|
|
1372
|
-
const targetOrigin = "*";
|
|
1373
|
-
if (this.config.debug) {
|
|
1374
|
-
console.log("[SDK Debug] ========== Sending Request ==========");
|
|
1375
|
-
console.log("[SDK Debug] Request ID:", requestId);
|
|
1376
|
-
console.log("[SDK Debug] Method:", request.method);
|
|
1377
|
-
console.log("[SDK Debug] Params:", request.params);
|
|
1378
|
-
console.log("[SDK Debug] Target origin:", targetOrigin);
|
|
1379
|
-
console.log("[SDK Debug] Extension info:", this._extensionInfo);
|
|
1380
|
-
console.log("[SDK Debug] ========================================");
|
|
1381
|
-
}
|
|
1382
|
-
window.parent.postMessage({ id: requestId, ...request }, targetOrigin);
|
|
1383
|
-
});
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
// src/transport/handlers/permissions.ts
|
|
1352
|
+
var permissionsHandlers = {
|
|
1353
|
+
"permissions.web.check": {
|
|
1354
|
+
command: TAURI_COMMANDS.permissions.checkWeb,
|
|
1355
|
+
args: (p) => ({
|
|
1356
|
+
url: p.url
|
|
1357
|
+
})
|
|
1358
|
+
},
|
|
1359
|
+
"permissions.database.check": {
|
|
1360
|
+
command: TAURI_COMMANDS.permissions.checkDatabase,
|
|
1361
|
+
args: (p) => ({
|
|
1362
|
+
resource: p.resource,
|
|
1363
|
+
operation: p.operation
|
|
1364
|
+
})
|
|
1365
|
+
},
|
|
1366
|
+
"permissions.filesystem.check": {
|
|
1367
|
+
command: TAURI_COMMANDS.permissions.checkFilesystem,
|
|
1368
|
+
args: (p) => ({
|
|
1369
|
+
path: p.path,
|
|
1370
|
+
actionStr: p.action
|
|
1371
|
+
})
|
|
1384
1372
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
});
|
|
1404
|
-
case "permissions.web.check":
|
|
1405
|
-
return invoke("webview_extension_check_web_permission", {
|
|
1406
|
-
url: params.url
|
|
1407
|
-
});
|
|
1408
|
-
case "permissions.database.check":
|
|
1409
|
-
return invoke("webview_extension_check_database_permission", {
|
|
1410
|
-
resource: params.resource,
|
|
1411
|
-
operation: params.operation
|
|
1412
|
-
});
|
|
1413
|
-
case "permissions.filesystem.check":
|
|
1414
|
-
return invoke("webview_extension_check_filesystem_permission", {
|
|
1415
|
-
path: params.path,
|
|
1416
|
-
actionStr: params.action
|
|
1417
|
-
});
|
|
1418
|
-
case HAEXTENSION_METHODS.application.open:
|
|
1419
|
-
return invoke("webview_extension_web_open", {
|
|
1420
|
-
url: params.url
|
|
1421
|
-
});
|
|
1422
|
-
case HAEXTENSION_METHODS.web.fetch:
|
|
1423
|
-
return invoke("webview_extension_web_request", {
|
|
1424
|
-
url: params.url,
|
|
1425
|
-
method: params.method,
|
|
1426
|
-
headers: params.headers,
|
|
1427
|
-
body: params.body
|
|
1428
|
-
});
|
|
1429
|
-
case HAEXTENSION_METHODS.filesystem.saveFile:
|
|
1430
|
-
return invoke("webview_extension_fs_save_file", {
|
|
1431
|
-
data: params.data,
|
|
1432
|
-
defaultPath: params.defaultPath,
|
|
1433
|
-
title: params.title,
|
|
1434
|
-
filters: params.filters
|
|
1435
|
-
});
|
|
1436
|
-
case HAEXTENSION_METHODS.filesystem.openFile:
|
|
1437
|
-
return invoke("webview_extension_fs_open_file", {
|
|
1438
|
-
data: params.data,
|
|
1439
|
-
fileName: params.fileName
|
|
1440
|
-
});
|
|
1441
|
-
case HAEXTENSION_METHODS.database.registerMigrations:
|
|
1442
|
-
return invoke("webview_extension_db_register_migrations", {
|
|
1443
|
-
extensionVersion: params.extensionVersion,
|
|
1444
|
-
migrations: params.migrations
|
|
1445
|
-
});
|
|
1446
|
-
case "external.respond":
|
|
1447
|
-
return invoke("webview_extension_external_respond", {
|
|
1448
|
-
requestId: params.requestId,
|
|
1449
|
-
success: params.success,
|
|
1450
|
-
data: params.data,
|
|
1451
|
-
error: params.error
|
|
1452
|
-
});
|
|
1453
|
-
default:
|
|
1454
|
-
throw new HaexHubError(
|
|
1455
|
-
"METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,
|
|
1456
|
-
"errors.method_not_found",
|
|
1457
|
-
{ method }
|
|
1458
|
-
);
|
|
1459
|
-
}
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
// src/transport/handlers/web.ts
|
|
1376
|
+
var webHandlers = {
|
|
1377
|
+
[HAEXTENSION_METHODS.application.open]: {
|
|
1378
|
+
command: TAURI_COMMANDS.web.open,
|
|
1379
|
+
args: (p) => ({
|
|
1380
|
+
url: p.url
|
|
1381
|
+
})
|
|
1382
|
+
},
|
|
1383
|
+
[HAEXTENSION_METHODS.web.fetch]: {
|
|
1384
|
+
command: TAURI_COMMANDS.web.fetch,
|
|
1385
|
+
args: (p) => ({
|
|
1386
|
+
url: p.url,
|
|
1387
|
+
method: p.method,
|
|
1388
|
+
headers: p.headers,
|
|
1389
|
+
body: p.body
|
|
1390
|
+
})
|
|
1460
1391
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
// src/transport/handlers/filesystem.ts
|
|
1395
|
+
var filesystemHandlers = {
|
|
1396
|
+
[HAEXTENSION_METHODS.filesystem.saveFile]: {
|
|
1397
|
+
command: TAURI_COMMANDS.filesystem.saveFile,
|
|
1398
|
+
args: (p) => ({
|
|
1399
|
+
data: p.data,
|
|
1400
|
+
defaultPath: p.defaultPath,
|
|
1401
|
+
title: p.title,
|
|
1402
|
+
filters: p.filters
|
|
1403
|
+
})
|
|
1404
|
+
},
|
|
1405
|
+
[HAEXTENSION_METHODS.filesystem.openFile]: {
|
|
1406
|
+
command: TAURI_COMMANDS.filesystem.openFile,
|
|
1407
|
+
args: (p) => ({
|
|
1408
|
+
data: p.data,
|
|
1409
|
+
fileName: p.fileName
|
|
1410
|
+
})
|
|
1411
|
+
},
|
|
1412
|
+
[HAEXTENSION_METHODS.filesystem.showImage]: {
|
|
1413
|
+
command: TAURI_COMMANDS.filesystem.showImage,
|
|
1414
|
+
args: (p) => ({
|
|
1415
|
+
dataUrl: p.dataUrl
|
|
1416
|
+
})
|
|
1466
1417
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
// src/transport/handlers/external.ts
|
|
1421
|
+
var externalHandlers = {
|
|
1422
|
+
"external.respond": {
|
|
1423
|
+
command: TAURI_COMMANDS.external.respond,
|
|
1424
|
+
args: (p) => ({
|
|
1425
|
+
requestId: p.requestId,
|
|
1426
|
+
success: p.success,
|
|
1427
|
+
data: p.data,
|
|
1428
|
+
error: p.error
|
|
1429
|
+
})
|
|
1472
1430
|
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1433
|
+
// src/transport/handlers/filesync.ts
|
|
1434
|
+
var filesyncHandlers = {
|
|
1435
|
+
// ==========================================================================
|
|
1436
|
+
// Spaces
|
|
1437
|
+
// ==========================================================================
|
|
1438
|
+
[HAEXTENSION_METHODS.filesystem.sync.listSpaces]: {
|
|
1439
|
+
command: TAURI_COMMANDS.filesync.listSpaces,
|
|
1440
|
+
args: () => ({})
|
|
1441
|
+
},
|
|
1442
|
+
[HAEXTENSION_METHODS.filesystem.sync.createSpace]: {
|
|
1443
|
+
command: TAURI_COMMANDS.filesync.createSpace,
|
|
1444
|
+
args: (p) => ({ request: p })
|
|
1445
|
+
},
|
|
1446
|
+
[HAEXTENSION_METHODS.filesystem.sync.deleteSpace]: {
|
|
1447
|
+
command: TAURI_COMMANDS.filesync.deleteSpace,
|
|
1448
|
+
args: (p) => ({ spaceId: p.spaceId })
|
|
1449
|
+
},
|
|
1450
|
+
// ==========================================================================
|
|
1451
|
+
// Files
|
|
1452
|
+
// ==========================================================================
|
|
1453
|
+
[HAEXTENSION_METHODS.filesystem.sync.listFiles]: {
|
|
1454
|
+
command: TAURI_COMMANDS.filesync.listFiles,
|
|
1455
|
+
args: (p) => ({ request: p })
|
|
1456
|
+
},
|
|
1457
|
+
[HAEXTENSION_METHODS.filesystem.sync.getFile]: {
|
|
1458
|
+
command: TAURI_COMMANDS.filesync.getFile,
|
|
1459
|
+
args: (p) => ({ fileId: p.fileId })
|
|
1460
|
+
},
|
|
1461
|
+
[HAEXTENSION_METHODS.filesystem.sync.uploadFile]: {
|
|
1462
|
+
command: TAURI_COMMANDS.filesync.uploadFile,
|
|
1463
|
+
args: (p) => ({ request: p })
|
|
1464
|
+
},
|
|
1465
|
+
[HAEXTENSION_METHODS.filesystem.sync.downloadFile]: {
|
|
1466
|
+
command: TAURI_COMMANDS.filesync.downloadFile,
|
|
1467
|
+
args: (p) => ({ request: p })
|
|
1468
|
+
},
|
|
1469
|
+
[HAEXTENSION_METHODS.filesystem.sync.deleteFile]: {
|
|
1470
|
+
command: TAURI_COMMANDS.filesync.deleteFile,
|
|
1471
|
+
args: (p) => ({ fileId: p.fileId })
|
|
1472
|
+
},
|
|
1473
|
+
// ==========================================================================
|
|
1474
|
+
// Backends
|
|
1475
|
+
// ==========================================================================
|
|
1476
|
+
[HAEXTENSION_METHODS.filesystem.sync.listBackends]: {
|
|
1477
|
+
command: TAURI_COMMANDS.filesync.listBackends,
|
|
1478
|
+
args: () => ({})
|
|
1479
|
+
},
|
|
1480
|
+
[HAEXTENSION_METHODS.filesystem.sync.addBackend]: {
|
|
1481
|
+
command: TAURI_COMMANDS.filesync.addBackend,
|
|
1482
|
+
args: (p) => ({ request: p })
|
|
1483
|
+
},
|
|
1484
|
+
[HAEXTENSION_METHODS.filesystem.sync.removeBackend]: {
|
|
1485
|
+
command: TAURI_COMMANDS.filesync.removeBackend,
|
|
1486
|
+
args: (p) => ({ backendId: p.backendId })
|
|
1487
|
+
},
|
|
1488
|
+
[HAEXTENSION_METHODS.filesystem.sync.testBackend]: {
|
|
1489
|
+
command: TAURI_COMMANDS.filesync.testBackend,
|
|
1490
|
+
args: (p) => ({ backendId: p.backendId })
|
|
1491
|
+
},
|
|
1492
|
+
// ==========================================================================
|
|
1493
|
+
// Sync Rules
|
|
1494
|
+
// ==========================================================================
|
|
1495
|
+
[HAEXTENSION_METHODS.filesystem.sync.listSyncRules]: {
|
|
1496
|
+
command: TAURI_COMMANDS.filesync.listSyncRules,
|
|
1497
|
+
args: () => ({})
|
|
1498
|
+
},
|
|
1499
|
+
[HAEXTENSION_METHODS.filesystem.sync.addSyncRule]: {
|
|
1500
|
+
command: TAURI_COMMANDS.filesync.addSyncRule,
|
|
1501
|
+
args: (p) => ({ request: p })
|
|
1502
|
+
},
|
|
1503
|
+
[HAEXTENSION_METHODS.filesystem.sync.removeSyncRule]: {
|
|
1504
|
+
command: TAURI_COMMANDS.filesync.removeSyncRule,
|
|
1505
|
+
args: (p) => ({ ruleId: p.ruleId })
|
|
1506
|
+
},
|
|
1507
|
+
// ==========================================================================
|
|
1508
|
+
// Sync Operations
|
|
1509
|
+
// ==========================================================================
|
|
1510
|
+
[HAEXTENSION_METHODS.filesystem.sync.getSyncStatus]: {
|
|
1511
|
+
command: TAURI_COMMANDS.filesync.getSyncStatus,
|
|
1512
|
+
args: () => ({})
|
|
1513
|
+
},
|
|
1514
|
+
[HAEXTENSION_METHODS.filesystem.sync.triggerSync]: {
|
|
1515
|
+
command: TAURI_COMMANDS.filesync.triggerSync,
|
|
1516
|
+
args: () => ({})
|
|
1517
|
+
},
|
|
1518
|
+
[HAEXTENSION_METHODS.filesystem.sync.pauseSync]: {
|
|
1519
|
+
command: TAURI_COMMANDS.filesync.pauseSync,
|
|
1520
|
+
args: () => ({})
|
|
1521
|
+
},
|
|
1522
|
+
[HAEXTENSION_METHODS.filesystem.sync.resumeSync]: {
|
|
1523
|
+
command: TAURI_COMMANDS.filesync.resumeSync,
|
|
1524
|
+
args: () => ({})
|
|
1525
|
+
},
|
|
1526
|
+
// ==========================================================================
|
|
1527
|
+
// Conflict Resolution
|
|
1528
|
+
// ==========================================================================
|
|
1529
|
+
[HAEXTENSION_METHODS.filesystem.sync.resolveConflict]: {
|
|
1530
|
+
command: TAURI_COMMANDS.filesync.resolveConflict,
|
|
1531
|
+
args: (p) => ({ request: p })
|
|
1532
|
+
},
|
|
1533
|
+
// ==========================================================================
|
|
1534
|
+
// UI Helpers
|
|
1535
|
+
// ==========================================================================
|
|
1536
|
+
[HAEXTENSION_METHODS.filesystem.sync.selectFolder]: {
|
|
1537
|
+
command: TAURI_COMMANDS.filesync.selectFolder,
|
|
1538
|
+
args: () => ({})
|
|
1482
1539
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
if (event.payload) {
|
|
1525
|
-
this.handleEvent({
|
|
1526
|
-
type: HAEXTENSION_EVENTS.EXTERNAL_REQUEST,
|
|
1527
|
-
data: event.payload,
|
|
1528
|
-
timestamp: Date.now()
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
console.log("[HaexSpace SDK] External request listener registered successfully");
|
|
1533
|
-
} catch (error) {
|
|
1534
|
-
console.error("[HaexSpace SDK] Failed to setup external request listener:", error);
|
|
1535
|
-
this.log("Failed to setup external request listener:", error);
|
|
1536
|
-
}
|
|
1537
|
-
this.resolveReady();
|
|
1538
|
-
return;
|
|
1539
|
-
}
|
|
1540
|
-
} catch (error) {
|
|
1541
|
-
this.log("Tauri commands failed, falling back to iframe mode", error);
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
if (window.self === window.top) {
|
|
1545
|
-
throw new HaexHubError("NOT_IN_IFRAME" /* NOT_IN_IFRAME */, "errors.not_in_iframe");
|
|
1546
|
-
}
|
|
1547
|
-
this.messageHandler = this.handleMessage.bind(this);
|
|
1548
|
-
window.addEventListener("message", this.messageHandler);
|
|
1549
|
-
this.isNativeWindow = false;
|
|
1550
|
-
this.initialized = true;
|
|
1551
|
-
this.log("HaexSpace SDK initialized in iframe mode");
|
|
1552
|
-
try {
|
|
1553
|
-
if (this.config.manifest) {
|
|
1554
|
-
this._extensionInfo = {
|
|
1555
|
-
publicKey: this.config.manifest.publicKey,
|
|
1556
|
-
name: this.config.manifest.name,
|
|
1557
|
-
version: this.config.manifest.version,
|
|
1558
|
-
displayName: this.config.manifest.name
|
|
1559
|
-
};
|
|
1560
|
-
this.log("Extension info loaded from manifest:", this._extensionInfo);
|
|
1561
|
-
this.notifySubscribers();
|
|
1562
|
-
}
|
|
1563
|
-
if (typeof window !== "undefined" && window.parent) {
|
|
1564
|
-
const debugInfo = `SDK Debug:
|
|
1565
|
-
window.parent exists: ${!!window.parent}
|
|
1566
|
-
window.parent === window: ${window.parent === window}
|
|
1567
|
-
window.self === window.top: ${window.self === window.top}`;
|
|
1568
|
-
try {
|
|
1569
|
-
window.parent.postMessage({
|
|
1570
|
-
type: HAEXSPACE_MESSAGE_TYPES.DEBUG,
|
|
1571
|
-
data: debugInfo
|
|
1572
|
-
}, "*");
|
|
1573
|
-
} catch (e) {
|
|
1574
|
-
alert(debugInfo + `
|
|
1575
|
-
postMessage error: ${e}`);
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
this._context = await this.request(HAEXTENSION_METHODS.context.get);
|
|
1579
|
-
this.log("Application context received:", this._context);
|
|
1580
|
-
this.notifySubscribers();
|
|
1581
|
-
this.resolveReady();
|
|
1582
|
-
} catch (error) {
|
|
1583
|
-
this.log("Failed to load extension info or context:", error);
|
|
1584
|
-
throw error;
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
// src/transport/handlers/index.ts
|
|
1543
|
+
var allHandlers = {
|
|
1544
|
+
...databaseHandlers,
|
|
1545
|
+
...permissionsHandlers,
|
|
1546
|
+
...webHandlers,
|
|
1547
|
+
...filesystemHandlers,
|
|
1548
|
+
...externalHandlers,
|
|
1549
|
+
...filesyncHandlers
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
// src/client/transport.ts
|
|
1553
|
+
function generateRequestId(counter) {
|
|
1554
|
+
return `req_${counter}`;
|
|
1555
|
+
}
|
|
1556
|
+
function sendPostMessage(method, params, requestId, config, extensionInfo, pendingRequests) {
|
|
1557
|
+
const request = {
|
|
1558
|
+
method,
|
|
1559
|
+
params,
|
|
1560
|
+
timestamp: Date.now()
|
|
1561
|
+
};
|
|
1562
|
+
return new Promise((resolve, reject) => {
|
|
1563
|
+
const timeout = setTimeout(() => {
|
|
1564
|
+
pendingRequests.delete(requestId);
|
|
1565
|
+
reject(
|
|
1566
|
+
new HaexVaultSdkError("TIMEOUT" /* TIMEOUT */, "errors.timeout", {
|
|
1567
|
+
timeout: config.timeout
|
|
1568
|
+
})
|
|
1569
|
+
);
|
|
1570
|
+
}, config.timeout);
|
|
1571
|
+
pendingRequests.set(requestId, { resolve, reject, timeout });
|
|
1572
|
+
const targetOrigin = "*";
|
|
1573
|
+
if (config.debug) {
|
|
1574
|
+
console.log("[SDK Debug] ========== Sending Request ==========");
|
|
1575
|
+
console.log("[SDK Debug] Request ID:", requestId);
|
|
1576
|
+
console.log("[SDK Debug] Method:", request.method);
|
|
1577
|
+
console.log("[SDK Debug] Params:", request.params);
|
|
1578
|
+
console.log("[SDK Debug] Target origin:", targetOrigin);
|
|
1579
|
+
console.log("[SDK Debug] Extension info:", extensionInfo);
|
|
1580
|
+
console.log("[SDK Debug] ========================================");
|
|
1585
1581
|
}
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1582
|
+
window.parent.postMessage({ id: requestId, ...request }, targetOrigin);
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
async function sendInvoke(method, params, config, log) {
|
|
1586
|
+
const { invoke } = window.__TAURI__.core;
|
|
1587
|
+
if (config.debug) {
|
|
1588
|
+
console.log("[SDK Debug] ========== Invoke Request ==========");
|
|
1589
|
+
console.log("[SDK Debug] Method:", method);
|
|
1590
|
+
console.log("[SDK Debug] Params:", params);
|
|
1591
|
+
console.log("[SDK Debug] =======================================");
|
|
1592
|
+
}
|
|
1593
|
+
const handler = allHandlers[method];
|
|
1594
|
+
if (handler) {
|
|
1595
|
+
const args = handler.args(params);
|
|
1596
|
+
return invoke(handler.command, args);
|
|
1597
|
+
}
|
|
1598
|
+
throw new HaexVaultSdkError(
|
|
1599
|
+
"METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,
|
|
1600
|
+
"errors.method_not_found",
|
|
1601
|
+
{ method }
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
// src/client/events.ts
|
|
1606
|
+
function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
|
|
1607
|
+
return (event) => {
|
|
1608
|
+
if (config.debug) {
|
|
1589
1609
|
console.log("[SDK Debug] ========== Message Received ==========");
|
|
1590
1610
|
console.log("[SDK Debug] Event origin:", event.origin);
|
|
1591
1611
|
console.log(
|
|
@@ -1593,160 +1613,534 @@ postMessage error: ${e}`);
|
|
|
1593
1613
|
event.source === window.parent ? "parent window" : "unknown"
|
|
1594
1614
|
);
|
|
1595
1615
|
console.log("[SDK Debug] Event data:", event.data);
|
|
1596
|
-
console.log("[SDK Debug] Extension info loaded:", !!
|
|
1616
|
+
console.log("[SDK Debug] Extension info loaded:", !!extensionInfo());
|
|
1597
1617
|
console.log(
|
|
1598
1618
|
"[SDK Debug] Pending requests count:",
|
|
1599
|
-
|
|
1619
|
+
pendingRequests.size
|
|
1600
1620
|
);
|
|
1601
1621
|
}
|
|
1602
1622
|
if (event.source !== window.parent) {
|
|
1603
|
-
if (
|
|
1623
|
+
if (config.debug) {
|
|
1604
1624
|
console.error("[SDK Debug] \u274C REJECTED: Message not from parent window!");
|
|
1605
1625
|
}
|
|
1606
1626
|
return;
|
|
1607
1627
|
}
|
|
1608
1628
|
const data = event.data;
|
|
1609
|
-
if ("id" in data &&
|
|
1610
|
-
if (
|
|
1629
|
+
if ("id" in data && pendingRequests.has(data.id)) {
|
|
1630
|
+
if (config.debug) {
|
|
1611
1631
|
console.log("[SDK Debug] \u2705 Found pending request for ID:", data.id);
|
|
1612
1632
|
}
|
|
1613
|
-
const pending =
|
|
1633
|
+
const pending = pendingRequests.get(data.id);
|
|
1614
1634
|
clearTimeout(pending.timeout);
|
|
1615
|
-
|
|
1635
|
+
pendingRequests.delete(data.id);
|
|
1616
1636
|
if (data.error) {
|
|
1617
|
-
if (
|
|
1637
|
+
if (config.debug) {
|
|
1618
1638
|
console.error("[SDK Debug] \u274C Request failed:", data.error);
|
|
1619
1639
|
}
|
|
1620
1640
|
pending.reject(data.error);
|
|
1621
1641
|
} else {
|
|
1622
|
-
if (
|
|
1642
|
+
if (config.debug) {
|
|
1623
1643
|
console.log("[SDK Debug] \u2705 Request succeeded:", data.result);
|
|
1624
1644
|
}
|
|
1625
1645
|
pending.resolve(data.result);
|
|
1626
1646
|
}
|
|
1627
1647
|
return;
|
|
1628
1648
|
}
|
|
1629
|
-
if ("id" in data && !
|
|
1630
|
-
if (
|
|
1649
|
+
if ("id" in data && !pendingRequests.has(data.id)) {
|
|
1650
|
+
if (config.debug) {
|
|
1631
1651
|
console.warn(
|
|
1632
1652
|
"[SDK Debug] \u26A0\uFE0F Received response for unknown request ID:",
|
|
1633
1653
|
data.id
|
|
1634
1654
|
);
|
|
1635
1655
|
console.warn(
|
|
1636
1656
|
"[SDK Debug] Known IDs:",
|
|
1637
|
-
Array.from(
|
|
1657
|
+
Array.from(pendingRequests.keys())
|
|
1638
1658
|
);
|
|
1639
1659
|
}
|
|
1640
1660
|
}
|
|
1641
1661
|
if ("type" in data && data.type) {
|
|
1642
|
-
if (
|
|
1662
|
+
if (config.debug) {
|
|
1643
1663
|
console.log("[SDK Debug] Event received:", data.type);
|
|
1644
1664
|
}
|
|
1645
|
-
|
|
1665
|
+
onEvent(data);
|
|
1646
1666
|
}
|
|
1647
|
-
if (
|
|
1667
|
+
if (config.debug) {
|
|
1648
1668
|
console.log("[SDK Debug] ========== End Message ==========");
|
|
1649
1669
|
}
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest) {
|
|
1673
|
+
if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
|
|
1674
|
+
const contextEvent = event;
|
|
1675
|
+
onContextChanged(contextEvent.data.context);
|
|
1676
|
+
log("Context updated:", contextEvent.data.context);
|
|
1677
|
+
}
|
|
1678
|
+
if (event.type === HAEXTENSION_EVENTS.EXTERNAL_REQUEST) {
|
|
1679
|
+
const externalEvent = event;
|
|
1680
|
+
onExternalRequest(externalEvent);
|
|
1681
|
+
return;
|
|
1650
1682
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1683
|
+
emitEvent(event, log, eventListeners);
|
|
1684
|
+
}
|
|
1685
|
+
function emitEvent(event, log, eventListeners) {
|
|
1686
|
+
log("Event received:", event);
|
|
1687
|
+
const listeners = eventListeners.get(event.type);
|
|
1688
|
+
if (listeners) {
|
|
1689
|
+
listeners.forEach((callback) => callback(event));
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
function addEventListener(eventType, callback, eventListeners) {
|
|
1693
|
+
if (!eventListeners.has(eventType)) {
|
|
1694
|
+
eventListeners.set(eventType, /* @__PURE__ */ new Set());
|
|
1695
|
+
}
|
|
1696
|
+
eventListeners.get(eventType).add(callback);
|
|
1697
|
+
}
|
|
1698
|
+
function removeEventListener(eventType, callback, eventListeners) {
|
|
1699
|
+
const listeners = eventListeners.get(eventType);
|
|
1700
|
+
if (listeners) {
|
|
1701
|
+
listeners.delete(callback);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
function notifySubscribers(subscribers) {
|
|
1705
|
+
subscribers.forEach((callback) => callback());
|
|
1706
|
+
}
|
|
1707
|
+
function createDrizzleInstance(schema, extensionInfo, request, log) {
|
|
1708
|
+
if (!extensionInfo) {
|
|
1709
|
+
throw new HaexVaultSdkError(
|
|
1710
|
+
"EXTENSION_INFO_UNAVAILABLE" /* EXTENSION_INFO_UNAVAILABLE */,
|
|
1711
|
+
"errors.client_not_ready"
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
return drizzle(
|
|
1715
|
+
async (sql, params, method) => {
|
|
1716
|
+
try {
|
|
1717
|
+
if (method === "run" || method === "all") {
|
|
1718
|
+
const result2 = await request(
|
|
1719
|
+
HAEXTENSION_METHODS.database.execute,
|
|
1720
|
+
{
|
|
1721
|
+
query: sql,
|
|
1722
|
+
params
|
|
1723
|
+
}
|
|
1724
|
+
);
|
|
1725
|
+
if (method === "all") {
|
|
1726
|
+
return { rows: result2.rows || [] };
|
|
1727
|
+
}
|
|
1728
|
+
if (result2.rows && Array.isArray(result2.rows) && result2.rows.length > 0) {
|
|
1729
|
+
return { rows: result2.rows };
|
|
1730
|
+
}
|
|
1731
|
+
return result2;
|
|
1732
|
+
}
|
|
1733
|
+
const result = await request(HAEXTENSION_METHODS.database.query, {
|
|
1734
|
+
query: sql,
|
|
1735
|
+
params
|
|
1736
|
+
});
|
|
1737
|
+
const rows = result.rows;
|
|
1738
|
+
if (method === "get") {
|
|
1739
|
+
return { rows: rows.length > 0 ? rows.at(0) : void 0 };
|
|
1740
|
+
}
|
|
1741
|
+
return { rows };
|
|
1742
|
+
} catch (error) {
|
|
1743
|
+
log("Database operation failed:", error);
|
|
1744
|
+
throw error;
|
|
1745
|
+
}
|
|
1746
|
+
},
|
|
1747
|
+
{
|
|
1748
|
+
schema,
|
|
1749
|
+
logger: false
|
|
1657
1750
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1751
|
+
);
|
|
1752
|
+
}
|
|
1753
|
+
async function queryRaw(sql, params, request, debug) {
|
|
1754
|
+
const result = await request(
|
|
1755
|
+
HAEXTENSION_METHODS.database.query,
|
|
1756
|
+
{ query: sql, params }
|
|
1757
|
+
);
|
|
1758
|
+
if (debug) {
|
|
1759
|
+
console.log("[SDK query()] Raw result:", JSON.stringify(result, null, 2));
|
|
1760
|
+
}
|
|
1761
|
+
return result.rows;
|
|
1762
|
+
}
|
|
1763
|
+
async function executeRaw(sql, params, request) {
|
|
1764
|
+
const result = await request(
|
|
1765
|
+
HAEXTENSION_METHODS.database.execute,
|
|
1766
|
+
{ query: sql, params }
|
|
1767
|
+
);
|
|
1768
|
+
return {
|
|
1769
|
+
rowsAffected: result.rowsAffected,
|
|
1770
|
+
lastInsertId: result.lastInsertId
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// src/client/external.ts
|
|
1775
|
+
function registerExternalHandler(action, handler, handlers, log) {
|
|
1776
|
+
handlers.set(action, handler);
|
|
1777
|
+
log(`[ExternalRequest] Registered handler for action: ${action}`);
|
|
1778
|
+
return () => {
|
|
1779
|
+
handlers.delete(action);
|
|
1780
|
+
log(`[ExternalRequest] Unregistered handler for action: ${action}`);
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1783
|
+
async function handleExternalRequest(request, handlers, respond, log) {
|
|
1784
|
+
log(`[ExternalRequest] Received request: ${request.action} from ${request.publicKey.substring(0, 20)}...`);
|
|
1785
|
+
const handler = handlers.get(request.action);
|
|
1786
|
+
if (!handler) {
|
|
1787
|
+
log(`[ExternalRequest] No handler for action: ${request.action}`);
|
|
1788
|
+
await respond({
|
|
1789
|
+
requestId: request.requestId,
|
|
1790
|
+
success: false,
|
|
1791
|
+
error: `No handler registered for action: ${request.action}`
|
|
1792
|
+
});
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
try {
|
|
1796
|
+
const response = await handler(request);
|
|
1797
|
+
await respond(response);
|
|
1798
|
+
log(`[ExternalRequest] Response sent for: ${request.action}`);
|
|
1799
|
+
} catch (error) {
|
|
1800
|
+
log(`[ExternalRequest] Handler error:`, error);
|
|
1801
|
+
await respond({
|
|
1802
|
+
requestId: request.requestId,
|
|
1803
|
+
success: false,
|
|
1804
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
async function respondToExternalRequest(response, request) {
|
|
1809
|
+
await request("external.respond", response);
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// src/client.ts
|
|
1813
|
+
var HaexVaultClient = class {
|
|
1814
|
+
constructor(config = {}) {
|
|
1815
|
+
// State
|
|
1816
|
+
this.initialized = false;
|
|
1817
|
+
this.isNativeWindow = false;
|
|
1818
|
+
this.requestCounter = 0;
|
|
1819
|
+
this._extensionInfo = null;
|
|
1820
|
+
this._context = null;
|
|
1821
|
+
this._setupCompleted = false;
|
|
1822
|
+
// Collections
|
|
1823
|
+
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
1824
|
+
this.eventListeners = /* @__PURE__ */ new Map();
|
|
1825
|
+
this.externalRequestHandlers = /* @__PURE__ */ new Map();
|
|
1826
|
+
this.reactiveSubscribers = /* @__PURE__ */ new Set();
|
|
1827
|
+
// Handlers
|
|
1828
|
+
this.messageHandler = null;
|
|
1829
|
+
this.setupPromise = null;
|
|
1830
|
+
this.setupHook = null;
|
|
1831
|
+
// Public APIs
|
|
1832
|
+
this.orm = null;
|
|
1833
|
+
this.config = {
|
|
1834
|
+
debug: config.debug ?? false,
|
|
1835
|
+
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
1836
|
+
manifest: config.manifest
|
|
1837
|
+
};
|
|
1838
|
+
this.storage = new StorageAPI(this);
|
|
1839
|
+
this.database = new DatabaseAPI(this);
|
|
1840
|
+
this.filesystem = new FilesystemAPI(this);
|
|
1841
|
+
this.web = new WebAPI(this);
|
|
1842
|
+
this.permissions = new PermissionsAPI(this);
|
|
1843
|
+
installConsoleForwarding(this.config.debug);
|
|
1844
|
+
this.readyPromise = new Promise((resolve) => {
|
|
1845
|
+
this.resolveReady = resolve;
|
|
1846
|
+
});
|
|
1847
|
+
this.init();
|
|
1848
|
+
}
|
|
1849
|
+
// ==========================================================================
|
|
1850
|
+
// Lifecycle
|
|
1851
|
+
// ==========================================================================
|
|
1852
|
+
async ready() {
|
|
1853
|
+
return this.readyPromise;
|
|
1854
|
+
}
|
|
1855
|
+
get setupCompleted() {
|
|
1856
|
+
return this._setupCompleted;
|
|
1857
|
+
}
|
|
1858
|
+
onSetup(setupFn) {
|
|
1859
|
+
if (this.setupHook) {
|
|
1860
|
+
throw new Error("Setup hook already registered");
|
|
1662
1861
|
}
|
|
1663
|
-
this.
|
|
1664
|
-
}
|
|
1665
|
-
async
|
|
1666
|
-
this.
|
|
1667
|
-
|
|
1668
|
-
if (!handler) {
|
|
1669
|
-
this.log(`[ExternalRequest] No handler for action: ${request.action}`);
|
|
1670
|
-
await this.respondToExternalRequest({
|
|
1671
|
-
requestId: request.requestId,
|
|
1672
|
-
success: false,
|
|
1673
|
-
error: `No handler registered for action: ${request.action}`
|
|
1674
|
-
});
|
|
1862
|
+
this.setupHook = setupFn;
|
|
1863
|
+
}
|
|
1864
|
+
async setupComplete() {
|
|
1865
|
+
await this.readyPromise;
|
|
1866
|
+
if (!this.setupHook || this.setupCompleted) {
|
|
1675
1867
|
return;
|
|
1676
1868
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
await this.respondToExternalRequest(response);
|
|
1680
|
-
this.log(`[ExternalRequest] Response sent for: ${request.action}`);
|
|
1681
|
-
} catch (error) {
|
|
1682
|
-
this.log(`[ExternalRequest] Handler error:`, error);
|
|
1683
|
-
await this.respondToExternalRequest({
|
|
1684
|
-
requestId: request.requestId,
|
|
1685
|
-
success: false,
|
|
1686
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1687
|
-
});
|
|
1869
|
+
if (!this.setupPromise) {
|
|
1870
|
+
this.setupPromise = this.runSetupAsync();
|
|
1688
1871
|
}
|
|
1872
|
+
return this.setupPromise;
|
|
1689
1873
|
}
|
|
1690
|
-
|
|
1691
|
-
this.
|
|
1692
|
-
|
|
1693
|
-
if (listeners) {
|
|
1694
|
-
listeners.forEach((callback) => callback(event));
|
|
1874
|
+
destroy() {
|
|
1875
|
+
if (this.messageHandler) {
|
|
1876
|
+
window.removeEventListener("message", this.messageHandler);
|
|
1695
1877
|
}
|
|
1878
|
+
this.pendingRequests.forEach(({ timeout }) => clearTimeout(timeout));
|
|
1879
|
+
this.pendingRequests.clear();
|
|
1880
|
+
this.eventListeners.clear();
|
|
1881
|
+
this.initialized = false;
|
|
1882
|
+
this.log("HaexVault SDK destroyed");
|
|
1696
1883
|
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1884
|
+
// ==========================================================================
|
|
1885
|
+
// Properties
|
|
1886
|
+
// ==========================================================================
|
|
1887
|
+
get extensionInfo() {
|
|
1888
|
+
return this._extensionInfo;
|
|
1699
1889
|
}
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
throw new HaexHubError(
|
|
1703
|
-
"INVALID_PUBLIC_KEY" /* INVALID_PUBLIC_KEY */,
|
|
1704
|
-
"errors.invalid_public_key",
|
|
1705
|
-
{ publicKey }
|
|
1706
|
-
);
|
|
1707
|
-
}
|
|
1890
|
+
get context() {
|
|
1891
|
+
return this._context;
|
|
1708
1892
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
);
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1893
|
+
// ==========================================================================
|
|
1894
|
+
// Subscriptions
|
|
1895
|
+
// ==========================================================================
|
|
1896
|
+
subscribe(callback) {
|
|
1897
|
+
this.reactiveSubscribers.add(callback);
|
|
1898
|
+
return () => {
|
|
1899
|
+
this.reactiveSubscribers.delete(callback);
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
// ==========================================================================
|
|
1903
|
+
// Table Name Utilities
|
|
1904
|
+
// ==========================================================================
|
|
1905
|
+
getTableName(tableName) {
|
|
1906
|
+
return getExtensionTableName(this._extensionInfo, tableName);
|
|
1907
|
+
}
|
|
1908
|
+
getDependencyTableName(publicKey, extensionName, tableName) {
|
|
1909
|
+
return getDependencyTableName(publicKey, extensionName, tableName);
|
|
1910
|
+
}
|
|
1911
|
+
parseTableName(fullTableName) {
|
|
1912
|
+
return parseTableName(fullTableName);
|
|
1913
|
+
}
|
|
1914
|
+
// ==========================================================================
|
|
1915
|
+
// Database
|
|
1916
|
+
// ==========================================================================
|
|
1917
|
+
initializeDatabase(schema) {
|
|
1918
|
+
const db = createDrizzleInstance(schema, this._extensionInfo, this.request.bind(this), this.log.bind(this));
|
|
1919
|
+
this.orm = db;
|
|
1920
|
+
return db;
|
|
1921
|
+
}
|
|
1922
|
+
async query(sql, params = []) {
|
|
1923
|
+
return queryRaw(sql, params, this.request.bind(this), this.config.debug);
|
|
1924
|
+
}
|
|
1925
|
+
async select(sql, params = []) {
|
|
1926
|
+
return this.query(sql, params);
|
|
1927
|
+
}
|
|
1928
|
+
async execute(sql, params = []) {
|
|
1929
|
+
return executeRaw(sql, params, this.request.bind(this));
|
|
1930
|
+
}
|
|
1931
|
+
async registerMigrationsAsync(extensionVersion, migrations) {
|
|
1932
|
+
return this.database.registerMigrationsAsync(extensionVersion, migrations);
|
|
1933
|
+
}
|
|
1934
|
+
// ==========================================================================
|
|
1935
|
+
// Dependencies
|
|
1936
|
+
// ==========================================================================
|
|
1937
|
+
async getDependencies() {
|
|
1938
|
+
return this.request("extensions.getDependencies");
|
|
1939
|
+
}
|
|
1940
|
+
// ==========================================================================
|
|
1941
|
+
// Permissions
|
|
1942
|
+
// ==========================================================================
|
|
1943
|
+
async requestDatabasePermission(request) {
|
|
1944
|
+
return this.request("permissions.database.request", {
|
|
1945
|
+
resource: request.resource,
|
|
1946
|
+
operation: request.operation,
|
|
1947
|
+
reason: request.reason
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
async checkDatabasePermission(resource, operation) {
|
|
1951
|
+
const response = await this.request("permissions.database.check", { resource, operation });
|
|
1952
|
+
return response.status === "granted";
|
|
1953
|
+
}
|
|
1954
|
+
// ==========================================================================
|
|
1955
|
+
// Search
|
|
1956
|
+
// ==========================================================================
|
|
1957
|
+
async respondToSearch(requestId, results) {
|
|
1958
|
+
await this.request("search.respond", { requestId, results });
|
|
1959
|
+
}
|
|
1960
|
+
// ==========================================================================
|
|
1961
|
+
// External Requests
|
|
1962
|
+
// ==========================================================================
|
|
1963
|
+
onExternalRequest(action, handler) {
|
|
1964
|
+
return registerExternalHandler(action, handler, this.externalRequestHandlers, this.log.bind(this));
|
|
1965
|
+
}
|
|
1966
|
+
async respondToExternalRequest(response) {
|
|
1967
|
+
await respondToExternalRequest(response, this.request.bind(this));
|
|
1968
|
+
}
|
|
1969
|
+
// ==========================================================================
|
|
1970
|
+
// Events
|
|
1971
|
+
// ==========================================================================
|
|
1972
|
+
on(eventType, callback) {
|
|
1973
|
+
addEventListener(eventType, callback, this.eventListeners);
|
|
1974
|
+
}
|
|
1975
|
+
off(eventType, callback) {
|
|
1976
|
+
removeEventListener(eventType, callback, this.eventListeners);
|
|
1977
|
+
}
|
|
1978
|
+
// ==========================================================================
|
|
1979
|
+
// Communication
|
|
1980
|
+
// ==========================================================================
|
|
1981
|
+
async request(method, params) {
|
|
1982
|
+
const resolvedParams = params ?? {};
|
|
1983
|
+
if (this.isNativeWindow && hasTauri()) {
|
|
1984
|
+
return sendInvoke(method, resolvedParams, this.config, this.log.bind(this));
|
|
1723
1985
|
}
|
|
1986
|
+
const requestId = generateRequestId(++this.requestCounter);
|
|
1987
|
+
return sendPostMessage(method, resolvedParams, requestId, this.config, this._extensionInfo, this.pendingRequests);
|
|
1724
1988
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1989
|
+
// ==========================================================================
|
|
1990
|
+
// Private: Initialization
|
|
1991
|
+
// ==========================================================================
|
|
1992
|
+
async init() {
|
|
1993
|
+
if (this.initialized) return;
|
|
1994
|
+
if (!isInIframe() && hasTauri()) {
|
|
1995
|
+
try {
|
|
1996
|
+
await this.initNative();
|
|
1997
|
+
return;
|
|
1998
|
+
} catch (error) {
|
|
1999
|
+
this.log("Tauri commands failed, falling back to iframe mode", error);
|
|
2000
|
+
}
|
|
1731
2001
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
2002
|
+
await this.initIframe();
|
|
2003
|
+
}
|
|
2004
|
+
async initNative() {
|
|
2005
|
+
const { extensionInfo, context } = await initNativeMode(
|
|
2006
|
+
{
|
|
2007
|
+
config: this.config,
|
|
2008
|
+
state: {
|
|
2009
|
+
initialized: this.initialized,
|
|
2010
|
+
isNativeWindow: this.isNativeWindow,
|
|
2011
|
+
requestCounter: this.requestCounter,
|
|
2012
|
+
setupCompleted: this._setupCompleted,
|
|
2013
|
+
extensionInfo: this._extensionInfo,
|
|
2014
|
+
context: this._context,
|
|
2015
|
+
orm: this.orm
|
|
2016
|
+
},
|
|
2017
|
+
collections: {
|
|
2018
|
+
pendingRequests: this.pendingRequests,
|
|
2019
|
+
eventListeners: this.eventListeners,
|
|
2020
|
+
externalRequestHandlers: this.externalRequestHandlers,
|
|
2021
|
+
reactiveSubscribers: this.reactiveSubscribers
|
|
2022
|
+
},
|
|
2023
|
+
promises: {
|
|
2024
|
+
readyPromise: this.readyPromise,
|
|
2025
|
+
resolveReady: this.resolveReady,
|
|
2026
|
+
setupPromise: this.setupPromise,
|
|
2027
|
+
setupHook: this.setupHook
|
|
2028
|
+
},
|
|
2029
|
+
handlers: {
|
|
2030
|
+
messageHandler: this.messageHandler
|
|
2031
|
+
}
|
|
2032
|
+
},
|
|
2033
|
+
this.log.bind(this),
|
|
2034
|
+
this.handleEvent.bind(this),
|
|
2035
|
+
(ctx) => {
|
|
2036
|
+
this._context = ctx;
|
|
2037
|
+
this.notifySubscribersInternal();
|
|
2038
|
+
}
|
|
2039
|
+
);
|
|
2040
|
+
this._extensionInfo = extensionInfo;
|
|
2041
|
+
this._context = context;
|
|
2042
|
+
this.isNativeWindow = true;
|
|
2043
|
+
this.initialized = true;
|
|
2044
|
+
this.notifySubscribersInternal();
|
|
2045
|
+
this.resolveReady();
|
|
2046
|
+
}
|
|
2047
|
+
async initIframe() {
|
|
2048
|
+
this.messageHandler = createMessageHandler(
|
|
2049
|
+
this.config,
|
|
2050
|
+
this.pendingRequests,
|
|
2051
|
+
() => this._extensionInfo,
|
|
2052
|
+
this.handleEvent.bind(this)
|
|
2053
|
+
);
|
|
2054
|
+
const { context } = await initIframeMode(
|
|
2055
|
+
{
|
|
2056
|
+
config: this.config,
|
|
2057
|
+
state: {
|
|
2058
|
+
initialized: this.initialized,
|
|
2059
|
+
isNativeWindow: this.isNativeWindow,
|
|
2060
|
+
requestCounter: this.requestCounter,
|
|
2061
|
+
setupCompleted: this._setupCompleted,
|
|
2062
|
+
extensionInfo: this._extensionInfo,
|
|
2063
|
+
context: this._context,
|
|
2064
|
+
orm: this.orm
|
|
2065
|
+
},
|
|
2066
|
+
collections: {
|
|
2067
|
+
pendingRequests: this.pendingRequests,
|
|
2068
|
+
eventListeners: this.eventListeners,
|
|
2069
|
+
externalRequestHandlers: this.externalRequestHandlers,
|
|
2070
|
+
reactiveSubscribers: this.reactiveSubscribers
|
|
2071
|
+
},
|
|
2072
|
+
promises: {
|
|
2073
|
+
readyPromise: this.readyPromise,
|
|
2074
|
+
resolveReady: this.resolveReady,
|
|
2075
|
+
setupPromise: this.setupPromise,
|
|
2076
|
+
setupHook: this.setupHook
|
|
2077
|
+
},
|
|
2078
|
+
handlers: {
|
|
2079
|
+
messageHandler: this.messageHandler
|
|
2080
|
+
}
|
|
2081
|
+
},
|
|
2082
|
+
this.log.bind(this),
|
|
2083
|
+
this.messageHandler,
|
|
2084
|
+
this.request.bind(this)
|
|
2085
|
+
);
|
|
2086
|
+
if (this.config.manifest) {
|
|
2087
|
+
this._extensionInfo = {
|
|
2088
|
+
publicKey: this.config.manifest.publicKey,
|
|
2089
|
+
name: this.config.manifest.name,
|
|
2090
|
+
version: this.config.manifest.version,
|
|
2091
|
+
displayName: this.config.manifest.name
|
|
2092
|
+
};
|
|
2093
|
+
this.notifySubscribersInternal();
|
|
1738
2094
|
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
2095
|
+
this._context = context;
|
|
2096
|
+
this.isNativeWindow = false;
|
|
2097
|
+
this.initialized = true;
|
|
2098
|
+
this.notifySubscribersInternal();
|
|
2099
|
+
this.resolveReady();
|
|
2100
|
+
}
|
|
2101
|
+
// ==========================================================================
|
|
2102
|
+
// Private: Event Handling
|
|
2103
|
+
// ==========================================================================
|
|
2104
|
+
handleEvent(event) {
|
|
2105
|
+
processEvent(
|
|
2106
|
+
event,
|
|
2107
|
+
this.log.bind(this),
|
|
2108
|
+
this.eventListeners,
|
|
2109
|
+
(ctx) => {
|
|
2110
|
+
this._context = ctx;
|
|
2111
|
+
this.notifySubscribersInternal();
|
|
2112
|
+
},
|
|
2113
|
+
(extEvent) => this.handleExternalRequestInternal(extEvent.data)
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
async handleExternalRequestInternal(request) {
|
|
2117
|
+
await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
|
|
2118
|
+
}
|
|
2119
|
+
// ==========================================================================
|
|
2120
|
+
// Private: Setup
|
|
2121
|
+
// ==========================================================================
|
|
2122
|
+
async runSetupAsync() {
|
|
2123
|
+
if (!this.setupHook) return;
|
|
2124
|
+
try {
|
|
2125
|
+
this.log("[HaexVault] Running setup hook...");
|
|
2126
|
+
await this.setupHook();
|
|
2127
|
+
this._setupCompleted = true;
|
|
2128
|
+
this.log("[HaexVault] Setup completed successfully");
|
|
2129
|
+
this.notifySubscribersInternal();
|
|
2130
|
+
} catch (error) {
|
|
2131
|
+
this.log("[HaexVault] Setup failed:", error);
|
|
2132
|
+
throw error;
|
|
1745
2133
|
}
|
|
1746
2134
|
}
|
|
2135
|
+
// ==========================================================================
|
|
2136
|
+
// Private: Utilities
|
|
2137
|
+
// ==========================================================================
|
|
2138
|
+
notifySubscribersInternal() {
|
|
2139
|
+
notifySubscribers(this.reactiveSubscribers);
|
|
2140
|
+
}
|
|
1747
2141
|
log(...args) {
|
|
1748
2142
|
if (this.config.debug) {
|
|
1749
|
-
console.log("[
|
|
2143
|
+
console.log("[HaexVault SDK]", ...args);
|
|
1750
2144
|
}
|
|
1751
2145
|
}
|
|
1752
2146
|
};
|
|
@@ -2070,6 +2464,6 @@ function createHaexVaultClient(config = {}) {
|
|
|
2070
2464
|
return new HaexVaultClient(config);
|
|
2071
2465
|
}
|
|
2072
2466
|
|
|
2073
|
-
export { DEFAULT_TIMEOUT, DatabaseAPI, ErrorCode, FileSyncAPI, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HAEXTENSION_METHODS,
|
|
2467
|
+
export { DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, FileSyncAPI, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HAEXTENSION_METHODS, HaexVaultClient, HaexVaultSdkError, PermissionStatus, PermissionsAPI, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base64ToArrayBuffer, createHaexVaultClient, decryptCrdtData, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptString, encryptVaultKey, generateVaultKey, getTableName, hexToBytes, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, wrapKey };
|
|
2074
2468
|
//# sourceMappingURL=index.mjs.map
|
|
2075
2469
|
//# sourceMappingURL=index.mjs.map
|