@velarscript/web 0.29.2 → 0.30.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 +10 -2
- package/dist/analysis/look-values.d.ts +76 -1
- package/dist/analysis/look-values.d.ts.map +1 -1
- package/dist/analysis/look-values.js +193 -0
- package/dist/analysis/look-values.js.map +1 -1
- package/dist/analysis/reactive-names.d.ts +50 -0
- package/dist/analysis/reactive-names.d.ts.map +1 -0
- package/dist/analysis/reactive-names.js +199 -0
- package/dist/analysis/reactive-names.js.map +1 -0
- package/dist/analysis/watch-cycles.d.ts +28 -0
- package/dist/analysis/watch-cycles.d.ts.map +1 -1
- package/dist/analysis/watch-cycles.js +47 -0
- package/dist/analysis/watch-cycles.js.map +1 -1
- package/dist/analyzer.d.ts +5 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +50 -60
- package/dist/analyzer.js.map +1 -1
- package/dist/compiler.d.ts +1 -1
- package/dist/compiler.js +2 -2
- package/dist/compiler.js.map +1 -1
- package/dist/css-string.d.ts +4 -10
- package/dist/css-string.d.ts.map +1 -1
- package/dist/css-string.js +4 -27
- package/dist/css-string.js.map +1 -1
- package/dist/emitter.d.ts.map +1 -1
- package/dist/emitter.js +11 -2090
- package/dist/emitter.js.map +1 -1
- package/dist/lexer.js +63 -43
- package/dist/lexer.js.map +1 -1
- package/dist/look-static.d.ts +15 -1
- package/dist/look-static.d.ts.map +1 -1
- package/dist/look-static.js +30 -11
- package/dist/look-static.js.map +1 -1
- package/dist/look.d.ts +4 -4
- package/dist/look.d.ts.map +1 -1
- package/dist/look.js +4 -4
- package/dist/look.js.map +1 -1
- package/dist/parser.js +1 -2
- package/dist/parser.js.map +1 -1
- package/dist/runtime-sources.generated.d.ts +89 -0
- package/dist/runtime-sources.generated.d.ts.map +1 -0
- package/dist/runtime-sources.generated.js +96 -0
- package/dist/runtime-sources.generated.js.map +1 -0
- package/dist/runtime.d.ts +18 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +31 -3742
- package/dist/runtime.js.map +1 -1
- package/package.json +3 -3
- package/dist/browser-host-runtime.d.ts +0 -23
- package/dist/browser-host-runtime.d.ts.map +0 -1
- package/dist/browser-host-runtime.js +0 -29
- package/dist/browser-host-runtime.js.map +0 -1
- package/dist/reactive-bridge-runtime.d.ts +0 -6
- package/dist/reactive-bridge-runtime.d.ts.map +0 -1
- package/dist/reactive-bridge-runtime.js +0 -114
- package/dist/reactive-bridge-runtime.js.map +0 -1
- package/dist/realtime-client-runtime.d.ts +0 -3
- package/dist/realtime-client-runtime.d.ts.map +0 -1
- package/dist/realtime-client-runtime.js +0 -382
- package/dist/realtime-client-runtime.js.map +0 -1
- package/dist/runtime-foundation.d.ts +0 -7
- package/dist/runtime-foundation.d.ts.map +0 -1
- package/dist/runtime-foundation.js +0 -1676
- package/dist/runtime-foundation.js.map +0 -1
- package/dist/websocket-runtime.d.ts +0 -2
- package/dist/websocket-runtime.d.ts.map +0 -1
- package/dist/websocket-runtime.js +0 -37
- package/dist/websocket-runtime.js.map +0 -1
- package/dist/worker-runtime.d.ts +0 -2
- package/dist/worker-runtime.d.ts.map +0 -1
- package/dist/worker-runtime.js +0 -83
- package/dist/worker-runtime.js.map +0 -1
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EACL,mCAAmC,EAAE,2BAA2B,EAAE,wBAAwB,EAC1F,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EACzF,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAC1F,cAAc,GACf,MAAM,gCAAgC,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC;IACnE,CAAC,cAAc,EAAE,wBAAwB,CAAC;IAC1C,CAAC,iBAAiB,EAAE,2BAA2B,CAAC;IAChD,CAAC,YAAY,EAAE,eAAe,CAAC;IAC/B,CAAC,WAAW,EAAE,cAAc,CAAC;IAC7B,CAAC,cAAc,EAAE,iBAAiB,CAAC;IACnC,CAAC,WAAW,EAAE,cAAc,CAAC;IAC7B,CAAC,aAAa,EAAE,gBAAgB,CAAC;IACjC,CAAC,YAAY,EAAE,eAAe,CAAC;IAC/B,CAAC,eAAe,EAAE,kBAAkB,CAAC;IACrC,CAAC,eAAe,EAAE,kBAAkB,CAAC;IACrC,CAAC,aAAa,EAAE,gBAAgB,CAAC;IACjC,CAAC,gBAAgB,EAAE,mBAAmB,CAAC;IACvC,CAAC,gBAAgB,EAAE,eAAe,CAAC;CACpC,CAAC,CAAC;AAOH;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,GAAG,GAA0B,EAAE,IAAI,EAAE,GAAG,EAAE;IACxF,IAAI,MAAM,KAAK,4BAA4B;QAAE,OAAO,mCAAmC,CAAC;IACxF,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACjH,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velarscript/web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "The official VelarScript Web framework contract and browser runtime.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"velar": {
|
|
28
28
|
"extension": {
|
|
29
29
|
"kind": "application",
|
|
30
|
-
"apiVersion": "0.
|
|
30
|
+
"apiVersion": "0.14",
|
|
31
31
|
"manifestKey": "web",
|
|
32
32
|
"extends": {}
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@velarscript/compiler": "0.
|
|
36
|
+
"@velarscript/compiler": "0.30.1"
|
|
37
37
|
},
|
|
38
38
|
"exports": {
|
|
39
39
|
".": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The one refusal `velar/browser` gives when there is no browser under it.
|
|
3
|
-
*
|
|
4
|
-
* D114 0.29.0 LC-I1: "there is no browser here" is one fact, and it used to
|
|
5
|
-
* arrive in four sentences — two of them field validations ("Browser online
|
|
6
|
-
* state must be bool") that sent the author to check his own data, and two
|
|
7
|
-
* spellings of "The browser does not expose native …" that differed by a word.
|
|
8
|
-
* `velar/storage` already answers this in one sentence at the call that needed
|
|
9
|
-
* the host, and the charter's standard-library membership boundary requires the
|
|
10
|
-
* failure to arrive there rather than at the import; this is that sentence for
|
|
11
|
-
* `velar/browser`.
|
|
12
|
-
*
|
|
13
|
-
* The document is the host's own evidence: every guarded entry reads `window`,
|
|
14
|
-
* `navigator`, `location` or the document itself, and none of the four exists
|
|
15
|
-
* without it. With a document present, every entry behaves exactly as it did —
|
|
16
|
-
* an argument is still checked before the host is touched, and a clipboard
|
|
17
|
-
* outside a secure context still says so.
|
|
18
|
-
*
|
|
19
|
-
* D115 §三: it lives in its own module because `runtime.ts` is exempt from the
|
|
20
|
-
* file budget and an exempt file may shrink and may not grow.
|
|
21
|
-
*/
|
|
22
|
-
export declare const WEB_BROWSER_HOST_RUNTIME = "\nfunction __velarBrowserRequireHost(entry) {\n const value = __velarBrowserDocument;\n if (value === __velarBrowserMissingField || value === null || (typeof value !== \"object\" && typeof value !== \"function\")) {\n throw new Error(\"velar/browser requires a browser host; \" + entry + \" was called where no document exists\");\n }\n}";
|
|
23
|
-
//# sourceMappingURL=browser-host-runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-host-runtime.d.ts","sourceRoot":"","sources":["../src/browser-host-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,4VAMnC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The one refusal `velar/browser` gives when there is no browser under it.
|
|
3
|
-
*
|
|
4
|
-
* D114 0.29.0 LC-I1: "there is no browser here" is one fact, and it used to
|
|
5
|
-
* arrive in four sentences — two of them field validations ("Browser online
|
|
6
|
-
* state must be bool") that sent the author to check his own data, and two
|
|
7
|
-
* spellings of "The browser does not expose native …" that differed by a word.
|
|
8
|
-
* `velar/storage` already answers this in one sentence at the call that needed
|
|
9
|
-
* the host, and the charter's standard-library membership boundary requires the
|
|
10
|
-
* failure to arrive there rather than at the import; this is that sentence for
|
|
11
|
-
* `velar/browser`.
|
|
12
|
-
*
|
|
13
|
-
* The document is the host's own evidence: every guarded entry reads `window`,
|
|
14
|
-
* `navigator`, `location` or the document itself, and none of the four exists
|
|
15
|
-
* without it. With a document present, every entry behaves exactly as it did —
|
|
16
|
-
* an argument is still checked before the host is touched, and a clipboard
|
|
17
|
-
* outside a secure context still says so.
|
|
18
|
-
*
|
|
19
|
-
* D115 §三: it lives in its own module because `runtime.ts` is exempt from the
|
|
20
|
-
* file budget and an exempt file may shrink and may not grow.
|
|
21
|
-
*/
|
|
22
|
-
export const WEB_BROWSER_HOST_RUNTIME = `
|
|
23
|
-
function __velarBrowserRequireHost(entry) {
|
|
24
|
-
const value = __velarBrowserDocument;
|
|
25
|
-
if (value === __velarBrowserMissingField || value === null || (typeof value !== "object" && typeof value !== "function")) {
|
|
26
|
-
throw new Error("velar/browser requires a browser host; " + entry + " was called where no document exists");
|
|
27
|
-
}
|
|
28
|
-
}`;
|
|
29
|
-
//# sourceMappingURL=browser-host-runtime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-host-runtime.js","sourceRoot":"","sources":["../src/browser-host-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;EAMtC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** Web-owned late-binding bridge to its optional immutable reactive runtime provider. */
|
|
2
|
-
export declare const VELAR_REACTIVE_BRIDGE_RUNTIME: string;
|
|
3
|
-
/** Collection-only extension of the Web reactive bridge. */
|
|
4
|
-
export declare const VELAR_REACTIVE_COLLECTION_BRIDGE_RUNTIME: string;
|
|
5
|
-
export declare const VELAR_REACTIVE_BRIDGE_MODULE_SOURCE: string;
|
|
6
|
-
//# sourceMappingURL=reactive-bridge-runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactive-bridge-runtime.d.ts","sourceRoot":"","sources":["../src/reactive-bridge-runtime.ts"],"names":[],"mappings":"AAEA,yFAAyF;AACzF,eAAO,MAAM,6BAA6B,QAsD7B,CAAC;AAEd,4DAA4D;AAC5D,eAAO,MAAM,wCAAwC,QAuCxC,CAAC;AAEd,eAAO,MAAM,mCAAmC,QAcnC,CAAC"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { VELAR_RUNTIME_REGISTRY_KEY, VELAR_RUNTIME_SCHEMA_VERSION } from "@velarscript/compiler/extension";
|
|
2
|
-
/** Web-owned late-binding bridge to its optional immutable reactive runtime provider. */
|
|
3
|
-
export const VELAR_REACTIVE_BRIDGE_RUNTIME = String.raw `
|
|
4
|
-
const __velarReactiveBridgeGlobal = globalThis;
|
|
5
|
-
const __velarReactiveBridgeNativeObject = globalThis.Object;
|
|
6
|
-
const __velarReactiveBridgeNativeSymbol = globalThis.Symbol;
|
|
7
|
-
const __velarReactiveBridgeNativeTypeError = globalThis.TypeError;
|
|
8
|
-
const __velarReactiveBridgeGetOwnPropertyDescriptor = __velarReactiveBridgeNativeObject.getOwnPropertyDescriptor;
|
|
9
|
-
const __velarReactiveBridgeGetPrototypeOf = __velarReactiveBridgeGetOwnPropertyDescriptor(__velarReactiveBridgeNativeObject, "getPrototypeOf")?.value;
|
|
10
|
-
const __velarReactiveBridgeIsExtensible = __velarReactiveBridgeGetOwnPropertyDescriptor(__velarReactiveBridgeNativeObject, "isExtensible")?.value;
|
|
11
|
-
const __velarReactiveBridgeOwnSymbols = __velarReactiveBridgeGetOwnPropertyDescriptor(__velarReactiveBridgeNativeObject, "getOwnPropertySymbols")?.value;
|
|
12
|
-
const __velarReactiveBridgeSymbolFor = __velarReactiveBridgeGetOwnPropertyDescriptor(__velarReactiveBridgeNativeSymbol, "for")?.value;
|
|
13
|
-
if (typeof __velarReactiveBridgeGetOwnPropertyDescriptor !== "function" || typeof __velarReactiveBridgeGetPrototypeOf !== "function"
|
|
14
|
-
|| typeof __velarReactiveBridgeIsExtensible !== "function" || typeof __velarReactiveBridgeOwnSymbols !== "function"
|
|
15
|
-
|| typeof __velarReactiveBridgeSymbolFor !== "function") throw new __velarReactiveBridgeNativeTypeError("The JavaScript reactive bridge runtime is unavailable");
|
|
16
|
-
const __velarReactiveRuntimeKey = __velarReactiveBridgeSymbolFor(${JSON.stringify(VELAR_RUNTIME_REGISTRY_KEY)});
|
|
17
|
-
const __velarReactiveIterateKey = __velarReactiveBridgeSymbolFor("velar.reactive.iterate.v1");
|
|
18
|
-
const __velarReactiveStructureKey = __velarReactiveBridgeSymbolFor("velar.reactive.structure.v1");
|
|
19
|
-
let __velarReactiveBridge = null;
|
|
20
|
-
function __velarReactiveBridgeField(runtime, name) {
|
|
21
|
-
const descriptor = __velarReactiveBridgeGetOwnPropertyDescriptor(runtime, name);
|
|
22
|
-
if (!descriptor || !("value" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable) {
|
|
23
|
-
throw new __velarReactiveBridgeNativeTypeError("VelarScript reactive runtime field '" + name + "' is invalid");
|
|
24
|
-
}
|
|
25
|
-
return descriptor.value;
|
|
26
|
-
}
|
|
27
|
-
function __velarResolveReactiveBridge() {
|
|
28
|
-
if (__velarReactiveBridge) return __velarReactiveBridge;
|
|
29
|
-
const descriptor = __velarReactiveBridgeGetOwnPropertyDescriptor(__velarReactiveBridgeGlobal, __velarReactiveRuntimeKey);
|
|
30
|
-
if (!descriptor) return null;
|
|
31
|
-
if (!("value" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable) {
|
|
32
|
-
throw new __velarReactiveBridgeNativeTypeError("VelarScript reactive runtime registry ownership is invalid");
|
|
33
|
-
}
|
|
34
|
-
const runtime = descriptor.value;
|
|
35
|
-
if (!runtime || typeof runtime !== "object"
|
|
36
|
-
|| __velarReactiveBridgeGetPrototypeOf(runtime) !== null
|
|
37
|
-
|| __velarReactiveBridgeIsExtensible(runtime)
|
|
38
|
-
|| __velarReactiveBridgeOwnSymbols(runtime).length > 0) {
|
|
39
|
-
throw new __velarReactiveBridgeNativeTypeError("VelarScript reactive runtime ownership is invalid");
|
|
40
|
-
}
|
|
41
|
-
const version = __velarReactiveBridgeField(runtime, "version");
|
|
42
|
-
const toRaw = __velarReactiveBridgeField(runtime, "toRaw");
|
|
43
|
-
if (version !== ${JSON.stringify(VELAR_RUNTIME_SCHEMA_VERSION)}) {
|
|
44
|
-
throw new __velarReactiveBridgeNativeTypeError("VelarScript reactive runtime schema " + (typeof version === "string" ? version : "(unknown)") + " does not match this module's schema ${VELAR_RUNTIME_SCHEMA_VERSION}; one build mixed two generations of @velarscript/* — run 'npm ls @velarscript/compiler' and pin one version");
|
|
45
|
-
}
|
|
46
|
-
if (typeof toRaw !== "function") {
|
|
47
|
-
throw new __velarReactiveBridgeNativeTypeError("VelarScript reactive runtime values are invalid");
|
|
48
|
-
}
|
|
49
|
-
__velarReactiveBridge = { runtime, toRaw };
|
|
50
|
-
return __velarReactiveBridge;
|
|
51
|
-
}
|
|
52
|
-
function __velarReactiveRaw(value) {
|
|
53
|
-
const bridge = __velarResolveReactiveBridge();
|
|
54
|
-
return bridge ? bridge.toRaw(value) : value;
|
|
55
|
-
}
|
|
56
|
-
function __velarHostRaw(value) { return __velarReactiveRaw(value); }
|
|
57
|
-
`.trimStart();
|
|
58
|
-
/** Collection-only extension of the Web reactive bridge. */
|
|
59
|
-
export const VELAR_REACTIVE_COLLECTION_BRIDGE_RUNTIME = String.raw `
|
|
60
|
-
let __velarReactiveCollectionBridge = null;
|
|
61
|
-
function __velarResolveReactiveCollectionBridge() {
|
|
62
|
-
if (__velarReactiveCollectionBridge) return __velarReactiveCollectionBridge;
|
|
63
|
-
const bridge = __velarResolveReactiveBridge();
|
|
64
|
-
if (!bridge) return null;
|
|
65
|
-
const collectionRead = __velarReactiveBridgeField(bridge.runtime, "collectionRead");
|
|
66
|
-
const collectionTrigger = __velarReactiveBridgeField(bridge.runtime, "collectionTrigger");
|
|
67
|
-
const collectionUnlink = __velarReactiveBridgeField(bridge.runtime, "collectionUnlink");
|
|
68
|
-
const reactive = __velarReactiveBridgeField(bridge.runtime, "reactive");
|
|
69
|
-
const track = __velarReactiveBridgeField(bridge.runtime, "track");
|
|
70
|
-
if (typeof collectionRead !== "function" || typeof collectionTrigger !== "function"
|
|
71
|
-
|| typeof collectionUnlink !== "function" || typeof reactive !== "function" || typeof track !== "function") {
|
|
72
|
-
throw new __velarReactiveBridgeNativeTypeError("VelarScript reactive collection runtime values are invalid");
|
|
73
|
-
}
|
|
74
|
-
__velarReactiveCollectionBridge = { runtime: bridge.runtime, toRaw: bridge.toRaw, collectionRead, collectionTrigger, collectionUnlink, reactive, track };
|
|
75
|
-
return __velarReactiveCollectionBridge;
|
|
76
|
-
}
|
|
77
|
-
function __velarReactiveCollectionRead(value, key, child) {
|
|
78
|
-
if (child === undefined) child = null;
|
|
79
|
-
const bridge = __velarResolveReactiveCollectionBridge();
|
|
80
|
-
return bridge ? bridge.collectionRead(value, key, child) : child;
|
|
81
|
-
}
|
|
82
|
-
function __velarReactiveCollectionTrack(value, key = __velarReactiveIterateKey) {
|
|
83
|
-
const bridge = __velarResolveReactiveCollectionBridge();
|
|
84
|
-
if (bridge) bridge.track(bridge.toRaw(value), key);
|
|
85
|
-
}
|
|
86
|
-
function __velarReactiveCollectionLink(value, child) {
|
|
87
|
-
const bridge = __velarResolveReactiveCollectionBridge();
|
|
88
|
-
if (bridge) bridge.reactive(child, bridge.toRaw(value));
|
|
89
|
-
}
|
|
90
|
-
function __velarReactiveCollectionTrigger(value, key, iterate = true, structure = false, indexFrom = null, allKeys = false) {
|
|
91
|
-
const bridge = __velarResolveReactiveCollectionBridge();
|
|
92
|
-
if (bridge) bridge.collectionTrigger(value, key, iterate, structure, indexFrom, allKeys);
|
|
93
|
-
}
|
|
94
|
-
function __velarReactiveCollectionUnlink(value, child) {
|
|
95
|
-
const bridge = __velarResolveReactiveCollectionBridge();
|
|
96
|
-
if (bridge) bridge.collectionUnlink(value, child);
|
|
97
|
-
}
|
|
98
|
-
`.trimStart();
|
|
99
|
-
export const VELAR_REACTIVE_BRIDGE_MODULE_SOURCE = String.raw `
|
|
100
|
-
${VELAR_REACTIVE_BRIDGE_RUNTIME}
|
|
101
|
-
${VELAR_REACTIVE_COLLECTION_BRIDGE_RUNTIME}
|
|
102
|
-
export {
|
|
103
|
-
__velarReactiveIterateKey as reactiveIterateKey,
|
|
104
|
-
__velarReactiveStructureKey as reactiveStructureKey,
|
|
105
|
-
__velarReactiveRaw as reactiveRaw,
|
|
106
|
-
__velarHostRaw as hostRaw,
|
|
107
|
-
__velarReactiveCollectionRead as reactiveCollectionRead,
|
|
108
|
-
__velarReactiveCollectionTrack as reactiveCollectionTrack,
|
|
109
|
-
__velarReactiveCollectionLink as reactiveCollectionLink,
|
|
110
|
-
__velarReactiveCollectionTrigger as reactiveCollectionTrigger,
|
|
111
|
-
__velarReactiveCollectionUnlink as reactiveCollectionUnlink,
|
|
112
|
-
};
|
|
113
|
-
`.trimStart();
|
|
114
|
-
//# sourceMappingURL=reactive-bridge-runtime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactive-bridge-runtime.js","sourceRoot":"","sources":["../src/reactive-bridge-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAE3G,yFAAyF;AACzF,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;mEAaY,IAAI,CAAC,SAAS,CAAC,0BAA0B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA2BzF,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC;4LAC4H,4BAA4B;;;;;;;;;;;;;CAavN,CAAC,SAAS,EAAE,CAAC;AAEd,4DAA4D;AAC5D,MAAM,CAAC,MAAM,wCAAwC,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCjE,CAAC,SAAS,EAAE,CAAC;AAEd,MAAM,CAAC,MAAM,mCAAmC,GAAG,MAAM,CAAC,GAAG,CAAA;EAC3D,6BAA6B;EAC7B,wCAAwC;;;;;;;;;;;;CAYzC,CAAC,SAAS,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"realtime-client-runtime.d.ts","sourceRoot":"","sources":["../src/realtime-client-runtime.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,iCAAiC,QA2XjC,CAAC"}
|
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
/** Browser-owned resilient realtime client layered over `velar/websocket`. */
|
|
2
|
-
export const VELAR_WEB_REALTIME_CLIENT_RUNTIME = String.raw `
|
|
3
|
-
import { WebSocketConnection as __velarRealtimeConnection, connect as __velarRealtimeConnect } from "velar/websocket";
|
|
4
|
-
|
|
5
|
-
const __velarRealtimeClients = new WeakMap();
|
|
6
|
-
const __velarRealtimeApply = Reflect.apply;
|
|
7
|
-
const __velarRealtimeArrayIsArray = Array.isArray;
|
|
8
|
-
const __velarRealtimeArrayPush = Array.prototype.push;
|
|
9
|
-
const __velarRealtimeFreeze = Object.freeze;
|
|
10
|
-
const __velarRealtimeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
11
|
-
const __velarRealtimeGetOwnPropertyNames = Object.getOwnPropertyNames;
|
|
12
|
-
const __velarRealtimeArrayIncludes = Array.prototype.includes;
|
|
13
|
-
const __velarRealtimeNumberIsFinite = Number.isFinite;
|
|
14
|
-
const __velarRealtimeNumberIsSafeInteger = Number.isSafeInteger;
|
|
15
|
-
const __velarRealtimeMathMax = Math.max;
|
|
16
|
-
const __velarRealtimeMathRound = Math.round;
|
|
17
|
-
const __velarRealtimeRandom = Math.random;
|
|
18
|
-
const __velarRealtimeSetTimeout = globalThis.setTimeout;
|
|
19
|
-
const __velarRealtimeClearTimeout = globalThis.clearTimeout;
|
|
20
|
-
const __velarRealtimePromise = Promise;
|
|
21
|
-
const __velarRealtimePromiseReject = Promise.reject;
|
|
22
|
-
const __velarRealtimePromiseResolve = Promise.resolve;
|
|
23
|
-
const __velarRealtimeStringCharCodeAt = String.prototype.charCodeAt;
|
|
24
|
-
const __velarRealtimeWeakMapGet = WeakMap.prototype.get;
|
|
25
|
-
const __velarRealtimeWeakMapHas = WeakMap.prototype.has;
|
|
26
|
-
const __velarRealtimeWeakMapSet = WeakMap.prototype.set;
|
|
27
|
-
const __velarRealtimeOptionNames = __velarRealtimeFreeze(["connectTimeout", "maxMessageBytes", "maxQueuedMessages", "maxQueuedBytes", "maxPendingSendBytes", "reconnectDelays", "reconnectJitter", "retryInitial"]);
|
|
28
|
-
const __velarRealtimeDefaultDelays = __velarRealtimeFreeze([0, 1000, 2000, 5000, 10000, 30000]);
|
|
29
|
-
|
|
30
|
-
export class RealtimeUnavailableError extends Error {
|
|
31
|
-
constructor(message = "Realtime client is not connected") { super(message); this.name = "RealtimeUnavailableError"; }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function __velarRealtimeCall(operation, receiver, arguments_) { return __velarRealtimeApply(operation, receiver, arguments_); }
|
|
35
|
-
function __velarRealtimeRejected(failure) { return __velarRealtimeCall(__velarRealtimePromiseReject, __velarRealtimePromise, [failure]); }
|
|
36
|
-
function __velarRealtimeResolved(value) { return __velarRealtimeCall(__velarRealtimePromiseResolve, __velarRealtimePromise, [value]); }
|
|
37
|
-
|
|
38
|
-
function __velarRealtimeRecord(value, label, allowed = null) {
|
|
39
|
-
if (value === null || typeof value !== "object" || __velarRealtimeCall(__velarRealtimeArrayIsArray, Array, [value])) throw new TypeError(label + " must be a record");
|
|
40
|
-
const names = __velarRealtimeCall(__velarRealtimeGetOwnPropertyNames, Object, [value]);
|
|
41
|
-
for (let index = 0; index < names.length; index += 1) {
|
|
42
|
-
const name = names[index];
|
|
43
|
-
if (allowed !== null && !__velarRealtimeCall(__velarRealtimeArrayIncludes, allowed, [name])) throw new TypeError(label + " has unknown field '" + name + "'");
|
|
44
|
-
const descriptor = __velarRealtimeCall(__velarRealtimeGetOwnPropertyDescriptor, Object, [value, name]);
|
|
45
|
-
if (!descriptor?.enumerable || !("value" in descriptor)) throw new TypeError(label + " fields must be enumerable data values");
|
|
46
|
-
}
|
|
47
|
-
return value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function __velarRealtimeOption(options, name) {
|
|
51
|
-
const descriptor = __velarRealtimeCall(__velarRealtimeGetOwnPropertyDescriptor, Object, [options, name]);
|
|
52
|
-
return descriptor && "value" in descriptor ? descriptor.value : undefined;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function __velarRealtimeInteger(value, fallback, minimum, maximum, label) {
|
|
56
|
-
if (value === undefined || value === null) return fallback;
|
|
57
|
-
if (!__velarRealtimeCall(__velarRealtimeNumberIsSafeInteger, Number, [value]) || value < minimum || value > maximum) throw new RangeError(label + " must be an integer from " + minimum + " through " + maximum);
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function __velarRealtimeDuration(value, fallback, label) {
|
|
62
|
-
if (value === undefined || value === null) return fallback;
|
|
63
|
-
if (typeof value !== "string") throw new TypeError(label + " must be Duration");
|
|
64
|
-
const match = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(ms|s)$/.exec(value);
|
|
65
|
-
if (!match) throw new TypeError(label + " must be Duration such as 5s");
|
|
66
|
-
const milliseconds = Number(match[1]) * (match[2] === "s" ? 1000 : 1);
|
|
67
|
-
if (!__velarRealtimeCall(__velarRealtimeNumberIsFinite, Number, [milliseconds]) || milliseconds < 0 || milliseconds > 2147483647) throw new RangeError(label + " is outside the supported range");
|
|
68
|
-
return milliseconds;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function __velarRealtimeDelays(value) {
|
|
72
|
-
if (value === undefined || value === null) return __velarRealtimeDefaultDelays;
|
|
73
|
-
if (!__velarRealtimeCall(__velarRealtimeArrayIsArray, Array, [value])) throw new TypeError("Realtime reconnectDelays must be List<Duration>");
|
|
74
|
-
if (value.length > 32) throw new RangeError("Realtime reconnectDelays cannot contain more than 32 entries");
|
|
75
|
-
const delays = [];
|
|
76
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
77
|
-
const descriptor = __velarRealtimeCall(__velarRealtimeGetOwnPropertyDescriptor, Object, [value, index]);
|
|
78
|
-
if (!descriptor?.enumerable || !("value" in descriptor)) throw new TypeError("Realtime reconnectDelays must be a dense List<Duration>");
|
|
79
|
-
__velarRealtimeCall(__velarRealtimeArrayPush, delays, [__velarRealtimeDuration(descriptor.value, 0, "Realtime reconnect delay")]);
|
|
80
|
-
}
|
|
81
|
-
return __velarRealtimeFreeze(delays);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function __velarRealtimeOptions(value = {}) {
|
|
85
|
-
const options = __velarRealtimeRecord(value, "Realtime client options", __velarRealtimeOptionNames);
|
|
86
|
-
const jitter = __velarRealtimeOption(options, "reconnectJitter") ?? 0.2;
|
|
87
|
-
if (typeof jitter !== "number" || !__velarRealtimeCall(__velarRealtimeNumberIsFinite, Number, [jitter]) || jitter < 0 || jitter > 1) throw new RangeError("Realtime reconnectJitter must be from 0 through 1");
|
|
88
|
-
const retryInitial = __velarRealtimeOption(options, "retryInitial") ?? false;
|
|
89
|
-
if (typeof retryInitial !== "boolean") throw new TypeError("Realtime retryInitial must be bool");
|
|
90
|
-
return __velarRealtimeFreeze({
|
|
91
|
-
connectTimeout: __velarRealtimeDuration(__velarRealtimeOption(options, "connectTimeout"), 10000, "Realtime connectTimeout"),
|
|
92
|
-
maxMessageBytes: __velarRealtimeInteger(__velarRealtimeOption(options, "maxMessageBytes"), 16 * 1024 * 1024, 1, 64 * 1024 * 1024, "Realtime maxMessageBytes"),
|
|
93
|
-
maxQueuedMessages: __velarRealtimeInteger(__velarRealtimeOption(options, "maxQueuedMessages"), 256, 1, 10000, "Realtime maxQueuedMessages"),
|
|
94
|
-
maxQueuedBytes: __velarRealtimeInteger(__velarRealtimeOption(options, "maxQueuedBytes"), 16 * 1024 * 1024, 1, 64 * 1024 * 1024, "Realtime maxQueuedBytes"),
|
|
95
|
-
maxPendingSendBytes: __velarRealtimeInteger(__velarRealtimeOption(options, "maxPendingSendBytes"), 16 * 1024 * 1024, 1, 64 * 1024 * 1024, "Realtime maxPendingSendBytes"),
|
|
96
|
-
reconnectDelays: __velarRealtimeDelays(__velarRealtimeOption(options, "reconnectDelays")),
|
|
97
|
-
reconnectJitter: jitter,
|
|
98
|
-
retryInitial,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function __velarRealtimeCodec(value) {
|
|
103
|
-
const codec = __velarRealtimeRecord(value, "Realtime codec", ["decode", "encode"]);
|
|
104
|
-
const decode = __velarRealtimeOption(codec, "decode");
|
|
105
|
-
const encode = __velarRealtimeOption(codec, "encode");
|
|
106
|
-
if (typeof decode !== "function" || typeof encode !== "function") throw new TypeError("Realtime codec requires decode and encode functions");
|
|
107
|
-
return __velarRealtimeFreeze({decode, encode});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function __velarRealtimeCallback(value, label) {
|
|
111
|
-
if (value !== null && typeof value !== "function") throw new TypeError(label + " must be a function or null");
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function __velarRealtimeFailure(phase, failure, recoverable) {
|
|
116
|
-
const error = failure instanceof Error ? failure : new Error("Realtime " + phase + " failed");
|
|
117
|
-
return __velarRealtimeFreeze({phase, error, recoverable});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function __velarRealtimeUtf8Size(value, maximum) {
|
|
121
|
-
let size = 0;
|
|
122
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
123
|
-
const code = __velarRealtimeCall(__velarRealtimeStringCharCodeAt, value, [index]);
|
|
124
|
-
if (code < 0x80) size += 1;
|
|
125
|
-
else if (code < 0x800) size += 2;
|
|
126
|
-
else if (code >= 0xd800 && code <= 0xdbff && index + 1 < value.length) {
|
|
127
|
-
const following = __velarRealtimeCall(__velarRealtimeStringCharCodeAt, value, [index + 1]);
|
|
128
|
-
if (following >= 0xdc00 && following <= 0xdfff) { size += 4; index += 1; }
|
|
129
|
-
else size += 3;
|
|
130
|
-
} else size += 3;
|
|
131
|
-
if (size > maximum) return size;
|
|
132
|
-
}
|
|
133
|
-
return size;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function __velarRealtimeClientState(client) {
|
|
137
|
-
const state = __velarRealtimeCall(__velarRealtimeWeakMapGet, __velarRealtimeClients, [client]);
|
|
138
|
-
if (!state) throw new TypeError("RealtimeClient method requires a RealtimeClient receiver");
|
|
139
|
-
return state;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function __velarRealtimeTransition(client, next) {
|
|
143
|
-
const state = __velarRealtimeClientState(client);
|
|
144
|
-
if (state.status === next) return __velarRealtimeResolved(null);
|
|
145
|
-
state.status = next;
|
|
146
|
-
if (state.stateChanged === null) return __velarRealtimeResolved(null);
|
|
147
|
-
return __velarRealtimeResolved(state.stateChanged(client, next));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function __velarRealtimeWait(state, milliseconds) {
|
|
151
|
-
if (milliseconds <= 0) return __velarRealtimeResolved(null);
|
|
152
|
-
return new __velarRealtimePromise(resolve => {
|
|
153
|
-
const timer = __velarRealtimeSetTimeout(() => {
|
|
154
|
-
if (state.delayWake === null) return;
|
|
155
|
-
state.delayWake = null;
|
|
156
|
-
resolve(null);
|
|
157
|
-
}, milliseconds);
|
|
158
|
-
state.delayWake = () => {
|
|
159
|
-
__velarRealtimeClearTimeout(timer);
|
|
160
|
-
state.delayWake = null;
|
|
161
|
-
resolve(null);
|
|
162
|
-
};
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function __velarRealtimeReconnectDelay(state, attempt) {
|
|
167
|
-
if (attempt >= state.options.reconnectDelays.length) return null;
|
|
168
|
-
const base = state.options.reconnectDelays[attempt];
|
|
169
|
-
if (base === 0 || state.options.reconnectJitter === 0) return base;
|
|
170
|
-
const spread = base * state.options.reconnectJitter;
|
|
171
|
-
const rounded = __velarRealtimeCall(__velarRealtimeMathRound, Math, [base - spread + __velarRealtimeCall(__velarRealtimeRandom, Math, []) * spread * 2]);
|
|
172
|
-
return __velarRealtimeCall(__velarRealtimeMathMax, Math, [0, rounded]);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async function __velarRealtimeFailureAction(state, client, failure) {
|
|
176
|
-
if (state.failed === null) return failure.recoverable ? "reconnect" : "stop";
|
|
177
|
-
const action = await state.failed(failure, client);
|
|
178
|
-
if (action !== "continue" && action !== "reconnect" && action !== "stop") throw new TypeError("Realtime client failure callback returned an invalid action");
|
|
179
|
-
if (!failure.recoverable && action === "continue") return "stop";
|
|
180
|
-
return action;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function __velarRealtimeResolveOpen(state) {
|
|
184
|
-
const waiters = state.openWaiters;
|
|
185
|
-
state.openWaiters = [];
|
|
186
|
-
for (let index = 0; index < waiters.length; index += 1) waiters[index].resolve(state.generation);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function __velarRealtimeRejectOpen(state, failure) {
|
|
190
|
-
const waiters = state.openWaiters;
|
|
191
|
-
state.openWaiters = [];
|
|
192
|
-
for (let index = 0; index < waiters.length; index += 1) waiters[index].reject(failure);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
async function __velarRealtimeCloseFailedConnection(state, client) {
|
|
196
|
-
const connection = state.connection;
|
|
197
|
-
if (connection === null) return;
|
|
198
|
-
try { await connection.close(1011, "Realtime client callback failed"); } catch {}
|
|
199
|
-
let close = {code: 1006, reason: "Realtime client callback failed"};
|
|
200
|
-
try { close = await connection.closeInfo(); } catch {}
|
|
201
|
-
state.connection = null;
|
|
202
|
-
if (state.closed !== null) {
|
|
203
|
-
try { await state.closed(client, close); } catch {}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
async function __velarRealtimeRun(client) {
|
|
208
|
-
const state = __velarRealtimeClientState(client);
|
|
209
|
-
let reconnectAttempt = 0;
|
|
210
|
-
let openedOnce = false;
|
|
211
|
-
try {
|
|
212
|
-
while (!state.stopping) {
|
|
213
|
-
await __velarRealtimeTransition(client, openedOnce ? "reconnecting" : "connecting");
|
|
214
|
-
let connection;
|
|
215
|
-
try {
|
|
216
|
-
const url = typeof state.url === "function" ? state.url() : state.url;
|
|
217
|
-
if (typeof url !== "string") throw new TypeError("Realtime URL provider must return text");
|
|
218
|
-
connection = await __velarRealtimeConnect(url, {
|
|
219
|
-
timeout: state.options.connectTimeout + "ms",
|
|
220
|
-
maxMessageBytes: state.options.maxMessageBytes,
|
|
221
|
-
maxQueuedMessages: state.options.maxQueuedMessages,
|
|
222
|
-
maxQueuedBytes: state.options.maxQueuedBytes,
|
|
223
|
-
maxPendingSendBytes: state.options.maxPendingSendBytes,
|
|
224
|
-
});
|
|
225
|
-
} catch (failure) {
|
|
226
|
-
const problem = __velarRealtimeFailure("connect", failure, true);
|
|
227
|
-
const action = await __velarRealtimeFailureAction(state, client, problem);
|
|
228
|
-
const canRetry = action === "reconnect" && (openedOnce || state.options.retryInitial);
|
|
229
|
-
const delay = canRetry ? __velarRealtimeReconnectDelay(state, reconnectAttempt) : null;
|
|
230
|
-
if (delay === null) { __velarRealtimeRejectOpen(state, problem.error); break; }
|
|
231
|
-
reconnectAttempt += 1;
|
|
232
|
-
await __velarRealtimeWait(state, delay);
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
state.connection = __velarRealtimeConnection.parse(connection);
|
|
236
|
-
if (state.stopping) { await connection.close(1000, "Realtime client stopped"); break; }
|
|
237
|
-
state.generation += 1;
|
|
238
|
-
reconnectAttempt = 0;
|
|
239
|
-
await __velarRealtimeTransition(client, "open");
|
|
240
|
-
try {
|
|
241
|
-
if (state.opened !== null) await state.opened(client, __velarRealtimeFreeze({generation: state.generation, reconnected: openedOnce}));
|
|
242
|
-
} catch (failure) {
|
|
243
|
-
const problem = __velarRealtimeFailure("opened", failure, false);
|
|
244
|
-
await __velarRealtimeFailureAction(state, client, problem);
|
|
245
|
-
__velarRealtimeRejectOpen(state, problem.error);
|
|
246
|
-
await connection.close(1011, "Realtime client setup failed");
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
openedOnce = true;
|
|
250
|
-
__velarRealtimeResolveOpen(state);
|
|
251
|
-
let reconnect = false;
|
|
252
|
-
while (!state.stopping) {
|
|
253
|
-
let wire;
|
|
254
|
-
try { wire = await connection.next(); }
|
|
255
|
-
catch (failure) {
|
|
256
|
-
const action = await __velarRealtimeFailureAction(state, client, __velarRealtimeFailure("transport", failure, true));
|
|
257
|
-
reconnect = action === "reconnect";
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
if (wire === null) break;
|
|
261
|
-
let message;
|
|
262
|
-
try { message = __velarRealtimeCall(state.codec.decode, undefined, [wire]); }
|
|
263
|
-
catch (failure) {
|
|
264
|
-
const action = await __velarRealtimeFailureAction(state, client, __velarRealtimeFailure("decode", failure, true));
|
|
265
|
-
if (action === "continue") continue;
|
|
266
|
-
reconnect = action === "reconnect";
|
|
267
|
-
await connection.close(1007, "Realtime message is invalid");
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
try { await state.receive(message, client); }
|
|
271
|
-
catch (failure) {
|
|
272
|
-
const action = await __velarRealtimeFailureAction(state, client, __velarRealtimeFailure("receive", failure, true));
|
|
273
|
-
if (action === "continue") continue;
|
|
274
|
-
reconnect = action === "reconnect";
|
|
275
|
-
await connection.close(1011, "Realtime message handler failed");
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
const close = await connection.closeInfo();
|
|
280
|
-
state.connection = null;
|
|
281
|
-
if (state.closed !== null) await state.closed(client, close);
|
|
282
|
-
if (state.stopping) break;
|
|
283
|
-
if (!reconnect) reconnect = close.code === 1001 || close.code === 1006 || close.code === 1011 || close.code === 1012 || close.code === 1013;
|
|
284
|
-
const delay = reconnect ? __velarRealtimeReconnectDelay(state, reconnectAttempt) : null;
|
|
285
|
-
if (delay === null) break;
|
|
286
|
-
reconnectAttempt += 1;
|
|
287
|
-
await __velarRealtimeWait(state, delay);
|
|
288
|
-
}
|
|
289
|
-
} catch (failure) {
|
|
290
|
-
const error = failure instanceof Error ? failure : new Error("Realtime client failed");
|
|
291
|
-
await __velarRealtimeCloseFailedConnection(state, client);
|
|
292
|
-
__velarRealtimeRejectOpen(state, error);
|
|
293
|
-
state.runnerFailure = error;
|
|
294
|
-
} finally {
|
|
295
|
-
state.connection = null;
|
|
296
|
-
state.stopping = true;
|
|
297
|
-
try { await __velarRealtimeTransition(client, "closed"); }
|
|
298
|
-
catch (failure) { if (state.runnerFailure === null) state.runnerFailure = failure instanceof Error ? failure : new Error("Realtime state callback failed"); }
|
|
299
|
-
__velarRealtimeRejectOpen(state, new RealtimeUnavailableError("Realtime client closed before opening"));
|
|
300
|
-
state.resolveDone(null);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const __velarRealtimeClientPrototype = __velarRealtimeFreeze({
|
|
305
|
-
state() { return __velarRealtimeClientState(this).status; },
|
|
306
|
-
generation() { return __velarRealtimeClientState(this).generation; },
|
|
307
|
-
start() {
|
|
308
|
-
const state = __velarRealtimeClientState(this);
|
|
309
|
-
if (state.status === "closed") return __velarRealtimeRejected(new RealtimeUnavailableError("Realtime client is closed"));
|
|
310
|
-
const opening = this.whenOpen();
|
|
311
|
-
if (state.runner === null) state.runner = __velarRealtimeRun(this);
|
|
312
|
-
return (async () => { await opening; return null; })();
|
|
313
|
-
},
|
|
314
|
-
whenOpen() {
|
|
315
|
-
const state = __velarRealtimeClientState(this);
|
|
316
|
-
if (state.status === "open") return __velarRealtimeResolved(state.generation);
|
|
317
|
-
if (state.status === "closed") return __velarRealtimeRejected(new RealtimeUnavailableError("Realtime client is closed"));
|
|
318
|
-
if (state.openWaiters.length >= 256) return __velarRealtimeRejected(new RealtimeUnavailableError("Realtime open waiter limit exceeded"));
|
|
319
|
-
return new __velarRealtimePromise((resolve, reject) => __velarRealtimeCall(__velarRealtimeArrayPush, state.openWaiters, [{resolve, reject}]));
|
|
320
|
-
},
|
|
321
|
-
async whenClosed() {
|
|
322
|
-
const state = __velarRealtimeClientState(this);
|
|
323
|
-
await state.done;
|
|
324
|
-
if (state.runnerFailure !== null) throw state.runnerFailure;
|
|
325
|
-
return null;
|
|
326
|
-
},
|
|
327
|
-
send(value) {
|
|
328
|
-
const state = __velarRealtimeClientState(this);
|
|
329
|
-
if (state.status !== "open" || state.connection === null) return __velarRealtimeRejected(new RealtimeUnavailableError());
|
|
330
|
-
let wire;
|
|
331
|
-
try { wire = __velarRealtimeCall(state.codec.encode, undefined, [value]); }
|
|
332
|
-
catch (failure) { return __velarRealtimeRejected(failure); }
|
|
333
|
-
return state.connection.send(wire);
|
|
334
|
-
},
|
|
335
|
-
async close(code = 1000, reason = "") {
|
|
336
|
-
const state = __velarRealtimeClientState(this);
|
|
337
|
-
if (state.status === "closed") return null;
|
|
338
|
-
if (!__velarRealtimeCall(__velarRealtimeNumberIsSafeInteger, Number, [code]) || code < 1000 || code > 4999) throw new RangeError("Realtime close code must be from 1000 through 4999");
|
|
339
|
-
if (typeof reason !== "string" || __velarRealtimeUtf8Size(reason, 123) > 123) throw new RangeError("Realtime close reason cannot exceed 123 UTF-8 bytes");
|
|
340
|
-
state.stopping = true;
|
|
341
|
-
if (state.delayWake !== null) state.delayWake();
|
|
342
|
-
if (state.connection !== null) await state.connection.close(code, reason);
|
|
343
|
-
if (state.runner !== null) await this.whenClosed();
|
|
344
|
-
else {
|
|
345
|
-
try { await __velarRealtimeTransition(this, "closed"); }
|
|
346
|
-
catch (failure) { state.runnerFailure = failure instanceof Error ? failure : new Error("Realtime state callback failed"); }
|
|
347
|
-
__velarRealtimeRejectOpen(state, new RealtimeUnavailableError("Realtime client closed before opening"));
|
|
348
|
-
state.resolveDone(null);
|
|
349
|
-
if (state.runnerFailure !== null) throw state.runnerFailure;
|
|
350
|
-
}
|
|
351
|
-
return null;
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
export function realtimeClient(url, codec, receive, opened = null, failed = null, closed = null, stateChanged = null, options = {}) {
|
|
356
|
-
if (typeof url !== "string" && typeof url !== "function") throw new TypeError("realtimeClient URL must be text or a zero-argument function");
|
|
357
|
-
codec = __velarRealtimeCodec(codec);
|
|
358
|
-
if (typeof receive !== "function") throw new TypeError("realtimeClient receive must be a function");
|
|
359
|
-
opened = __velarRealtimeCallback(opened, "realtimeClient opened");
|
|
360
|
-
failed = __velarRealtimeCallback(failed, "realtimeClient failed");
|
|
361
|
-
closed = __velarRealtimeCallback(closed, "realtimeClient closed");
|
|
362
|
-
stateChanged = __velarRealtimeCallback(stateChanged, "realtimeClient stateChanged");
|
|
363
|
-
let resolveDone;
|
|
364
|
-
const done = new __velarRealtimePromise(resolve => { resolveDone = resolve; });
|
|
365
|
-
const client = Object.create(__velarRealtimeClientPrototype);
|
|
366
|
-
__velarRealtimeCall(__velarRealtimeWeakMapSet, __velarRealtimeClients, [client, {url, codec, receive, opened, failed, closed, stateChanged, options: __velarRealtimeOptions(options), status: "idle", generation: 0, connection: null, runner: null, runnerFailure: null, stopping: false, delayWake: null, openWaiters: [], done, resolveDone}]);
|
|
367
|
-
return __velarRealtimeFreeze(client);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
const __velarRealtimeClientType = __velarRealtimeFreeze({is(value) { return __velarRealtimeCall(__velarRealtimeWeakMapHas, __velarRealtimeClients, [value]); }, parse(value) { if (!this.is(value)) throw new TypeError("Value does not match RealtimeClient"); return value; }});
|
|
371
|
-
const __velarRealtimeCodecType = __velarRealtimeFreeze({is(value) { try { __velarRealtimeCodec(value); return true; } catch { return false; } }, parse(value) { return __velarRealtimeCodec(value); }});
|
|
372
|
-
const __velarRealtimeFailureType = __velarRealtimeFreeze({is(value) { return value !== null && typeof value === "object" && typeof value.phase === "string" && value.error instanceof Error && typeof value.recoverable === "boolean"; }, parse(value) { if (!this.is(value)) throw new TypeError("Value does not match RealtimeFailure"); return value; }});
|
|
373
|
-
const __velarRealtimeOpenType = __velarRealtimeFreeze({is(value) { return value !== null && typeof value === "object" && Number.isSafeInteger(value.generation) && typeof value.reconnected === "boolean"; }, parse(value) { if (!this.is(value)) throw new TypeError("Value does not match RealtimeOpen"); return value; }});
|
|
374
|
-
|
|
375
|
-
export const RealtimeClient = __velarRealtimeFreeze({...__velarRealtimeClientType, of() { return __velarRealtimeClientType; }});
|
|
376
|
-
export const RealtimeCodec = __velarRealtimeFreeze({...__velarRealtimeCodecType, of() { return __velarRealtimeCodecType; }});
|
|
377
|
-
export const RealtimeFailure = __velarRealtimeFailureType;
|
|
378
|
-
export const RealtimeOpen = __velarRealtimeOpenType;
|
|
379
|
-
export const RealtimeClientState = __velarRealtimeFreeze({idle: "idle", connecting: "connecting", open: "open", reconnecting: "reconnecting", closed: "closed", is(value) { return value === "idle" || value === "connecting" || value === "open" || value === "reconnecting" || value === "closed"; }, parse(value) { if (!this.is(value)) throw new TypeError("Value does not match RealtimeClientState"); return value; }, values() { return ["idle", "connecting", "open", "reconnecting", "closed"]; }});
|
|
380
|
-
export const RealtimeClientFailureAction = __velarRealtimeFreeze({continue: "continue", reconnect: "reconnect", stop: "stop", is(value) { return value === "continue" || value === "reconnect" || value === "stop"; }, parse(value) { if (!this.is(value)) throw new TypeError("Value does not match RealtimeClientFailureAction"); return value; }, values() { return ["continue", "reconnect", "stop"]; }});
|
|
381
|
-
`.trimStart();
|
|
382
|
-
//# sourceMappingURL=realtime-client-runtime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"realtime-client-runtime.js","sourceRoot":"","sources":["../src/realtime-client-runtime.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2X1D,CAAC,SAAS,EAAE,CAAC"}
|