@inter-digital/wasm-client-sdk 3.8.3-patch.14 → 3.8.3-patch.14-beta.2
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/lib/index.es.js +31 -1
- package/lib/index.js +31 -1
- package/lib/index.umd.js +31 -1
- package/lib/sdk/index.d.ts +1 -0
- package/package.json +1 -1
package/lib/index.es.js
CHANGED
|
@@ -943,6 +943,18 @@ let initialized = false;
|
|
|
943
943
|
let go;
|
|
944
944
|
let goExitPromise;
|
|
945
945
|
const CACHE_KEY = 'openim-wasm-cache';
|
|
946
|
+
if (typeof window !== 'undefined') {
|
|
947
|
+
const cleanup = () => {
|
|
948
|
+
reset();
|
|
949
|
+
};
|
|
950
|
+
window.addEventListener('beforeunload', cleanup);
|
|
951
|
+
window.addEventListener('unload', cleanup);
|
|
952
|
+
if ('__TAURI__' in window) {
|
|
953
|
+
window.addEventListener('tauri://close-requested', cleanup);
|
|
954
|
+
window.addEventListener('tauri://destroyed', cleanup);
|
|
955
|
+
window.addEventListener('tauri://window-close-requested', cleanup);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
946
958
|
async function initializeWasm(url) {
|
|
947
959
|
if (initialized) {
|
|
948
960
|
return null;
|
|
@@ -970,6 +982,12 @@ async function initializeWasm(url) {
|
|
|
970
982
|
initialized = true;
|
|
971
983
|
return go;
|
|
972
984
|
}
|
|
985
|
+
function reset() {
|
|
986
|
+
initialized = false;
|
|
987
|
+
if (go) {
|
|
988
|
+
go = undefined;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
973
991
|
function getGO() {
|
|
974
992
|
return go;
|
|
975
993
|
}
|
|
@@ -1171,12 +1189,18 @@ class SDK extends Emitter {
|
|
|
1171
1189
|
this.goExisted = false;
|
|
1172
1190
|
this.tryParse = true;
|
|
1173
1191
|
this.isLogStandardOutput = true;
|
|
1192
|
+
this.isInitialized = false;
|
|
1174
1193
|
this.init = async (params, operationID = v4()) => {
|
|
1175
1194
|
var _a, _b;
|
|
1176
1195
|
this._logWrap(`SDK => (invoked by js) run init with args ${JSON.stringify({
|
|
1177
1196
|
params,
|
|
1178
1197
|
operationID,
|
|
1179
1198
|
})}`);
|
|
1199
|
+
// Prevent multiple initialization calls
|
|
1200
|
+
if (this.isInitialized) {
|
|
1201
|
+
this._logWrap('SDK => init already called, skipping duplicate initialization');
|
|
1202
|
+
return Promise.resolve();
|
|
1203
|
+
}
|
|
1180
1204
|
await workerPromise;
|
|
1181
1205
|
await this.wasmInitializedPromise;
|
|
1182
1206
|
window.commonEventFunc(event => {
|
|
@@ -1208,7 +1232,9 @@ class SDK extends Emitter {
|
|
|
1208
1232
|
isExternalExtensions: params.isExternalExtensions || false,
|
|
1209
1233
|
};
|
|
1210
1234
|
this.tryParse = (_b = params.tryParse) !== null && _b !== void 0 ? _b : true;
|
|
1211
|
-
|
|
1235
|
+
const result = window.initSDK(operationID, JSON.stringify(config));
|
|
1236
|
+
this.isInitialized = true;
|
|
1237
|
+
return result;
|
|
1212
1238
|
};
|
|
1213
1239
|
this.login = async (params, operationID = v4()) => {
|
|
1214
1240
|
this._logWrap(`SDK => (invoked by js) run login with args ${JSON.stringify({
|
|
@@ -2076,8 +2102,11 @@ class SDK extends Emitter {
|
|
|
2076
2102
|
]);
|
|
2077
2103
|
};
|
|
2078
2104
|
this.fileMapSet = (uuid, file) => window.fileMapSet(uuid, file);
|
|
2105
|
+
// Reset any previous state before initializing
|
|
2106
|
+
reset();
|
|
2079
2107
|
initDatabaseAPI(debug);
|
|
2080
2108
|
this.isLogStandardOutput = debug;
|
|
2109
|
+
this.isInitialized = false; // Reset initialization flag
|
|
2081
2110
|
this.wasmInitializedPromise = initializeWasm(url);
|
|
2082
2111
|
this.goExitPromise = getGoExitPromise();
|
|
2083
2112
|
if (this.goExitPromise) {
|
|
@@ -2090,6 +2119,7 @@ class SDK extends Emitter {
|
|
|
2090
2119
|
})
|
|
2091
2120
|
.finally(() => {
|
|
2092
2121
|
this.goExisted = true;
|
|
2122
|
+
this.isInitialized = false; // Reset when WASM exits
|
|
2093
2123
|
});
|
|
2094
2124
|
}
|
|
2095
2125
|
}
|
package/lib/index.js
CHANGED
|
@@ -947,6 +947,18 @@ let initialized = false;
|
|
|
947
947
|
let go;
|
|
948
948
|
let goExitPromise;
|
|
949
949
|
const CACHE_KEY = 'openim-wasm-cache';
|
|
950
|
+
if (typeof window !== 'undefined') {
|
|
951
|
+
const cleanup = () => {
|
|
952
|
+
reset();
|
|
953
|
+
};
|
|
954
|
+
window.addEventListener('beforeunload', cleanup);
|
|
955
|
+
window.addEventListener('unload', cleanup);
|
|
956
|
+
if ('__TAURI__' in window) {
|
|
957
|
+
window.addEventListener('tauri://close-requested', cleanup);
|
|
958
|
+
window.addEventListener('tauri://destroyed', cleanup);
|
|
959
|
+
window.addEventListener('tauri://window-close-requested', cleanup);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
950
962
|
async function initializeWasm(url) {
|
|
951
963
|
if (initialized) {
|
|
952
964
|
return null;
|
|
@@ -974,6 +986,12 @@ async function initializeWasm(url) {
|
|
|
974
986
|
initialized = true;
|
|
975
987
|
return go;
|
|
976
988
|
}
|
|
989
|
+
function reset() {
|
|
990
|
+
initialized = false;
|
|
991
|
+
if (go) {
|
|
992
|
+
go = undefined;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
977
995
|
function getGO() {
|
|
978
996
|
return go;
|
|
979
997
|
}
|
|
@@ -1175,12 +1193,18 @@ class SDK extends Emitter {
|
|
|
1175
1193
|
this.goExisted = false;
|
|
1176
1194
|
this.tryParse = true;
|
|
1177
1195
|
this.isLogStandardOutput = true;
|
|
1196
|
+
this.isInitialized = false;
|
|
1178
1197
|
this.init = async (params, operationID = v4()) => {
|
|
1179
1198
|
var _a, _b;
|
|
1180
1199
|
this._logWrap(`SDK => (invoked by js) run init with args ${JSON.stringify({
|
|
1181
1200
|
params,
|
|
1182
1201
|
operationID,
|
|
1183
1202
|
})}`);
|
|
1203
|
+
// Prevent multiple initialization calls
|
|
1204
|
+
if (this.isInitialized) {
|
|
1205
|
+
this._logWrap('SDK => init already called, skipping duplicate initialization');
|
|
1206
|
+
return Promise.resolve();
|
|
1207
|
+
}
|
|
1184
1208
|
await workerPromise;
|
|
1185
1209
|
await this.wasmInitializedPromise;
|
|
1186
1210
|
window.commonEventFunc(event => {
|
|
@@ -1212,7 +1236,9 @@ class SDK extends Emitter {
|
|
|
1212
1236
|
isExternalExtensions: params.isExternalExtensions || false,
|
|
1213
1237
|
};
|
|
1214
1238
|
this.tryParse = (_b = params.tryParse) !== null && _b !== void 0 ? _b : true;
|
|
1215
|
-
|
|
1239
|
+
const result = window.initSDK(operationID, JSON.stringify(config));
|
|
1240
|
+
this.isInitialized = true;
|
|
1241
|
+
return result;
|
|
1216
1242
|
};
|
|
1217
1243
|
this.login = async (params, operationID = v4()) => {
|
|
1218
1244
|
this._logWrap(`SDK => (invoked by js) run login with args ${JSON.stringify({
|
|
@@ -2080,8 +2106,11 @@ class SDK extends Emitter {
|
|
|
2080
2106
|
]);
|
|
2081
2107
|
};
|
|
2082
2108
|
this.fileMapSet = (uuid, file) => window.fileMapSet(uuid, file);
|
|
2109
|
+
// Reset any previous state before initializing
|
|
2110
|
+
reset();
|
|
2083
2111
|
initDatabaseAPI(debug);
|
|
2084
2112
|
this.isLogStandardOutput = debug;
|
|
2113
|
+
this.isInitialized = false; // Reset initialization flag
|
|
2085
2114
|
this.wasmInitializedPromise = initializeWasm(url);
|
|
2086
2115
|
this.goExitPromise = getGoExitPromise();
|
|
2087
2116
|
if (this.goExitPromise) {
|
|
@@ -2094,6 +2123,7 @@ class SDK extends Emitter {
|
|
|
2094
2123
|
})
|
|
2095
2124
|
.finally(() => {
|
|
2096
2125
|
this.goExisted = true;
|
|
2126
|
+
this.isInitialized = false; // Reset when WASM exits
|
|
2097
2127
|
});
|
|
2098
2128
|
}
|
|
2099
2129
|
}
|
package/lib/index.umd.js
CHANGED
|
@@ -949,6 +949,18 @@
|
|
|
949
949
|
let go;
|
|
950
950
|
let goExitPromise;
|
|
951
951
|
const CACHE_KEY = 'openim-wasm-cache';
|
|
952
|
+
if (typeof window !== 'undefined') {
|
|
953
|
+
const cleanup = () => {
|
|
954
|
+
reset();
|
|
955
|
+
};
|
|
956
|
+
window.addEventListener('beforeunload', cleanup);
|
|
957
|
+
window.addEventListener('unload', cleanup);
|
|
958
|
+
if ('__TAURI__' in window) {
|
|
959
|
+
window.addEventListener('tauri://close-requested', cleanup);
|
|
960
|
+
window.addEventListener('tauri://destroyed', cleanup);
|
|
961
|
+
window.addEventListener('tauri://window-close-requested', cleanup);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
952
964
|
async function initializeWasm(url) {
|
|
953
965
|
if (initialized) {
|
|
954
966
|
return null;
|
|
@@ -976,6 +988,12 @@
|
|
|
976
988
|
initialized = true;
|
|
977
989
|
return go;
|
|
978
990
|
}
|
|
991
|
+
function reset() {
|
|
992
|
+
initialized = false;
|
|
993
|
+
if (go) {
|
|
994
|
+
go = undefined;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
979
997
|
function getGO() {
|
|
980
998
|
return go;
|
|
981
999
|
}
|
|
@@ -1177,12 +1195,18 @@
|
|
|
1177
1195
|
this.goExisted = false;
|
|
1178
1196
|
this.tryParse = true;
|
|
1179
1197
|
this.isLogStandardOutput = true;
|
|
1198
|
+
this.isInitialized = false;
|
|
1180
1199
|
this.init = async (params, operationID = v4()) => {
|
|
1181
1200
|
var _a, _b;
|
|
1182
1201
|
this._logWrap(`SDK => (invoked by js) run init with args ${JSON.stringify({
|
|
1183
1202
|
params,
|
|
1184
1203
|
operationID,
|
|
1185
1204
|
})}`);
|
|
1205
|
+
// Prevent multiple initialization calls
|
|
1206
|
+
if (this.isInitialized) {
|
|
1207
|
+
this._logWrap('SDK => init already called, skipping duplicate initialization');
|
|
1208
|
+
return Promise.resolve();
|
|
1209
|
+
}
|
|
1186
1210
|
await workerPromise;
|
|
1187
1211
|
await this.wasmInitializedPromise;
|
|
1188
1212
|
window.commonEventFunc(event => {
|
|
@@ -1214,7 +1238,9 @@
|
|
|
1214
1238
|
isExternalExtensions: params.isExternalExtensions || false,
|
|
1215
1239
|
};
|
|
1216
1240
|
this.tryParse = (_b = params.tryParse) !== null && _b !== void 0 ? _b : true;
|
|
1217
|
-
|
|
1241
|
+
const result = window.initSDK(operationID, JSON.stringify(config));
|
|
1242
|
+
this.isInitialized = true;
|
|
1243
|
+
return result;
|
|
1218
1244
|
};
|
|
1219
1245
|
this.login = async (params, operationID = v4()) => {
|
|
1220
1246
|
this._logWrap(`SDK => (invoked by js) run login with args ${JSON.stringify({
|
|
@@ -2082,8 +2108,11 @@
|
|
|
2082
2108
|
]);
|
|
2083
2109
|
};
|
|
2084
2110
|
this.fileMapSet = (uuid, file) => window.fileMapSet(uuid, file);
|
|
2111
|
+
// Reset any previous state before initializing
|
|
2112
|
+
reset();
|
|
2085
2113
|
initDatabaseAPI(debug);
|
|
2086
2114
|
this.isLogStandardOutput = debug;
|
|
2115
|
+
this.isInitialized = false; // Reset initialization flag
|
|
2087
2116
|
this.wasmInitializedPromise = initializeWasm(url);
|
|
2088
2117
|
this.goExitPromise = getGoExitPromise();
|
|
2089
2118
|
if (this.goExitPromise) {
|
|
@@ -2096,6 +2125,7 @@
|
|
|
2096
2125
|
})
|
|
2097
2126
|
.finally(() => {
|
|
2098
2127
|
this.goExisted = true;
|
|
2128
|
+
this.isInitialized = false; // Reset when WASM exits
|
|
2099
2129
|
});
|
|
2100
2130
|
}
|
|
2101
2131
|
}
|
package/lib/sdk/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare class SDK extends Emitter {
|
|
|
8
8
|
private goExisted;
|
|
9
9
|
private tryParse;
|
|
10
10
|
private isLogStandardOutput;
|
|
11
|
+
private isInitialized;
|
|
11
12
|
constructor(url?: string, debug?: boolean);
|
|
12
13
|
_logWrap(...args: any[]): void;
|
|
13
14
|
_invoker<T>(functionName: string, func: (...args: any[]) => Promise<any>, args: any[], processor?: (data: string) => string): Promise<WsResponse<T>>;
|