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