@rsbuild/core 2.0.0-beta.0 → 2.0.0-beta.10
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/compiled/chokidar/index.d.ts +197 -29
- package/compiled/chokidar/package.json +1 -1
- package/compiled/connect-next/index.d.ts +56 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/index.js +2 -2
- package/compiled/css-loader/package.json +1 -1
- package/compiled/html-rspack-plugin/index.d.ts +102 -1
- package/compiled/html-rspack-plugin/index.js +863 -20
- package/compiled/html-rspack-plugin/package.json +1 -1
- package/compiled/http-proxy-middleware/index.d.ts +268 -43
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/jiti/LICENSE +21 -0
- package/compiled/jiti/README.md +243 -0
- package/compiled/jiti/dist/babel.cjs +46699 -0
- package/compiled/jiti/dist/jiti.cjs +4842 -0
- package/compiled/jiti/lib/jiti-cli.mjs +19 -0
- package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
- package/compiled/jiti/lib/jiti-native.mjs +76 -0
- package/compiled/jiti/lib/jiti-register.d.mts +1 -0
- package/compiled/jiti/lib/jiti-register.mjs +2 -0
- package/compiled/jiti/lib/jiti.cjs +24 -0
- package/compiled/jiti/lib/jiti.d.cts +8 -0
- package/compiled/jiti/lib/jiti.d.mts +8 -0
- package/compiled/jiti/lib/jiti.mjs +23 -0
- package/compiled/jiti/lib/types.d.ts +363 -0
- package/compiled/jiti/package.json +133 -0
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/postcss/lib/comment.d.ts +1 -1
- package/compiled/postcss/lib/container.d.ts +1 -1
- package/compiled/postcss/lib/css-syntax-error.d.ts +1 -1
- package/compiled/postcss/lib/declaration.d.ts +1 -1
- package/compiled/postcss/lib/document.d.ts +1 -1
- package/compiled/postcss/lib/input.d.ts +1 -1
- package/compiled/postcss/lib/lazy-result.d.ts +1 -1
- package/compiled/postcss/lib/no-work-result.d.ts +1 -1
- package/compiled/postcss/lib/node.d.ts +1 -1
- package/compiled/postcss/lib/previous-map.d.ts +1 -1
- package/compiled/postcss/lib/processor.d.ts +1 -1
- package/compiled/postcss/lib/result.d.ts +1 -1
- package/compiled/postcss/lib/root.d.ts +1 -1
- package/compiled/postcss/lib/rule.d.ts +1 -1
- package/compiled/postcss/lib/stringifier.d.ts +1 -1
- package/compiled/postcss/lib/warning.d.ts +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +10 -9
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/rslog/index.d.ts +33 -2
- package/compiled/rslog/package.json +1 -1
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +0 -5
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/style-loader/index.js +37 -94
- package/compiled/style-loader/package.json +1 -1
- package/dist/{131.js → 958.js} +1706 -1655
- package/dist/chokidar.js +59 -57
- package/dist/client/hmr.js +3 -3
- package/dist/client/overlay.js +2 -2
- package/dist/connect-next.js +268 -0
- package/dist/{connect.js.LICENSE.txt → connect-next.js.LICENSE.txt} +3 -13
- package/dist/cors.js +2 -2
- package/dist/http-proxy-middleware.js +2985 -0
- package/dist/http-proxy-middleware.js.LICENSE.txt +69 -0
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +96 -16
- package/dist/manifest-plugin.js +543 -21
- package/dist/memfs.js +241 -776
- package/dist/{710.js → mrmime.js} +2 -1
- package/dist/open.js +32 -28
- package/dist/range-parser.js +2 -2
- package/dist/remapping.js +2 -2
- package/dist/rslib-runtime.js +4 -4
- package/dist/sirv.js +14 -14
- package/dist/src.js +510 -0
- package/dist/tinyglobby.js +114 -69
- package/dist/transformLoader.mjs +38 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist/ws.js +1549 -0
- package/dist-types/createContext.d.ts +3 -2
- package/dist-types/helpers/format.d.ts +2 -1
- package/dist-types/helpers/fs.d.ts +2 -1
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/helpers/stats.d.ts +4 -3
- package/dist-types/helpers/vendors.d.ts +0 -2
- package/dist-types/hooks.d.ts +3 -3
- package/dist-types/index.d.ts +4 -3
- package/dist-types/initPlugins.d.ts +2 -1
- package/dist-types/logger.d.ts +9 -3
- package/dist-types/pluginManager.d.ts +2 -1
- package/dist-types/restart.d.ts +4 -2
- package/dist-types/server/assets-middleware/index.d.ts +3 -2
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +2 -1
- package/dist-types/server/cliShortcuts.d.ts +4 -1
- package/dist-types/server/devMiddlewares.d.ts +4 -6
- package/dist-types/server/devServer.d.ts +8 -42
- package/dist-types/server/helper.d.ts +50 -16
- package/dist-types/server/historyApiFallback.d.ts +2 -1
- package/dist-types/server/middlewares.d.ts +5 -3
- package/dist-types/server/open.d.ts +4 -2
- package/dist-types/server/previewServer.d.ts +4 -0
- package/dist-types/server/proxy.d.ts +3 -2
- package/dist-types/server/runner/asModule.d.ts +1 -1
- package/dist-types/server/serverSetup.d.ts +2 -0
- package/dist-types/server/socketServer.d.ts +4 -1
- package/dist-types/server/watchFiles.d.ts +1 -1
- package/dist-types/types/config.d.ts +123 -25
- package/dist-types/types/context.d.ts +3 -0
- package/dist-types/types/hooks.d.ts +17 -15
- package/dist-types/types/plugin.d.ts +14 -11
- package/dist-types/types/rsbuild.d.ts +11 -4
- package/dist-types/types/thirdParty.d.ts +15 -6
- package/package.json +23 -26
- package/compiled/chokidar/handler.d.ts +0 -90
- package/compiled/http-proxy-middleware/index.js +0 -5284
- package/compiled/ws/index.d.ts +0 -437
- package/compiled/ws/index.js +0 -3166
- package/compiled/ws/license +0 -20
- package/compiled/ws/package.json +0 -1
- package/dist/397.js +0 -11
- package/dist/7.js +0 -1
- package/dist/743.js +0 -7
- package/dist/88.js +0 -40
- package/dist/connect.js +0 -581
- package/dist-types/server/prodServer.d.ts +0 -24
- /package/compiled/html-rspack-plugin/{loader.js → htmlLoader.js} +0 -0
- /package/dist/{131.js.LICENSE.txt → 958.js.LICENSE.txt} +0 -0
- /package/dist/client/{59.js → 797.js} +0 -0
- /package/dist/{31.js → trace-mapping.js} +0 -0
package/dist/ws.js
ADDED
|
@@ -0,0 +1,1549 @@
|
|
|
1
|
+
import * as __rspack_external_buffer from "buffer";
|
|
2
|
+
import * as __rspack_external_crypto from "crypto";
|
|
3
|
+
import * as __rspack_external_http from "http";
|
|
4
|
+
import * as __rspack_external_https from "https";
|
|
5
|
+
import * as __rspack_external_net from "net";
|
|
6
|
+
import * as __rspack_external_stream from "stream";
|
|
7
|
+
import * as __rspack_external_tls from "tls";
|
|
8
|
+
import * as __rspack_external_url from "url";
|
|
9
|
+
import * as __rspack_external_zlib from "zlib";
|
|
10
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
11
|
+
import "./958.js";
|
|
12
|
+
__webpack_require__.add({
|
|
13
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
14
|
+
let { EMPTY_BUFFER } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"), FastBuffer = Buffer[Symbol.species];
|
|
15
|
+
function toBuffer(data) {
|
|
16
|
+
let buf;
|
|
17
|
+
return (toBuffer.readOnly = !0, Buffer.isBuffer(data)) ? data : (data instanceof ArrayBuffer ? buf = new FastBuffer(data) : ArrayBuffer.isView(data) ? buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength) : (buf = Buffer.from(data), toBuffer.readOnly = !1), buf);
|
|
18
|
+
}
|
|
19
|
+
module.exports = {
|
|
20
|
+
concat: function concat(list, totalLength) {
|
|
21
|
+
if (0 === list.length) return EMPTY_BUFFER;
|
|
22
|
+
if (1 === list.length) return list[0];
|
|
23
|
+
let target = Buffer.allocUnsafe(totalLength), offset = 0;
|
|
24
|
+
for(let i = 0; i < list.length; i++){
|
|
25
|
+
let buf = list[i];
|
|
26
|
+
target.set(buf, offset), offset += buf.length;
|
|
27
|
+
}
|
|
28
|
+
return offset < totalLength ? new FastBuffer(target.buffer, target.byteOffset, offset) : target;
|
|
29
|
+
},
|
|
30
|
+
mask: function _mask(source, mask, output, offset, length) {
|
|
31
|
+
for(let i = 0; i < length; i++)output[offset + i] = source[i] ^ mask[3 & i];
|
|
32
|
+
},
|
|
33
|
+
toArrayBuffer: function toArrayBuffer(buf) {
|
|
34
|
+
return buf.length === buf.buffer.byteLength ? buf.buffer : buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
|
|
35
|
+
},
|
|
36
|
+
toBuffer,
|
|
37
|
+
unmask: function _unmask(buffer, mask) {
|
|
38
|
+
for(let i = 0; i < buffer.length; i++)buffer[i] ^= mask[3 & i];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js" (module) {
|
|
43
|
+
let BINARY_TYPES = [
|
|
44
|
+
'nodebuffer',
|
|
45
|
+
'arraybuffer',
|
|
46
|
+
'fragments'
|
|
47
|
+
], hasBlob = "u" > typeof Blob;
|
|
48
|
+
hasBlob && BINARY_TYPES.push('blob'), module.exports = {
|
|
49
|
+
BINARY_TYPES,
|
|
50
|
+
CLOSE_TIMEOUT: 30000,
|
|
51
|
+
EMPTY_BUFFER: Buffer.alloc(0),
|
|
52
|
+
GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
|
|
53
|
+
hasBlob,
|
|
54
|
+
kForOnEventAttribute: Symbol('kIsForOnEventAttribute'),
|
|
55
|
+
kListener: Symbol('kListener'),
|
|
56
|
+
kStatusCode: Symbol('status-code'),
|
|
57
|
+
kWebSocket: Symbol('websocket'),
|
|
58
|
+
NOOP: ()=>{}
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/event-target.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
62
|
+
let { kForOnEventAttribute, kListener } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"), kCode = Symbol('kCode'), kData = Symbol('kData'), kError = Symbol('kError'), kMessage = Symbol('kMessage'), kReason = Symbol('kReason'), kTarget = Symbol('kTarget'), kType = Symbol('kType'), kWasClean = Symbol('kWasClean');
|
|
63
|
+
class Event {
|
|
64
|
+
constructor(type){
|
|
65
|
+
this[kTarget] = null, this[kType] = type;
|
|
66
|
+
}
|
|
67
|
+
get target() {
|
|
68
|
+
return this[kTarget];
|
|
69
|
+
}
|
|
70
|
+
get type() {
|
|
71
|
+
return this[kType];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
Object.defineProperty(Event.prototype, 'target', {
|
|
75
|
+
enumerable: !0
|
|
76
|
+
}), Object.defineProperty(Event.prototype, 'type', {
|
|
77
|
+
enumerable: !0
|
|
78
|
+
});
|
|
79
|
+
class CloseEvent extends Event {
|
|
80
|
+
constructor(type, options = {}){
|
|
81
|
+
super(type), this[kCode] = void 0 === options.code ? 0 : options.code, this[kReason] = void 0 === options.reason ? '' : options.reason, this[kWasClean] = void 0 !== options.wasClean && options.wasClean;
|
|
82
|
+
}
|
|
83
|
+
get code() {
|
|
84
|
+
return this[kCode];
|
|
85
|
+
}
|
|
86
|
+
get reason() {
|
|
87
|
+
return this[kReason];
|
|
88
|
+
}
|
|
89
|
+
get wasClean() {
|
|
90
|
+
return this[kWasClean];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
Object.defineProperty(CloseEvent.prototype, 'code', {
|
|
94
|
+
enumerable: !0
|
|
95
|
+
}), Object.defineProperty(CloseEvent.prototype, 'reason', {
|
|
96
|
+
enumerable: !0
|
|
97
|
+
}), Object.defineProperty(CloseEvent.prototype, 'wasClean', {
|
|
98
|
+
enumerable: !0
|
|
99
|
+
});
|
|
100
|
+
class ErrorEvent extends Event {
|
|
101
|
+
constructor(type, options = {}){
|
|
102
|
+
super(type), this[kError] = void 0 === options.error ? null : options.error, this[kMessage] = void 0 === options.message ? '' : options.message;
|
|
103
|
+
}
|
|
104
|
+
get error() {
|
|
105
|
+
return this[kError];
|
|
106
|
+
}
|
|
107
|
+
get message() {
|
|
108
|
+
return this[kMessage];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
Object.defineProperty(ErrorEvent.prototype, 'error', {
|
|
112
|
+
enumerable: !0
|
|
113
|
+
}), Object.defineProperty(ErrorEvent.prototype, 'message', {
|
|
114
|
+
enumerable: !0
|
|
115
|
+
});
|
|
116
|
+
class MessageEvent extends Event {
|
|
117
|
+
constructor(type, options = {}){
|
|
118
|
+
super(type), this[kData] = void 0 === options.data ? null : options.data;
|
|
119
|
+
}
|
|
120
|
+
get data() {
|
|
121
|
+
return this[kData];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function callListener(listener, thisArg, event) {
|
|
125
|
+
'object' == typeof listener && listener.handleEvent ? listener.handleEvent.call(listener, event) : listener.call(thisArg, event);
|
|
126
|
+
}
|
|
127
|
+
Object.defineProperty(MessageEvent.prototype, 'data', {
|
|
128
|
+
enumerable: !0
|
|
129
|
+
}), module.exports = {
|
|
130
|
+
CloseEvent,
|
|
131
|
+
ErrorEvent,
|
|
132
|
+
Event,
|
|
133
|
+
EventTarget: {
|
|
134
|
+
addEventListener (type, handler, options = {}) {
|
|
135
|
+
let wrapper;
|
|
136
|
+
for (let listener of this.listeners(type))if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) return;
|
|
137
|
+
if ('message' === type) wrapper = function onMessage(data, isBinary) {
|
|
138
|
+
let event = new MessageEvent('message', {
|
|
139
|
+
data: isBinary ? data : data.toString()
|
|
140
|
+
});
|
|
141
|
+
event[kTarget] = this, callListener(handler, this, event);
|
|
142
|
+
};
|
|
143
|
+
else if ('close' === type) wrapper = function onClose(code, message) {
|
|
144
|
+
let event = new CloseEvent('close', {
|
|
145
|
+
code,
|
|
146
|
+
reason: message.toString(),
|
|
147
|
+
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
148
|
+
});
|
|
149
|
+
event[kTarget] = this, callListener(handler, this, event);
|
|
150
|
+
};
|
|
151
|
+
else if ('error' === type) wrapper = function onError(error) {
|
|
152
|
+
let event = new ErrorEvent('error', {
|
|
153
|
+
error,
|
|
154
|
+
message: error.message
|
|
155
|
+
});
|
|
156
|
+
event[kTarget] = this, callListener(handler, this, event);
|
|
157
|
+
};
|
|
158
|
+
else {
|
|
159
|
+
if ('open' !== type) return;
|
|
160
|
+
wrapper = function onOpen() {
|
|
161
|
+
let event = new Event('open');
|
|
162
|
+
event[kTarget] = this, callListener(handler, this, event);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute], wrapper[kListener] = handler, options.once ? this.once(type, wrapper) : this.on(type, wrapper);
|
|
166
|
+
},
|
|
167
|
+
removeEventListener (type, handler) {
|
|
168
|
+
for (let listener of this.listeners(type))if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
169
|
+
this.removeListener(type, listener);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
MessageEvent
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
178
|
+
let { tokenChars } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js");
|
|
179
|
+
function push(dest, name, elem) {
|
|
180
|
+
void 0 === dest[name] ? dest[name] = [
|
|
181
|
+
elem
|
|
182
|
+
] : dest[name].push(elem);
|
|
183
|
+
}
|
|
184
|
+
module.exports = {
|
|
185
|
+
format: function format(extensions) {
|
|
186
|
+
return Object.keys(extensions).map((extension)=>{
|
|
187
|
+
let configurations = extensions[extension];
|
|
188
|
+
return Array.isArray(configurations) || (configurations = [
|
|
189
|
+
configurations
|
|
190
|
+
]), configurations.map((params)=>[
|
|
191
|
+
extension
|
|
192
|
+
].concat(Object.keys(params).map((k)=>{
|
|
193
|
+
let values = params[k];
|
|
194
|
+
return Array.isArray(values) || (values = [
|
|
195
|
+
values
|
|
196
|
+
]), values.map((v)=>!0 === v ? k : `${k}=${v}`).join('; ');
|
|
197
|
+
})).join('; ')).join(', ');
|
|
198
|
+
}).join(', ');
|
|
199
|
+
},
|
|
200
|
+
parse: function parse(header) {
|
|
201
|
+
let extensionName, paramName, offers = Object.create(null), params = Object.create(null), mustUnescape = !1, isEscaping = !1, inQuotes = !1, start = -1, code = -1, end = -1, i = 0;
|
|
202
|
+
for(; i < header.length; i++)if (code = header.charCodeAt(i), void 0 === extensionName) if (-1 === end && 1 === tokenChars[code]) -1 === start && (start = i);
|
|
203
|
+
else if (0 !== i && (0x20 === code || 0x09 === code)) -1 === end && -1 !== start && (end = i);
|
|
204
|
+
else if (0x3b === code || 0x2c === code) {
|
|
205
|
+
if (-1 === start) throw SyntaxError(`Unexpected character at index ${i}`);
|
|
206
|
+
-1 === end && (end = i);
|
|
207
|
+
let name = header.slice(start, end);
|
|
208
|
+
0x2c === code ? (push(offers, name, params), params = Object.create(null)) : extensionName = name, start = end = -1;
|
|
209
|
+
} else throw SyntaxError(`Unexpected character at index ${i}`);
|
|
210
|
+
else if (void 0 === paramName) if (-1 === end && 1 === tokenChars[code]) -1 === start && (start = i);
|
|
211
|
+
else if (0x20 === code || 0x09 === code) -1 === end && -1 !== start && (end = i);
|
|
212
|
+
else if (0x3b === code || 0x2c === code) {
|
|
213
|
+
if (-1 === start) throw SyntaxError(`Unexpected character at index ${i}`);
|
|
214
|
+
-1 === end && (end = i), push(params, header.slice(start, end), !0), 0x2c === code && (push(offers, extensionName, params), params = Object.create(null), extensionName = void 0), start = end = -1;
|
|
215
|
+
} else if (0x3d === code && -1 !== start && -1 === end) paramName = header.slice(start, i), start = end = -1;
|
|
216
|
+
else throw SyntaxError(`Unexpected character at index ${i}`);
|
|
217
|
+
else if (isEscaping) {
|
|
218
|
+
if (1 !== tokenChars[code]) throw SyntaxError(`Unexpected character at index ${i}`);
|
|
219
|
+
-1 === start ? start = i : mustUnescape || (mustUnescape = !0), isEscaping = !1;
|
|
220
|
+
} else if (inQuotes) if (1 === tokenChars[code]) -1 === start && (start = i);
|
|
221
|
+
else if (0x22 === code && -1 !== start) inQuotes = !1, end = i;
|
|
222
|
+
else if (0x5c === code) isEscaping = !0;
|
|
223
|
+
else throw SyntaxError(`Unexpected character at index ${i}`);
|
|
224
|
+
else if (0x22 === code && 0x3d === header.charCodeAt(i - 1)) inQuotes = !0;
|
|
225
|
+
else if (-1 === end && 1 === tokenChars[code]) -1 === start && (start = i);
|
|
226
|
+
else if (-1 !== start && (0x20 === code || 0x09 === code)) -1 === end && (end = i);
|
|
227
|
+
else if (0x3b === code || 0x2c === code) {
|
|
228
|
+
if (-1 === start) throw SyntaxError(`Unexpected character at index ${i}`);
|
|
229
|
+
-1 === end && (end = i);
|
|
230
|
+
let value = header.slice(start, end);
|
|
231
|
+
mustUnescape && (value = value.replace(/\\/g, ''), mustUnescape = !1), push(params, paramName, value), 0x2c === code && (push(offers, extensionName, params), params = Object.create(null), extensionName = void 0), paramName = void 0, start = end = -1;
|
|
232
|
+
} else throw SyntaxError(`Unexpected character at index ${i}`);
|
|
233
|
+
if (-1 === start || inQuotes || 0x20 === code || 0x09 === code) throw SyntaxError('Unexpected end of input');
|
|
234
|
+
-1 === end && (end = i);
|
|
235
|
+
let token = header.slice(start, end);
|
|
236
|
+
return void 0 === extensionName ? push(offers, token, params) : (void 0 === paramName ? push(params, token, !0) : mustUnescape ? push(params, paramName, token.replace(/\\/g, '')) : push(params, paramName, token), push(offers, extensionName, params)), offers;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
},
|
|
240
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/limiter.js" (module) {
|
|
241
|
+
let kDone = Symbol('kDone'), kRun = Symbol('kRun');
|
|
242
|
+
module.exports = class {
|
|
243
|
+
constructor(concurrency){
|
|
244
|
+
this[kDone] = ()=>{
|
|
245
|
+
this.pending--, this[kRun]();
|
|
246
|
+
}, this.concurrency = concurrency || 1 / 0, this.jobs = [], this.pending = 0;
|
|
247
|
+
}
|
|
248
|
+
add(job) {
|
|
249
|
+
this.jobs.push(job), this[kRun]();
|
|
250
|
+
}
|
|
251
|
+
[kRun]() {
|
|
252
|
+
if (this.pending !== this.concurrency && this.jobs.length) {
|
|
253
|
+
let job = this.jobs.shift();
|
|
254
|
+
this.pending++, job(this[kDone]);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
},
|
|
259
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
260
|
+
let zlibLimiter, zlib = __webpack_require__("zlib?d5a8"), bufferUtil = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js"), Limiter = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/limiter.js"), { kStatusCode } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"), FastBuffer = Buffer[Symbol.species], TRAILER = Buffer.from([
|
|
261
|
+
0x00,
|
|
262
|
+
0x00,
|
|
263
|
+
0xff,
|
|
264
|
+
0xff
|
|
265
|
+
]), kPerMessageDeflate = Symbol('permessage-deflate'), kTotalLength = Symbol('total-length'), kCallback = Symbol('callback'), kBuffers = Symbol('buffers'), kError = Symbol('error');
|
|
266
|
+
function deflateOnData(chunk) {
|
|
267
|
+
this[kBuffers].push(chunk), this[kTotalLength] += chunk.length;
|
|
268
|
+
}
|
|
269
|
+
function inflateOnData(chunk) {
|
|
270
|
+
(this[kTotalLength] += chunk.length, this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) ? this[kBuffers].push(chunk) : (this[kError] = RangeError('Max payload size exceeded'), this[kError].code = 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH', this[kError][kStatusCode] = 1009, this.removeListener('data', inflateOnData), this.reset());
|
|
271
|
+
}
|
|
272
|
+
function inflateOnError(err) {
|
|
273
|
+
(this[kPerMessageDeflate]._inflate = null, this[kError]) ? this[kCallback](this[kError]) : (err[kStatusCode] = 1007, this[kCallback](err));
|
|
274
|
+
}
|
|
275
|
+
module.exports = class {
|
|
276
|
+
constructor(options){
|
|
277
|
+
this._options = options || {}, this._threshold = void 0 !== this._options.threshold ? this._options.threshold : 1024, this._maxPayload = 0 | this._options.maxPayload, this._isServer = !!this._options.isServer, this._deflate = null, this._inflate = null, this.params = null, zlibLimiter || (zlibLimiter = new Limiter(void 0 !== this._options.concurrencyLimit ? this._options.concurrencyLimit : 10));
|
|
278
|
+
}
|
|
279
|
+
static get extensionName() {
|
|
280
|
+
return 'permessage-deflate';
|
|
281
|
+
}
|
|
282
|
+
offer() {
|
|
283
|
+
let params = {};
|
|
284
|
+
return this._options.serverNoContextTakeover && (params.server_no_context_takeover = !0), this._options.clientNoContextTakeover && (params.client_no_context_takeover = !0), this._options.serverMaxWindowBits && (params.server_max_window_bits = this._options.serverMaxWindowBits), this._options.clientMaxWindowBits ? params.client_max_window_bits = this._options.clientMaxWindowBits : null == this._options.clientMaxWindowBits && (params.client_max_window_bits = !0), params;
|
|
285
|
+
}
|
|
286
|
+
accept(configurations) {
|
|
287
|
+
return configurations = this.normalizeParams(configurations), this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations), this.params;
|
|
288
|
+
}
|
|
289
|
+
cleanup() {
|
|
290
|
+
if (this._inflate && (this._inflate.close(), this._inflate = null), this._deflate) {
|
|
291
|
+
let callback = this._deflate[kCallback];
|
|
292
|
+
this._deflate.close(), this._deflate = null, callback && callback(Error('The deflate stream was closed while data was being processed'));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
acceptAsServer(offers) {
|
|
296
|
+
let opts = this._options, accepted = offers.find((params)=>(!1 !== opts.serverNoContextTakeover || !params.server_no_context_takeover) && (!params.server_max_window_bits || !1 !== opts.serverMaxWindowBits && ('number' != typeof opts.serverMaxWindowBits || !(opts.serverMaxWindowBits > params.server_max_window_bits))) && ('number' != typeof opts.clientMaxWindowBits || !!params.client_max_window_bits));
|
|
297
|
+
if (!accepted) throw Error('None of the extension offers can be accepted');
|
|
298
|
+
return opts.serverNoContextTakeover && (accepted.server_no_context_takeover = !0), opts.clientNoContextTakeover && (accepted.client_no_context_takeover = !0), 'number' == typeof opts.serverMaxWindowBits && (accepted.server_max_window_bits = opts.serverMaxWindowBits), 'number' == typeof opts.clientMaxWindowBits ? accepted.client_max_window_bits = opts.clientMaxWindowBits : (!0 === accepted.client_max_window_bits || !1 === opts.clientMaxWindowBits) && delete accepted.client_max_window_bits, accepted;
|
|
299
|
+
}
|
|
300
|
+
acceptAsClient(response) {
|
|
301
|
+
let params = response[0];
|
|
302
|
+
if (!1 === this._options.clientNoContextTakeover && params.client_no_context_takeover) throw Error('Unexpected parameter "client_no_context_takeover"');
|
|
303
|
+
if (params.client_max_window_bits) {
|
|
304
|
+
if (!1 === this._options.clientMaxWindowBits || 'number' == typeof this._options.clientMaxWindowBits && params.client_max_window_bits > this._options.clientMaxWindowBits) throw Error('Unexpected or invalid parameter "client_max_window_bits"');
|
|
305
|
+
} else 'number' == typeof this._options.clientMaxWindowBits && (params.client_max_window_bits = this._options.clientMaxWindowBits);
|
|
306
|
+
return params;
|
|
307
|
+
}
|
|
308
|
+
normalizeParams(configurations) {
|
|
309
|
+
return configurations.forEach((params)=>{
|
|
310
|
+
Object.keys(params).forEach((key)=>{
|
|
311
|
+
let value = params[key];
|
|
312
|
+
if (value.length > 1) throw Error(`Parameter "${key}" must have only a single value`);
|
|
313
|
+
if (value = value[0], 'client_max_window_bits' === key) {
|
|
314
|
+
if (!0 !== value) {
|
|
315
|
+
let num = +value;
|
|
316
|
+
if (!Number.isInteger(num) || num < 8 || num > 15) throw TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
317
|
+
value = num;
|
|
318
|
+
} else if (!this._isServer) throw TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
319
|
+
} else if ('server_max_window_bits' === key) {
|
|
320
|
+
let num = +value;
|
|
321
|
+
if (!Number.isInteger(num) || num < 8 || num > 15) throw TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
322
|
+
value = num;
|
|
323
|
+
} else if ('client_no_context_takeover' === key || 'server_no_context_takeover' === key) {
|
|
324
|
+
if (!0 !== value) throw TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
325
|
+
} else throw Error(`Unknown parameter "${key}"`);
|
|
326
|
+
params[key] = value;
|
|
327
|
+
});
|
|
328
|
+
}), configurations;
|
|
329
|
+
}
|
|
330
|
+
decompress(data, fin, callback) {
|
|
331
|
+
zlibLimiter.add((done)=>{
|
|
332
|
+
this._decompress(data, fin, (err, result)=>{
|
|
333
|
+
done(), callback(err, result);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
compress(data, fin, callback) {
|
|
338
|
+
zlibLimiter.add((done)=>{
|
|
339
|
+
this._compress(data, fin, (err, result)=>{
|
|
340
|
+
done(), callback(err, result);
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
_decompress(data, fin, callback) {
|
|
345
|
+
let endpoint = this._isServer ? 'client' : 'server';
|
|
346
|
+
if (!this._inflate) {
|
|
347
|
+
let key = `${endpoint}_max_window_bits`, windowBits = 'number' != typeof this.params[key] ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
348
|
+
this._inflate = zlib.createInflateRaw({
|
|
349
|
+
...this._options.zlibInflateOptions,
|
|
350
|
+
windowBits
|
|
351
|
+
}), this._inflate[kPerMessageDeflate] = this, this._inflate[kTotalLength] = 0, this._inflate[kBuffers] = [], this._inflate.on('error', inflateOnError), this._inflate.on('data', inflateOnData);
|
|
352
|
+
}
|
|
353
|
+
this._inflate[kCallback] = callback, this._inflate.write(data), fin && this._inflate.write(TRAILER), this._inflate.flush(()=>{
|
|
354
|
+
let err = this._inflate[kError];
|
|
355
|
+
if (err) {
|
|
356
|
+
this._inflate.close(), this._inflate = null, callback(err);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
let data = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
|
|
360
|
+
this._inflate._readableState.endEmitted ? (this._inflate.close(), this._inflate = null) : (this._inflate[kTotalLength] = 0, this._inflate[kBuffers] = [], fin && this.params[`${endpoint}_no_context_takeover`] && this._inflate.reset()), callback(null, data);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
_compress(data, fin, callback) {
|
|
364
|
+
let endpoint = this._isServer ? 'server' : 'client';
|
|
365
|
+
if (!this._deflate) {
|
|
366
|
+
let key = `${endpoint}_max_window_bits`, windowBits = 'number' != typeof this.params[key] ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
367
|
+
this._deflate = zlib.createDeflateRaw({
|
|
368
|
+
...this._options.zlibDeflateOptions,
|
|
369
|
+
windowBits
|
|
370
|
+
}), this._deflate[kTotalLength] = 0, this._deflate[kBuffers] = [], this._deflate.on('data', deflateOnData);
|
|
371
|
+
}
|
|
372
|
+
this._deflate[kCallback] = callback, this._deflate.write(data), this._deflate.flush(zlib.Z_SYNC_FLUSH, ()=>{
|
|
373
|
+
if (!this._deflate) return;
|
|
374
|
+
let data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
375
|
+
fin && (data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4)), this._deflate[kCallback] = null, this._deflate[kTotalLength] = 0, this._deflate[kBuffers] = [], fin && this.params[`${endpoint}_no_context_takeover`] && this._deflate.reset(), callback(null, data);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
},
|
|
380
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/receiver.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
381
|
+
let { Writable } = __webpack_require__("stream?91df"), PerMessageDeflate = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"), { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"), { concat, toArrayBuffer, unmask } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js"), { isValidStatusCode, isValidUTF8 } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js"), FastBuffer = Buffer[Symbol.species];
|
|
382
|
+
module.exports = class extends Writable {
|
|
383
|
+
constructor(options = {}){
|
|
384
|
+
super(), this._allowSynchronousEvents = void 0 === options.allowSynchronousEvents || options.allowSynchronousEvents, this._binaryType = options.binaryType || BINARY_TYPES[0], this._extensions = options.extensions || {}, this._isServer = !!options.isServer, this._maxPayload = 0 | options.maxPayload, this._skipUTF8Validation = !!options.skipUTF8Validation, this[kWebSocket] = void 0, this._bufferedBytes = 0, this._buffers = [], this._compressed = !1, this._payloadLength = 0, this._mask = void 0, this._fragmented = 0, this._masked = !1, this._fin = !1, this._opcode = 0, this._totalPayloadLength = 0, this._messageLength = 0, this._fragments = [], this._errored = !1, this._loop = !1, this._state = 0;
|
|
385
|
+
}
|
|
386
|
+
_write(chunk, encoding, cb) {
|
|
387
|
+
if (0x08 === this._opcode && 0 == this._state) return cb();
|
|
388
|
+
this._bufferedBytes += chunk.length, this._buffers.push(chunk), this.startLoop(cb);
|
|
389
|
+
}
|
|
390
|
+
consume(n) {
|
|
391
|
+
if (this._bufferedBytes -= n, n === this._buffers[0].length) return this._buffers.shift();
|
|
392
|
+
if (n < this._buffers[0].length) {
|
|
393
|
+
let buf = this._buffers[0];
|
|
394
|
+
return this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n), new FastBuffer(buf.buffer, buf.byteOffset, n);
|
|
395
|
+
}
|
|
396
|
+
let dst = Buffer.allocUnsafe(n);
|
|
397
|
+
do {
|
|
398
|
+
let buf = this._buffers[0], offset = dst.length - n;
|
|
399
|
+
n >= buf.length ? dst.set(this._buffers.shift(), offset) : (dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset), this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n)), n -= buf.length;
|
|
400
|
+
}while (n > 0);
|
|
401
|
+
return dst;
|
|
402
|
+
}
|
|
403
|
+
startLoop(cb) {
|
|
404
|
+
this._loop = !0;
|
|
405
|
+
do switch(this._state){
|
|
406
|
+
case 0:
|
|
407
|
+
this.getInfo(cb);
|
|
408
|
+
break;
|
|
409
|
+
case 1:
|
|
410
|
+
this.getPayloadLength16(cb);
|
|
411
|
+
break;
|
|
412
|
+
case 2:
|
|
413
|
+
this.getPayloadLength64(cb);
|
|
414
|
+
break;
|
|
415
|
+
case 3:
|
|
416
|
+
this.getMask();
|
|
417
|
+
break;
|
|
418
|
+
case 4:
|
|
419
|
+
this.getData(cb);
|
|
420
|
+
break;
|
|
421
|
+
case 5:
|
|
422
|
+
case 6:
|
|
423
|
+
this._loop = !1;
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
while (this._loop);
|
|
427
|
+
this._errored || cb();
|
|
428
|
+
}
|
|
429
|
+
getInfo(cb) {
|
|
430
|
+
if (this._bufferedBytes < 2) {
|
|
431
|
+
this._loop = !1;
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
let buf = this.consume(2);
|
|
435
|
+
if ((0x30 & buf[0]) != 0x00) return void cb(this.createError(RangeError, 'RSV2 and RSV3 must be clear', !0, 1002, 'WS_ERR_UNEXPECTED_RSV_2_3'));
|
|
436
|
+
let compressed = (0x40 & buf[0]) == 0x40;
|
|
437
|
+
if (compressed && !this._extensions[PerMessageDeflate.extensionName]) return void cb(this.createError(RangeError, 'RSV1 must be clear', !0, 1002, 'WS_ERR_UNEXPECTED_RSV_1'));
|
|
438
|
+
if (this._fin = (0x80 & buf[0]) == 0x80, this._opcode = 0x0f & buf[0], this._payloadLength = 0x7f & buf[1], 0x00 === this._opcode) {
|
|
439
|
+
if (compressed) return void cb(this.createError(RangeError, 'RSV1 must be clear', !0, 1002, 'WS_ERR_UNEXPECTED_RSV_1'));
|
|
440
|
+
if (!this._fragmented) return void cb(this.createError(RangeError, 'invalid opcode 0', !0, 1002, 'WS_ERR_INVALID_OPCODE'));
|
|
441
|
+
this._opcode = this._fragmented;
|
|
442
|
+
} else if (0x01 === this._opcode || 0x02 === this._opcode) {
|
|
443
|
+
if (this._fragmented) return void cb(this.createError(RangeError, `invalid opcode ${this._opcode}`, !0, 1002, 'WS_ERR_INVALID_OPCODE'));
|
|
444
|
+
this._compressed = compressed;
|
|
445
|
+
} else {
|
|
446
|
+
if (!(this._opcode > 0x07) || !(this._opcode < 0x0b)) return void cb(this.createError(RangeError, `invalid opcode ${this._opcode}`, !0, 1002, 'WS_ERR_INVALID_OPCODE'));
|
|
447
|
+
if (!this._fin) return void cb(this.createError(RangeError, 'FIN must be set', !0, 1002, 'WS_ERR_EXPECTED_FIN'));
|
|
448
|
+
if (compressed) return void cb(this.createError(RangeError, 'RSV1 must be clear', !0, 1002, 'WS_ERR_UNEXPECTED_RSV_1'));
|
|
449
|
+
if (this._payloadLength > 0x7d || 0x08 === this._opcode && 1 === this._payloadLength) return void cb(this.createError(RangeError, `invalid payload length ${this._payloadLength}`, !0, 1002, 'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH'));
|
|
450
|
+
}
|
|
451
|
+
if (this._fin || this._fragmented || (this._fragmented = this._opcode), this._masked = (0x80 & buf[1]) == 0x80, this._isServer) {
|
|
452
|
+
if (!this._masked) return void cb(this.createError(RangeError, 'MASK must be set', !0, 1002, 'WS_ERR_EXPECTED_MASK'));
|
|
453
|
+
} else if (this._masked) return void cb(this.createError(RangeError, 'MASK must be clear', !0, 1002, 'WS_ERR_UNEXPECTED_MASK'));
|
|
454
|
+
126 === this._payloadLength ? this._state = 1 : 127 === this._payloadLength ? this._state = 2 : this.haveLength(cb);
|
|
455
|
+
}
|
|
456
|
+
getPayloadLength16(cb) {
|
|
457
|
+
if (this._bufferedBytes < 2) {
|
|
458
|
+
this._loop = !1;
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength(cb);
|
|
462
|
+
}
|
|
463
|
+
getPayloadLength64(cb) {
|
|
464
|
+
if (this._bufferedBytes < 8) {
|
|
465
|
+
this._loop = !1;
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
let buf = this.consume(8), num = buf.readUInt32BE(0);
|
|
469
|
+
num > 2097151 ? cb(this.createError(RangeError, 'Unsupported WebSocket frame: payload length > 2^53 - 1', !1, 1009, 'WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH')) : (this._payloadLength = 4294967296 * num + buf.readUInt32BE(4), this.haveLength(cb));
|
|
470
|
+
}
|
|
471
|
+
haveLength(cb) {
|
|
472
|
+
this._payloadLength && this._opcode < 0x08 && (this._totalPayloadLength += this._payloadLength, this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) ? cb(this.createError(RangeError, 'Max payload size exceeded', !1, 1009, 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH')) : this._masked ? this._state = 3 : this._state = 4;
|
|
473
|
+
}
|
|
474
|
+
getMask() {
|
|
475
|
+
if (this._bufferedBytes < 4) {
|
|
476
|
+
this._loop = !1;
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
this._mask = this.consume(4), this._state = 4;
|
|
480
|
+
}
|
|
481
|
+
getData(cb) {
|
|
482
|
+
let data = EMPTY_BUFFER;
|
|
483
|
+
if (this._payloadLength) {
|
|
484
|
+
if (this._bufferedBytes < this._payloadLength) {
|
|
485
|
+
this._loop = !1;
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
data = this.consume(this._payloadLength), this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) != 0 && unmask(data, this._mask);
|
|
489
|
+
}
|
|
490
|
+
if (this._opcode > 0x07) return void this.controlMessage(data, cb);
|
|
491
|
+
if (this._compressed) {
|
|
492
|
+
this._state = 5, this.decompress(data, cb);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
data.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(data)), this.dataMessage(cb);
|
|
496
|
+
}
|
|
497
|
+
decompress(data, cb) {
|
|
498
|
+
this._extensions[PerMessageDeflate.extensionName].decompress(data, this._fin, (err, buf)=>{
|
|
499
|
+
if (err) return cb(err);
|
|
500
|
+
if (buf.length) {
|
|
501
|
+
if (this._messageLength += buf.length, this._messageLength > this._maxPayload && this._maxPayload > 0) return void cb(this.createError(RangeError, 'Max payload size exceeded', !1, 1009, 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH'));
|
|
502
|
+
this._fragments.push(buf);
|
|
503
|
+
}
|
|
504
|
+
this.dataMessage(cb), 0 === this._state && this.startLoop(cb);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
dataMessage(cb) {
|
|
508
|
+
if (!this._fin) {
|
|
509
|
+
this._state = 0;
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
let messageLength = this._messageLength, fragments = this._fragments;
|
|
513
|
+
if (this._totalPayloadLength = 0, this._messageLength = 0, this._fragmented = 0, this._fragments = [], 2 === this._opcode) {
|
|
514
|
+
let data;
|
|
515
|
+
data = 'nodebuffer' === this._binaryType ? concat(fragments, messageLength) : 'arraybuffer' === this._binaryType ? toArrayBuffer(concat(fragments, messageLength)) : 'blob' === this._binaryType ? new Blob(fragments) : fragments, this._allowSynchronousEvents ? (this.emit('message', data, !0), this._state = 0) : (this._state = 6, setImmediate(()=>{
|
|
516
|
+
this.emit('message', data, !0), this._state = 0, this.startLoop(cb);
|
|
517
|
+
}));
|
|
518
|
+
} else {
|
|
519
|
+
let buf = concat(fragments, messageLength);
|
|
520
|
+
if (!this._skipUTF8Validation && !isValidUTF8(buf)) return void cb(this.createError(Error, 'invalid UTF-8 sequence', !0, 1007, 'WS_ERR_INVALID_UTF8'));
|
|
521
|
+
5 === this._state || this._allowSynchronousEvents ? (this.emit('message', buf, !1), this._state = 0) : (this._state = 6, setImmediate(()=>{
|
|
522
|
+
this.emit('message', buf, !1), this._state = 0, this.startLoop(cb);
|
|
523
|
+
}));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
controlMessage(data, cb) {
|
|
527
|
+
if (0x08 === this._opcode) {
|
|
528
|
+
if (0 === data.length) this._loop = !1, this.emit('conclude', 1005, EMPTY_BUFFER), this.end();
|
|
529
|
+
else {
|
|
530
|
+
let code = data.readUInt16BE(0);
|
|
531
|
+
if (!isValidStatusCode(code)) return void cb(this.createError(RangeError, `invalid status code ${code}`, !0, 1002, 'WS_ERR_INVALID_CLOSE_CODE'));
|
|
532
|
+
let buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);
|
|
533
|
+
if (!this._skipUTF8Validation && !isValidUTF8(buf)) return void cb(this.createError(Error, 'invalid UTF-8 sequence', !0, 1007, 'WS_ERR_INVALID_UTF8'));
|
|
534
|
+
this._loop = !1, this.emit('conclude', code, buf), this.end();
|
|
535
|
+
}
|
|
536
|
+
this._state = 0;
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
this._allowSynchronousEvents ? (this.emit(0x09 === this._opcode ? 'ping' : 'pong', data), this._state = 0) : (this._state = 6, setImmediate(()=>{
|
|
540
|
+
this.emit(0x09 === this._opcode ? 'ping' : 'pong', data), this._state = 0, this.startLoop(cb);
|
|
541
|
+
}));
|
|
542
|
+
}
|
|
543
|
+
createError(ErrorCtor, message, prefix, statusCode, errorCode) {
|
|
544
|
+
this._loop = !1, this._errored = !0;
|
|
545
|
+
let err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);
|
|
546
|
+
return Error.captureStackTrace(err, this.createError), err.code = errorCode, err[kStatusCode] = statusCode, err;
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
},
|
|
550
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/sender.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
551
|
+
let randomPool, { Duplex } = __webpack_require__("stream?91df"), { randomFillSync } = __webpack_require__("crypto"), PerMessageDeflate = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"), { EMPTY_BUFFER, kWebSocket, NOOP } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"), { isBlob, isValidStatusCode } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js"), { mask: applyMask, toBuffer } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js"), kByteLength = Symbol('kByteLength'), maskBuffer = Buffer.alloc(4), randomPoolPointer = 8192;
|
|
552
|
+
class Sender {
|
|
553
|
+
constructor(socket, extensions, generateMask){
|
|
554
|
+
this._extensions = extensions || {}, generateMask && (this._generateMask = generateMask, this._maskBuffer = Buffer.alloc(4)), this._socket = socket, this._firstFragment = !0, this._compress = !1, this._bufferedBytes = 0, this._queue = [], this._state = 0, this.onerror = NOOP, this[kWebSocket] = void 0;
|
|
555
|
+
}
|
|
556
|
+
static frame(data, options) {
|
|
557
|
+
let mask, dataLength, merge = !1, offset = 2, skipMasking = !1;
|
|
558
|
+
options.mask && (mask = options.maskBuffer || maskBuffer, options.generateMask ? options.generateMask(mask) : (8192 === randomPoolPointer && (void 0 === randomPool && (randomPool = Buffer.alloc(8192)), randomFillSync(randomPool, 0, 8192), randomPoolPointer = 0), mask[0] = randomPool[randomPoolPointer++], mask[1] = randomPool[randomPoolPointer++], mask[2] = randomPool[randomPoolPointer++], mask[3] = randomPool[randomPoolPointer++]), skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) == 0, offset = 6), 'string' == typeof data ? dataLength = (!options.mask || skipMasking) && void 0 !== options[kByteLength] ? options[kByteLength] : (data = Buffer.from(data)).length : (dataLength = data.length, merge = options.mask && options.readOnly && !skipMasking);
|
|
559
|
+
let payloadLength = dataLength;
|
|
560
|
+
dataLength >= 65536 ? (offset += 8, payloadLength = 127) : dataLength > 125 && (offset += 2, payloadLength = 126);
|
|
561
|
+
let target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
|
|
562
|
+
return (target[0] = options.fin ? 0x80 | options.opcode : options.opcode, options.rsv1 && (target[0] |= 0x40), target[1] = payloadLength, 126 === payloadLength ? target.writeUInt16BE(dataLength, 2) : 127 === payloadLength && (target[2] = target[3] = 0, target.writeUIntBE(dataLength, 4, 6)), options.mask) ? (target[1] |= 0x80, target[offset - 4] = mask[0], target[offset - 3] = mask[1], target[offset - 2] = mask[2], target[offset - 1] = mask[3], skipMasking) ? [
|
|
563
|
+
target,
|
|
564
|
+
data
|
|
565
|
+
] : merge ? (applyMask(data, mask, target, offset, dataLength), [
|
|
566
|
+
target
|
|
567
|
+
]) : (applyMask(data, mask, data, 0, dataLength), [
|
|
568
|
+
target,
|
|
569
|
+
data
|
|
570
|
+
]) : [
|
|
571
|
+
target,
|
|
572
|
+
data
|
|
573
|
+
];
|
|
574
|
+
}
|
|
575
|
+
close(code, data, mask, cb) {
|
|
576
|
+
let buf;
|
|
577
|
+
if (void 0 === code) buf = EMPTY_BUFFER;
|
|
578
|
+
else if ('number' == typeof code && isValidStatusCode(code)) if (void 0 !== data && data.length) {
|
|
579
|
+
let length = Buffer.byteLength(data);
|
|
580
|
+
if (length > 123) throw RangeError('The message must not be greater than 123 bytes');
|
|
581
|
+
(buf = Buffer.allocUnsafe(2 + length)).writeUInt16BE(code, 0), 'string' == typeof data ? buf.write(data, 2) : buf.set(data, 2);
|
|
582
|
+
} else (buf = Buffer.allocUnsafe(2)).writeUInt16BE(code, 0);
|
|
583
|
+
else throw TypeError('First argument must be a valid error code number');
|
|
584
|
+
let options = {
|
|
585
|
+
[kByteLength]: buf.length,
|
|
586
|
+
fin: !0,
|
|
587
|
+
generateMask: this._generateMask,
|
|
588
|
+
mask,
|
|
589
|
+
maskBuffer: this._maskBuffer,
|
|
590
|
+
opcode: 0x08,
|
|
591
|
+
readOnly: !1,
|
|
592
|
+
rsv1: !1
|
|
593
|
+
};
|
|
594
|
+
0 !== this._state ? this.enqueue([
|
|
595
|
+
this.dispatch,
|
|
596
|
+
buf,
|
|
597
|
+
!1,
|
|
598
|
+
options,
|
|
599
|
+
cb
|
|
600
|
+
]) : this.sendFrame(Sender.frame(buf, options), cb);
|
|
601
|
+
}
|
|
602
|
+
ping(data, mask, cb) {
|
|
603
|
+
let byteLength, readOnly;
|
|
604
|
+
if ('string' == typeof data ? (byteLength = Buffer.byteLength(data), readOnly = !1) : isBlob(data) ? (byteLength = data.size, readOnly = !1) : (byteLength = (data = toBuffer(data)).length, readOnly = toBuffer.readOnly), byteLength > 125) throw RangeError('The data size must not be greater than 125 bytes');
|
|
605
|
+
let options = {
|
|
606
|
+
[kByteLength]: byteLength,
|
|
607
|
+
fin: !0,
|
|
608
|
+
generateMask: this._generateMask,
|
|
609
|
+
mask,
|
|
610
|
+
maskBuffer: this._maskBuffer,
|
|
611
|
+
opcode: 0x09,
|
|
612
|
+
readOnly,
|
|
613
|
+
rsv1: !1
|
|
614
|
+
};
|
|
615
|
+
isBlob(data) ? 0 !== this._state ? this.enqueue([
|
|
616
|
+
this.getBlobData,
|
|
617
|
+
data,
|
|
618
|
+
!1,
|
|
619
|
+
options,
|
|
620
|
+
cb
|
|
621
|
+
]) : this.getBlobData(data, !1, options, cb) : 0 !== this._state ? this.enqueue([
|
|
622
|
+
this.dispatch,
|
|
623
|
+
data,
|
|
624
|
+
!1,
|
|
625
|
+
options,
|
|
626
|
+
cb
|
|
627
|
+
]) : this.sendFrame(Sender.frame(data, options), cb);
|
|
628
|
+
}
|
|
629
|
+
pong(data, mask, cb) {
|
|
630
|
+
let byteLength, readOnly;
|
|
631
|
+
if ('string' == typeof data ? (byteLength = Buffer.byteLength(data), readOnly = !1) : isBlob(data) ? (byteLength = data.size, readOnly = !1) : (byteLength = (data = toBuffer(data)).length, readOnly = toBuffer.readOnly), byteLength > 125) throw RangeError('The data size must not be greater than 125 bytes');
|
|
632
|
+
let options = {
|
|
633
|
+
[kByteLength]: byteLength,
|
|
634
|
+
fin: !0,
|
|
635
|
+
generateMask: this._generateMask,
|
|
636
|
+
mask,
|
|
637
|
+
maskBuffer: this._maskBuffer,
|
|
638
|
+
opcode: 0x0a,
|
|
639
|
+
readOnly,
|
|
640
|
+
rsv1: !1
|
|
641
|
+
};
|
|
642
|
+
isBlob(data) ? 0 !== this._state ? this.enqueue([
|
|
643
|
+
this.getBlobData,
|
|
644
|
+
data,
|
|
645
|
+
!1,
|
|
646
|
+
options,
|
|
647
|
+
cb
|
|
648
|
+
]) : this.getBlobData(data, !1, options, cb) : 0 !== this._state ? this.enqueue([
|
|
649
|
+
this.dispatch,
|
|
650
|
+
data,
|
|
651
|
+
!1,
|
|
652
|
+
options,
|
|
653
|
+
cb
|
|
654
|
+
]) : this.sendFrame(Sender.frame(data, options), cb);
|
|
655
|
+
}
|
|
656
|
+
send(data, options, cb) {
|
|
657
|
+
let byteLength, readOnly, perMessageDeflate = this._extensions[PerMessageDeflate.extensionName], opcode = options.binary ? 2 : 1, rsv1 = options.compress;
|
|
658
|
+
'string' == typeof data ? (byteLength = Buffer.byteLength(data), readOnly = !1) : isBlob(data) ? (byteLength = data.size, readOnly = !1) : (byteLength = (data = toBuffer(data)).length, readOnly = toBuffer.readOnly), this._firstFragment ? (this._firstFragment = !1, rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? 'server_no_context_takeover' : 'client_no_context_takeover'] && (rsv1 = byteLength >= perMessageDeflate._threshold), this._compress = rsv1) : (rsv1 = !1, opcode = 0), options.fin && (this._firstFragment = !0);
|
|
659
|
+
let opts = {
|
|
660
|
+
[kByteLength]: byteLength,
|
|
661
|
+
fin: options.fin,
|
|
662
|
+
generateMask: this._generateMask,
|
|
663
|
+
mask: options.mask,
|
|
664
|
+
maskBuffer: this._maskBuffer,
|
|
665
|
+
opcode,
|
|
666
|
+
readOnly,
|
|
667
|
+
rsv1
|
|
668
|
+
};
|
|
669
|
+
isBlob(data) ? 0 !== this._state ? this.enqueue([
|
|
670
|
+
this.getBlobData,
|
|
671
|
+
data,
|
|
672
|
+
this._compress,
|
|
673
|
+
opts,
|
|
674
|
+
cb
|
|
675
|
+
]) : this.getBlobData(data, this._compress, opts, cb) : 0 !== this._state ? this.enqueue([
|
|
676
|
+
this.dispatch,
|
|
677
|
+
data,
|
|
678
|
+
this._compress,
|
|
679
|
+
opts,
|
|
680
|
+
cb
|
|
681
|
+
]) : this.dispatch(data, this._compress, opts, cb);
|
|
682
|
+
}
|
|
683
|
+
getBlobData(blob, compress, options, cb) {
|
|
684
|
+
this._bufferedBytes += options[kByteLength], this._state = 2, blob.arrayBuffer().then((arrayBuffer)=>{
|
|
685
|
+
if (this._socket.destroyed) {
|
|
686
|
+
let err = Error('The socket was closed while the blob was being read');
|
|
687
|
+
process.nextTick(callCallbacks, this, err, cb);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
this._bufferedBytes -= options[kByteLength];
|
|
691
|
+
let data = toBuffer(arrayBuffer);
|
|
692
|
+
compress ? this.dispatch(data, compress, options, cb) : (this._state = 0, this.sendFrame(Sender.frame(data, options), cb), this.dequeue());
|
|
693
|
+
}).catch((err)=>{
|
|
694
|
+
process.nextTick(onError, this, err, cb);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
dispatch(data, compress, options, cb) {
|
|
698
|
+
if (!compress) return void this.sendFrame(Sender.frame(data, options), cb);
|
|
699
|
+
let perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
700
|
+
this._bufferedBytes += options[kByteLength], this._state = 1, perMessageDeflate.compress(data, options.fin, (_, buf)=>{
|
|
701
|
+
this._socket.destroyed ? callCallbacks(this, Error('The socket was closed while data was being compressed'), cb) : (this._bufferedBytes -= options[kByteLength], this._state = 0, options.readOnly = !1, this.sendFrame(Sender.frame(buf, options), cb), this.dequeue());
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
dequeue() {
|
|
705
|
+
for(; 0 === this._state && this._queue.length;){
|
|
706
|
+
let params = this._queue.shift();
|
|
707
|
+
this._bufferedBytes -= params[3][kByteLength], Reflect.apply(params[0], this, params.slice(1));
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
enqueue(params) {
|
|
711
|
+
this._bufferedBytes += params[3][kByteLength], this._queue.push(params);
|
|
712
|
+
}
|
|
713
|
+
sendFrame(list, cb) {
|
|
714
|
+
2 === list.length ? (this._socket.cork(), this._socket.write(list[0]), this._socket.write(list[1], cb), this._socket.uncork()) : this._socket.write(list[0], cb);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function callCallbacks(sender, err, cb) {
|
|
718
|
+
'function' == typeof cb && cb(err);
|
|
719
|
+
for(let i = 0; i < sender._queue.length; i++){
|
|
720
|
+
let params = sender._queue[i], callback = params[params.length - 1];
|
|
721
|
+
'function' == typeof callback && callback(err);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
function onError(sender, err, cb) {
|
|
725
|
+
callCallbacks(sender, err, cb), sender.onerror(err);
|
|
726
|
+
}
|
|
727
|
+
module.exports = Sender;
|
|
728
|
+
},
|
|
729
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/stream.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
730
|
+
__webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js");
|
|
731
|
+
let { Duplex } = __webpack_require__("stream?91df");
|
|
732
|
+
function emitClose(stream) {
|
|
733
|
+
stream.emit('close');
|
|
734
|
+
}
|
|
735
|
+
function duplexOnEnd() {
|
|
736
|
+
!this.destroyed && this._writableState.finished && this.destroy();
|
|
737
|
+
}
|
|
738
|
+
function duplexOnError(err) {
|
|
739
|
+
this.removeListener('error', duplexOnError), this.destroy(), 0 === this.listenerCount('error') && this.emit('error', err);
|
|
740
|
+
}
|
|
741
|
+
module.exports = function createWebSocketStream(ws, options) {
|
|
742
|
+
let terminateOnDestroy = !0, duplex = new Duplex({
|
|
743
|
+
...options,
|
|
744
|
+
autoDestroy: !1,
|
|
745
|
+
emitClose: !1,
|
|
746
|
+
objectMode: !1,
|
|
747
|
+
writableObjectMode: !1
|
|
748
|
+
});
|
|
749
|
+
return ws.on('message', function message(msg, isBinary) {
|
|
750
|
+
let data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
751
|
+
duplex.push(data) || ws.pause();
|
|
752
|
+
}), ws.once('error', function error(err) {
|
|
753
|
+
duplex.destroyed || (terminateOnDestroy = !1, duplex.destroy(err));
|
|
754
|
+
}), ws.once('close', function close() {
|
|
755
|
+
duplex.destroyed || duplex.push(null);
|
|
756
|
+
}), duplex._destroy = function(err, callback) {
|
|
757
|
+
if (ws.readyState === ws.CLOSED) {
|
|
758
|
+
callback(err), process.nextTick(emitClose, duplex);
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
let called = !1;
|
|
762
|
+
ws.once('error', function error(err) {
|
|
763
|
+
called = !0, callback(err);
|
|
764
|
+
}), ws.once('close', function close() {
|
|
765
|
+
called || callback(err), process.nextTick(emitClose, duplex);
|
|
766
|
+
}), terminateOnDestroy && ws.terminate();
|
|
767
|
+
}, duplex._final = function(callback) {
|
|
768
|
+
ws.readyState === ws.CONNECTING ? ws.once('open', function open() {
|
|
769
|
+
duplex._final(callback);
|
|
770
|
+
}) : null !== ws._socket && (ws._socket._writableState.finished ? (callback(), duplex._readableState.endEmitted && duplex.destroy()) : (ws._socket.once('finish', function finish() {
|
|
771
|
+
callback();
|
|
772
|
+
}), ws.close()));
|
|
773
|
+
}, duplex._read = function() {
|
|
774
|
+
ws.isPaused && ws.resume();
|
|
775
|
+
}, duplex._write = function(chunk, encoding, callback) {
|
|
776
|
+
ws.readyState === ws.CONNECTING ? ws.once('open', function open() {
|
|
777
|
+
duplex._write(chunk, encoding, callback);
|
|
778
|
+
}) : ws.send(chunk, callback);
|
|
779
|
+
}, duplex.on('end', duplexOnEnd), duplex.on('error', duplexOnError), duplex;
|
|
780
|
+
};
|
|
781
|
+
},
|
|
782
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/subprotocol.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
783
|
+
let { tokenChars } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js");
|
|
784
|
+
module.exports = {
|
|
785
|
+
parse: function parse(header) {
|
|
786
|
+
let protocols = new Set(), start = -1, end = -1, i = 0;
|
|
787
|
+
for(; i < header.length; i++){
|
|
788
|
+
let code = header.charCodeAt(i);
|
|
789
|
+
if (-1 === end && 1 === tokenChars[code]) -1 === start && (start = i);
|
|
790
|
+
else if (0 !== i && (0x20 === code || 0x09 === code)) -1 === end && -1 !== start && (end = i);
|
|
791
|
+
else if (0x2c === code) {
|
|
792
|
+
if (-1 === start) throw SyntaxError(`Unexpected character at index ${i}`);
|
|
793
|
+
-1 === end && (end = i);
|
|
794
|
+
let protocol = header.slice(start, end);
|
|
795
|
+
if (protocols.has(protocol)) throw SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
796
|
+
protocols.add(protocol), start = end = -1;
|
|
797
|
+
} else throw SyntaxError(`Unexpected character at index ${i}`);
|
|
798
|
+
}
|
|
799
|
+
if (-1 === start || -1 !== end) throw SyntaxError('Unexpected end of input');
|
|
800
|
+
let protocol = header.slice(start, i);
|
|
801
|
+
if (protocols.has(protocol)) throw SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
802
|
+
return protocols.add(protocol), protocols;
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
},
|
|
806
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
807
|
+
let { isUtf8 } = __webpack_require__("buffer"), { hasBlob } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js");
|
|
808
|
+
function _isValidUTF8(buf) {
|
|
809
|
+
let len = buf.length, i = 0;
|
|
810
|
+
for(; i < len;)if ((0x80 & buf[i]) == 0) i++;
|
|
811
|
+
else if ((0xe0 & buf[i]) == 0xc0) {
|
|
812
|
+
if (i + 1 === len || (0xc0 & buf[i + 1]) != 0x80 || (0xfe & buf[i]) == 0xc0) return !1;
|
|
813
|
+
i += 2;
|
|
814
|
+
} else if ((0xf0 & buf[i]) == 0xe0) {
|
|
815
|
+
if (i + 2 >= len || (0xc0 & buf[i + 1]) != 0x80 || (0xc0 & buf[i + 2]) != 0x80 || 0xe0 === buf[i] && (0xe0 & buf[i + 1]) == 0x80 || 0xed === buf[i] && (0xe0 & buf[i + 1]) == 0xa0) return !1;
|
|
816
|
+
i += 3;
|
|
817
|
+
} else {
|
|
818
|
+
if ((0xf8 & buf[i]) != 0xf0 || i + 3 >= len || (0xc0 & buf[i + 1]) != 0x80 || (0xc0 & buf[i + 2]) != 0x80 || (0xc0 & buf[i + 3]) != 0x80 || 0xf0 === buf[i] && (0xf0 & buf[i + 1]) == 0x80 || 0xf4 === buf[i] && buf[i + 1] > 0x8f || buf[i] > 0xf4) return !1;
|
|
819
|
+
i += 4;
|
|
820
|
+
}
|
|
821
|
+
return !0;
|
|
822
|
+
}
|
|
823
|
+
module.exports = {
|
|
824
|
+
isBlob: function isBlob(value) {
|
|
825
|
+
return hasBlob && 'object' == typeof value && 'function' == typeof value.arrayBuffer && 'string' == typeof value.type && 'function' == typeof value.stream && ('Blob' === value[Symbol.toStringTag] || 'File' === value[Symbol.toStringTag]);
|
|
826
|
+
},
|
|
827
|
+
isValidStatusCode: function isValidStatusCode(code) {
|
|
828
|
+
return code >= 1000 && code <= 1014 && 1004 !== code && 1005 !== code && 1006 !== code || code >= 3000 && code <= 4999;
|
|
829
|
+
},
|
|
830
|
+
isValidUTF8: _isValidUTF8,
|
|
831
|
+
tokenChars: [
|
|
832
|
+
0,
|
|
833
|
+
0,
|
|
834
|
+
0,
|
|
835
|
+
0,
|
|
836
|
+
0,
|
|
837
|
+
0,
|
|
838
|
+
0,
|
|
839
|
+
0,
|
|
840
|
+
0,
|
|
841
|
+
0,
|
|
842
|
+
0,
|
|
843
|
+
0,
|
|
844
|
+
0,
|
|
845
|
+
0,
|
|
846
|
+
0,
|
|
847
|
+
0,
|
|
848
|
+
0,
|
|
849
|
+
0,
|
|
850
|
+
0,
|
|
851
|
+
0,
|
|
852
|
+
0,
|
|
853
|
+
0,
|
|
854
|
+
0,
|
|
855
|
+
0,
|
|
856
|
+
0,
|
|
857
|
+
0,
|
|
858
|
+
0,
|
|
859
|
+
0,
|
|
860
|
+
0,
|
|
861
|
+
0,
|
|
862
|
+
0,
|
|
863
|
+
0,
|
|
864
|
+
0,
|
|
865
|
+
1,
|
|
866
|
+
0,
|
|
867
|
+
1,
|
|
868
|
+
1,
|
|
869
|
+
1,
|
|
870
|
+
1,
|
|
871
|
+
1,
|
|
872
|
+
0,
|
|
873
|
+
0,
|
|
874
|
+
1,
|
|
875
|
+
1,
|
|
876
|
+
0,
|
|
877
|
+
1,
|
|
878
|
+
1,
|
|
879
|
+
0,
|
|
880
|
+
1,
|
|
881
|
+
1,
|
|
882
|
+
1,
|
|
883
|
+
1,
|
|
884
|
+
1,
|
|
885
|
+
1,
|
|
886
|
+
1,
|
|
887
|
+
1,
|
|
888
|
+
1,
|
|
889
|
+
1,
|
|
890
|
+
0,
|
|
891
|
+
0,
|
|
892
|
+
0,
|
|
893
|
+
0,
|
|
894
|
+
0,
|
|
895
|
+
0,
|
|
896
|
+
0,
|
|
897
|
+
1,
|
|
898
|
+
1,
|
|
899
|
+
1,
|
|
900
|
+
1,
|
|
901
|
+
1,
|
|
902
|
+
1,
|
|
903
|
+
1,
|
|
904
|
+
1,
|
|
905
|
+
1,
|
|
906
|
+
1,
|
|
907
|
+
1,
|
|
908
|
+
1,
|
|
909
|
+
1,
|
|
910
|
+
1,
|
|
911
|
+
1,
|
|
912
|
+
1,
|
|
913
|
+
1,
|
|
914
|
+
1,
|
|
915
|
+
1,
|
|
916
|
+
1,
|
|
917
|
+
1,
|
|
918
|
+
1,
|
|
919
|
+
1,
|
|
920
|
+
1,
|
|
921
|
+
1,
|
|
922
|
+
1,
|
|
923
|
+
0,
|
|
924
|
+
0,
|
|
925
|
+
0,
|
|
926
|
+
1,
|
|
927
|
+
1,
|
|
928
|
+
1,
|
|
929
|
+
1,
|
|
930
|
+
1,
|
|
931
|
+
1,
|
|
932
|
+
1,
|
|
933
|
+
1,
|
|
934
|
+
1,
|
|
935
|
+
1,
|
|
936
|
+
1,
|
|
937
|
+
1,
|
|
938
|
+
1,
|
|
939
|
+
1,
|
|
940
|
+
1,
|
|
941
|
+
1,
|
|
942
|
+
1,
|
|
943
|
+
1,
|
|
944
|
+
1,
|
|
945
|
+
1,
|
|
946
|
+
1,
|
|
947
|
+
1,
|
|
948
|
+
1,
|
|
949
|
+
1,
|
|
950
|
+
1,
|
|
951
|
+
1,
|
|
952
|
+
1,
|
|
953
|
+
1,
|
|
954
|
+
1,
|
|
955
|
+
0,
|
|
956
|
+
1,
|
|
957
|
+
0,
|
|
958
|
+
1,
|
|
959
|
+
0
|
|
960
|
+
]
|
|
961
|
+
}, isUtf8 && (module.exports.isValidUTF8 = function(buf) {
|
|
962
|
+
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
963
|
+
});
|
|
964
|
+
},
|
|
965
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket-server.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
966
|
+
let EventEmitter = __webpack_require__("events"), http = __webpack_require__("http?bf5e"), { Duplex } = __webpack_require__("stream?91df"), { createHash } = __webpack_require__("crypto"), extension = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js"), PerMessageDeflate = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"), subprotocol = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/subprotocol.js"), WebSocket = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js"), { CLOSE_TIMEOUT, GUID, kWebSocket } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"), keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
967
|
+
function addListeners(server, map) {
|
|
968
|
+
for (let event of Object.keys(map))server.on(event, map[event]);
|
|
969
|
+
return function removeListeners() {
|
|
970
|
+
for (let event of Object.keys(map))server.removeListener(event, map[event]);
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
function emitClose(server) {
|
|
974
|
+
server._state = 2, server.emit('close');
|
|
975
|
+
}
|
|
976
|
+
function socketOnError() {
|
|
977
|
+
this.destroy();
|
|
978
|
+
}
|
|
979
|
+
function abortHandshake(socket, code, message, headers) {
|
|
980
|
+
message = message || http.STATUS_CODES[code], headers = {
|
|
981
|
+
Connection: 'close',
|
|
982
|
+
'Content-Type': 'text/html',
|
|
983
|
+
'Content-Length': Buffer.byteLength(message),
|
|
984
|
+
...headers
|
|
985
|
+
}, socket.once('finish', socket.destroy), socket.end(`HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r\n` + Object.keys(headers).map((h)=>`${h}: ${headers[h]}`).join('\r\n') + '\r\n\r\n' + message);
|
|
986
|
+
}
|
|
987
|
+
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {
|
|
988
|
+
if (server.listenerCount('wsClientError')) {
|
|
989
|
+
let err = Error(message);
|
|
990
|
+
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError), server.emit('wsClientError', err, socket, req);
|
|
991
|
+
} else abortHandshake(socket, code, message, headers);
|
|
992
|
+
}
|
|
993
|
+
module.exports = class extends EventEmitter {
|
|
994
|
+
constructor(options, callback){
|
|
995
|
+
if (super(), null == (options = {
|
|
996
|
+
allowSynchronousEvents: !0,
|
|
997
|
+
autoPong: !0,
|
|
998
|
+
maxPayload: 104857600,
|
|
999
|
+
skipUTF8Validation: !1,
|
|
1000
|
+
perMessageDeflate: !1,
|
|
1001
|
+
handleProtocols: null,
|
|
1002
|
+
clientTracking: !0,
|
|
1003
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
1004
|
+
verifyClient: null,
|
|
1005
|
+
noServer: !1,
|
|
1006
|
+
backlog: null,
|
|
1007
|
+
server: null,
|
|
1008
|
+
host: null,
|
|
1009
|
+
path: null,
|
|
1010
|
+
port: null,
|
|
1011
|
+
WebSocket,
|
|
1012
|
+
...options
|
|
1013
|
+
}).port && !options.server && !options.noServer || null != options.port && (options.server || options.noServer) || options.server && options.noServer) throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');
|
|
1014
|
+
if (null != options.port ? (this._server = http.createServer((req, res)=>{
|
|
1015
|
+
let body = http.STATUS_CODES[426];
|
|
1016
|
+
res.writeHead(426, {
|
|
1017
|
+
'Content-Length': body.length,
|
|
1018
|
+
'Content-Type': 'text/plain'
|
|
1019
|
+
}), res.end(body);
|
|
1020
|
+
}), this._server.listen(options.port, options.host, options.backlog, callback)) : options.server && (this._server = options.server), this._server) {
|
|
1021
|
+
let emitConnection = this.emit.bind(this, 'connection');
|
|
1022
|
+
this._removeListeners = addListeners(this._server, {
|
|
1023
|
+
listening: this.emit.bind(this, 'listening'),
|
|
1024
|
+
error: this.emit.bind(this, 'error'),
|
|
1025
|
+
upgrade: (req, socket, head)=>{
|
|
1026
|
+
this.handleUpgrade(req, socket, head, emitConnection);
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
!0 === options.perMessageDeflate && (options.perMessageDeflate = {}), options.clientTracking && (this.clients = new Set(), this._shouldEmitClose = !1), this.options = options, this._state = 0;
|
|
1031
|
+
}
|
|
1032
|
+
address() {
|
|
1033
|
+
if (this.options.noServer) throw Error('The server is operating in "noServer" mode');
|
|
1034
|
+
return this._server ? this._server.address() : null;
|
|
1035
|
+
}
|
|
1036
|
+
close(cb) {
|
|
1037
|
+
if (2 === this._state) {
|
|
1038
|
+
cb && this.once('close', ()=>{
|
|
1039
|
+
cb(Error('The server is not running'));
|
|
1040
|
+
}), process.nextTick(emitClose, this);
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
if (cb && this.once('close', cb), 1 !== this._state) if (this._state = 1, this.options.noServer || this.options.server) this._server && (this._removeListeners(), this._removeListeners = this._server = null), this.clients && this.clients.size ? this._shouldEmitClose = !0 : process.nextTick(emitClose, this);
|
|
1044
|
+
else {
|
|
1045
|
+
let server = this._server;
|
|
1046
|
+
this._removeListeners(), this._removeListeners = this._server = null, server.close(()=>{
|
|
1047
|
+
emitClose(this);
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
shouldHandle(req) {
|
|
1052
|
+
if (this.options.path) {
|
|
1053
|
+
let index = req.url.indexOf('?');
|
|
1054
|
+
if ((-1 !== index ? req.url.slice(0, index) : req.url) !== this.options.path) return !1;
|
|
1055
|
+
}
|
|
1056
|
+
return !0;
|
|
1057
|
+
}
|
|
1058
|
+
handleUpgrade(req, socket, head, cb) {
|
|
1059
|
+
socket.on('error', socketOnError);
|
|
1060
|
+
let key = req.headers['sec-websocket-key'], upgrade = req.headers.upgrade, version = +req.headers['sec-websocket-version'];
|
|
1061
|
+
if ('GET' !== req.method) return void abortHandshakeOrEmitwsClientError(this, req, socket, 405, 'Invalid HTTP method');
|
|
1062
|
+
if (void 0 === upgrade || 'websocket' !== upgrade.toLowerCase()) return void abortHandshakeOrEmitwsClientError(this, req, socket, 400, 'Invalid Upgrade header');
|
|
1063
|
+
if (void 0 === key || !keyRegex.test(key)) return void abortHandshakeOrEmitwsClientError(this, req, socket, 400, 'Missing or invalid Sec-WebSocket-Key header');
|
|
1064
|
+
if (13 !== version && 8 !== version) return void abortHandshakeOrEmitwsClientError(this, req, socket, 400, 'Missing or invalid Sec-WebSocket-Version header', {
|
|
1065
|
+
'Sec-WebSocket-Version': '13, 8'
|
|
1066
|
+
});
|
|
1067
|
+
if (!this.shouldHandle(req)) return void abortHandshake(socket, 400);
|
|
1068
|
+
let secWebSocketProtocol = req.headers['sec-websocket-protocol'], protocols = new Set();
|
|
1069
|
+
if (void 0 !== secWebSocketProtocol) try {
|
|
1070
|
+
protocols = subprotocol.parse(secWebSocketProtocol);
|
|
1071
|
+
} catch (err) {
|
|
1072
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, 'Invalid Sec-WebSocket-Protocol header');
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
let secWebSocketExtensions = req.headers['sec-websocket-extensions'], extensions = {};
|
|
1076
|
+
if (this.options.perMessageDeflate && void 0 !== secWebSocketExtensions) {
|
|
1077
|
+
let perMessageDeflate = new PerMessageDeflate({
|
|
1078
|
+
...this.options.perMessageDeflate,
|
|
1079
|
+
isServer: !0,
|
|
1080
|
+
maxPayload: this.options.maxPayload
|
|
1081
|
+
});
|
|
1082
|
+
try {
|
|
1083
|
+
let offers = extension.parse(secWebSocketExtensions);
|
|
1084
|
+
offers[PerMessageDeflate.extensionName] && (perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]), extensions[PerMessageDeflate.extensionName] = perMessageDeflate);
|
|
1085
|
+
} catch (err) {
|
|
1086
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, 'Invalid or unacceptable Sec-WebSocket-Extensions header');
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
if (this.options.verifyClient) {
|
|
1091
|
+
let info = {
|
|
1092
|
+
origin: req.headers[`${8 === version ? 'sec-websocket-origin' : 'origin'}`],
|
|
1093
|
+
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
1094
|
+
req
|
|
1095
|
+
};
|
|
1096
|
+
if (2 === this.options.verifyClient.length) return void this.options.verifyClient(info, (verified, code, message, headers)=>{
|
|
1097
|
+
if (!verified) return abortHandshake(socket, code || 401, message, headers);
|
|
1098
|
+
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
1099
|
+
});
|
|
1100
|
+
if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
|
|
1101
|
+
}
|
|
1102
|
+
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
1103
|
+
}
|
|
1104
|
+
completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
|
|
1105
|
+
if (!socket.readable || !socket.writable) return socket.destroy();
|
|
1106
|
+
if (socket[kWebSocket]) throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");
|
|
1107
|
+
if (this._state > 0) return abortHandshake(socket, 503);
|
|
1108
|
+
let digest = createHash('sha1').update(key + GUID).digest('base64'), headers = [
|
|
1109
|
+
'HTTP/1.1 101 Switching Protocols',
|
|
1110
|
+
'Upgrade: websocket',
|
|
1111
|
+
'Connection: Upgrade',
|
|
1112
|
+
`Sec-WebSocket-Accept: ${digest}`
|
|
1113
|
+
], ws = new this.options.WebSocket(null, void 0, this.options);
|
|
1114
|
+
if (protocols.size) {
|
|
1115
|
+
let protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
|
|
1116
|
+
protocol && (headers.push(`Sec-WebSocket-Protocol: ${protocol}`), ws._protocol = protocol);
|
|
1117
|
+
}
|
|
1118
|
+
if (extensions[PerMessageDeflate.extensionName]) {
|
|
1119
|
+
let params = extensions[PerMessageDeflate.extensionName].params, value = extension.format({
|
|
1120
|
+
[PerMessageDeflate.extensionName]: [
|
|
1121
|
+
params
|
|
1122
|
+
]
|
|
1123
|
+
});
|
|
1124
|
+
headers.push(`Sec-WebSocket-Extensions: ${value}`), ws._extensions = extensions;
|
|
1125
|
+
}
|
|
1126
|
+
this.emit('headers', headers, req), socket.write(headers.concat('\r\n').join('\r\n')), socket.removeListener('error', socketOnError), ws.setSocket(socket, head, {
|
|
1127
|
+
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
1128
|
+
maxPayload: this.options.maxPayload,
|
|
1129
|
+
skipUTF8Validation: this.options.skipUTF8Validation
|
|
1130
|
+
}), this.clients && (this.clients.add(ws), ws.on('close', ()=>{
|
|
1131
|
+
this.clients.delete(ws), this._shouldEmitClose && !this.clients.size && process.nextTick(emitClose, this);
|
|
1132
|
+
})), cb(ws, req);
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
},
|
|
1136
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1137
|
+
let EventEmitter = __webpack_require__("events"), https = __webpack_require__("https?be51"), http = __webpack_require__("http?bf5e"), net = __webpack_require__("net"), tls = __webpack_require__("tls"), { randomBytes, createHash } = __webpack_require__("crypto"), { Duplex, Readable } = __webpack_require__("stream?91df"), { URL } = __webpack_require__("url?a954"), PerMessageDeflate = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"), Receiver = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/receiver.js"), Sender = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/sender.js"), { isBlob } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js"), { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"), { EventTarget: { addEventListener, removeEventListener } } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/event-target.js"), { format, parse } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js"), { toBuffer } = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js"), kAborted = Symbol('kAborted'), protocolVersions = [
|
|
1138
|
+
8,
|
|
1139
|
+
13
|
|
1140
|
+
], readyStates = [
|
|
1141
|
+
'CONNECTING',
|
|
1142
|
+
'OPEN',
|
|
1143
|
+
'CLOSING',
|
|
1144
|
+
'CLOSED'
|
|
1145
|
+
], subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
1146
|
+
class WebSocket extends EventEmitter {
|
|
1147
|
+
constructor(address, protocols, options){
|
|
1148
|
+
super(), this._binaryType = BINARY_TYPES[0], this._closeCode = 1006, this._closeFrameReceived = !1, this._closeFrameSent = !1, this._closeMessage = EMPTY_BUFFER, this._closeTimer = null, this._errorEmitted = !1, this._extensions = {}, this._paused = !1, this._protocol = '', this._readyState = WebSocket.CONNECTING, this._receiver = null, this._sender = null, this._socket = null, null !== address ? (this._bufferedAmount = 0, this._isServer = !1, this._redirects = 0, void 0 === protocols ? protocols = [] : Array.isArray(protocols) || ('object' == typeof protocols && null !== protocols ? (options = protocols, protocols = []) : protocols = [
|
|
1149
|
+
protocols
|
|
1150
|
+
]), initAsClient(this, address, protocols, options)) : (this._autoPong = options.autoPong, this._closeTimeout = options.closeTimeout, this._isServer = !0);
|
|
1151
|
+
}
|
|
1152
|
+
get binaryType() {
|
|
1153
|
+
return this._binaryType;
|
|
1154
|
+
}
|
|
1155
|
+
set binaryType(type) {
|
|
1156
|
+
BINARY_TYPES.includes(type) && (this._binaryType = type, this._receiver && (this._receiver._binaryType = type));
|
|
1157
|
+
}
|
|
1158
|
+
get bufferedAmount() {
|
|
1159
|
+
return this._socket ? this._socket._writableState.length + this._sender._bufferedBytes : this._bufferedAmount;
|
|
1160
|
+
}
|
|
1161
|
+
get extensions() {
|
|
1162
|
+
return Object.keys(this._extensions).join();
|
|
1163
|
+
}
|
|
1164
|
+
get isPaused() {
|
|
1165
|
+
return this._paused;
|
|
1166
|
+
}
|
|
1167
|
+
get onclose() {
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
get onerror() {
|
|
1171
|
+
return null;
|
|
1172
|
+
}
|
|
1173
|
+
get onopen() {
|
|
1174
|
+
return null;
|
|
1175
|
+
}
|
|
1176
|
+
get onmessage() {
|
|
1177
|
+
return null;
|
|
1178
|
+
}
|
|
1179
|
+
get protocol() {
|
|
1180
|
+
return this._protocol;
|
|
1181
|
+
}
|
|
1182
|
+
get readyState() {
|
|
1183
|
+
return this._readyState;
|
|
1184
|
+
}
|
|
1185
|
+
get url() {
|
|
1186
|
+
return this._url;
|
|
1187
|
+
}
|
|
1188
|
+
setSocket(socket, head, options) {
|
|
1189
|
+
let receiver = new Receiver({
|
|
1190
|
+
allowSynchronousEvents: options.allowSynchronousEvents,
|
|
1191
|
+
binaryType: this.binaryType,
|
|
1192
|
+
extensions: this._extensions,
|
|
1193
|
+
isServer: this._isServer,
|
|
1194
|
+
maxPayload: options.maxPayload,
|
|
1195
|
+
skipUTF8Validation: options.skipUTF8Validation
|
|
1196
|
+
}), sender = new Sender(socket, this._extensions, options.generateMask);
|
|
1197
|
+
this._receiver = receiver, this._sender = sender, this._socket = socket, receiver[kWebSocket] = this, sender[kWebSocket] = this, socket[kWebSocket] = this, receiver.on('conclude', receiverOnConclude), receiver.on('drain', receiverOnDrain), receiver.on('error', receiverOnError), receiver.on('message', receiverOnMessage), receiver.on('ping', receiverOnPing), receiver.on('pong', receiverOnPong), sender.onerror = senderOnError, socket.setTimeout && socket.setTimeout(0), socket.setNoDelay && socket.setNoDelay(), head.length > 0 && socket.unshift(head), socket.on('close', socketOnClose), socket.on('data', socketOnData), socket.on('end', socketOnEnd), socket.on('error', socketOnError), this._readyState = WebSocket.OPEN, this.emit('open');
|
|
1198
|
+
}
|
|
1199
|
+
emitClose() {
|
|
1200
|
+
if (!this._socket) {
|
|
1201
|
+
this._readyState = WebSocket.CLOSED, this.emit('close', this._closeCode, this._closeMessage);
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
this._extensions[PerMessageDeflate.extensionName] && this._extensions[PerMessageDeflate.extensionName].cleanup(), this._receiver.removeAllListeners(), this._readyState = WebSocket.CLOSED, this.emit('close', this._closeCode, this._closeMessage);
|
|
1205
|
+
}
|
|
1206
|
+
close(code, data) {
|
|
1207
|
+
if (this.readyState !== WebSocket.CLOSED) {
|
|
1208
|
+
if (this.readyState === WebSocket.CONNECTING) return void abortHandshake(this, this._req, 'WebSocket was closed before the connection was established');
|
|
1209
|
+
if (this.readyState === WebSocket.CLOSING) {
|
|
1210
|
+
this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end();
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
this._readyState = WebSocket.CLOSING, this._sender.close(code, data, !this._isServer, (err)=>{
|
|
1214
|
+
!err && (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end());
|
|
1215
|
+
}), setCloseTimer(this);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
pause() {
|
|
1219
|
+
this.readyState !== WebSocket.CONNECTING && this.readyState !== WebSocket.CLOSED && (this._paused = !0, this._socket.pause());
|
|
1220
|
+
}
|
|
1221
|
+
ping(data, mask, cb) {
|
|
1222
|
+
if (this.readyState === WebSocket.CONNECTING) throw Error('WebSocket is not open: readyState 0 (CONNECTING)');
|
|
1223
|
+
('function' == typeof data ? (cb = data, data = mask = void 0) : 'function' == typeof mask && (cb = mask, mask = void 0), 'number' == typeof data && (data = data.toString()), this.readyState !== WebSocket.OPEN) ? sendAfterClose(this, data, cb) : (void 0 === mask && (mask = !this._isServer), this._sender.ping(data || EMPTY_BUFFER, mask, cb));
|
|
1224
|
+
}
|
|
1225
|
+
pong(data, mask, cb) {
|
|
1226
|
+
if (this.readyState === WebSocket.CONNECTING) throw Error('WebSocket is not open: readyState 0 (CONNECTING)');
|
|
1227
|
+
('function' == typeof data ? (cb = data, data = mask = void 0) : 'function' == typeof mask && (cb = mask, mask = void 0), 'number' == typeof data && (data = data.toString()), this.readyState !== WebSocket.OPEN) ? sendAfterClose(this, data, cb) : (void 0 === mask && (mask = !this._isServer), this._sender.pong(data || EMPTY_BUFFER, mask, cb));
|
|
1228
|
+
}
|
|
1229
|
+
resume() {
|
|
1230
|
+
this.readyState !== WebSocket.CONNECTING && this.readyState !== WebSocket.CLOSED && (this._paused = !1, this._receiver._writableState.needDrain || this._socket.resume());
|
|
1231
|
+
}
|
|
1232
|
+
send(data, options, cb) {
|
|
1233
|
+
if (this.readyState === WebSocket.CONNECTING) throw Error('WebSocket is not open: readyState 0 (CONNECTING)');
|
|
1234
|
+
if ('function' == typeof options && (cb = options, options = {}), 'number' == typeof data && (data = data.toString()), this.readyState !== WebSocket.OPEN) return void sendAfterClose(this, data, cb);
|
|
1235
|
+
let opts = {
|
|
1236
|
+
binary: 'string' != typeof data,
|
|
1237
|
+
mask: !this._isServer,
|
|
1238
|
+
compress: !0,
|
|
1239
|
+
fin: !0,
|
|
1240
|
+
...options
|
|
1241
|
+
};
|
|
1242
|
+
this._extensions[PerMessageDeflate.extensionName] || (opts.compress = !1), this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
1243
|
+
}
|
|
1244
|
+
terminate() {
|
|
1245
|
+
if (this.readyState !== WebSocket.CLOSED) {
|
|
1246
|
+
if (this.readyState === WebSocket.CONNECTING) return void abortHandshake(this, this._req, 'WebSocket was closed before the connection was established');
|
|
1247
|
+
this._socket && (this._readyState = WebSocket.CLOSING, this._socket.destroy());
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
function initAsClient(websocket, address, protocols, options) {
|
|
1252
|
+
let parsedUrl, invalidUrlMessage, perMessageDeflate, req, opts = {
|
|
1253
|
+
allowSynchronousEvents: !0,
|
|
1254
|
+
autoPong: !0,
|
|
1255
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
1256
|
+
protocolVersion: protocolVersions[1],
|
|
1257
|
+
maxPayload: 104857600,
|
|
1258
|
+
skipUTF8Validation: !1,
|
|
1259
|
+
perMessageDeflate: !0,
|
|
1260
|
+
followRedirects: !1,
|
|
1261
|
+
maxRedirects: 10,
|
|
1262
|
+
...options,
|
|
1263
|
+
socketPath: void 0,
|
|
1264
|
+
hostname: void 0,
|
|
1265
|
+
protocol: void 0,
|
|
1266
|
+
timeout: void 0,
|
|
1267
|
+
method: 'GET',
|
|
1268
|
+
host: void 0,
|
|
1269
|
+
path: void 0,
|
|
1270
|
+
port: void 0
|
|
1271
|
+
};
|
|
1272
|
+
if (websocket._autoPong = opts.autoPong, websocket._closeTimeout = opts.closeTimeout, !protocolVersions.includes(opts.protocolVersion)) throw RangeError(`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(', ')})`);
|
|
1273
|
+
if (address instanceof URL) parsedUrl = address;
|
|
1274
|
+
else try {
|
|
1275
|
+
parsedUrl = new URL(address);
|
|
1276
|
+
} catch {
|
|
1277
|
+
throw SyntaxError(`Invalid URL: ${address}`);
|
|
1278
|
+
}
|
|
1279
|
+
'http:' === parsedUrl.protocol ? parsedUrl.protocol = 'ws:' : 'https:' === parsedUrl.protocol && (parsedUrl.protocol = 'wss:'), websocket._url = parsedUrl.href;
|
|
1280
|
+
let isSecure = 'wss:' === parsedUrl.protocol, isIpcUrl = 'ws+unix:' === parsedUrl.protocol;
|
|
1281
|
+
if ('ws:' === parsedUrl.protocol || isSecure || isIpcUrl ? isIpcUrl && !parsedUrl.pathname ? invalidUrlMessage = "The URL's pathname is empty" : parsedUrl.hash && (invalidUrlMessage = 'The URL contains a fragment identifier') : invalidUrlMessage = 'The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"', invalidUrlMessage) {
|
|
1282
|
+
let err = SyntaxError(invalidUrlMessage);
|
|
1283
|
+
if (0 !== websocket._redirects) return void emitErrorAndClose(websocket, err);
|
|
1284
|
+
throw err;
|
|
1285
|
+
}
|
|
1286
|
+
let defaultPort = isSecure ? 443 : 80, key = randomBytes(16).toString('base64'), request = isSecure ? https.request : http.request, protocolSet = new Set();
|
|
1287
|
+
if (opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect), opts.defaultPort = opts.defaultPort || defaultPort, opts.port = parsedUrl.port || defaultPort, opts.host = parsedUrl.hostname.startsWith('[') ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname, opts.headers = {
|
|
1288
|
+
...opts.headers,
|
|
1289
|
+
'Sec-WebSocket-Version': opts.protocolVersion,
|
|
1290
|
+
'Sec-WebSocket-Key': key,
|
|
1291
|
+
Connection: 'Upgrade',
|
|
1292
|
+
Upgrade: 'websocket'
|
|
1293
|
+
}, opts.path = parsedUrl.pathname + parsedUrl.search, opts.timeout = opts.handshakeTimeout, opts.perMessageDeflate && (perMessageDeflate = new PerMessageDeflate({
|
|
1294
|
+
...opts.perMessageDeflate,
|
|
1295
|
+
isServer: !1,
|
|
1296
|
+
maxPayload: opts.maxPayload
|
|
1297
|
+
}), opts.headers['Sec-WebSocket-Extensions'] = format({
|
|
1298
|
+
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
|
1299
|
+
})), protocols.length) {
|
|
1300
|
+
for (let protocol of protocols){
|
|
1301
|
+
if ('string' != typeof protocol || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) throw SyntaxError('An invalid or duplicated subprotocol was specified');
|
|
1302
|
+
protocolSet.add(protocol);
|
|
1303
|
+
}
|
|
1304
|
+
opts.headers['Sec-WebSocket-Protocol'] = protocols.join(',');
|
|
1305
|
+
}
|
|
1306
|
+
if (opts.origin && (opts.protocolVersion < 13 ? opts.headers['Sec-WebSocket-Origin'] = opts.origin : opts.headers.Origin = opts.origin), (parsedUrl.username || parsedUrl.password) && (opts.auth = `${parsedUrl.username}:${parsedUrl.password}`), isIpcUrl) {
|
|
1307
|
+
let parts = opts.path.split(':');
|
|
1308
|
+
opts.socketPath = parts[0], opts.path = parts[1];
|
|
1309
|
+
}
|
|
1310
|
+
if (opts.followRedirects) {
|
|
1311
|
+
if (0 === websocket._redirects) {
|
|
1312
|
+
websocket._originalIpc = isIpcUrl, websocket._originalSecure = isSecure, websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
|
|
1313
|
+
let headers = options && options.headers;
|
|
1314
|
+
if (options = {
|
|
1315
|
+
...options,
|
|
1316
|
+
headers: {}
|
|
1317
|
+
}, headers) for (let [key, value] of Object.entries(headers))options.headers[key.toLowerCase()] = value;
|
|
1318
|
+
} else if (0 === websocket.listenerCount('redirect')) {
|
|
1319
|
+
let isSameHost = isIpcUrl ? !!websocket._originalIpc && opts.socketPath === websocket._originalHostOrSocketPath : !websocket._originalIpc && parsedUrl.host === websocket._originalHostOrSocketPath;
|
|
1320
|
+
isSameHost && (!websocket._originalSecure || isSecure) || (delete opts.headers.authorization, delete opts.headers.cookie, isSameHost || delete opts.headers.host, opts.auth = void 0);
|
|
1321
|
+
}
|
|
1322
|
+
opts.auth && !options.headers.authorization && (options.headers.authorization = 'Basic ' + Buffer.from(opts.auth).toString('base64')), req = websocket._req = request(opts), websocket._redirects && websocket.emit('redirect', websocket.url, req);
|
|
1323
|
+
} else req = websocket._req = request(opts);
|
|
1324
|
+
opts.timeout && req.on('timeout', ()=>{
|
|
1325
|
+
abortHandshake(websocket, req, 'Opening handshake has timed out');
|
|
1326
|
+
}), req.on('error', (err)=>{
|
|
1327
|
+
null === req || req[kAborted] || (req = websocket._req = null, emitErrorAndClose(websocket, err));
|
|
1328
|
+
}), req.on('response', (res)=>{
|
|
1329
|
+
let location = res.headers.location, statusCode = res.statusCode;
|
|
1330
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
1331
|
+
let addr;
|
|
1332
|
+
if (++websocket._redirects > opts.maxRedirects) return void abortHandshake(websocket, req, 'Maximum redirects exceeded');
|
|
1333
|
+
req.abort();
|
|
1334
|
+
try {
|
|
1335
|
+
addr = new URL(location, address);
|
|
1336
|
+
} catch (e) {
|
|
1337
|
+
emitErrorAndClose(websocket, SyntaxError(`Invalid URL: ${location}`));
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
initAsClient(websocket, addr, protocols, options);
|
|
1341
|
+
} else websocket.emit('unexpected-response', req, res) || abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);
|
|
1342
|
+
}), req.on('upgrade', (res, socket, head)=>{
|
|
1343
|
+
let protError;
|
|
1344
|
+
if (websocket.emit('upgrade', res), websocket.readyState !== WebSocket.CONNECTING) return;
|
|
1345
|
+
req = websocket._req = null;
|
|
1346
|
+
let upgrade = res.headers.upgrade;
|
|
1347
|
+
if (void 0 === upgrade || 'websocket' !== upgrade.toLowerCase()) return void abortHandshake(websocket, socket, 'Invalid Upgrade header');
|
|
1348
|
+
let digest = createHash('sha1').update(key + GUID).digest('base64');
|
|
1349
|
+
if (res.headers['sec-websocket-accept'] !== digest) return void abortHandshake(websocket, socket, 'Invalid Sec-WebSocket-Accept header');
|
|
1350
|
+
let serverProt = res.headers['sec-websocket-protocol'];
|
|
1351
|
+
if (void 0 !== serverProt ? protocolSet.size ? protocolSet.has(serverProt) || (protError = 'Server sent an invalid subprotocol') : protError = 'Server sent a subprotocol but none was requested' : protocolSet.size && (protError = 'Server sent no subprotocol'), protError) return void abortHandshake(websocket, socket, protError);
|
|
1352
|
+
serverProt && (websocket._protocol = serverProt);
|
|
1353
|
+
let secWebSocketExtensions = res.headers['sec-websocket-extensions'];
|
|
1354
|
+
if (void 0 !== secWebSocketExtensions) {
|
|
1355
|
+
let extensions;
|
|
1356
|
+
if (!perMessageDeflate) return void abortHandshake(websocket, socket, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
|
|
1357
|
+
try {
|
|
1358
|
+
extensions = parse(secWebSocketExtensions);
|
|
1359
|
+
} catch (err) {
|
|
1360
|
+
abortHandshake(websocket, socket, 'Invalid Sec-WebSocket-Extensions header');
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
let extensionNames = Object.keys(extensions);
|
|
1364
|
+
if (1 !== extensionNames.length || extensionNames[0] !== PerMessageDeflate.extensionName) return void abortHandshake(websocket, socket, 'Server indicated an extension that was not requested');
|
|
1365
|
+
try {
|
|
1366
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
|
|
1367
|
+
} catch (err) {
|
|
1368
|
+
abortHandshake(websocket, socket, 'Invalid Sec-WebSocket-Extensions header');
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
1372
|
+
}
|
|
1373
|
+
websocket.setSocket(socket, head, {
|
|
1374
|
+
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
1375
|
+
generateMask: opts.generateMask,
|
|
1376
|
+
maxPayload: opts.maxPayload,
|
|
1377
|
+
skipUTF8Validation: opts.skipUTF8Validation
|
|
1378
|
+
});
|
|
1379
|
+
}), opts.finishRequest ? opts.finishRequest(req, websocket) : req.end();
|
|
1380
|
+
}
|
|
1381
|
+
function emitErrorAndClose(websocket, err) {
|
|
1382
|
+
websocket._readyState = WebSocket.CLOSING, websocket._errorEmitted = !0, websocket.emit('error', err), websocket.emitClose();
|
|
1383
|
+
}
|
|
1384
|
+
function netConnect(options) {
|
|
1385
|
+
return options.path = options.socketPath, net.connect(options);
|
|
1386
|
+
}
|
|
1387
|
+
function tlsConnect(options) {
|
|
1388
|
+
return options.path = void 0, options.servername || '' === options.servername || (options.servername = net.isIP(options.host) ? '' : options.host), tls.connect(options);
|
|
1389
|
+
}
|
|
1390
|
+
function abortHandshake(websocket, stream, message) {
|
|
1391
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
1392
|
+
let err = Error(message);
|
|
1393
|
+
Error.captureStackTrace(err, abortHandshake), stream.setHeader ? (stream[kAborted] = !0, stream.abort(), stream.socket && !stream.socket.destroyed && stream.socket.destroy(), process.nextTick(emitErrorAndClose, websocket, err)) : (stream.destroy(err), stream.once('error', websocket.emit.bind(websocket, 'error')), stream.once('close', websocket.emitClose.bind(websocket)));
|
|
1394
|
+
}
|
|
1395
|
+
function sendAfterClose(websocket, data, cb) {
|
|
1396
|
+
if (data) {
|
|
1397
|
+
let length = isBlob(data) ? data.size : toBuffer(data).length;
|
|
1398
|
+
websocket._socket ? websocket._sender._bufferedBytes += length : websocket._bufferedAmount += length;
|
|
1399
|
+
}
|
|
1400
|
+
if (cb) {
|
|
1401
|
+
let err = Error(`WebSocket is not open: readyState ${websocket.readyState} (${readyStates[websocket.readyState]})`);
|
|
1402
|
+
process.nextTick(cb, err);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
function receiverOnConclude(code, reason) {
|
|
1406
|
+
let websocket = this[kWebSocket];
|
|
1407
|
+
websocket._closeFrameReceived = !0, websocket._closeMessage = reason, websocket._closeCode = code, void 0 !== websocket._socket[kWebSocket] && (websocket._socket.removeListener('data', socketOnData), process.nextTick(resume, websocket._socket), 1005 === code ? websocket.close() : websocket.close(code, reason));
|
|
1408
|
+
}
|
|
1409
|
+
function receiverOnDrain() {
|
|
1410
|
+
let websocket = this[kWebSocket];
|
|
1411
|
+
websocket.isPaused || websocket._socket.resume();
|
|
1412
|
+
}
|
|
1413
|
+
function receiverOnError(err) {
|
|
1414
|
+
let websocket = this[kWebSocket];
|
|
1415
|
+
void 0 !== websocket._socket[kWebSocket] && (websocket._socket.removeListener('data', socketOnData), process.nextTick(resume, websocket._socket), websocket.close(err[kStatusCode])), websocket._errorEmitted || (websocket._errorEmitted = !0, websocket.emit('error', err));
|
|
1416
|
+
}
|
|
1417
|
+
function receiverOnFinish() {
|
|
1418
|
+
this[kWebSocket].emitClose();
|
|
1419
|
+
}
|
|
1420
|
+
function receiverOnMessage(data, isBinary) {
|
|
1421
|
+
this[kWebSocket].emit('message', data, isBinary);
|
|
1422
|
+
}
|
|
1423
|
+
function receiverOnPing(data) {
|
|
1424
|
+
let websocket = this[kWebSocket];
|
|
1425
|
+
websocket._autoPong && websocket.pong(data, !this._isServer, NOOP), websocket.emit('ping', data);
|
|
1426
|
+
}
|
|
1427
|
+
function receiverOnPong(data) {
|
|
1428
|
+
this[kWebSocket].emit('pong', data);
|
|
1429
|
+
}
|
|
1430
|
+
function resume(stream) {
|
|
1431
|
+
stream.resume();
|
|
1432
|
+
}
|
|
1433
|
+
function senderOnError(err) {
|
|
1434
|
+
let websocket = this[kWebSocket];
|
|
1435
|
+
websocket.readyState !== WebSocket.CLOSED && (websocket.readyState === WebSocket.OPEN && (websocket._readyState = WebSocket.CLOSING, setCloseTimer(websocket)), this._socket.end(), websocket._errorEmitted || (websocket._errorEmitted = !0, websocket.emit('error', err)));
|
|
1436
|
+
}
|
|
1437
|
+
function setCloseTimer(websocket) {
|
|
1438
|
+
websocket._closeTimer = setTimeout(websocket._socket.destroy.bind(websocket._socket), websocket._closeTimeout);
|
|
1439
|
+
}
|
|
1440
|
+
function socketOnClose() {
|
|
1441
|
+
let websocket = this[kWebSocket];
|
|
1442
|
+
if (this.removeListener('close', socketOnClose), this.removeListener('data', socketOnData), this.removeListener('end', socketOnEnd), websocket._readyState = WebSocket.CLOSING, !this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && 0 !== this._readableState.length) {
|
|
1443
|
+
let chunk = this.read(this._readableState.length);
|
|
1444
|
+
websocket._receiver.write(chunk);
|
|
1445
|
+
}
|
|
1446
|
+
websocket._receiver.end(), this[kWebSocket] = void 0, clearTimeout(websocket._closeTimer), websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted ? websocket.emitClose() : (websocket._receiver.on('error', receiverOnFinish), websocket._receiver.on('finish', receiverOnFinish));
|
|
1447
|
+
}
|
|
1448
|
+
function socketOnData(chunk) {
|
|
1449
|
+
this[kWebSocket]._receiver.write(chunk) || this.pause();
|
|
1450
|
+
}
|
|
1451
|
+
function socketOnEnd() {
|
|
1452
|
+
let websocket = this[kWebSocket];
|
|
1453
|
+
websocket._readyState = WebSocket.CLOSING, websocket._receiver.end(), this.end();
|
|
1454
|
+
}
|
|
1455
|
+
function socketOnError() {
|
|
1456
|
+
let websocket = this[kWebSocket];
|
|
1457
|
+
this.removeListener('error', socketOnError), this.on('error', NOOP), websocket && (websocket._readyState = WebSocket.CLOSING, this.destroy());
|
|
1458
|
+
}
|
|
1459
|
+
Object.defineProperty(WebSocket, 'CONNECTING', {
|
|
1460
|
+
enumerable: !0,
|
|
1461
|
+
value: readyStates.indexOf('CONNECTING')
|
|
1462
|
+
}), Object.defineProperty(WebSocket.prototype, 'CONNECTING', {
|
|
1463
|
+
enumerable: !0,
|
|
1464
|
+
value: readyStates.indexOf('CONNECTING')
|
|
1465
|
+
}), Object.defineProperty(WebSocket, 'OPEN', {
|
|
1466
|
+
enumerable: !0,
|
|
1467
|
+
value: readyStates.indexOf('OPEN')
|
|
1468
|
+
}), Object.defineProperty(WebSocket.prototype, 'OPEN', {
|
|
1469
|
+
enumerable: !0,
|
|
1470
|
+
value: readyStates.indexOf('OPEN')
|
|
1471
|
+
}), Object.defineProperty(WebSocket, 'CLOSING', {
|
|
1472
|
+
enumerable: !0,
|
|
1473
|
+
value: readyStates.indexOf('CLOSING')
|
|
1474
|
+
}), Object.defineProperty(WebSocket.prototype, 'CLOSING', {
|
|
1475
|
+
enumerable: !0,
|
|
1476
|
+
value: readyStates.indexOf('CLOSING')
|
|
1477
|
+
}), Object.defineProperty(WebSocket, 'CLOSED', {
|
|
1478
|
+
enumerable: !0,
|
|
1479
|
+
value: readyStates.indexOf('CLOSED')
|
|
1480
|
+
}), Object.defineProperty(WebSocket.prototype, 'CLOSED', {
|
|
1481
|
+
enumerable: !0,
|
|
1482
|
+
value: readyStates.indexOf('CLOSED')
|
|
1483
|
+
}), [
|
|
1484
|
+
'binaryType',
|
|
1485
|
+
'bufferedAmount',
|
|
1486
|
+
'extensions',
|
|
1487
|
+
'isPaused',
|
|
1488
|
+
'protocol',
|
|
1489
|
+
'readyState',
|
|
1490
|
+
'url'
|
|
1491
|
+
].forEach((property)=>{
|
|
1492
|
+
Object.defineProperty(WebSocket.prototype, property, {
|
|
1493
|
+
enumerable: !0
|
|
1494
|
+
});
|
|
1495
|
+
}), [
|
|
1496
|
+
'open',
|
|
1497
|
+
'error',
|
|
1498
|
+
'close',
|
|
1499
|
+
'message'
|
|
1500
|
+
].forEach((method)=>{
|
|
1501
|
+
Object.defineProperty(WebSocket.prototype, `on${method}`, {
|
|
1502
|
+
enumerable: !0,
|
|
1503
|
+
get () {
|
|
1504
|
+
for (let listener of this.listeners(method))if (listener[kForOnEventAttribute]) return listener[kListener];
|
|
1505
|
+
return null;
|
|
1506
|
+
},
|
|
1507
|
+
set (handler) {
|
|
1508
|
+
for (let listener of this.listeners(method))if (listener[kForOnEventAttribute]) {
|
|
1509
|
+
this.removeListener(method, listener);
|
|
1510
|
+
break;
|
|
1511
|
+
}
|
|
1512
|
+
'function' == typeof handler && this.addEventListener(method, handler, {
|
|
1513
|
+
[kForOnEventAttribute]: !0
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
});
|
|
1517
|
+
}), WebSocket.prototype.addEventListener = addEventListener, WebSocket.prototype.removeEventListener = removeEventListener, module.exports = WebSocket;
|
|
1518
|
+
},
|
|
1519
|
+
buffer (module) {
|
|
1520
|
+
module.exports = __rspack_external_buffer;
|
|
1521
|
+
},
|
|
1522
|
+
crypto (module) {
|
|
1523
|
+
module.exports = __rspack_external_crypto;
|
|
1524
|
+
},
|
|
1525
|
+
"http?bf5e" (module) {
|
|
1526
|
+
module.exports = __rspack_external_http;
|
|
1527
|
+
},
|
|
1528
|
+
"https?be51" (module) {
|
|
1529
|
+
module.exports = __rspack_external_https;
|
|
1530
|
+
},
|
|
1531
|
+
net (module) {
|
|
1532
|
+
module.exports = __rspack_external_net;
|
|
1533
|
+
},
|
|
1534
|
+
"stream?91df" (module) {
|
|
1535
|
+
module.exports = __rspack_external_stream;
|
|
1536
|
+
},
|
|
1537
|
+
tls (module) {
|
|
1538
|
+
module.exports = __rspack_external_tls;
|
|
1539
|
+
},
|
|
1540
|
+
"url?a954" (module) {
|
|
1541
|
+
module.exports = __rspack_external_url;
|
|
1542
|
+
},
|
|
1543
|
+
"zlib?d5a8" (module) {
|
|
1544
|
+
module.exports = __rspack_external_zlib;
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
let websocket_server = __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket-server.js");
|
|
1548
|
+
__webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/stream.js"), __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js"), __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"), __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/receiver.js"), __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/sender.js"), __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/subprotocol.js"), __webpack_require__("../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js");
|
|
1549
|
+
export { websocket_server as WebSocketServer };
|