@riddledc/riddle-proof 0.7.90 → 0.7.91

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.
@@ -3097,6 +3097,10 @@ function textMatches(sample, check) {
3097
3097
  }
3098
3098
  return String(sample || "").includes(check.text || "");
3099
3099
  }
3100
+ function profileCheckAppliesToViewport(check, viewport) {
3101
+ if (!Array.isArray(check.viewports) || !check.viewports.length) return true;
3102
+ return Boolean(viewport && viewport.name && check.viewports.includes(viewport.name));
3103
+ }
3100
3104
  function setupActionType(action) {
3101
3105
  return String(action && action.type ? action.type : "").replace(/-/g, "_");
3102
3106
  }
@@ -3114,6 +3118,30 @@ function setupTextMatches(sample, action) {
3114
3118
  }
3115
3119
  return String(sample || "").includes(action.text || "");
3116
3120
  }
3121
+ async function waitForAnyVisibleSelector(context, selector, timeout) {
3122
+ const deadline = Date.now() + setupNumber(timeout, 15000);
3123
+ let lastReason = "selector_not_found";
3124
+ while (Date.now() <= deadline) {
3125
+ try {
3126
+ const locator = context.locator(selector);
3127
+ const count = await locator.count();
3128
+ if (!count) {
3129
+ lastReason = "selector_not_found";
3130
+ } else {
3131
+ lastReason = "no_visible_match";
3132
+ for (let index = 0; index < count; index += 1) {
3133
+ if (await locator.nth(index).isVisible().catch(() => false)) {
3134
+ return { ok: true, count, index };
3135
+ }
3136
+ }
3137
+ }
3138
+ } catch (error) {
3139
+ lastReason = String(error && error.message ? error.message : error).slice(0, 500);
3140
+ }
3141
+ await page.waitForTimeout(200);
3142
+ }
3143
+ throw new Error("No visible match for selector " + selector + ": " + lastReason);
3144
+ }
3117
3145
  function setupHasOwn(action, key) {
3118
3146
  return Boolean(action) && Object.keys(action).includes(key);
3119
3147
  }
@@ -3447,7 +3475,7 @@ async function executeSetupAction(action, ordinal, viewport) {
3447
3475
  if (type === "wait_for_selector") {
3448
3476
  const scope = await setupActionScope(action, timeout);
3449
3477
  if (!scope.ok) return setupScopeFailure(base, scope);
3450
- await scope.context.waitForSelector(action.selector, { state: "visible", timeout });
3478
+ await waitForAnyVisibleSelector(scope.context, action.selector, timeout);
3451
3479
  return { ...base, ...setupScopeEvidence(scope), ok: true, timeout_ms: timeout };
3452
3480
  }
3453
3481
  if (type === "drag") {
@@ -4463,7 +4491,7 @@ async function collectRouteInventory(check, viewport) {
4463
4491
  try {
4464
4492
  await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: 90000 });
4465
4493
  if (profile.target.wait_for_selector) {
4466
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 }).catch(() => {});
4494
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000).catch(() => {});
4467
4495
  }
4468
4496
  const index = await findInventoryLinkIndex(check, expectedRoute.path);
4469
4497
  if (index < 0) {
@@ -4522,7 +4550,7 @@ async function captureViewport(viewport) {
4522
4550
  }
4523
4551
  if (!navigationError && profile.target.wait_for_selector) {
4524
4552
  try {
4525
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 });
4553
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000);
4526
4554
  } catch (error) {
4527
4555
  waitError = String(error && error.message ? error.message : error).slice(0, 1000);
4528
4556
  }
