@rogatio/cli 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3339,6 +3339,37 @@ var EditorControllerImpl = class {
3339
3339
  this.applyGroupEnablementLabel(button, enabled.has(groupId), groupName);
3340
3340
  }
3341
3341
  }
3342
+ /**
3343
+ * Scroll a rendered rule card into view and focus it. Explicit `behavior`
3344
+ * overrides the stylesheet's `scroll-behavior`, so the reduced-motion
3345
+ * preference has to be read here too.
3346
+ */
3347
+ revealRuleCard(groupId, ruleId) {
3348
+ const card = this.document.getElementById(ruleAnchorId(groupId, ruleId));
3349
+ if (!card) return;
3350
+ const view = this.document.defaultView;
3351
+ const reduceMotion = typeof view?.matchMedia === "function" && view.matchMedia("(prefers-reduced-motion: reduce)").matches;
3352
+ card.scrollIntoView({
3353
+ block: "start",
3354
+ behavior: reduceMotion ? "auto" : "smooth"
3355
+ });
3356
+ card.focus({ preventScroll: true });
3357
+ }
3358
+ /**
3359
+ * Deep-link to a rule: route to the group that owns it, render, then reveal
3360
+ * the rule card. Resolves against the draft, because the editor renders the
3361
+ * draft and a rule id from committed storage may have been renamed there. An
3362
+ * unknown rule still lands on its group; an unknown group falls back to
3363
+ * Overview. Never throws, so a stale link lands somewhere real rather than
3364
+ * failing.
3365
+ */
3366
+ navigateToRule(groupId, ruleId) {
3367
+ this.navigateToGroup(groupId);
3368
+ const resolvedGroup = safeText(this.currentGroupId());
3369
+ const resolvedRule = safeText(ruleId);
3370
+ if (resolvedGroup.length === 0 || resolvedRule.length === 0) return;
3371
+ this.revealRuleCard(resolvedGroup, resolvedRule);
3372
+ }
3342
3373
  navigateToSearchResult(path) {
3343
3374
  const segments = decodePointer(path);
3344
3375
  if (segments?.[0] !== "groups") {
@@ -3357,12 +3388,7 @@ var EditorControllerImpl = class {
3357
3388
  this.statusMessage = "Jumped to rule.";
3358
3389
  this.render();
3359
3390
  if (rule && typeof rule.id === "string") {
3360
- const anchor = `rogatio-rule-${safeText(group.id)}-${safeText(rule.id)}`;
3361
- const card = this.document.getElementById(anchor);
3362
- if (card) {
3363
- card.scrollIntoView({ block: "start", behavior: "smooth" });
3364
- card.focus({ preventScroll: true });
3365
- }
3391
+ this.revealRuleCard(group.id, rule.id);
3366
3392
  }
3367
3393
  }
3368
3394
  navigateToPath(path) {
@@ -3872,7 +3898,7 @@ var EditorControllerImpl = class {
3872
3898
  const card = this.document.createElement("article");
3873
3899
  card.dataset.ruleCard = "true";
3874
3900
  card.dataset.ruleId = ruleId;
3875
- card.id = `rogatio-rule-${groupId}-${ruleId}`;
3901
+ card.id = ruleAnchorId(groupId, ruleId);
3876
3902
  card.tabIndex = -1;
3877
3903
  const headingRow = this.document.createElement("div");
3878
3904
  headingRow.dataset.ruleHeading = "true";
@@ -4551,6 +4577,17 @@ function saveFailureDiagnostic(value) {
4551
4577
  const message = typeof value.message === "string" && value.message.length > 0 ? value.message : "The host could not save the project.";
4552
4578
  return diagnostic(code, path, message);
4553
4579
  }
4580
+ function encodeAnchorSegment(value) {
4581
+ return encodeURIComponent(value).replace(
4582
+ /[!'()*]/g,
4583
+ (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
4584
+ );
4585
+ }
4586
+ function ruleAnchorId(groupId, ruleId) {
4587
+ return `rogatio-rule-${encodeAnchorSegment(safeText(groupId))}:${encodeAnchorSegment(
4588
+ safeText(ruleId)
4589
+ )}`;
4590
+ }
4554
4591
  function resolveGroupRoute(groupId, groupIds) {
4555
4592
  if (typeof groupId === "string" && groupId.length > 0 && groupIds.has(groupId)) {
4556
4593
  return { kind: "group", groupId };
@@ -4595,5 +4632,6 @@ export {
4595
4632
  createRequestBodyRuleType,
4596
4633
  createResponseBodyRuleType,
4597
4634
  queryRuleType,
4635
+ ruleAnchorId,
4598
4636
  urlToExactRegex
4599
4637
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogatio/cli",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local-first browser request and response rules — editor host, file verification, test runner, and runtime dispatch.",