@riddledc/riddle-proof 0.7.172 → 0.7.174
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 +7 -1
- package/dist/{chunk-5ELOMJ7U.js → chunk-BD4RHTGW.js} +179 -39
- package/dist/cli.cjs +206 -40
- package/dist/cli.js +28 -2
- package/dist/index.cjs +179 -39
- package/dist/index.js +1 -1
- package/dist/profile.cjs +179 -39
- package/dist/profile.d.cts +1 -1
- package/dist/profile.d.ts +1 -1
- package/dist/profile.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8777,6 +8777,7 @@ var RIDDLE_PROOF_PROFILE_CHECK_TYPES = [
|
|
|
8777
8777
|
];
|
|
8778
8778
|
var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
8779
8779
|
"click",
|
|
8780
|
+
"tap",
|
|
8780
8781
|
"drag",
|
|
8781
8782
|
"press",
|
|
8782
8783
|
"fill",
|
|
@@ -9328,6 +9329,21 @@ function profileSetupDragReceipts(results) {
|
|
|
9328
9329
|
reason: result.reason ?? result.error ?? null
|
|
9329
9330
|
}));
|
|
9330
9331
|
}
|
|
9332
|
+
function profileSetupTapReceipts(results) {
|
|
9333
|
+
return results.filter((result) => profileSetupResultAction(result) === "tap").map((result) => ({
|
|
9334
|
+
ordinal: result.ordinal ?? null,
|
|
9335
|
+
ok: result.ok !== false,
|
|
9336
|
+
selector: result.selector ?? null,
|
|
9337
|
+
frame_selector: result.frame_selector ?? null,
|
|
9338
|
+
pointer_type: result.pointer_type ?? null,
|
|
9339
|
+
input_dispatch: result.input_dispatch ?? null,
|
|
9340
|
+
coordinate_mode: result.coordinate_mode ?? null,
|
|
9341
|
+
x: result.x ?? null,
|
|
9342
|
+
y: result.y ?? null,
|
|
9343
|
+
duration_ms: result.duration_ms ?? null,
|
|
9344
|
+
reason: result.reason ?? result.error ?? null
|
|
9345
|
+
}));
|
|
9346
|
+
}
|
|
9331
9347
|
function profileSetupCanvasSignatureReceipts(results) {
|
|
9332
9348
|
return results.filter((result) => profileSetupResultAction(result) === "canvas_signature").map((result) => ({
|
|
9333
9349
|
ordinal: result.ordinal ?? null,
|
|
@@ -9365,21 +9381,28 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
|
|
|
9365
9381
|
}
|
|
9366
9382
|
const warnings = [];
|
|
9367
9383
|
for (const group of groups.values()) {
|
|
9368
|
-
const
|
|
9369
|
-
const
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9384
|
+
const receiptsByHash = /* @__PURE__ */ new Map();
|
|
9385
|
+
for (const receipt of group.receipts) {
|
|
9386
|
+
const hashReceipts = receiptsByHash.get(receipt.hash) || [];
|
|
9387
|
+
hashReceipts.push(receipt);
|
|
9388
|
+
receiptsByHash.set(receipt.hash, hashReceipts);
|
|
9389
|
+
}
|
|
9390
|
+
for (const [hash, receipts] of receiptsByHash.entries()) {
|
|
9391
|
+
const labels = [...new Set(receipts.map((receipt) => receipt.label))];
|
|
9392
|
+
if (receipts.length < 2 || labels.length < 2) continue;
|
|
9393
|
+
const visibleLabels = labels.slice(0, 8);
|
|
9394
|
+
warnings.push({
|
|
9395
|
+
selector: group.selector,
|
|
9396
|
+
frame_selector: group.frame_selector ?? null,
|
|
9397
|
+
hash,
|
|
9398
|
+
count: receipts.length,
|
|
9399
|
+
label_count: labels.length,
|
|
9400
|
+
labels: visibleLabels,
|
|
9401
|
+
omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
|
|
9402
|
+
ordinals: receipts.map((receipt) => receipt.ordinal).filter((value) => value !== void 0).slice(0, 12),
|
|
9403
|
+
reason: "stable_canvas_signature_hash"
|
|
9404
|
+
});
|
|
9405
|
+
}
|
|
9383
9406
|
}
|
|
9384
9407
|
return warnings;
|
|
9385
9408
|
}
|
|
@@ -9482,6 +9505,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
9482
9505
|
const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
|
|
9483
9506
|
const dragReceipts = profileSetupDragReceipts(results);
|
|
9484
9507
|
const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
|
|
9508
|
+
const tapReceipts = profileSetupTapReceipts(results);
|
|
9509
|
+
const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
|
|
9485
9510
|
const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
|
|
9486
9511
|
const sampledCanvasSignatureReceipts = sampleProfileSetupSummaryItems(canvasSignatureReceipts, 8);
|
|
9487
9512
|
const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
|
|
@@ -9546,6 +9571,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
9546
9571
|
drag_total: dragReceipts.length,
|
|
9547
9572
|
drag_truncated: dragReceipts.length > sampledDragReceipts.length,
|
|
9548
9573
|
drag: sampledDragReceipts,
|
|
9574
|
+
tap_total: tapReceipts.length,
|
|
9575
|
+
tap_truncated: tapReceipts.length > sampledTapReceipts.length,
|
|
9576
|
+
tap: sampledTapReceipts,
|
|
9549
9577
|
canvas_signature_total: canvasSignatureReceipts.length,
|
|
9550
9578
|
canvas_signature_truncated: canvasSignatureReceipts.length > sampledCanvasSignatureReceipts.length,
|
|
9551
9579
|
canvas_signature: sampledCanvasSignatureReceipts,
|
|
@@ -9602,7 +9630,7 @@ function isSupportedCheckType(value) {
|
|
|
9602
9630
|
}
|
|
9603
9631
|
function normalizeSetupActionType(value, index) {
|
|
9604
9632
|
const normalizedInput = String(value || "").trim().replace(/-/g, "_");
|
|
9605
|
-
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "deterministic_runtime" || normalizedInput === "mock_runtime" || normalizedInput === "mock_random" || normalizedInput === "mock_random_queue" || normalizedInput === "seed_random_queue" || normalizedInput === "set_random_queue" || normalizedInput === "mock_clock" || normalizedInput === "set_mock_clock" || normalizedInput === "set_runtime_determinism" || normalizedInput === "runtime_determinism" ? "deterministic_runtime" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
|
|
9633
|
+
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "pointer_tap" || normalizedInput === "touch_tap" || normalizedInput === "canvas_tap" ? "tap" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "deterministic_runtime" || normalizedInput === "mock_runtime" || normalizedInput === "mock_random" || normalizedInput === "mock_random_queue" || normalizedInput === "seed_random_queue" || normalizedInput === "set_random_queue" || normalizedInput === "mock_clock" || normalizedInput === "set_mock_clock" || normalizedInput === "set_runtime_determinism" || normalizedInput === "runtime_determinism" ? "deterministic_runtime" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
|
|
9606
9634
|
if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
|
|
9607
9635
|
return normalized;
|
|
9608
9636
|
}
|
|
@@ -9684,8 +9712,8 @@ function normalizeSetupActionCoordinateMode(value, index) {
|
|
|
9684
9712
|
}
|
|
9685
9713
|
function normalizeSetupActionPointerType(value, type, index) {
|
|
9686
9714
|
if (value === void 0 || value === null || value === "") return void 0;
|
|
9687
|
-
if (type !== "drag") {
|
|
9688
|
-
throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag actions.`);
|
|
9715
|
+
if (type !== "drag" && type !== "tap") {
|
|
9716
|
+
throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag/tap actions.`);
|
|
9689
9717
|
}
|
|
9690
9718
|
const normalized = String(value).trim().replace(/-/g, "_").toLowerCase();
|
|
9691
9719
|
if (normalized === "mouse") return "mouse";
|
|
@@ -9764,11 +9792,11 @@ function normalizeSetupAction(input, index) {
|
|
|
9764
9792
|
if (frameIndex !== void 0 && (!Number.isInteger(frameIndex) || frameIndex < 0)) {
|
|
9765
9793
|
throw new Error(`target.setup_actions[${index}].frame_index must be a non-negative integer.`);
|
|
9766
9794
|
}
|
|
9767
|
-
if ((type === "click" || type === "drag" || type === "fill" || type === "set_input_value" || type === "set_range_value" || type === "canvas_signature" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
|
|
9795
|
+
if ((type === "click" || type === "tap" || type === "drag" || type === "fill" || type === "set_input_value" || type === "set_range_value" || type === "canvas_signature" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
|
|
9768
9796
|
throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
|
|
9769
9797
|
}
|
|
9770
|
-
const fromX = type === "click" ? numberValue3(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue3(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
|
|
9771
|
-
const fromY = type === "click" ? numberValue3(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue3(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
|
|
9798
|
+
const fromX = type === "click" || type === "tap" ? numberValue3(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue3(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
|
|
9799
|
+
const fromY = type === "click" || type === "tap" ? numberValue3(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue3(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
|
|
9772
9800
|
const toX = numberValue3(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
|
|
9773
9801
|
const toY = numberValue3(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
|
|
9774
9802
|
const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
|
|
@@ -9788,6 +9816,21 @@ function normalizeSetupAction(input, index) {
|
|
|
9788
9816
|
}
|
|
9789
9817
|
}
|
|
9790
9818
|
}
|
|
9819
|
+
if (type === "tap") {
|
|
9820
|
+
const hasTapCoordinate = fromX !== void 0 || fromY !== void 0;
|
|
9821
|
+
if (hasTapCoordinate && (fromX === void 0 || fromY === void 0)) {
|
|
9822
|
+
throw new Error(`target.setup_actions[${index}] tap coordinates require both x and y.`);
|
|
9823
|
+
}
|
|
9824
|
+
if (hasTapCoordinate && fromX !== void 0 && fromY !== void 0) {
|
|
9825
|
+
const tapCoordinates = [fromX, fromY];
|
|
9826
|
+
if (coordinateMode === "ratio" && tapCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
|
|
9827
|
+
throw new Error(`target.setup_actions[${index}] tap ratio coordinates must be between 0 and 1.`);
|
|
9828
|
+
}
|
|
9829
|
+
if ((coordinateMode === void 0 || coordinateMode === "pixels") && tapCoordinates.some((value2) => value2 < 0)) {
|
|
9830
|
+
throw new Error(`target.setup_actions[${index}] tap pixel coordinates must be non-negative.`);
|
|
9831
|
+
}
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9791
9834
|
if (type === "drag") {
|
|
9792
9835
|
if (fromX === void 0 || fromY === void 0 || toX === void 0 || toY === void 0) {
|
|
9793
9836
|
throw new Error(`target.setup_actions[${index}] drag requires from_x, from_y, to_x, and to_y.`);
|
|
@@ -13142,24 +13185,31 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
|
|
|
13142
13185
|
}
|
|
13143
13186
|
const warnings = [];
|
|
13144
13187
|
for (const group of groups.values()) {
|
|
13145
|
-
const
|
|
13146
|
-
const
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
|
|
13159
|
-
.
|
|
13160
|
-
.
|
|
13161
|
-
|
|
13162
|
-
|
|
13188
|
+
const receiptsByHash = new Map();
|
|
13189
|
+
for (const receipt of group.receipts) {
|
|
13190
|
+
const hashReceipts = receiptsByHash.get(receipt.hash) || [];
|
|
13191
|
+
hashReceipts.push(receipt);
|
|
13192
|
+
receiptsByHash.set(receipt.hash, hashReceipts);
|
|
13193
|
+
}
|
|
13194
|
+
for (const [hash, receipts] of receiptsByHash.entries()) {
|
|
13195
|
+
const labels = [...new Set(receipts.map((receipt) => receipt.label))];
|
|
13196
|
+
if (receipts.length < 2 || labels.length < 2) continue;
|
|
13197
|
+
const visibleLabels = labels.slice(0, 8);
|
|
13198
|
+
warnings.push({
|
|
13199
|
+
selector: group.selector,
|
|
13200
|
+
frame_selector: group.frame_selector || null,
|
|
13201
|
+
hash,
|
|
13202
|
+
count: receipts.length,
|
|
13203
|
+
label_count: labels.length,
|
|
13204
|
+
labels: visibleLabels,
|
|
13205
|
+
omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
|
|
13206
|
+
ordinals: receipts
|
|
13207
|
+
.map((receipt) => receipt.ordinal)
|
|
13208
|
+
.filter((value) => value !== undefined)
|
|
13209
|
+
.slice(0, 12),
|
|
13210
|
+
reason: "stable_canvas_signature_hash",
|
|
13211
|
+
});
|
|
13212
|
+
}
|
|
13163
13213
|
}
|
|
13164
13214
|
return warnings;
|
|
13165
13215
|
}
|
|
@@ -14776,6 +14826,96 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14776
14826
|
await waitForAnyVisibleSelector(scope.context, action.selector, timeout);
|
|
14777
14827
|
return { ...base, ...setupScopeEvidence(scope), ok: true, timeout_ms: timeout };
|
|
14778
14828
|
}
|
|
14829
|
+
if (type === "tap") {
|
|
14830
|
+
const scope = await setupActionScope(action, timeout);
|
|
14831
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
14832
|
+
const locator = scope.context.locator(action.selector);
|
|
14833
|
+
const count = await locator.count();
|
|
14834
|
+
if (!count) return { ...base, ...setupScopeEvidence(scope), reason: "selector_not_found", count };
|
|
14835
|
+
const targetIndex = Number.isInteger(action.index) ? action.index : 0;
|
|
14836
|
+
if (targetIndex < 0 || targetIndex >= count) return { ...base, ...setupScopeEvidence(scope), reason: "index_out_of_range", count, target_index: targetIndex };
|
|
14837
|
+
const target = locator.nth(targetIndex);
|
|
14838
|
+
await target.waitFor({ state: "visible", timeout });
|
|
14839
|
+
const box = await target.boundingBox();
|
|
14840
|
+
if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
|
|
14841
|
+
const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
|
|
14842
|
+
const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
|
|
14843
|
+
const hasTapPosition = fromX !== undefined || fromY !== undefined;
|
|
14844
|
+
if (hasTapPosition && (fromX === undefined || fromY === undefined)) return { ...base, ...setupScopeEvidence(scope), reason: "missing_tap_coordinates", count, target_index: targetIndex };
|
|
14845
|
+
const mode = String(action.coordinate_mode || action.coordinateMode || (hasTapPosition ? "pixels" : "ratio")).trim();
|
|
14846
|
+
if (hasTapPosition && mode === "ratio" && [fromX, fromY].some((value) => value < 0 || value > 1)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_ratio_coordinates", count, target_index: targetIndex };
|
|
14847
|
+
if (hasTapPosition && mode !== "ratio" && [fromX, fromY].some((value) => value < 0)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_pixel_coordinates", count, target_index: targetIndex };
|
|
14848
|
+
const coordinate = (value, size) => mode === "ratio" ? value * size : value;
|
|
14849
|
+
const localX = hasTapPosition && fromX !== undefined ? fromX : 0.5;
|
|
14850
|
+
const localY = hasTapPosition && fromY !== undefined ? fromY : 0.5;
|
|
14851
|
+
const point = {
|
|
14852
|
+
x: box.x + coordinate(localX, box.width),
|
|
14853
|
+
y: box.y + coordinate(localY, box.height),
|
|
14854
|
+
};
|
|
14855
|
+
const durationMs = setupNumber(action.duration_ms ?? action.durationMs, 0);
|
|
14856
|
+
const pointerType = String(action.pointer_type || action.pointerType || "touch").trim().toLowerCase();
|
|
14857
|
+
if (pointerType === "touch" || pointerType === "pen") {
|
|
14858
|
+
const client = await page.context().newCDPSession(page);
|
|
14859
|
+
try {
|
|
14860
|
+
if (pointerType === "touch") {
|
|
14861
|
+
const touchPoint = {
|
|
14862
|
+
x: point.x,
|
|
14863
|
+
y: point.y,
|
|
14864
|
+
radiusX: 1,
|
|
14865
|
+
radiusY: 1,
|
|
14866
|
+
force: 1,
|
|
14867
|
+
id: 11,
|
|
14868
|
+
};
|
|
14869
|
+
await client.send("Input.dispatchTouchEvent", {
|
|
14870
|
+
type: "touchStart",
|
|
14871
|
+
touchPoints: [touchPoint],
|
|
14872
|
+
});
|
|
14873
|
+
if (durationMs) await page.waitForTimeout(durationMs);
|
|
14874
|
+
await client.send("Input.dispatchTouchEvent", {
|
|
14875
|
+
type: "touchEnd",
|
|
14876
|
+
touchPoints: [],
|
|
14877
|
+
});
|
|
14878
|
+
} else {
|
|
14879
|
+
await client.send("Input.dispatchMouseEvent", {
|
|
14880
|
+
type: "mousePressed",
|
|
14881
|
+
x: point.x,
|
|
14882
|
+
y: point.y,
|
|
14883
|
+
button: "left",
|
|
14884
|
+
buttons: 1,
|
|
14885
|
+
clickCount: 1,
|
|
14886
|
+
pointerType: "pen",
|
|
14887
|
+
});
|
|
14888
|
+
if (durationMs) await page.waitForTimeout(durationMs);
|
|
14889
|
+
await client.send("Input.dispatchMouseEvent", {
|
|
14890
|
+
type: "mouseReleased",
|
|
14891
|
+
x: point.x,
|
|
14892
|
+
y: point.y,
|
|
14893
|
+
button: "left",
|
|
14894
|
+
buttons: 0,
|
|
14895
|
+
clickCount: 1,
|
|
14896
|
+
pointerType: "pen",
|
|
14897
|
+
});
|
|
14898
|
+
}
|
|
14899
|
+
} finally {
|
|
14900
|
+
await client.detach().catch(() => {});
|
|
14901
|
+
}
|
|
14902
|
+
} else {
|
|
14903
|
+
await page.mouse.click(point.x, point.y);
|
|
14904
|
+
}
|
|
14905
|
+
return {
|
|
14906
|
+
...base,
|
|
14907
|
+
...setupScopeEvidence(scope),
|
|
14908
|
+
ok: true,
|
|
14909
|
+
count,
|
|
14910
|
+
target_index: targetIndex,
|
|
14911
|
+
coordinate_mode: hasTapPosition ? mode : undefined,
|
|
14912
|
+
x: hasTapPosition ? fromX : undefined,
|
|
14913
|
+
y: hasTapPosition ? fromY : undefined,
|
|
14914
|
+
pointer_type: pointerType,
|
|
14915
|
+
input_dispatch: pointerType === "touch" || pointerType === "pen" ? "cdp" : "playwright_mouse",
|
|
14916
|
+
duration_ms: durationMs || undefined,
|
|
14917
|
+
};
|
|
14918
|
+
}
|
|
14779
14919
|
if (type === "drag") {
|
|
14780
14920
|
const scope = await setupActionScope(action, timeout);
|
|
14781
14921
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
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-BD4RHTGW.js";
|
|
66
66
|
import {
|
|
67
67
|
DEFAULT_RIDDLE_API_BASE_URL,
|
|
68
68
|
DEFAULT_RIDDLE_API_KEY_FILE,
|
package/dist/profile.cjs
CHANGED
|
@@ -91,6 +91,7 @@ var RIDDLE_PROOF_PROFILE_CHECK_TYPES = [
|
|
|
91
91
|
];
|
|
92
92
|
var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
93
93
|
"click",
|
|
94
|
+
"tap",
|
|
94
95
|
"drag",
|
|
95
96
|
"press",
|
|
96
97
|
"fill",
|
|
@@ -642,6 +643,21 @@ function profileSetupDragReceipts(results) {
|
|
|
642
643
|
reason: result.reason ?? result.error ?? null
|
|
643
644
|
}));
|
|
644
645
|
}
|
|
646
|
+
function profileSetupTapReceipts(results) {
|
|
647
|
+
return results.filter((result) => profileSetupResultAction(result) === "tap").map((result) => ({
|
|
648
|
+
ordinal: result.ordinal ?? null,
|
|
649
|
+
ok: result.ok !== false,
|
|
650
|
+
selector: result.selector ?? null,
|
|
651
|
+
frame_selector: result.frame_selector ?? null,
|
|
652
|
+
pointer_type: result.pointer_type ?? null,
|
|
653
|
+
input_dispatch: result.input_dispatch ?? null,
|
|
654
|
+
coordinate_mode: result.coordinate_mode ?? null,
|
|
655
|
+
x: result.x ?? null,
|
|
656
|
+
y: result.y ?? null,
|
|
657
|
+
duration_ms: result.duration_ms ?? null,
|
|
658
|
+
reason: result.reason ?? result.error ?? null
|
|
659
|
+
}));
|
|
660
|
+
}
|
|
645
661
|
function profileSetupCanvasSignatureReceipts(results) {
|
|
646
662
|
return results.filter((result) => profileSetupResultAction(result) === "canvas_signature").map((result) => ({
|
|
647
663
|
ordinal: result.ordinal ?? null,
|
|
@@ -679,21 +695,28 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
|
|
|
679
695
|
}
|
|
680
696
|
const warnings = [];
|
|
681
697
|
for (const group of groups.values()) {
|
|
682
|
-
const
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
698
|
+
const receiptsByHash = /* @__PURE__ */ new Map();
|
|
699
|
+
for (const receipt of group.receipts) {
|
|
700
|
+
const hashReceipts = receiptsByHash.get(receipt.hash) || [];
|
|
701
|
+
hashReceipts.push(receipt);
|
|
702
|
+
receiptsByHash.set(receipt.hash, hashReceipts);
|
|
703
|
+
}
|
|
704
|
+
for (const [hash, receipts] of receiptsByHash.entries()) {
|
|
705
|
+
const labels = [...new Set(receipts.map((receipt) => receipt.label))];
|
|
706
|
+
if (receipts.length < 2 || labels.length < 2) continue;
|
|
707
|
+
const visibleLabels = labels.slice(0, 8);
|
|
708
|
+
warnings.push({
|
|
709
|
+
selector: group.selector,
|
|
710
|
+
frame_selector: group.frame_selector ?? null,
|
|
711
|
+
hash,
|
|
712
|
+
count: receipts.length,
|
|
713
|
+
label_count: labels.length,
|
|
714
|
+
labels: visibleLabels,
|
|
715
|
+
omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
|
|
716
|
+
ordinals: receipts.map((receipt) => receipt.ordinal).filter((value) => value !== void 0).slice(0, 12),
|
|
717
|
+
reason: "stable_canvas_signature_hash"
|
|
718
|
+
});
|
|
719
|
+
}
|
|
697
720
|
}
|
|
698
721
|
return warnings;
|
|
699
722
|
}
|
|
@@ -796,6 +819,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
796
819
|
const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
|
|
797
820
|
const dragReceipts = profileSetupDragReceipts(results);
|
|
798
821
|
const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
|
|
822
|
+
const tapReceipts = profileSetupTapReceipts(results);
|
|
823
|
+
const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
|
|
799
824
|
const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
|
|
800
825
|
const sampledCanvasSignatureReceipts = sampleProfileSetupSummaryItems(canvasSignatureReceipts, 8);
|
|
801
826
|
const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
|
|
@@ -860,6 +885,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
860
885
|
drag_total: dragReceipts.length,
|
|
861
886
|
drag_truncated: dragReceipts.length > sampledDragReceipts.length,
|
|
862
887
|
drag: sampledDragReceipts,
|
|
888
|
+
tap_total: tapReceipts.length,
|
|
889
|
+
tap_truncated: tapReceipts.length > sampledTapReceipts.length,
|
|
890
|
+
tap: sampledTapReceipts,
|
|
863
891
|
canvas_signature_total: canvasSignatureReceipts.length,
|
|
864
892
|
canvas_signature_truncated: canvasSignatureReceipts.length > sampledCanvasSignatureReceipts.length,
|
|
865
893
|
canvas_signature: sampledCanvasSignatureReceipts,
|
|
@@ -916,7 +944,7 @@ function isSupportedCheckType(value) {
|
|
|
916
944
|
}
|
|
917
945
|
function normalizeSetupActionType(value, index) {
|
|
918
946
|
const normalizedInput = String(value || "").trim().replace(/-/g, "_");
|
|
919
|
-
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "deterministic_runtime" || normalizedInput === "mock_runtime" || normalizedInput === "mock_random" || normalizedInput === "mock_random_queue" || normalizedInput === "seed_random_queue" || normalizedInput === "set_random_queue" || normalizedInput === "mock_clock" || normalizedInput === "set_mock_clock" || normalizedInput === "set_runtime_determinism" || normalizedInput === "runtime_determinism" ? "deterministic_runtime" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
|
|
947
|
+
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "pointer_tap" || normalizedInput === "touch_tap" || normalizedInput === "canvas_tap" ? "tap" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "deterministic_runtime" || normalizedInput === "mock_runtime" || normalizedInput === "mock_random" || normalizedInput === "mock_random_queue" || normalizedInput === "seed_random_queue" || normalizedInput === "set_random_queue" || normalizedInput === "mock_clock" || normalizedInput === "set_mock_clock" || normalizedInput === "set_runtime_determinism" || normalizedInput === "runtime_determinism" ? "deterministic_runtime" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
|
|
920
948
|
if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
|
|
921
949
|
return normalized;
|
|
922
950
|
}
|
|
@@ -998,8 +1026,8 @@ function normalizeSetupActionCoordinateMode(value, index) {
|
|
|
998
1026
|
}
|
|
999
1027
|
function normalizeSetupActionPointerType(value, type, index) {
|
|
1000
1028
|
if (value === void 0 || value === null || value === "") return void 0;
|
|
1001
|
-
if (type !== "drag") {
|
|
1002
|
-
throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag actions.`);
|
|
1029
|
+
if (type !== "drag" && type !== "tap") {
|
|
1030
|
+
throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag/tap actions.`);
|
|
1003
1031
|
}
|
|
1004
1032
|
const normalized = String(value).trim().replace(/-/g, "_").toLowerCase();
|
|
1005
1033
|
if (normalized === "mouse") return "mouse";
|
|
@@ -1078,11 +1106,11 @@ function normalizeSetupAction(input, index) {
|
|
|
1078
1106
|
if (frameIndex !== void 0 && (!Number.isInteger(frameIndex) || frameIndex < 0)) {
|
|
1079
1107
|
throw new Error(`target.setup_actions[${index}].frame_index must be a non-negative integer.`);
|
|
1080
1108
|
}
|
|
1081
|
-
if ((type === "click" || type === "drag" || type === "fill" || type === "set_input_value" || type === "set_range_value" || type === "canvas_signature" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
|
|
1109
|
+
if ((type === "click" || type === "tap" || type === "drag" || type === "fill" || type === "set_input_value" || type === "set_range_value" || type === "canvas_signature" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
|
|
1082
1110
|
throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
|
|
1083
1111
|
}
|
|
1084
|
-
const fromX = type === "click" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
|
|
1085
|
-
const fromY = type === "click" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
|
|
1112
|
+
const fromX = type === "click" || type === "tap" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
|
|
1113
|
+
const fromY = type === "click" || type === "tap" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
|
|
1086
1114
|
const toX = numberValue(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
|
|
1087
1115
|
const toY = numberValue(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
|
|
1088
1116
|
const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
|
|
@@ -1102,6 +1130,21 @@ function normalizeSetupAction(input, index) {
|
|
|
1102
1130
|
}
|
|
1103
1131
|
}
|
|
1104
1132
|
}
|
|
1133
|
+
if (type === "tap") {
|
|
1134
|
+
const hasTapCoordinate = fromX !== void 0 || fromY !== void 0;
|
|
1135
|
+
if (hasTapCoordinate && (fromX === void 0 || fromY === void 0)) {
|
|
1136
|
+
throw new Error(`target.setup_actions[${index}] tap coordinates require both x and y.`);
|
|
1137
|
+
}
|
|
1138
|
+
if (hasTapCoordinate && fromX !== void 0 && fromY !== void 0) {
|
|
1139
|
+
const tapCoordinates = [fromX, fromY];
|
|
1140
|
+
if (coordinateMode === "ratio" && tapCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
|
|
1141
|
+
throw new Error(`target.setup_actions[${index}] tap ratio coordinates must be between 0 and 1.`);
|
|
1142
|
+
}
|
|
1143
|
+
if ((coordinateMode === void 0 || coordinateMode === "pixels") && tapCoordinates.some((value2) => value2 < 0)) {
|
|
1144
|
+
throw new Error(`target.setup_actions[${index}] tap pixel coordinates must be non-negative.`);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1105
1148
|
if (type === "drag") {
|
|
1106
1149
|
if (fromX === void 0 || fromY === void 0 || toX === void 0 || toY === void 0) {
|
|
1107
1150
|
throw new Error(`target.setup_actions[${index}] drag requires from_x, from_y, to_x, and to_y.`);
|
|
@@ -4456,24 +4499,31 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
|
|
|
4456
4499
|
}
|
|
4457
4500
|
const warnings = [];
|
|
4458
4501
|
for (const group of groups.values()) {
|
|
4459
|
-
const
|
|
4460
|
-
const
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
.
|
|
4474
|
-
.
|
|
4475
|
-
|
|
4476
|
-
|
|
4502
|
+
const receiptsByHash = new Map();
|
|
4503
|
+
for (const receipt of group.receipts) {
|
|
4504
|
+
const hashReceipts = receiptsByHash.get(receipt.hash) || [];
|
|
4505
|
+
hashReceipts.push(receipt);
|
|
4506
|
+
receiptsByHash.set(receipt.hash, hashReceipts);
|
|
4507
|
+
}
|
|
4508
|
+
for (const [hash, receipts] of receiptsByHash.entries()) {
|
|
4509
|
+
const labels = [...new Set(receipts.map((receipt) => receipt.label))];
|
|
4510
|
+
if (receipts.length < 2 || labels.length < 2) continue;
|
|
4511
|
+
const visibleLabels = labels.slice(0, 8);
|
|
4512
|
+
warnings.push({
|
|
4513
|
+
selector: group.selector,
|
|
4514
|
+
frame_selector: group.frame_selector || null,
|
|
4515
|
+
hash,
|
|
4516
|
+
count: receipts.length,
|
|
4517
|
+
label_count: labels.length,
|
|
4518
|
+
labels: visibleLabels,
|
|
4519
|
+
omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
|
|
4520
|
+
ordinals: receipts
|
|
4521
|
+
.map((receipt) => receipt.ordinal)
|
|
4522
|
+
.filter((value) => value !== undefined)
|
|
4523
|
+
.slice(0, 12),
|
|
4524
|
+
reason: "stable_canvas_signature_hash",
|
|
4525
|
+
});
|
|
4526
|
+
}
|
|
4477
4527
|
}
|
|
4478
4528
|
return warnings;
|
|
4479
4529
|
}
|
|
@@ -6090,6 +6140,96 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
6090
6140
|
await waitForAnyVisibleSelector(scope.context, action.selector, timeout);
|
|
6091
6141
|
return { ...base, ...setupScopeEvidence(scope), ok: true, timeout_ms: timeout };
|
|
6092
6142
|
}
|
|
6143
|
+
if (type === "tap") {
|
|
6144
|
+
const scope = await setupActionScope(action, timeout);
|
|
6145
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
6146
|
+
const locator = scope.context.locator(action.selector);
|
|
6147
|
+
const count = await locator.count();
|
|
6148
|
+
if (!count) return { ...base, ...setupScopeEvidence(scope), reason: "selector_not_found", count };
|
|
6149
|
+
const targetIndex = Number.isInteger(action.index) ? action.index : 0;
|
|
6150
|
+
if (targetIndex < 0 || targetIndex >= count) return { ...base, ...setupScopeEvidence(scope), reason: "index_out_of_range", count, target_index: targetIndex };
|
|
6151
|
+
const target = locator.nth(targetIndex);
|
|
6152
|
+
await target.waitFor({ state: "visible", timeout });
|
|
6153
|
+
const box = await target.boundingBox();
|
|
6154
|
+
if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
|
|
6155
|
+
const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
|
|
6156
|
+
const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
|
|
6157
|
+
const hasTapPosition = fromX !== undefined || fromY !== undefined;
|
|
6158
|
+
if (hasTapPosition && (fromX === undefined || fromY === undefined)) return { ...base, ...setupScopeEvidence(scope), reason: "missing_tap_coordinates", count, target_index: targetIndex };
|
|
6159
|
+
const mode = String(action.coordinate_mode || action.coordinateMode || (hasTapPosition ? "pixels" : "ratio")).trim();
|
|
6160
|
+
if (hasTapPosition && mode === "ratio" && [fromX, fromY].some((value) => value < 0 || value > 1)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_ratio_coordinates", count, target_index: targetIndex };
|
|
6161
|
+
if (hasTapPosition && mode !== "ratio" && [fromX, fromY].some((value) => value < 0)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_pixel_coordinates", count, target_index: targetIndex };
|
|
6162
|
+
const coordinate = (value, size) => mode === "ratio" ? value * size : value;
|
|
6163
|
+
const localX = hasTapPosition && fromX !== undefined ? fromX : 0.5;
|
|
6164
|
+
const localY = hasTapPosition && fromY !== undefined ? fromY : 0.5;
|
|
6165
|
+
const point = {
|
|
6166
|
+
x: box.x + coordinate(localX, box.width),
|
|
6167
|
+
y: box.y + coordinate(localY, box.height),
|
|
6168
|
+
};
|
|
6169
|
+
const durationMs = setupNumber(action.duration_ms ?? action.durationMs, 0);
|
|
6170
|
+
const pointerType = String(action.pointer_type || action.pointerType || "touch").trim().toLowerCase();
|
|
6171
|
+
if (pointerType === "touch" || pointerType === "pen") {
|
|
6172
|
+
const client = await page.context().newCDPSession(page);
|
|
6173
|
+
try {
|
|
6174
|
+
if (pointerType === "touch") {
|
|
6175
|
+
const touchPoint = {
|
|
6176
|
+
x: point.x,
|
|
6177
|
+
y: point.y,
|
|
6178
|
+
radiusX: 1,
|
|
6179
|
+
radiusY: 1,
|
|
6180
|
+
force: 1,
|
|
6181
|
+
id: 11,
|
|
6182
|
+
};
|
|
6183
|
+
await client.send("Input.dispatchTouchEvent", {
|
|
6184
|
+
type: "touchStart",
|
|
6185
|
+
touchPoints: [touchPoint],
|
|
6186
|
+
});
|
|
6187
|
+
if (durationMs) await page.waitForTimeout(durationMs);
|
|
6188
|
+
await client.send("Input.dispatchTouchEvent", {
|
|
6189
|
+
type: "touchEnd",
|
|
6190
|
+
touchPoints: [],
|
|
6191
|
+
});
|
|
6192
|
+
} else {
|
|
6193
|
+
await client.send("Input.dispatchMouseEvent", {
|
|
6194
|
+
type: "mousePressed",
|
|
6195
|
+
x: point.x,
|
|
6196
|
+
y: point.y,
|
|
6197
|
+
button: "left",
|
|
6198
|
+
buttons: 1,
|
|
6199
|
+
clickCount: 1,
|
|
6200
|
+
pointerType: "pen",
|
|
6201
|
+
});
|
|
6202
|
+
if (durationMs) await page.waitForTimeout(durationMs);
|
|
6203
|
+
await client.send("Input.dispatchMouseEvent", {
|
|
6204
|
+
type: "mouseReleased",
|
|
6205
|
+
x: point.x,
|
|
6206
|
+
y: point.y,
|
|
6207
|
+
button: "left",
|
|
6208
|
+
buttons: 0,
|
|
6209
|
+
clickCount: 1,
|
|
6210
|
+
pointerType: "pen",
|
|
6211
|
+
});
|
|
6212
|
+
}
|
|
6213
|
+
} finally {
|
|
6214
|
+
await client.detach().catch(() => {});
|
|
6215
|
+
}
|
|
6216
|
+
} else {
|
|
6217
|
+
await page.mouse.click(point.x, point.y);
|
|
6218
|
+
}
|
|
6219
|
+
return {
|
|
6220
|
+
...base,
|
|
6221
|
+
...setupScopeEvidence(scope),
|
|
6222
|
+
ok: true,
|
|
6223
|
+
count,
|
|
6224
|
+
target_index: targetIndex,
|
|
6225
|
+
coordinate_mode: hasTapPosition ? mode : undefined,
|
|
6226
|
+
x: hasTapPosition ? fromX : undefined,
|
|
6227
|
+
y: hasTapPosition ? fromY : undefined,
|
|
6228
|
+
pointer_type: pointerType,
|
|
6229
|
+
input_dispatch: pointerType === "touch" || pointerType === "pen" ? "cdp" : "playwright_mouse",
|
|
6230
|
+
duration_ms: durationMs || undefined,
|
|
6231
|
+
};
|
|
6232
|
+
}
|
|
6093
6233
|
if (type === "drag") {
|
|
6094
6234
|
const scope = await setupActionScope(action, timeout);
|
|
6095
6235
|
if (!scope.ok) return setupScopeFailure(base, scope);
|
package/dist/profile.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
|
|
|
5
5
|
declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
|
|
6
6
|
declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
|
|
7
7
|
declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "url_search_param_equals", "url_search_param_absent", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "dialog_count_equals", "dialog_accept_count_equals", "dialog_dismiss_count_equals", "selector_text_visible", "selector_text_absent", "selector_text_order", "observe_within", "frame_text_visible", "frame_url_equals", "frame_url_matches", "frame_no_horizontal_overflow", "text_visible", "text_absent", "http_status", "link_status", "artifact_link_status", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors", "no_console_warnings"];
|
|
8
|
-
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
8
|
+
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "tap", "drag", "press", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
9
9
|
type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
|
|
10
10
|
type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
|
|
11
11
|
type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
|