@hocuspocus/common 3.4.3 → 3.4.5-rc.0
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/dist/hocuspocus-common.cjs +443 -425
- package/dist/hocuspocus-common.cjs.map +1 -1
- package/dist/hocuspocus-common.esm.js +440 -424
- package/dist/hocuspocus-common.esm.js.map +1 -1
- package/dist/index.d.ts +100 -0
- package/dist/index.js +524 -0
- package/package.json +3 -3
- package/src/auth.ts +2 -1
- package/dist/node_modules/@tiptap/pm/model/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/state/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/transform/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/view/index.d.ts +0 -1
- package/dist/packages/common/src/CloseEvents.d.ts +0 -29
- package/dist/packages/common/src/auth.d.ts +0 -12
- package/dist/packages/common/src/awarenessStatesToArray.d.ts +0 -3
- package/dist/packages/common/src/index.d.ts +0 -4
- package/dist/packages/common/src/types.d.ts +0 -10
- package/dist/packages/extension-database/src/Database.d.ts +0 -30
- package/dist/packages/extension-database/src/index.d.ts +0 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +0 -67
- package/dist/packages/extension-logger/src/index.d.ts +0 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +0 -124
- package/dist/packages/extension-redis/src/index.d.ts +0 -1
- package/dist/packages/extension-s3/src/S3.d.ts +0 -44
- package/dist/packages/extension-s3/src/index.d.ts +0 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +0 -27
- package/dist/packages/extension-sqlite/src/index.d.ts +0 -1
- package/dist/packages/extension-throttle/src/index.d.ts +0 -30
- package/dist/packages/extension-webhook/src/index.d.ts +0 -56
- package/dist/packages/provider/src/EventEmitter.d.ts +0 -9
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +0 -116
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +0 -114
- package/dist/packages/provider/src/IncomingMessage.d.ts +0 -17
- package/dist/packages/provider/src/MessageReceiver.d.ts +0 -12
- package/dist/packages/provider/src/MessageSender.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +0 -8
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +0 -8
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +0 -8
- package/dist/packages/provider/src/index.d.ts +0 -3
- package/dist/packages/provider/src/types.d.ts +0 -92
- package/dist/packages/server/src/ClientConnection.d.ts +0 -63
- package/dist/packages/server/src/Connection.d.ts +0 -71
- package/dist/packages/server/src/DirectConnection.d.ts +0 -14
- package/dist/packages/server/src/Document.d.ts +0 -92
- package/dist/packages/server/src/Hocuspocus.d.ts +0 -80
- package/dist/packages/server/src/IncomingMessage.d.ts +0 -25
- package/dist/packages/server/src/MessageReceiver.d.ts +0 -11
- package/dist/packages/server/src/OutgoingMessage.d.ts +0 -23
- package/dist/packages/server/src/Server.d.ts +0 -32
- package/dist/packages/server/src/index.d.ts +0 -9
- package/dist/packages/server/src/types.d.ts +0 -342
- package/dist/packages/server/src/util/debounce.d.ts +0 -6
- package/dist/packages/server/src/util/getParameters.d.ts +0 -6
- package/dist/packages/transformer/src/Prosemirror.d.ts +0 -11
- package/dist/packages/transformer/src/Tiptap.d.ts +0 -10
- package/dist/packages/transformer/src/index.d.ts +0 -3
- package/dist/packages/transformer/src/types.d.ts +0 -5
- package/dist/playground/backend/src/default.d.ts +0 -1
- package/dist/playground/backend/src/deno.d.ts +0 -1
- package/dist/playground/backend/src/express.d.ts +0 -1
- package/dist/playground/backend/src/hono.d.ts +0 -1
- package/dist/playground/backend/src/koa.d.ts +0 -1
- package/dist/playground/backend/src/load-document.d.ts +0 -1
- package/dist/playground/backend/src/redis.d.ts +0 -1
- package/dist/playground/backend/src/s3-redis.d.ts +0 -1
- package/dist/playground/backend/src/s3.d.ts +0 -1
- package/dist/playground/backend/src/slow.d.ts +0 -1
- package/dist/playground/backend/src/tiptapcollab.d.ts +0 -1
- package/dist/playground/backend/src/webhook.d.ts +0 -1
- package/dist/playground/frontend/app/SocketContext1.d.ts +0 -2
- package/dist/playground/frontend/app/SocketContext2.d.ts +0 -2
- package/dist/playground/frontend/next.config.d.ts +0 -3
- package/dist/tests/extension-database/fetch.d.ts +0 -1
- package/dist/tests/extension-logger/onListen.d.ts +0 -1
- package/dist/tests/extension-redis/onAwarenessChange.d.ts +0 -1
- package/dist/tests/extension-redis/onChange.d.ts +0 -1
- package/dist/tests/extension-redis/onStateless.d.ts +0 -1
- package/dist/tests/extension-redis/onStoreDocument.d.ts +0 -1
- package/dist/tests/extension-s3/fetch.d.ts +0 -1
- package/dist/tests/extension-throttle/banning.d.ts +0 -1
- package/dist/tests/extension-throttle/configuration.d.ts +0 -1
- package/dist/tests/provider/hasUnsyncedChanges.d.ts +0 -1
- package/dist/tests/provider/observe.d.ts +0 -1
- package/dist/tests/provider/observeDeep.d.ts +0 -1
- package/dist/tests/provider/onAuthenticated.d.ts +0 -1
- package/dist/tests/provider/onAuthenticationFailed.d.ts +0 -1
- package/dist/tests/provider/onAwarenessChange.d.ts +0 -1
- package/dist/tests/provider/onAwarenessUpdate.d.ts +0 -1
- package/dist/tests/provider/onClose.d.ts +0 -1
- package/dist/tests/provider/onConnect.d.ts +0 -1
- package/dist/tests/provider/onDisconnect.d.ts +0 -1
- package/dist/tests/provider/onMessage.d.ts +0 -1
- package/dist/tests/provider/onOpen.d.ts +0 -1
- package/dist/tests/provider/onStateless.d.ts +0 -1
- package/dist/tests/provider/onSynced.d.ts +0 -1
- package/dist/tests/providerwebsocket/configuration.d.ts +0 -1
- package/dist/tests/server/address.d.ts +0 -1
- package/dist/tests/server/afterLoadDocument.d.ts +0 -1
- package/dist/tests/server/afterStoreDocument.d.ts +0 -1
- package/dist/tests/server/afterUnloadDocument.d.ts +0 -1
- package/dist/tests/server/beforeBroadcastStateless.d.ts +0 -1
- package/dist/tests/server/beforeHandleMessage.d.ts +0 -1
- package/dist/tests/server/beforeSync.d.ts +0 -1
- package/dist/tests/server/beforeUnloadDocument.d.ts +0 -1
- package/dist/tests/server/closeConnections.d.ts +0 -1
- package/dist/tests/server/getConnectionsCount.d.ts +0 -1
- package/dist/tests/server/getDocumentsCount.d.ts +0 -1
- package/dist/tests/server/listen.d.ts +0 -1
- package/dist/tests/server/onAuthenticate.d.ts +0 -1
- package/dist/tests/server/onAwarenessUpdate.d.ts +0 -1
- package/dist/tests/server/onChange.d.ts +0 -1
- package/dist/tests/server/onClose.d.ts +0 -1
- package/dist/tests/server/onConfigure.d.ts +0 -1
- package/dist/tests/server/onConnect.d.ts +0 -1
- package/dist/tests/server/onDestroy.d.ts +0 -1
- package/dist/tests/server/onDisconnect.d.ts +0 -1
- package/dist/tests/server/onListen.d.ts +0 -1
- package/dist/tests/server/onLoadDocument.d.ts +0 -1
- package/dist/tests/server/onRequest.d.ts +0 -1
- package/dist/tests/server/onStateless.d.ts +0 -1
- package/dist/tests/server/onStoreDocument.d.ts +0 -1
- package/dist/tests/server/onTokenSync.d.ts +0 -1
- package/dist/tests/server/onUpgrade.d.ts +0 -1
- package/dist/tests/server/openDirectConnection.d.ts +0 -1
- package/dist/tests/server/websocketError.d.ts +0 -1
- package/dist/tests/transformer/TiptapTransformer.d.ts +0 -1
- package/dist/tests/utils/createDirectory.d.ts +0 -1
- package/dist/tests/utils/flushRedis.d.ts +0 -1
- package/dist/tests/utils/index.d.ts +0 -9
- package/dist/tests/utils/newHocuspocus.d.ts +0 -2
- package/dist/tests/utils/newHocuspocusProvider.d.ts +0 -3
- package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +0 -4
- package/dist/tests/utils/randomInteger.d.ts +0 -1
- package/dist/tests/utils/redisConnectionSettings.d.ts +0 -4
- package/dist/tests/utils/removeDirectory.d.ts +0 -1
- package/dist/tests/utils/retryableAssertion.d.ts +0 -2
- package/dist/tests/utils/sleep.d.ts +0 -1
|
@@ -1,521 +1,539 @@
|
|
|
1
|
-
'
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
+
//#region node_modules/lib0/math.js
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
* Common Math expressions.
|
|
6
|
+
*
|
|
7
|
+
* @module math
|
|
8
|
+
*/
|
|
9
9
|
const floor = Math.floor;
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
* @function
|
|
12
|
+
* @param {number} a
|
|
13
|
+
* @param {number} b
|
|
14
|
+
* @return {number} The smaller element of a and b
|
|
15
|
+
*/
|
|
17
16
|
const min = (a, b) => a < b ? a : b;
|
|
18
|
-
|
|
19
17
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
* @function
|
|
19
|
+
* @param {number} a
|
|
20
|
+
* @param {number} b
|
|
21
|
+
* @return {number} The bigger element of a and b
|
|
22
|
+
*/
|
|
25
23
|
const max = (a, b) => a > b ? a : b;
|
|
24
|
+
const isNaN$1 = Number.isNaN;
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region node_modules/lib0/binary.js
|
|
29
28
|
const BIT8 = 128;
|
|
29
|
+
const BIT18 = 1 << 17;
|
|
30
|
+
const BIT19 = 1 << 18;
|
|
31
|
+
const BIT20 = 1 << 19;
|
|
32
|
+
const BIT21 = 1 << 20;
|
|
33
|
+
const BIT22 = 1 << 21;
|
|
34
|
+
const BIT23 = 1 << 22;
|
|
35
|
+
const BIT24 = 1 << 23;
|
|
36
|
+
const BIT25 = 1 << 24;
|
|
37
|
+
const BIT26 = 1 << 25;
|
|
38
|
+
const BIT27 = 1 << 26;
|
|
39
|
+
const BIT28 = 1 << 27;
|
|
40
|
+
const BIT29 = 1 << 28;
|
|
41
|
+
const BIT30 = 1 << 29;
|
|
42
|
+
const BIT31 = 1 << 30;
|
|
43
|
+
const BIT32 = 1 << 31;
|
|
30
44
|
const BITS7 = 127;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
const BITS17 = BIT18 - 1;
|
|
46
|
+
const BITS18 = BIT19 - 1;
|
|
47
|
+
const BITS19 = BIT20 - 1;
|
|
48
|
+
const BITS20 = BIT21 - 1;
|
|
49
|
+
const BITS21 = BIT22 - 1;
|
|
50
|
+
const BITS22 = BIT23 - 1;
|
|
51
|
+
const BITS23 = BIT24 - 1;
|
|
52
|
+
const BITS24 = BIT25 - 1;
|
|
53
|
+
const BITS25 = BIT26 - 1;
|
|
54
|
+
const BITS26 = BIT27 - 1;
|
|
55
|
+
const BITS27 = BIT28 - 1;
|
|
56
|
+
const BITS28 = BIT29 - 1;
|
|
57
|
+
const BITS29 = BIT30 - 1;
|
|
58
|
+
const BITS30 = BIT31 - 1;
|
|
59
|
+
/**
|
|
60
|
+
* @type {number}
|
|
61
|
+
*/
|
|
62
|
+
const BITS31 = 2147483647;
|
|
63
|
+
/**
|
|
64
|
+
* @type {number}
|
|
65
|
+
*/
|
|
66
|
+
const BITS32 = 4294967295;
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region node_modules/lib0/number.js
|
|
70
|
+
/**
|
|
71
|
+
* Utility helpers for working with numbers.
|
|
72
|
+
*
|
|
73
|
+
* @module number
|
|
74
|
+
*/
|
|
39
75
|
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*/
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
76
|
+
const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
|
|
77
|
+
const LOWEST_INT32 = 1 << 31;
|
|
78
|
+
const HIGHEST_INT32 = BITS31;
|
|
79
|
+
const HIGHEST_UINT32 = BITS32;
|
|
80
|
+
/* c8 ignore next */
|
|
81
|
+
const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
|
|
82
|
+
const isNaN = Number.isNaN;
|
|
83
|
+
const parseInt = Number.parseInt;
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region node_modules/lib0/string.js
|
|
87
|
+
/**
|
|
88
|
+
* Utility module to work with strings.
|
|
89
|
+
*
|
|
90
|
+
* @module string
|
|
91
|
+
*/
|
|
92
|
+
const fromCharCode = String.fromCharCode;
|
|
93
|
+
const fromCodePoint = String.fromCodePoint;
|
|
94
|
+
/**
|
|
95
|
+
* The largest utf16 character.
|
|
96
|
+
* Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)
|
|
97
|
+
*/
|
|
98
|
+
const MAX_UTF16_CHARACTER = fromCharCode(65535);
|
|
99
|
+
/**
|
|
100
|
+
* @param {string} str
|
|
101
|
+
* @return {Uint8Array}
|
|
102
|
+
*/
|
|
103
|
+
const _encodeUtf8Polyfill = (str) => {
|
|
104
|
+
const encodedString = unescape(encodeURIComponent(str));
|
|
105
|
+
const len = encodedString.length;
|
|
106
|
+
const buf = new Uint8Array(len);
|
|
107
|
+
for (let i = 0; i < len; i++) buf[i] = encodedString.codePointAt(i);
|
|
108
|
+
return buf;
|
|
53
109
|
};
|
|
54
|
-
|
|
55
110
|
/* c8 ignore next */
|
|
56
|
-
const utf8TextEncoder =
|
|
57
|
-
|
|
111
|
+
const utf8TextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder() : null;
|
|
58
112
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const _encodeUtf8Native = str => utf8TextEncoder.encode(str);
|
|
63
|
-
|
|
113
|
+
* @param {string} str
|
|
114
|
+
* @return {Uint8Array}
|
|
115
|
+
*/
|
|
116
|
+
const _encodeUtf8Native = (str) => utf8TextEncoder.encode(str);
|
|
64
117
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
118
|
+
* @param {string} str
|
|
119
|
+
* @return {Uint8Array}
|
|
120
|
+
*/
|
|
68
121
|
/* c8 ignore next */
|
|
69
122
|
const encodeUtf8 = utf8TextEncoder ? _encodeUtf8Native : _encodeUtf8Polyfill;
|
|
70
|
-
|
|
71
123
|
/* c8 ignore next */
|
|
72
|
-
let utf8TextDecoder = typeof TextDecoder ===
|
|
73
|
-
|
|
124
|
+
let utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8", {
|
|
125
|
+
fatal: true,
|
|
126
|
+
ignoreBOM: true
|
|
127
|
+
});
|
|
74
128
|
/* c8 ignore start */
|
|
75
|
-
if (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array()).length === 1)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* Write one byte to the encoder.
|
|
116
|
-
*
|
|
117
|
-
* @function
|
|
118
|
-
* @param {Encoder} encoder
|
|
119
|
-
* @param {number} num The byte that is to be encoded.
|
|
120
|
-
*/
|
|
129
|
+
if (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array()).length === 1)
|
|
130
|
+
/* c8 ignore next */
|
|
131
|
+
utf8TextDecoder = null;
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region node_modules/lib0/encoding.js
|
|
135
|
+
/**
|
|
136
|
+
* Efficient schema-less binary encoding with support for variable length encoding.
|
|
137
|
+
*
|
|
138
|
+
* Use [lib0/encoding] with [lib0/decoding]. Every encoding function has a corresponding decoding function.
|
|
139
|
+
*
|
|
140
|
+
* Encodes numbers in little-endian order (least to most significant byte order)
|
|
141
|
+
* and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
|
|
142
|
+
* which is also used in Protocol Buffers.
|
|
143
|
+
*
|
|
144
|
+
* ```js
|
|
145
|
+
* // encoding step
|
|
146
|
+
* const encoder = encoding.createEncoder()
|
|
147
|
+
* encoding.writeVarUint(encoder, 256)
|
|
148
|
+
* encoding.writeVarString(encoder, 'Hello world!')
|
|
149
|
+
* const buf = encoding.toUint8Array(encoder)
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* ```js
|
|
153
|
+
* // decoding step
|
|
154
|
+
* const decoder = decoding.createDecoder(buf)
|
|
155
|
+
* decoding.readVarUint(decoder) // => 256
|
|
156
|
+
* decoding.readVarString(decoder) // => 'Hello world!'
|
|
157
|
+
* decoding.hasContent(decoder) // => false - all data is read
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @module encoding
|
|
161
|
+
*/
|
|
162
|
+
/**
|
|
163
|
+
* Write one byte to the encoder.
|
|
164
|
+
*
|
|
165
|
+
* @function
|
|
166
|
+
* @param {Encoder} encoder
|
|
167
|
+
* @param {number} num The byte that is to be encoded.
|
|
168
|
+
*/
|
|
121
169
|
const write = (encoder, num) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
170
|
+
const bufferLen = encoder.cbuf.length;
|
|
171
|
+
if (encoder.cpos === bufferLen) {
|
|
172
|
+
encoder.bufs.push(encoder.cbuf);
|
|
173
|
+
encoder.cbuf = new Uint8Array(bufferLen * 2);
|
|
174
|
+
encoder.cpos = 0;
|
|
175
|
+
}
|
|
176
|
+
encoder.cbuf[encoder.cpos++] = num;
|
|
129
177
|
};
|
|
130
|
-
|
|
131
178
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
179
|
+
* Write a variable length unsigned integer. Max encodable integer is 2^53.
|
|
180
|
+
*
|
|
181
|
+
* @function
|
|
182
|
+
* @param {Encoder} encoder
|
|
183
|
+
* @param {number} num The number that is to be encoded.
|
|
184
|
+
*/
|
|
138
185
|
const writeVarUint = (encoder, num) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
186
|
+
while (num > BITS7) {
|
|
187
|
+
write(encoder, BIT8 | BITS7 & num);
|
|
188
|
+
num = floor(num / 128);
|
|
189
|
+
}
|
|
190
|
+
write(encoder, BITS7 & num);
|
|
144
191
|
};
|
|
145
|
-
|
|
146
192
|
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const _strBuffer = new Uint8Array(
|
|
193
|
+
* A cache to store strings temporarily
|
|
194
|
+
*/
|
|
195
|
+
const _strBuffer = new Uint8Array(3e4);
|
|
150
196
|
const _maxStrBSize = _strBuffer.length / 3;
|
|
151
|
-
|
|
152
197
|
/**
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
198
|
+
* Write a variable length string.
|
|
199
|
+
*
|
|
200
|
+
* @function
|
|
201
|
+
* @param {Encoder} encoder
|
|
202
|
+
* @param {String} str The string that is to be encoded.
|
|
203
|
+
*/
|
|
159
204
|
const _writeVarStringNative = (encoder, str) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
write(encoder, _strBuffer[i]);
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
writeVarUint8Array(encoder, encodeUtf8(str));
|
|
170
|
-
}
|
|
205
|
+
if (str.length < _maxStrBSize) {
|
|
206
|
+
/* c8 ignore next */
|
|
207
|
+
const written = utf8TextEncoder.encodeInto(str, _strBuffer).written || 0;
|
|
208
|
+
writeVarUint(encoder, written);
|
|
209
|
+
for (let i = 0; i < written; i++) write(encoder, _strBuffer[i]);
|
|
210
|
+
} else writeVarUint8Array(encoder, encodeUtf8(str));
|
|
171
211
|
};
|
|
172
|
-
|
|
173
212
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
213
|
+
* Write a variable length string.
|
|
214
|
+
*
|
|
215
|
+
* @function
|
|
216
|
+
* @param {Encoder} encoder
|
|
217
|
+
* @param {String} str The string that is to be encoded.
|
|
218
|
+
*/
|
|
180
219
|
const _writeVarStringPolyfill = (encoder, str) => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
write(encoder, /** @type {number} */ (encodedString.codePointAt(i)));
|
|
186
|
-
}
|
|
220
|
+
const encodedString = unescape(encodeURIComponent(str));
|
|
221
|
+
const len = encodedString.length;
|
|
222
|
+
writeVarUint(encoder, len);
|
|
223
|
+
for (let i = 0; i < len; i++) write(encoder, encodedString.codePointAt(i));
|
|
187
224
|
};
|
|
188
|
-
|
|
189
225
|
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
226
|
+
* Write a variable length string.
|
|
227
|
+
*
|
|
228
|
+
* @function
|
|
229
|
+
* @param {Encoder} encoder
|
|
230
|
+
* @param {String} str The string that is to be encoded.
|
|
231
|
+
*/
|
|
196
232
|
/* c8 ignore next */
|
|
197
|
-
const writeVarString =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*/
|
|
233
|
+
const writeVarString = utf8TextEncoder && utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
|
|
234
|
+
/**
|
|
235
|
+
* Append fixed-length Uint8Array to the encoder.
|
|
236
|
+
*
|
|
237
|
+
* @function
|
|
238
|
+
* @param {Encoder} encoder
|
|
239
|
+
* @param {Uint8Array} uint8Array
|
|
240
|
+
*/
|
|
206
241
|
const writeUint8Array = (encoder, uint8Array) => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// copy array
|
|
220
|
-
encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
|
|
221
|
-
encoder.cpos = rightCopyLen;
|
|
222
|
-
}
|
|
242
|
+
const bufferLen = encoder.cbuf.length;
|
|
243
|
+
const cpos = encoder.cpos;
|
|
244
|
+
const leftCopyLen = min(bufferLen - cpos, uint8Array.length);
|
|
245
|
+
const rightCopyLen = uint8Array.length - leftCopyLen;
|
|
246
|
+
encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
|
|
247
|
+
encoder.cpos += leftCopyLen;
|
|
248
|
+
if (rightCopyLen > 0) {
|
|
249
|
+
encoder.bufs.push(encoder.cbuf);
|
|
250
|
+
encoder.cbuf = new Uint8Array(max(bufferLen * 2, rightCopyLen));
|
|
251
|
+
encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
|
|
252
|
+
encoder.cpos = rightCopyLen;
|
|
253
|
+
}
|
|
223
254
|
};
|
|
224
|
-
|
|
225
255
|
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
256
|
+
* Append an Uint8Array to Encoder.
|
|
257
|
+
*
|
|
258
|
+
* @function
|
|
259
|
+
* @param {Encoder} encoder
|
|
260
|
+
* @param {Uint8Array} uint8Array
|
|
261
|
+
*/
|
|
232
262
|
const writeVarUint8Array = (encoder, uint8Array) => {
|
|
233
|
-
|
|
234
|
-
|
|
263
|
+
writeVarUint(encoder, uint8Array.byteLength);
|
|
264
|
+
writeUint8Array(encoder, uint8Array);
|
|
235
265
|
};
|
|
236
266
|
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region node_modules/lib0/error.js
|
|
237
269
|
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
270
|
+
* Error helpers.
|
|
271
|
+
*
|
|
272
|
+
* @module error
|
|
273
|
+
*/
|
|
243
274
|
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
275
|
+
* @param {string} s
|
|
276
|
+
* @return {Error}
|
|
277
|
+
*/
|
|
247
278
|
/* c8 ignore next */
|
|
248
|
-
const create = s => new Error(s);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const errorUnexpectedEndOfArray = create(
|
|
280
|
-
const errorIntegerOutOfRange = create(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
*/
|
|
279
|
+
const create = (s) => new Error(s);
|
|
280
|
+
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region node_modules/lib0/decoding.js
|
|
283
|
+
/**
|
|
284
|
+
* Efficient schema-less binary decoding with support for variable length encoding.
|
|
285
|
+
*
|
|
286
|
+
* Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.
|
|
287
|
+
*
|
|
288
|
+
* Encodes numbers in little-endian order (least to most significant byte order)
|
|
289
|
+
* and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
|
|
290
|
+
* which is also used in Protocol Buffers.
|
|
291
|
+
*
|
|
292
|
+
* ```js
|
|
293
|
+
* // encoding step
|
|
294
|
+
* const encoder = encoding.createEncoder()
|
|
295
|
+
* encoding.writeVarUint(encoder, 256)
|
|
296
|
+
* encoding.writeVarString(encoder, 'Hello world!')
|
|
297
|
+
* const buf = encoding.toUint8Array(encoder)
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* ```js
|
|
301
|
+
* // decoding step
|
|
302
|
+
* const decoder = decoding.createDecoder(buf)
|
|
303
|
+
* decoding.readVarUint(decoder) // => 256
|
|
304
|
+
* decoding.readVarString(decoder) // => 'Hello world!'
|
|
305
|
+
* decoding.hasContent(decoder) // => false - all data is read
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @module decoding
|
|
309
|
+
*/
|
|
310
|
+
const errorUnexpectedEndOfArray = create("Unexpected end of array");
|
|
311
|
+
const errorIntegerOutOfRange = create("Integer out of Range");
|
|
312
|
+
/**
|
|
313
|
+
* Create an Uint8Array view of the next `len` bytes and advance the position by `len`.
|
|
314
|
+
*
|
|
315
|
+
* Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.
|
|
316
|
+
* Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
|
|
317
|
+
*
|
|
318
|
+
* @function
|
|
319
|
+
* @param {Decoder} decoder The decoder instance
|
|
320
|
+
* @param {number} len The length of bytes to read
|
|
321
|
+
* @return {Uint8Array}
|
|
322
|
+
*/
|
|
293
323
|
const readUint8Array = (decoder, len) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
324
|
+
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
|
|
325
|
+
decoder.pos += len;
|
|
326
|
+
return view;
|
|
297
327
|
};
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Read variable length Uint8Array.
|
|
301
|
-
*
|
|
302
|
-
* Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.
|
|
303
|
-
* Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
|
|
304
|
-
*
|
|
305
|
-
* @function
|
|
306
|
-
* @param {Decoder} decoder
|
|
307
|
-
* @return {Uint8Array}
|
|
308
|
-
*/
|
|
309
|
-
const readVarUint8Array = decoder => readUint8Array(decoder, readVarUint(decoder));
|
|
310
|
-
|
|
311
328
|
/**
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
329
|
+
* Read variable length Uint8Array.
|
|
330
|
+
*
|
|
331
|
+
* Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.
|
|
332
|
+
* Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
|
|
333
|
+
*
|
|
334
|
+
* @function
|
|
335
|
+
* @param {Decoder} decoder
|
|
336
|
+
* @return {Uint8Array}
|
|
337
|
+
*/
|
|
338
|
+
const readVarUint8Array = (decoder) => readUint8Array(decoder, readVarUint(decoder));
|
|
339
|
+
/**
|
|
340
|
+
* Read one byte as unsigned integer.
|
|
341
|
+
* @function
|
|
342
|
+
* @param {Decoder} decoder The decoder instance
|
|
343
|
+
* @return {number} Unsigned 8-bit integer
|
|
344
|
+
*/
|
|
345
|
+
const readUint8 = (decoder) => decoder.arr[decoder.pos++];
|
|
346
|
+
/**
|
|
347
|
+
* Read unsigned integer (32bit) with variable length.
|
|
348
|
+
* 1/8th of the storage is used as encoding overhead.
|
|
349
|
+
* * numbers < 2^7 is stored in one bytlength
|
|
350
|
+
* * numbers < 2^14 is stored in two bylength
|
|
351
|
+
*
|
|
352
|
+
* @function
|
|
353
|
+
* @param {Decoder} decoder
|
|
354
|
+
* @return {number} An unsigned integer.length
|
|
355
|
+
*/
|
|
356
|
+
const readVarUint = (decoder) => {
|
|
357
|
+
let num = 0;
|
|
358
|
+
let mult = 1;
|
|
359
|
+
const len = decoder.arr.length;
|
|
360
|
+
while (decoder.pos < len) {
|
|
361
|
+
const r = decoder.arr[decoder.pos++];
|
|
362
|
+
num = num + (r & BITS7) * mult;
|
|
363
|
+
mult *= 128;
|
|
364
|
+
if (r < BIT8) return num;
|
|
365
|
+
/* c8 ignore start */
|
|
366
|
+
if (num > MAX_SAFE_INTEGER) throw errorIntegerOutOfRange;
|
|
367
|
+
}
|
|
368
|
+
throw errorUnexpectedEndOfArray;
|
|
348
369
|
};
|
|
349
|
-
|
|
350
370
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
371
|
+
* We don't test this function anymore as we use native decoding/encoding by default now.
|
|
372
|
+
* Better not modify this anymore..
|
|
373
|
+
*
|
|
374
|
+
* Transforming utf8 to a string is pretty expensive. The code performs 10x better
|
|
375
|
+
* when String.fromCodePoint is fed with all characters as arguments.
|
|
376
|
+
* But most environments have a maximum number of arguments per functions.
|
|
377
|
+
* For effiency reasons we apply a maximum of 10000 characters at once.
|
|
378
|
+
*
|
|
379
|
+
* @function
|
|
380
|
+
* @param {Decoder} decoder
|
|
381
|
+
* @return {String} The read String.
|
|
382
|
+
*/
|
|
363
383
|
/* c8 ignore start */
|
|
364
|
-
const _readVarStringPolyfill = decoder => {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
decoder.pos += nextLen;
|
|
380
|
-
// Starting with ES5.1 we can supply a generic array-like object as arguments
|
|
381
|
-
encodedString += String.fromCodePoint.apply(null, /** @type {any} */ (bytes));
|
|
382
|
-
remainingLen -= nextLen;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return decodeURIComponent(escape(encodedString))
|
|
386
|
-
}
|
|
384
|
+
const _readVarStringPolyfill = (decoder) => {
|
|
385
|
+
let remainingLen = readVarUint(decoder);
|
|
386
|
+
if (remainingLen === 0) return "";
|
|
387
|
+
else {
|
|
388
|
+
let encodedString = String.fromCodePoint(readUint8(decoder));
|
|
389
|
+
if (--remainingLen < 100) while (remainingLen--) encodedString += String.fromCodePoint(readUint8(decoder));
|
|
390
|
+
else while (remainingLen > 0) {
|
|
391
|
+
const nextLen = remainingLen < 1e4 ? remainingLen : 1e4;
|
|
392
|
+
const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen);
|
|
393
|
+
decoder.pos += nextLen;
|
|
394
|
+
encodedString += String.fromCodePoint.apply(null, bytes);
|
|
395
|
+
remainingLen -= nextLen;
|
|
396
|
+
}
|
|
397
|
+
return decodeURIComponent(escape(encodedString));
|
|
398
|
+
}
|
|
387
399
|
};
|
|
388
400
|
/* c8 ignore stop */
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* @function
|
|
392
|
-
* @param {Decoder} decoder
|
|
393
|
-
* @return {String} The read String
|
|
394
|
-
*/
|
|
395
|
-
const _readVarStringNative = decoder =>
|
|
396
|
-
/** @type any */ (utf8TextDecoder).decode(readVarUint8Array(decoder));
|
|
397
|
-
|
|
398
401
|
/**
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
402
|
+
* @function
|
|
403
|
+
* @param {Decoder} decoder
|
|
404
|
+
* @return {String} The read String
|
|
405
|
+
*/
|
|
406
|
+
const _readVarStringNative = (decoder) => utf8TextDecoder.decode(readVarUint8Array(decoder));
|
|
407
|
+
/**
|
|
408
|
+
* Read string of variable length
|
|
409
|
+
* * varUint is used to store the length of the string
|
|
410
|
+
*
|
|
411
|
+
* @function
|
|
412
|
+
* @param {Decoder} decoder
|
|
413
|
+
* @return {String} The read String
|
|
414
|
+
*
|
|
415
|
+
*/
|
|
407
416
|
/* c8 ignore next */
|
|
408
417
|
const readVarString = utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill;
|
|
409
418
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region packages/common/src/auth.ts
|
|
421
|
+
let AuthMessageType = /* @__PURE__ */ function(AuthMessageType) {
|
|
422
|
+
AuthMessageType[AuthMessageType["Token"] = 0] = "Token";
|
|
423
|
+
AuthMessageType[AuthMessageType["PermissionDenied"] = 1] = "PermissionDenied";
|
|
424
|
+
AuthMessageType[AuthMessageType["Authenticated"] = 2] = "Authenticated";
|
|
425
|
+
return AuthMessageType;
|
|
426
|
+
}({});
|
|
416
427
|
const writeAuthentication = (encoder, auth) => {
|
|
417
|
-
|
|
418
|
-
|
|
428
|
+
writeVarUint(encoder, AuthMessageType.Token);
|
|
429
|
+
writeVarString(encoder, auth);
|
|
419
430
|
};
|
|
420
431
|
const writePermissionDenied = (encoder, reason) => {
|
|
421
|
-
|
|
422
|
-
|
|
432
|
+
writeVarUint(encoder, AuthMessageType.PermissionDenied);
|
|
433
|
+
writeVarString(encoder, reason);
|
|
423
434
|
};
|
|
424
435
|
const writeAuthenticated = (encoder, scope) => {
|
|
425
|
-
|
|
426
|
-
|
|
436
|
+
writeVarUint(encoder, AuthMessageType.Authenticated);
|
|
437
|
+
writeVarString(encoder, scope);
|
|
427
438
|
};
|
|
428
439
|
const writeTokenSyncRequest = (encoder) => {
|
|
429
|
-
|
|
440
|
+
writeVarUint(encoder, AuthMessageType.Token);
|
|
430
441
|
};
|
|
431
442
|
const readAuthMessage = (decoder, sendToken, permissionDeniedHandler, authenticatedHandler) => {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
}
|
|
443
|
+
switch (readVarUint(decoder)) {
|
|
444
|
+
case AuthMessageType.Token:
|
|
445
|
+
sendToken();
|
|
446
|
+
break;
|
|
447
|
+
case AuthMessageType.PermissionDenied:
|
|
448
|
+
permissionDeniedHandler(readVarString(decoder));
|
|
449
|
+
break;
|
|
450
|
+
case AuthMessageType.Authenticated:
|
|
451
|
+
authenticatedHandler(readVarString(decoder));
|
|
452
|
+
break;
|
|
453
|
+
default:
|
|
454
|
+
}
|
|
446
455
|
};
|
|
447
456
|
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region packages/common/src/CloseEvents.ts
|
|
448
459
|
/**
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
460
|
+
* The server is terminating the connection because a data frame was received
|
|
461
|
+
* that is too large.
|
|
462
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
|
|
463
|
+
*/
|
|
453
464
|
const MessageTooBig = {
|
|
454
|
-
|
|
455
|
-
|
|
465
|
+
code: 1009,
|
|
466
|
+
reason: "Message Too Big"
|
|
456
467
|
};
|
|
457
468
|
/**
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
469
|
+
* The server successfully processed the request, asks that the requester reset
|
|
470
|
+
* its document view, and is not returning any content.
|
|
471
|
+
*/
|
|
461
472
|
const ResetConnection = {
|
|
462
|
-
|
|
463
|
-
|
|
473
|
+
code: 4205,
|
|
474
|
+
reason: "Reset Connection"
|
|
464
475
|
};
|
|
465
476
|
/**
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
477
|
+
* Similar to Forbidden, but specifically for use when authentication is required and has
|
|
478
|
+
* failed or has not yet been provided.
|
|
479
|
+
*/
|
|
469
480
|
const Unauthorized = {
|
|
470
|
-
|
|
471
|
-
|
|
481
|
+
code: 4401,
|
|
482
|
+
reason: "Unauthorized"
|
|
472
483
|
};
|
|
473
484
|
/**
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
485
|
+
* The request contained valid data and was understood by the server, but the server
|
|
486
|
+
* is refusing action.
|
|
487
|
+
*/
|
|
477
488
|
const Forbidden = {
|
|
478
|
-
|
|
479
|
-
|
|
489
|
+
code: 4403,
|
|
490
|
+
reason: "Forbidden"
|
|
480
491
|
};
|
|
481
492
|
/**
|
|
482
|
-
|
|
483
|
-
|
|
493
|
+
* The server timed out waiting for the request.
|
|
494
|
+
*/
|
|
484
495
|
const ConnectionTimeout = {
|
|
485
|
-
|
|
486
|
-
|
|
496
|
+
code: 4408,
|
|
497
|
+
reason: "Connection Timeout"
|
|
487
498
|
};
|
|
488
499
|
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region packages/common/src/awarenessStatesToArray.ts
|
|
489
502
|
const awarenessStatesToArray = (states) => {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
503
|
+
return Array.from(states.entries()).map(([key, value]) => {
|
|
504
|
+
return {
|
|
505
|
+
clientId: key,
|
|
506
|
+
...value
|
|
507
|
+
};
|
|
508
|
+
});
|
|
496
509
|
};
|
|
497
510
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region packages/common/src/types.ts
|
|
513
|
+
/**
|
|
514
|
+
* State of the WebSocket connection.
|
|
515
|
+
* https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
|
|
516
|
+
*/
|
|
517
|
+
let WsReadyStates = /* @__PURE__ */ function(WsReadyStates) {
|
|
518
|
+
WsReadyStates[WsReadyStates["Connecting"] = 0] = "Connecting";
|
|
519
|
+
WsReadyStates[WsReadyStates["Open"] = 1] = "Open";
|
|
520
|
+
WsReadyStates[WsReadyStates["Closing"] = 2] = "Closing";
|
|
521
|
+
WsReadyStates[WsReadyStates["Closed"] = 3] = "Closed";
|
|
522
|
+
return WsReadyStates;
|
|
523
|
+
}({});
|
|
524
|
+
|
|
525
|
+
//#endregion
|
|
526
|
+
exports.AuthMessageType = AuthMessageType;
|
|
510
527
|
exports.ConnectionTimeout = ConnectionTimeout;
|
|
511
528
|
exports.Forbidden = Forbidden;
|
|
512
529
|
exports.MessageTooBig = MessageTooBig;
|
|
513
530
|
exports.ResetConnection = ResetConnection;
|
|
514
531
|
exports.Unauthorized = Unauthorized;
|
|
532
|
+
exports.WsReadyStates = WsReadyStates;
|
|
515
533
|
exports.awarenessStatesToArray = awarenessStatesToArray;
|
|
516
534
|
exports.readAuthMessage = readAuthMessage;
|
|
517
535
|
exports.writeAuthenticated = writeAuthenticated;
|
|
518
536
|
exports.writeAuthentication = writeAuthentication;
|
|
519
537
|
exports.writePermissionDenied = writePermissionDenied;
|
|
520
538
|
exports.writeTokenSyncRequest = writeTokenSyncRequest;
|
|
521
|
-
//# sourceMappingURL=hocuspocus-common.cjs.map
|
|
539
|
+
//# sourceMappingURL=hocuspocus-common.cjs.map
|