@mtkruto/browser 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/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/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
|
@@ -53,7 +53,7 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
53
53
|
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
54
54
|
export const INITIAL_DC = "2";
|
|
55
55
|
export const LAYER = 166;
|
|
56
|
-
export const APP_VERSION = "MTKruto 0.1.
|
|
56
|
+
export const APP_VERSION = "MTKruto 0.1.110";
|
|
57
57
|
// @ts-ignore: lib
|
|
58
58
|
export const DEVICE_MODEL = typeof Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : Deno.build.os + "-" + Deno.build.arch;
|
|
59
59
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -9,11 +9,12 @@ 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 { debug, Mutex } from "../0_deps.js";
|
|
14
14
|
import { UNREACHABLE } from "../1_utilities.js";
|
|
15
15
|
import { ConnectionUnframed } from "./0_connection.js";
|
|
16
16
|
const d = debug("ConnectionWebSocket");
|
|
17
|
+
const errConnectionNotOpen = new Error("Connection not open");
|
|
17
18
|
export class ConnectionWebSocket extends ConnectionUnframed {
|
|
18
19
|
constructor(url) {
|
|
19
20
|
super();
|
|
@@ -67,11 +68,10 @@ export class ConnectionWebSocket extends ConnectionUnframed {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
async read(p) {
|
|
70
|
-
|
|
71
|
-
throw new Error("Connection not open");
|
|
72
|
-
}
|
|
71
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
73
72
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_rMutex, "f").acquire();
|
|
74
73
|
try {
|
|
74
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
75
75
|
if (__classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").length < p.length) {
|
|
76
76
|
await new Promise((resolve, reject) => __classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, [p.length, { resolve, reject }], "f"));
|
|
77
77
|
}
|
|
@@ -82,11 +82,10 @@ export class ConnectionWebSocket extends ConnectionUnframed {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
async write(p) {
|
|
85
|
-
|
|
86
|
-
throw new Error("Connection not open");
|
|
87
|
-
}
|
|
85
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
88
86
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_wMutex, "f").acquire();
|
|
89
87
|
try {
|
|
88
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
90
89
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").send(p);
|
|
91
90
|
}
|
|
92
91
|
finally {
|
|
@@ -94,19 +93,16 @@ export class ConnectionWebSocket extends ConnectionUnframed {
|
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
close() {
|
|
97
|
-
|
|
98
|
-
throw new Error("Connection not open");
|
|
99
|
-
}
|
|
96
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
100
97
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").close(1000, "method");
|
|
101
|
-
|
|
102
|
-
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(new Error("Connection not open"));
|
|
103
|
-
}
|
|
98
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
101
|
_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() {
|
|
107
102
|
const webSocket = new WebSocket(this.url, "binary");
|
|
108
103
|
const mutex = new Mutex();
|
|
109
104
|
webSocket.addEventListener("close", () => {
|
|
105
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
110
106
|
this.stateChangeHandler?.(false);
|
|
111
107
|
});
|
|
112
108
|
webSocket.addEventListener("open", () => {
|
|
@@ -137,4 +133,13 @@ _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = ne
|
|
|
137
133
|
}
|
|
138
134
|
});
|
|
139
135
|
return webSocket;
|
|
136
|
+
}, _ConnectionWebSocket_assertConnected = function _ConnectionWebSocket_assertConnected() {
|
|
137
|
+
if (!this.connected) {
|
|
138
|
+
throw errConnectionNotOpen;
|
|
139
|
+
}
|
|
140
|
+
}, _ConnectionWebSocket_rejectRead = function _ConnectionWebSocket_rejectRead() {
|
|
141
|
+
if (__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f") != null) {
|
|
142
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(errConnectionNotOpen);
|
|
143
|
+
__classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, null, "f");
|
|
144
|
+
}
|
|
140
145
|
};
|
|
@@ -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
|
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
|
@@ -56,7 +56,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
56
56
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
57
57
|
exports.INITIAL_DC = "2";
|
|
58
58
|
exports.LAYER = 166;
|
|
59
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
59
|
+
exports.APP_VERSION = "MTKruto 0.1.110";
|
|
60
60
|
// @ts-ignore: lib
|
|
61
61
|
exports.DEVICE_MODEL = typeof Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : Deno.build.os + "-" + Deno.build.arch;
|
|
62
62
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -10,13 +10,14 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
12
|
};
|
|
13
|
-
var _ConnectionWebSocket_instances, _ConnectionWebSocket_webSocket, _ConnectionWebSocket_rMutex, _ConnectionWebSocket_wMutex, _ConnectionWebSocket_buffer, _ConnectionWebSocket_nextResolve, _ConnectionWebSocket_initWs, _ConnectionWebSocket_wasConnected, _ConnectionWebSocket_isConnecting, _ConnectionWebSocket_connectionError;
|
|
13
|
+
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;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ConnectionWebSocket = void 0;
|
|
16
16
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
17
17
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
18
18
|
const _0_connection_js_1 = require("./0_connection.js");
|
|
19
19
|
const d = (0, _0_deps_js_1.debug)("ConnectionWebSocket");
|
|
20
|
+
const errConnectionNotOpen = new Error("Connection not open");
|
|
20
21
|
class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
21
22
|
constructor(url) {
|
|
22
23
|
super();
|
|
@@ -70,11 +71,10 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
async read(p) {
|
|
73
|
-
|
|
74
|
-
throw new Error("Connection not open");
|
|
75
|
-
}
|
|
74
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
76
75
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_rMutex, "f").acquire();
|
|
77
76
|
try {
|
|
77
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
78
78
|
if (__classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").length < p.length) {
|
|
79
79
|
await new Promise((resolve, reject) => __classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, [p.length, { resolve, reject }], "f"));
|
|
80
80
|
}
|
|
@@ -85,11 +85,10 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
async write(p) {
|
|
88
|
-
|
|
89
|
-
throw new Error("Connection not open");
|
|
90
|
-
}
|
|
88
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
91
89
|
const release = await __classPrivateFieldGet(this, _ConnectionWebSocket_wMutex, "f").acquire();
|
|
92
90
|
try {
|
|
91
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
93
92
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").send(p);
|
|
94
93
|
}
|
|
95
94
|
finally {
|
|
@@ -97,13 +96,9 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
close() {
|
|
100
|
-
|
|
101
|
-
throw new Error("Connection not open");
|
|
102
|
-
}
|
|
99
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
|
|
103
100
|
__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").close(1000, "method");
|
|
104
|
-
|
|
105
|
-
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(new Error("Connection not open"));
|
|
106
|
-
}
|
|
101
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
107
102
|
}
|
|
108
103
|
}
|
|
109
104
|
exports.ConnectionWebSocket = ConnectionWebSocket;
|
|
@@ -111,6 +106,7 @@ _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = ne
|
|
|
111
106
|
const webSocket = new WebSocket(this.url, "binary");
|
|
112
107
|
const mutex = new _0_deps_js_1.Mutex();
|
|
113
108
|
webSocket.addEventListener("close", () => {
|
|
109
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
|
|
114
110
|
this.stateChangeHandler?.(false);
|
|
115
111
|
});
|
|
116
112
|
webSocket.addEventListener("open", () => {
|
|
@@ -141,4 +137,13 @@ _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = ne
|
|
|
141
137
|
}
|
|
142
138
|
});
|
|
143
139
|
return webSocket;
|
|
140
|
+
}, _ConnectionWebSocket_assertConnected = function _ConnectionWebSocket_assertConnected() {
|
|
141
|
+
if (!this.connected) {
|
|
142
|
+
throw errConnectionNotOpen;
|
|
143
|
+
}
|
|
144
|
+
}, _ConnectionWebSocket_rejectRead = function _ConnectionWebSocket_rejectRead() {
|
|
145
|
+
if (__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f") != null) {
|
|
146
|
+
__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(errConnectionNotOpen);
|
|
147
|
+
__classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, null, "f");
|
|
148
|
+
}
|
|
144
149
|
};
|
|
@@ -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
|