@onyx-p/imlib-web 2.2.8 → 2.3.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/index.esm.js +23 -43
- package/index.umd.js +23 -43
- package/package.json +1 -1
package/index.esm.js
CHANGED
@@ -20798,7 +20798,9 @@ class MessageLoader {
|
|
20798
20798
|
if (code !== ErrorCode.SUCCESS) {
|
20799
20799
|
logger.warn('pullMsg failed -> code:', code);
|
20800
20800
|
this.pullingMsg = false;
|
20801
|
-
|
20801
|
+
if (LibLoader.loader?.getConnectionStatus() == ConnectionStatus.CONNECTED) {
|
20802
|
+
this.try2RePullMsg();
|
20803
|
+
}
|
20802
20804
|
return;
|
20803
20805
|
}
|
20804
20806
|
const {
|
@@ -21187,7 +21189,7 @@ class MessageCache {
|
|
21187
21189
|
if (!content) return '';
|
21188
21190
|
try {
|
21189
21191
|
const contentStr = JSON.stringify(content);
|
21190
|
-
return
|
21192
|
+
return contentStr;
|
21191
21193
|
} catch (error) {
|
21192
21194
|
logger.error('加密消息内容失败', error);
|
21193
21195
|
return '';
|
@@ -21198,7 +21200,7 @@ class MessageCache {
|
|
21198
21200
|
return null;
|
21199
21201
|
}
|
21200
21202
|
try {
|
21201
|
-
const decryptedStr =
|
21203
|
+
const decryptedStr = encryptedHex;
|
21202
21204
|
return JSON.parse(decryptedStr);
|
21203
21205
|
} catch (error) {
|
21204
21206
|
logger.error('解密消息内容失败', error);
|
@@ -21552,28 +21554,7 @@ class MessageCache {
|
|
21552
21554
|
});
|
21553
21555
|
}
|
21554
21556
|
async upsertMessage(message) {
|
21555
|
-
|
21556
|
-
throw new Error('数据库未初始化');
|
21557
|
-
}
|
21558
|
-
return new Promise((resolve, reject) => {
|
21559
|
-
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
21560
|
-
const store = transaction.objectStore(this.STORE_NAME);
|
21561
|
-
const messageToStore = {
|
21562
|
-
...message
|
21563
|
-
};
|
21564
|
-
if (messageToStore.content) {
|
21565
|
-
const encryptedContent = this.encryptContent(messageToStore.content);
|
21566
|
-
messageToStore.content = encryptedContent;
|
21567
|
-
}
|
21568
|
-
const request = store.put(messageToStore);
|
21569
|
-
request.onsuccess = () => {
|
21570
|
-
resolve();
|
21571
|
-
};
|
21572
|
-
request.onerror = event => {
|
21573
|
-
logger.error('更新/插入消息失败', event);
|
21574
|
-
reject(new Error('更新/插入消息失败'));
|
21575
|
-
};
|
21576
|
-
});
|
21557
|
+
this.addMessages([message], message);
|
21577
21558
|
}
|
21578
21559
|
async getMessageById(messageId) {
|
21579
21560
|
if (!this.db) {
|
@@ -21809,24 +21790,22 @@ class LibLoader {
|
|
21809
21790
|
}
|
21810
21791
|
async connectionStatusListener(status) {
|
21811
21792
|
this.connectionStatus = status;
|
21812
|
-
|
21813
|
-
|
21814
|
-
|
21815
|
-
|
21816
|
-
|
21817
|
-
|
21818
|
-
|
21819
|
-
|
21820
|
-
|
21821
|
-
|
21822
|
-
|
21823
|
-
|
21824
|
-
|
21825
|
-
|
21826
|
-
|
21827
|
-
|
21828
|
-
}
|
21829
|
-
}, 0);
|
21793
|
+
switch (status) {
|
21794
|
+
case ConnectionStatus.BLOCKED:
|
21795
|
+
case ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:
|
21796
|
+
case ConnectionStatus.DISCONNECT_BY_SERVER:
|
21797
|
+
this.handleDisconnect();
|
21798
|
+
break;
|
21799
|
+
case ConnectionStatus.CONNECTING:
|
21800
|
+
this.handleConnecting();
|
21801
|
+
break;
|
21802
|
+
case ConnectionStatus.CONNECTED:
|
21803
|
+
this.handleConnected();
|
21804
|
+
break;
|
21805
|
+
case ConnectionStatus.DISCONNECTED:
|
21806
|
+
this.handleDisconnect();
|
21807
|
+
break;
|
21808
|
+
}
|
21830
21809
|
}
|
21831
21810
|
handleConnecting() {
|
21832
21811
|
this.watcher.onConnecting?.();
|
@@ -29037,6 +29016,7 @@ async function send(message, sentArgs) {
|
|
29037
29016
|
const secretKey = await DialogSecretKey$1.getDialogAesKey(dialogId.toString());
|
29038
29017
|
if (!secretKey) {
|
29039
29018
|
receivedMessage.sentStatus = SentStatus.FAILED;
|
29019
|
+
await saveSentMessage(receivedMessage, sentArgs);
|
29040
29020
|
return {
|
29041
29021
|
code: ErrorCode.MSG_ENCRYPT_ERROR,
|
29042
29022
|
data: receivedMessage
|
package/index.umd.js
CHANGED
@@ -20804,7 +20804,9 @@
|
|
20804
20804
|
if (code !== exports.ErrorCode.SUCCESS) {
|
20805
20805
|
logger.warn('pullMsg failed -> code:', code);
|
20806
20806
|
this.pullingMsg = false;
|
20807
|
-
|
20807
|
+
if (LibLoader.loader?.getConnectionStatus() == exports.ConnectionStatus.CONNECTED) {
|
20808
|
+
this.try2RePullMsg();
|
20809
|
+
}
|
20808
20810
|
return;
|
20809
20811
|
}
|
20810
20812
|
const {
|
@@ -21193,7 +21195,7 @@
|
|
21193
21195
|
if (!content) return '';
|
21194
21196
|
try {
|
21195
21197
|
const contentStr = JSON.stringify(content);
|
21196
|
-
return
|
21198
|
+
return contentStr;
|
21197
21199
|
} catch (error) {
|
21198
21200
|
logger.error('加密消息内容失败', error);
|
21199
21201
|
return '';
|
@@ -21204,7 +21206,7 @@
|
|
21204
21206
|
return null;
|
21205
21207
|
}
|
21206
21208
|
try {
|
21207
|
-
const decryptedStr =
|
21209
|
+
const decryptedStr = encryptedHex;
|
21208
21210
|
return JSON.parse(decryptedStr);
|
21209
21211
|
} catch (error) {
|
21210
21212
|
logger.error('解密消息内容失败', error);
|
@@ -21558,28 +21560,7 @@
|
|
21558
21560
|
});
|
21559
21561
|
}
|
21560
21562
|
async upsertMessage(message) {
|
21561
|
-
|
21562
|
-
throw new Error('数据库未初始化');
|
21563
|
-
}
|
21564
|
-
return new Promise((resolve, reject) => {
|
21565
|
-
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
21566
|
-
const store = transaction.objectStore(this.STORE_NAME);
|
21567
|
-
const messageToStore = {
|
21568
|
-
...message
|
21569
|
-
};
|
21570
|
-
if (messageToStore.content) {
|
21571
|
-
const encryptedContent = this.encryptContent(messageToStore.content);
|
21572
|
-
messageToStore.content = encryptedContent;
|
21573
|
-
}
|
21574
|
-
const request = store.put(messageToStore);
|
21575
|
-
request.onsuccess = () => {
|
21576
|
-
resolve();
|
21577
|
-
};
|
21578
|
-
request.onerror = event => {
|
21579
|
-
logger.error('更新/插入消息失败', event);
|
21580
|
-
reject(new Error('更新/插入消息失败'));
|
21581
|
-
};
|
21582
|
-
});
|
21563
|
+
this.addMessages([message], message);
|
21583
21564
|
}
|
21584
21565
|
async getMessageById(messageId) {
|
21585
21566
|
if (!this.db) {
|
@@ -21815,24 +21796,22 @@
|
|
21815
21796
|
}
|
21816
21797
|
async connectionStatusListener(status) {
|
21817
21798
|
this.connectionStatus = status;
|
21818
|
-
|
21819
|
-
|
21820
|
-
|
21821
|
-
|
21822
|
-
|
21823
|
-
|
21824
|
-
|
21825
|
-
|
21826
|
-
|
21827
|
-
|
21828
|
-
|
21829
|
-
|
21830
|
-
|
21831
|
-
|
21832
|
-
|
21833
|
-
|
21834
|
-
}
|
21835
|
-
}, 0);
|
21799
|
+
switch (status) {
|
21800
|
+
case exports.ConnectionStatus.BLOCKED:
|
21801
|
+
case exports.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:
|
21802
|
+
case exports.ConnectionStatus.DISCONNECT_BY_SERVER:
|
21803
|
+
this.handleDisconnect();
|
21804
|
+
break;
|
21805
|
+
case exports.ConnectionStatus.CONNECTING:
|
21806
|
+
this.handleConnecting();
|
21807
|
+
break;
|
21808
|
+
case exports.ConnectionStatus.CONNECTED:
|
21809
|
+
this.handleConnected();
|
21810
|
+
break;
|
21811
|
+
case exports.ConnectionStatus.DISCONNECTED:
|
21812
|
+
this.handleDisconnect();
|
21813
|
+
break;
|
21814
|
+
}
|
21836
21815
|
}
|
21837
21816
|
handleConnecting() {
|
21838
21817
|
this.watcher.onConnecting?.();
|
@@ -29043,6 +29022,7 @@
|
|
29043
29022
|
const secretKey = await DialogSecretKey$1.getDialogAesKey(dialogId.toString());
|
29044
29023
|
if (!secretKey) {
|
29045
29024
|
receivedMessage.sentStatus = exports.SentStatus.FAILED;
|
29025
|
+
await saveSentMessage(receivedMessage, sentArgs);
|
29046
29026
|
return {
|
29047
29027
|
code: exports.ErrorCode.MSG_ENCRYPT_ERROR,
|
29048
29028
|
data: receivedMessage
|