omowright 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -23
- package/TOOLS.md +140 -19
- package/dist/agent-tabs.d.ts +56 -0
- package/dist/aria-hidden.d.ts +1 -0
- package/dist/aside/cli-binary.d.ts +7 -0
- package/dist/aside/cli-contract.d.ts +9 -0
- package/dist/aside/errors.d.ts +8 -0
- package/dist/aside/line-transport.d.ts +11 -0
- package/dist/aside/mcp-transport.d.ts +11 -0
- package/dist/aside/onboard.d.ts +76 -0
- package/dist/aside/session-types.d.ts +68 -0
- package/dist/aside/session.d.ts +20 -0
- package/{bin/omowright-cloak.mjs → dist/bin/omowright-cloak.js} +28 -31
- package/dist/bridge-schemas.d.ts +326 -0
- package/dist/bridge-transport.d.ts +144 -0
- package/dist/browser-context.d.ts +4024 -0
- package/dist/browser-process.d.ts +10 -0
- package/dist/bsk/browser-signals.d.ts +23 -0
- package/dist/bsk/browsers.d.ts +46 -0
- package/dist/bsk/connect.d.ts +23 -0
- package/dist/bsk/daemon-info.d.ts +16 -0
- package/dist/bsk/external-extension.d.ts +74 -0
- package/dist/bsk/identify-browser.d.ts +48 -0
- package/dist/bsk/install-cli.d.ts +37 -0
- package/dist/bsk/ipc-client.d.ts +45 -0
- package/dist/bsk/onboard.d.ts +96 -0
- package/dist/bsk/reply-fields.d.ts +3 -0
- package/dist/bsk/screenshot.d.ts +24 -0
- package/dist/bsk/session.d.ts +142 -0
- package/dist/bsk/snapshot.d.ts +16 -0
- package/dist/bsk/targets.d.ts +20 -0
- package/dist/captcha-wait.d.ts +17 -0
- package/dist/captcha.d.ts +46 -0
- package/dist/cdp-errors.d.ts +38 -0
- package/dist/cdp-methods.d.ts +10 -0
- package/dist/cdp-protocol.d.ts +459 -0
- package/dist/chrome-profile.d.ts +77 -0
- package/dist/chrome.d.ts +130 -0
- package/dist/cloak-profile.d.ts +43 -0
- package/dist/connection.d.ts +4024 -0
- package/dist/console-events.d.ts +22 -0
- package/dist/cookies.d.ts +42 -0
- package/dist/core.d.ts +10810 -0
- package/dist/cua.d.ts +56 -0
- package/dist/dialog-policy.d.ts +43 -0
- package/dist/ego/bindings.d.ts +68 -0
- package/dist/ego/cdp-client.d.ts +28 -0
- package/dist/ego/client.d.ts +8 -0
- package/dist/ego/errors.d.ts +7 -0
- package/dist/emulate.d.ts +62 -0
- package/dist/engines.d.ts +59 -0
- package/dist/events.d.ts +93 -0
- package/dist/frames-snapshot.d.ts +58 -0
- package/dist/har.d.ts +88 -0
- package/dist/human-handoff.d.ts +30 -0
- package/{src/index.js → dist/index.d.ts} +12 -53
- package/dist/index.js +39262 -0
- package/dist/injected.d.ts +1 -0
- package/dist/instance-lock.d.ts +5 -0
- package/dist/instances.d.ts +45 -0
- package/dist/internal-capability.d.ts +1 -0
- package/dist/launch-endpoint.d.ts +34 -0
- package/dist/layers.d.ts +31 -0
- package/dist/llm.d.ts +1349 -0
- package/dist/lock-backend-win32-xbcm60vz.js +57 -0
- package/dist/lock-backend-win32.d.ts +3 -0
- package/dist/lock-backend.d.ts +6 -0
- package/dist/native-host-win32.d.ts +38 -0
- package/dist/network-events.d.ts +66 -0
- package/dist/network-snoop.d.ts +56 -0
- package/dist/nul-frames.d.ts +4 -0
- package/dist/open-shadow-query.d.ts +1 -0
- package/dist/owner-only.d.ts +15 -0
- package/dist/page-bundle.js +1587 -0
- package/dist/page-events.d.ts +25 -0
- package/dist/page-routes.d.ts +30 -0
- package/dist/page-setup.d.ts +55 -0
- package/dist/pipe.d.ts +71 -0
- package/dist/process-start-time.d.ts +2 -0
- package/dist/read-property.d.ts +2 -0
- package/dist/routes.d.ts +60 -0
- package/dist/running-browser.d.ts +39 -0
- package/dist/scroll-collect.d.ts +36 -0
- package/dist/serial-emitter.d.ts +5 -0
- package/dist/shared-connections.d.ts +11 -0
- package/dist/snapshot-diff.d.ts +57 -0
- package/dist/text-matching.d.ts +21 -0
- package/dist/trace.d.ts +59 -0
- package/dist/url-match.d.ts +7 -0
- package/dist/viewport.d.ts +26 -0
- package/dist/ws.d.ts +62 -0
- package/package.json +47 -26
- package/presets/agent-events/SKILL.md +1 -1
- package/presets/captcha/SKILL.md +1 -3
- package/presets/chrome/SKILL.md +11 -7
- package/presets/cloak-bridge/SKILL.md +11 -11
- package/presets/network/SKILL.md +15 -13
- package/presets/visual-browse/SKILL.md +14 -10
- package/skills/omowright/SKILL.md +77 -47
- package/skills/omowright/references/aside.md +50 -0
- package/skills/omowright/references/browserskill.md +39 -33
- package/skills/omowright/references/ego.md +24 -0
- package/skills/omowright/references/eval-kernel.md +44 -23
- package/skills/omowright/references/frames-layers-human.md +16 -7
- package/skills/omowright/references/quickstart.md +17 -4
- package/skills/omowright/references/stealth.md +7 -7
- package/src/agent-tabs.js +0 -160
- package/src/bridge-schemas.js +0 -44
- package/src/bridge-transport.js +0 -57
- package/src/browser-process.js +0 -122
- package/src/bsk/browser-signals.js +0 -90
- package/src/bsk/browsers.js +0 -114
- package/src/bsk/connect.js +0 -45
- package/src/bsk/daemon-info.js +0 -100
- package/src/bsk/external-extension.js +0 -110
- package/src/bsk/identify-browser.js +0 -88
- package/src/bsk/install-cli.js +0 -81
- package/src/bsk/ipc-client.js +0 -236
- package/src/bsk/onboard.js +0 -133
- package/src/bsk/screenshot.js +0 -49
- package/src/bsk/session.js +0 -131
- package/src/bsk/snapshot.js +0 -56
- package/src/bsk/targets.js +0 -25
- package/src/captcha-wait.js +0 -74
- package/src/captcha.js +0 -142
- package/src/cdp-errors.js +0 -23
- package/src/cdp-methods.js +0 -61
- package/src/chrome-profile.js +0 -176
- package/src/chrome.js +0 -192
- package/src/cloak-profile.js +0 -266
- package/src/connection.js +0 -135
- package/src/cookies.js +0 -29
- package/src/core.js +0 -1710
- package/src/cua.js +0 -74
- package/src/dialog-policy.js +0 -80
- package/src/emulate.js +0 -127
- package/src/events.js +0 -111
- package/src/frames-snapshot.js +0 -138
- package/src/har.js +0 -103
- package/src/human-handoff.js +0 -122
- package/src/injected.js +0 -3
- package/src/instance-lock.js +0 -230
- package/src/instances.js +0 -493
- package/src/internal-capability.js +0 -1
- package/src/launch-endpoint.js +0 -185
- package/src/layers.js +0 -138
- package/src/llm.js +0 -201
- package/src/lock-file.js +0 -130
- package/src/native-host-win32.js +0 -201
- package/src/network-events.js +0 -201
- package/src/network-snoop.js +0 -229
- package/src/open-shadow-query.js +0 -22
- package/src/owner-only.js +0 -109
- package/src/page-bundle.js +0 -1397
- package/src/page-routes.js +0 -94
- package/src/pipe.js +0 -391
- package/src/routes.js +0 -256
- package/src/running-browser.js +0 -85
- package/src/scroll-collect.js +0 -73
- package/src/serial-emitter.js +0 -17
- package/src/shared-connections.js +0 -278
- package/src/snapshot-diff.js +0 -75
- package/src/trace.js +0 -183
- package/src/url-match.js +0 -148
- package/src/viewport.js +0 -12
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { isDeepStrictEqual } from "node:util";
|
|
2
|
-
|
|
3
|
-
// One CDP connection per browser per process (#68). Chrome asks the user to
|
|
4
|
-
// allow remote debugging once per WebSocket connection to their own profile,
|
|
5
|
-
// so an attach that opens a fresh socket on every call prompts on every call.
|
|
6
|
-
// Entries are keyed by the browser's webSocketDebuggerUrl: it carries the
|
|
7
|
-
// browser GUID, so a restarted or different browser never gets a cached
|
|
8
|
-
// connection. Each caller gets a lease whose close() is a release; the last
|
|
9
|
-
// release disconnects, because an open socket keeps the process alive.
|
|
10
|
-
const shared = new Map();
|
|
11
|
-
|
|
12
|
-
function withinTimeout(pending, timeoutMs, message) {
|
|
13
|
-
let timer;
|
|
14
|
-
return Promise.race([
|
|
15
|
-
pending,
|
|
16
|
-
new Promise((_, reject) => {
|
|
17
|
-
timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
18
|
-
}),
|
|
19
|
-
]).finally(() => clearTimeout(timer));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function release(key, entry) {
|
|
23
|
-
entry.refs -= 1;
|
|
24
|
-
if (entry.refs > 0) return Promise.resolve();
|
|
25
|
-
if (shared.get(key) === entry) shared.delete(key);
|
|
26
|
-
return entry.ready.then(
|
|
27
|
-
(connection) => connection.close(),
|
|
28
|
-
() => {},
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function bindTo(target, value) {
|
|
33
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Thrown when a holder tries to change a setting every other holder of the
|
|
37
|
-
// connection shares. Opening with that setting gives the holder its own.
|
|
38
|
-
export class SharedConnectionError extends Error {
|
|
39
|
-
constructor() {
|
|
40
|
-
super("this browser connection is shared; pass dialogPolicy to connect()/connectNamed() so this holder gets its own connection");
|
|
41
|
-
this.name = "SharedConnectionError";
|
|
42
|
-
this.code = "shared_connection";
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Members the lease itself provides; a handle can't replace them.
|
|
47
|
-
const RESERVED = new Set(["cdp", "close", "setDialogPolicy"]);
|
|
48
|
-
|
|
49
|
-
function refuse(what) {
|
|
50
|
-
return (_target, property) => {
|
|
51
|
-
throw new TypeError(`cannot change ${String(property)} on ${what} through a handle: every holder of this connection uses it`);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// A lease is one holder's view of the shared connection, and a holder never
|
|
56
|
-
// changes what another holder gets (#72 review):
|
|
57
|
-
// - setDialogPolicy works for a sole holder and makes the connection
|
|
58
|
-
// unshareable from then on; while others hold it, it throws
|
|
59
|
-
// SharedConnectionError instead (pages are shared, so a policy can't be
|
|
60
|
-
// scoped to one holder, and moving the holder would orphan its pages).
|
|
61
|
-
// - Properties set or defined on the lease stay on the lease; shared ones can't
|
|
62
|
-
// be deleted through it, and the shared client can't be written through it.
|
|
63
|
-
// - Listeners added through lease.cdp are removed when the lease closes, and
|
|
64
|
-
// lease.cdp.close() releases only this lease.
|
|
65
|
-
// - After close() the lease refuses every use, so a stale handle can never
|
|
66
|
-
// reopen a connection nobody owns.
|
|
67
|
-
function lease(key, entry, connection) {
|
|
68
|
-
let closed;
|
|
69
|
-
const overlay = Object.create(null);
|
|
70
|
-
const subscriptions = new Set();
|
|
71
|
-
const transportSubscriptions = new Set();
|
|
72
|
-
const unsubscribeAll = (set) => {
|
|
73
|
-
for (const unsubscribe of [...set]) unsubscribe();
|
|
74
|
-
};
|
|
75
|
-
// Symbols and `then` stay readable, so inspecting or resolving a closed
|
|
76
|
-
// handle doesn't throw; every named member does.
|
|
77
|
-
const ensureOpen = (property) => {
|
|
78
|
-
if (closed && typeof property === "string" && property !== "then") {
|
|
79
|
-
throw new Error("this browser connection handle was closed");
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const close = () => {
|
|
83
|
-
if (!closed) {
|
|
84
|
-
unsubscribeAll(subscriptions);
|
|
85
|
-
closed = release(key, entry);
|
|
86
|
-
}
|
|
87
|
-
return closed;
|
|
88
|
-
};
|
|
89
|
-
const setDialogPolicy = (policy) => {
|
|
90
|
-
ensureOpen("setDialogPolicy");
|
|
91
|
-
if (entry.refs > 1) throw new SharedConnectionError();
|
|
92
|
-
if (shared.get(key) === entry) shared.delete(key);
|
|
93
|
-
return connection.setDialogPolicy(policy);
|
|
94
|
-
};
|
|
95
|
-
// An unsubscribe forgets itself, so a handle that subscribes and
|
|
96
|
-
// unsubscribes keeps nothing, and close() or clearListeners() never runs a
|
|
97
|
-
// spent unsubscribe that would remove the same function registered since by
|
|
98
|
-
// another holder (#82).
|
|
99
|
-
const tracked = (subscribe, ...sets) => (...args) => {
|
|
100
|
-
const remove = subscribe(...args);
|
|
101
|
-
let removed = false;
|
|
102
|
-
const unsubscribe = () => {
|
|
103
|
-
if (removed) return;
|
|
104
|
-
removed = true;
|
|
105
|
-
for (const set of sets) set.delete(unsubscribe);
|
|
106
|
-
remove();
|
|
107
|
-
};
|
|
108
|
-
for (const set of sets) set.add(unsubscribe);
|
|
109
|
-
return unsubscribe;
|
|
110
|
-
};
|
|
111
|
-
const readOnly = (what, get) => ({
|
|
112
|
-
get,
|
|
113
|
-
set: refuse(what),
|
|
114
|
-
defineProperty: refuse(what),
|
|
115
|
-
deleteProperty: refuse(what),
|
|
116
|
-
});
|
|
117
|
-
const client = connection.cdp;
|
|
118
|
-
// Transport events reach every holder: through a handle, clearListeners
|
|
119
|
-
// removes only that handle's listeners and emit is refused.
|
|
120
|
-
const transportEvents = new Proxy(client.transportEvents, readOnly("the shared transport events", (target, property) => {
|
|
121
|
-
ensureOpen(property);
|
|
122
|
-
if (property === "on") return tracked(target.on.bind(target), subscriptions, transportSubscriptions);
|
|
123
|
-
if (property === "clearListeners") return () => unsubscribeAll(transportSubscriptions);
|
|
124
|
-
if (property === "emit") {
|
|
125
|
-
return () => {
|
|
126
|
-
throw new TypeError("cannot emit transport events through a handle: every holder of this connection hears them");
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
return bindTo(target, Reflect.get(target, property, target));
|
|
130
|
-
}));
|
|
131
|
-
const clientView = new Proxy(client, readOnly("the shared CDP client", (target, property) => {
|
|
132
|
-
ensureOpen(property);
|
|
133
|
-
if (property === "setDialogPolicy") return setDialogPolicy;
|
|
134
|
-
if (property === "close") return close;
|
|
135
|
-
if (property === "on") return tracked(target.on.bind(target), subscriptions);
|
|
136
|
-
if (property === "transportEvents") return transportEvents;
|
|
137
|
-
return bindTo(target, Reflect.get(target, property, target));
|
|
138
|
-
}));
|
|
139
|
-
return new Proxy(connection, {
|
|
140
|
-
get(target, property) {
|
|
141
|
-
if (property === "close") return close;
|
|
142
|
-
ensureOpen(property);
|
|
143
|
-
if (property === "setDialogPolicy") return setDialogPolicy;
|
|
144
|
-
if (property === "cdp") return clientView;
|
|
145
|
-
if (Object.hasOwn(overlay, property)) return overlay[property];
|
|
146
|
-
return bindTo(target, Reflect.get(target, property, target));
|
|
147
|
-
},
|
|
148
|
-
set(target, property, value) {
|
|
149
|
-
ensureOpen(property);
|
|
150
|
-
if (RESERVED.has(property)) return refuse("a handle")(target, property);
|
|
151
|
-
return Reflect.set(overlay, property, value);
|
|
152
|
-
},
|
|
153
|
-
defineProperty(target, property, descriptor) {
|
|
154
|
-
ensureOpen(property);
|
|
155
|
-
if (RESERVED.has(property)) return refuse("a handle")(target, property);
|
|
156
|
-
// A non-configurable property can't live on the lease alone.
|
|
157
|
-
if (descriptor.configurable !== true) return false;
|
|
158
|
-
return Reflect.defineProperty(overlay, property, descriptor);
|
|
159
|
-
},
|
|
160
|
-
deleteProperty(target, property) {
|
|
161
|
-
ensureOpen(property);
|
|
162
|
-
if (Object.hasOwn(overlay, property)) return Reflect.deleteProperty(overlay, property);
|
|
163
|
-
return refuse("the shared connection")(target, property);
|
|
164
|
-
},
|
|
165
|
-
has(target, property) {
|
|
166
|
-
return Object.hasOwn(overlay, property) || Reflect.has(target, property);
|
|
167
|
-
},
|
|
168
|
-
ownKeys(target) {
|
|
169
|
-
return [...new Set([...Reflect.ownKeys(target), ...Reflect.ownKeys(overlay)])];
|
|
170
|
-
},
|
|
171
|
-
getOwnPropertyDescriptor(target, property) {
|
|
172
|
-
return Object.hasOwn(overlay, property)
|
|
173
|
-
? Reflect.getOwnPropertyDescriptor(overlay, property)
|
|
174
|
-
: Reflect.getOwnPropertyDescriptor(target, property);
|
|
175
|
-
},
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Only plain data is compared structurally, and isDeepStrictEqual sees only
|
|
180
|
-
// enumerable values. So options are shared only when every own key is an
|
|
181
|
-
// enumerable, string-keyed data property and nothing refers back to itself;
|
|
182
|
-
// a class instance (an authorizer keeping its token in a private field), a
|
|
183
|
-
// symbol or non-enumerable key, an accessor or a cycle makes them unshareable.
|
|
184
|
-
// Functions compare by identity, which is exact.
|
|
185
|
-
function isPlainData(value, path = new Set()) {
|
|
186
|
-
if (typeof value === "function" || value === null || typeof value !== "object") return true;
|
|
187
|
-
if (path.has(value)) return false;
|
|
188
|
-
const prototype = Object.getPrototypeOf(value);
|
|
189
|
-
const isArray = Array.isArray(value);
|
|
190
|
-
if (isArray ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
path.add(value);
|
|
194
|
-
try {
|
|
195
|
-
for (const key of Reflect.ownKeys(value)) {
|
|
196
|
-
if (isArray && key === "length") continue;
|
|
197
|
-
if (typeof key === "symbol") return false;
|
|
198
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
199
|
-
if (!descriptor.enumerable || !("value" in descriptor)) return false;
|
|
200
|
-
if (!isPlainData(descriptor.value, path)) return false;
|
|
201
|
-
}
|
|
202
|
-
return true;
|
|
203
|
-
} finally {
|
|
204
|
-
path.delete(value);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// A frozen deep copy of shareable options (plain data, so only arrays and
|
|
209
|
-
// objects need copying; functions keep their identity). The shared connection
|
|
210
|
-
// is opened with and compared against this copy, so a caller mutating its
|
|
211
|
-
// options object after attaching changes neither the live connection nor which
|
|
212
|
-
// later attaches share it, and a handle can't change the policy in place (#81).
|
|
213
|
-
function frozenCopy(value) {
|
|
214
|
-
if (value === null || typeof value !== "object") return value;
|
|
215
|
-
const copy = Array.isArray(value)
|
|
216
|
-
? new Array(value.length)
|
|
217
|
-
: Object.create(Object.getPrototypeOf(value));
|
|
218
|
-
for (const key of Object.keys(value)) {
|
|
219
|
-
Object.defineProperty(copy, key, { value: frozenCopy(value[key]), enumerable: true });
|
|
220
|
-
}
|
|
221
|
-
return Object.freeze(copy);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// The options a shared connection is opened with: the snapshot, plus a frozen
|
|
225
|
-
// default dialog policy of its own when the caller passed none, so no holder
|
|
226
|
-
// can change the live policy in place through handle.cdp.dialogPolicy (#81).
|
|
227
|
-
// The snapshot itself stays the sharing key, so an attach that names no policy
|
|
228
|
-
// still differs from one that asks for { accept: true }.
|
|
229
|
-
function openingOptions(snapshot) {
|
|
230
|
-
if (snapshot?.dialogPolicy != null || snapshot?.client?.dialogPolicy != null) return snapshot;
|
|
231
|
-
return Object.freeze({ ...snapshot, dialogPolicy: Object.freeze({ accept: true }) });
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// An authorizer is a credential: two callers never share one connection
|
|
235
|
-
// through it, even with the same authorizer object (#79 review).
|
|
236
|
-
export function canShareConnection(options) {
|
|
237
|
-
return options?.client?.authorizer === undefined && isPlainData(options);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// `open(options)` makes the real connection; it runs once per browser while a
|
|
241
|
-
// lease is held. A caller whose connection options differ from the shared
|
|
242
|
-
// connection's (dialogPolicy included) gets a connection of its own rather
|
|
243
|
-
// than someone else's storage root or dialog policy.
|
|
244
|
-
export async function acquireSharedConnection(
|
|
245
|
-
webSocketDebuggerUrl,
|
|
246
|
-
options,
|
|
247
|
-
{ open, timeoutMs },
|
|
248
|
-
) {
|
|
249
|
-
if (!canShareConnection(options)) return open(options);
|
|
250
|
-
const snapshot = frozenCopy(options);
|
|
251
|
-
let entry = shared.get(webSocketDebuggerUrl);
|
|
252
|
-
if (entry && !isDeepStrictEqual(entry.options, snapshot)) return open(openingOptions(snapshot));
|
|
253
|
-
if (!entry) {
|
|
254
|
-
entry = { options: snapshot, refs: 0, ready: open(openingOptions(snapshot)) };
|
|
255
|
-
shared.set(webSocketDebuggerUrl, entry);
|
|
256
|
-
}
|
|
257
|
-
entry.refs += 1;
|
|
258
|
-
try {
|
|
259
|
-
const connection = await entry.ready;
|
|
260
|
-
// A dropped socket is already being reconnected by the client; join that
|
|
261
|
-
// attempt (or start one) instead of opening a second connection.
|
|
262
|
-
const reconnected = connection.cdp.ensureConnected();
|
|
263
|
-
await (timeoutMs === undefined
|
|
264
|
-
? reconnected
|
|
265
|
-
: withinTimeout(
|
|
266
|
-
reconnected,
|
|
267
|
-
timeoutMs,
|
|
268
|
-
`timed out after ${timeoutMs}ms reconnecting the CDP session on ${webSocketDebuggerUrl}`,
|
|
269
|
-
));
|
|
270
|
-
return lease(webSocketDebuggerUrl, entry, connection);
|
|
271
|
-
} catch (error) {
|
|
272
|
-
// The browser behind this key is gone or unreachable: evict the entry so
|
|
273
|
-
// the next attach resolves and opens anew instead of joining a dead one.
|
|
274
|
-
if (shared.get(webSocketDebuggerUrl) === entry) shared.delete(webSocketDebuggerUrl);
|
|
275
|
-
await release(webSocketDebuggerUrl, entry);
|
|
276
|
-
throw error;
|
|
277
|
-
}
|
|
278
|
-
}
|
package/src/snapshot-diff.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const baselines = new WeakMap();
|
|
2
|
-
const REF_LINE = /^(\s*)- [^\s"]+(?: "(?:\\.|[^"\\])*")? \[ref=((?:f\d+)?e\d+)\]/;
|
|
3
|
-
|
|
4
|
-
// Compare the final, frame-inlined tree so values, selected options and text children use
|
|
5
|
-
// exactly the same escaping and password redaction as a full snapshot.
|
|
6
|
-
function indexTree(tree) {
|
|
7
|
-
const nodes = new Map();
|
|
8
|
-
const unreferenced = [];
|
|
9
|
-
const parents = [];
|
|
10
|
-
let focused = null;
|
|
11
|
-
for (const line of tree.split("\n")) {
|
|
12
|
-
if (!line) continue;
|
|
13
|
-
const depth = line.search(/\S/);
|
|
14
|
-
while (parents.length && parents.at(-1).depth >= depth) parents.pop();
|
|
15
|
-
const match = REF_LINE.exec(line);
|
|
16
|
-
if (match) {
|
|
17
|
-
const ref = match[2];
|
|
18
|
-
const node = { ref, tree: line.trim().slice(2) };
|
|
19
|
-
nodes.set(ref, node);
|
|
20
|
-
parents.push({ depth, node });
|
|
21
|
-
// Strip the quoted name before looking at state, not user-supplied name text.
|
|
22
|
-
const state = line.slice(match[0].length).match(/"(?:\\.|[^"\\])*"|\[focused\]/g) ?? [];
|
|
23
|
-
if (state.includes("[focused]")) focused = ref;
|
|
24
|
-
} else if (parents.length) {
|
|
25
|
-
parents.at(-1).node.tree += ` | ${line.trim().slice(2)}`;
|
|
26
|
-
} else if (!/^\s*- [\w-]+:?$/.test(line)) {
|
|
27
|
-
unreferenced.push(line);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return { nodes, focused, unreferenced: unreferenced.join("\n") };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function snapshotResult(frameManager, options, snapshot) {
|
|
34
|
-
const { diff, ...scope } = options;
|
|
35
|
-
const document = frameManager.getFrame(frameManager.mainFrameId);
|
|
36
|
-
const contexts = JSON.stringify(frameManager.collectDescendantFrames(frameManager.mainFrameId)
|
|
37
|
-
.map(({ frameId }) => [frameId, frameManager.getFrame(frameId)?.isolatedContextId]));
|
|
38
|
-
const scopeKey = JSON.stringify(scope);
|
|
39
|
-
const current = indexTree(snapshot.tree);
|
|
40
|
-
const previous = baselines.get(frameManager);
|
|
41
|
-
// Store private, derived data, not the caller-mutable refs map or returned delta entries.
|
|
42
|
-
baselines.set(frameManager, { ...current, document, contexts, scopeKey });
|
|
43
|
-
if (diff !== true) return snapshot;
|
|
44
|
-
let reason;
|
|
45
|
-
if (!previous) reason = "no-baseline";
|
|
46
|
-
else if (previous.document !== document || previous.contexts !== contexts) reason = "navigation";
|
|
47
|
-
else if (previous.scopeKey !== scopeKey) reason = "options-changed";
|
|
48
|
-
else if (previous.unreferenced !== current.unreferenced) reason = "unreferenced-content";
|
|
49
|
-
if (reason) return { ...snapshot, full: true, reason };
|
|
50
|
-
|
|
51
|
-
const added = [];
|
|
52
|
-
const changed = [];
|
|
53
|
-
const removed = [];
|
|
54
|
-
for (const [ref, node] of current.nodes) {
|
|
55
|
-
const before = previous.nodes.get(ref);
|
|
56
|
-
if (!before) added.push({ ...node });
|
|
57
|
-
else if (before.tree !== node.tree) {
|
|
58
|
-
// A stable ref already identifies the role and name. Do not resend its unchanged
|
|
59
|
-
// label or placeholder on every keystroke; the remaining text is current state/value.
|
|
60
|
-
const label = /^[^\s"]+(?: "(?:\\.|[^"\\])*")? /;
|
|
61
|
-
let tree = node.tree;
|
|
62
|
-
const heading = label.exec(tree)?.[0];
|
|
63
|
-
if (heading && heading === label.exec(before.tree)?.[0]) tree = tree.slice(heading.length);
|
|
64
|
-
const placeholder = / \[placeholder="(?:\\.|[^"\\])*"\]/.exec(tree)?.[0];
|
|
65
|
-
if (placeholder && before.tree.includes(placeholder)) tree = tree.replace(placeholder, "");
|
|
66
|
-
changed.push({ ref, tree });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
for (const ref of previous.nodes.keys()) if (!current.nodes.has(ref)) removed.push(ref);
|
|
70
|
-
const result = { diff: { added, changed, removed, focused: current.focused }, full: false };
|
|
71
|
-
if (Buffer.byteLength(JSON.stringify(result), "utf8") > Buffer.byteLength(snapshot.tree, "utf8")) {
|
|
72
|
-
return { ...snapshot, full: true, reason: "diff-larger-than-full" };
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
package/src/trace.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { createNetworkSnoop } from "./network-snoop.js";
|
|
4
|
-
import { toHar } from "./har.js";
|
|
5
|
-
|
|
6
|
-
const SLUG_MAX = 48;
|
|
7
|
-
const SNOOP_MAX_ENTRIES = 5000;
|
|
8
|
-
|
|
9
|
-
function slug(name) {
|
|
10
|
-
const value = String(name ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
11
|
-
return (value || "step").slice(0, SLUG_MAX);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function messageOf(error) {
|
|
15
|
-
return error instanceof Error ? error.message : String(error);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function readConsole(page) {
|
|
19
|
-
// core.js exposes `page.console` as a PageConsole getter with logs(); simpler pages
|
|
20
|
-
// expose it as a method. Both hand back the buffered in-page entries.
|
|
21
|
-
const api = page.console;
|
|
22
|
-
const entries = typeof api === "function" ? await api.call(page) : await api?.logs?.();
|
|
23
|
-
return Array.isArray(entries) ? entries : [];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Records a flight recorder trace for one page: steps, screenshots, network, console,
|
|
28
|
-
* dialogs, navigations and downloads, flushed to `dir` as trace.jsonl, trace.har and
|
|
29
|
-
* summary.json when {@link stop} runs.
|
|
30
|
-
*/
|
|
31
|
-
export function createTrace(page, options = {}) {
|
|
32
|
-
if (!page?.cdp || typeof page.resolveSessionId !== "function") {
|
|
33
|
-
throw new TypeError("createTrace requires a page with cdp and resolveSessionId");
|
|
34
|
-
}
|
|
35
|
-
const {
|
|
36
|
-
dir,
|
|
37
|
-
screenshots = true,
|
|
38
|
-
network = true,
|
|
39
|
-
console: consoleLogs = true,
|
|
40
|
-
maxBodyBytes = 1_000_000,
|
|
41
|
-
events,
|
|
42
|
-
} = options;
|
|
43
|
-
if (typeof dir !== "string" || dir.length === 0) throw new TypeError("createTrace requires a dir");
|
|
44
|
-
|
|
45
|
-
const shotDir = path.join(dir, "screenshots");
|
|
46
|
-
const ready = mkdir(shotDir, { recursive: true });
|
|
47
|
-
const startedAt = Date.now();
|
|
48
|
-
const records = [];
|
|
49
|
-
const netEntries = [];
|
|
50
|
-
const unsubscribers = [];
|
|
51
|
-
const snoop = network
|
|
52
|
-
? createNetworkSnoop(page, { bodies: true, maxBodyBytes, maxEntries: SNOOP_MAX_ENTRIES })
|
|
53
|
-
: null;
|
|
54
|
-
let seq = 0;
|
|
55
|
-
let consoleSeen = 0;
|
|
56
|
-
let sessionId = null;
|
|
57
|
-
let stopped = false;
|
|
58
|
-
let stopping = null;
|
|
59
|
-
|
|
60
|
-
function record(event) {
|
|
61
|
-
const entry = { ...event, ts: Date.now(), seq: seq++ };
|
|
62
|
-
records.push(entry);
|
|
63
|
-
return entry;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const sessionReady = Promise.resolve(page.resolveSessionId()).then(id => { sessionId = id; });
|
|
67
|
-
sessionReady.catch(error => record({ kind: "warning", scope: "session", message: messageOf(error) }));
|
|
68
|
-
|
|
69
|
-
unsubscribers.push(page.cdp.on("Page.frameNavigated", (params, meta) => {
|
|
70
|
-
if (stopped || params?.frame?.parentId) return;
|
|
71
|
-
const add = () => record({ kind: "navigation", url: params?.frame?.url ?? "", frameId: params?.frame?.id ?? null });
|
|
72
|
-
if (sessionId === null) {
|
|
73
|
-
// The session id resolves asynchronously; hold early events until it is known.
|
|
74
|
-
sessionReady.then(() => { if (!stopped && meta?.sessionId === sessionId) add(); }).catch(() => {});
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (meta?.sessionId === sessionId) add();
|
|
78
|
-
}));
|
|
79
|
-
|
|
80
|
-
unsubscribers.push(page.on("dialog", dialog => record({
|
|
81
|
-
kind: "dialog",
|
|
82
|
-
type: dialog.type() ?? null,
|
|
83
|
-
message: dialog.message() ?? "",
|
|
84
|
-
defaultPrompt: dialog.defaultValue(),
|
|
85
|
-
url: dialog.url ?? null,
|
|
86
|
-
})));
|
|
87
|
-
|
|
88
|
-
if (events) {
|
|
89
|
-
unsubscribers.push(events.on("downloadStarted", payload => record({ kind: "download", phase: "started", ...payload })));
|
|
90
|
-
unsubscribers.push(events.on("downloadFinished", payload => record({ kind: "download", phase: "finished", ...payload })));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function capture(step, phase) {
|
|
94
|
-
const file = path.join(shotDir, `${step.seq}-${slug(step.name)}-${phase}.png`);
|
|
95
|
-
try {
|
|
96
|
-
// The buffer is written here rather than through screenshot({ path }) so the file
|
|
97
|
-
// always lands in the trace directory, whatever the page's path resolution does.
|
|
98
|
-
await writeFile(file, await page.screenshot({ type: "png" }));
|
|
99
|
-
step.screenshots[phase] = file;
|
|
100
|
-
} catch (error) {
|
|
101
|
-
record({ kind: "warning", scope: `screenshot:${phase}`, step: step.seq, message: messageOf(error) });
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function drainNetwork() {
|
|
106
|
-
for (const entry of snoop?.pop() ?? []) {
|
|
107
|
-
if (typeof entry.body === "string" && Buffer.byteLength(entry.body) > maxBodyBytes) {
|
|
108
|
-
entry.body = null;
|
|
109
|
-
entry.bodySkipped = true;
|
|
110
|
-
}
|
|
111
|
-
netEntries.push(entry);
|
|
112
|
-
record({ kind: "network", ...entry });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function drainConsole() {
|
|
117
|
-
if (!consoleLogs) return;
|
|
118
|
-
let entries;
|
|
119
|
-
try {
|
|
120
|
-
entries = await readConsole(page);
|
|
121
|
-
} catch {
|
|
122
|
-
// A closed or navigating page cannot report its console; keep the rest of the trace.
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (entries.length < consoleSeen) consoleSeen = 0;
|
|
126
|
-
for (const entry of entries.slice(consoleSeen)) record({ kind: "console", ...entry });
|
|
127
|
-
consoleSeen = entries.length;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async function drain() {
|
|
131
|
-
drainNetwork();
|
|
132
|
-
await drainConsole();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async function step(name, fn) {
|
|
136
|
-
if (typeof fn !== "function") throw new TypeError("trace.step requires a function");
|
|
137
|
-
await ready;
|
|
138
|
-
const entry = record({ kind: "step", name: String(name), startedAt: Date.now(), screenshots: {} });
|
|
139
|
-
if (screenshots) await capture(entry, "before");
|
|
140
|
-
try {
|
|
141
|
-
return await fn();
|
|
142
|
-
} catch (error) {
|
|
143
|
-
entry.error = messageOf(error);
|
|
144
|
-
throw error;
|
|
145
|
-
} finally {
|
|
146
|
-
entry.endedAt = Date.now();
|
|
147
|
-
entry.durationMs = entry.endedAt - entry.startedAt;
|
|
148
|
-
if (screenshots) await capture(entry, "after");
|
|
149
|
-
await drain();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function mark(name, data) {
|
|
154
|
-
return record({ kind: "mark", name: String(name), data: data ?? null });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async function finish() {
|
|
158
|
-
await ready;
|
|
159
|
-
await drain();
|
|
160
|
-
stopped = true;
|
|
161
|
-
for (const off of unsubscribers.splice(0, unsubscribers.length)) off();
|
|
162
|
-
snoop?.dispose();
|
|
163
|
-
const ordered = [...records].sort((a, b) => a.seq - b.seq);
|
|
164
|
-
const summary = {
|
|
165
|
-
steps: ordered.filter(entry => entry.kind === "step").length,
|
|
166
|
-
events: ordered.length,
|
|
167
|
-
network: netEntries.length,
|
|
168
|
-
startedAt,
|
|
169
|
-
endedAt: Date.now(),
|
|
170
|
-
url: page.url(),
|
|
171
|
-
};
|
|
172
|
-
await writeFile(path.join(dir, "trace.jsonl"), ordered.map(entry => `${JSON.stringify(entry)}\n`).join(""));
|
|
173
|
-
await writeFile(path.join(dir, "trace.har"), `${JSON.stringify(toHar(netEntries), null, 2)}\n`);
|
|
174
|
-
await writeFile(path.join(dir, "summary.json"), `${JSON.stringify(summary, null, 2)}\n`);
|
|
175
|
-
return summary;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function stop() {
|
|
179
|
-
return stopping ??= finish();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return { step, mark, stop, get dir() { return dir; } };
|
|
183
|
-
}
|
package/src/url-match.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// URL matching for page.waitForURL, ported from Playwright's packages/isomorphic/urlMatch.ts
|
|
2
|
-
// (Copyright (c) Microsoft Corporation, Apache License 2.0) so that globs, regular expressions and
|
|
3
|
-
// predicates written for Playwright match the same URLs here. OmOWright has no baseURL option, so
|
|
4
|
-
// globs resolve the way Playwright resolves them without one.
|
|
5
|
-
|
|
6
|
-
const escapedChars = new Set(["$", "^", "+", ".", "*", "(", ")", "|", "\\", "?", "{", "}", "[", "]"]);
|
|
7
|
-
|
|
8
|
-
function globToRegexPattern(glob) {
|
|
9
|
-
const tokens = ["^"];
|
|
10
|
-
let inGroup = false;
|
|
11
|
-
for (let i = 0; i < glob.length; ++i) {
|
|
12
|
-
const c = glob[i];
|
|
13
|
-
if (c === "\\" && i + 1 < glob.length) {
|
|
14
|
-
const char = glob[++i];
|
|
15
|
-
tokens.push(escapedChars.has(char) ? "\\" + char : char);
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
if (c === "*") {
|
|
19
|
-
const charBefore = glob[i - 1];
|
|
20
|
-
let starCount = 1;
|
|
21
|
-
while (glob[i + 1] === "*") {
|
|
22
|
-
starCount++;
|
|
23
|
-
i++;
|
|
24
|
-
}
|
|
25
|
-
if (starCount > 1) {
|
|
26
|
-
const charAfter = glob[i + 1];
|
|
27
|
-
// Match either /..something../ or /.
|
|
28
|
-
if (charAfter === "/") {
|
|
29
|
-
if (charBefore === "/") tokens.push("((.+/)|)");
|
|
30
|
-
else tokens.push("(.*/)");
|
|
31
|
-
++i;
|
|
32
|
-
} else {
|
|
33
|
-
tokens.push("(.*)");
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
tokens.push("([^/]*)");
|
|
37
|
-
}
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
switch (c) {
|
|
42
|
-
case "{":
|
|
43
|
-
if (inGroup) throw new Error(`Invalid glob pattern ${JSON.stringify(glob)}: nested '{' is not supported`);
|
|
44
|
-
inGroup = true;
|
|
45
|
-
tokens.push("(");
|
|
46
|
-
break;
|
|
47
|
-
case "}":
|
|
48
|
-
if (!inGroup) throw new Error(`Invalid glob pattern ${JSON.stringify(glob)}: unmatched '}'`);
|
|
49
|
-
inGroup = false;
|
|
50
|
-
tokens.push(")");
|
|
51
|
-
break;
|
|
52
|
-
case ",":
|
|
53
|
-
if (inGroup) {
|
|
54
|
-
tokens.push("|");
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
tokens.push("\\" + c);
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
tokens.push(escapedChars.has(c) ? "\\" + c : c);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (inGroup) throw new Error(`Invalid glob pattern ${JSON.stringify(glob)}: unmatched '{'`);
|
|
64
|
-
tokens.push("$");
|
|
65
|
-
return tokens.join("");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function resolveGlob(match) {
|
|
69
|
-
if (match.startsWith("*")) return match;
|
|
70
|
-
const tokenMap = new Map();
|
|
71
|
-
function mapToken(original, replacement) {
|
|
72
|
-
if (original.length === 0) return "";
|
|
73
|
-
tokenMap.set(replacement, original);
|
|
74
|
-
return replacement;
|
|
75
|
-
}
|
|
76
|
-
// Escaped `\\?` behaves the same as `?` in these glob patterns.
|
|
77
|
-
match = match.replaceAll(/\\\\\?/g, "?");
|
|
78
|
-
if (match.startsWith("about:") || match.startsWith("data:")
|
|
79
|
-
|| match.startsWith("chrome:") || match.startsWith("edge:")
|
|
80
|
-
|| match.startsWith("file:")) return match;
|
|
81
|
-
// Glob symbols may be escaped in the URL and some of them such as ? affect resolution,
|
|
82
|
-
// so they are replaced with safe components first.
|
|
83
|
-
const relativePath = match.split("/").map((token, index) => {
|
|
84
|
-
if (token === "." || token === ".." || token === "") return token;
|
|
85
|
-
// http*:// and similar: the stand-in scheme must be a web scheme so slashes follow the host.
|
|
86
|
-
if (index === 0 && token.endsWith(":")) {
|
|
87
|
-
if (token.indexOf("*") !== -1 || token.indexOf("{") !== -1) return mapToken(token, "http:");
|
|
88
|
-
// An explicit scheme is kept as is; it decides trailing slashes after the host.
|
|
89
|
-
return token;
|
|
90
|
-
}
|
|
91
|
-
// Literal components round-trip through new URL() so default ports, percent-encoding and IDN
|
|
92
|
-
// hosts are normalized; only components with glob characters are replaced.
|
|
93
|
-
if (!/[*?{}\\]/.test(token)) return token;
|
|
94
|
-
const questionIndex = token.indexOf("?");
|
|
95
|
-
if (questionIndex === -1) return mapToken(token, `$_${index}_$`);
|
|
96
|
-
const newPrefix = mapToken(token.substring(0, questionIndex), `$_${index}_$`);
|
|
97
|
-
const newSuffix = mapToken(token.substring(questionIndex), `?$_${index}_$`);
|
|
98
|
-
return newPrefix + newSuffix;
|
|
99
|
-
}).join("/");
|
|
100
|
-
const result = resolveURL(relativePath);
|
|
101
|
-
let resolved = result.resolved;
|
|
102
|
-
for (const [token, original] of tokenMap) {
|
|
103
|
-
const normalize = result.caseInsensitivePart?.includes(token);
|
|
104
|
-
const replacement = normalize ? original.toLowerCase() : original;
|
|
105
|
-
// The function form keeps `$$`, `$&` and similar replacement patterns literal.
|
|
106
|
-
resolved = resolved.replace(token, () => replacement);
|
|
107
|
-
}
|
|
108
|
-
return resolved;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function resolveURL(givenURL) {
|
|
112
|
-
try {
|
|
113
|
-
const url = new URL(givenURL);
|
|
114
|
-
// Scheme and host are case-insensitive.
|
|
115
|
-
return { resolved: url.toString(), caseInsensitivePart: url.origin };
|
|
116
|
-
} catch {
|
|
117
|
-
return { resolved: givenURL };
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function parseURL(url) {
|
|
122
|
-
try {
|
|
123
|
-
return new URL(url);
|
|
124
|
-
} catch {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function isRegExp(value) {
|
|
130
|
-
return value instanceof RegExp || Object.prototype.toString.call(value) === "[object RegExp]";
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Playwright's URL match: a glob string, a RegExp, or a predicate receiving a URL object.
|
|
135
|
-
* An empty or missing match accepts every URL; an invalid glob throws.
|
|
136
|
-
*/
|
|
137
|
-
export async function urlMatches(urlString, match) {
|
|
138
|
-
if (match === undefined || match === "") return true;
|
|
139
|
-
if (typeof match === "string") match = new RegExp(globToRegexPattern(resolveGlob(match)));
|
|
140
|
-
if (isRegExp(match)) {
|
|
141
|
-
match.lastIndex = 0;
|
|
142
|
-
return match.test(urlString);
|
|
143
|
-
}
|
|
144
|
-
if (typeof match !== "function") throw new TypeError("url parameter should be string, RegExp or function");
|
|
145
|
-
const url = parseURL(urlString);
|
|
146
|
-
if (!url) return false;
|
|
147
|
-
return Boolean(await match(url));
|
|
148
|
-
}
|