@weasel-js/routing 1.6.0 → 1.6.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.
- package/dist/{chunk-D2TZLDP5.js → chunk-VEC3ACV5.js} +35 -8
- package/dist/chunk-VEC3ACV5.js.map +1 -0
- package/dist/{index-B_KvoXww.d.ts → index-CKmbNpwl.d.ts} +42 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +5 -5
- package/dist/react.js +3 -2
- package/dist/react.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-D2TZLDP5.js.map +0 -1
|
@@ -465,6 +465,22 @@ function recordModeSwitch(mode, from, to, detail) {
|
|
|
465
465
|
...detail !== void 0 ? { detail } : {}
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
|
+
function liveInView(binding, view) {
|
|
469
|
+
const views = binding.opts?.views;
|
|
470
|
+
return views === void 0 || views.includes(view);
|
|
471
|
+
}
|
|
472
|
+
function preferViewScoped(matches, view) {
|
|
473
|
+
const named = [];
|
|
474
|
+
const rest = [];
|
|
475
|
+
for (const m of matches) {
|
|
476
|
+
(m.binding.opts?.views?.includes(view) ? named : rest).push(m);
|
|
477
|
+
}
|
|
478
|
+
return named.length === 0 ? [...matches] : [...named, ...rest];
|
|
479
|
+
}
|
|
480
|
+
function ruleCtxOf(ctx) {
|
|
481
|
+
const r = ctx.getRuleCtx?.();
|
|
482
|
+
return r ? { ...r, viewId: ctx.viewId ?? null } : void 0;
|
|
483
|
+
}
|
|
468
484
|
function eligibleToRule(eligible) {
|
|
469
485
|
return typeof eligible === "function" ? eligible.rule : eligible;
|
|
470
486
|
}
|
|
@@ -516,6 +532,7 @@ function createDispatcher(opts) {
|
|
|
516
532
|
function isEmptyOngoingHandle(h) {
|
|
517
533
|
return !h.onMove && !h.onEnd && !h.overlay && !h.previewIds && !h.previewPose;
|
|
518
534
|
}
|
|
535
|
+
let routedView;
|
|
519
536
|
function buildUiInvocationCtx(deps, params) {
|
|
520
537
|
return {
|
|
521
538
|
world: { x: 0, y: 0 },
|
|
@@ -534,7 +551,8 @@ function createDispatcher(opts) {
|
|
|
534
551
|
const base = {
|
|
535
552
|
world: { x: 0, y: 0 },
|
|
536
553
|
modifiers,
|
|
537
|
-
deps
|
|
554
|
+
deps,
|
|
555
|
+
...routedView !== void 0 ? { viewId: routedView } : {}
|
|
538
556
|
};
|
|
539
557
|
const clientPoint = (ev) => {
|
|
540
558
|
const cx = ev.clientX;
|
|
@@ -618,14 +636,16 @@ function createDispatcher(opts) {
|
|
|
618
636
|
}
|
|
619
637
|
const capsCtx = ctx.getRuleCtx?.();
|
|
620
638
|
const allows = capsCtx ? (tags) => tags.every((tag) => capsCtx.allowedCapabilities.has(tag)) : void 0;
|
|
639
|
+
const view = ctx.viewId ?? null;
|
|
621
640
|
const result = scopeBindings(ordered, {
|
|
622
641
|
focusedId: ctx.activeToolId,
|
|
623
642
|
engagedIds: new Set(ctx.hotkeyStack),
|
|
624
643
|
...allows ? { allows } : {}
|
|
625
|
-
});
|
|
644
|
+
}).filter((sb) => liveInView(sb.binding, view));
|
|
626
645
|
for (const action of ctx.actions.list()) {
|
|
627
646
|
const targetScope = action.scope === "hotkey" ? "hotkey" : "ambient";
|
|
628
647
|
for (const binding of actionBindings(action)) {
|
|
648
|
+
if (!liveInView(binding, view)) continue;
|
|
629
649
|
result.push({ binding, scope: targetScope, ownerToolId: null });
|
|
630
650
|
}
|
|
631
651
|
}
|
|
@@ -647,6 +667,7 @@ function createDispatcher(opts) {
|
|
|
647
667
|
return map;
|
|
648
668
|
}
|
|
649
669
|
function handleInput(event, ctx) {
|
|
670
|
+
routedView = ctx.viewId;
|
|
650
671
|
if (event.kind === "key-held" && event.phase === "up") {
|
|
651
672
|
const gestureId = gestureIdFor(event);
|
|
652
673
|
const handle = inFlightHandles.get(gestureId);
|
|
@@ -734,7 +755,10 @@ function createDispatcher(opts) {
|
|
|
734
755
|
}
|
|
735
756
|
const scopedBindings = assembleScopedBindings(ctx);
|
|
736
757
|
const engagedChannels = snapshotEngagedChannels();
|
|
737
|
-
const rawMatches =
|
|
758
|
+
const rawMatches = preferViewScoped(
|
|
759
|
+
matchSorted(event, scopedBindings, ctx.isMac, engagedChannels),
|
|
760
|
+
ctx.viewId ?? null
|
|
761
|
+
);
|
|
738
762
|
const traceCandidates = [];
|
|
739
763
|
const eventKey = event.kind === "key" || event.kind === "key-held" ? event.key : void 0;
|
|
740
764
|
const finishTrace = (fired, outcome) => {
|
|
@@ -753,7 +777,7 @@ function createDispatcher(opts) {
|
|
|
753
777
|
return "unhandled";
|
|
754
778
|
}
|
|
755
779
|
const actionMap = buildActionMap(ctx.actions);
|
|
756
|
-
const ruleCtx = ctx
|
|
780
|
+
const ruleCtx = ruleCtxOf(ctx);
|
|
757
781
|
const matches = ruleCtx ? filterEligible(rawMatches, (id) => actionMap.get(id), ruleCtx) : rawMatches;
|
|
758
782
|
if (matches.length === 0) {
|
|
759
783
|
finishTrace(null, "unhandled");
|
|
@@ -903,10 +927,13 @@ function createDispatcher(opts) {
|
|
|
903
927
|
function resolveAll(event, ctx, resolveOpts) {
|
|
904
928
|
const scopedBindings = assembleScopedBindings(ctx);
|
|
905
929
|
const engagedChannels = snapshotEngagedChannels();
|
|
906
|
-
const matches =
|
|
930
|
+
const matches = preferViewScoped(
|
|
931
|
+
matchSorted(event, scopedBindings, ctx.isMac, engagedChannels),
|
|
932
|
+
ctx.viewId ?? null
|
|
933
|
+
);
|
|
907
934
|
if (matches.length === 0) return [];
|
|
908
935
|
const actionMap = buildActionMap(ctx.actions);
|
|
909
|
-
const ruleCtx = ctx
|
|
936
|
+
const ruleCtx = ruleCtxOf(ctx);
|
|
910
937
|
const verdictByAction = /* @__PURE__ */ new Map();
|
|
911
938
|
let fired = false;
|
|
912
939
|
const out = [];
|
|
@@ -1524,5 +1551,5 @@ function dlog(namespace, ...args) {
|
|
|
1524
1551
|
}
|
|
1525
1552
|
|
|
1526
1553
|
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 };
|
|
1527
|
-
//# sourceMappingURL=chunk-
|
|
1528
|
-
//# sourceMappingURL=chunk-
|
|
1554
|
+
//# sourceMappingURL=chunk-VEC3ACV5.js.map
|
|
1555
|
+
//# sourceMappingURL=chunk-VEC3ACV5.js.map
|