@weasel-js/routing 1.5.2 → 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-H5AGTB2J.js → chunk-VEC3ACV5.js} +49 -8
- package/dist/chunk-VEC3ACV5.js.map +1 -0
- package/dist/{index-D4hKg8yu.d.ts → index-CKmbNpwl.d.ts} +89 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +38 -6
- package/dist/react.js +112 -4
- package/dist/react.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-H5AGTB2J.js.map +0 -1
|
@@ -226,6 +226,8 @@ function claimGestureOf(e) {
|
|
|
226
226
|
return "longPress";
|
|
227
227
|
case "wheel":
|
|
228
228
|
return "wheel";
|
|
229
|
+
case "pinch":
|
|
230
|
+
return "pinch";
|
|
229
231
|
default:
|
|
230
232
|
return null;
|
|
231
233
|
}
|
|
@@ -463,6 +465,22 @@ function recordModeSwitch(mode, from, to, detail) {
|
|
|
463
465
|
...detail !== void 0 ? { detail } : {}
|
|
464
466
|
});
|
|
465
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
|
+
}
|
|
466
484
|
function eligibleToRule(eligible) {
|
|
467
485
|
return typeof eligible === "function" ? eligible.rule : eligible;
|
|
468
486
|
}
|
|
@@ -514,6 +532,7 @@ function createDispatcher(opts) {
|
|
|
514
532
|
function isEmptyOngoingHandle(h) {
|
|
515
533
|
return !h.onMove && !h.onEnd && !h.overlay && !h.previewIds && !h.previewPose;
|
|
516
534
|
}
|
|
535
|
+
let routedView;
|
|
517
536
|
function buildUiInvocationCtx(deps, params) {
|
|
518
537
|
return {
|
|
519
538
|
world: { x: 0, y: 0 },
|
|
@@ -532,7 +551,8 @@ function createDispatcher(opts) {
|
|
|
532
551
|
const base = {
|
|
533
552
|
world: { x: 0, y: 0 },
|
|
534
553
|
modifiers,
|
|
535
|
-
deps
|
|
554
|
+
deps,
|
|
555
|
+
...routedView !== void 0 ? { viewId: routedView } : {}
|
|
536
556
|
};
|
|
537
557
|
const clientPoint = (ev) => {
|
|
538
558
|
const cx = ev.clientX;
|
|
@@ -547,6 +567,8 @@ function createDispatcher(opts) {
|
|
|
547
567
|
base.key = { key: event.key, repeat: false };
|
|
548
568
|
} else if (event.kind === "wheel") {
|
|
549
569
|
base.wheel = { deltaX: event.deltaX, deltaY: event.deltaY, deltaZ: 0 };
|
|
570
|
+
} else if (event.kind === "pinch") {
|
|
571
|
+
base.pinch = { scale: event.scale, rotation: event.rotation };
|
|
550
572
|
} else if (event.kind === "pointerdown" || event.kind === "click" || event.kind === "doubleclick" || event.kind === "contextmenu") {
|
|
551
573
|
const sx = event.x ?? (event.kind === "click" ? event.pressX : void 0) ?? 0;
|
|
552
574
|
const sy = event.y ?? (event.kind === "click" ? event.pressY : void 0) ?? 0;
|
|
@@ -614,14 +636,16 @@ function createDispatcher(opts) {
|
|
|
614
636
|
}
|
|
615
637
|
const capsCtx = ctx.getRuleCtx?.();
|
|
616
638
|
const allows = capsCtx ? (tags) => tags.every((tag) => capsCtx.allowedCapabilities.has(tag)) : void 0;
|
|
639
|
+
const view = ctx.viewId ?? null;
|
|
617
640
|
const result = scopeBindings(ordered, {
|
|
618
641
|
focusedId: ctx.activeToolId,
|
|
619
642
|
engagedIds: new Set(ctx.hotkeyStack),
|
|
620
643
|
...allows ? { allows } : {}
|
|
621
|
-
});
|
|
644
|
+
}).filter((sb) => liveInView(sb.binding, view));
|
|
622
645
|
for (const action of ctx.actions.list()) {
|
|
623
646
|
const targetScope = action.scope === "hotkey" ? "hotkey" : "ambient";
|
|
624
647
|
for (const binding of actionBindings(action)) {
|
|
648
|
+
if (!liveInView(binding, view)) continue;
|
|
625
649
|
result.push({ binding, scope: targetScope, ownerToolId: null });
|
|
626
650
|
}
|
|
627
651
|
}
|
|
@@ -643,6 +667,7 @@ function createDispatcher(opts) {
|
|
|
643
667
|
return map;
|
|
644
668
|
}
|
|
645
669
|
function handleInput(event, ctx) {
|
|
670
|
+
routedView = ctx.viewId;
|
|
646
671
|
if (event.kind === "key-held" && event.phase === "up") {
|
|
647
672
|
const gestureId = gestureIdFor(event);
|
|
648
673
|
const handle = inFlightHandles.get(gestureId);
|
|
@@ -730,7 +755,10 @@ function createDispatcher(opts) {
|
|
|
730
755
|
}
|
|
731
756
|
const scopedBindings = assembleScopedBindings(ctx);
|
|
732
757
|
const engagedChannels = snapshotEngagedChannels();
|
|
733
|
-
const rawMatches =
|
|
758
|
+
const rawMatches = preferViewScoped(
|
|
759
|
+
matchSorted(event, scopedBindings, ctx.isMac, engagedChannels),
|
|
760
|
+
ctx.viewId ?? null
|
|
761
|
+
);
|
|
734
762
|
const traceCandidates = [];
|
|
735
763
|
const eventKey = event.kind === "key" || event.kind === "key-held" ? event.key : void 0;
|
|
736
764
|
const finishTrace = (fired, outcome) => {
|
|
@@ -749,7 +777,7 @@ function createDispatcher(opts) {
|
|
|
749
777
|
return "unhandled";
|
|
750
778
|
}
|
|
751
779
|
const actionMap = buildActionMap(ctx.actions);
|
|
752
|
-
const ruleCtx = ctx
|
|
780
|
+
const ruleCtx = ruleCtxOf(ctx);
|
|
753
781
|
const matches = ruleCtx ? filterEligible(rawMatches, (id) => actionMap.get(id), ruleCtx) : rawMatches;
|
|
754
782
|
if (matches.length === 0) {
|
|
755
783
|
finishTrace(null, "unhandled");
|
|
@@ -789,6 +817,15 @@ function createDispatcher(opts) {
|
|
|
789
817
|
affordance: event.affordance,
|
|
790
818
|
...resolved
|
|
791
819
|
};
|
|
820
|
+
} else if (event.kind === "pinch") {
|
|
821
|
+
params = {
|
|
822
|
+
scale: event.scale,
|
|
823
|
+
rotation: event.rotation,
|
|
824
|
+
clientX: event.clientX,
|
|
825
|
+
clientY: event.clientY,
|
|
826
|
+
affordance: event.affordance,
|
|
827
|
+
...resolved
|
|
828
|
+
};
|
|
792
829
|
} else if (event.kind === "click" || event.kind === "doubleclick") {
|
|
793
830
|
params = {
|
|
794
831
|
worldX: event.x,
|
|
@@ -890,10 +927,13 @@ function createDispatcher(opts) {
|
|
|
890
927
|
function resolveAll(event, ctx, resolveOpts) {
|
|
891
928
|
const scopedBindings = assembleScopedBindings(ctx);
|
|
892
929
|
const engagedChannels = snapshotEngagedChannels();
|
|
893
|
-
const matches =
|
|
930
|
+
const matches = preferViewScoped(
|
|
931
|
+
matchSorted(event, scopedBindings, ctx.isMac, engagedChannels),
|
|
932
|
+
ctx.viewId ?? null
|
|
933
|
+
);
|
|
894
934
|
if (matches.length === 0) return [];
|
|
895
935
|
const actionMap = buildActionMap(ctx.actions);
|
|
896
|
-
const ruleCtx = ctx
|
|
936
|
+
const ruleCtx = ruleCtxOf(ctx);
|
|
897
937
|
const verdictByAction = /* @__PURE__ */ new Map();
|
|
898
938
|
let fired = false;
|
|
899
939
|
const out = [];
|
|
@@ -1179,6 +1219,7 @@ var SPEC_KIND_TO_GESTURE = {
|
|
|
1179
1219
|
key: "keyDown",
|
|
1180
1220
|
"key-held": "keyHeld",
|
|
1181
1221
|
wheel: "wheel",
|
|
1222
|
+
pinch: "pinch",
|
|
1182
1223
|
click: "click",
|
|
1183
1224
|
doubleClick: "dblTap",
|
|
1184
1225
|
contextMenu: "contextMenu",
|
|
@@ -1510,5 +1551,5 @@ function dlog(namespace, ...args) {
|
|
|
1510
1551
|
}
|
|
1511
1552
|
|
|
1512
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 };
|
|
1513
|
-
//# sourceMappingURL=chunk-
|
|
1514
|
-
//# sourceMappingURL=chunk-
|
|
1554
|
+
//# sourceMappingURL=chunk-VEC3ACV5.js.map
|
|
1555
|
+
//# sourceMappingURL=chunk-VEC3ACV5.js.map
|