@mtkruto/node 0.1.190 → 0.1.200
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/0_errors.d.ts +12 -0
- package/esm/0_errors.js +19 -0
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/2_tl.d.ts +6 -6
- package/esm/2_tl.js +6 -6
- package/esm/3_storage.d.ts +5 -5
- package/esm/3_storage.js +5 -5
- package/esm/3_types.d.ts +6 -5
- package/esm/3_types.js +6 -5
- package/esm/4_constants.d.ts +2 -2
- package/esm/4_constants.js +2 -2
- package/esm/5_client.d.ts +1 -1
- package/esm/5_client.js +1 -1
- package/esm/client/0_client_abstract.js +3 -2
- package/esm/client/0_html.js +4 -3
- package/esm/client/0_markdown.js +6 -5
- package/esm/client/0_params.d.ts +7 -1
- package/esm/client/0_types.d.ts +1 -2
- package/esm/client/0_types.js +1 -2
- package/esm/client/0_utilities.d.ts +0 -3
- package/esm/client/0_utilities.js +2 -21
- package/esm/client/1_business_connection_manager.d.ts +11 -0
- package/esm/client/1_business_connection_manager.js +47 -0
- package/esm/client/1_client_encrypted.js +1 -1
- package/esm/client/1_client_plain.js +3 -4
- package/esm/client/1_composer.js +3 -2
- package/esm/client/1_file_manager.js +4 -4
- package/esm/client/1_update_manager.d.ts +8 -1
- package/esm/client/1_update_manager.js +88 -8
- package/esm/client/2_message_manager.d.ts +7 -6
- package/esm/client/2_message_manager.js +89 -74
- package/esm/client/3_chat_list_manager.js +3 -2
- package/esm/client/3_story_manager.js +2 -1
- package/esm/client/4_client.d.ts +422 -421
- package/esm/client/4_client.js +578 -520
- package/esm/mod.d.ts +1 -0
- package/esm/mod.js +1 -0
- package/esm/storage/0_storage.d.ts +5 -0
- package/esm/storage/0_storage.js +20 -0
- package/esm/storage/{1_storage_indexed_db.js → 2_storage_indexed_db.js} +1 -1
- package/esm/storage/{1_storage_local_storage.js → 2_storage_local_storage.js} +1 -1
- package/{script/storage/1_storage_memory.d.ts → esm/storage/2_storage_memory.d.ts} +1 -4
- package/esm/storage/{1_storage_memory.js → 2_storage_memory.js} +8 -28
- package/esm/storage/{1_storage_session_storage.js → 2_storage_session_storage.js} +1 -1
- package/esm/tl/2_types.d.ts +1071 -183
- package/esm/tl/2_types.js +2916 -464
- package/esm/tl/3_functions.d.ts +381 -17
- package/esm/tl/3_functions.js +1002 -120
- package/{script/tl/4_tl_writer.d.ts → esm/tl/5_tl_writer.d.ts} +1 -1
- package/{script/tl/4_rpc_result.d.ts → esm/tl/6_rpc_result.d.ts} +1 -1
- package/esm/tl/{4_rpc_result.js → 6_rpc_result.js} +1 -1
- package/esm/tl/{6_message.d.ts → 7_message.d.ts} +2 -2
- package/esm/tl/{6_message.js → 7_message.js} +3 -3
- package/esm/tl/{7_message_container.d.ts → 8_message_container.d.ts} +1 -1
- package/esm/tl/{7_message_container.js → 8_message_container.js} +3 -3
- package/esm/types/0_chat_photo.d.ts +1 -0
- package/esm/types/0_chat_photo.js +8 -5
- package/esm/types/0_message_entity.d.ts +1 -1
- package/esm/types/0_thumbnail.js +1 -1
- package/esm/types/1_bot_command_scope.d.ts +1 -1
- package/esm/types/1_photo.js +2 -2
- package/esm/types/1_story_privacy.d.ts +1 -1
- package/esm/types/2_business_connection.d.ts +11 -0
- package/esm/types/2_business_connection.js +12 -0
- package/esm/types/2_chat_member.d.ts +1 -1
- package/esm/types/2_chosen_inline_result.d.ts +1 -1
- package/esm/types/2_game.js +1 -1
- package/esm/types/2_inline_keyboard_button.d.ts +1 -1
- package/esm/types/2_inline_query.d.ts +1 -1
- package/esm/types/2_invite_link.d.ts +1 -1
- package/esm/types/2_message_reaction_count.d.ts +1 -1
- package/esm/types/2_message_reactions.d.ts +1 -1
- package/esm/types/2_story_content.js +1 -1
- package/{script/types/1_story_interactive_area.d.ts → esm/types/2_story_interactive_area.d.ts} +2 -2
- package/esm/types/{1_story_interactive_area.js → 2_story_interactive_area.js} +1 -1
- package/esm/types/3_chat_member_updated.d.ts +1 -1
- package/esm/types/3_reply_markup.d.ts +1 -1
- package/esm/types/3_story.d.ts +2 -2
- package/esm/types/3_story.js +1 -1
- package/esm/types/4_inline_query_result.d.ts +1 -1
- package/esm/types/4_inline_query_result.js +1 -1
- package/esm/types/4_message.d.ts +9 -3
- package/esm/types/4_message.js +22 -5
- package/esm/types/5_callback_query.d.ts +1 -1
- package/esm/types/5_callback_query.js +2 -1
- package/esm/types/5_chat.d.ts +1 -1
- package/esm/types/6_update.d.ts +12 -2
- package/esm/types/{0__file_id.js → _file_id.js} +2 -1
- package/package.json +1 -1
- package/script/0_errors.d.ts +12 -0
- package/script/0_errors.js +27 -0
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.js +1 -1
- package/script/2_tl.d.ts +6 -6
- package/script/2_tl.js +6 -6
- package/script/3_storage.d.ts +5 -5
- package/script/3_storage.js +5 -5
- package/script/3_types.d.ts +6 -5
- package/script/3_types.js +6 -5
- package/script/4_constants.d.ts +2 -2
- package/script/4_constants.js +2 -2
- package/script/5_client.d.ts +1 -1
- package/script/5_client.js +1 -1
- package/script/client/0_client_abstract.js +3 -2
- package/script/client/0_html.js +4 -3
- package/script/client/0_markdown.js +6 -5
- package/script/client/0_params.d.ts +7 -1
- package/script/client/0_types.d.ts +1 -2
- package/script/client/0_types.js +0 -4
- package/script/client/0_utilities.d.ts +0 -3
- package/script/client/0_utilities.js +3 -24
- package/script/client/1_business_connection_manager.d.ts +11 -0
- package/script/client/1_business_connection_manager.js +51 -0
- package/script/client/1_client_encrypted.js +2 -2
- package/script/client/1_client_plain.js +3 -4
- package/script/client/1_composer.js +3 -2
- package/script/client/1_file_manager.js +5 -5
- package/script/client/1_update_manager.d.ts +8 -1
- package/script/client/1_update_manager.js +88 -8
- package/script/client/2_message_manager.d.ts +7 -6
- package/script/client/2_message_manager.js +88 -73
- package/script/client/3_chat_list_manager.js +3 -2
- package/script/client/3_story_manager.js +2 -1
- package/script/client/4_client.d.ts +422 -421
- package/script/client/4_client.js +578 -520
- package/script/mod.d.ts +1 -0
- package/script/mod.js +1 -0
- package/script/storage/0_storage.d.ts +5 -0
- package/script/storage/0_storage.js +20 -0
- package/script/storage/{1_storage_indexed_db.js → 2_storage_indexed_db.js} +7 -7
- package/script/storage/{1_storage_local_storage.js → 2_storage_local_storage.js} +10 -10
- package/{esm/storage/1_storage_memory.d.ts → script/storage/2_storage_memory.d.ts} +1 -4
- package/script/storage/{1_storage_memory.js → 2_storage_memory.js} +12 -32
- package/script/storage/{1_storage_session_storage.js → 2_storage_session_storage.js} +10 -10
- package/script/tl/2_types.d.ts +1071 -183
- package/script/tl/2_types.js +3028 -504
- package/script/tl/3_functions.d.ts +381 -17
- package/script/tl/3_functions.js +1047 -143
- package/{esm/tl/4_tl_writer.d.ts → script/tl/5_tl_writer.d.ts} +1 -1
- package/{esm/tl/4_rpc_result.d.ts → script/tl/6_rpc_result.d.ts} +1 -1
- package/script/tl/{4_rpc_result.js → 6_rpc_result.js} +2 -2
- package/script/tl/{6_message.d.ts → 7_message.d.ts} +2 -2
- package/script/tl/{6_message.js → 7_message.js} +8 -8
- package/script/tl/{7_message_container.d.ts → 8_message_container.d.ts} +1 -1
- package/script/tl/{7_message_container.js → 8_message_container.js} +7 -7
- package/script/types/0_chat_photo.d.ts +1 -0
- package/script/types/0_chat_photo.js +16 -13
- package/script/types/0_message_entity.d.ts +1 -1
- package/script/types/0_thumbnail.js +6 -6
- package/script/types/1_bot_command_scope.d.ts +1 -1
- package/script/types/1_photo.js +7 -7
- package/script/types/1_story_privacy.d.ts +1 -1
- package/script/types/2_business_connection.d.ts +11 -0
- package/script/types/2_business_connection.js +16 -0
- package/script/types/2_chat_member.d.ts +1 -1
- package/script/types/2_chosen_inline_result.d.ts +1 -1
- package/script/types/2_game.js +3 -3
- package/script/types/2_inline_keyboard_button.d.ts +1 -1
- package/script/types/2_inline_query.d.ts +1 -1
- package/script/types/2_invite_link.d.ts +1 -1
- package/script/types/2_message_reaction_count.d.ts +1 -1
- package/script/types/2_message_reactions.d.ts +1 -1
- package/script/types/2_story_content.js +4 -4
- package/{esm/types/1_story_interactive_area.d.ts → script/types/2_story_interactive_area.d.ts} +2 -2
- package/script/types/{1_story_interactive_area.js → 2_story_interactive_area.js} +2 -2
- package/script/types/3_chat_member_updated.d.ts +1 -1
- package/script/types/3_reply_markup.d.ts +1 -1
- package/script/types/3_story.d.ts +2 -2
- package/script/types/3_story.js +2 -2
- package/script/types/4_inline_query_result.d.ts +1 -1
- package/script/types/4_inline_query_result.js +2 -2
- package/script/types/4_message.d.ts +9 -3
- package/script/types/4_message.js +37 -20
- package/script/types/5_callback_query.d.ts +1 -1
- package/script/types/5_callback_query.js +2 -1
- package/script/types/5_chat.d.ts +1 -1
- package/script/types/6_update.d.ts +12 -2
- package/script/types/{0__file_id.js → _file_id.js} +2 -1
- /package/esm/storage/{0_utilities.d.ts → 1_utilities.d.ts} +0 -0
- /package/esm/storage/{0_utilities.js → 1_utilities.js} +0 -0
- /package/esm/storage/{1_storage_indexed_db.d.ts → 2_storage_indexed_db.d.ts} +0 -0
- /package/esm/storage/{1_storage_local_storage.d.ts → 2_storage_local_storage.d.ts} +0 -0
- /package/esm/storage/{1_storage_session_storage.d.ts → 2_storage_session_storage.d.ts} +0 -0
- /package/esm/tl/{3_tl_reader.d.ts → 4_tl_reader.d.ts} +0 -0
- /package/esm/tl/{3_tl_reader.js → 4_tl_reader.js} +0 -0
- /package/esm/tl/{4_tl_writer.js → 5_tl_writer.js} +0 -0
- /package/esm/types/{0_venue.d.ts → 1_venue.d.ts} +0 -0
- /package/esm/types/{0_venue.js → 1_venue.js} +0 -0
- /package/esm/types/{0__file_id.d.ts → _file_id.d.ts} +0 -0
- /package/esm/types/{1__getters.d.ts → _getters.d.ts} +0 -0
- /package/esm/types/{1__getters.js → _getters.js} +0 -0
- /package/script/storage/{0_utilities.d.ts → 1_utilities.d.ts} +0 -0
- /package/script/storage/{0_utilities.js → 1_utilities.js} +0 -0
- /package/script/storage/{1_storage_indexed_db.d.ts → 2_storage_indexed_db.d.ts} +0 -0
- /package/script/storage/{1_storage_local_storage.d.ts → 2_storage_local_storage.d.ts} +0 -0
- /package/script/storage/{1_storage_session_storage.d.ts → 2_storage_session_storage.d.ts} +0 -0
- /package/script/tl/{3_tl_reader.d.ts → 4_tl_reader.d.ts} +0 -0
- /package/script/tl/{3_tl_reader.js → 4_tl_reader.js} +0 -0
- /package/script/tl/{4_tl_writer.js → 5_tl_writer.js} +0 -0
- /package/script/types/{0_venue.d.ts → 1_venue.d.ts} +0 -0
- /package/script/types/{0_venue.js → 1_venue.js} +0 -0
- /package/script/types/{0__file_id.d.ts → _file_id.d.ts} +0 -0
- /package/script/types/{1__getters.d.ts → _getters.d.ts} +0 -0
- /package/script/types/{1__getters.js → _getters.js} +0 -0
package/script/mod.d.ts
CHANGED
package/script/mod.js
CHANGED
|
@@ -27,6 +27,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.errors = exports.SYSTEM_VERSION = exports.SYSTEM_LANG_CODE = exports.LAYER = exports.LANG_PACK = exports.LANG_CODE = exports.INITIAL_DC = exports.DEVICE_MODEL = exports.APP_VERSION = exports.checkPassword = exports.setLogVerbosity = exports.getRandomId = exports.getColorName = exports.getColorFromPeerId = void 0;
|
|
30
|
+
__exportStar(require("./0_errors.js"), exports);
|
|
30
31
|
var _1_utilities_js_1 = require("./1_utilities.js");
|
|
31
32
|
Object.defineProperty(exports, "getColorFromPeerId", { enumerable: true, get: function () { return _1_utilities_js_1.getColorFromPeerId; } });
|
|
32
33
|
Object.defineProperty(exports, "getColorName", { enumerable: true, get: function () { return _1_utilities_js_1.getColorName; } });
|
|
@@ -39,6 +39,8 @@ export declare const K: {
|
|
|
39
39
|
filePart: (fileId: bigint, n: number) => StorageKeyPart[];
|
|
40
40
|
customEmojiDocuments: () => StorageKeyPart[];
|
|
41
41
|
customEmojiDocument: (id: bigint) => StorageKeyPart[];
|
|
42
|
+
businessConnections: () => StorageKeyPart[];
|
|
43
|
+
businessConnection: (id: string) => StorageKeyPart[];
|
|
42
44
|
};
|
|
43
45
|
messages: {
|
|
44
46
|
P: (string: string) => string;
|
|
@@ -126,6 +128,8 @@ export declare abstract class Storage {
|
|
|
126
128
|
setFilePartCount(id: bigint, partCount: number, chunkSize: number): Promise<void>;
|
|
127
129
|
setCustomEmojiDocument(id: bigint, document: types.Document): Promise<void>;
|
|
128
130
|
getCustomEmojiDocument(id: bigint): Promise<[types.Document, Date] | null>;
|
|
131
|
+
setBusinessConnection(id: string, connection: types.BotBusinessConnection | null): Promise<void>;
|
|
132
|
+
getBusinessConnection(id: string): Promise<types.BotBusinessConnection | null>;
|
|
129
133
|
setUpdate(boxId: bigint, update: enums.Update): Promise<void>;
|
|
130
134
|
deleteUpdates(): Promise<void>;
|
|
131
135
|
getFirstUpdate(boxId: bigint): Promise<[readonly StorageKeyPart[], enums.Update] | null>;
|
|
@@ -133,6 +137,7 @@ export declare abstract class Storage {
|
|
|
133
137
|
assertBot(source: string): Promise<void>;
|
|
134
138
|
deleteFiles(): Promise<void>;
|
|
135
139
|
deleteCustomEmojiDocuments(): Promise<void>;
|
|
140
|
+
deleteBusinessConnections(): Promise<void>;
|
|
136
141
|
deleteStickerSetNames(): Promise<void>;
|
|
137
142
|
deletePeers(): Promise<void>;
|
|
138
143
|
deleteUsernames(): Promise<void>;
|
|
@@ -54,6 +54,8 @@ exports.K = {
|
|
|
54
54
|
filePart: (fileId, n) => [...exports.K.cache.fileParts(), fileId, n],
|
|
55
55
|
customEmojiDocuments: () => [exports.K.cache.P("customEmojiDocuments")],
|
|
56
56
|
customEmojiDocument: (id) => [...exports.K.cache.customEmojiDocuments(), id],
|
|
57
|
+
businessConnections: () => [exports.K.cache.P("businessConnections")],
|
|
58
|
+
businessConnection: (id) => [...exports.K.cache.businessConnections(), id],
|
|
57
59
|
},
|
|
58
60
|
messages: {
|
|
59
61
|
P: (string) => `messages.${string}`,
|
|
@@ -370,6 +372,18 @@ class Storage {
|
|
|
370
372
|
return null;
|
|
371
373
|
}
|
|
372
374
|
}
|
|
375
|
+
async setBusinessConnection(id, connection) {
|
|
376
|
+
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]()));
|
|
377
|
+
}
|
|
378
|
+
async getBusinessConnection(id) {
|
|
379
|
+
const v = await this.get(exports.K.cache.businessConnection(id));
|
|
380
|
+
if (v != null) {
|
|
381
|
+
return await this.getTlObject(v);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
373
387
|
async setUpdate(boxId, update) {
|
|
374
388
|
await this.setTlObject(exports.K.updates.update(boxId, __classPrivateFieldGet(this, _Storage_instances, "m", _Storage_getUpdateId).call(this, update)), update);
|
|
375
389
|
}
|
|
@@ -412,6 +426,11 @@ class Storage {
|
|
|
412
426
|
await this.set(key, null);
|
|
413
427
|
}
|
|
414
428
|
}
|
|
429
|
+
async deleteBusinessConnections() {
|
|
430
|
+
for await (const [key] of await this.getMany({ prefix: exports.K.cache.businessConnections() })) {
|
|
431
|
+
await this.set(key, null);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
415
434
|
async deleteStickerSetNames() {
|
|
416
435
|
for await (const [key] of await this.getMany({ prefix: exports.K.cache.stickerSetNames() })) {
|
|
417
436
|
await this.set(key, null);
|
|
@@ -435,6 +454,7 @@ class Storage {
|
|
|
435
454
|
this.deleteUpdates(),
|
|
436
455
|
this.deleteFiles(),
|
|
437
456
|
this.deleteCustomEmojiDocuments(),
|
|
457
|
+
this.deleteBusinessConnections(),
|
|
438
458
|
this.deleteStickerSetNames(),
|
|
439
459
|
this.deletePeers(),
|
|
440
460
|
this.deleteUsernames(),
|
|
@@ -14,7 +14,7 @@ var _StorageIndexedDB_instances, _StorageIndexedDB_name, _StorageIndexedDB_id, _
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.StorageIndexedDB = void 0;
|
|
16
16
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
17
|
-
const
|
|
17
|
+
const _1_utilities_js_1 = require("./1_utilities.js");
|
|
18
18
|
const VERSION = 1;
|
|
19
19
|
const KV_OBJECT_STORE = "kv";
|
|
20
20
|
class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
@@ -72,10 +72,10 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
72
72
|
// deno-lint-ignore no-explicit-any
|
|
73
73
|
let tx;
|
|
74
74
|
if (v == null) {
|
|
75
|
-
tx = store.delete((0,
|
|
75
|
+
tx = store.delete((0, _1_utilities_js_1.fixKey)(k));
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
tx = store.put(v, (0,
|
|
78
|
+
tx = store.put(v, (0, _1_utilities_js_1.fixKey)(k));
|
|
79
79
|
}
|
|
80
80
|
return new Promise((res, rej) => {
|
|
81
81
|
tx.onerror = rej;
|
|
@@ -94,7 +94,7 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
94
94
|
const tx = (tx_ ?? this.database
|
|
95
95
|
.transaction(KV_OBJECT_STORE, "readonly"))
|
|
96
96
|
.objectStore(KV_OBJECT_STORE)
|
|
97
|
-
.get((0,
|
|
97
|
+
.get((0, _1_utilities_js_1.fixKey)(k));
|
|
98
98
|
return new Promise((res, rej) => {
|
|
99
99
|
tx.onerror = rej;
|
|
100
100
|
tx.onsuccess = () => {
|
|
@@ -120,10 +120,10 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
120
120
|
}
|
|
121
121
|
let keyRange;
|
|
122
122
|
if ("prefix" in filter) {
|
|
123
|
-
keyRange = (0,
|
|
123
|
+
keyRange = (0, _1_utilities_js_1.getPrefixKeyRange)((0, _1_utilities_js_1.fixKey)(filter.prefix));
|
|
124
124
|
}
|
|
125
125
|
else {
|
|
126
|
-
keyRange = IDBKeyRange.bound((0,
|
|
126
|
+
keyRange = IDBKeyRange.bound((0, _1_utilities_js_1.fixKey)(filter.start), (0, _1_utilities_js_1.fixKey)(filter.end), true, true);
|
|
127
127
|
}
|
|
128
128
|
const keys = await new Promise((res, rej) => {
|
|
129
129
|
const items = new Array();
|
|
@@ -137,7 +137,7 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
137
137
|
res(items);
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
items.push((0,
|
|
140
|
+
items.push((0, _1_utilities_js_1.restoreKey)(cursor.key));
|
|
141
141
|
if (params?.limit !== undefined && items.length >= params.limit) {
|
|
142
142
|
res(items);
|
|
143
143
|
}
|
|
@@ -14,7 +14,7 @@ var _StorageLocalStorage_prefix;
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.StorageLocalStorage = void 0;
|
|
16
16
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
17
|
-
const
|
|
17
|
+
const _1_utilities_js_1 = require("./1_utilities.js");
|
|
18
18
|
class StorageLocalStorage extends _0_storage_js_1.Storage {
|
|
19
19
|
constructor(prefix) {
|
|
20
20
|
if (typeof localStorage === "undefined") {
|
|
@@ -23,7 +23,7 @@ class StorageLocalStorage extends _0_storage_js_1.Storage {
|
|
|
23
23
|
if (prefix.length <= 0) {
|
|
24
24
|
throw new Error("Empty prefix");
|
|
25
25
|
}
|
|
26
|
-
else if (!
|
|
26
|
+
else if (!_1_utilities_js_1.WEB_STORAGE_PREFIX_EXP.test(prefix)) {
|
|
27
27
|
throw new Error("Unallowed prefix");
|
|
28
28
|
}
|
|
29
29
|
super();
|
|
@@ -42,10 +42,10 @@ class StorageLocalStorage extends _0_storage_js_1.Storage {
|
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
get(key_) {
|
|
45
|
-
const key = this.prefix + (0,
|
|
45
|
+
const key = this.prefix + (0, _1_utilities_js_1.toString)(key_);
|
|
46
46
|
const value = localStorage.getItem(key);
|
|
47
47
|
if (value != null) {
|
|
48
|
-
return (0,
|
|
48
|
+
return (0, _1_utilities_js_1.fromString)(value);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
return null;
|
|
@@ -63,28 +63,28 @@ class StorageLocalStorage extends _0_storage_js_1.Storage {
|
|
|
63
63
|
if (key.startsWith(this.prefix)) {
|
|
64
64
|
key = key.slice(this.prefix.length);
|
|
65
65
|
}
|
|
66
|
-
const parts = (0,
|
|
66
|
+
const parts = (0, _1_utilities_js_1.fromString)(key);
|
|
67
67
|
if (Array.isArray(parts)) {
|
|
68
68
|
if ("prefix" in filter) {
|
|
69
69
|
for (const [i, p] of filter.prefix.entries()) {
|
|
70
|
-
if ((0,
|
|
70
|
+
if ((0, _1_utilities_js_1.toString)(p) != (0, _1_utilities_js_1.toString)(parts[i])) {
|
|
71
71
|
continue entries;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
|
-
if (!(0,
|
|
76
|
+
if (!(0, _1_utilities_js_1.isInRange)(parts, filter.start, filter.end)) {
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
yield [parts, (0,
|
|
80
|
+
yield [parts, (0, _1_utilities_js_1.fromString)(value)];
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
set(key_, value) {
|
|
85
|
-
const key = this.prefix + (0,
|
|
85
|
+
const key = this.prefix + (0, _1_utilities_js_1.toString)(key_);
|
|
86
86
|
if (value != null) {
|
|
87
|
-
localStorage.setItem(key, (0,
|
|
87
|
+
localStorage.setItem(key, (0, _1_utilities_js_1.toString)(value));
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
90
|
localStorage.removeItem(key);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageMemory extends Storage implements Storage {
|
|
4
4
|
#private;
|
|
5
5
|
protected map: Map<string, unknown>;
|
|
6
|
-
protected messageMap: CacheMap<string, unknown>;
|
|
7
6
|
constructor(authString?: string);
|
|
8
7
|
get isMemoryStorage(): boolean;
|
|
9
8
|
initialize(): Promise<void>;
|
|
10
|
-
getMap(key: readonly StorageKeyPart[]): Map<string, unknown>;
|
|
11
|
-
getMaps(): [Map<string, unknown>, Map<string, unknown>];
|
|
12
9
|
branch(id: string): Storage;
|
|
13
10
|
get supportsFiles(): boolean;
|
|
14
11
|
get<T>(key: readonly StorageKeyPart[]): T | null;
|
|
@@ -13,9 +13,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _StorageMemory_instances, _StorageMemory_id, _StorageMemory_authString, _StorageMemory_fixKey, _StorageMemory_getEntries;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.StorageMemory = void 0;
|
|
16
|
-
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
17
16
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
18
|
-
const
|
|
17
|
+
const _1_utilities_js_1 = require("./1_utilities.js");
|
|
19
18
|
class StorageMemory extends _0_storage_js_1.Storage {
|
|
20
19
|
constructor(authString) {
|
|
21
20
|
super();
|
|
@@ -26,12 +25,6 @@ class StorageMemory extends _0_storage_js_1.Storage {
|
|
|
26
25
|
writable: true,
|
|
27
26
|
value: new Map()
|
|
28
27
|
});
|
|
29
|
-
Object.defineProperty(this, "messageMap", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: new _1_utilities_js_1.CacheMap(30000)
|
|
34
|
-
});
|
|
35
28
|
_StorageMemory_id.set(this, null);
|
|
36
29
|
_StorageMemory_authString.set(this, void 0);
|
|
37
30
|
__classPrivateFieldSet(this, _StorageMemory_authString, authString, "f");
|
|
@@ -44,17 +37,6 @@ class StorageMemory extends _0_storage_js_1.Storage {
|
|
|
44
37
|
await this.importAuthString(__classPrivateFieldGet(this, _StorageMemory_authString, "f"));
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
|
-
getMap(key) {
|
|
48
|
-
if (key[0] == "messages.messages") {
|
|
49
|
-
return this.messageMap;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return this.map;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
getMaps() {
|
|
56
|
-
return [this.map, this.messageMap];
|
|
57
|
-
}
|
|
58
40
|
branch(id) {
|
|
59
41
|
const storage = new StorageMemory();
|
|
60
42
|
__classPrivateFieldSet(storage, _StorageMemory_id, id, "f");
|
|
@@ -65,7 +47,7 @@ class StorageMemory extends _0_storage_js_1.Storage {
|
|
|
65
47
|
}
|
|
66
48
|
get(key) {
|
|
67
49
|
key = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key);
|
|
68
|
-
return this.
|
|
50
|
+
return this.map.get((0, _1_utilities_js_1.toString)(key)) ?? null;
|
|
69
51
|
}
|
|
70
52
|
*getMany(filter, params) {
|
|
71
53
|
let entries = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_getEntries).call(this);
|
|
@@ -76,17 +58,17 @@ class StorageMemory extends _0_storage_js_1.Storage {
|
|
|
76
58
|
entries = entries.slice(0, params.limit <= 0 ? 1 : params.limit);
|
|
77
59
|
}
|
|
78
60
|
entries: for (const [key, value] of entries) {
|
|
79
|
-
const parts = (0,
|
|
61
|
+
const parts = (0, _1_utilities_js_1.fromString)(key);
|
|
80
62
|
if (Array.isArray(parts)) {
|
|
81
63
|
if ("prefix" in filter) {
|
|
82
64
|
for (const [i, p] of filter.prefix.entries()) {
|
|
83
|
-
if ((0,
|
|
65
|
+
if ((0, _1_utilities_js_1.toString)(p) != (0, _1_utilities_js_1.toString)(parts[i])) {
|
|
84
66
|
continue entries;
|
|
85
67
|
}
|
|
86
68
|
}
|
|
87
69
|
}
|
|
88
70
|
else {
|
|
89
|
-
if (!(0,
|
|
71
|
+
if (!(0, _1_utilities_js_1.isInRange)(parts, filter.start, filter.end)) {
|
|
90
72
|
continue;
|
|
91
73
|
}
|
|
92
74
|
}
|
|
@@ -96,12 +78,12 @@ class StorageMemory extends _0_storage_js_1.Storage {
|
|
|
96
78
|
}
|
|
97
79
|
set(key_, value) {
|
|
98
80
|
key_ = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key_);
|
|
99
|
-
const key = (0,
|
|
81
|
+
const key = (0, _1_utilities_js_1.toString)(key_);
|
|
100
82
|
if (value != null) {
|
|
101
|
-
this.
|
|
83
|
+
this.map.set(key, value);
|
|
102
84
|
}
|
|
103
85
|
else {
|
|
104
|
-
this.
|
|
86
|
+
this.map.delete(key);
|
|
105
87
|
}
|
|
106
88
|
}
|
|
107
89
|
incr(key, by) {
|
|
@@ -118,13 +100,11 @@ _StorageMemory_id = new WeakMap(), _StorageMemory_authString = new WeakMap(), _S
|
|
|
118
100
|
}
|
|
119
101
|
}, _StorageMemory_getEntries = function _StorageMemory_getEntries() {
|
|
120
102
|
const entries = new Array();
|
|
121
|
-
for (const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
entries.push(entry);
|
|
103
|
+
for (const entry of this.map.entries()) {
|
|
104
|
+
if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null && !entry[0].startsWith("__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"))) {
|
|
105
|
+
continue;
|
|
127
106
|
}
|
|
107
|
+
entries.push(entry);
|
|
128
108
|
}
|
|
129
109
|
return entries;
|
|
130
110
|
};
|
|
@@ -14,7 +14,7 @@ var _StorageSessionStorage_prefix;
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.StorageSessionStorage = void 0;
|
|
16
16
|
const _0_storage_js_1 = require("./0_storage.js");
|
|
17
|
-
const
|
|
17
|
+
const _1_utilities_js_1 = require("./1_utilities.js");
|
|
18
18
|
class StorageSessionStorage extends _0_storage_js_1.Storage {
|
|
19
19
|
constructor(prefix) {
|
|
20
20
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -23,7 +23,7 @@ class StorageSessionStorage extends _0_storage_js_1.Storage {
|
|
|
23
23
|
if (prefix.length <= 0) {
|
|
24
24
|
throw new Error("Empty prefix");
|
|
25
25
|
}
|
|
26
|
-
else if (!
|
|
26
|
+
else if (!_1_utilities_js_1.WEB_STORAGE_PREFIX_EXP.test(prefix)) {
|
|
27
27
|
throw new Error("Unallowed prefix");
|
|
28
28
|
}
|
|
29
29
|
super();
|
|
@@ -42,10 +42,10 @@ class StorageSessionStorage extends _0_storage_js_1.Storage {
|
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
get(key_) {
|
|
45
|
-
const key = this.prefix + (0,
|
|
45
|
+
const key = this.prefix + (0, _1_utilities_js_1.toString)(key_);
|
|
46
46
|
const value = sessionStorage.getItem(key);
|
|
47
47
|
if (value != null) {
|
|
48
|
-
return (0,
|
|
48
|
+
return (0, _1_utilities_js_1.fromString)(value);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
return null;
|
|
@@ -63,28 +63,28 @@ class StorageSessionStorage extends _0_storage_js_1.Storage {
|
|
|
63
63
|
if (key.startsWith(this.prefix)) {
|
|
64
64
|
key = key.slice(this.prefix.length);
|
|
65
65
|
}
|
|
66
|
-
const parts = (0,
|
|
66
|
+
const parts = (0, _1_utilities_js_1.fromString)(key);
|
|
67
67
|
if (Array.isArray(parts)) {
|
|
68
68
|
if ("prefix" in filter) {
|
|
69
69
|
for (const [i, p] of filter.prefix.entries()) {
|
|
70
|
-
if ((0,
|
|
70
|
+
if ((0, _1_utilities_js_1.toString)(p) != (0, _1_utilities_js_1.toString)(parts[i])) {
|
|
71
71
|
continue entries;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
|
-
if (!(0,
|
|
76
|
+
if (!(0, _1_utilities_js_1.isInRange)(parts, filter.start, filter.end)) {
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
yield [parts, (0,
|
|
80
|
+
yield [parts, (0, _1_utilities_js_1.fromString)(value)];
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
set(key_, value) {
|
|
85
|
-
const key = this.prefix + (0,
|
|
85
|
+
const key = this.prefix + (0, _1_utilities_js_1.toString)(key_);
|
|
86
86
|
if (value != null) {
|
|
87
|
-
sessionStorage.setItem(key, (0,
|
|
87
|
+
sessionStorage.setItem(key, (0, _1_utilities_js_1.toString)(value));
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
90
|
sessionStorage.removeItem(key);
|