@@ -4626,6 +4654,7 @@ async function captureViewport(viewport) {
4626
4654
  const text_matches = {};
4627
4655
  const link_statuses = {};
4628
4656
  for (const check of profile.checks || []) {
4657
+ if (!profileCheckAppliesToViewport(check, viewport)) continue;
4629
4658
  if (
4630
4659
  (
4631
4660
  check.type === "selector_visible"
@@ -4661,7 +4690,7 @@ async function captureViewport(viewport) {
4661
4690
  pageErrors.push({ message: "saveScreenshot failed: " + String(error && error.message ? error.message : error).slice(0, 500) });
4662
4691
  }
4663
4692
  let routeInventory;
4664
- const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory");
4693
+ const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory" && profileCheckAppliesToViewport(check, viewport));
4665
4694
  const firstViewportName = (profile.target.viewports || [])[0] && (profile.target.viewports || [])[0].name;
4666
4695
  if (routeInventoryCheck && (routeInventoryCheck.run_all_viewports || !firstViewportName || viewport.name === firstViewportName)) {
4667
4696
  try {
@@ -4766,7 +4795,7 @@ function buildProfileEvidence(currentViewports) {
4766
4795
  })),
4767
4796
  })),
4768
4797
  link_status: currentViewports
4769
- .filter((viewport) => viewport.link_statuses)
4798
+ .filter((viewport) => viewport.link_statuses && Object.keys(viewport.link_statuses).length)
4770
4799
  .map((viewport) => ({
4771
4800
  viewport: viewport.name,
4772
4801
  selectors: Object.entries(viewport.link_statuses || {}).map(([selector, statusSet]) => ({
package/dist/cli.cjs CHANGED
@@ -9968,6 +9968,10 @@ function textMatches(sample, check) {
9968
9968
  }
9969
9969
  return String(sample || "").includes(check.text || "");
9970
9970
  }
9971
+ function profileCheckAppliesToViewport(check, viewport) {
9972
+ if (!Array.isArray(check.viewports) || !check.viewports.length) return true;
9973
+ return Boolean(viewport && viewport.name && check.viewports.includes(viewport.name));
9974
+ }
9971
9975
  function setupActionType(action) {
9972
9976
  return String(action && action.type ? action.type : "").replace(/-/g, "_");
9973
9977
  }
@@ -9985,6 +9989,30 @@ function setupTextMatches(sample, action) {
9985
9989
  }
9986
9990
  return String(sample || "").includes(action.text || "");
9987
9991
  }
9992
+ async function waitForAnyVisibleSelector(context, selector, timeout) {
9993
+ const deadline = Date.now() + setupNumber(timeout, 15000);
9994
+ let lastReason = "selector_not_found";
9995
+ while (Date.now() <= deadline) {
9996
+ try {
9997
+ const locator = context.locator(selector);
9998
+ const count = await locator.count();
9999
+ if (!count) {
10000
+ lastReason = "selector_not_found";
10001
+ } else {
10002
+ lastReason = "no_visible_match";
10003
+ for (let index = 0; index < count; index += 1) {
10004
+ if (await locator.nth(index).isVisible().catch(() => false)) {
10005
+ return { ok: true, count, index };
10006
+ }
10007
+ }
10008
+ }
10009
+ } catch (error) {
10010
+ lastReason = String(error && error.message ? error.message : error).slice(0, 500);
10011
+ }
10012
+ await page.waitForTimeout(200);
10013
+ }
10014
+ throw new Error("No visible match for selector " + selector + ": " + lastReason);
10015
+ }
9988
10016
  function setupHasOwn(action, key) {
9989
10017
  return Boolean(action) && Object.keys(action).includes(key);
9990
10018
  }
@@ -10318,7 +10346,7 @@ async function executeSetupAction(action, ordinal, viewport) {
10318
10346
  if (type === "wait_for_selector") {
10319
10347
  const scope = await setupActionScope(action, timeout);
10320
10348
  if (!scope.ok) return setupScopeFailure(base, scope);
10321
- await scope.context.waitForSelector(action.selector, { state: "visible", timeout });
10349
+ await waitForAnyVisibleSelector(scope.context, action.selector, timeout);
10322
10350
  return { ...base, ...setupScopeEvidence(scope), ok: true, timeout_ms: timeout };
10323
10351
  }
10324
10352
  if (type === "drag") {
@@ -11334,7 +11362,7 @@ async function collectRouteInventory(check, viewport) {
11334
11362
  try {
11335
11363
  await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: 90000 });
11336
11364
  if (profile.target.wait_for_selector) {
11337
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 }).catch(() => {});
11365
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000).catch(() => {});
11338
11366
  }
11339
11367
  const index = await findInventoryLinkIndex(check, expectedRoute.path);
11340
11368
  if (index < 0) {
@@ -11393,7 +11421,7 @@ async function captureViewport(viewport) {
11393
11421
  }
11394
11422
  if (!navigationError && profile.target.wait_for_selector) {
11395
11423
  try {
11396
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 });
11424
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000);
11397
11425
  } catch (error) {
11398
11426
  waitError = String(error && error.message ? error.message : error).slice(0, 1000);
11399
11427
  }
@@ -11497,6 +11525,7 @@ async function captureViewport(viewport) {
11497
11525
  const text_matches = {};
11498
11526
  const link_statuses = {};
11499
11527
  for (const check of profile.checks || []) {
11528
+ if (!profileCheckAppliesToViewport(check, viewport)) continue;
11500
11529
  if (
11501
11530
  (
11502
11531
  check.type === "selector_visible"
@@ -11532,7 +11561,7 @@ async function captureViewport(viewport) {
11532
11561
  pageErrors.push({ message: "saveScreenshot failed: " + String(error && error.message ? error.message : error).slice(0, 500) });
11533
11562
  }
11534
11563
  let routeInventory;
11535
- const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory");
11564
+ const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory" && profileCheckAppliesToViewport(check, viewport));
11536
11565
  const firstViewportName = (profile.target.viewports || [])[0] && (profile.target.viewports || [])[0].name;
11537
11566
  if (routeInventoryCheck && (routeInventoryCheck.run_all_viewports || !firstViewportName || viewport.name === firstViewportName)) {
11538
11567
  try {
@@ -11637,7 +11666,7 @@ function buildProfileEvidence(currentViewports) {
11637
11666
  })),
11638
11667
  })),
11639
11668
  link_status: currentViewports
11640
- .filter((viewport) => viewport.link_statuses)
11669
+ .filter((viewport) => viewport.link_statuses && Object.keys(viewport.link_statuses).length)
11641
11670
  .map((viewport) => ({
11642
11671
  viewport: viewport.name,
11643
11672
  selectors: Object.entries(viewport.link_statuses || {}).map(([selector, statusSet]) => ({
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  profileStatusExitCode,
11
11
  resolveRiddleProofProfileTargetUrl,
12
12
  resolveRiddleProofProfileTimeoutSec
13
- } from "./chunk-4FMBHM4E.js";
13
+ } from "./chunk-2SGLFPFX.js";
14
14
  import {
15
15
  createRiddleApiClient,
16
16
  parseRiddleViewport
package/dist/index.cjs CHANGED
@@ -11825,6 +11825,10 @@ function textMatches(sample, check) {
11825
11825
  }
11826
11826
  return String(sample || "").includes(check.text || "");
11827
11827
  }
11828
+ function profileCheckAppliesToViewport(check, viewport) {
11829
+ if (!Array.isArray(check.viewports) || !check.viewports.length) return true;
11830
+ return Boolean(viewport && viewport.name && check.viewports.includes(viewport.name));
11831
+ }
11828
11832
  function setupActionType(action) {
11829
11833
  return String(action && action.type ? action.type : "").replace(/-/g, "_");
11830
11834
  }
@@ -11842,6 +11846,30 @@ function setupTextMatches(sample, action) {
11842
11846
  }
11843
11847
  return String(sample || "").includes(action.text || "");
11844
11848
  }
11849
+ async function waitForAnyVisibleSelector(context, selector, timeout) {
11850
+ const deadline = Date.now() + setupNumber(timeout, 15000);
11851
+ let lastReason = "selector_not_found";
11852
+ while (Date.now() <= deadline) {
11853
+ try {
11854
+ const locator = context.locator(selector);
11855
+ const count = await locator.count();
11856
+ if (!count) {
11857
+ lastReason = "selector_not_found";
11858
+ } else {
11859
+ lastReason = "no_visible_match";
11860
+ for (let index = 0; index < count; index += 1) {
11861
+ if (await locator.nth(index).isVisible().catch(() => false)) {
11862
+ return { ok: true, count, index };
11863
+ }
11864
+ }
11865
+ }
11866
+ } catch (error) {
11867
+ lastReason = String(error && error.message ? error.message : error).slice(0, 500);
11868
+ }
11869
+ await page.waitForTimeout(200);
11870
+ }
11871
+ throw new Error("No visible match for selector " + selector + ": " + lastReason);
11872
+ }
11845
11873
  function setupHasOwn(action, key) {
11846
11874
  return Boolean(action) && Object.keys(action).includes(key);
11847
11875
  }
@@ -12175,7 +12203,7 @@ async function executeSetupAction(action, ordinal, viewport) {
12175
12203
  if (type === "wait_for_selector") {
12176
12204
  const scope = await setupActionScope(action, timeout);
12177
12205
  if (!scope.ok) return setupScopeFailure(base, scope);
12178
- await scope.context.waitForSelector(action.selector, { state: "visible", timeout });
12206
+ await waitForAnyVisibleSelector(scope.context, action.selector, timeout);
12179
12207
  return { ...base, ...setupScopeEvidence(scope), ok: true, timeout_ms: timeout };
12180
12208
  }
12181
12209
  if (type === "drag") {
@@ -13191,7 +13219,7 @@ async function collectRouteInventory(check, viewport) {
13191
13219
  try {
13192
13220
  await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: 90000 });
13193
13221
  if (profile.target.wait_for_selector) {
13194
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 }).catch(() => {});
13222
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000).catch(() => {});
13195
13223
  }
13196
13224
  const index = await findInventoryLinkIndex(check, expectedRoute.path);
13197
13225
  if (index < 0) {
@@ -13250,7 +13278,7 @@ async function captureViewport(viewport) {
13250
13278
  }
13251
13279
  if (!navigationError && profile.target.wait_for_selector) {
13252
13280
  try {
13253
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 });
13281
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000);
13254
13282
  } catch (error) {
13255
13283
  waitError = String(error && error.message ? error.message : error).slice(0, 1000);
13256
13284
  }
@@ -13354,6 +13382,7 @@ async function captureViewport(viewport) {
13354
13382
  const text_matches = {};
13355
13383
  const link_statuses = {};
13356
13384
  for (const check of profile.checks || []) {
13385
+ if (!profileCheckAppliesToViewport(check, viewport)) continue;
13357
13386
  if (
13358
13387
  (
13359
13388
  check.type === "selector_visible"
@@ -13389,7 +13418,7 @@ async function captureViewport(viewport) {
13389
13418
  pageErrors.push({ message: "saveScreenshot failed: " + String(error && error.message ? error.message : error).slice(0, 500) });
13390
13419
  }
13391
13420
  let routeInventory;
13392
- const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory");
13421
+ const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory" && profileCheckAppliesToViewport(check, viewport));
13393
13422
  const firstViewportName = (profile.target.viewports || [])[0] && (profile.target.viewports || [])[0].name;
13394
13423
  if (routeInventoryCheck && (routeInventoryCheck.run_all_viewports || !firstViewportName || viewport.name === firstViewportName)) {
13395
13424
  try {
@@ -13494,7 +13523,7 @@ function buildProfileEvidence(currentViewports) {
13494
13523
  })),
13495
13524
  })),
13496
13525
  link_status: currentViewports
13497
- .filter((viewport) => viewport.link_statuses)
13526
+ .filter((viewport) => viewport.link_statuses && Object.keys(viewport.link_statuses).length)
13498
13527
  .map((viewport) => ({
13499
13528
  viewport: viewport.name,
13500
13529
  selectors: Object.entries(viewport.link_statuses || {}).map(([selector, statusSet]) => ({
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ import {
58
58
  resolveRiddleProofProfileTimeoutSec,
59
59
  slugifyRiddleProofProfileName,
60
60
  summarizeRiddleProofProfileResult
61
- } from "./chunk-4FMBHM4E.js";
61
+ } from "./chunk-2SGLFPFX.js";
62
62
  import {
63
63
  DEFAULT_RIDDLE_API_BASE_URL,
64
64
  DEFAULT_RIDDLE_API_KEY_FILE,
package/dist/profile.cjs CHANGED
@@ -3140,6 +3140,10 @@ function textMatches(sample, check) {
3140
3140
  }
3141
3141
  return String(sample || "").includes(check.text || "");
3142
3142
  }
3143
+ function profileCheckAppliesToViewport(check, viewport) {
3144
+ if (!Array.isArray(check.viewports) || !check.viewports.length) return true;
3145
+ return Boolean(viewport && viewport.name && check.viewports.includes(viewport.name));
3146
+ }
3143
3147
  function setupActionType(action) {
3144
3148
  return String(action && action.type ? action.type : "").replace(/-/g, "_");
3145
3149
  }
@@ -3157,6 +3161,30 @@ function setupTextMatches(sample, action) {
3157
3161
  }
3158
3162
  return String(sample || "").includes(action.text || "");
3159
3163
  }
3164
+ async function waitForAnyVisibleSelector(context, selector, timeout) {
3165
+ const deadline = Date.now() + setupNumber(timeout, 15000);
3166
+ let lastReason = "selector_not_found";
3167
+ while (Date.now() <= deadline) {
3168
+ try {
3169
+ const locator = context.locator(selector);
3170
+ const count = await locator.count();
3171
+ if (!count) {
3172
+ lastReason = "selector_not_found";
3173
+ } else {
3174
+ lastReason = "no_visible_match";
3175
+ for (let index = 0; index < count; index += 1) {
3176
+ if (await locator.nth(index).isVisible().catch(() => false)) {
3177
+ return { ok: true, count, index };
3178
+ }
3179
+ }
3180
+ }
3181
+ } catch (error) {
3182
+ lastReason = String(error && error.message ? error.message : error).slice(0, 500);
3183
+ }
3184
+ await page.waitForTimeout(200);
3185
+ }
3186
+ throw new Error("No visible match for selector " + selector + ": " + lastReason);
3187
+ }
3160
3188
  function setupHasOwn(action, key) {
3161
3189
  return Boolean(action) && Object.keys(action).includes(key);
3162
3190
  }
@@ -3490,7 +3518,7 @@ async function executeSetupAction(action, ordinal, viewport) {
3490
3518
  if (type === "wait_for_selector") {
3491
3519
  const scope = await setupActionScope(action, timeout);
3492
3520
  if (!scope.ok) return setupScopeFailure(base, scope);
3493
- await scope.context.waitForSelector(action.selector, { state: "visible", timeout });
3521
+ await waitForAnyVisibleSelector(scope.context, action.selector, timeout);
3494
3522
  return { ...base, ...setupScopeEvidence(scope), ok: true, timeout_ms: timeout };
3495
3523
  }
3496
3524
  if (type === "drag") {
@@ -4506,7 +4534,7 @@ async function collectRouteInventory(check, viewport) {
4506
4534
  try {
4507
4535
  await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: 90000 });
4508
4536
  if (profile.target.wait_for_selector) {
4509
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 }).catch(() => {});
4537
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000).catch(() => {});
4510
4538
  }
4511
4539
  const index = await findInventoryLinkIndex(check, expectedRoute.path);
4512
4540
  if (index < 0) {
@@ -4565,7 +4593,7 @@ async function captureViewport(viewport) {
4565
4593
  }
4566
4594
  if (!navigationError && profile.target.wait_for_selector) {
4567
4595
  try {
4568
- await page.waitForSelector(profile.target.wait_for_selector, { state: "visible", timeout: 15000 });
4596
+ await waitForAnyVisibleSelector(page, profile.target.wait_for_selector, 15000);
4569
4597
  } catch (error) {
4570
4598
  waitError = String(error && error.message ? error.message : error).slice(0, 1000);
4571
4599
  }
@@ -4669,6 +4697,7 @@ async function captureViewport(viewport) {
4669
4697
  const text_matches = {};
4670
4698
  const link_statuses = {};
4671
4699
  for (const check of profile.checks || []) {
4700
+ if (!profileCheckAppliesToViewport(check, viewport)) continue;
4672
4701
  if (
4673
4702
  (
4674
4703
  check.type === "selector_visible"
@@ -4704,7 +4733,7 @@ async function captureViewport(viewport) {
4704
4733
  pageErrors.push({ message: "saveScreenshot failed: " + String(error && error.message ? error.message : error).slice(0, 500) });
4705
4734
  }
4706
4735
  let routeInventory;
4707
- const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory");
4736
+ const routeInventoryCheck = (profile.checks || []).find((check) => check.type === "route_inventory" && profileCheckAppliesToViewport(check, viewport));
4708
4737
  const firstViewportName = (profile.target.viewports || [])[0] && (profile.target.viewports || [])[0].name;
4709
4738
  if (routeInventoryCheck && (routeInventoryCheck.run_all_viewports || !firstViewportName || viewport.name === firstViewportName)) {
4710
4739
  try {
@@ -4809,7 +4838,7 @@ function buildProfileEvidence(currentViewports) {
4809
4838
  })),
4810
4839
  })),
4811
4840
  link_status: currentViewports
4812
- .filter((viewport) => viewport.link_statuses)
4841
+ .filter((viewport) => viewport.link_statuses && Object.keys(viewport.link_statuses).length)
4813
4842
  .map((viewport) => ({
4814
4843
  viewport: viewport.name,
4815
4844
  selectors: Object.entries(viewport.link_statuses || {}).map(([selector, statusSet]) => ({
package/dist/profile.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  resolveRiddleProofProfileTimeoutSec,
20
20
  slugifyRiddleProofProfileName,
21
21
  summarizeRiddleProofProfileResult
22
- } from "./chunk-4FMBHM4E.js";
22
+ } from "./chunk-2SGLFPFX.js";
23
23
  export {
24
24
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
25
25
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.90",
3
+ "version": "0.7.91",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",