lemon-model 1.5.1 → 5.0.1
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/README.md +23 -0
- package/dist/esm/fields/index.js +108 -0
- package/dist/esm/fields/index.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core-storage.js +87 -17
- package/dist/esm/types/core-storage.js.map +1 -1
- package/dist/esm/types/core-types.js +1 -0
- package/dist/esm/types/core-types.js.map +1 -1
- package/dist/fields/index.d.ts +55 -0
- package/dist/fields/index.js +114 -0
- package/dist/fields/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types/core-storage.d.ts +12 -13
- package/dist/types/core-storage.js +90 -19
- package/dist/types/core-storage.js.map +1 -1
- package/dist/types/core-types.d.ts +38 -0
- package/dist/types/core-types.js +1 -0
- package/dist/types/core-types.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/sync/network.js +0 -273
- package/dist/esm/sync/network.js.map +0 -1
- package/dist/socket/client/index.d.ts +0 -9
- package/dist/socket/client/index.js +0 -26
- package/dist/socket/client/index.js.map +0 -1
- package/dist/socket/client/keep-alive-controller.d.ts +0 -35
- package/dist/socket/client/keep-alive-controller.js +0 -101
- package/dist/socket/client/keep-alive-controller.js.map +0 -1
- package/dist/socket/client/message-router.d.ts +0 -15
- package/dist/socket/client/message-router.js +0 -52
- package/dist/socket/client/message-router.js.map +0 -1
- package/dist/socket/client/pending-request-store.d.ts +0 -24
- package/dist/socket/client/pending-request-store.js +0 -78
- package/dist/socket/client/pending-request-store.js.map +0 -1
- package/dist/socket/client/reconnect-controller.d.ts +0 -56
- package/dist/socket/client/reconnect-controller.js +0 -177
- package/dist/socket/client/reconnect-controller.js.map +0 -1
- package/dist/socket/client/rotation-controller.d.ts +0 -32
- package/dist/socket/client/rotation-controller.js +0 -76
- package/dist/socket/client/rotation-controller.js.map +0 -1
- package/dist/socket/client/shared-timer-scheduler.d.ts +0 -17
- package/dist/socket/client/shared-timer-scheduler.js +0 -77
- package/dist/socket/client/shared-timer-scheduler.js.map +0 -1
- package/dist/socket/client/socket-client.d.ts +0 -2
- package/dist/socket/client/socket-client.js +0 -219
- package/dist/socket/client/socket-client.js.map +0 -1
- package/dist/socket/client/types.d.ts +0 -101
- package/dist/socket/client/types.js +0 -3
- package/dist/socket/client/types.js.map +0 -1
- package/dist/socket/client/websocket-client-transport.d.ts +0 -23
- package/dist/socket/client/websocket-client-transport.js +0 -152
- package/dist/socket/client/websocket-client-transport.js.map +0 -1
- package/dist/sync/network.d.ts +0 -38
- package/dist/sync/network.js +0 -278
- package/dist/sync/network.js.map +0 -1
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CORE_FIELDS = exports.CoreModel = void 0;
|
|
2
13
|
/**
|
|
3
14
|
* `core-storage.ts`
|
|
4
15
|
* - common types for core storage
|
|
@@ -8,26 +19,86 @@
|
|
|
8
19
|
* @date 2019-11-20 initial version
|
|
9
20
|
* @date 2020-01-03 support cognito-identity
|
|
10
21
|
* @date 2021-12-07 support SearchBody
|
|
22
|
+
* @date 2026-10-28 `CoreModel` as a class with `@field()` annotations (lemon-core v5 B4)
|
|
11
23
|
*
|
|
12
24
|
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
13
25
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
];
|
|
26
|
+
// field annotations for the `CoreModel` class
|
|
27
|
+
const fields_1 = require("../fields");
|
|
28
|
+
/**
|
|
29
|
+
* class: `CoreModel`
|
|
30
|
+
* - general model out of base Model to support the common usage
|
|
31
|
+
* - a class (not an interface) since 5.0.0: the fields carry `@field()` so `fieldsOf(CoreModel)` lists them.
|
|
32
|
+
* - keep public optional fields only (no methods, no private members): object literals and
|
|
33
|
+
* `interface X extends CoreModel` must keep compiling.
|
|
34
|
+
*/
|
|
35
|
+
class CoreModel {
|
|
36
|
+
}
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, fields_1.field)({ kind: 'view' }),
|
|
39
|
+
__metadata("design:type", Object)
|
|
40
|
+
], CoreModel.prototype, "$", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, fields_1.field)(),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], CoreModel.prototype, "ns", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, fields_1.field)(),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], CoreModel.prototype, "type", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, fields_1.field)(),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], CoreModel.prototype, "stereo", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, fields_1.field)(),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], CoreModel.prototype, "sid", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, fields_1.field)(),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], CoreModel.prototype, "uid", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, fields_1.field)(),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], CoreModel.prototype, "gid", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, fields_1.field)(),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], CoreModel.prototype, "lock", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, fields_1.field)(),
|
|
71
|
+
__metadata("design:type", Number)
|
|
72
|
+
], CoreModel.prototype, "next", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, fields_1.field)(),
|
|
75
|
+
__metadata("design:type", Object)
|
|
76
|
+
], CoreModel.prototype, "meta", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, fields_1.field)(),
|
|
79
|
+
__metadata("design:type", Number)
|
|
80
|
+
], CoreModel.prototype, "createdAt", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, fields_1.field)(),
|
|
83
|
+
__metadata("design:type", Number)
|
|
84
|
+
], CoreModel.prototype, "updatedAt", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, fields_1.field)(),
|
|
87
|
+
__metadata("design:type", Number)
|
|
88
|
+
], CoreModel.prototype, "deletedAt", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, fields_1.field)(),
|
|
91
|
+
__metadata("design:type", String)
|
|
92
|
+
], CoreModel.prototype, "error", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, fields_1.field)({ kind: 'internal' }),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], CoreModel.prototype, "id", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, fields_1.field)({ kind: 'internal' }),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], CoreModel.prototype, "_id", void 0);
|
|
101
|
+
exports.CoreModel = CoreModel;
|
|
102
|
+
// L1 core fields: view + data kinds of `CoreModel` (14, same order as the former literal list)
|
|
103
|
+
exports.CORE_FIELDS = (0, fields_1.fieldsOf)(CoreModel, { kinds: ['view', 'data'] });
|
|
33
104
|
//# sourceMappingURL=core-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-storage.js","sourceRoot":"","sources":["../../src/types/core-storage.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"core-storage.js","sourceRoot":"","sources":["../../src/types/core-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,8CAA8C;AAC9C,sCAA4C;AAwD5C;;;;;;GAMG;AACH,MAAa,SAAS;CAuFrB;AAhFG;IADC,IAAA,cAAK,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oCACE;AAO1B;IADC,IAAA,cAAK,GAAE;;qCACI;AAKZ;IADC,IAAA,cAAK,GAAE;;uCACS;AAKjB;IADC,IAAA,cAAK,GAAE;;yCACQ;AAKhB;IADC,IAAA,cAAK,GAAE;;sCACK;AAKb;IADC,IAAA,cAAK,GAAE;;sCACK;AAKb;IADC,IAAA,cAAK,GAAE;;sCACK;AAKb;IADC,IAAA,cAAK,GAAE;;uCACM;AAKd;IADC,IAAA,cAAK,GAAE;;uCACM;AAKd;IADC,IAAA,cAAK,GAAE;;uCACY;AAKpB;IADC,IAAA,cAAK,GAAE;;4CACW;AAKnB;IADC,IAAA,cAAK,GAAE;;4CACW;AAKnB;IADC,IAAA,cAAK,GAAE;;4CACW;AAKnB;IADC,IAAA,cAAK,GAAE;;wCACO;AAOf;IADC,IAAA,cAAK,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;;qCAChB;AAKZ;IADC,IAAA,cAAK,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;;sCACf;AAtFjB,8BAuFC;AAED,+FAA+F;AAClF,QAAA,WAAW,GAAa,IAAA,iBAAQ,EAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @date 2024-12-20 optimized `NextIdentityCognito`
|
|
11
11
|
* @date 2025-05-13 optimized `NextContext` with `Authorization` header
|
|
12
12
|
* @date 2025-06-12 optimized `SearchBody` with `knn` support
|
|
13
|
+
* @date 2026-10-30 v5 B13: `NextContext.channel` and `NextContext.trace` (`NextTrace`).
|
|
13
14
|
*
|
|
14
15
|
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
15
16
|
*/
|
|
@@ -253,6 +254,43 @@ export interface NextContext<T extends NextIdentity = NextIdentity> {
|
|
|
253
254
|
* calling depth for every handler. ( automatically increased from lambda-handler )
|
|
254
255
|
*/
|
|
255
256
|
depth?: number;
|
|
257
|
+
/**
|
|
258
|
+
* (optional) the channel of this request, set once by the receiving entry (v5 B13).
|
|
259
|
+
* - `external`: a web request with a `host` header (API Gateway, ALB, Function URL).
|
|
260
|
+
* - `internal`: a host-less web event (direct invoke) or a protocol call (relay, SNS, SQS).
|
|
261
|
+
* - `local`: the local express harness (local mode).
|
|
262
|
+
*/
|
|
263
|
+
channel?: 'external' | 'internal' | 'local';
|
|
264
|
+
/**
|
|
265
|
+
* (optional) the trace of the call chain, set by the receiving entry (v5 B13).
|
|
266
|
+
*/
|
|
267
|
+
trace?: NextTrace;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* type: `NextTrace`
|
|
271
|
+
* - the trace of a call chain across internal hops (v5 B13).
|
|
272
|
+
*/
|
|
273
|
+
export interface NextTrace {
|
|
274
|
+
/**
|
|
275
|
+
* trace id: the requestId of the first entry of the chain.
|
|
276
|
+
*/
|
|
277
|
+
tid: string;
|
|
278
|
+
/**
|
|
279
|
+
* hop count from the first entry (the first entry is `0`).
|
|
280
|
+
*/
|
|
281
|
+
hop: number;
|
|
282
|
+
/**
|
|
283
|
+
* (optional) service uri of the direct caller (the previous hop).
|
|
284
|
+
*/
|
|
285
|
+
via?: string;
|
|
286
|
+
/**
|
|
287
|
+
* (optional) requestId of the direct caller (the previous hop).
|
|
288
|
+
*/
|
|
289
|
+
pid?: string;
|
|
290
|
+
/**
|
|
291
|
+
* (optional) the first request path uri of the chain (like `context.source`).
|
|
292
|
+
*/
|
|
293
|
+
src?: string;
|
|
256
294
|
}
|
|
257
295
|
/**
|
|
258
296
|
* type: `NextHandler`
|
package/dist/types/core-types.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* @date 2024-12-20 optimized `NextIdentityCognito`
|
|
12
12
|
* @date 2025-05-13 optimized `NextContext` with `Authorization` header
|
|
13
13
|
* @date 2025-06-12 optimized `SearchBody` with `knn` support
|
|
14
|
+
* @date 2026-10-30 v5 B13: `NextContext.channel` and `NextContext.trace` (`NextTrace`).
|
|
14
15
|
*
|
|
15
16
|
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
|
|
16
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-types.js","sourceRoot":"","sources":["../../src/types/core-types.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"core-types.js","sourceRoot":"","sources":["../../src/types/core-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}
|
package/package.json
CHANGED
package/dist/esm/sync/network.js
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `sync/network.ts`
|
|
3
|
-
* - L1 network decorators: reconnect-on-death wrapper and raw wire translator.
|
|
4
|
-
* - additive to `src/socket`; free to compose with `createFilteredNetwork` (translated -> filtered -> L3).
|
|
5
|
-
*
|
|
6
|
-
* @copyright (C) 2026 LemonCloud Co Ltd. - All Rights Reserved.
|
|
7
|
-
*/
|
|
8
|
-
import { WEBSOCKET_NETWORK_SCOPE, } from '../socket/index.js';
|
|
9
|
-
/**
|
|
10
|
-
* default watchdog cadence for readyState-based death detection.
|
|
11
|
-
* needed because an in-memory `Network.close()` notifies no one (see `socket/socket.ts`); only a
|
|
12
|
-
* real `OwnedWebSocketNetwork`/`BrowserWebSocketNetwork` close notifies via `onError` (see below),
|
|
13
|
-
* so the watchdog is a fallback and can stay slow — 1s keeps idle browser cost negligible.
|
|
14
|
-
*/
|
|
15
|
-
const DEFAULT_WATCHDOG_MS = 1000;
|
|
16
|
-
/** create the L1 reconnect decorator: swaps the internal network on death, keeping instance identity for L3 */
|
|
17
|
-
export const createReconnectingNetwork = (factory, options) => new ReconnectingNetwork(factory, options);
|
|
18
|
-
/** `NetworkSupportable` decorator that transparently swaps its internal network on death */
|
|
19
|
-
class ReconnectingNetwork {
|
|
20
|
-
constructor(factory, options) {
|
|
21
|
-
var _a, _b, _c, _d;
|
|
22
|
-
this.factory = factory;
|
|
23
|
-
this._generation = 0;
|
|
24
|
-
/** connected: 정상 감시 | connecting: 후보 open 대기 | backoff: 재시도 대기 | closed: 영구 종료 */
|
|
25
|
-
this.phase = 'connected';
|
|
26
|
-
this.retryCount = 0;
|
|
27
|
-
this.lastMessageAt = Date.now();
|
|
28
|
-
this.messageHandlers = new Set();
|
|
29
|
-
this.errorHandlers = new Set();
|
|
30
|
-
this.reconnectHandlers = new Set();
|
|
31
|
-
this.baseMs = (_a = options === null || options === void 0 ? void 0 : options.baseMs) !== null && _a !== void 0 ? _a : 1000;
|
|
32
|
-
this.factor = (_b = options === null || options === void 0 ? void 0 : options.factor) !== null && _b !== void 0 ? _b : 2;
|
|
33
|
-
this.maxMs = (_c = options === null || options === void 0 ? void 0 : options.maxMs) !== null && _c !== void 0 ? _c : 30000;
|
|
34
|
-
this.maxRetries = options === null || options === void 0 ? void 0 : options.maxRetries;
|
|
35
|
-
this.idleTimeoutMs = options === null || options === void 0 ? void 0 : options.idleTimeoutMs;
|
|
36
|
-
this.delayMs = this.baseMs;
|
|
37
|
-
this.current = factory();
|
|
38
|
-
this.attach(this.current);
|
|
39
|
-
this.watchdogTimer = setInterval(() => this.watch(), (_d = options === null || options === void 0 ? void 0 : options.watchdogMs) !== null && _d !== void 0 ? _d : DEFAULT_WATCHDOG_MS);
|
|
40
|
-
}
|
|
41
|
-
/** internal network generation (0 initially, +1 per reconnect) */
|
|
42
|
-
get generation() {
|
|
43
|
-
return this._generation;
|
|
44
|
-
}
|
|
45
|
-
get readyState() {
|
|
46
|
-
return this.phase === 'closed' ? 'closed' : this.current.readyState;
|
|
47
|
-
}
|
|
48
|
-
ready() {
|
|
49
|
-
var _a, _b, _c;
|
|
50
|
-
return (_c = (_b = (_a = this.current).ready) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : Promise.resolve();
|
|
51
|
-
}
|
|
52
|
-
onOpen(handler) {
|
|
53
|
-
var _a, _b, _c;
|
|
54
|
-
return (_c = (_b = (_a = this.current).onOpen) === null || _b === void 0 ? void 0 : _b.call(_a, handler)) !== null && _c !== void 0 ? _c : (() => undefined);
|
|
55
|
-
}
|
|
56
|
-
/** while disconnected (mid-reconnect or permanently closed) this throws synchronously; no send queuing */
|
|
57
|
-
send(data) {
|
|
58
|
-
if (this.phase === 'closed')
|
|
59
|
-
throw new Error(`@network is closed - reconnectingNetwork.send`);
|
|
60
|
-
if (this.current.readyState !== 'open') {
|
|
61
|
-
throw new Error(`@network is not connected - reconnectingNetwork.send`);
|
|
62
|
-
}
|
|
63
|
-
this.current.send(data);
|
|
64
|
-
}
|
|
65
|
-
onMessage(handler) {
|
|
66
|
-
this.messageHandlers.add(handler);
|
|
67
|
-
return () => this.messageHandlers.delete(handler);
|
|
68
|
-
}
|
|
69
|
-
onError(handler) {
|
|
70
|
-
this.errorHandlers.add(handler);
|
|
71
|
-
return () => this.errorHandlers.delete(handler);
|
|
72
|
-
}
|
|
73
|
-
onReconnect(handler) {
|
|
74
|
-
this.reconnectHandlers.add(handler);
|
|
75
|
-
return () => this.reconnectHandlers.delete(handler);
|
|
76
|
-
}
|
|
77
|
-
/** options are remembered and re-applied to every reconnected generation */
|
|
78
|
-
configure(options) {
|
|
79
|
-
var _a, _b;
|
|
80
|
-
this.configured = Object.assign(Object.assign({}, this.configured), options);
|
|
81
|
-
(_b = (_a = this.current).configure) === null || _b === void 0 ? void 0 : _b.call(_a, this.configured);
|
|
82
|
-
}
|
|
83
|
-
/** stop reconnecting and close the internal network for good */
|
|
84
|
-
close(code, reason) {
|
|
85
|
-
if (this.phase === 'closed')
|
|
86
|
-
return;
|
|
87
|
-
this.phase = 'closed';
|
|
88
|
-
clearInterval(this.watchdogTimer);
|
|
89
|
-
if (this.reconnectTimer)
|
|
90
|
-
clearTimeout(this.reconnectTimer);
|
|
91
|
-
this.detach();
|
|
92
|
-
this.current.close(code, reason);
|
|
93
|
-
this.messageHandlers.clear();
|
|
94
|
-
this.errorHandlers.clear();
|
|
95
|
-
this.reconnectHandlers.clear();
|
|
96
|
-
}
|
|
97
|
-
attach(network) {
|
|
98
|
-
this.unsubscribeMessage = network.onMessage(raw => {
|
|
99
|
-
this.lastMessageAt = Date.now();
|
|
100
|
-
for (const handler of [...this.messageHandlers])
|
|
101
|
-
handler(raw);
|
|
102
|
-
});
|
|
103
|
-
this.unsubscribeError = network.onError((error, context) => {
|
|
104
|
-
for (const handler of [...this.errorHandlers])
|
|
105
|
-
handler(error, Object.assign(Object.assign({}, context), { network: this }));
|
|
106
|
-
//! `OwnedWebSocketNetwork`/`BrowserWebSocketNetwork` notify a close via onError with this scope
|
|
107
|
-
//! (see `WEBSOCKET_NETWORK_SCOPE` in `socket/websocket.ts`). other onError calls (e.g. delivery
|
|
108
|
-
//! errors) are forwarded above but do not by themselves mean the network died.
|
|
109
|
-
if (context.scope === WEBSOCKET_NETWORK_SCOPE.ownedClose ||
|
|
110
|
-
context.scope === WEBSOCKET_NETWORK_SCOPE.browserClose) {
|
|
111
|
-
this.onInnerDeath();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
detach() {
|
|
116
|
-
var _a, _b, _c;
|
|
117
|
-
(_a = this.unsubscribeMessage) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
118
|
-
(_b = this.unsubscribeError) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
119
|
-
(_c = this.unsubscribeCandidateOpen) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
120
|
-
}
|
|
121
|
-
onInnerDeath() {
|
|
122
|
-
if (this.phase === 'connected')
|
|
123
|
-
this.beginBackoff();
|
|
124
|
-
else if (this.phase === 'connecting')
|
|
125
|
-
this.failAttempt(new Error(`@candidate network died before open - reconnectingNetwork`), 'reconnectingNetwork.connect');
|
|
126
|
-
}
|
|
127
|
-
/** watchdog fallback for networks that close without notifying (e.g. in-memory `Network.close()`) */
|
|
128
|
-
watch() {
|
|
129
|
-
const state = this.current.readyState;
|
|
130
|
-
if (this.phase === 'connected') {
|
|
131
|
-
if (state === 'closing' || state === 'closed')
|
|
132
|
-
return this.beginBackoff();
|
|
133
|
-
if (this.idleTimeoutMs && Date.now() - this.lastMessageAt > this.idleTimeoutMs)
|
|
134
|
-
this.beginBackoff();
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (this.phase === 'connecting') {
|
|
138
|
-
if (state === 'open')
|
|
139
|
-
return this.settleReconnected(); // onOpen 없는 network용 fallback
|
|
140
|
-
if (state === 'closing' || state === 'closed')
|
|
141
|
-
this.onInnerDeath();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
beginBackoff() {
|
|
145
|
-
this.detach();
|
|
146
|
-
this.phase = 'backoff';
|
|
147
|
-
this.reconnectTimer = setTimeout(() => this.attemptReconnect(), this.delayMs);
|
|
148
|
-
}
|
|
149
|
-
attemptReconnect() {
|
|
150
|
-
var _a, _b;
|
|
151
|
-
if (this.phase === 'closed')
|
|
152
|
-
return;
|
|
153
|
-
if (this.maxRetries != null && this.retryCount >= this.maxRetries) {
|
|
154
|
-
this.phase = 'closed';
|
|
155
|
-
clearInterval(this.watchdogTimer);
|
|
156
|
-
const error = new Error(`@network exceeded maxRetries[${this.maxRetries}] - reconnectingNetwork`);
|
|
157
|
-
for (const handler of [...this.errorHandlers])
|
|
158
|
-
handler(error, { scope: 'reconnectingNetwork.maxRetries', network: this });
|
|
159
|
-
this.messageHandlers.clear();
|
|
160
|
-
this.errorHandlers.clear();
|
|
161
|
-
this.reconnectHandlers.clear();
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
let next;
|
|
165
|
-
try {
|
|
166
|
-
next = this.factory();
|
|
167
|
-
}
|
|
168
|
-
catch (e) {
|
|
169
|
-
this.failAttempt(e, 'reconnectingNetwork.factory');
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
this.current = next;
|
|
173
|
-
this.attach(next);
|
|
174
|
-
if (this.configured)
|
|
175
|
-
(_a = next.configure) === null || _a === void 0 ? void 0 : _a.call(next, this.configured);
|
|
176
|
-
this.phase = 'connecting';
|
|
177
|
-
//! success is declared only once the candidate actually OPENS. a factory return alone is not a
|
|
178
|
-
//! connection (a real WebSocket constructs fine while the server is down), so resetting backoff
|
|
179
|
-
//! here would degrade to a constant-rate reconnect storm with an onReconnect/tick per attempt.
|
|
180
|
-
const state = next.readyState;
|
|
181
|
-
if (state === 'open')
|
|
182
|
-
return this.settleReconnected();
|
|
183
|
-
if (state === 'closing' || state === 'closed')
|
|
184
|
-
return this.onInnerDeath();
|
|
185
|
-
this.unsubscribeCandidateOpen = (_b = next.onOpen) === null || _b === void 0 ? void 0 : _b.call(next, () => {
|
|
186
|
-
if (this.phase === 'connecting' && this.current === next)
|
|
187
|
-
this.settleReconnected();
|
|
188
|
-
});
|
|
189
|
-
//! a candidate stuck in 'connecting' is bounded by the inner network's own connect timeout
|
|
190
|
-
//! (e.g. `OwnedWebSocketNetwork.connectTimeoutMs`), which actual-closes and lands in onInnerDeath.
|
|
191
|
-
}
|
|
192
|
-
/** a reconnect attempt failed (factory throw, or candidate died before open): keep growing the backoff */
|
|
193
|
-
failAttempt(error, scope) {
|
|
194
|
-
this.detach();
|
|
195
|
-
this.retryCount++;
|
|
196
|
-
this.delayMs = Math.min(this.delayMs * this.factor, this.maxMs);
|
|
197
|
-
for (const handler of [...this.errorHandlers])
|
|
198
|
-
handler(error, { scope, network: this });
|
|
199
|
-
this.phase = 'backoff';
|
|
200
|
-
this.reconnectTimer = setTimeout(() => this.attemptReconnect(), this.delayMs);
|
|
201
|
-
}
|
|
202
|
-
/** the candidate opened: only now reset the backoff/retry budget and notify onReconnect */
|
|
203
|
-
settleReconnected() {
|
|
204
|
-
var _a;
|
|
205
|
-
(_a = this.unsubscribeCandidateOpen) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
206
|
-
this.unsubscribeCandidateOpen = undefined;
|
|
207
|
-
this.phase = 'connected';
|
|
208
|
-
this._generation++;
|
|
209
|
-
this.retryCount = 0;
|
|
210
|
-
this.delayMs = this.baseMs;
|
|
211
|
-
this.lastMessageAt = Date.now();
|
|
212
|
-
for (const handler of [...this.reconnectHandlers])
|
|
213
|
-
handler();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/** create the L1 wire translator decorator over a raw string, same slot as `createFilteredNetwork` */
|
|
217
|
-
export const createTranslatedNetwork = (source, translator) => new TranslatedNetwork(source, translator);
|
|
218
|
-
/** `NetworkSupportable` decorator that translates raw strings at the wire boundary */
|
|
219
|
-
class TranslatedNetwork {
|
|
220
|
-
constructor(source, translator) {
|
|
221
|
-
this.source = source;
|
|
222
|
-
this.translator = translator;
|
|
223
|
-
this.errorHandlers = new Set();
|
|
224
|
-
this.unsubscribeSourceError = source.onError((error, context) => this.emitError(error, context));
|
|
225
|
-
}
|
|
226
|
-
get readyState() {
|
|
227
|
-
return this.source.readyState;
|
|
228
|
-
}
|
|
229
|
-
ready() {
|
|
230
|
-
var _a, _b, _c;
|
|
231
|
-
return (_c = (_b = (_a = this.source).ready) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : Promise.resolve();
|
|
232
|
-
}
|
|
233
|
-
onOpen(handler) {
|
|
234
|
-
var _a, _b, _c;
|
|
235
|
-
return (_c = (_b = (_a = this.source).onOpen) === null || _b === void 0 ? void 0 : _b.call(_a, handler)) !== null && _c !== void 0 ? _c : (() => undefined);
|
|
236
|
-
}
|
|
237
|
-
send(data) {
|
|
238
|
-
this.source.send(this.translator.outbound ? this.translator.outbound(data) : data);
|
|
239
|
-
}
|
|
240
|
-
onMessage(handler) {
|
|
241
|
-
return this.source.onMessage(raw => {
|
|
242
|
-
let translated;
|
|
243
|
-
try {
|
|
244
|
-
translated = this.translator.inbound ? this.translator.inbound(raw) : raw;
|
|
245
|
-
}
|
|
246
|
-
catch (e) {
|
|
247
|
-
this.emitError(e, { scope: 'translatedNetwork.inbound' });
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
if (translated === undefined)
|
|
251
|
-
return; // dropped by translator
|
|
252
|
-
handler(translated);
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
configure(options) {
|
|
256
|
-
var _a, _b;
|
|
257
|
-
(_b = (_a = this.source).configure) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
|
258
|
-
}
|
|
259
|
-
onError(handler) {
|
|
260
|
-
this.errorHandlers.add(handler);
|
|
261
|
-
return () => this.errorHandlers.delete(handler);
|
|
262
|
-
}
|
|
263
|
-
close(code, reason) {
|
|
264
|
-
this.unsubscribeSourceError();
|
|
265
|
-
this.errorHandlers.clear();
|
|
266
|
-
this.source.close(code, reason);
|
|
267
|
-
}
|
|
268
|
-
emitError(error, context) {
|
|
269
|
-
for (const handler of [...this.errorHandlers])
|
|
270
|
-
handler(error, Object.assign(Object.assign({}, context), { network: this }));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
//# sourceMappingURL=network.js.map
|
|
@@ -1 +0,0 @@
|
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AAK,EAAE,2BAA2B,EAAE,CAAC,CAAC;gBAC1D,OAAO;aACV;YACD,IAAI,UAAU,KAAK,SAAS;gBAAE,OAAO,CAAC,wBAAwB;YAC9D,OAAO,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,SAAS,CAAC,OAA6B;;QAC1C,MAAA,MAAA,IAAI,CAAC,MAAM,EAAC,SAAS,mDAAG,OAAO,CAAC,CAAC;IACrC,CAAC;IAEM,OAAO,CAAC,OAA2B;QACtC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,IAAa,EAAE,MAAe;QACvC,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC9B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAEO,SAAS,CAAC,KAAU,EAAE,OAA4C;QACtE,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;YAAE,OAAO,CAAC,KAAK,kCAAO,OAAO,KAAE,OAAO,EAAE,IAAI,IAAG,CAAC;IACjG,CAAC;CACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './shared-timer-scheduler';
|
|
3
|
-
export * from './message-router';
|
|
4
|
-
export * from './pending-request-store';
|
|
5
|
-
export * from './socket-client';
|
|
6
|
-
export * from './websocket-client-transport';
|
|
7
|
-
export * from './keep-alive-controller';
|
|
8
|
-
export * from './reconnect-controller';
|
|
9
|
-
export * from './rotation-controller';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./shared-timer-scheduler"), exports);
|
|
19
|
-
__exportStar(require("./message-router"), exports);
|
|
20
|
-
__exportStar(require("./pending-request-store"), exports);
|
|
21
|
-
__exportStar(require("./socket-client"), exports);
|
|
22
|
-
__exportStar(require("./websocket-client-transport"), exports);
|
|
23
|
-
__exportStar(require("./keep-alive-controller"), exports);
|
|
24
|
-
__exportStar(require("./reconnect-controller"), exports);
|
|
25
|
-
__exportStar(require("./rotation-controller"), exports);
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/socket/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2DAAyC;AACzC,mDAAiC;AACjC,0DAAwC;AACxC,kDAAgC;AAChC,+DAA6C;AAC7C,0DAAwC;AACxC,yDAAuC;AACvC,wDAAsC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { SharedTimerScheduler, SocketRuntimePort } from './types';
|
|
2
|
-
export interface KeepAliveControllerOptions<TMessage> {
|
|
3
|
-
client: SocketRuntimePort<TMessage>;
|
|
4
|
-
buildMessage: () => TMessage;
|
|
5
|
-
intervalMs?: number;
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
maxMissedPongs?: number;
|
|
8
|
-
mode?: 'send' | 'request';
|
|
9
|
-
timerScheduler?: SharedTimerScheduler;
|
|
10
|
-
timerKey?: string;
|
|
11
|
-
onPongTimeout?: () => unknown | Promise<unknown>;
|
|
12
|
-
}
|
|
13
|
-
export declare class KeepAliveController<TMessage> {
|
|
14
|
-
private readonly client;
|
|
15
|
-
private readonly buildMessage;
|
|
16
|
-
private readonly intervalMs;
|
|
17
|
-
private readonly timeoutMs;
|
|
18
|
-
private readonly maxMissedPongs;
|
|
19
|
-
private readonly mode;
|
|
20
|
-
private readonly timerScheduler;
|
|
21
|
-
private readonly timerKey;
|
|
22
|
-
private readonly onPongTimeout;
|
|
23
|
-
private readonly unsubs;
|
|
24
|
-
private running;
|
|
25
|
-
private inFlight;
|
|
26
|
-
private missedPongs;
|
|
27
|
-
constructor(options: KeepAliveControllerOptions<TMessage>);
|
|
28
|
-
start(): void;
|
|
29
|
-
stop(): void;
|
|
30
|
-
destroy(): void;
|
|
31
|
-
private scheduleNow;
|
|
32
|
-
private scheduleNext;
|
|
33
|
-
private clearTimer;
|
|
34
|
-
private tick;
|
|
35
|
-
}
|