@weasel-js/routing 1.5.0 → 1.5.1

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.
@@ -136,7 +136,6 @@ function liveScope(id, eligibility, state) {
136
136
  const tags = eligibility.capabilities;
137
137
  if (tags && tags.length > 0 && state.allows && !state.allows(tags)) return null;
138
138
  if (state.engagedIds?.has(id)) return "hotkey";
139
- if (eligibility.offhand && state.heldTriggers.has(eligibility.offhand)) return "hotkey";
140
139
  if (eligibility.focus && state.focusedId === id) return "active";
141
140
  if (eligibility.always || eligibility.claimed) return "ambient";
142
141
  return null;
@@ -481,11 +480,23 @@ function filterEligible(matches, actionLookup, ruleCtx) {
481
480
  return isEligible(action, ruleCtx);
482
481
  });
483
482
  }
484
- var EMPTY_TRIGGERS = /* @__PURE__ */ new Set();
485
483
  var EMPTY_ENGAGED2 = /* @__PURE__ */ new Set();
486
484
  function modifiersOf(e) {
487
485
  return { alt: e.altKey, ctrl: e.ctrlKey, meta: e.metaKey, shift: e.shiftKey };
488
486
  }
487
+ function worldPointOf(event) {
488
+ switch (event.kind) {
489
+ case "pointerdown":
490
+ case "longpress":
491
+ return event.x !== void 0 && event.y !== void 0 ? { x: event.x, y: event.y } : void 0;
492
+ case "click":
493
+ case "doubleclick":
494
+ case "contextmenu":
495
+ return event.worldX !== void 0 && event.worldY !== void 0 ? { x: event.worldX, y: event.worldY } : void 0;
496
+ default:
497
+ return void 0;
498
+ }
499
+ }
489
500
  function createDispatcher(opts) {
490
501
  const inFlightHandles = /* @__PURE__ */ new Map();
491
502
  const inFlightOwners = /* @__PURE__ */ new Map();
@@ -605,7 +616,6 @@ function createDispatcher(opts) {
605
616
  const allows = capsCtx ? (tags) => tags.every((tag) => capsCtx.allowedCapabilities.has(tag)) : void 0;
606
617
  const result = scopeBindings(ordered, {
607
618
  focusedId: ctx.activeToolId,
608
- heldTriggers: EMPTY_TRIGGERS,
609
619
  engagedIds: new Set(ctx.hotkeyStack),
610
620
  ...allows ? { allows } : {}
611
621
  });
@@ -759,7 +769,7 @@ function createDispatcher(opts) {
759
769
  }
760
770
  const deps = buildDepsFromRequires(action, ctx.depRegistry);
761
771
  if (action.enabled) {
762
- const result = action.enabled(deps);
772
+ const result = action.enabled(deps, worldPointOf(event));
763
773
  if (result !== true) {
764
774
  traceCandidates.push({ actionId: action.id, scope: match.scope, enabledResult: String(result) });
765
775
  continue;
@@ -898,7 +908,7 @@ function createDispatcher(opts) {
898
908
  } else if (ruleCtx && action.eligible && !isEligible(action, ruleCtx)) {
899
909
  verdict = { kind: "ineligible", reason: describeEligible(action.eligible) };
900
910
  } else {
901
- const disabled = action.enabled ? action.enabled(buildDepsFromRequires(action, ctx.depRegistry)) : true;
911
+ const disabled = action.enabled ? action.enabled(buildDepsFromRequires(action, ctx.depRegistry), worldPointOf(event)) : true;
902
912
  if (disabled !== true) {
903
913
  verdict = { kind: "disabled", reason: String(disabled) };
904
914
  } else if (fired) {
@@ -1500,5 +1510,5 @@ function dlog(namespace, ...args) {
1500
1510
  }
1501
1511
 
1502
1512
  export { ALWAYS, COARSE_TARGET_SCALE, DEFAULT_ALLOWED_CAPABILITIES, DEFAULT_DEVICE_PROFILE, INGEST_STRING_MIMES, NEVER, PREDICATE_TARGET, TOOL_OFFHAND_ID, actionBindings, buildDepsFromRequires, buildRouteRegistry, buildRuleCtx, buildToolOffhandBindings, clientToCanvas, clientToCanvasRect, createDispatcher, describeRule, dlog, evaluate, filterEligible, findConflicts, isDev, isEditableTarget, itemsFromClipboardData, itemsFromDataTransfer, itemsFromFiles, liveScope, makeToolOffhandAction, matchBest, matchSorted, matchesKeyBinding, offhandKeyFor, openPointerSession, pointerGestureId, recordModeSwitch, reportRouteConflicts, resolveDeviceProfile, resolveParams, routeGestureForSpecKind, routesForSpec, scopeBindings, specificity, targetConsultsAffordance, validateActionDefaultBinding, validateActionId };
1503
- //# sourceMappingURL=chunk-Y5FHAA4U.js.map
1504
- //# sourceMappingURL=chunk-Y5FHAA4U.js.map
1513
+ //# sourceMappingURL=chunk-ZZICE4J7.js.map
1514
+ //# sourceMappingURL=chunk-ZZICE4J7.js.map