@mtkruto/node 0.1.109 → 0.1.110
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_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/connection/1_connection_web_socket.js +18 -13
- package/esm/storage/0_utilities.js +1 -1
- package/esm/storage/0_utilities_test.d.ts +1 -0
- package/package.json +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/connection/1_connection_web_socket.js +18 -13
- package/script/storage/0_utilities.js +1 -1
- package/script/storage/0_utilities_test.d.ts +1 -0
package/esm/4_constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 166;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.110";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/esm/4_constants.js
CHANGED
|
@@ -54,7 +54,7 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
54
54
|
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
55
55
|
export const INITIAL_DC = "2";
|
|
56
56
|
export const LAYER = 166;
|
|
57
|
-
export const APP_VERSION = "MTKruto 0.1.
|
|
57
|
+
export const APP_VERSION = "MTKruto 0.1.110";
|
|
58
58
|
// @ts-ignore: lib
|
|
59
59
|
export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
60
60
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -9,12 +9,13 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
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");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _ConnectionWebSocket_instances, _ConnectionWebSocket_webSocket, _ConnectionWebSocket_rMutex, _ConnectionWebSocket_wMutex, _ConnectionWebSocket_buffer, _ConnectionWebSocket_nextResolve, _ConnectionWebSocket_initWs, _ConnectionWebSocket_wasConnected, _ConnectionWebSocket_isConnecting, _ConnectionWebSocket_connectionError;
|
|
12
|
+
var _ConnectionWebSocket_instances, _ConnectionWebSocket_webSocket, _ConnectionWebSocket_rMutex, _ConnectionWebSocket_wMutex, _ConnectionWebSocket_buffer, _ConnectionWebSocket_nextResolve, _ConnectionWebSocket_initWs, _ConnectionWebSocket_wasConnected, _ConnectionWebSocket_isConnecting, _ConnectionWebSocket_connectionError, _ConnectionWebSocket_assertConnected, _ConnectionWebSocket_rejectRead;
|
|
13
13
|
import * as dntShim from "../_dnt.shims.js";
|
|
14
14
|
import { debug, Mutex } from "../0_deps.js";
|
|
15
15
|
import { UNREACHABLE } from "../1_utilities.js";
|
|
16
16
|
import { ConnectionUnframed } from "./0_connection.js";
|
|
17
17
|
const d = debug("ConnectionWebSocket");
|
|
18
|
+
const errConnectionNotOpen = new Error("Connection not open");
|
|
18
19
|
export class ConnectionWebSocket extends ConnectionUnframed {
|
|
19
20
|
constructor(url) {
|
|
20
21
|
super();
|
|
@@ -68,11 +69,10 @@ export class ConnectionWebSocket extends ConnectionUnframed {
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
async read(p) {
|
|
71
|
-
|
|
72
|
-
throw new Error("Connection not open");
|
|
73
|
-
}
|
|
72
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
74
73
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_rMutex, "f").acquire();
|
|
75
74
|
try {
|
|
75
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
76
76
|
if (__classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").length < p.length) {
|
|
77
77
|
await new Promise((resolve, reject) => __classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, [p.length, { resolve, reject }], "f"));
|
|
78
78
|
}
|
|
@@ -83,11 +83,10 @@ export class ConnectionWebSocket extends ConnectionUnframed {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
async write(p) {
|
|
86
|
-
|
|
87
|
-
throw new Error("Connection not open");
|
|
88
|
-
}
|
|
86
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
89
87
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_wMutex, "f").acquire();
|
|
90
88
|
try {
|
|
89
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
91
90
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").send(p);
|
|
92
91
|
}
|
|
93
92
|
finally {
|
|
@@ -95,19 +94,16 @@ export class ConnectionWebSocket extends ConnectionUnframed {
|
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
close() {
|
|
98
|
-
|
|
99
|
-
throw new Error("Connection not open");
|
|
100
|
-
}
|
|
97
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
101
98
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").close(1000, "method");
|
|
102
|
-
|
|
103
|
-
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(new Error("Connection not open"));
|
|
104
|
-
}
|
|
99
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
102
|
_ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = new WeakMap(), _ConnectionWebSocket_wMutex = new WeakMap(), _ConnectionWebSocket_buffer = new WeakMap(), _ConnectionWebSocket_nextResolve = new WeakMap(), _ConnectionWebSocket_wasConnected = new WeakMap(), _ConnectionWebSocket_isConnecting = new WeakMap(), _ConnectionWebSocket_connectionError = new WeakMap(), _ConnectionWebSocket_instances = new WeakSet(), _ConnectionWebSocket_initWs = function _ConnectionWebSocket_initWs() {
|
|
108
103
|
const webSocket = new dntShim.WebSocket(this.url, "binary");
|
|
109
104
|
const mutex = new Mutex();
|
|
110
105
|
webSocket.addEventListener("close", () => {
|
|
106
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
111
107
|
this.stateChangeHandler?.(false);
|
|
112
108
|
});
|
|
113
109
|
webSocket.addEventListener("open", () => {
|
|
@@ -138,4 +134,13 @@ _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = ne
|
|
|
138
134
|
}
|
|
139
135
|
});
|
|
140
136
|
return webSocket;
|
|
137
|
+
}, _ConnectionWebSocket_assertConnected = function _ConnectionWebSocket_assertConnected() {
|
|
138
|
+
if (!this.connected) {
|
|
139
|
+
throw errConnectionNotOpen;
|
|
140
|
+
}
|
|
141
|
+
}, _ConnectionWebSocket_rejectRead = function _ConnectionWebSocket_rejectRead() {
|
|
142
|
+
if (__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f") != null) {
|
|
143
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(errConnectionNotOpen);
|
|
144
|
+
__classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, null, "f");
|
|
145
|
+
}
|
|
141
146
|
};
|
|
@@ -88,7 +88,7 @@ export function fromString(string) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
export function fixKey(key) {
|
|
91
|
-
return key.map((v) => typeof v === "bigint" ? String(v) : v);
|
|
91
|
+
return key.map((v) => typeof v === "bigint" ? String(ValueType.BigInt) + String(v) : typeof v === "string" ? String(ValueType.String) + v : v);
|
|
92
92
|
}
|
|
93
93
|
// Source: https://gist.github.com/inexorabletash/5462871
|
|
94
94
|
// deno-lint-ignore no-explicit-any
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/script/4_constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 166;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.110";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
80
80
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
81
81
|
exports.INITIAL_DC = "2";
|
|
82
82
|
exports.LAYER = 166;
|
|
83
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
83
|
+
exports.APP_VERSION = "MTKruto 0.1.110";
|
|
84
84
|
// @ts-ignore: lib
|
|
85
85
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
86
86
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -33,7 +33,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
33
33
|
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");
|
|
34
34
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
35
35
|
};
|
|
36
|
-
var _ConnectionWebSocket_instances, _ConnectionWebSocket_webSocket, _ConnectionWebSocket_rMutex, _ConnectionWebSocket_wMutex, _ConnectionWebSocket_buffer, _ConnectionWebSocket_nextResolve, _ConnectionWebSocket_initWs, _ConnectionWebSocket_wasConnected, _ConnectionWebSocket_isConnecting, _ConnectionWebSocket_connectionError;
|
|
36
|
+
var _ConnectionWebSocket_instances, _ConnectionWebSocket_webSocket, _ConnectionWebSocket_rMutex, _ConnectionWebSocket_wMutex, _ConnectionWebSocket_buffer, _ConnectionWebSocket_nextResolve, _ConnectionWebSocket_initWs, _ConnectionWebSocket_wasConnected, _ConnectionWebSocket_isConnecting, _ConnectionWebSocket_connectionError, _ConnectionWebSocket_assertConnected, _ConnectionWebSocket_rejectRead;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.ConnectionWebSocket = void 0;
|
|
39
39
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
@@ -41,6 +41,7 @@ const _0_deps_js_1 = require("../0_deps.js");
|
|
|
41
41
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
42
42
|
const _0_connection_js_1 = require("./0_connection.js");
|
|
43
43
|
const d = (0, _0_deps_js_1.debug)("ConnectionWebSocket");
|
|
44
|
+
const errConnectionNotOpen = new Error("Connection not open");
|
|
44
45
|
class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
45
46
|
constructor(url) {
|
|
46
47
|
super();
|
|
@@ -94,11 +95,10 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
async read(p) {
|
|
97
|
-
|
|
98
|
-
throw new Error("Connection not open");
|
|
99
|
-
}
|
|
98
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
100
99
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_rMutex, "f").acquire();
|
|
101
100
|
try {
|
|
101
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
102
102
|
if (__classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").length < p.length) {
|
|
103
103
|
await new Promise((resolve, reject) => __classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, [p.length, { resolve, reject }], "f"));
|
|
104
104
|
}
|
|
@@ -109,11 +109,10 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
async write(p) {
|
|
112
|
-
|
|
113
|
-
throw new Error("Connection not open");
|
|
114
|
-
}
|
|
112
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
115
113
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_wMutex, "f").acquire();
|
|
116
114
|
try {
|
|
115
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
117
116
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").send(p);
|
|
118
117
|
}
|
|
119
118
|
finally {
|
|
@@ -121,13 +120,9 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
close() {
|
|
124
|
-
|
|
125
|
-
throw new Error("Connection not open");
|
|
126
|
-
}
|
|
123
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
127
124
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").close(1000, "method");
|
|
128
|
-
|
|
129
|
-
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(new Error("Connection not open"));
|
|
130
|
-
}
|
|
125
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
131
126
|
}
|
|
132
127
|
}
|
|
133
128
|
exports.ConnectionWebSocket = ConnectionWebSocket;
|
|
@@ -135,6 +130,7 @@ _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = ne
|
|
|
135
130
|
const webSocket = new dntShim.WebSocket(this.url, "binary");
|
|
136
131
|
const mutex = new _0_deps_js_1.Mutex();
|
|
137
132
|
webSocket.addEventListener("close", () => {
|
|
133
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
138
134
|
this.stateChangeHandler?.(false);
|
|
139
135
|
});
|
|
140
136
|
webSocket.addEventListener("open", () => {
|
|
@@ -165,4 +161,13 @@ _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = ne
|
|
|
165
161
|
}
|
|
166
162
|
});
|
|
167
163
|
return webSocket;
|
|
164
|
+
}, _ConnectionWebSocket_assertConnected = function _ConnectionWebSocket_assertConnected() {
|
|
165
|
+
if (!this.connected) {
|
|
166
|
+
throw errConnectionNotOpen;
|
|
167
|
+
}
|
|
168
|
+
}, _ConnectionWebSocket_rejectRead = function _ConnectionWebSocket_rejectRead() {
|
|
169
|
+
if (__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f") != null) {
|
|
170
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(errConnectionNotOpen);
|
|
171
|
+
__classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, null, "f");
|
|
172
|
+
}
|
|
168
173
|
};
|
|
@@ -93,7 +93,7 @@ function fromString(string) {
|
|
|
93
93
|
}
|
|
94
94
|
exports.fromString = fromString;
|
|
95
95
|
function fixKey(key) {
|
|
96
|
-
return key.map((v) => typeof v === "bigint" ? String(v) : v);
|
|
96
|
+
return key.map((v) => typeof v === "bigint" ? String(ValueType.BigInt) + String(v) : typeof v === "string" ? String(ValueType.String) + v : v);
|
|
97
97
|
}
|
|
98
98
|
exports.fixKey = fixKey;
|
|
99
99
|
// Source: https://gist.github.com/inexorabletash/5462871
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|