spana-test 0.6.0 → 0.8.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/.agents/skills/spana-testing/SKILL.md +19 -15
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +9 -9
- package/dist/{allure-RNMEYTXS.js → allure-RAEK4SIH.js} +2 -2
- package/dist/allure-RAEK4SIH.js.map +1 -0
- package/dist/{android-4NVTZMHL.js → android-6BOQTMM3.js} +2 -2
- package/dist/app-CgbLADmF.d.ts +1191 -0
- package/dist/{chunk-H27IBIGA.js → chunk-2AFWVHQK.js} +63 -43
- package/dist/chunk-2AFWVHQK.js.map +1 -0
- package/dist/{chunk-KBRLIQRA.js → chunk-2T4K7BJ3.js} +8 -3
- package/dist/chunk-2T4K7BJ3.js.map +1 -0
- package/dist/{chunk-KEUZLBQS.js → chunk-3FXDOTFI.js} +1361 -327
- package/dist/chunk-3FXDOTFI.js.map +1 -0
- package/dist/{chunk-4K3FZTSV.js → chunk-54ASKII6.js} +6 -2
- package/dist/chunk-54ASKII6.js.map +1 -0
- package/dist/{chunk-PWUJT5HE.js → chunk-AJCSETN6.js} +1330 -246
- package/dist/chunk-AJCSETN6.js.map +1 -0
- package/dist/chunk-JPZCZHL4.js +79 -0
- package/dist/chunk-JPZCZHL4.js.map +1 -0
- package/dist/{chunk-C4E4XULT.js → chunk-NS2HLJO4.js} +3 -3
- package/dist/{chunk-S4JVAHBR.js → chunk-PMXSU5MS.js} +2 -2
- package/dist/{chunk-HYSTRWYN.js → chunk-QP4MDUBY.js} +4 -4
- package/dist/chunk-RKYKRGHB.js +236 -0
- package/dist/chunk-RKYKRGHB.js.map +1 -0
- package/dist/{chunk-HCG4CJKR.js → chunk-SF7UYW4I.js} +3 -3
- package/dist/{chunk-LCV673G3.js → chunk-SNL4X67N.js} +1166 -94
- package/dist/chunk-SNL4X67N.js.map +1 -0
- package/dist/{chunk-WBBMEAHU.js → chunk-WKVU24B6.js} +8 -8
- package/dist/{chunk-S5JNNDXS.js → chunk-WV3ALL3H.js} +65 -37
- package/dist/chunk-WV3ALL3H.js.map +1 -0
- package/dist/cli.js +23 -11
- package/dist/cli.js.map +1 -1
- package/dist/config-loader-5FU45FXK.js +9 -0
- package/dist/{console-MI2XB5RG.js → console-BGAK7Z2L.js} +11 -1
- package/dist/{console-MI2XB5RG.js.map → console-BGAK7Z2L.js.map} +1 -1
- package/dist/{daemon-manager-FBISTX24.js → daemon-manager-DDYQITPD.js} +4 -2
- package/dist/{discover-LHEBSUIP.js → discover-RLSKEBAX.js} +5 -5
- package/dist/{doctor-command-WEHFANT7.js → doctor-command-HEQQOYUR.js} +26 -18
- package/dist/doctor-command-HEQQOYUR.js.map +1 -0
- package/dist/{flow-C2JQ7gUu.d.ts → flow-Md5xLwbX.d.ts} +3 -29
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-F3X3XPSX.js → html-JO2YNRWX.js} +195 -4
- package/dist/html-JO2YNRWX.js.map +1 -0
- package/dist/index.d.ts +400 -15
- package/dist/index.js +255 -18
- package/dist/index.js.map +1 -1
- package/dist/{installer-VUPFWP5X.js → installer-IYGMG7LS.js} +4 -4
- package/dist/{ios-JPK43TFZ.js → ios-Y4TO5MBR.js} +7 -3
- package/dist/{screenshot-compare-5NINZVOK.js → screenshot-compare-POTXVUTL.js} +2 -2
- package/dist/{server-3MGZNK67.js → server-4PEREPHY.js} +2 -2
- package/dist/{server-OANRDAHN.js → server-JPNH33MX.js} +50 -36
- package/dist/server-JPNH33MX.js.map +1 -0
- package/dist/{session-Daq0mE_a.d.ts → session-D9e30RVS.d.ts} +1 -1
- package/dist/session-V4PYJXNB.js +18 -0
- package/dist/{studio-command-RJYLJT4I.js → studio-command-JOIFCOHC.js} +2 -2
- package/dist/{test-command-ALH5ZQY5.js → test-command-JCO2HPYI.js} +221 -27
- package/dist/test-command-JCO2HPYI.js.map +1 -0
- package/native/darwin-arm64/libspana_native.dylib +0 -0
- package/native/darwin-x64/libspana_native.dylib +0 -0
- package/native/linux-arm64/libspana_native.so +0 -0
- package/native/linux-x64/libspana_native.so +0 -0
- package/native/win32-x64/spana_native.dll +0 -0
- package/package.json +2 -1
- package/studio-dist/assets/index-CBFsOh-9.js +193 -0
- package/studio-dist/assets/index-DH_18EyL.css +1 -0
- package/studio-dist/index.html +2 -2
- package/dist/allure-RNMEYTXS.js.map +0 -1
- package/dist/app-DcLXtpv4.d.ts +0 -908
- package/dist/chunk-4K3FZTSV.js.map +0 -1
- package/dist/chunk-DTNK54C2.js +0 -127
- package/dist/chunk-DTNK54C2.js.map +0 -1
- package/dist/chunk-H27IBIGA.js.map +0 -1
- package/dist/chunk-KBRLIQRA.js.map +0 -1
- package/dist/chunk-KEUZLBQS.js.map +0 -1
- package/dist/chunk-LCV673G3.js.map +0 -1
- package/dist/chunk-OBCFACUW.js +0 -28
- package/dist/chunk-OBCFACUW.js.map +0 -1
- package/dist/chunk-PWUJT5HE.js.map +0 -1
- package/dist/chunk-S5JNNDXS.js.map +0 -1
- package/dist/config-loader-J4Z2PMUQ.js +0 -9
- package/dist/doctor-command-WEHFANT7.js.map +0 -1
- package/dist/html-F3X3XPSX.js.map +0 -1
- package/dist/server-OANRDAHN.js.map +0 -1
- package/dist/session-Q3QYHT4Q.js +0 -18
- package/dist/test-command-ALH5ZQY5.js.map +0 -1
- package/studio-dist/assets/index-C-Io44gy.js +0 -193
- package/studio-dist/assets/index-DfM9lK4p.css +0 -1
- /package/dist/{android-4NVTZMHL.js.map → android-6BOQTMM3.js.map} +0 -0
- /package/dist/{chunk-C4E4XULT.js.map → chunk-NS2HLJO4.js.map} +0 -0
- /package/dist/{chunk-S4JVAHBR.js.map → chunk-PMXSU5MS.js.map} +0 -0
- /package/dist/{chunk-HYSTRWYN.js.map → chunk-QP4MDUBY.js.map} +0 -0
- /package/dist/{chunk-HCG4CJKR.js.map → chunk-SF7UYW4I.js.map} +0 -0
- /package/dist/{chunk-WBBMEAHU.js.map → chunk-WKVU24B6.js.map} +0 -0
- /package/dist/{config-loader-J4Z2PMUQ.js.map → config-loader-5FU45FXK.js.map} +0 -0
- /package/dist/{daemon-manager-FBISTX24.js.map → daemon-manager-DDYQITPD.js.map} +0 -0
- /package/dist/{discover-LHEBSUIP.js.map → discover-RLSKEBAX.js.map} +0 -0
- /package/dist/{installer-VUPFWP5X.js.map → installer-IYGMG7LS.js.map} +0 -0
- /package/dist/{ios-JPK43TFZ.js.map → ios-Y4TO5MBR.js.map} +0 -0
- /package/dist/{screenshot-compare-5NINZVOK.js.map → screenshot-compare-POTXVUTL.js.map} +0 -0
- /package/dist/{server-3MGZNK67.js.map → server-4PEREPHY.js.map} +0 -0
- /package/dist/{session-Q3QYHT4Q.js.map → session-V4PYJXNB.js.map} +0 -0
- /package/dist/{studio-command-RJYLJT4I.js.map → studio-command-JOIFCOHC.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_MAX_WORKERS_PER_PROCESS,
|
|
3
|
+
buildPlaybackTraceFromSteps,
|
|
4
|
+
createRemoteFlowClaimer,
|
|
5
|
+
exportFramesToMp4,
|
|
6
|
+
extractCodeFrame,
|
|
7
|
+
formatCodeFrame,
|
|
2
8
|
launchDirectCdpBrowser,
|
|
3
9
|
makeLightweightCdpDriver,
|
|
4
10
|
orderFlowsLongestFirst,
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
partitionFlowsAcrossProcesses,
|
|
12
|
+
planProcessPool,
|
|
13
|
+
resolveWebEngine,
|
|
14
|
+
runMultiProcessPool,
|
|
15
|
+
speculativelyPrelaunchWebBrowser,
|
|
16
|
+
startAndroidVideoRecorder,
|
|
17
|
+
startCdpScreencastRecorder,
|
|
18
|
+
startIosSimulatorVideoRecorder,
|
|
19
|
+
startSharedFlowQueueServer
|
|
20
|
+
} from "./chunk-3FXDOTFI.js";
|
|
7
21
|
import {
|
|
8
22
|
SPANA_MCP_TOOLS,
|
|
9
23
|
SpanaMcpServer,
|
|
10
24
|
buildFlowFileFromLines,
|
|
11
25
|
formatSelectorCode
|
|
12
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-NS2HLJO4.js";
|
|
13
27
|
import {
|
|
14
28
|
defineConfig
|
|
15
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-2T4K7BJ3.js";
|
|
16
30
|
import "./chunk-X2TJP7LB.js";
|
|
17
31
|
import {
|
|
18
32
|
createGitHubPrReporter,
|
|
@@ -31,24 +45,34 @@ import {
|
|
|
31
45
|
probabilityFromTopLogprobs
|
|
32
46
|
} from "./chunk-3SH5JQF7.js";
|
|
33
47
|
import {
|
|
48
|
+
byCss,
|
|
49
|
+
byRole,
|
|
34
50
|
connectPlaywrightOverCDP,
|
|
35
51
|
connectPlaywrightOverWS,
|
|
36
52
|
domRectToScreenBounds,
|
|
37
53
|
ensureWarmBrowserDaemon,
|
|
54
|
+
filterSelector,
|
|
38
55
|
findWebViewFrame,
|
|
56
|
+
first,
|
|
57
|
+
inFrame,
|
|
39
58
|
invalidateWebViewFrameCache,
|
|
59
|
+
isComposableDomSelector,
|
|
40
60
|
isOffscreenInViewport,
|
|
41
61
|
isSystemUISelector,
|
|
42
62
|
isTestIDSelector,
|
|
63
|
+
last,
|
|
43
64
|
launchPlaywrightBrowser,
|
|
44
65
|
makeElectronDriver,
|
|
66
|
+
nth,
|
|
45
67
|
resolveElementAcrossChannels,
|
|
46
|
-
systemUI
|
|
47
|
-
|
|
68
|
+
systemUI,
|
|
69
|
+
within
|
|
70
|
+
} from "./chunk-AJCSETN6.js";
|
|
48
71
|
import {
|
|
49
72
|
AndroidWebViewCdpChannel,
|
|
50
73
|
AppleWebInspectorClient,
|
|
51
74
|
CdpDomChannel,
|
|
75
|
+
SPANA_INJECTED_RUNTIME_SCRIPT,
|
|
52
76
|
SpanaBridgeChannel,
|
|
53
77
|
TARGET_CHANNEL_MATRIX,
|
|
54
78
|
WebKitInspectorChannel,
|
|
@@ -56,6 +80,7 @@ import {
|
|
|
56
80
|
buildDomWaitForHiddenScript,
|
|
57
81
|
buildDomWaitForMatchScript,
|
|
58
82
|
buildDomWaitForSelectorScript,
|
|
83
|
+
buildInjectedCallScript,
|
|
59
84
|
createAndroidWebViewCdpChannel,
|
|
60
85
|
createCdpDomChannel,
|
|
61
86
|
createCompositeDomChannel,
|
|
@@ -71,24 +96,32 @@ import {
|
|
|
71
96
|
resolveElectrobunEngine,
|
|
72
97
|
resolveElectrobunLaunchPlan,
|
|
73
98
|
resolveTargetDescriptor
|
|
74
|
-
} from "./chunk-
|
|
75
|
-
import "./chunk-
|
|
99
|
+
} from "./chunk-SNL4X67N.js";
|
|
100
|
+
import "./chunk-QP4MDUBY.js";
|
|
76
101
|
import {
|
|
102
|
+
defaultDaemonStateDir,
|
|
77
103
|
getHealthyWarmDaemon,
|
|
78
104
|
listWarmDaemons,
|
|
79
105
|
stopAllWarmDaemons,
|
|
80
106
|
stopWarmDaemon,
|
|
81
107
|
updateWarmDaemonSession
|
|
82
|
-
} from "./chunk-
|
|
83
|
-
import
|
|
84
|
-
|
|
108
|
+
} from "./chunk-RKYKRGHB.js";
|
|
109
|
+
import {
|
|
110
|
+
cloneIOSSimulator,
|
|
111
|
+
deleteIOSSimulator
|
|
112
|
+
} from "./chunk-WV3ALL3H.js";
|
|
113
|
+
import {
|
|
114
|
+
allocateFreePort,
|
|
115
|
+
assertPortAvailable,
|
|
116
|
+
isPortAvailable
|
|
117
|
+
} from "./chunk-JPZCZHL4.js";
|
|
85
118
|
import {
|
|
86
119
|
comparePngNative,
|
|
87
120
|
getNativeAcceleratorPath,
|
|
88
121
|
isNativeAcceleratorActive,
|
|
89
122
|
tokenizeXmlNative
|
|
90
|
-
} from "./chunk-
|
|
91
|
-
import "./chunk-
|
|
123
|
+
} from "./chunk-54ASKII6.js";
|
|
124
|
+
import "./chunk-2AFWVHQK.js";
|
|
92
125
|
import "./chunk-DGUM43GV.js";
|
|
93
126
|
|
|
94
127
|
// src/api/flow.ts
|
|
@@ -238,8 +271,8 @@ function extractDestructuredParamNames(fn) {
|
|
|
238
271
|
}
|
|
239
272
|
token += ch;
|
|
240
273
|
}
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
274
|
+
const last2 = parseDestructuredKey(token);
|
|
275
|
+
if (last2) names.push(last2);
|
|
243
276
|
return names;
|
|
244
277
|
}
|
|
245
278
|
function parseDestructuredKey(raw) {
|
|
@@ -427,9 +460,55 @@ function createApiFixture(options) {
|
|
|
427
460
|
function definePersona(name, config) {
|
|
428
461
|
return { name, ...config };
|
|
429
462
|
}
|
|
463
|
+
function toImportableCredentials(creds) {
|
|
464
|
+
if (!creds) return [];
|
|
465
|
+
return creds.filter(
|
|
466
|
+
(c) => typeof c.privateKey === "string" && c.privateKey.length > 0
|
|
467
|
+
).map((c) => ({
|
|
468
|
+
credentialId: c.credentialId,
|
|
469
|
+
isResidentCredential: c.isResidentCredential,
|
|
470
|
+
privateKey: c.privateKey,
|
|
471
|
+
signCount: c.signCount,
|
|
472
|
+
...c.rpId !== void 0 ? { rpId: c.rpId } : {},
|
|
473
|
+
...c.userHandle !== void 0 ? { userHandle: c.userHandle } : {},
|
|
474
|
+
...c.userName !== void 0 ? { userName: c.userName } : {}
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
var VirtualCredentialStore = class {
|
|
478
|
+
store = /* @__PURE__ */ new Map();
|
|
479
|
+
save(persona, credentials) {
|
|
480
|
+
const importable = toImportableCredentials(credentials);
|
|
481
|
+
if (importable.length > 0) {
|
|
482
|
+
this.store.set(persona, importable);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
get(persona) {
|
|
486
|
+
return [...this.store.get(persona) ?? []];
|
|
487
|
+
}
|
|
488
|
+
has(persona) {
|
|
489
|
+
return (this.store.get(persona)?.length ?? 0) > 0;
|
|
490
|
+
}
|
|
491
|
+
clear(persona) {
|
|
492
|
+
if (!persona) {
|
|
493
|
+
this.store.clear();
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
this.store.delete(persona);
|
|
497
|
+
}
|
|
498
|
+
async restore(persona, app, opts) {
|
|
499
|
+
const creds = this.store.get(persona);
|
|
500
|
+
if (!creds || creds.length === 0) return 0;
|
|
501
|
+
const authId = await app.enableVirtualAuthenticator(opts);
|
|
502
|
+
for (const cred of creds) {
|
|
503
|
+
await app.addVirtualCredential(cred, authId);
|
|
504
|
+
}
|
|
505
|
+
return creds.length;
|
|
506
|
+
}
|
|
507
|
+
};
|
|
430
508
|
var PersonaAuthCache = class {
|
|
431
509
|
cache = /* @__PURE__ */ new Map();
|
|
432
510
|
inflight = /* @__PURE__ */ new Map();
|
|
511
|
+
credentials = new VirtualCredentialStore();
|
|
433
512
|
keyFor(persona) {
|
|
434
513
|
return `${persona.name}::${persona.cacheKey ?? "default"}`;
|
|
435
514
|
}
|
|
@@ -439,16 +518,20 @@ var PersonaAuthCache = class {
|
|
|
439
518
|
invalidate(name, cacheKey = "default") {
|
|
440
519
|
if (!name) {
|
|
441
520
|
this.cache.clear();
|
|
521
|
+
this.credentials.clear();
|
|
442
522
|
return;
|
|
443
523
|
}
|
|
444
524
|
this.cache.delete(`${name}::${cacheKey}`);
|
|
525
|
+
this.credentials.clear(`${name}::${cacheKey}`);
|
|
445
526
|
}
|
|
446
527
|
/**
|
|
447
528
|
* Ensure `persona` is authenticated in `ctx`. On cache miss, executes `persona.signIn(ctx)`
|
|
448
|
-
* once (coalescing concurrent callers); on cache hit, restores cookies/storageState
|
|
529
|
+
* once (coalescing concurrent callers); on cache hit, restores cookies/storageState and
|
|
530
|
+
* imports any stored WebAuthn virtual passkeys directly into the fresh context.
|
|
449
531
|
*/
|
|
450
532
|
async authenticate(persona, ctx) {
|
|
451
533
|
const key = this.keyFor(persona);
|
|
534
|
+
const app = ctx.app;
|
|
452
535
|
let state = this.cache.get(key);
|
|
453
536
|
let wasMiss = false;
|
|
454
537
|
if (!state) {
|
|
@@ -457,9 +540,23 @@ var PersonaAuthCache = class {
|
|
|
457
540
|
if (!pending) {
|
|
458
541
|
pending = (async () => {
|
|
459
542
|
const produced = await persona.signIn(ctx) ?? {};
|
|
543
|
+
let virtualCredentials = produced.virtualCredentials;
|
|
544
|
+
if (!virtualCredentials && persona.captureVirtualCredentials !== false && ctx.platform === "web") {
|
|
545
|
+
try {
|
|
546
|
+
const captured = await app.getVirtualCredentials();
|
|
547
|
+
if (captured.length > 0) {
|
|
548
|
+
virtualCredentials = captured;
|
|
549
|
+
}
|
|
550
|
+
} catch {
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (virtualCredentials && virtualCredentials.length > 0) {
|
|
554
|
+
this.credentials.save(key, virtualCredentials);
|
|
555
|
+
}
|
|
460
556
|
const entry = {
|
|
461
557
|
storage: produced.storage,
|
|
462
558
|
storageStatePath: produced.storageStatePath,
|
|
559
|
+
virtualCredentials,
|
|
463
560
|
cachedAt: Date.now()
|
|
464
561
|
};
|
|
465
562
|
this.cache.set(key, entry);
|
|
@@ -471,7 +568,6 @@ var PersonaAuthCache = class {
|
|
|
471
568
|
}
|
|
472
569
|
state = await pending;
|
|
473
570
|
}
|
|
474
|
-
const app = ctx.app;
|
|
475
571
|
if (!wasMiss) {
|
|
476
572
|
if (state.storageStatePath && ctx.platform === "web") {
|
|
477
573
|
await app.loadAuthState(state.storageStatePath);
|
|
@@ -479,6 +575,9 @@ var PersonaAuthCache = class {
|
|
|
479
575
|
if (state.storage) {
|
|
480
576
|
await app.setStorage(state.storage);
|
|
481
577
|
}
|
|
578
|
+
if (ctx.platform === "web" && this.credentials.has(key)) {
|
|
579
|
+
await this.credentials.restore(key, app, persona.authenticatorOptions);
|
|
580
|
+
}
|
|
482
581
|
}
|
|
483
582
|
if (persona.navigateTo) {
|
|
484
583
|
await app.openLink(persona.navigateTo);
|
|
@@ -712,27 +811,143 @@ var ReplaySession = class {
|
|
|
712
811
|
return summary;
|
|
713
812
|
}
|
|
714
813
|
};
|
|
814
|
+
|
|
815
|
+
// src/core/network-cache.ts
|
|
816
|
+
import { createHash as createHash2 } from "crypto";
|
|
817
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
818
|
+
import { join as join2 } from "path";
|
|
819
|
+
function buildNetworkCacheKey(method, url) {
|
|
820
|
+
const normalizedMethod = method.toUpperCase();
|
|
821
|
+
const hash = createHash2("sha256").update(`${normalizedMethod} ${url}`).digest("hex").slice(0, 16);
|
|
822
|
+
const slug = url.replace(/^https?:\/\//, "").replaceAll(/[^a-zA-Z0-9-_]/g, "_").replaceAll(/_+/g, "_").slice(0, 48);
|
|
823
|
+
return `${normalizedMethod.toLowerCase()}-${slug}-${hash}`;
|
|
824
|
+
}
|
|
825
|
+
var NetworkReplayCache = class {
|
|
826
|
+
cacheDir;
|
|
827
|
+
constructor(options = {}) {
|
|
828
|
+
this.cacheDir = options.cacheDir ?? join2(process.cwd(), ".spana", "network-cache");
|
|
829
|
+
}
|
|
830
|
+
entryPath(key) {
|
|
831
|
+
return join2(this.cacheDir, `${key}.json`);
|
|
832
|
+
}
|
|
833
|
+
get(method, url) {
|
|
834
|
+
const key = buildNetworkCacheKey(method, url);
|
|
835
|
+
const filePath = this.entryPath(key);
|
|
836
|
+
if (!existsSync2(filePath)) return null;
|
|
837
|
+
try {
|
|
838
|
+
const parsed = JSON.parse(readFileSync2(filePath, "utf8"));
|
|
839
|
+
if (parsed && parsed.version === 1 && typeof parsed.body === "string") {
|
|
840
|
+
return parsed;
|
|
841
|
+
}
|
|
842
|
+
} catch {
|
|
843
|
+
}
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
set(entry) {
|
|
847
|
+
mkdirSync2(this.cacheDir, { recursive: true });
|
|
848
|
+
const key = buildNetworkCacheKey(entry.method, entry.url);
|
|
849
|
+
const record = {
|
|
850
|
+
version: 1,
|
|
851
|
+
key,
|
|
852
|
+
method: entry.method.toUpperCase(),
|
|
853
|
+
url: entry.url,
|
|
854
|
+
status: entry.status,
|
|
855
|
+
contentType: entry.contentType,
|
|
856
|
+
...entry.headers ? { headers: entry.headers } : {},
|
|
857
|
+
body: entry.body,
|
|
858
|
+
recordedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
859
|
+
};
|
|
860
|
+
writeFileSync2(this.entryPath(key), JSON.stringify(record, null, 2), "utf8");
|
|
861
|
+
return record;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Fetch an endpoint live on cache miss (in `"record"` or `"auto"` mode) or return
|
|
865
|
+
* the cached response in <1ms on cache hit (in `"replay"` or `"auto"` mode).
|
|
866
|
+
*/
|
|
867
|
+
async resolve(url, options) {
|
|
868
|
+
const method = (options?.method ?? "GET").toUpperCase();
|
|
869
|
+
const mode = options?.mode ?? "auto";
|
|
870
|
+
if (mode !== "record") {
|
|
871
|
+
const hit = this.get(method, url);
|
|
872
|
+
if (hit) return { entry: hit, source: "cache" };
|
|
873
|
+
if (mode === "replay") {
|
|
874
|
+
throw new Error(`NetworkReplayCache miss in strict replay mode for ${method} ${url}`);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
const fetchFn = options?.fetchFn ?? fetch;
|
|
878
|
+
const res = await fetchFn(url, { method, headers: options?.headers });
|
|
879
|
+
const body = await res.text();
|
|
880
|
+
const contentType = res.headers.get("content-type") ?? "application/json";
|
|
881
|
+
const entry = this.set({
|
|
882
|
+
method,
|
|
883
|
+
url,
|
|
884
|
+
status: res.status,
|
|
885
|
+
contentType,
|
|
886
|
+
body
|
|
887
|
+
});
|
|
888
|
+
return { entry, source: "network" };
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
async function attachNetworkReplayCache(app, options) {
|
|
892
|
+
const cache = new NetworkReplayCache({ cacheDir: options.cacheDir });
|
|
893
|
+
let cacheHits = 0;
|
|
894
|
+
let networkFetches = 0;
|
|
895
|
+
for (const route of options.routes) {
|
|
896
|
+
const { entry, source } = await cache.resolve(route.url, {
|
|
897
|
+
method: route.method,
|
|
898
|
+
mode: options.mode,
|
|
899
|
+
headers: route.headers,
|
|
900
|
+
fetchFn: options.fetchFn
|
|
901
|
+
});
|
|
902
|
+
if (source === "cache") cacheHits += 1;
|
|
903
|
+
else networkFetches += 1;
|
|
904
|
+
await app.mockNetwork(route.matcher ?? route.url, {
|
|
905
|
+
status: entry.status,
|
|
906
|
+
contentType: entry.contentType,
|
|
907
|
+
headers: entry.headers,
|
|
908
|
+
body: entry.body
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
return {
|
|
912
|
+
cacheHits,
|
|
913
|
+
networkFetches,
|
|
914
|
+
totalRoutes: options.routes.length
|
|
915
|
+
};
|
|
916
|
+
}
|
|
715
917
|
export {
|
|
716
918
|
AndroidWebViewCdpChannel,
|
|
717
919
|
AppleWebInspectorClient,
|
|
718
920
|
CdpDomChannel,
|
|
921
|
+
DEFAULT_MAX_WORKERS_PER_PROCESS,
|
|
922
|
+
NetworkReplayCache,
|
|
719
923
|
PersonaAuthCache,
|
|
720
924
|
ReplayCacheStore,
|
|
721
925
|
ReplaySession,
|
|
926
|
+
SPANA_INJECTED_RUNTIME_SCRIPT,
|
|
722
927
|
SPANA_MCP_TOOLS,
|
|
723
928
|
SpanaBridgeChannel,
|
|
724
929
|
SpanaMcpServer,
|
|
725
930
|
TARGET_CHANNEL_MATRIX,
|
|
931
|
+
VirtualCredentialStore,
|
|
726
932
|
WebKitInspectorChannel,
|
|
933
|
+
allocateFreePort,
|
|
727
934
|
applyNamedSetup,
|
|
728
935
|
applyTestFilters,
|
|
936
|
+
assertPortAvailable,
|
|
937
|
+
attachNetworkReplayCache,
|
|
729
938
|
buildDomFillScript,
|
|
730
939
|
buildDomWaitForHiddenScript,
|
|
731
940
|
buildDomWaitForMatchScript,
|
|
732
941
|
buildDomWaitForSelectorScript,
|
|
733
942
|
buildFilterCandidates,
|
|
734
943
|
buildFlowFileFromLines,
|
|
944
|
+
buildInjectedCallScript,
|
|
945
|
+
buildNetworkCacheKey,
|
|
946
|
+
buildPlaybackTraceFromSteps,
|
|
735
947
|
buildReplayCacheKey,
|
|
948
|
+
byCss,
|
|
949
|
+
byRole,
|
|
950
|
+
cloneIOSSimulator,
|
|
736
951
|
collectGitChanges,
|
|
737
952
|
comparePngNative,
|
|
738
953
|
connectPlaywrightOverCDP,
|
|
@@ -746,53 +961,75 @@ export {
|
|
|
746
961
|
createGitHubPrReporter,
|
|
747
962
|
createLogprobDecisionJudge,
|
|
748
963
|
createOllamaDecisionJudge,
|
|
964
|
+
createRemoteFlowClaimer,
|
|
749
965
|
createSpanaBridgeChannel,
|
|
750
966
|
createWebKitInspectorChannel,
|
|
751
967
|
decisionFilter,
|
|
752
968
|
decodeWebInspectorFrames,
|
|
969
|
+
defaultDaemonStateDir,
|
|
753
970
|
defineConfig,
|
|
754
971
|
definePersona,
|
|
755
972
|
defineSetup,
|
|
973
|
+
deleteIOSSimulator,
|
|
756
974
|
deterministicImpactFilter,
|
|
757
975
|
domRectToScreenBounds,
|
|
758
976
|
encodeWebInspectorPacket,
|
|
759
977
|
ensureWarmBrowserDaemon,
|
|
978
|
+
exportFramesToMp4,
|
|
979
|
+
extractCodeFrame,
|
|
760
980
|
extractDestructuredParamNames,
|
|
981
|
+
filterSelector,
|
|
761
982
|
findSimulatorWebInspectorSocket,
|
|
762
983
|
findWebViewFrame,
|
|
984
|
+
first,
|
|
763
985
|
flow,
|
|
986
|
+
formatCodeFrame,
|
|
764
987
|
formatFilterSummary,
|
|
765
988
|
formatGitHubPrMarkdown,
|
|
766
989
|
formatSelectorCode,
|
|
767
990
|
formatTargetMatrixTable,
|
|
768
991
|
getHealthyWarmDaemon,
|
|
769
992
|
getNativeAcceleratorPath,
|
|
993
|
+
inFrame,
|
|
770
994
|
invalidateWebViewFrameCache,
|
|
995
|
+
isComposableDomSelector,
|
|
771
996
|
isNativeAcceleratorActive,
|
|
772
997
|
isOffscreenInViewport,
|
|
998
|
+
isPortAvailable,
|
|
773
999
|
isSystemUISelector,
|
|
774
1000
|
isTestIDSelector,
|
|
1001
|
+
last,
|
|
775
1002
|
launchDirectCdpBrowser,
|
|
776
1003
|
launchPlaywrightBrowser,
|
|
777
1004
|
listWarmDaemons,
|
|
778
1005
|
makeElectrobunDriver,
|
|
779
1006
|
makeElectronDriver,
|
|
780
1007
|
makeLightweightCdpDriver,
|
|
1008
|
+
nth,
|
|
781
1009
|
orderFlowsLongestFirst,
|
|
782
1010
|
parseAndroidWebViewSockets,
|
|
783
1011
|
parseWebInspectorXmlFrame,
|
|
1012
|
+
partitionFlowsAcrossProcesses,
|
|
784
1013
|
pathRuleFilter,
|
|
1014
|
+
planProcessPool,
|
|
785
1015
|
probabilityFromTopLogprobs,
|
|
786
1016
|
replayRecordedAction,
|
|
787
1017
|
resolveElectrobunEngine,
|
|
788
1018
|
resolveElectrobunLaunchPlan,
|
|
789
1019
|
resolveElementAcrossChannels,
|
|
790
1020
|
resolveTargetDescriptor,
|
|
1021
|
+
resolveWebEngine,
|
|
1022
|
+
runMultiProcessPool,
|
|
791
1023
|
speculativelyPrelaunchWebBrowser,
|
|
1024
|
+
startAndroidVideoRecorder,
|
|
1025
|
+
startCdpScreencastRecorder,
|
|
1026
|
+
startIosSimulatorVideoRecorder,
|
|
1027
|
+
startSharedFlowQueueServer,
|
|
792
1028
|
stopAllWarmDaemons,
|
|
793
1029
|
stopWarmDaemon,
|
|
794
1030
|
systemUI,
|
|
795
1031
|
tokenizeXmlNative,
|
|
796
|
-
updateWarmDaemonSession
|
|
1032
|
+
updateWarmDaemonSession,
|
|
1033
|
+
within
|
|
797
1034
|
};
|
|
798
1035
|
//# sourceMappingURL=index.js.map
|