@riddledc/riddle-proof 0.7.135 → 0.7.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4IAUK6C6.js → chunk-DNSJMFK6.js} +62 -12
- package/dist/cli.cjs +62 -12
- package/dist/cli.js +1 -1
- package/dist/index.cjs +62 -12
- package/dist/index.js +1 -1
- package/dist/profile.cjs +62 -12
- package/dist/profile.d.cts +2 -0
- package/dist/profile.d.ts +2 -0
- package/dist/profile.js +1 -1
- package/package.json +1 -1
|
@@ -732,6 +732,18 @@ function normalizeSetupAction(input, index) {
|
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
734
|
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
735
|
+
const storeReturnTo = stringFromOwn(
|
|
736
|
+
input,
|
|
737
|
+
"store_return_to",
|
|
738
|
+
"storeReturnTo",
|
|
739
|
+
"save_return_to",
|
|
740
|
+
"saveReturnTo",
|
|
741
|
+
"assign_return_to",
|
|
742
|
+
"assignReturnTo",
|
|
743
|
+
"return_state_path",
|
|
744
|
+
"returnStatePath"
|
|
745
|
+
);
|
|
746
|
+
const captureReturn = input.capture_return === false || input.captureReturn === false || input.include_return === false || input.includeReturn === false || input.omit_return === true || input.omitReturn === true ? false : void 0;
|
|
735
747
|
const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
|
|
736
748
|
const hasUntilExpectedValue = hasOwn(input, "until_expected_value") || hasOwn(input, "untilExpectedValue") || hasOwn(input, "until_expected") || hasOwn(input, "untilExpected") || hasOwn(input, "until_value") || hasOwn(input, "untilValue") || hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected");
|
|
737
749
|
if (type === "window_call_until") {
|
|
@@ -776,6 +788,8 @@ function normalizeSetupAction(input, index) {
|
|
|
776
788
|
path,
|
|
777
789
|
args,
|
|
778
790
|
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
791
|
+
store_return_to: storeReturnTo,
|
|
792
|
+
capture_return: captureReturn,
|
|
779
793
|
until_path: untilPath,
|
|
780
794
|
until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
|
|
781
795
|
max_calls: maxCalls,
|
|
@@ -4680,8 +4694,8 @@ async function setupReadWindowValue(context, path) {
|
|
|
4680
4694
|
return { ok: true, value: toJsonValue(current) };
|
|
4681
4695
|
}, { path });
|
|
4682
4696
|
}
|
|
4683
|
-
async function setupCallWindowFunction(context, path, args) {
|
|
4684
|
-
return await context.evaluate(async ({ path, args }) => {
|
|
4697
|
+
async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
|
|
4698
|
+
return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
|
|
4685
4699
|
const toJsonValue = (value) => {
|
|
4686
4700
|
if (value === null || value === undefined) return null;
|
|
4687
4701
|
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
@@ -4692,6 +4706,19 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
4692
4706
|
}
|
|
4693
4707
|
return String(value);
|
|
4694
4708
|
};
|
|
4709
|
+
const storeWindowReturn = (storePath, value) => {
|
|
4710
|
+
const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
4711
|
+
if (pathParts[0] === "window") pathParts.shift();
|
|
4712
|
+
if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
|
|
4713
|
+
let target = window;
|
|
4714
|
+
for (let index = 0; index < pathParts.length - 1; index += 1) {
|
|
4715
|
+
const part = pathParts[index];
|
|
4716
|
+
if (target[part] === null || typeof target[part] !== "object") target[part] = {};
|
|
4717
|
+
target = target[part];
|
|
4718
|
+
}
|
|
4719
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
4720
|
+
return { ok: true, path: pathParts.join(".") };
|
|
4721
|
+
};
|
|
4695
4722
|
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
4696
4723
|
let parent = window;
|
|
4697
4724
|
let current = window;
|
|
@@ -4702,11 +4729,18 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
4702
4729
|
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
4703
4730
|
try {
|
|
4704
4731
|
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
4705
|
-
|
|
4732
|
+
const jsonReturned = toJsonValue(returned);
|
|
4733
|
+
const returnedForResult = captureReturn === false ? undefined : jsonReturned;
|
|
4734
|
+
if (storeReturnTo) {
|
|
4735
|
+
const stored = storeWindowReturn(storeReturnTo, jsonReturned);
|
|
4736
|
+
if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
|
|
4737
|
+
return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
|
|
4738
|
+
}
|
|
4739
|
+
return { ok: true, returned: returnedForResult };
|
|
4706
4740
|
} catch (error) {
|
|
4707
4741
|
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
4708
4742
|
}
|
|
4709
|
-
}, { path, args });
|
|
4743
|
+
}, { path, args, storeReturnTo, captureReturn });
|
|
4710
4744
|
}
|
|
4711
4745
|
function setupFrameSelector(action) {
|
|
4712
4746
|
return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
|
|
@@ -5222,10 +5256,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5222
5256
|
if (type === "window_call") {
|
|
5223
5257
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
5224
5258
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
5259
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
5225
5260
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
5226
5261
|
const scope = await setupActionScope(action, timeout);
|
|
5227
5262
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
5228
|
-
const result = await setupCallWindowFunction(scope.context, path, args);
|
|
5229
5263
|
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
5230
5264
|
|| setupHasOwn(action, "expectReturn")
|
|
5231
5265
|
|| setupHasOwn(action, "expected_return")
|
|
@@ -5234,9 +5268,13 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5234
5268
|
? action.expect_return
|
|
5235
5269
|
: setupHasOwn(action, "expectReturn")
|
|
5236
5270
|
? action.expectReturn
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5271
|
+
: setupHasOwn(action, "expected_return")
|
|
5272
|
+
? action.expected_return
|
|
5273
|
+
: action.expectedReturn;
|
|
5274
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
5275
|
+
? hasExpectation
|
|
5276
|
+
: true;
|
|
5277
|
+
const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
5240
5278
|
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
5241
5279
|
return {
|
|
5242
5280
|
...base,
|
|
@@ -5244,9 +5282,12 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5244
5282
|
ok: Boolean(result.ok && expectationMet),
|
|
5245
5283
|
path,
|
|
5246
5284
|
arg_count: args.length,
|
|
5247
|
-
returned: setupJsonValue(result.returned),
|
|
5285
|
+
returned: captureReturn ? setupJsonValue(result.returned) : undefined,
|
|
5286
|
+
return_captured: captureReturn,
|
|
5248
5287
|
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
5288
|
+
return_stored_to: result.return_stored_to || storeReturnTo || undefined,
|
|
5249
5289
|
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
5290
|
+
store_reason: result.store_reason || undefined,
|
|
5250
5291
|
error: result.error || undefined,
|
|
5251
5292
|
};
|
|
5252
5293
|
}
|
|
@@ -5254,6 +5295,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5254
5295
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
5255
5296
|
const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
|
|
5256
5297
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
5298
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
5257
5299
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
5258
5300
|
if (!untilPath) return { ...base, path, reason: "missing_until_path" };
|
|
5259
5301
|
const hasUntilExpected = setupHasOwn(action, "until_expected_value")
|
|
@@ -5296,6 +5338,9 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5296
5338
|
: setupHasOwn(action, "expected_return")
|
|
5297
5339
|
? action.expected_return
|
|
5298
5340
|
: action.expectedReturn;
|
|
5341
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
5342
|
+
? hasReturnExpectation
|
|
5343
|
+
: true;
|
|
5299
5344
|
const scope = await setupActionScope(action, timeout);
|
|
5300
5345
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
5301
5346
|
const startedAt = Date.now();
|
|
@@ -5319,7 +5364,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5319
5364
|
};
|
|
5320
5365
|
}
|
|
5321
5366
|
while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
|
|
5322
|
-
lastCallResult = await setupCallWindowFunction(scope.context, path, args);
|
|
5367
|
+
lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
5323
5368
|
callCount += 1;
|
|
5324
5369
|
if (!lastCallResult.ok) break;
|
|
5325
5370
|
if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
|
|
@@ -5331,8 +5376,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5331
5376
|
ok: true,
|
|
5332
5377
|
path,
|
|
5333
5378
|
arg_count: args.length,
|
|
5334
|
-
returned: setupJsonValue(lastCallResult.returned),
|
|
5379
|
+
returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
|
|
5380
|
+
return_captured: captureReturn,
|
|
5335
5381
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
5382
|
+
return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
|
|
5336
5383
|
until_path: untilPath,
|
|
5337
5384
|
until_value: setupJsonValue(lastPredicateResult.value),
|
|
5338
5385
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -5350,8 +5397,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5350
5397
|
...setupScopeEvidence(scope),
|
|
5351
5398
|
path,
|
|
5352
5399
|
arg_count: args.length,
|
|
5353
|
-
returned: setupJsonValue(lastCallResult?.returned),
|
|
5400
|
+
returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
|
|
5401
|
+
return_captured: captureReturn,
|
|
5354
5402
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
5403
|
+
return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
|
|
5355
5404
|
until_path: untilPath,
|
|
5356
5405
|
until_value: setupJsonValue(lastPredicateResult?.value),
|
|
5357
5406
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -5367,6 +5416,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5367
5416
|
? "timeout"
|
|
5368
5417
|
: "until_condition_not_met",
|
|
5369
5418
|
error: lastCallResult?.error || undefined,
|
|
5419
|
+
store_reason: lastCallResult?.store_reason || undefined,
|
|
5370
5420
|
missing_part: lastPredicateResult?.missing_part || undefined,
|
|
5371
5421
|
};
|
|
5372
5422
|
}
|
package/dist/cli.cjs
CHANGED
|
@@ -7669,6 +7669,18 @@ function normalizeSetupAction(input, index) {
|
|
|
7669
7669
|
}
|
|
7670
7670
|
}
|
|
7671
7671
|
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
7672
|
+
const storeReturnTo = stringFromOwn(
|
|
7673
|
+
input,
|
|
7674
|
+
"store_return_to",
|
|
7675
|
+
"storeReturnTo",
|
|
7676
|
+
"save_return_to",
|
|
7677
|
+
"saveReturnTo",
|
|
7678
|
+
"assign_return_to",
|
|
7679
|
+
"assignReturnTo",
|
|
7680
|
+
"return_state_path",
|
|
7681
|
+
"returnStatePath"
|
|
7682
|
+
);
|
|
7683
|
+
const captureReturn = input.capture_return === false || input.captureReturn === false || input.include_return === false || input.includeReturn === false || input.omit_return === true || input.omitReturn === true ? false : void 0;
|
|
7672
7684
|
const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
|
|
7673
7685
|
const hasUntilExpectedValue = hasOwn(input, "until_expected_value") || hasOwn(input, "untilExpectedValue") || hasOwn(input, "until_expected") || hasOwn(input, "untilExpected") || hasOwn(input, "until_value") || hasOwn(input, "untilValue") || hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected");
|
|
7674
7686
|
if (type === "window_call_until") {
|
|
@@ -7713,6 +7725,8 @@ function normalizeSetupAction(input, index) {
|
|
|
7713
7725
|
path: path7,
|
|
7714
7726
|
args,
|
|
7715
7727
|
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
7728
|
+
store_return_to: storeReturnTo,
|
|
7729
|
+
capture_return: captureReturn,
|
|
7716
7730
|
until_path: untilPath,
|
|
7717
7731
|
until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
|
|
7718
7732
|
max_calls: maxCalls,
|
|
@@ -11601,8 +11615,8 @@ async function setupReadWindowValue(context, path) {
|
|
|
11601
11615
|
return { ok: true, value: toJsonValue(current) };
|
|
11602
11616
|
}, { path });
|
|
11603
11617
|
}
|
|
11604
|
-
async function setupCallWindowFunction(context, path, args) {
|
|
11605
|
-
return await context.evaluate(async ({ path, args }) => {
|
|
11618
|
+
async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
|
|
11619
|
+
return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
|
|
11606
11620
|
const toJsonValue = (value) => {
|
|
11607
11621
|
if (value === null || value === undefined) return null;
|
|
11608
11622
|
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
@@ -11613,6 +11627,19 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
11613
11627
|
}
|
|
11614
11628
|
return String(value);
|
|
11615
11629
|
};
|
|
11630
|
+
const storeWindowReturn = (storePath, value) => {
|
|
11631
|
+
const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
11632
|
+
if (pathParts[0] === "window") pathParts.shift();
|
|
11633
|
+
if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
|
|
11634
|
+
let target = window;
|
|
11635
|
+
for (let index = 0; index < pathParts.length - 1; index += 1) {
|
|
11636
|
+
const part = pathParts[index];
|
|
11637
|
+
if (target[part] === null || typeof target[part] !== "object") target[part] = {};
|
|
11638
|
+
target = target[part];
|
|
11639
|
+
}
|
|
11640
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
11641
|
+
return { ok: true, path: pathParts.join(".") };
|
|
11642
|
+
};
|
|
11616
11643
|
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
11617
11644
|
let parent = window;
|
|
11618
11645
|
let current = window;
|
|
@@ -11623,11 +11650,18 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
11623
11650
|
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
11624
11651
|
try {
|
|
11625
11652
|
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
11626
|
-
|
|
11653
|
+
const jsonReturned = toJsonValue(returned);
|
|
11654
|
+
const returnedForResult = captureReturn === false ? undefined : jsonReturned;
|
|
11655
|
+
if (storeReturnTo) {
|
|
11656
|
+
const stored = storeWindowReturn(storeReturnTo, jsonReturned);
|
|
11657
|
+
if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
|
|
11658
|
+
return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
|
|
11659
|
+
}
|
|
11660
|
+
return { ok: true, returned: returnedForResult };
|
|
11627
11661
|
} catch (error) {
|
|
11628
11662
|
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
11629
11663
|
}
|
|
11630
|
-
}, { path, args });
|
|
11664
|
+
}, { path, args, storeReturnTo, captureReturn });
|
|
11631
11665
|
}
|
|
11632
11666
|
function setupFrameSelector(action) {
|
|
11633
11667
|
return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
|
|
@@ -12143,10 +12177,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12143
12177
|
if (type === "window_call") {
|
|
12144
12178
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
12145
12179
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
12180
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
12146
12181
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
12147
12182
|
const scope = await setupActionScope(action, timeout);
|
|
12148
12183
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
12149
|
-
const result = await setupCallWindowFunction(scope.context, path, args);
|
|
12150
12184
|
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
12151
12185
|
|| setupHasOwn(action, "expectReturn")
|
|
12152
12186
|
|| setupHasOwn(action, "expected_return")
|
|
@@ -12155,9 +12189,13 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12155
12189
|
? action.expect_return
|
|
12156
12190
|
: setupHasOwn(action, "expectReturn")
|
|
12157
12191
|
? action.expectReturn
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12192
|
+
: setupHasOwn(action, "expected_return")
|
|
12193
|
+
? action.expected_return
|
|
12194
|
+
: action.expectedReturn;
|
|
12195
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
12196
|
+
? hasExpectation
|
|
12197
|
+
: true;
|
|
12198
|
+
const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
12161
12199
|
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
12162
12200
|
return {
|
|
12163
12201
|
...base,
|
|
@@ -12165,9 +12203,12 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12165
12203
|
ok: Boolean(result.ok && expectationMet),
|
|
12166
12204
|
path,
|
|
12167
12205
|
arg_count: args.length,
|
|
12168
|
-
returned: setupJsonValue(result.returned),
|
|
12206
|
+
returned: captureReturn ? setupJsonValue(result.returned) : undefined,
|
|
12207
|
+
return_captured: captureReturn,
|
|
12169
12208
|
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
12209
|
+
return_stored_to: result.return_stored_to || storeReturnTo || undefined,
|
|
12170
12210
|
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
12211
|
+
store_reason: result.store_reason || undefined,
|
|
12171
12212
|
error: result.error || undefined,
|
|
12172
12213
|
};
|
|
12173
12214
|
}
|
|
@@ -12175,6 +12216,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12175
12216
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
12176
12217
|
const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
|
|
12177
12218
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
12219
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
12178
12220
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
12179
12221
|
if (!untilPath) return { ...base, path, reason: "missing_until_path" };
|
|
12180
12222
|
const hasUntilExpected = setupHasOwn(action, "until_expected_value")
|
|
@@ -12217,6 +12259,9 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12217
12259
|
: setupHasOwn(action, "expected_return")
|
|
12218
12260
|
? action.expected_return
|
|
12219
12261
|
: action.expectedReturn;
|
|
12262
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
12263
|
+
? hasReturnExpectation
|
|
12264
|
+
: true;
|
|
12220
12265
|
const scope = await setupActionScope(action, timeout);
|
|
12221
12266
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
12222
12267
|
const startedAt = Date.now();
|
|
@@ -12240,7 +12285,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12240
12285
|
};
|
|
12241
12286
|
}
|
|
12242
12287
|
while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
|
|
12243
|
-
lastCallResult = await setupCallWindowFunction(scope.context, path, args);
|
|
12288
|
+
lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
12244
12289
|
callCount += 1;
|
|
12245
12290
|
if (!lastCallResult.ok) break;
|
|
12246
12291
|
if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
|
|
@@ -12252,8 +12297,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12252
12297
|
ok: true,
|
|
12253
12298
|
path,
|
|
12254
12299
|
arg_count: args.length,
|
|
12255
|
-
returned: setupJsonValue(lastCallResult.returned),
|
|
12300
|
+
returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
|
|
12301
|
+
return_captured: captureReturn,
|
|
12256
12302
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
12303
|
+
return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
|
|
12257
12304
|
until_path: untilPath,
|
|
12258
12305
|
until_value: setupJsonValue(lastPredicateResult.value),
|
|
12259
12306
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -12271,8 +12318,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12271
12318
|
...setupScopeEvidence(scope),
|
|
12272
12319
|
path,
|
|
12273
12320
|
arg_count: args.length,
|
|
12274
|
-
returned: setupJsonValue(lastCallResult?.returned),
|
|
12321
|
+
returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
|
|
12322
|
+
return_captured: captureReturn,
|
|
12275
12323
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
12324
|
+
return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
|
|
12276
12325
|
until_path: untilPath,
|
|
12277
12326
|
until_value: setupJsonValue(lastPredicateResult?.value),
|
|
12278
12327
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -12288,6 +12337,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
12288
12337
|
? "timeout"
|
|
12289
12338
|
: "until_condition_not_met",
|
|
12290
12339
|
error: lastCallResult?.error || undefined,
|
|
12340
|
+
store_reason: lastCallResult?.store_reason || undefined,
|
|
12291
12341
|
missing_part: lastPredicateResult?.missing_part || undefined,
|
|
12292
12342
|
};
|
|
12293
12343
|
}
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -9465,6 +9465,18 @@ function normalizeSetupAction(input, index) {
|
|
|
9465
9465
|
}
|
|
9466
9466
|
}
|
|
9467
9467
|
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
9468
|
+
const storeReturnTo = stringFromOwn(
|
|
9469
|
+
input,
|
|
9470
|
+
"store_return_to",
|
|
9471
|
+
"storeReturnTo",
|
|
9472
|
+
"save_return_to",
|
|
9473
|
+
"saveReturnTo",
|
|
9474
|
+
"assign_return_to",
|
|
9475
|
+
"assignReturnTo",
|
|
9476
|
+
"return_state_path",
|
|
9477
|
+
"returnStatePath"
|
|
9478
|
+
);
|
|
9479
|
+
const captureReturn = input.capture_return === false || input.captureReturn === false || input.include_return === false || input.includeReturn === false || input.omit_return === true || input.omitReturn === true ? false : void 0;
|
|
9468
9480
|
const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
|
|
9469
9481
|
const hasUntilExpectedValue = hasOwn(input, "until_expected_value") || hasOwn(input, "untilExpectedValue") || hasOwn(input, "until_expected") || hasOwn(input, "untilExpected") || hasOwn(input, "until_value") || hasOwn(input, "untilValue") || hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected");
|
|
9470
9482
|
if (type === "window_call_until") {
|
|
@@ -9509,6 +9521,8 @@ function normalizeSetupAction(input, index) {
|
|
|
9509
9521
|
path: path6,
|
|
9510
9522
|
args,
|
|
9511
9523
|
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
9524
|
+
store_return_to: storeReturnTo,
|
|
9525
|
+
capture_return: captureReturn,
|
|
9512
9526
|
until_path: untilPath,
|
|
9513
9527
|
until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
|
|
9514
9528
|
max_calls: maxCalls,
|
|
@@ -13413,8 +13427,8 @@ async function setupReadWindowValue(context, path) {
|
|
|
13413
13427
|
return { ok: true, value: toJsonValue(current) };
|
|
13414
13428
|
}, { path });
|
|
13415
13429
|
}
|
|
13416
|
-
async function setupCallWindowFunction(context, path, args) {
|
|
13417
|
-
return await context.evaluate(async ({ path, args }) => {
|
|
13430
|
+
async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
|
|
13431
|
+
return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
|
|
13418
13432
|
const toJsonValue = (value) => {
|
|
13419
13433
|
if (value === null || value === undefined) return null;
|
|
13420
13434
|
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
@@ -13425,6 +13439,19 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
13425
13439
|
}
|
|
13426
13440
|
return String(value);
|
|
13427
13441
|
};
|
|
13442
|
+
const storeWindowReturn = (storePath, value) => {
|
|
13443
|
+
const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
13444
|
+
if (pathParts[0] === "window") pathParts.shift();
|
|
13445
|
+
if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
|
|
13446
|
+
let target = window;
|
|
13447
|
+
for (let index = 0; index < pathParts.length - 1; index += 1) {
|
|
13448
|
+
const part = pathParts[index];
|
|
13449
|
+
if (target[part] === null || typeof target[part] !== "object") target[part] = {};
|
|
13450
|
+
target = target[part];
|
|
13451
|
+
}
|
|
13452
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
13453
|
+
return { ok: true, path: pathParts.join(".") };
|
|
13454
|
+
};
|
|
13428
13455
|
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
13429
13456
|
let parent = window;
|
|
13430
13457
|
let current = window;
|
|
@@ -13435,11 +13462,18 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
13435
13462
|
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
13436
13463
|
try {
|
|
13437
13464
|
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
13438
|
-
|
|
13465
|
+
const jsonReturned = toJsonValue(returned);
|
|
13466
|
+
const returnedForResult = captureReturn === false ? undefined : jsonReturned;
|
|
13467
|
+
if (storeReturnTo) {
|
|
13468
|
+
const stored = storeWindowReturn(storeReturnTo, jsonReturned);
|
|
13469
|
+
if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
|
|
13470
|
+
return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
|
|
13471
|
+
}
|
|
13472
|
+
return { ok: true, returned: returnedForResult };
|
|
13439
13473
|
} catch (error) {
|
|
13440
13474
|
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
13441
13475
|
}
|
|
13442
|
-
}, { path, args });
|
|
13476
|
+
}, { path, args, storeReturnTo, captureReturn });
|
|
13443
13477
|
}
|
|
13444
13478
|
function setupFrameSelector(action) {
|
|
13445
13479
|
return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
|
|
@@ -13955,10 +13989,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
13955
13989
|
if (type === "window_call") {
|
|
13956
13990
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
13957
13991
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
13992
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
13958
13993
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
13959
13994
|
const scope = await setupActionScope(action, timeout);
|
|
13960
13995
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
13961
|
-
const result = await setupCallWindowFunction(scope.context, path, args);
|
|
13962
13996
|
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
13963
13997
|
|| setupHasOwn(action, "expectReturn")
|
|
13964
13998
|
|| setupHasOwn(action, "expected_return")
|
|
@@ -13967,9 +14001,13 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
13967
14001
|
? action.expect_return
|
|
13968
14002
|
: setupHasOwn(action, "expectReturn")
|
|
13969
14003
|
? action.expectReturn
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
14004
|
+
: setupHasOwn(action, "expected_return")
|
|
14005
|
+
? action.expected_return
|
|
14006
|
+
: action.expectedReturn;
|
|
14007
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
14008
|
+
? hasExpectation
|
|
14009
|
+
: true;
|
|
14010
|
+
const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
13973
14011
|
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
13974
14012
|
return {
|
|
13975
14013
|
...base,
|
|
@@ -13977,9 +14015,12 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
13977
14015
|
ok: Boolean(result.ok && expectationMet),
|
|
13978
14016
|
path,
|
|
13979
14017
|
arg_count: args.length,
|
|
13980
|
-
returned: setupJsonValue(result.returned),
|
|
14018
|
+
returned: captureReturn ? setupJsonValue(result.returned) : undefined,
|
|
14019
|
+
return_captured: captureReturn,
|
|
13981
14020
|
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
14021
|
+
return_stored_to: result.return_stored_to || storeReturnTo || undefined,
|
|
13982
14022
|
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
14023
|
+
store_reason: result.store_reason || undefined,
|
|
13983
14024
|
error: result.error || undefined,
|
|
13984
14025
|
};
|
|
13985
14026
|
}
|
|
@@ -13987,6 +14028,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
13987
14028
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
13988
14029
|
const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
|
|
13989
14030
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
14031
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
13990
14032
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
13991
14033
|
if (!untilPath) return { ...base, path, reason: "missing_until_path" };
|
|
13992
14034
|
const hasUntilExpected = setupHasOwn(action, "until_expected_value")
|
|
@@ -14029,6 +14071,9 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14029
14071
|
: setupHasOwn(action, "expected_return")
|
|
14030
14072
|
? action.expected_return
|
|
14031
14073
|
: action.expectedReturn;
|
|
14074
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
14075
|
+
? hasReturnExpectation
|
|
14076
|
+
: true;
|
|
14032
14077
|
const scope = await setupActionScope(action, timeout);
|
|
14033
14078
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
14034
14079
|
const startedAt = Date.now();
|
|
@@ -14052,7 +14097,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14052
14097
|
};
|
|
14053
14098
|
}
|
|
14054
14099
|
while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
|
|
14055
|
-
lastCallResult = await setupCallWindowFunction(scope.context, path, args);
|
|
14100
|
+
lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
14056
14101
|
callCount += 1;
|
|
14057
14102
|
if (!lastCallResult.ok) break;
|
|
14058
14103
|
if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
|
|
@@ -14064,8 +14109,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14064
14109
|
ok: true,
|
|
14065
14110
|
path,
|
|
14066
14111
|
arg_count: args.length,
|
|
14067
|
-
returned: setupJsonValue(lastCallResult.returned),
|
|
14112
|
+
returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
|
|
14113
|
+
return_captured: captureReturn,
|
|
14068
14114
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
14115
|
+
return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
|
|
14069
14116
|
until_path: untilPath,
|
|
14070
14117
|
until_value: setupJsonValue(lastPredicateResult.value),
|
|
14071
14118
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -14083,8 +14130,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14083
14130
|
...setupScopeEvidence(scope),
|
|
14084
14131
|
path,
|
|
14085
14132
|
arg_count: args.length,
|
|
14086
|
-
returned: setupJsonValue(lastCallResult?.returned),
|
|
14133
|
+
returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
|
|
14134
|
+
return_captured: captureReturn,
|
|
14087
14135
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
14136
|
+
return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
|
|
14088
14137
|
until_path: untilPath,
|
|
14089
14138
|
until_value: setupJsonValue(lastPredicateResult?.value),
|
|
14090
14139
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -14100,6 +14149,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14100
14149
|
? "timeout"
|
|
14101
14150
|
: "until_condition_not_met",
|
|
14102
14151
|
error: lastCallResult?.error || undefined,
|
|
14152
|
+
store_reason: lastCallResult?.store_reason || undefined,
|
|
14103
14153
|
missing_part: lastPredicateResult?.missing_part || undefined,
|
|
14104
14154
|
};
|
|
14105
14155
|
}
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
resolveRiddleProofProfileTimeoutSec,
|
|
63
63
|
slugifyRiddleProofProfileName,
|
|
64
64
|
summarizeRiddleProofProfileResult
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-DNSJMFK6.js";
|
|
66
66
|
import {
|
|
67
67
|
DEFAULT_RIDDLE_API_BASE_URL,
|
|
68
68
|
DEFAULT_RIDDLE_API_KEY_FILE,
|
package/dist/profile.cjs
CHANGED
|
@@ -779,6 +779,18 @@ function normalizeSetupAction(input, index) {
|
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
781
|
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
782
|
+
const storeReturnTo = stringFromOwn(
|
|
783
|
+
input,
|
|
784
|
+
"store_return_to",
|
|
785
|
+
"storeReturnTo",
|
|
786
|
+
"save_return_to",
|
|
787
|
+
"saveReturnTo",
|
|
788
|
+
"assign_return_to",
|
|
789
|
+
"assignReturnTo",
|
|
790
|
+
"return_state_path",
|
|
791
|
+
"returnStatePath"
|
|
792
|
+
);
|
|
793
|
+
const captureReturn = input.capture_return === false || input.captureReturn === false || input.include_return === false || input.includeReturn === false || input.omit_return === true || input.omitReturn === true ? false : void 0;
|
|
782
794
|
const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
|
|
783
795
|
const hasUntilExpectedValue = hasOwn(input, "until_expected_value") || hasOwn(input, "untilExpectedValue") || hasOwn(input, "until_expected") || hasOwn(input, "untilExpected") || hasOwn(input, "until_value") || hasOwn(input, "untilValue") || hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected");
|
|
784
796
|
if (type === "window_call_until") {
|
|
@@ -823,6 +835,8 @@ function normalizeSetupAction(input, index) {
|
|
|
823
835
|
path,
|
|
824
836
|
args,
|
|
825
837
|
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
838
|
+
store_return_to: storeReturnTo,
|
|
839
|
+
capture_return: captureReturn,
|
|
826
840
|
until_path: untilPath,
|
|
827
841
|
until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
|
|
828
842
|
max_calls: maxCalls,
|
|
@@ -4727,8 +4741,8 @@ async function setupReadWindowValue(context, path) {
|
|
|
4727
4741
|
return { ok: true, value: toJsonValue(current) };
|
|
4728
4742
|
}, { path });
|
|
4729
4743
|
}
|
|
4730
|
-
async function setupCallWindowFunction(context, path, args) {
|
|
4731
|
-
return await context.evaluate(async ({ path, args }) => {
|
|
4744
|
+
async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
|
|
4745
|
+
return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
|
|
4732
4746
|
const toJsonValue = (value) => {
|
|
4733
4747
|
if (value === null || value === undefined) return null;
|
|
4734
4748
|
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
@@ -4739,6 +4753,19 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
4739
4753
|
}
|
|
4740
4754
|
return String(value);
|
|
4741
4755
|
};
|
|
4756
|
+
const storeWindowReturn = (storePath, value) => {
|
|
4757
|
+
const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
4758
|
+
if (pathParts[0] === "window") pathParts.shift();
|
|
4759
|
+
if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
|
|
4760
|
+
let target = window;
|
|
4761
|
+
for (let index = 0; index < pathParts.length - 1; index += 1) {
|
|
4762
|
+
const part = pathParts[index];
|
|
4763
|
+
if (target[part] === null || typeof target[part] !== "object") target[part] = {};
|
|
4764
|
+
target = target[part];
|
|
4765
|
+
}
|
|
4766
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
4767
|
+
return { ok: true, path: pathParts.join(".") };
|
|
4768
|
+
};
|
|
4742
4769
|
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
4743
4770
|
let parent = window;
|
|
4744
4771
|
let current = window;
|
|
@@ -4749,11 +4776,18 @@ async function setupCallWindowFunction(context, path, args) {
|
|
|
4749
4776
|
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
4750
4777
|
try {
|
|
4751
4778
|
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
4752
|
-
|
|
4779
|
+
const jsonReturned = toJsonValue(returned);
|
|
4780
|
+
const returnedForResult = captureReturn === false ? undefined : jsonReturned;
|
|
4781
|
+
if (storeReturnTo) {
|
|
4782
|
+
const stored = storeWindowReturn(storeReturnTo, jsonReturned);
|
|
4783
|
+
if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
|
|
4784
|
+
return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
|
|
4785
|
+
}
|
|
4786
|
+
return { ok: true, returned: returnedForResult };
|
|
4753
4787
|
} catch (error) {
|
|
4754
4788
|
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
4755
4789
|
}
|
|
4756
|
-
}, { path, args });
|
|
4790
|
+
}, { path, args, storeReturnTo, captureReturn });
|
|
4757
4791
|
}
|
|
4758
4792
|
function setupFrameSelector(action) {
|
|
4759
4793
|
return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
|
|
@@ -5269,10 +5303,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5269
5303
|
if (type === "window_call") {
|
|
5270
5304
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
5271
5305
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
5306
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
5272
5307
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
5273
5308
|
const scope = await setupActionScope(action, timeout);
|
|
5274
5309
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
5275
|
-
const result = await setupCallWindowFunction(scope.context, path, args);
|
|
5276
5310
|
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
5277
5311
|
|| setupHasOwn(action, "expectReturn")
|
|
5278
5312
|
|| setupHasOwn(action, "expected_return")
|
|
@@ -5281,9 +5315,13 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5281
5315
|
? action.expect_return
|
|
5282
5316
|
: setupHasOwn(action, "expectReturn")
|
|
5283
5317
|
? action.expectReturn
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5318
|
+
: setupHasOwn(action, "expected_return")
|
|
5319
|
+
? action.expected_return
|
|
5320
|
+
: action.expectedReturn;
|
|
5321
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
5322
|
+
? hasExpectation
|
|
5323
|
+
: true;
|
|
5324
|
+
const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
5287
5325
|
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
5288
5326
|
return {
|
|
5289
5327
|
...base,
|
|
@@ -5291,9 +5329,12 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5291
5329
|
ok: Boolean(result.ok && expectationMet),
|
|
5292
5330
|
path,
|
|
5293
5331
|
arg_count: args.length,
|
|
5294
|
-
returned: setupJsonValue(result.returned),
|
|
5332
|
+
returned: captureReturn ? setupJsonValue(result.returned) : undefined,
|
|
5333
|
+
return_captured: captureReturn,
|
|
5295
5334
|
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
5335
|
+
return_stored_to: result.return_stored_to || storeReturnTo || undefined,
|
|
5296
5336
|
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
5337
|
+
store_reason: result.store_reason || undefined,
|
|
5297
5338
|
error: result.error || undefined,
|
|
5298
5339
|
};
|
|
5299
5340
|
}
|
|
@@ -5301,6 +5342,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5301
5342
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
5302
5343
|
const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
|
|
5303
5344
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
5345
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
5304
5346
|
if (!path) return { ...base, path, reason: "missing_path" };
|
|
5305
5347
|
if (!untilPath) return { ...base, path, reason: "missing_until_path" };
|
|
5306
5348
|
const hasUntilExpected = setupHasOwn(action, "until_expected_value")
|
|
@@ -5343,6 +5385,9 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5343
5385
|
: setupHasOwn(action, "expected_return")
|
|
5344
5386
|
? action.expected_return
|
|
5345
5387
|
: action.expectedReturn;
|
|
5388
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
5389
|
+
? hasReturnExpectation
|
|
5390
|
+
: true;
|
|
5346
5391
|
const scope = await setupActionScope(action, timeout);
|
|
5347
5392
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
5348
5393
|
const startedAt = Date.now();
|
|
@@ -5366,7 +5411,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5366
5411
|
};
|
|
5367
5412
|
}
|
|
5368
5413
|
while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
|
|
5369
|
-
lastCallResult = await setupCallWindowFunction(scope.context, path, args);
|
|
5414
|
+
lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
|
|
5370
5415
|
callCount += 1;
|
|
5371
5416
|
if (!lastCallResult.ok) break;
|
|
5372
5417
|
if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
|
|
@@ -5378,8 +5423,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5378
5423
|
ok: true,
|
|
5379
5424
|
path,
|
|
5380
5425
|
arg_count: args.length,
|
|
5381
|
-
returned: setupJsonValue(lastCallResult.returned),
|
|
5426
|
+
returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
|
|
5427
|
+
return_captured: captureReturn,
|
|
5382
5428
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
5429
|
+
return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
|
|
5383
5430
|
until_path: untilPath,
|
|
5384
5431
|
until_value: setupJsonValue(lastPredicateResult.value),
|
|
5385
5432
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -5397,8 +5444,10 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5397
5444
|
...setupScopeEvidence(scope),
|
|
5398
5445
|
path,
|
|
5399
5446
|
arg_count: args.length,
|
|
5400
|
-
returned: setupJsonValue(lastCallResult?.returned),
|
|
5447
|
+
returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
|
|
5448
|
+
return_captured: captureReturn,
|
|
5401
5449
|
expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
|
|
5450
|
+
return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
|
|
5402
5451
|
until_path: untilPath,
|
|
5403
5452
|
until_value: setupJsonValue(lastPredicateResult?.value),
|
|
5404
5453
|
until_expected_value: setupJsonValue(untilExpected),
|
|
@@ -5414,6 +5463,7 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5414
5463
|
? "timeout"
|
|
5415
5464
|
: "until_condition_not_met",
|
|
5416
5465
|
error: lastCallResult?.error || undefined,
|
|
5466
|
+
store_reason: lastCallResult?.store_reason || undefined,
|
|
5417
5467
|
missing_part: lastPredicateResult?.missing_part || undefined,
|
|
5418
5468
|
};
|
|
5419
5469
|
}
|
package/dist/profile.d.cts
CHANGED
|
@@ -129,6 +129,8 @@ interface RiddleProofProfileSetupAction {
|
|
|
129
129
|
path?: string;
|
|
130
130
|
args?: JsonValue[];
|
|
131
131
|
expect_return?: JsonValue;
|
|
132
|
+
store_return_to?: string;
|
|
133
|
+
capture_return?: boolean;
|
|
132
134
|
until_path?: string;
|
|
133
135
|
until_expected_value?: JsonValue;
|
|
134
136
|
max_calls?: number;
|
package/dist/profile.d.ts
CHANGED
|
@@ -129,6 +129,8 @@ interface RiddleProofProfileSetupAction {
|
|
|
129
129
|
path?: string;
|
|
130
130
|
args?: JsonValue[];
|
|
131
131
|
expect_return?: JsonValue;
|
|
132
|
+
store_return_to?: string;
|
|
133
|
+
capture_return?: boolean;
|
|
132
134
|
until_path?: string;
|
|
133
135
|
until_expected_value?: JsonValue;
|
|
134
136
|
max_calls?: number;
|
package/dist/profile.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
resolveRiddleProofProfileTimeoutSec,
|
|
24
24
|
slugifyRiddleProofProfileName,
|
|
25
25
|
summarizeRiddleProofProfileResult
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-DNSJMFK6.js";
|
|
27
27
|
export {
|
|
28
28
|
RIDDLE_PROOF_PROFILE_CHECK_TYPES,
|
|
29
29
|
RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
|