@mtkruto/node 0.1.600 → 0.1.701
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/esm/4_errors.js +2 -4
- package/esm/5_client.d.ts +1 -1
- package/esm/5_client.js +1 -1
- package/esm/client/0_params.d.ts +5 -1
- package/esm/client/0_storage_operations.d.ts +182 -0
- package/esm/client/0_storage_operations.js +611 -0
- package/esm/client/1_composer.d.ts +2 -0
- package/esm/client/1_composer.js +28 -0
- package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
- package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
- package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
- package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +1 -1
- package/esm/client/{1_file_manager.js → 2_file_manager.js} +5 -3
- package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
- package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
- package/{script/client/2_message_manager.d.ts → esm/client/3_message_manager.d.ts} +2 -2
- package/esm/client/{2_video_chat_manager.d.ts → 3_video_chat_manager.d.ts} +2 -2
- package/{script/client/3_callback_query_manager.d.ts → esm/client/4_callback_query_manager.d.ts} +2 -2
- package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +3 -3
- package/{script/client/3_inline_query_manager.d.ts → esm/client/4_inline_query_manager.d.ts} +2 -2
- package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +39 -29
- package/esm/client/{4_client.js → 5_client.js} +83 -73
- package/esm/connection/0_connection.d.ts +6 -15
- package/esm/connection/0_connection.js +1 -38
- package/esm/connection/1_connection_web_socket.d.ts +3 -2
- package/esm/connection/1_connection_web_socket.js +7 -3
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/storage/0_storage.d.ts +9 -159
- package/esm/storage/0_storage.js +1 -563
- package/esm/storage/2_storage_indexed_db.d.ts +3 -2
- package/esm/storage/2_storage_indexed_db.js +9 -8
- package/esm/storage/2_storage_local_storage.d.ts +3 -2
- package/esm/storage/2_storage_local_storage.js +5 -4
- package/esm/storage/2_storage_memory.d.ts +4 -4
- package/esm/storage/2_storage_memory.js +12 -19
- package/esm/storage/2_storage_session_storage.d.ts +2 -1
- package/esm/storage/2_storage_session_storage.js +5 -4
- package/esm/types/0_id.d.ts +1 -1
- package/package.json +1 -1
- package/script/4_errors.js +2 -4
- package/script/5_client.d.ts +1 -1
- package/script/5_client.js +1 -1
- package/script/client/0_params.d.ts +5 -1
- package/script/client/0_storage_operations.d.ts +182 -0
- package/script/client/0_storage_operations.js +615 -0
- package/script/client/1_composer.d.ts +2 -0
- package/script/client/1_composer.js +28 -0
- package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
- package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
- package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
- package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +1 -1
- package/script/client/{1_file_manager.js → 2_file_manager.js} +4 -2
- package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
- package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
- package/{esm/client/2_message_manager.d.ts → script/client/3_message_manager.d.ts} +2 -2
- package/script/client/{2_video_chat_manager.d.ts → 3_video_chat_manager.d.ts} +2 -2
- package/{esm/client/3_callback_query_manager.d.ts → script/client/4_callback_query_manager.d.ts} +2 -2
- package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +3 -3
- package/{esm/client/3_inline_query_manager.d.ts → script/client/4_inline_query_manager.d.ts} +2 -2
- package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +39 -29
- package/script/client/{4_client.js → 5_client.js} +105 -95
- package/script/connection/0_connection.d.ts +6 -15
- package/script/connection/0_connection.js +0 -41
- package/script/connection/1_connection_web_socket.d.ts +3 -2
- package/script/connection/1_connection_web_socket.js +7 -3
- package/script/mod.d.ts +1 -1
- package/script/mod.js +1 -1
- package/script/storage/0_storage.d.ts +9 -159
- package/script/storage/0_storage.js +0 -565
- package/script/storage/2_storage_indexed_db.d.ts +3 -2
- package/script/storage/2_storage_indexed_db.js +9 -8
- package/script/storage/2_storage_local_storage.d.ts +3 -2
- package/script/storage/2_storage_local_storage.js +5 -4
- package/script/storage/2_storage_memory.d.ts +4 -4
- package/script/storage/2_storage_memory.js +12 -19
- package/script/storage/2_storage_session_storage.d.ts +2 -1
- package/script/storage/2_storage_session_storage.js +5 -4
- package/script/types/0_id.d.ts +1 -1
- /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/esm/{3_storage.js → 2_storage.js} +0 -0
- /package/esm/client/{0_types.js → 1_types.js} +0 -0
- /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/esm/client/{2_video_chat_manager.js → 3_video_chat_manager.js} +0 -0
- /package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +0 -0
- /package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +0 -0
- /package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +0 -0
- /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
- /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/script/{3_storage.js → 2_storage.js} +0 -0
- /package/script/client/{0_types.js → 1_types.js} +0 -0
- /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/script/client/{2_video_chat_manager.js → 3_video_chat_manager.js} +0 -0
- /package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +0 -0
- /package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +0 -0
- /package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +0 -0
- /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
|
@@ -18,569 +18,4 @@
|
|
|
18
18
|
* You should have received a copy of the GNU Lesser General Public License
|
|
19
19
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
22
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
23
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
25
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
26
|
-
};
|
|
27
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
28
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
29
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
30
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
|
-
};
|
|
32
|
-
var _Storage_instances, _Storage_authKeyId, _Storage_resetAuthKeyId, _Storage_accountId, _Storage_accountType, _Storage_getUpdateId;
|
|
33
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.Storage = exports.K = void 0;
|
|
35
|
-
const _0_deps_js_1 = require("../0_deps.js");
|
|
36
|
-
const _0_errors_js_1 = require("../0_errors.js");
|
|
37
|
-
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
38
|
-
const _2_tl_js_1 = require("../2_tl.js");
|
|
39
|
-
// key parts
|
|
40
|
-
exports.K = {
|
|
41
|
-
connection: {
|
|
42
|
-
P: (string) => `connection.${string}`,
|
|
43
|
-
apiId: () => [exports.K.connection.P("apiId")],
|
|
44
|
-
},
|
|
45
|
-
session: {
|
|
46
|
-
P: (string) => `session.${string}`,
|
|
47
|
-
serverSalt: () => [exports.K.session.P("serverSalt")],
|
|
48
|
-
},
|
|
49
|
-
auth: {
|
|
50
|
-
P: (string) => `auth.${string}`,
|
|
51
|
-
dc: () => [exports.K.auth.P("dc")],
|
|
52
|
-
key: () => [exports.K.auth.P("key")],
|
|
53
|
-
accountId: () => [exports.K.auth.P("accountId")],
|
|
54
|
-
accountType: () => [exports.K.auth.P("accountType")],
|
|
55
|
-
},
|
|
56
|
-
updates: {
|
|
57
|
-
P: (string) => `updates.${string}`,
|
|
58
|
-
state: () => [exports.K.updates.P("state")],
|
|
59
|
-
all: () => [exports.K.updates.P("updates")],
|
|
60
|
-
updates: (boxId) => [...exports.K.updates.all(), boxId],
|
|
61
|
-
update: (boxId, id) => [...exports.K.updates.updates(boxId), id],
|
|
62
|
-
channelPts: (channelId) => [exports.K.updates.P("channelPts"), channelId],
|
|
63
|
-
},
|
|
64
|
-
cache: {
|
|
65
|
-
P: (string) => `cache.${string}`,
|
|
66
|
-
usernames: () => [exports.K.cache.P("username")],
|
|
67
|
-
username: (v) => [...exports.K.cache.usernames(), v],
|
|
68
|
-
peers: () => [exports.K.cache.P("peer")],
|
|
69
|
-
peer: (id) => [...exports.K.cache.peers(), id],
|
|
70
|
-
stickerSetNames: () => [exports.K.cache.P("stickerSetNames")],
|
|
71
|
-
stickerSetName: (id, accessHash) => [...exports.K.cache.stickerSetNames(), id, accessHash],
|
|
72
|
-
files: () => [exports.K.cache.P("files")],
|
|
73
|
-
file: (fileId) => [...exports.K.cache.files(), fileId],
|
|
74
|
-
fileParts: () => [exports.K.cache.P("fileParts")],
|
|
75
|
-
filePart: (fileId, n) => [...exports.K.cache.fileParts(), fileId, n],
|
|
76
|
-
customEmojiDocuments: () => [exports.K.cache.P("customEmojiDocuments")],
|
|
77
|
-
customEmojiDocument: (id) => [...exports.K.cache.customEmojiDocuments(), id],
|
|
78
|
-
businessConnections: () => [exports.K.cache.P("businessConnections")],
|
|
79
|
-
businessConnection: (id) => [...exports.K.cache.businessConnections(), id],
|
|
80
|
-
inlineQueryAnswers: () => [exports.K.cache.P("inlineQueryResults")],
|
|
81
|
-
inlineQueryAnswer: (userId, chatId, query, offset) => [...exports.K.cache.inlineQueryAnswers(), userId, chatId, query, offset],
|
|
82
|
-
callbackQueryAnswers: () => [exports.K.cache.P("callbackQueryAnswers")],
|
|
83
|
-
callbackQueryAnswer: (chatId, messageId, question) => [...exports.K.cache.callbackQueryAnswers(), chatId, messageId, question],
|
|
84
|
-
fullChats: () => [exports.K.cache.P("fullChats")],
|
|
85
|
-
fullChat: (chatId) => [...exports.K.cache.fullChats(), chatId],
|
|
86
|
-
groupCalls: () => [exports.K.cache.P("groupCalls")],
|
|
87
|
-
groupCall: (id) => [...exports.K.cache.groupCalls(), id],
|
|
88
|
-
groupCallAccessHashes: () => [exports.K.cache.P("groupCallAccessHashes")],
|
|
89
|
-
groupCallAccessHash: (id) => [...exports.K.cache.groupCallAccessHashes(), id],
|
|
90
|
-
},
|
|
91
|
-
messages: {
|
|
92
|
-
P: (string) => `messages.${string}`,
|
|
93
|
-
messages: (chatId) => [exports.K.messages.P("messages"), chatId],
|
|
94
|
-
message: (chatId, messageId) => [...exports.K.messages.messages(chatId), messageId],
|
|
95
|
-
allMessageRefs: () => [exports.K.messages.P("messageRefs")],
|
|
96
|
-
messageRef: (messageId) => [...exports.K.messages.allMessageRefs(), messageId],
|
|
97
|
-
},
|
|
98
|
-
chatlists: {
|
|
99
|
-
P: (string) => `chatlists.${string}`,
|
|
100
|
-
hasAllChats: (listId) => [exports.K.chatlists.P("hasAllChats"), listId],
|
|
101
|
-
chats: (listId) => [exports.K.chatlists.P("chats"), listId],
|
|
102
|
-
chat: (listId, chatId) => [...exports.K.chatlists.chats(listId), chatId],
|
|
103
|
-
pinnedChats: (listId) => [exports.K.chatlists.P("pinnedChats"), listId],
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
class Storage {
|
|
107
|
-
constructor() {
|
|
108
|
-
_Storage_instances.add(this);
|
|
109
|
-
_Storage_authKeyId.set(this, null);
|
|
110
|
-
_Storage_accountId.set(this, null);
|
|
111
|
-
_Storage_accountType.set(this, null);
|
|
112
|
-
}
|
|
113
|
-
get isMemoryStorage() {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
async setDc(dc) {
|
|
117
|
-
await this.set(exports.K.auth.dc(), dc);
|
|
118
|
-
}
|
|
119
|
-
getDc() {
|
|
120
|
-
return this.get(exports.K.auth.dc());
|
|
121
|
-
}
|
|
122
|
-
async getAuthKey() {
|
|
123
|
-
const authKey = await this.get(exports.K.auth.key());
|
|
124
|
-
await __classPrivateFieldGet(this, _Storage_instances, "m", _Storage_resetAuthKeyId).call(this, authKey);
|
|
125
|
-
return authKey;
|
|
126
|
-
}
|
|
127
|
-
async setAuthKey(authKey) {
|
|
128
|
-
await this.set(exports.K.auth.key(), authKey);
|
|
129
|
-
await __classPrivateFieldGet(this, _Storage_instances, "m", _Storage_resetAuthKeyId).call(this, authKey);
|
|
130
|
-
}
|
|
131
|
-
get authKeyId() {
|
|
132
|
-
return __classPrivateFieldGet(this, _Storage_authKeyId, "f");
|
|
133
|
-
}
|
|
134
|
-
async exportAuthString(apiId_) {
|
|
135
|
-
if (typeof apiId_ === "number") {
|
|
136
|
-
await this.setApiId(apiId_);
|
|
137
|
-
}
|
|
138
|
-
const [dc, authKey, apiId, accountId, accountType] = await Promise.all([this.getDc(), this.getAuthKey(), this.getApiId(), this.getAccountId(), this.getAccountType()]);
|
|
139
|
-
if (dc == null || authKey == null || apiId == null || accountId == null || accountType == null) {
|
|
140
|
-
throw new Error("Not authorized");
|
|
141
|
-
}
|
|
142
|
-
const writer = new _2_tl_js_1.TLWriter();
|
|
143
|
-
writer.writeString(dc);
|
|
144
|
-
writer.writeBytes(authKey);
|
|
145
|
-
writer.writeInt32(apiId);
|
|
146
|
-
writer.write(new Uint8Array([accountType == "bot" ? 1 : 0]));
|
|
147
|
-
writer.writeInt64(BigInt(accountId));
|
|
148
|
-
const data = (0, _1_utilities_js_1.rleEncode)(writer.buffer);
|
|
149
|
-
return (0, _1_utilities_js_1.base64EncodeUrlSafe)(data);
|
|
150
|
-
}
|
|
151
|
-
async importAuthString(string) {
|
|
152
|
-
const data = (0, _1_utilities_js_1.rleDecode)((0, _1_utilities_js_1.base64DecodeUrlSafe)(string));
|
|
153
|
-
const reader = new _2_tl_js_1.TLReader(data);
|
|
154
|
-
const dc = reader.readString();
|
|
155
|
-
const authKey = reader.readBytes();
|
|
156
|
-
const apiId = reader.readInt32();
|
|
157
|
-
const isBot = reader.read(1)[0];
|
|
158
|
-
const accountId = Number(reader.readInt64());
|
|
159
|
-
await this.setAccountId(accountId);
|
|
160
|
-
await this.setAccountType(isBot ? "bot" : "user");
|
|
161
|
-
await this.setApiId(apiId);
|
|
162
|
-
await this.setDc(dc);
|
|
163
|
-
await this.setAuthKey(authKey);
|
|
164
|
-
}
|
|
165
|
-
async getChannelAccessHash(id) {
|
|
166
|
-
const channel = await this.getEntity(id);
|
|
167
|
-
if (channel) {
|
|
168
|
-
if (!(channel instanceof _2_tl_js_1.types.Channel) && !(channel instanceof _2_tl_js_1.types.ChannelForbidden)) {
|
|
169
|
-
(0, _0_deps_js_1.unreachable)();
|
|
170
|
-
}
|
|
171
|
-
return typeof channel.access_hash === "bigint" ? channel.access_hash : null;
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async getUserAccessHash(id) {
|
|
178
|
-
const user = await this.getEntity(id);
|
|
179
|
-
if (user) {
|
|
180
|
-
if (!(user instanceof _2_tl_js_1.types.User)) {
|
|
181
|
-
(0, _0_deps_js_1.unreachable)();
|
|
182
|
-
}
|
|
183
|
-
return typeof user.access_hash === "bigint" ? user.access_hash : null;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async updateUsernames(id, usernames) {
|
|
190
|
-
for (let username of usernames) {
|
|
191
|
-
username = username.toLowerCase();
|
|
192
|
-
await this.set(exports.K.cache.username(username), [id, new Date()]);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async getUsername(username) {
|
|
196
|
-
username = username.toLowerCase();
|
|
197
|
-
return await this.get(exports.K.cache.username(username));
|
|
198
|
-
}
|
|
199
|
-
async setTlObject(key, value) {
|
|
200
|
-
if (value == null) {
|
|
201
|
-
await this.set(key, null);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
await this.set(key, this.isMemoryStorage ? value : (0, _1_utilities_js_1.rleEncode)(value[_2_tl_js_1.serialize]()));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
async getTlObject(keyOrBuffer) {
|
|
208
|
-
const buffer = (keyOrBuffer instanceof Uint8Array || keyOrBuffer instanceof _2_tl_js_1.TLObject) ? keyOrBuffer : await this.get(keyOrBuffer);
|
|
209
|
-
if (buffer != null) {
|
|
210
|
-
if (buffer instanceof Uint8Array) {
|
|
211
|
-
return new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)(buffer)).readObject();
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
return buffer;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
async setState(state) {
|
|
222
|
-
await this.setTlObject(exports.K.updates.state(), state);
|
|
223
|
-
}
|
|
224
|
-
async getState() {
|
|
225
|
-
return await this.getTlObject(exports.K.updates.state());
|
|
226
|
-
}
|
|
227
|
-
async setMessage(chatId, messageId, message) {
|
|
228
|
-
if (chatId > _1_utilities_js_1.ZERO_CHANNEL_ID) {
|
|
229
|
-
await this.set(exports.K.messages.messageRef(messageId), message == null ? null : chatId);
|
|
230
|
-
}
|
|
231
|
-
await this.setTlObject(exports.K.messages.message(chatId, messageId), message);
|
|
232
|
-
}
|
|
233
|
-
async deleteMessages() {
|
|
234
|
-
const maybePromises = new Array();
|
|
235
|
-
for await (const [k, o] of await this.getMany({ prefix: exports.K.messages.allMessageRefs() })) {
|
|
236
|
-
maybePromises.push(Promise.all([this.set(k, null), o == null ? Promise.resolve() : this.set(exports.K.messages.message(o, k[1]), null)]).then(() => { }));
|
|
237
|
-
}
|
|
238
|
-
await Promise.all(maybePromises.filter((v) => v instanceof Promise));
|
|
239
|
-
}
|
|
240
|
-
getMessageChat(messageId) {
|
|
241
|
-
return this.get(exports.K.messages.messageRef(messageId));
|
|
242
|
-
}
|
|
243
|
-
async getMessage(chatId, messageId) {
|
|
244
|
-
return await this.getTlObject(exports.K.messages.message(chatId, messageId));
|
|
245
|
-
}
|
|
246
|
-
async getLastMessage(chatId) {
|
|
247
|
-
for await (const [_, buffer] of await this.getMany({ prefix: exports.K.messages.messages(chatId) }, { limit: 1, reverse: true })) {
|
|
248
|
-
return await this.getTlObject(buffer);
|
|
249
|
-
}
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
async setChannelPts(channelId, pts) {
|
|
253
|
-
await this.set(exports.K.updates.channelPts(channelId), pts);
|
|
254
|
-
}
|
|
255
|
-
getChannelPts(channelId) {
|
|
256
|
-
return this.get(exports.K.updates.channelPts(channelId));
|
|
257
|
-
}
|
|
258
|
-
async setEntity(entity) {
|
|
259
|
-
await this.set(exports.K.cache.peer((0, _2_tl_js_1.peerToChatId)(entity)), [this.isMemoryStorage ? entity : (0, _1_utilities_js_1.rleEncode)(entity[_2_tl_js_1.serialize]()), new Date()]);
|
|
260
|
-
}
|
|
261
|
-
async getEntity(key) {
|
|
262
|
-
const peer_ = await this.get(exports.K.cache.peer(key));
|
|
263
|
-
if (peer_ != null) {
|
|
264
|
-
const [obj_] = peer_;
|
|
265
|
-
return await this.getTlObject(obj_);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
async setAccountId(accountId) {
|
|
272
|
-
await this.set(exports.K.auth.accountId(), accountId);
|
|
273
|
-
}
|
|
274
|
-
async getAccountId() {
|
|
275
|
-
if (__classPrivateFieldGet(this, _Storage_accountId, "f") != null) {
|
|
276
|
-
return __classPrivateFieldGet(this, _Storage_accountId, "f");
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
return (__classPrivateFieldSet(this, _Storage_accountId, await this.get(exports.K.auth.accountId()), "f"));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
async setAccountType(type) {
|
|
283
|
-
try {
|
|
284
|
-
await this.getAccountType();
|
|
285
|
-
(0, _0_deps_js_1.unreachable)();
|
|
286
|
-
}
|
|
287
|
-
catch (err) {
|
|
288
|
-
if (!(err instanceof _0_deps_js_1.AssertionError)) {
|
|
289
|
-
throw err;
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
await this.set(exports.K.auth.accountType(), type);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
async getAccountType() {
|
|
297
|
-
if (__classPrivateFieldGet(this, _Storage_accountType, "f") != null) {
|
|
298
|
-
return __classPrivateFieldGet(this, _Storage_accountType, "f");
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
return __classPrivateFieldSet(this, _Storage_accountType, await this.get(exports.K.auth.accountType()), "f");
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
async updateStickerSetName(id, accessHash, name) {
|
|
305
|
-
await this.set(exports.K.cache.stickerSetName(id, accessHash), [name, new Date()]);
|
|
306
|
-
}
|
|
307
|
-
getStickerSetName(id, accessHash) {
|
|
308
|
-
return this.get(exports.K.cache.stickerSetName(id, accessHash));
|
|
309
|
-
}
|
|
310
|
-
async setServerSalt(serverSalt) {
|
|
311
|
-
await this.set(exports.K.session.serverSalt(), serverSalt);
|
|
312
|
-
}
|
|
313
|
-
getServerSalt() {
|
|
314
|
-
return this.get(exports.K.session.serverSalt());
|
|
315
|
-
}
|
|
316
|
-
async setChat(listId, chatId, pinned, topMessageId, topMessageDate) {
|
|
317
|
-
await this.set(exports.K.chatlists.chat(listId, chatId), [pinned, topMessageId, topMessageDate]);
|
|
318
|
-
}
|
|
319
|
-
async getChats(listId) {
|
|
320
|
-
const chats = new Array();
|
|
321
|
-
for await (const [key, value] of await this.getMany({ prefix: exports.K.chatlists.chats(listId) })) {
|
|
322
|
-
if (key.length != 3 || typeof key[2] !== "number") {
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
chats.push({ chatId: key[2], pinned: value[0], topMessageId: value[1], topMessageDate: value[2] });
|
|
326
|
-
}
|
|
327
|
-
return chats;
|
|
328
|
-
}
|
|
329
|
-
async removeChats(listId) {
|
|
330
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.chatlists.chats(listId) })) {
|
|
331
|
-
await this.set(key, null);
|
|
332
|
-
}
|
|
333
|
-
await this.setHasAllChats(listId, false);
|
|
334
|
-
await this.setPinnedChats(listId, null);
|
|
335
|
-
}
|
|
336
|
-
async setHasAllChats(listId, hasAllChats) {
|
|
337
|
-
await this.set(exports.K.chatlists.hasAllChats(listId), hasAllChats);
|
|
338
|
-
}
|
|
339
|
-
async hasAllChats(listId) {
|
|
340
|
-
const v = await this.get(exports.K.chatlists.hasAllChats(listId));
|
|
341
|
-
return v == true;
|
|
342
|
-
}
|
|
343
|
-
async setPinnedChats(listId, chatIds) {
|
|
344
|
-
await this.set(exports.K.chatlists.pinnedChats(listId), chatIds);
|
|
345
|
-
}
|
|
346
|
-
async getPinnedChats(listId) {
|
|
347
|
-
return await this.get(exports.K.chatlists.pinnedChats(listId));
|
|
348
|
-
}
|
|
349
|
-
async getHistory(chatId, offsetId, limit) {
|
|
350
|
-
if (offsetId == 0) {
|
|
351
|
-
offsetId = Infinity;
|
|
352
|
-
}
|
|
353
|
-
++limit;
|
|
354
|
-
const messages = new Array();
|
|
355
|
-
for await (const [_, buffer] of await this.getMany({ start: exports.K.messages.message(chatId, 0), end: exports.K.messages.message(chatId, offsetId) }, { limit, reverse: true })) {
|
|
356
|
-
const message = await this.getTlObject(buffer);
|
|
357
|
-
if ("id" in message && message.id == offsetId) {
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
messages.push(message);
|
|
361
|
-
}
|
|
362
|
-
return messages;
|
|
363
|
-
}
|
|
364
|
-
async getFile(id) {
|
|
365
|
-
if (!this.supportsFiles) {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
return await this.get(exports.K.cache.file(id));
|
|
369
|
-
}
|
|
370
|
-
async *iterFileParts(id, partCount, offset) {
|
|
371
|
-
if (!this.supportsFiles) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
for (let i = offset; i < partCount; i++) {
|
|
375
|
-
const part = await this.get(exports.K.cache.filePart(id, i));
|
|
376
|
-
if (part == null) {
|
|
377
|
-
continue;
|
|
378
|
-
}
|
|
379
|
-
yield part;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
async saveFilePart(id, index, bytes) {
|
|
383
|
-
if (!this.supportsFiles) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
await this.set(exports.K.cache.filePart(id, index), bytes);
|
|
387
|
-
}
|
|
388
|
-
async setFilePartCount(id, partCount, chunkSize) {
|
|
389
|
-
if (!this.supportsFiles) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
await this.set(exports.K.cache.file(id), [partCount, chunkSize]);
|
|
393
|
-
}
|
|
394
|
-
async setCustomEmojiDocument(id, document) {
|
|
395
|
-
await this.set(exports.K.cache.customEmojiDocument(id), [this.isMemoryStorage ? document : (0, _1_utilities_js_1.rleEncode)(document[_2_tl_js_1.serialize]()), new Date()]);
|
|
396
|
-
}
|
|
397
|
-
async getCustomEmojiDocument(id) {
|
|
398
|
-
const v = await this.get(exports.K.cache.customEmojiDocument(id));
|
|
399
|
-
if (v != null) {
|
|
400
|
-
return [await this.getTlObject(v[0]), v[1]];
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
return null;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
async setBusinessConnection(id, connection) {
|
|
407
|
-
await this.set(exports.K.cache.businessConnection(id), connection == null ? null : this.isMemoryStorage ? connection : (0, _1_utilities_js_1.rleEncode)(connection[_2_tl_js_1.serialize]()));
|
|
408
|
-
}
|
|
409
|
-
async getBusinessConnection(id) {
|
|
410
|
-
const v = await this.get(exports.K.cache.businessConnection(id));
|
|
411
|
-
if (v != null) {
|
|
412
|
-
return await this.getTlObject(v);
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
return null;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
async setInlineQueryAnswer(userId, chatId, query, offset, results, date) {
|
|
419
|
-
await this.set(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset), [this.isMemoryStorage ? results : (0, _1_utilities_js_1.rleEncode)(results[_2_tl_js_1.serialize]()), date]);
|
|
420
|
-
}
|
|
421
|
-
async getInlineQueryAnswer(userId, chatId, query, offset) {
|
|
422
|
-
const peer_ = await this.get(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset));
|
|
423
|
-
if (peer_ != null) {
|
|
424
|
-
const [obj_, date] = peer_;
|
|
425
|
-
return [await this.getTlObject(obj_), date];
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
return null;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
async setCallbackQueryAnswer(chatId, messageId, question, answer) {
|
|
432
|
-
await this.set(exports.K.cache.callbackQueryAnswer(chatId, messageId, question), [this.isMemoryStorage ? answer : (0, _1_utilities_js_1.rleEncode)(answer[_2_tl_js_1.serialize]()), new Date()]);
|
|
433
|
-
}
|
|
434
|
-
async getCallbackQueryAnswer(chatId, messageId, question) {
|
|
435
|
-
const peer_ = await this.get(exports.K.cache.callbackQueryAnswer(chatId, messageId, question));
|
|
436
|
-
if (peer_ != null) {
|
|
437
|
-
const [obj_, date] = peer_;
|
|
438
|
-
return [await this.getTlObject(obj_), date];
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
return null;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
async setFullChat(chatId, fullChat) {
|
|
445
|
-
await this.setTlObject(exports.K.cache.fullChat(chatId), fullChat);
|
|
446
|
-
}
|
|
447
|
-
async getFullChat(chatId) {
|
|
448
|
-
return await this.getTlObject(exports.K.cache.fullChat(chatId));
|
|
449
|
-
}
|
|
450
|
-
async setGroupCall(id, groupCall) {
|
|
451
|
-
await this.setTlObject(exports.K.cache.groupCall(id), groupCall);
|
|
452
|
-
}
|
|
453
|
-
async getGroupCall(id) {
|
|
454
|
-
return await this.getTlObject(exports.K.cache.groupCall(id));
|
|
455
|
-
}
|
|
456
|
-
async setGroupCallAccessHash(id, accessHash) {
|
|
457
|
-
await this.set(exports.K.cache.groupCallAccessHash(id), accessHash);
|
|
458
|
-
}
|
|
459
|
-
async getGroupCallAccessHash(id) {
|
|
460
|
-
return await this.get(exports.K.cache.groupCallAccessHash(id));
|
|
461
|
-
}
|
|
462
|
-
async setUpdate(boxId, update) {
|
|
463
|
-
await this.setTlObject(exports.K.updates.update(boxId, __classPrivateFieldGet(this, _Storage_instances, "m", _Storage_getUpdateId).call(this, update)), update);
|
|
464
|
-
}
|
|
465
|
-
async deleteUpdates() {
|
|
466
|
-
const maybePromises = new Array();
|
|
467
|
-
for await (const [k] of await this.getMany({ prefix: exports.K.updates.all() })) {
|
|
468
|
-
maybePromises.push(this.set(k, null));
|
|
469
|
-
}
|
|
470
|
-
await Promise.all(maybePromises.filter((v) => v instanceof Promise));
|
|
471
|
-
}
|
|
472
|
-
async getFirstUpdate(boxId) {
|
|
473
|
-
for await (const [key, update] of await this.getMany({ prefix: exports.K.updates.updates(boxId) }, { limit: 1 })) {
|
|
474
|
-
return [key, await this.getTlObject(update).then((v) => v)];
|
|
475
|
-
}
|
|
476
|
-
return null;
|
|
477
|
-
}
|
|
478
|
-
async assertUser(source) {
|
|
479
|
-
if (await this.getAccountType() != "user") {
|
|
480
|
-
throw new _0_errors_js_1.InputError(`${source}: not user a client`);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
async assertBot(source) {
|
|
484
|
-
if (await this.getAccountType() != "bot") {
|
|
485
|
-
throw new _0_errors_js_1.InputError(`${source}: not a bot client`);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
async deleteFiles() {
|
|
489
|
-
if (!this.supportsFiles) {
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.fileParts() })) {
|
|
493
|
-
await this.set(key, null);
|
|
494
|
-
}
|
|
495
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.files() })) {
|
|
496
|
-
await this.set(key, null);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
async deleteCustomEmojiDocuments() {
|
|
500
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.customEmojiDocuments() })) {
|
|
501
|
-
await this.set(key, null);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
async deleteBusinessConnections() {
|
|
505
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.businessConnections() })) {
|
|
506
|
-
await this.set(key, null);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
async deleteInlineQueryAnswers() {
|
|
510
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.inlineQueryAnswers() })) {
|
|
511
|
-
await this.set(key, null);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
async deleteCallbackQueryAnswers() {
|
|
515
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.callbackQueryAnswers() })) {
|
|
516
|
-
await this.set(key, null);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
async deleteFullChats() {
|
|
520
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.fullChats() })) {
|
|
521
|
-
await this.set(key, null);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
async deleteGroupCalls() {
|
|
525
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.groupCalls() })) {
|
|
526
|
-
await this.set(key, null);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
async deleteStickerSetNames() {
|
|
530
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.stickerSetNames() })) {
|
|
531
|
-
await this.set(key, null);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
async deletePeers() {
|
|
535
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.peers() })) {
|
|
536
|
-
await this.set(key, null);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
async deleteUsernames() {
|
|
540
|
-
for await (const [key] of await this.getMany({ prefix: exports.K.cache.usernames() })) {
|
|
541
|
-
await this.set(key, null);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
async clear() {
|
|
545
|
-
await Promise.all([
|
|
546
|
-
this.deleteMessages(),
|
|
547
|
-
this.removeChats(0),
|
|
548
|
-
this.removeChats(1),
|
|
549
|
-
this.deleteUpdates(),
|
|
550
|
-
this.deleteFiles(),
|
|
551
|
-
this.deleteCustomEmojiDocuments(),
|
|
552
|
-
this.deleteBusinessConnections(),
|
|
553
|
-
this.deleteInlineQueryAnswers(),
|
|
554
|
-
this.deleteCallbackQueryAnswers(),
|
|
555
|
-
this.deleteFullChats(),
|
|
556
|
-
this.deleteGroupCalls(),
|
|
557
|
-
this.deleteStickerSetNames(),
|
|
558
|
-
this.deletePeers(),
|
|
559
|
-
this.deleteUsernames(),
|
|
560
|
-
]);
|
|
561
|
-
}
|
|
562
|
-
async setApiId(apiId) {
|
|
563
|
-
await this.set(exports.K.connection.apiId(), apiId);
|
|
564
|
-
}
|
|
565
|
-
async getApiId() {
|
|
566
|
-
return await this.get(exports.K.connection.apiId());
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
exports.Storage = Storage;
|
|
570
|
-
_Storage_authKeyId = new WeakMap(), _Storage_accountId = new WeakMap(), _Storage_accountType = new WeakMap(), _Storage_instances = new WeakSet(), _Storage_resetAuthKeyId = async function _Storage_resetAuthKeyId(authKey) {
|
|
571
|
-
if (authKey != null) {
|
|
572
|
-
__classPrivateFieldSet(this, _Storage_authKeyId, await (0, _1_utilities_js_1.sha1)(authKey).then((hash) => (0, _1_utilities_js_1.bigIntFromBuffer)(hash.subarray(-8), true, false)), "f");
|
|
573
|
-
}
|
|
574
|
-
else {
|
|
575
|
-
__classPrivateFieldSet(this, _Storage_authKeyId, null, "f");
|
|
576
|
-
}
|
|
577
|
-
}, _Storage_getUpdateId = function _Storage_getUpdateId(update) {
|
|
578
|
-
let id = BigInt(Date.now()) << 32n;
|
|
579
|
-
if ("pts" in update && update.pts) {
|
|
580
|
-
id |= BigInt(update.pts);
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
id |= BigInt(0xffffffffn);
|
|
584
|
-
}
|
|
585
|
-
return id;
|
|
586
|
-
};
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js";
|
|
21
21
|
export interface StorageIndexedDBParams {
|
|
22
22
|
/** Whether to store files. Defaults to true. */
|
|
23
|
-
|
|
23
|
+
storeFiles?: boolean;
|
|
24
24
|
}
|
|
25
|
-
export declare class StorageIndexedDB
|
|
25
|
+
export declare class StorageIndexedDB implements Storage {
|
|
26
26
|
#private;
|
|
27
27
|
database: IDBDatabase | null;
|
|
28
28
|
constructor(name: string, params?: StorageIndexedDBParams);
|
|
@@ -30,6 +30,7 @@ export declare class StorageIndexedDB extends Storage {
|
|
|
30
30
|
branch(id: string): StorageIndexedDB;
|
|
31
31
|
initialize(): Promise<void>;
|
|
32
32
|
get supportsFiles(): boolean;
|
|
33
|
+
get mustSerialize(): boolean;
|
|
33
34
|
set(k: readonly StorageKeyPart[], v: unknown, tx_?: IDBTransaction): Promise<void>;
|
|
34
35
|
get<T>(k: readonly StorageKeyPart[], tx_?: IDBTransaction | null, fix?: boolean): Promise<T | null>;
|
|
35
36
|
getMany<T>(filter: GetManyFilter, params?: {
|
|
@@ -32,16 +32,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
32
32
|
var _StorageIndexedDB_instances, _StorageIndexedDB_name, _StorageIndexedDB_id, _StorageIndexedDB_supportsFiles, _StorageIndexedDB_fixKey;
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.StorageIndexedDB = void 0;
|
|
35
|
-
const _0_storage_js_1 = require("./0_storage.js");
|
|
36
35
|
const _1_utilities_js_1 = require("./1_utilities.js");
|
|
37
36
|
const VERSION = 1;
|
|
38
37
|
const KV_OBJECT_STORE = "kv";
|
|
39
|
-
class StorageIndexedDB
|
|
38
|
+
class StorageIndexedDB {
|
|
40
39
|
constructor(name, params) {
|
|
41
|
-
if (typeof indexedDB == "undefined") {
|
|
42
|
-
throw new Error("Unavailable in current environment");
|
|
43
|
-
}
|
|
44
|
-
super();
|
|
45
40
|
_StorageIndexedDB_instances.add(this);
|
|
46
41
|
Object.defineProperty(this, "database", {
|
|
47
42
|
enumerable: true,
|
|
@@ -52,14 +47,17 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
52
47
|
_StorageIndexedDB_name.set(this, void 0);
|
|
53
48
|
_StorageIndexedDB_id.set(this, null);
|
|
54
49
|
_StorageIndexedDB_supportsFiles.set(this, void 0);
|
|
50
|
+
if (typeof indexedDB == "undefined") {
|
|
51
|
+
throw new Error("Unavailable in current environment");
|
|
52
|
+
}
|
|
55
53
|
__classPrivateFieldSet(this, _StorageIndexedDB_name, name, "f");
|
|
56
|
-
__classPrivateFieldSet(this, _StorageIndexedDB_supportsFiles, params?.
|
|
54
|
+
__classPrivateFieldSet(this, _StorageIndexedDB_supportsFiles, params?.storeFiles ?? true, "f");
|
|
57
55
|
}
|
|
58
56
|
get name() {
|
|
59
57
|
return __classPrivateFieldGet(this, _StorageIndexedDB_name, "f");
|
|
60
58
|
}
|
|
61
59
|
branch(id) {
|
|
62
|
-
const storage = new StorageIndexedDB(this.name);
|
|
60
|
+
const storage = new StorageIndexedDB(this.name, { storeFiles: __classPrivateFieldGet(this, _StorageIndexedDB_supportsFiles, "f") });
|
|
63
61
|
__classPrivateFieldSet(storage, _StorageIndexedDB_id, id, "f");
|
|
64
62
|
return storage;
|
|
65
63
|
}
|
|
@@ -80,6 +78,9 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
80
78
|
get supportsFiles() {
|
|
81
79
|
return __classPrivateFieldGet(this, _StorageIndexedDB_supportsFiles, "f");
|
|
82
80
|
}
|
|
81
|
+
get mustSerialize() {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
83
84
|
set(k, v, tx_) {
|
|
84
85
|
k = __classPrivateFieldGet(this, _StorageIndexedDB_instances, "m", _StorageIndexedDB_fixKey).call(this, k);
|
|
85
86
|
if (!this.database) {
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js";
|
|
21
|
-
export declare class StorageLocalStorage
|
|
21
|
+
export declare class StorageLocalStorage implements Storage {
|
|
22
22
|
#private;
|
|
23
23
|
constructor(prefix: string);
|
|
24
24
|
get prefix(): string;
|
|
25
|
-
branch(id: string):
|
|
25
|
+
branch(id: string): Storage;
|
|
26
26
|
initialize(): void;
|
|
27
27
|
get supportsFiles(): boolean;
|
|
28
|
+
get mustSerialize(): boolean;
|
|
28
29
|
get<T>(key_: readonly StorageKeyPart[]): T | null;
|
|
29
30
|
getMany<T>(filter: GetManyFilter, params?: {
|
|
30
31
|
limit?: number;
|
|
@@ -32,18 +32,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
32
32
|
var _StorageLocalStorage_prefix;
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.StorageLocalStorage = void 0;
|
|
35
|
-
const _0_storage_js_1 = require("./0_storage.js");
|
|
36
35
|
const _1_utilities_js_1 = require("./1_utilities.js");
|
|
37
|
-
class StorageLocalStorage
|
|
36
|
+
class StorageLocalStorage {
|
|
38
37
|
constructor(prefix) {
|
|
38
|
+
_StorageLocalStorage_prefix.set(this, void 0);
|
|
39
39
|
if (typeof localStorage === "undefined") {
|
|
40
40
|
throw new Error("Unavailable in current environment");
|
|
41
41
|
}
|
|
42
42
|
if (prefix.length <= 0) {
|
|
43
43
|
throw new Error("Empty prefix");
|
|
44
44
|
}
|
|
45
|
-
super();
|
|
46
|
-
_StorageLocalStorage_prefix.set(this, void 0);
|
|
47
45
|
__classPrivateFieldSet(this, _StorageLocalStorage_prefix, prefix, "f");
|
|
48
46
|
}
|
|
49
47
|
get prefix() {
|
|
@@ -57,6 +55,9 @@ class StorageLocalStorage extends _0_storage_js_1.Storage {
|
|
|
57
55
|
get supportsFiles() {
|
|
58
56
|
return false;
|
|
59
57
|
}
|
|
58
|
+
get mustSerialize() {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
60
61
|
get(key_) {
|
|
61
62
|
const key = this.prefix + (0, _1_utilities_js_1.toString)(key_);
|
|
62
63
|
const value = localStorage.getItem(key);
|