@onting/browser 0.0.0-0 → 0.1.0-main.202606180757.8b506d4
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/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/browser.d.ts +6 -1
- package/dist/browser.js +753 -3
- package/dist/browser.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -4
- package/src/bin-open/index.ts +254 -0
- package/src/bin-open/private/buildWebDriver.ts +100 -0
- package/src/bin-open/private/createSequencer.ts +46 -0
- package/src/bin-open/private/delta.ts +13 -0
- package/src/bin-open/private/findChromeDriverBin.ts +21 -0
- package/src/bin-open/private/findEdgeDriverBin.ts +21 -0
- package/src/bin-open/private/findGeckoDriverBin.ts +21 -0
- package/src/bin-open/private/findHostIP.ts +15 -0
- package/src/bin-open/private/findLocalIP.ts +15 -0
- package/src/bin-open/private/findSafariDriverBin.ts +17 -0
- package/src/bin-open/private/isWSL2.ts +20 -0
- package/src/bin-open/private/shortenRealmId.ts +7 -0
- package/dist/browser.mjs +0 -3
- package/dist/browser.mjs.map +0 -1
- /package/dist/{browser.d.mts → index.d.ts} +0 -0
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,755 @@
|
|
|
1
|
-
|
|
1
|
+
// src/browser/getStub.ts
|
|
2
|
+
import { createClientStub } from "@onting/rpc/client.js";
|
|
2
3
|
|
|
3
|
-
//
|
|
4
|
-
|
|
4
|
+
// ../../node_modules/@onting/selenium-webdriver-message-port/dist/browser.js
|
|
5
|
+
var byteToHex = [];
|
|
6
|
+
for (let i = 0; i < 256; ++i) {
|
|
7
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
8
|
+
}
|
|
9
|
+
function unsafeStringify(arr, offset = 0) {
|
|
10
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
var rnds8 = new Uint8Array(16);
|
|
13
|
+
function rng() {
|
|
14
|
+
return crypto.getRandomValues(rnds8);
|
|
15
|
+
}
|
|
16
|
+
var _state = {};
|
|
17
|
+
function v7(options, buf, offset) {
|
|
18
|
+
let bytes;
|
|
19
|
+
if (options) {
|
|
20
|
+
bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
|
|
21
|
+
} else {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
const rnds = rng();
|
|
24
|
+
updateV7State(_state, now, rnds);
|
|
25
|
+
bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
|
|
26
|
+
}
|
|
27
|
+
return buf ?? unsafeStringify(bytes);
|
|
28
|
+
}
|
|
29
|
+
function updateV7State(state, now, rnds) {
|
|
30
|
+
state.msecs ??= -Infinity;
|
|
31
|
+
state.seq ??= 0;
|
|
32
|
+
if (now > state.msecs) {
|
|
33
|
+
state.seq = rnds[6] << 23 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
34
|
+
state.msecs = now;
|
|
35
|
+
} else {
|
|
36
|
+
state.seq = state.seq + 1 | 0;
|
|
37
|
+
if (state.seq === 0) {
|
|
38
|
+
state.msecs++;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return state;
|
|
42
|
+
}
|
|
43
|
+
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
|
44
|
+
if (rnds.length < 16) {
|
|
45
|
+
throw new Error("Random bytes length must be >= 16");
|
|
46
|
+
}
|
|
47
|
+
if (!buf) {
|
|
48
|
+
buf = new Uint8Array(16);
|
|
49
|
+
offset = 0;
|
|
50
|
+
} else {
|
|
51
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
52
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
msecs ??= Date.now();
|
|
56
|
+
seq ??= rnds[6] * 127 << 24 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
57
|
+
buf[offset++] = msecs / 1099511627776 & 255;
|
|
58
|
+
buf[offset++] = msecs / 4294967296 & 255;
|
|
59
|
+
buf[offset++] = msecs / 16777216 & 255;
|
|
60
|
+
buf[offset++] = msecs / 65536 & 255;
|
|
61
|
+
buf[offset++] = msecs / 256 & 255;
|
|
62
|
+
buf[offset++] = msecs & 255;
|
|
63
|
+
buf[offset++] = 112 | seq >>> 28 & 15;
|
|
64
|
+
buf[offset++] = seq >>> 20 & 255;
|
|
65
|
+
buf[offset++] = 128 | seq >>> 14 & 63;
|
|
66
|
+
buf[offset++] = seq >>> 6 & 255;
|
|
67
|
+
buf[offset++] = seq << 2 & 255 | rnds[10] & 3;
|
|
68
|
+
buf[offset++] = rnds[11];
|
|
69
|
+
buf[offset++] = rnds[12];
|
|
70
|
+
buf[offset++] = rnds[13];
|
|
71
|
+
buf[offset++] = rnds[14];
|
|
72
|
+
buf[offset++] = rnds[15];
|
|
73
|
+
return buf;
|
|
74
|
+
}
|
|
75
|
+
var v7_default = v7;
|
|
76
|
+
var store$4;
|
|
77
|
+
var DEFAULT_CONFIG = {
|
|
78
|
+
lang: void 0,
|
|
79
|
+
message: void 0,
|
|
80
|
+
abortEarly: void 0,
|
|
81
|
+
abortPipeEarly: void 0
|
|
82
|
+
};
|
|
83
|
+
// @__NO_SIDE_EFFECTS__
|
|
84
|
+
function getGlobalConfig(config$1) {
|
|
85
|
+
if (!config$1 && !store$4) return DEFAULT_CONFIG;
|
|
86
|
+
return {
|
|
87
|
+
lang: config$1?.lang ?? store$4?.lang,
|
|
88
|
+
message: config$1?.message,
|
|
89
|
+
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
90
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
var store$3;
|
|
94
|
+
// @__NO_SIDE_EFFECTS__
|
|
95
|
+
function getGlobalMessage(lang) {
|
|
96
|
+
return store$3?.get(lang);
|
|
97
|
+
}
|
|
98
|
+
var store$2;
|
|
99
|
+
// @__NO_SIDE_EFFECTS__
|
|
100
|
+
function getSchemaMessage(lang) {
|
|
101
|
+
return store$2?.get(lang);
|
|
102
|
+
}
|
|
103
|
+
var store$1;
|
|
104
|
+
// @__NO_SIDE_EFFECTS__
|
|
105
|
+
function getSpecificMessage(reference, lang) {
|
|
106
|
+
return store$1?.get(reference)?.get(lang);
|
|
107
|
+
}
|
|
108
|
+
// @__NO_SIDE_EFFECTS__
|
|
109
|
+
function _stringify(input) {
|
|
110
|
+
const type = typeof input;
|
|
111
|
+
if (type === "string") return `"${input}"`;
|
|
112
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
113
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
114
|
+
return type;
|
|
115
|
+
}
|
|
116
|
+
function _addIssue(context, label, dataset, config$1, other) {
|
|
117
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
118
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
119
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
120
|
+
const issue = {
|
|
121
|
+
kind: context.kind,
|
|
122
|
+
type: context.type,
|
|
123
|
+
input,
|
|
124
|
+
expected,
|
|
125
|
+
received,
|
|
126
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
127
|
+
requirement: context.requirement,
|
|
128
|
+
path: other?.path,
|
|
129
|
+
issues: other?.issues,
|
|
130
|
+
lang: config$1.lang,
|
|
131
|
+
abortEarly: config$1.abortEarly,
|
|
132
|
+
abortPipeEarly: config$1.abortPipeEarly
|
|
133
|
+
};
|
|
134
|
+
const isSchema = context.kind === "schema";
|
|
135
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
136
|
+
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
137
|
+
if (isSchema) dataset.typed = false;
|
|
138
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
139
|
+
else dataset.issues = [issue];
|
|
140
|
+
}
|
|
141
|
+
var _standardCache = /* @__PURE__ */ new WeakMap();
|
|
142
|
+
// @__NO_SIDE_EFFECTS__
|
|
143
|
+
function _getStandardProps(context) {
|
|
144
|
+
let cached = _standardCache.get(context);
|
|
145
|
+
if (!cached) {
|
|
146
|
+
cached = {
|
|
147
|
+
version: 1,
|
|
148
|
+
vendor: "valibot",
|
|
149
|
+
validate(value$1) {
|
|
150
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
_standardCache.set(context, cached);
|
|
154
|
+
}
|
|
155
|
+
return cached;
|
|
156
|
+
}
|
|
157
|
+
var ValiError = class extends Error {
|
|
158
|
+
/**
|
|
159
|
+
* Creates a Valibot error with useful information.
|
|
160
|
+
*
|
|
161
|
+
* @param issues The error issues.
|
|
162
|
+
*/
|
|
163
|
+
constructor(issues) {
|
|
164
|
+
super(issues[0].message);
|
|
165
|
+
this.name = "ValiError";
|
|
166
|
+
this.issues = issues;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
// @__NO_SIDE_EFFECTS__
|
|
170
|
+
function readonly() {
|
|
171
|
+
return {
|
|
172
|
+
kind: "transformation",
|
|
173
|
+
type: "readonly",
|
|
174
|
+
reference: readonly,
|
|
175
|
+
async: false,
|
|
176
|
+
"~run"(dataset) {
|
|
177
|
+
return dataset;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// @__NO_SIDE_EFFECTS__
|
|
182
|
+
function getFallback(schema, dataset, config$1) {
|
|
183
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
184
|
+
}
|
|
185
|
+
// @__NO_SIDE_EFFECTS__
|
|
186
|
+
function getDefault(schema, dataset, config$1) {
|
|
187
|
+
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
188
|
+
}
|
|
189
|
+
// @__NO_SIDE_EFFECTS__
|
|
190
|
+
function array(item, message$1) {
|
|
191
|
+
return {
|
|
192
|
+
kind: "schema",
|
|
193
|
+
type: "array",
|
|
194
|
+
reference: array,
|
|
195
|
+
expects: "Array",
|
|
196
|
+
async: false,
|
|
197
|
+
item,
|
|
198
|
+
message: message$1,
|
|
199
|
+
get "~standard"() {
|
|
200
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
201
|
+
},
|
|
202
|
+
"~run"(dataset, config$1) {
|
|
203
|
+
const input = dataset.value;
|
|
204
|
+
if (Array.isArray(input)) {
|
|
205
|
+
dataset.typed = true;
|
|
206
|
+
dataset.value = [];
|
|
207
|
+
for (let key = 0; key < input.length; key++) {
|
|
208
|
+
const value$1 = input[key];
|
|
209
|
+
const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
|
|
210
|
+
if (itemDataset.issues) {
|
|
211
|
+
const pathItem = {
|
|
212
|
+
type: "array",
|
|
213
|
+
origin: "value",
|
|
214
|
+
input,
|
|
215
|
+
key,
|
|
216
|
+
value: value$1
|
|
217
|
+
};
|
|
218
|
+
for (const issue of itemDataset.issues) {
|
|
219
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
220
|
+
else issue.path = [pathItem];
|
|
221
|
+
dataset.issues?.push(issue);
|
|
222
|
+
}
|
|
223
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
224
|
+
if (config$1.abortEarly) {
|
|
225
|
+
dataset.typed = false;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
230
|
+
dataset.value.push(itemDataset.value);
|
|
231
|
+
}
|
|
232
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
233
|
+
return dataset;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
// @__NO_SIDE_EFFECTS__
|
|
238
|
+
function object(entries$1, message$1) {
|
|
239
|
+
return {
|
|
240
|
+
kind: "schema",
|
|
241
|
+
type: "object",
|
|
242
|
+
reference: object,
|
|
243
|
+
expects: "Object",
|
|
244
|
+
async: false,
|
|
245
|
+
entries: entries$1,
|
|
246
|
+
message: message$1,
|
|
247
|
+
get "~standard"() {
|
|
248
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
249
|
+
},
|
|
250
|
+
"~run"(dataset, config$1) {
|
|
251
|
+
const input = dataset.value;
|
|
252
|
+
if (input && typeof input === "object") {
|
|
253
|
+
dataset.typed = true;
|
|
254
|
+
dataset.value = {};
|
|
255
|
+
for (const key in this.entries) {
|
|
256
|
+
const valueSchema = this.entries[key];
|
|
257
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
258
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
259
|
+
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
260
|
+
if (valueDataset.issues) {
|
|
261
|
+
const pathItem = {
|
|
262
|
+
type: "object",
|
|
263
|
+
origin: "value",
|
|
264
|
+
input,
|
|
265
|
+
key,
|
|
266
|
+
value: value$1
|
|
267
|
+
};
|
|
268
|
+
for (const issue of valueDataset.issues) {
|
|
269
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
270
|
+
else issue.path = [pathItem];
|
|
271
|
+
dataset.issues?.push(issue);
|
|
272
|
+
}
|
|
273
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
274
|
+
if (config$1.abortEarly) {
|
|
275
|
+
dataset.typed = false;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
280
|
+
dataset.value[key] = valueDataset.value;
|
|
281
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
282
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
283
|
+
_addIssue(this, "key", dataset, config$1, {
|
|
284
|
+
input: void 0,
|
|
285
|
+
expected: `"${key}"`,
|
|
286
|
+
path: [{
|
|
287
|
+
type: "object",
|
|
288
|
+
origin: "key",
|
|
289
|
+
input,
|
|
290
|
+
key,
|
|
291
|
+
value: input[key]
|
|
292
|
+
}]
|
|
293
|
+
});
|
|
294
|
+
if (config$1.abortEarly) break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
298
|
+
return dataset;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
// @__NO_SIDE_EFFECTS__
|
|
303
|
+
function string(message$1) {
|
|
304
|
+
return {
|
|
305
|
+
kind: "schema",
|
|
306
|
+
type: "string",
|
|
307
|
+
reference: string,
|
|
308
|
+
expects: "string",
|
|
309
|
+
async: false,
|
|
310
|
+
message: message$1,
|
|
311
|
+
get "~standard"() {
|
|
312
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
313
|
+
},
|
|
314
|
+
"~run"(dataset, config$1) {
|
|
315
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
316
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
317
|
+
return dataset;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
// @__NO_SIDE_EFFECTS__
|
|
322
|
+
function unknown() {
|
|
323
|
+
return {
|
|
324
|
+
kind: "schema",
|
|
325
|
+
type: "unknown",
|
|
326
|
+
reference: unknown,
|
|
327
|
+
expects: "unknown",
|
|
328
|
+
async: false,
|
|
329
|
+
get "~standard"() {
|
|
330
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
331
|
+
},
|
|
332
|
+
"~run"(dataset) {
|
|
333
|
+
dataset.typed = true;
|
|
334
|
+
return dataset;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function parse(schema, input, config$1) {
|
|
339
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
340
|
+
if (dataset.issues) throw new ValiError(dataset.issues);
|
|
341
|
+
return dataset.value;
|
|
342
|
+
}
|
|
343
|
+
// @__NO_SIDE_EFFECTS__
|
|
344
|
+
function pipe(...pipe$1) {
|
|
345
|
+
return {
|
|
346
|
+
...pipe$1[0],
|
|
347
|
+
pipe: pipe$1,
|
|
348
|
+
get "~standard"() {
|
|
349
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
350
|
+
},
|
|
351
|
+
"~run"(dataset, config$1) {
|
|
352
|
+
for (const item of pipe$1) if (item.kind !== "metadata") {
|
|
353
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
354
|
+
dataset.typed = false;
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
|
|
358
|
+
}
|
|
359
|
+
return dataset;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
var ROOT_MESSAGE_PORT = "00000000-0000-0000-0000-000000000000";
|
|
364
|
+
var VOID = -1;
|
|
365
|
+
var PRIMITIVE = 0;
|
|
366
|
+
var ARRAY = 1;
|
|
367
|
+
var OBJECT = 2;
|
|
368
|
+
var DATE = 3;
|
|
369
|
+
var REGEXP = 4;
|
|
370
|
+
var MAP = 5;
|
|
371
|
+
var SET = 6;
|
|
372
|
+
var ERROR = 7;
|
|
373
|
+
var BIGINT = 8;
|
|
374
|
+
var env = typeof self === "object" ? self : globalThis;
|
|
375
|
+
var guard = (name, init) => {
|
|
376
|
+
switch (name) {
|
|
377
|
+
case "Function":
|
|
378
|
+
case "SharedWorker":
|
|
379
|
+
case "Worker":
|
|
380
|
+
case "eval":
|
|
381
|
+
case "setInterval":
|
|
382
|
+
case "setTimeout":
|
|
383
|
+
throw new TypeError("unable to deserialize " + name);
|
|
384
|
+
}
|
|
385
|
+
return new env[name](init);
|
|
386
|
+
};
|
|
387
|
+
var deserializer = ($, _) => {
|
|
388
|
+
const as = (out, index) => {
|
|
389
|
+
$.set(index, out);
|
|
390
|
+
return out;
|
|
391
|
+
};
|
|
392
|
+
const unpair = (index) => {
|
|
393
|
+
if ($.has(index))
|
|
394
|
+
return $.get(index);
|
|
395
|
+
const [type, value] = _[index];
|
|
396
|
+
switch (type) {
|
|
397
|
+
case PRIMITIVE:
|
|
398
|
+
case VOID:
|
|
399
|
+
return as(value, index);
|
|
400
|
+
case ARRAY: {
|
|
401
|
+
const arr = as([], index);
|
|
402
|
+
for (const index2 of value)
|
|
403
|
+
arr.push(unpair(index2));
|
|
404
|
+
return arr;
|
|
405
|
+
}
|
|
406
|
+
case OBJECT: {
|
|
407
|
+
const object2 = as({}, index);
|
|
408
|
+
for (const [key, index2] of value)
|
|
409
|
+
object2[unpair(key)] = unpair(index2);
|
|
410
|
+
return object2;
|
|
411
|
+
}
|
|
412
|
+
case DATE:
|
|
413
|
+
return as(new Date(value), index);
|
|
414
|
+
case REGEXP: {
|
|
415
|
+
const { source, flags } = value;
|
|
416
|
+
return as(new RegExp(source, flags), index);
|
|
417
|
+
}
|
|
418
|
+
case MAP: {
|
|
419
|
+
const map = as(/* @__PURE__ */ new Map(), index);
|
|
420
|
+
for (const [key, index2] of value)
|
|
421
|
+
map.set(unpair(key), unpair(index2));
|
|
422
|
+
return map;
|
|
423
|
+
}
|
|
424
|
+
case SET: {
|
|
425
|
+
const set = as(/* @__PURE__ */ new Set(), index);
|
|
426
|
+
for (const index2 of value)
|
|
427
|
+
set.add(unpair(index2));
|
|
428
|
+
return set;
|
|
429
|
+
}
|
|
430
|
+
case ERROR: {
|
|
431
|
+
const { name, message } = value;
|
|
432
|
+
return as(guard(name, message), index);
|
|
433
|
+
}
|
|
434
|
+
case BIGINT:
|
|
435
|
+
return as(BigInt(value), index);
|
|
436
|
+
case "BigInt":
|
|
437
|
+
return as(Object(BigInt(value)), index);
|
|
438
|
+
case "ArrayBuffer":
|
|
439
|
+
return as(new Uint8Array(value).buffer, value);
|
|
440
|
+
case "DataView": {
|
|
441
|
+
const { buffer } = new Uint8Array(value);
|
|
442
|
+
return as(new DataView(buffer), value);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return as(guard(type, value), index);
|
|
446
|
+
};
|
|
447
|
+
return unpair;
|
|
448
|
+
};
|
|
449
|
+
var deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0);
|
|
450
|
+
var EMPTY = "";
|
|
451
|
+
var { toString } = {};
|
|
452
|
+
var { keys } = Object;
|
|
453
|
+
var typeOf = (value) => {
|
|
454
|
+
const type = typeof value;
|
|
455
|
+
if (type !== "object" || !value)
|
|
456
|
+
return [PRIMITIVE, type];
|
|
457
|
+
const asString = toString.call(value).slice(8, -1);
|
|
458
|
+
switch (asString) {
|
|
459
|
+
case "Array":
|
|
460
|
+
return [ARRAY, EMPTY];
|
|
461
|
+
case "Object":
|
|
462
|
+
return [OBJECT, EMPTY];
|
|
463
|
+
case "Date":
|
|
464
|
+
return [DATE, EMPTY];
|
|
465
|
+
case "RegExp":
|
|
466
|
+
return [REGEXP, EMPTY];
|
|
467
|
+
case "Map":
|
|
468
|
+
return [MAP, EMPTY];
|
|
469
|
+
case "Set":
|
|
470
|
+
return [SET, EMPTY];
|
|
471
|
+
case "DataView":
|
|
472
|
+
return [ARRAY, asString];
|
|
473
|
+
}
|
|
474
|
+
if (asString.includes("Array"))
|
|
475
|
+
return [ARRAY, asString];
|
|
476
|
+
if (asString.includes("Error"))
|
|
477
|
+
return [ERROR, asString];
|
|
478
|
+
return [OBJECT, asString];
|
|
479
|
+
};
|
|
480
|
+
var shouldSkip = ([TYPE, type]) => TYPE === PRIMITIVE && (type === "function" || type === "symbol");
|
|
481
|
+
var serializer = (strict, json, $, _) => {
|
|
482
|
+
const as = (out, value) => {
|
|
483
|
+
const index = _.push(out) - 1;
|
|
484
|
+
$.set(value, index);
|
|
485
|
+
return index;
|
|
486
|
+
};
|
|
487
|
+
const pair = (value) => {
|
|
488
|
+
if ($.has(value))
|
|
489
|
+
return $.get(value);
|
|
490
|
+
let [TYPE, type] = typeOf(value);
|
|
491
|
+
switch (TYPE) {
|
|
492
|
+
case PRIMITIVE: {
|
|
493
|
+
let entry = value;
|
|
494
|
+
switch (type) {
|
|
495
|
+
case "bigint":
|
|
496
|
+
TYPE = BIGINT;
|
|
497
|
+
entry = value.toString();
|
|
498
|
+
break;
|
|
499
|
+
case "function":
|
|
500
|
+
case "symbol":
|
|
501
|
+
if (strict)
|
|
502
|
+
throw new TypeError("unable to serialize " + type);
|
|
503
|
+
entry = null;
|
|
504
|
+
break;
|
|
505
|
+
case "undefined":
|
|
506
|
+
return as([VOID], value);
|
|
507
|
+
}
|
|
508
|
+
return as([TYPE, entry], value);
|
|
509
|
+
}
|
|
510
|
+
case ARRAY: {
|
|
511
|
+
if (type) {
|
|
512
|
+
let spread = value;
|
|
513
|
+
if (type === "DataView") {
|
|
514
|
+
spread = new Uint8Array(value.buffer);
|
|
515
|
+
} else if (type === "ArrayBuffer") {
|
|
516
|
+
spread = new Uint8Array(value);
|
|
517
|
+
}
|
|
518
|
+
return as([type, [...spread]], value);
|
|
519
|
+
}
|
|
520
|
+
const arr = [];
|
|
521
|
+
const index = as([TYPE, arr], value);
|
|
522
|
+
for (const entry of value)
|
|
523
|
+
arr.push(pair(entry));
|
|
524
|
+
return index;
|
|
525
|
+
}
|
|
526
|
+
case OBJECT: {
|
|
527
|
+
if (type) {
|
|
528
|
+
switch (type) {
|
|
529
|
+
case "BigInt":
|
|
530
|
+
return as([type, value.toString()], value);
|
|
531
|
+
case "Boolean":
|
|
532
|
+
case "Number":
|
|
533
|
+
case "String":
|
|
534
|
+
return as([type, value.valueOf()], value);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (json && "toJSON" in value)
|
|
538
|
+
return pair(value.toJSON());
|
|
539
|
+
const entries = [];
|
|
540
|
+
const index = as([TYPE, entries], value);
|
|
541
|
+
for (const key of keys(value)) {
|
|
542
|
+
if (strict || !shouldSkip(typeOf(value[key])))
|
|
543
|
+
entries.push([pair(key), pair(value[key])]);
|
|
544
|
+
}
|
|
545
|
+
return index;
|
|
546
|
+
}
|
|
547
|
+
case DATE:
|
|
548
|
+
return as([TYPE, value.toISOString()], value);
|
|
549
|
+
case REGEXP: {
|
|
550
|
+
const { source, flags } = value;
|
|
551
|
+
return as([TYPE, { source, flags }], value);
|
|
552
|
+
}
|
|
553
|
+
case MAP: {
|
|
554
|
+
const entries = [];
|
|
555
|
+
const index = as([TYPE, entries], value);
|
|
556
|
+
for (const [key, entry] of value) {
|
|
557
|
+
if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
|
|
558
|
+
entries.push([pair(key), pair(entry)]);
|
|
559
|
+
}
|
|
560
|
+
return index;
|
|
561
|
+
}
|
|
562
|
+
case SET: {
|
|
563
|
+
const entries = [];
|
|
564
|
+
const index = as([TYPE, entries], value);
|
|
565
|
+
for (const entry of value) {
|
|
566
|
+
if (strict || !shouldSkip(typeOf(entry)))
|
|
567
|
+
entries.push(pair(entry));
|
|
568
|
+
}
|
|
569
|
+
return index;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const { message } = value;
|
|
573
|
+
return as([TYPE, { name: type, message }], value);
|
|
574
|
+
};
|
|
575
|
+
return pair;
|
|
576
|
+
};
|
|
577
|
+
var serialize = (value, { json, lossy } = {}) => {
|
|
578
|
+
const _ = [];
|
|
579
|
+
return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _;
|
|
580
|
+
};
|
|
581
|
+
function workthru_(target, transformer, walked) {
|
|
582
|
+
if (Array.isArray(target)) {
|
|
583
|
+
if (walked.has(target)) {
|
|
584
|
+
return walked.get(target);
|
|
585
|
+
}
|
|
586
|
+
let nextArray = transformer(target);
|
|
587
|
+
if (nextArray !== target) {
|
|
588
|
+
walked.set(target, nextArray);
|
|
589
|
+
return nextArray;
|
|
590
|
+
}
|
|
591
|
+
walked.set(target, target);
|
|
592
|
+
for (const index in target) {
|
|
593
|
+
const value = target[index];
|
|
594
|
+
const nextValue = workthru_(value, transformer, walked);
|
|
595
|
+
if (nextValue !== value) {
|
|
596
|
+
if (nextArray === target) {
|
|
597
|
+
nextArray = [...target];
|
|
598
|
+
}
|
|
599
|
+
nextArray[index] = nextValue;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
walked.set(target, nextArray);
|
|
603
|
+
return nextArray;
|
|
604
|
+
}
|
|
605
|
+
if (typeof target === "object" && target !== null) {
|
|
606
|
+
if (walked.has(target)) {
|
|
607
|
+
return walked.get(target);
|
|
608
|
+
}
|
|
609
|
+
const prototype = Object.getPrototypeOf(target);
|
|
610
|
+
if (prototype === null || prototype === Object.prototype) {
|
|
611
|
+
const nextTarget = transformer(target);
|
|
612
|
+
if (nextTarget !== target) {
|
|
613
|
+
walked.set(target, nextTarget);
|
|
614
|
+
return nextTarget;
|
|
615
|
+
}
|
|
616
|
+
walked.set(target, target);
|
|
617
|
+
const entries = Object.entries(target);
|
|
618
|
+
let nextMap = void 0;
|
|
619
|
+
for (const [key, value] of entries) {
|
|
620
|
+
const nextValue = workthru_(value, transformer, walked);
|
|
621
|
+
if (nextValue !== value) {
|
|
622
|
+
if (!nextMap) {
|
|
623
|
+
nextMap = new Map(entries);
|
|
624
|
+
}
|
|
625
|
+
nextMap.set(key, nextValue);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
const nextObject = nextMap ? Object.fromEntries(nextMap.entries()) : target;
|
|
629
|
+
walked.set(target, nextObject);
|
|
630
|
+
return nextObject;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return transformer(target);
|
|
634
|
+
}
|
|
635
|
+
function workthru(target, transformer) {
|
|
636
|
+
return workthru_(target, transformer, /* @__PURE__ */ new Map());
|
|
637
|
+
}
|
|
638
|
+
var workthru_default = workthru;
|
|
639
|
+
var MESSAGE_PORT = "@@__SELENIUM_WEBDRIVER_MESSAGE_PORT__@@";
|
|
640
|
+
function marshal(target, transferable) {
|
|
641
|
+
return serialize(
|
|
642
|
+
workthru_default(target, (value) => {
|
|
643
|
+
if (value instanceof MessagePort) {
|
|
644
|
+
const index = transferable.indexOf(value);
|
|
645
|
+
if (index === -1) {
|
|
646
|
+
throw new Error("Cannot marshal MessagePort: it must be included in the transfer list");
|
|
647
|
+
}
|
|
648
|
+
return [MESSAGE_PORT, index];
|
|
649
|
+
}
|
|
650
|
+
return value;
|
|
651
|
+
})
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
function unmarshal(target, transferable) {
|
|
655
|
+
return workthru_default(deserialize(target), (value) => {
|
|
656
|
+
if (Array.isArray(value) && value[0] === MESSAGE_PORT) {
|
|
657
|
+
const index = value[1];
|
|
658
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index >= transferable.length) {
|
|
659
|
+
throw new Error(`Cannot unmarshal MessagePort: invalid transfer index ${String(index)}`);
|
|
660
|
+
}
|
|
661
|
+
return transferable[index];
|
|
662
|
+
}
|
|
663
|
+
return value;
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
var serializedMessageSchema = /* @__PURE__ */ object({
|
|
667
|
+
data: /* @__PURE__ */ unknown(),
|
|
668
|
+
portId: /* @__PURE__ */ string(),
|
|
669
|
+
transferPortIds: /* @__PURE__ */ pipe(/* @__PURE__ */ array(/* @__PURE__ */ string()), /* @__PURE__ */ readonly())
|
|
670
|
+
});
|
|
671
|
+
var portMap = /* @__PURE__ */ new Map();
|
|
672
|
+
var queue = [];
|
|
673
|
+
function flushAll() {
|
|
674
|
+
return Object.freeze(queue.splice(0));
|
|
675
|
+
}
|
|
676
|
+
function tryFlushToPipe() {
|
|
677
|
+
const pipingMessageHandler = globalThis.__seleniumWebDriverMessagePortBiDiPipeDestination;
|
|
678
|
+
if (pipingMessageHandler) {
|
|
679
|
+
let message;
|
|
680
|
+
while (typeof (message = queue.shift()) === "string") {
|
|
681
|
+
pipingMessageHandler(message);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function createMessagePort(portId) {
|
|
686
|
+
if (portMap.has(portId)) {
|
|
687
|
+
throw new Error(`MessagePort with id "${portId}" is already registered, cannot register again`);
|
|
688
|
+
}
|
|
689
|
+
const { port1, port2 } = new MessageChannel();
|
|
690
|
+
registerMessagePort(port1, portId);
|
|
691
|
+
return port2;
|
|
692
|
+
}
|
|
693
|
+
function registerMessagePort(port, portId) {
|
|
694
|
+
if (portMap.has(portId)) {
|
|
695
|
+
throw new Error(`MessagePort with id "${portId}" is already registered, cannot register again`);
|
|
696
|
+
}
|
|
697
|
+
portMap.set(portId, port);
|
|
698
|
+
port.addEventListener("message", ({ data, ports }) => {
|
|
699
|
+
const transferPortIds = ports.map((port2) => {
|
|
700
|
+
const id = v7_default();
|
|
701
|
+
registerMessagePort(port2, id);
|
|
702
|
+
return id;
|
|
703
|
+
});
|
|
704
|
+
queue.push(
|
|
705
|
+
JSON.stringify(
|
|
706
|
+
parse(serializedMessageSchema, {
|
|
707
|
+
data: marshal(data, ports),
|
|
708
|
+
portId,
|
|
709
|
+
transferPortIds
|
|
710
|
+
})
|
|
711
|
+
)
|
|
712
|
+
);
|
|
713
|
+
tryFlushToPipe();
|
|
714
|
+
});
|
|
715
|
+
port.start();
|
|
716
|
+
}
|
|
717
|
+
function sendToBrowser(data) {
|
|
718
|
+
const { data: payload, portId, transferPortIds } = parse(serializedMessageSchema, JSON.parse(data));
|
|
719
|
+
const port = portMap.get(portId);
|
|
720
|
+
if (!port) {
|
|
721
|
+
console.warn(`Host should not send to unbound port "${portId}"`);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
const transfer = transferPortIds.map((transferPortId) => createMessagePort(transferPortId));
|
|
725
|
+
port.postMessage(unmarshal(payload, transfer), transfer);
|
|
726
|
+
}
|
|
727
|
+
globalThis.__seleniumWebDriverMessagePortFacility = Object.freeze({
|
|
728
|
+
flushAll,
|
|
729
|
+
sendToBrowser
|
|
730
|
+
});
|
|
731
|
+
var pipeDestination = globalThis.__seleniumWebDriverMessagePortBiDiPipeDestination;
|
|
732
|
+
Object.defineProperty(globalThis, "__seleniumWebDriverMessagePortBiDiPipeDestination", {
|
|
733
|
+
configurable: false,
|
|
734
|
+
enumerable: true,
|
|
735
|
+
get() {
|
|
736
|
+
return pipeDestination;
|
|
737
|
+
},
|
|
738
|
+
set(value) {
|
|
739
|
+
pipeDestination = value;
|
|
740
|
+
tryFlushToPipe();
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
tryFlushToPipe();
|
|
744
|
+
var messagePort = createMessagePort(ROOT_MESSAGE_PORT);
|
|
745
|
+
|
|
746
|
+
// src/browser/getStub.ts
|
|
747
|
+
import defaultStubDeclaration from "@onting/stub";
|
|
748
|
+
function getStub(stubDeclaration) {
|
|
749
|
+
return createClientStub(stubDeclaration ?? defaultStubDeclaration, messagePort);
|
|
750
|
+
}
|
|
751
|
+
var getStub_default = getStub;
|
|
752
|
+
export {
|
|
753
|
+
getStub_default as getStub
|
|
754
|
+
};
|
|
5
755
|
//# sourceMappingURL=browser.js.map
|