@weasel-js/routing 1.10.0 → 1.10.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-4DR6AJMN.js → chunk-VCEIQ64H.js} +53 -6
- package/dist/chunk-VCEIQ64H.js.map +1 -0
- package/dist/{index-Bm2QEV09.d.ts → index-DkOqUxow.d.ts} +86 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/{internal-D0rDmi7t.d.ts → internal-Boc2I3zn.d.ts} +1 -1
- package/dist/internal.d.ts +3 -3
- package/dist/react.d.ts +8 -4
- package/dist/react.js +151 -77
- package/dist/react.js.map +1 -1
- package/package.json +9 -9
- package/dist/chunk-4DR6AJMN.js.map +0 -1
|
@@ -282,6 +282,47 @@ function resolveParams(params) {
|
|
|
282
282
|
return typeof params === "function" ? params() : params;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
// src/interactions/actions/tuning.ts
|
|
286
|
+
var WRAPS = /* @__PURE__ */ new WeakMap();
|
|
287
|
+
function layered(under, over) {
|
|
288
|
+
if (typeof under !== "function" && typeof over !== "function") return { ...under, ...over };
|
|
289
|
+
return () => ({ ...resolveParams(under), ...resolveParams(over) });
|
|
290
|
+
}
|
|
291
|
+
function wrapInvoker(invoker, params) {
|
|
292
|
+
for (let w = invoker; w; w = WRAPS.get(w)?.inner) {
|
|
293
|
+
if (WRAPS.get(w)?.params === params) return invoker;
|
|
294
|
+
}
|
|
295
|
+
const base = (given) => ({ ...resolveParams(params), ...given });
|
|
296
|
+
const wrapped = invoker.timing === "immediate" ? { timing: "immediate", run: (deps, given) => invoker.run(deps, base(given)) } : {
|
|
297
|
+
timing: "ongoing",
|
|
298
|
+
start: (ctx, opts) => invoker.start(
|
|
299
|
+
ctx.params ? { ...ctx, params: base(ctx.params) } : ctx,
|
|
300
|
+
{ ...opts, params: layered(params, opts?.params) }
|
|
301
|
+
)
|
|
302
|
+
};
|
|
303
|
+
WRAPS.set(wrapped, { inner: invoker, params });
|
|
304
|
+
return wrapped;
|
|
305
|
+
}
|
|
306
|
+
function withBindings(own, added) {
|
|
307
|
+
const base = own === void 0 ? [] : Array.isArray(own) ? own : [own];
|
|
308
|
+
return [...base, ...added.filter((b) => !base.includes(b))];
|
|
309
|
+
}
|
|
310
|
+
function tuneOnce(action, tuning) {
|
|
311
|
+
const invoker = tuning.params && action.invoker ? wrapInvoker(action.invoker, tuning.params) : action.invoker;
|
|
312
|
+
const bindings = tuning.bindings?.length ? withBindings(action.defaultBinding, tuning.bindings) : null;
|
|
313
|
+
if (invoker === action.invoker && bindings === null) return action;
|
|
314
|
+
return {
|
|
315
|
+
...action,
|
|
316
|
+
...invoker ? { invoker } : {},
|
|
317
|
+
...bindings ? { defaultBinding: bindings } : {}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function tuneAction(action, tunings) {
|
|
321
|
+
let out = action;
|
|
322
|
+
for (const t of tunings) out = tuneOnce(out, t);
|
|
323
|
+
return out;
|
|
324
|
+
}
|
|
325
|
+
|
|
285
326
|
// src/interactions/actions/toolOffhand.ts
|
|
286
327
|
var TOOL_OFFHAND_ID = "tool.offhand";
|
|
287
328
|
function offhandKeyFor(trigger) {
|
|
@@ -301,8 +342,12 @@ function offhandKeyFor(trigger) {
|
|
|
301
342
|
}
|
|
302
343
|
}
|
|
303
344
|
function buildToolOffhandBindings(specs) {
|
|
304
|
-
return specs.map(({ toolId, key }) => ({
|
|
345
|
+
return specs.map(({ toolId, key }) => ({
|
|
346
|
+
spec: { ...heldKeySpec(key), phase: BETWEEN_GESTURES },
|
|
347
|
+
opts: { params: { toolId } }
|
|
348
|
+
}));
|
|
305
349
|
}
|
|
350
|
+
var BETWEEN_GESTURES = [{ channel: "*", phase: "initial" }];
|
|
306
351
|
function heldKeySpec(key) {
|
|
307
352
|
const isModifier = [key].flat().some((k) => MODIFIER_KEYS.has(k));
|
|
308
353
|
return { kind: "key-held", key, mods: { ...isModifier ? ANY_MODS : SHIFT_OR_ALT } };
|
|
@@ -409,6 +454,7 @@ function routeArgsForSpec(spec, fallback) {
|
|
|
409
454
|
if ("key" in spec) return Array.isArray(spec.key) ? spec.key : [spec.key];
|
|
410
455
|
if ("fingers" in spec) return [String(spec.fingers)];
|
|
411
456
|
if ("direction" in spec) return [spec.direction ?? fallback];
|
|
457
|
+
if (spec.kind === "hover") return [spec.motion ?? fallback];
|
|
412
458
|
if ("types" in spec) return [spec.types?.length ? spec.types.join("|") : fallback];
|
|
413
459
|
return [fallback];
|
|
414
460
|
}
|
|
@@ -1181,8 +1227,9 @@ function createInFlightGestures() {
|
|
|
1181
1227
|
},
|
|
1182
1228
|
cursor() {
|
|
1183
1229
|
let cursor = null;
|
|
1184
|
-
for (const
|
|
1185
|
-
const
|
|
1230
|
+
for (const [id, handle] of handles) {
|
|
1231
|
+
const action = actions.get(id);
|
|
1232
|
+
const spec = handle.cursor?.() ?? action?.activeCursor ?? action?.cursor;
|
|
1186
1233
|
if (spec !== void 0 && resolveCursor(spec)) cursor = spec;
|
|
1187
1234
|
}
|
|
1188
1235
|
return cursor;
|
|
@@ -2144,6 +2191,6 @@ function dwarn(namespace, ...args) {
|
|
|
2144
2191
|
console.warn(`[${namespace}]`, ...args);
|
|
2145
2192
|
}
|
|
2146
2193
|
|
|
2147
|
-
export { ALWAYS, ActionDisabledReason, COARSE_TARGET_SCALE, DEFAULT_ALLOWED_CAPABILITIES, DEFAULT_DEVICE_PROFILE, DEV2 as DEV, DepNode, INGEST_STRING_MIMES, LONG_PRESS_HAPTIC_MS, NEVER, PREDICATE_TARGET, ScopeNode, TOOL_OFFHAND_ID, actionBindings, assembleEntries, buildDepsFromRequires, buildRouteRegistry, buildRuleCtx, buildToolOffhandBindings, clientToCanvas, clientToCanvasRect, createDepRegistry, createDispatcher, createLongPressStore, depNodeOf, describeRule, dlog, dwarn, evaluate, evaluateActive, evaluateEnabled, findConflicts, heldKeySpec, historyKey, isDebugEnabled, isDev, isTool, itemTypesFromDataTransfer, itemsFromClipboardData, itemsFromDataTransfer, itemsFromFiles, liveScope, makeToolOffhandAction, matchBest, matchSorted, matchSortedWithBarred, matchesKeyBinding, multiTouchGestureId, offhandKeyFor, openPointerSession, pointerGestureId, publishLiveDispatch, pushOwner, recordModeSwitch, reportRouteConflicts, resolveDeviceProfile, resolveParams, routesForSpec, ruleCanHoldIn, rulesExclusive, scopeBindings, targetConsultsAffordance, validateActionDefaultBinding, validateActionId };
|
|
2148
|
-
//# sourceMappingURL=chunk-
|
|
2149
|
-
//# sourceMappingURL=chunk-
|
|
2194
|
+
export { ALWAYS, ActionDisabledReason, COARSE_TARGET_SCALE, DEFAULT_ALLOWED_CAPABILITIES, DEFAULT_DEVICE_PROFILE, DEV2 as DEV, DepNode, INGEST_STRING_MIMES, LONG_PRESS_HAPTIC_MS, NEVER, PREDICATE_TARGET, ScopeNode, TOOL_OFFHAND_ID, actionBindings, assembleEntries, buildDepsFromRequires, buildRouteRegistry, buildRuleCtx, buildToolOffhandBindings, clientToCanvas, clientToCanvasRect, createDepRegistry, createDispatcher, createLongPressStore, depNodeOf, describeRule, dlog, dwarn, evaluate, evaluateActive, evaluateEnabled, findConflicts, heldKeySpec, historyKey, isDebugEnabled, isDev, isTool, itemTypesFromDataTransfer, itemsFromClipboardData, itemsFromDataTransfer, itemsFromFiles, liveScope, makeToolOffhandAction, matchBest, matchSorted, matchSortedWithBarred, matchesKeyBinding, multiTouchGestureId, offhandKeyFor, openPointerSession, pointerGestureId, publishLiveDispatch, pushOwner, recordModeSwitch, reportRouteConflicts, resolveDeviceProfile, resolveParams, routesForSpec, ruleCanHoldIn, rulesExclusive, scopeBindings, targetConsultsAffordance, tuneAction, validateActionDefaultBinding, validateActionId };
|
|
2195
|
+
//# sourceMappingURL=chunk-VCEIQ64H.js.map
|
|
2196
|
+
//# sourceMappingURL=chunk-VCEIQ64H.js.map
|