@weasel-js/routing 1.14.2 → 1.15.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-INZ63QGX.js → chunk-VAUJJODS.js} +201 -4
- package/dist/chunk-VAUJJODS.js.map +1 -0
- package/dist/{chunk-EUCNVGJV.js → chunk-Z2BZBJ7W.js} +6 -3
- package/dist/chunk-Z2BZBJ7W.js.map +1 -0
- package/dist/{chunk-HR5F4LBX.js → chunk-ZUAFANMN.js} +31 -10
- package/dist/chunk-ZUAFANMN.js.map +1 -0
- package/dist/{index-DJ7SxEKS.d.ts → index-D-XFwx8D.d.ts} +1281 -1074
- package/dist/index.d.ts +4 -3
- package/dist/index.js +115 -8
- package/dist/index.js.map +1 -1
- package/dist/{internal-CaJ4viHc.d.ts → internal-nqfC0td8.d.ts} +8 -1
- package/dist/internal.d.ts +7 -6
- package/dist/react.d.ts +27 -9
- package/dist/react.js +120 -19
- package/dist/react.js.map +1 -1
- package/dist/testing/registerAction.d.ts +6 -5
- package/dist/testing/registerAction.js +2 -2
- package/package.json +13 -13
- package/dist/chunk-EUCNVGJV.js.map +0 -1
- package/dist/chunk-HR5F4LBX.js.map +0 -1
- package/dist/chunk-INZ63QGX.js.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { createDepRegistry, ScopeNode, overrideActionBindings, tuneAction,
|
|
1
|
+
import { createDepRegistry, ScopeNode, overrideActionBindings, tuneAction, evaluateEnabled, tunedParams, resolveBindingOverrides, createMenuHost, pushOwner, validateActionId, validateActionDefaultBinding, buildDepsFromRequires, resolveParams } from './chunk-Z2BZBJ7W.js';
|
|
2
2
|
import { createContext, useState, useContext, useEffect, useMemo } from 'react';
|
|
3
3
|
import { isDev, useLatest } from '@weasel-js/react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
import { prefLeaves } from '@weasel-js/prefs';
|
|
6
|
+
import { createEmitter } from '@weasel-js/registry';
|
|
5
7
|
|
|
6
8
|
var DepRegistryContext = createContext(null);
|
|
7
9
|
function DepRegistryProvider({ children }) {
|
|
@@ -39,6 +41,177 @@ function useMenus(defs, owner = null) {
|
|
|
39
41
|
};
|
|
40
42
|
}, [host, defs, owner]);
|
|
41
43
|
}
|
|
44
|
+
function editStackOf(history) {
|
|
45
|
+
const journal = history.activeJournal?.();
|
|
46
|
+
return journal?.isActive() ? journal : history;
|
|
47
|
+
}
|
|
48
|
+
function watchEntry(stack) {
|
|
49
|
+
stack.seal();
|
|
50
|
+
let entry = null;
|
|
51
|
+
let clean = true;
|
|
52
|
+
const off = stack.observe((step) => {
|
|
53
|
+
if (step.kind === "push" && entry === null && step.entries.length === 1) entry = step.entries[0].id;
|
|
54
|
+
else if (!(step.kind === "coalesce" && step.entries[0]?.id === entry && entry !== null)) clean = false;
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
stop: () => {
|
|
58
|
+
off();
|
|
59
|
+
return clean ? entry : null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function soleEntry(stack, run) {
|
|
64
|
+
const watch = watchEntry(stack);
|
|
65
|
+
let out;
|
|
66
|
+
try {
|
|
67
|
+
out = run();
|
|
68
|
+
} catch (err) {
|
|
69
|
+
watch.stop();
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
72
|
+
return { out, entry: watch.stop() };
|
|
73
|
+
}
|
|
74
|
+
function formValues(schema, params) {
|
|
75
|
+
const out = {};
|
|
76
|
+
for (const [path, leaf] of prefLeaves(schema)) out[path] = params[path] !== void 0 ? params[path] : leaf.default;
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
function without(params, keys) {
|
|
80
|
+
const out = {};
|
|
81
|
+
for (const [k, v] of Object.entries(params ?? {})) if (!(k in keys)) out[k] = v;
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
var LastOperationKeeper = class {
|
|
85
|
+
constructor(onSession) {
|
|
86
|
+
this.onSession = onSession;
|
|
87
|
+
}
|
|
88
|
+
onSession;
|
|
89
|
+
held = null;
|
|
90
|
+
busy = false;
|
|
91
|
+
listeners = createEmitter();
|
|
92
|
+
session = /* @__PURE__ */ new Map();
|
|
93
|
+
get = () => this.held?.op ?? null;
|
|
94
|
+
subscribe = (listener) => this.listeners.subscribe(listener);
|
|
95
|
+
dismiss = () => {
|
|
96
|
+
const held = this.held;
|
|
97
|
+
if (!held) return;
|
|
98
|
+
this.held = null;
|
|
99
|
+
held.unobserve();
|
|
100
|
+
this.listeners.emit();
|
|
101
|
+
};
|
|
102
|
+
adjust = (patch) => {
|
|
103
|
+
const held = this.held;
|
|
104
|
+
if (!held || this.busy) return false;
|
|
105
|
+
const { stack } = held;
|
|
106
|
+
const moved = editStackOf(held.history) !== stack;
|
|
107
|
+
if (moved || held.entry !== null && stack.entries().undo.at(-1)?.id !== held.entry) {
|
|
108
|
+
this.dismiss();
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const values = formValues(held.op.schema, { ...held.op.values, ...patch });
|
|
112
|
+
this.busy = true;
|
|
113
|
+
try {
|
|
114
|
+
if (held.entry !== null) stack.undo();
|
|
115
|
+
held.restore?.();
|
|
116
|
+
held.entry = soleEntry(stack, () => {
|
|
117
|
+
try {
|
|
118
|
+
held.rerun(values);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
console.error(`weasel last operation: rerunning "${held.op.id}" threw`, err);
|
|
121
|
+
}
|
|
122
|
+
}).entry;
|
|
123
|
+
} finally {
|
|
124
|
+
this.busy = false;
|
|
125
|
+
}
|
|
126
|
+
held.op = { ...held.op, values };
|
|
127
|
+
this.remember(held.op.id, values);
|
|
128
|
+
held.keep(values);
|
|
129
|
+
this.listeners.emit();
|
|
130
|
+
return true;
|
|
131
|
+
};
|
|
132
|
+
/** The tuning holding `id`'s session params, laid under every other; `null` before it has any. */
|
|
133
|
+
sessionTuning(id) {
|
|
134
|
+
return this.session.get(id) ?? null;
|
|
135
|
+
}
|
|
136
|
+
/** `action` with its run kept as the last operation when it commits one entry: an immediate action declaring
|
|
137
|
+
* `params`, or an ongoing one declaring them whose gesture's handle can `replay`, and in either case only a
|
|
138
|
+
* run its `params` answers a form for. Any other action comes back as it is. */
|
|
139
|
+
wrap(action, host) {
|
|
140
|
+
const { params: form, invoker } = action;
|
|
141
|
+
if (!form || !invoker) return action;
|
|
142
|
+
const schemaOf = typeof form === "function" ? form : () => form;
|
|
143
|
+
if (invoker.timing === "ongoing") return { ...action, invoker: this.ongoing(action.id, action.label, schemaOf, invoker, host) };
|
|
144
|
+
const run = (deps, given) => {
|
|
145
|
+
const history = this.busy ? null : host.history();
|
|
146
|
+
if (!history) return invoker.run(deps, given);
|
|
147
|
+
const resolved = host.paramsOf(action.id, given);
|
|
148
|
+
const schema = schemaOf(resolved);
|
|
149
|
+
if (!schema) return invoker.run(deps, given);
|
|
150
|
+
const restore = host.takeSelection();
|
|
151
|
+
const values = formValues(schema, resolved);
|
|
152
|
+
const stack = editStackOf(history);
|
|
153
|
+
const { out, entry } = soleEntry(stack, () => invoker.run(deps, given));
|
|
154
|
+
if (entry !== null && out !== "pass") {
|
|
155
|
+
const rest = without(given, values);
|
|
156
|
+
const op = { id: action.id, label: schema.name || action.label, schema, values };
|
|
157
|
+
const keep = (v) => host.keep(action.id, v);
|
|
158
|
+
this.hold({ op, entry, stack, history, restore, keep, rerun: (v) => host.rerun(action.id, { ...rest, ...v }) });
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
};
|
|
162
|
+
return { ...action, invoker: { timing: "immediate", run } };
|
|
163
|
+
}
|
|
164
|
+
/** `invoker` with each gesture whose handle can `replay` kept as the last operation when its commit leaves
|
|
165
|
+
* one entry. The selection is taken at the press and the params at the release, as the commit read them. */
|
|
166
|
+
ongoing(id, label, schemaOf, invoker, host) {
|
|
167
|
+
const start = (ctx, opts) => {
|
|
168
|
+
const history = this.busy ? null : host.history();
|
|
169
|
+
const restore = history ? host.takeSelection() : null;
|
|
170
|
+
const stack = history ? editStackOf(history) : null;
|
|
171
|
+
const handle = invoker.start(ctx, opts);
|
|
172
|
+
const { onEnd, replay } = handle;
|
|
173
|
+
if (!history || !stack || !onEnd || !replay) return handle;
|
|
174
|
+
const watch = watchEntry(stack);
|
|
175
|
+
const ended = (endCtx, reason) => {
|
|
176
|
+
let entry = null;
|
|
177
|
+
try {
|
|
178
|
+
onEnd.call(handle, endCtx, reason);
|
|
179
|
+
} finally {
|
|
180
|
+
entry = watch.stop();
|
|
181
|
+
}
|
|
182
|
+
if (reason !== "commit" || entry === null) return;
|
|
183
|
+
const resolved = { ...host.paramsOf(id, resolveParams(opts?.params)), ...handle.params?.() };
|
|
184
|
+
const schema = schemaOf(resolved);
|
|
185
|
+
if (!schema) return;
|
|
186
|
+
const values = formValues(schema, resolved);
|
|
187
|
+
const rest = without(resolved, values);
|
|
188
|
+
const op = { id, label: schema.name || label, schema, values };
|
|
189
|
+
const keep = (v) => host.keep(id, v);
|
|
190
|
+
this.hold({ op, entry, stack, history, restore, keep, rerun: (v) => replay.call(handle, { ...rest, ...v }) });
|
|
191
|
+
};
|
|
192
|
+
return { ...handle, onEnd: ended };
|
|
193
|
+
};
|
|
194
|
+
return { ...invoker, start };
|
|
195
|
+
}
|
|
196
|
+
hold(held) {
|
|
197
|
+
this.held?.unobserve();
|
|
198
|
+
const ended = () => {
|
|
199
|
+
if (!this.busy) this.dismiss();
|
|
200
|
+
};
|
|
201
|
+
const offs = [held.stack.observe(ended)];
|
|
202
|
+
if (held.stack !== held.history) offs.push(held.history.observe(ended));
|
|
203
|
+
const unobserve = () => {
|
|
204
|
+
for (const off of offs) off();
|
|
205
|
+
};
|
|
206
|
+
this.held = { ...held, unobserve };
|
|
207
|
+
this.remember(held.op.id, held.op.values);
|
|
208
|
+
this.listeners.emit();
|
|
209
|
+
}
|
|
210
|
+
remember(id, values) {
|
|
211
|
+
this.session.set(id, { params: { ...values } });
|
|
212
|
+
this.onSession();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
42
215
|
var ActionsContext = createContext(null);
|
|
43
216
|
function depsFor(a, r) {
|
|
44
217
|
if (!r) return {};
|
|
@@ -56,6 +229,7 @@ var ActionsNode = class extends ScopeNode {
|
|
|
56
229
|
constructor(parent, descends, contextDeps) {
|
|
57
230
|
super(parent, descends);
|
|
58
231
|
this.contextDeps = contextDeps;
|
|
232
|
+
this.lastOperation = parent ? parent.lastOperation : new LastOperationKeeper(() => this.changed());
|
|
59
233
|
NODES.set(this.registry, this);
|
|
60
234
|
}
|
|
61
235
|
contextDeps;
|
|
@@ -69,6 +243,9 @@ var ActionsNode = class extends ScopeNode {
|
|
|
69
243
|
host = null;
|
|
70
244
|
/** Called on `activate`, so a scope's dep and tool nodes move with it. */
|
|
71
245
|
onActivate = [];
|
|
246
|
+
/** The tree's last operation, kept at its root. */
|
|
247
|
+
lastOperation;
|
|
248
|
+
opHost = null;
|
|
72
249
|
resolve(id) {
|
|
73
250
|
for (const n of this.chain()) {
|
|
74
251
|
if (n.muted.has(id)) return void 0;
|
|
@@ -84,12 +261,32 @@ var ActionsNode = class extends ScopeNode {
|
|
|
84
261
|
const stack = n.tunings.get(id);
|
|
85
262
|
if (stack) tunings.unshift(...stack);
|
|
86
263
|
}
|
|
264
|
+
const session = this.lastOperation.sessionTuning(id);
|
|
265
|
+
if (session) tunings.unshift(session);
|
|
87
266
|
return tunings;
|
|
88
267
|
}
|
|
89
268
|
/** `a` under every tuning for its id from the root down to here. */
|
|
90
269
|
tuned(a) {
|
|
91
270
|
const tunings = this.tuningsOf(a.id);
|
|
92
|
-
|
|
271
|
+
const tuned = overrideActionBindings(tunings.length ? tuneAction(a, tunings) : a, this.overridesHere());
|
|
272
|
+
return this.lastOperation.wrap(tuned, this.opHost ??= this.lastOperationHost());
|
|
273
|
+
}
|
|
274
|
+
/** How the last operation reads and reruns what ran in this scope. */
|
|
275
|
+
lastOperationHost() {
|
|
276
|
+
return {
|
|
277
|
+
history: () => this.deps()?.get("history") ?? null,
|
|
278
|
+
takeSelection: () => this.deps()?.get("selectionSnapshot")?.take() ?? null,
|
|
279
|
+
paramsOf: (id, given) => tunedParams(this.tuningsOf(id), given),
|
|
280
|
+
rerun: (id, params) => {
|
|
281
|
+
const a = this.resolve(id);
|
|
282
|
+
if (a?.invoker?.timing !== "immediate") return;
|
|
283
|
+
const deps = depsFor(a, this.deps());
|
|
284
|
+
if (evaluateEnabled(a, deps, pointOf(params)).enabled) a.invoker.run(deps, params);
|
|
285
|
+
},
|
|
286
|
+
keep: (id, params) => {
|
|
287
|
+
for (const t of this.tuningsOf(id)) t.keep?.(params);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
93
290
|
}
|
|
94
291
|
/** Every binding override from the root down to here, read into specs. */
|
|
95
292
|
overridesHere() {
|
|
@@ -321,5 +518,5 @@ function useAction(action) {
|
|
|
321
518
|
}
|
|
322
519
|
|
|
323
520
|
export { ActionsContext, ActionsNode, ActionsProvider, DepRegistryContext, DepRegistryProvider, MenuHostContext, actionsNodeOf, useAction, useActionsRegistry, useDepRegistry, useDepSource, useMenuHost, useMenus, useOptionalDepRegistry };
|
|
324
|
-
//# sourceMappingURL=chunk-
|
|
325
|
-
//# sourceMappingURL=chunk-
|
|
521
|
+
//# sourceMappingURL=chunk-VAUJJODS.js.map
|
|
522
|
+
//# sourceMappingURL=chunk-VAUJJODS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/actions/depRegistry.tsx","../src/menus/MenuHostContext.tsx","../src/interactions/actions/lastOperation.ts","../src/interactions/actions/ActionsProvider.tsx"],"names":["createContext","useContext","useEffect","useLatest","jsx"],"mappings":";;;;;;;AAaO,IAAM,kBAAA,GAAqB,cAAkC,IAAI;AAIjE,SAAS,mBAAA,CAAoB,EAAE,QAAA,EAAS,EAA4B;AACzE,EAAA,MAAM,CAAC,QAAQ,CAAA,GAAI,QAAA,CAAS,iBAAiB,CAAA;AAC7C,EAAA,2BAAQ,kBAAA,CAA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C,EAAA,MAAM,SAAA,GAAYG,UAA8B,MAAM,CAAA;AACtD,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,MAAM,IAAI,WAAA,CAAY,IAAA,EAAM,IAAA,EAAM,MAAM,SAAA,CAAU,OAAO,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AAC5F,EAAA,uBACEC,GAAAA,CAAC,cAAA,CAAe,UAAf,EAAwB,KAAA,EAAO,KAAK,QAAA,EACnC,QAAA,kBAAAA,GAAAA,CAAC,eAAA,CAAgB,UAAhB,EAAyB,KAAA,EAAO,KAAK,QAAA,EAAS,EAAI,UAAS,CAAA,EAC9D,CAAA;AAEJ;AAEA,IAAM,SAAS,KAAA,EAAM;AAKd,SAAS,kBAAA,GAA6C;AAC3D,EAAA,OAAOH,WAAW,cAAc,CAAA;AAClC;AAQO,SAAS,UAAU,MAAA,EAAsB;AAC9C,EAAA,MAAM,MAAM,kBAAA,EAAmB;AAC/B,EAAAC,UAAU,MAAM;AACd,IAAA,IAAI,CAAC,GAAA,EAAK;AACR,MAAA,IAAI,MAAA,EAAQ;AACV,QAAA,OAAA,CAAQ,IAAA;AAAA,UACN,CAAA,WAAA,EAAc,OAAO,EAAE,CAAA,wGAAA;AAAA,SACzB;AAAA,MACF;AACA,MAAA;AAAA,IACF;AACA,IAAA,OAAO,GAAA,CAAI,SAAS,MAAM,CAAA;AAAA,EAC5B,CAAA,EAAG,CAAC,GAAA,EAAK,MAAM,CAAC,CAAA;AAClB","file":"chunk-VAUJJODS.js","sourcesContent":["/** The React seam over the dep registry in `./depNode`: its provider and hooks. */\nimport {\n createContext, useContext, useEffect, useState,\n type ReactNode,\n} from 'react';\nimport type { DepSchema, DepName } from '../../index';\nimport { createDepRegistry, type DepRegistry, type DepSource } from './depNode';\nimport { useLatest } from '@weasel-js/react';\n\nexport type { DepSchema, DepName, DepRegistry, DepSource };\nexport { DepNode, depNodeOf, createDepRegistry } from './depNode';\n\n/** @internal The context `<InputScope>` provides a scope's dep registry through. */\nexport const DepRegistryContext = createContext<DepRegistry | null>(null);\n\n/** Provides the dep registry for a canvas. `<SceneCanvas>` mounts one; a\n * consumer registering its own dep sources must be inside it. */\nexport function DepRegistryProvider({ children }: { children: ReactNode }) {\n const [registry] = useState(createDepRegistry);\n return <DepRegistryContext.Provider value={registry}>{children}</DepRegistryContext.Provider>;\n}\n\n/** The dep registry in scope. Throws outside a `<DepRegistryProvider>`. */\nexport function useDepRegistry(): DepRegistry {\n const r = useContext(DepRegistryContext);\n if (r === null) {\n throw new Error('useDepRegistry: no DepRegistryProvider in scope. Wrap your tree with <DepRegistryProvider> (typically inside <SceneCanvas>).');\n }\n return r;\n}\n\n/**\n * Like `useDepRegistry`, but returns `null` when no `<DepRegistryProvider>` is\n * in scope instead of throwing. Used by `useStandardActions` to preserve its\n * silent-no-op contract when neither provider is present.\n */\nexport function useOptionalDepRegistry(): DepRegistry | null {\n return useContext(DepRegistryContext);\n}\n\n/** Register a live source for `name` for the lifetime of the calling\n * component. The `source` thunk is called at dispatch time and should\n * return the latest value; its `below` reads the source it displaced. */\nexport function useDepSource<K extends DepName>(name: K, source: DepSource<K>) {\n const registry = useDepRegistry();\n const sourceRef = useLatest(source);\n useEffect(() => {\n return registry.register(name, (below) => sourceRef.current(below));\n }, [name, registry, sourceRef]);\n}\n","import { createContext, useContext, useEffect } from 'react';\nimport type { MenuHost } from './menuHost';\nimport type { MenuDef } from './types';\n\nexport const MenuHostContext = createContext<MenuHost | null>(null);\n\n/** The menu host in scope: the nearest `<ActionsProvider>`'s, else the one a\n * canvas with no provider above it makes. Null outside both. */\nexport function useMenuHost(): MenuHost | null {\n return useContext(MenuHostContext);\n}\n\n/** Declare menus for the calling component's lifetime. Memoize `defs`. */\nexport function useMenus(defs: readonly MenuDef[], owner: string | null = null): void {\n const host = useMenuHost();\n useEffect(() => {\n if (!host) return;\n const releases = defs.map((d) => host.define(d, owner));\n return () => { for (const r of releases) r(); };\n }, [host, defs, owner]);\n}\n","/**\n * The last operation: the latest run of an action that declares `params` and\n * committed one history entry, kept so its params can be changed after the\n * fact. A change undoes that entry and runs the action again in its place: an\n * immediate action is run again with the params it was handed, and a gesture\n * is replayed by its handle (`OngoingHandle.replay`).\n */\nimport type { History } from '@weasel-js/history';\nimport { prefLeaves, type PrefGroup } from '@weasel-js/prefs';\nimport { createEmitter } from '@weasel-js/registry';\nimport type { Action } from './action';\nimport { resolveParams, type ImmediateInvoker, type OngoingHandle, type OngoingInvoker } from './invoker';\nimport type { ActionTuning } from './tuning';\n\n/** One operation that can still be adjusted. */\nexport interface LastOperation {\n id: string;\n /** What a panel titles it: the form's name, else the action's label. */\n label: string;\n /** The action's `params` form. */\n schema: PrefGroup;\n /** What it ran with, one value per leaf of `schema`, by the leaf's path. */\n values: Readonly<Record<string, unknown>>;\n}\n\n/** The last operation of one actions tree, and the two things to do with it. */\nexport interface LastOperationStore {\n /** The operation, or `null` once anything else reached the history, or it was dismissed. */\n get(): LastOperation | null;\n subscribe(listener: () => void): () => void;\n /**\n * Undo the operation's entry, put back the selection it ran on, and run it again with `patch` laid over its\n * values (a gesture is replayed by its handle), keeping the entry that makes in place of the old one: the\n * history, or the journal open on it, still holds one entry for it. The merged values become the action's\n * params for the rest of the session, under any tuning, and each tuning that keeps them is handed them\n * (`ActionTuning.keep`). Returns whether it ran.\n */\n adjust(patch: Readonly<Record<string, unknown>>): boolean;\n /** Forget the operation; the scene and the history stay as they are. */\n dismiss(): void;\n}\n\n/** Every selection a host holds, captured: calling what `take` returns puts all of it back. */\nexport interface SelectionSnapshotDep {\n take(): () => void;\n}\n\n/** What the store reads from the scope an operation ran in. */\nexport interface LastOperationHost {\n history(): History | null;\n takeSelection(): (() => void) | null;\n /** The params a run of `id` handed `given` starts with: every tuning's, `given` laid over them. */\n paramsOf(id: string, given: Record<string, unknown> | undefined): Record<string, unknown>;\n /** Run the action live for `id` here with `params`, as `trigger` would. */\n rerun(id: string, params: Record<string, unknown>): void;\n /** Hand `params`, which a panel change made `id`'s for the session, to each tuning of `id` that keeps them. */\n keep(id: string, params: Readonly<Record<string, unknown>>): void;\n}\n\n/** Where an edit lands: the history, or the journal open on it. */\ntype EditStack = Pick<History, 'seal' | 'observe' | 'entries' | 'undo'>;\n\n/** The stack edits on `history` land on now: its active journal while one is open, which takes the entries an\n * edit makes until it commits them to `history` as one. */\nfunction editStackOf(history: History): EditStack {\n const journal = history.activeJournal?.();\n return journal?.isActive() ? journal : history;\n}\n\ninterface Held {\n op: LastOperation;\n entry: number | null;\n /** The stack the operation's entry is on. */\n stack: EditStack;\n /** The history that stack belongs to, any change on which ends the operation. */\n history: History;\n restore: (() => void) | null;\n /** Run the operation again with `values`, laid over what its first run was handed beyond them, such as the\n * point a binding carried. */\n rerun: (values: Record<string, unknown>) => void;\n /** Hand `values` to the tunings that keep the action's params. */\n keep: (values: Readonly<Record<string, unknown>>) => void;\n unobserve: () => void;\n}\n\n/** Watch `stack` from now: `stop` answers the id of the entry pushed meanwhile when exactly one was, later\n * pushes having coalesced into it, and nothing else changed the history. Seals first, so the entry stands alone\n * rather than coalescing into the one before it. */\nfunction watchEntry(stack: EditStack): { stop(): number | null } {\n stack.seal();\n let entry: number | null = null;\n let clean = true;\n const off = stack.observe((step) => {\n if (step.kind === 'push' && entry === null && step.entries.length === 1) entry = step.entries[0]!.id;\n else if (!(step.kind === 'coalesce' && step.entries[0]?.id === entry && entry !== null)) clean = false;\n });\n return {\n stop: () => {\n off();\n return clean ? entry : null;\n },\n };\n}\n\n/** Run `run`, and the id of the entry it pushed as {@link watchEntry} counts it. */\nfunction soleEntry<T>(stack: EditStack, run: () => T): { out: T; entry: number | null } {\n const watch = watchEntry(stack);\n let out: T;\n try {\n out = run();\n } catch (err) {\n watch.stop();\n throw err;\n }\n return { out, entry: watch.stop() };\n}\n\n/** `params`, reduced to the leaves of `schema`, each filled from its default where `params` has none. */\nfunction formValues(schema: PrefGroup, params: Readonly<Record<string, unknown>>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [path, leaf] of prefLeaves(schema)) out[path] = params[path] !== undefined ? params[path] : leaf.default;\n return out;\n}\n\nfunction without(params: Record<string, unknown> | undefined, keys: Readonly<Record<string, unknown>>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(params ?? {})) if (!(k in keys)) out[k] = v;\n return out;\n}\n\n/** The store one actions tree keeps at its root. `onSession` is told when an action's session params change. */\nexport class LastOperationKeeper implements LastOperationStore {\n private held: Held | null = null;\n private busy = false;\n private readonly listeners = createEmitter();\n private readonly session = new Map<string, ActionTuning>();\n\n constructor(private readonly onSession: () => void) {}\n\n readonly get = (): LastOperation | null => this.held?.op ?? null;\n\n readonly subscribe = (listener: () => void): (() => void) => this.listeners.subscribe(listener);\n\n readonly dismiss = (): void => {\n const held = this.held;\n if (!held) return;\n this.held = null;\n held.unobserve();\n this.listeners.emit();\n };\n\n readonly adjust = (patch: Readonly<Record<string, unknown>>): boolean => {\n const held = this.held;\n if (!held || this.busy) return false;\n const { stack } = held;\n const moved = editStackOf(held.history) !== stack;\n if (moved || (held.entry !== null && stack.entries().undo.at(-1)?.id !== held.entry)) {\n this.dismiss();\n return false;\n }\n const values = formValues(held.op.schema, { ...held.op.values, ...patch });\n this.busy = true;\n try {\n if (held.entry !== null) stack.undo();\n held.restore?.();\n held.entry = soleEntry(stack, () => {\n try {\n held.rerun(values);\n } catch (err) {\n console.error(`weasel last operation: rerunning \"${held.op.id}\" threw`, err);\n }\n }).entry;\n } finally {\n this.busy = false;\n }\n held.op = { ...held.op, values };\n this.remember(held.op.id, values);\n held.keep(values);\n this.listeners.emit();\n return true;\n };\n\n /** The tuning holding `id`'s session params, laid under every other; `null` before it has any. */\n sessionTuning(id: string): ActionTuning | null {\n return this.session.get(id) ?? null;\n }\n\n /** `action` with its run kept as the last operation when it commits one entry: an immediate action declaring\n * `params`, or an ongoing one declaring them whose gesture's handle can `replay`, and in either case only a\n * run its `params` answers a form for. Any other action comes back as it is. */\n wrap(action: Action, host: LastOperationHost): Action {\n const { params: form, invoker } = action;\n if (!form || !invoker) return action;\n const schemaOf = typeof form === 'function' ? form : () => form;\n if (invoker.timing === 'ongoing') return { ...action, invoker: this.ongoing(action.id, action.label, schemaOf, invoker, host) };\n const run: ImmediateInvoker['run'] = (deps, given) => {\n const history = this.busy ? null : host.history();\n if (!history) return invoker.run(deps, given);\n const resolved = host.paramsOf(action.id, given);\n const schema = schemaOf(resolved);\n if (!schema) return invoker.run(deps, given);\n const restore = host.takeSelection();\n const values = formValues(schema, resolved);\n const stack = editStackOf(history);\n const { out, entry } = soleEntry(stack, () => invoker.run(deps, given));\n if (entry !== null && out !== 'pass') {\n const rest = without(given, values);\n const op = { id: action.id, label: schema.name || action.label, schema, values };\n const keep = (v: Readonly<Record<string, unknown>>) => host.keep(action.id, v);\n this.hold({ op, entry, stack, history, restore, keep, rerun: (v) => host.rerun(action.id, { ...rest, ...v }) });\n }\n return out;\n };\n return { ...action, invoker: { timing: 'immediate', run } };\n }\n\n /** `invoker` with each gesture whose handle can `replay` kept as the last operation when its commit leaves\n * one entry. The selection is taken at the press and the params at the release, as the commit read them. */\n private ongoing(id: string, label: string, schemaOf: (params: Readonly<Record<string, unknown>>) => PrefGroup | null, invoker: OngoingInvoker, host: LastOperationHost): OngoingInvoker {\n const start: OngoingInvoker['start'] = (ctx, opts) => {\n const history = this.busy ? null : host.history();\n const restore = history ? host.takeSelection() : null;\n // Read before `start`, which may open a journal of its own that lands on this stack as one entry.\n const stack = history ? editStackOf(history) : null;\n const handle = invoker.start(ctx, opts);\n const { onEnd, replay } = handle;\n if (!history || !stack || !onEnd || !replay) return handle;\n const watch = watchEntry(stack);\n const ended: OngoingHandle['onEnd'] = (endCtx, reason) => {\n let entry: number | null = null;\n try {\n onEnd.call(handle, endCtx, reason);\n } finally {\n entry = watch.stop();\n }\n if (reason !== 'commit' || entry === null) return;\n const resolved = { ...host.paramsOf(id, resolveParams(opts?.params)), ...handle.params?.() };\n const schema = schemaOf(resolved);\n if (!schema) return;\n const values = formValues(schema, resolved);\n const rest = without(resolved, values);\n const op = { id, label: schema.name || label, schema, values };\n const keep = (v: Readonly<Record<string, unknown>>) => host.keep(id, v);\n this.hold({ op, entry, stack, history, restore, keep, rerun: (v) => replay.call(handle, { ...rest, ...v }) });\n };\n return { ...handle, onEnd: ended };\n };\n return { ...invoker, start };\n }\n\n private hold(held: Omit<Held, 'unobserve'>): void {\n this.held?.unobserve();\n const ended = () => {\n if (!this.busy) this.dismiss();\n };\n const offs = [held.stack.observe(ended)];\n if (held.stack !== held.history) offs.push(held.history.observe(ended));\n const unobserve = () => { for (const off of offs) off(); };\n this.held = { ...held, unobserve };\n this.remember(held.op.id, held.op.values);\n this.listeners.emit();\n }\n\n private remember(id: string, values: Readonly<Record<string, unknown>>): void {\n this.session.set(id, { params: { ...values } });\n this.onSession();\n }\n}\n","/**\n * The React half of the actions registry: the context, the tree node that\n * owns each id → descriptor stack, the providers that mount nodes, and the two\n * hooks. The store contract it implements is in `registry.ts`.\n */\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport type { Action } from './action';\nimport { evaluateEnabled } from './actionEnabled';\nimport { useLatest } from '@weasel-js/react';\nimport {\n useOptionalDepRegistry,\n type DepRegistry,\n type DepName,\n} from './depRegistry';\nimport { buildDepsFromRequires } from './buildDeps';\nimport type { ActionDeps, WorldPoint } from './invoker';\nimport type { ImmediateParams } from '../dispatcher/inputFacts';\nimport type { Dispatcher } from '../dispatcher/dispatcher';\nimport { validateActionId, validateActionDefaultBinding, type ActionsRegistry } from './registry';\nimport { createMenuHost, type MenuHost } from '../../menus/menuHost';\nimport { MenuHostContext } from '../../menus/MenuHostContext';\nimport { pushOwner, ScopeNode } from './scopeNode';\nimport { tuneAction, tunedParams, type ActionTuning } from './tuning';\nimport { overrideActionBindings, resolveBindingOverrides, type BindingOverrides, type ResolvedBindingOverrides } from './bindingOverrides';\nimport { isDev } from '@weasel-js/react';\nimport { LastOperationKeeper, type LastOperationHost } from './lastOperation';\nimport type { History } from '@weasel-js/history';\n\n/** @internal Provided by `<ActionsProvider>`, `<InputScope>` and `<Yoke>`. */\nexport const ActionsContext = createContext<ActionsRegistry | null>(null);\n\n/** The deps an action is invoked with: its declared `requires` when it has\n * one, the legacy fixed bag otherwise. The fixed bag has no `applyOps`, so an\n * action that needs the consumer's history must declare it. */\nfunction depsFor(a: Action, r: DepRegistry | null): ActionDeps {\n if (!r) return {};\n if (a.requires) return buildDepsFromRequires(a, r);\n return {\n selection: r.get('selection' as DepName),\n scene: r.get('scene' as DepName),\n history: r.get('history' as DepName),\n view: r.get('view' as DepName),\n activeTool: r.get('activeTool'),\n booleansAdapter: r.get('booleansAdapter' as DepName),\n } as ActionDeps;\n}\n\n/**\n * One node of the actions tree: the actions registered at it, over its\n * parent's. Each id holds a stack of registrants, newest live, so a displaced\n * registrant is restored when the one above it leaves. Every read the registry\n * answers — `list`, `trigger`, `begin` — starts at the node's leaf.\n */\nexport class ActionsNode extends ScopeNode<ActionsNode> {\n private readonly actions = new Map<string, Action[]>();\n private readonly muted = new Map<string, number>();\n private readonly tunings = new Map<string, ActionTuning[]>();\n private readonly overrides: BindingOverrides[] = [];\n private overrideCache: { version: number; resolved: ResolvedBindingOverrides } | null = null;\n private readonly dispatchers: Dispatcher[] = [];\n private cache: { version: number; leaf: ActionsNode; list: readonly Action[] } | null = null;\n private host: MenuHost | null = null;\n /** Called on `activate`, so a scope's dep and tool nodes move with it. */\n readonly onActivate: (() => void)[] = [];\n /** The tree's last operation, kept at its root. */\n readonly lastOperation: LastOperationKeeper;\n private opHost: LastOperationHost | null = null;\n\n constructor(\n parent: ActionsNode | null,\n descends: boolean,\n private readonly contextDeps: () => DepRegistry | null,\n ) {\n super(parent, descends);\n this.lastOperation = parent ? parent.lastOperation : new LastOperationKeeper(() => this.changed());\n NODES.set(this.registry, this);\n }\n\n private resolve(id: string): Action | undefined {\n for (const n of this.chain()) {\n if (n.muted.has(id)) return undefined;\n const a = n.actions.get(id)?.at(-1);\n if (a) return this.tuned(a);\n }\n return undefined;\n }\n\n /** Every tuning for `id` from the root down to here, root first. */\n private tuningsOf(id: string): ActionTuning[] {\n const tunings: ActionTuning[] = [];\n for (const n of this.chain()) {\n const stack = n.tunings.get(id);\n if (stack) tunings.unshift(...stack);\n }\n const session = this.lastOperation.sessionTuning(id);\n if (session) tunings.unshift(session);\n return tunings;\n }\n\n /** `a` under every tuning for its id from the root down to here. */\n private tuned(a: Action): Action {\n const tunings = this.tuningsOf(a.id);\n const tuned = overrideActionBindings(tunings.length ? tuneAction(a, tunings) : a, this.overridesHere());\n return this.lastOperation.wrap(tuned, this.opHost ??= this.lastOperationHost());\n }\n\n /** How the last operation reads and reruns what ran in this scope. */\n private lastOperationHost(): LastOperationHost {\n return {\n history: () => (this.deps()?.get('history' as DepName) as History | undefined) ?? null,\n takeSelection: () => this.deps()?.get('selectionSnapshot')?.take() ?? null,\n paramsOf: (id, given) => tunedParams(this.tuningsOf(id), given),\n rerun: (id, params) => {\n const a = this.resolve(id);\n if (a?.invoker?.timing !== 'immediate') return;\n const deps = depsFor(a, this.deps());\n if (evaluateEnabled(a, deps, pointOf(params)).enabled) a.invoker.run(deps, params);\n },\n keep: (id, params) => { for (const t of this.tuningsOf(id)) t.keep?.(params); },\n };\n }\n\n /** Every binding override from the root down to here, read into specs. */\n private overridesHere(): ResolvedBindingOverrides {\n const cached = this.overrideCache;\n if (cached && cached.version === this.tree.version) return cached.resolved;\n const maps: BindingOverrides[] = [];\n for (const n of this.chain()) maps.unshift(...n.overrides);\n const resolved = resolveBindingOverrides(maps);\n this.overrideCache = { version: this.tree.version, resolved };\n return resolved;\n }\n\n private snapshot(): readonly Action[] {\n const leaf = this.start();\n const cached = this.cache;\n if (cached && cached.version === this.tree.version && cached.leaf === leaf) return cached.list;\n const ids = new Set<string>();\n for (const n of leaf.chain()) for (const id of n.actions.keys()) ids.add(id);\n const out: Action[] = [];\n for (const id of ids) {\n const a = leaf.resolve(id);\n if (a) out.push(a);\n }\n const list = Object.freeze(out);\n this.cache = { version: this.tree.version, leaf, list };\n return list;\n }\n\n private deps(): DepRegistry | null {\n for (const n of this.chain()) {\n const r = n.contextDeps();\n if (r) return r;\n }\n return null;\n }\n\n /** The actions registered at this node itself, live, unmuted and tuned —\n * none from the scopes below it. */\n ownActions(): readonly Action[] {\n const out: Action[] = [];\n for (const [id, stack] of this.actions) {\n if (stack.length > 0 && !this.muted.has(id)) out.push(this.tuned(stack.at(-1)!));\n }\n return out;\n }\n\n /** The deps `a` is invoked with from here: the active scope's, which is\n * what `trigger` and `begin` run it with. */\n depsOf(a: Action): ActionDeps {\n return depsFor(a, this.start().deps());\n }\n\n /** The menu host of this node's tree, made by its root on first ask. Rows\n * resolve and run against the active scope, as chrome's `trigger` does. */\n menuHost(): MenuHost {\n const root = [...this.chain()].at(-1)!;\n return root.host ??= createMenuHost({\n actions: () => root.registry.list(),\n depsFor: (a) => root.depsOf(a),\n trigger: (id, params) => root.registry.trigger(id, params),\n activeTool: () => root.start().deps()?.get('activeTool')?.active ?? null,\n });\n }\n\n private dispatcher(): Dispatcher | null {\n for (const n of this.chain()) {\n const d = n.dispatchers.at(-1);\n if (d) return d;\n }\n return null;\n }\n\n override activate(): void {\n keyHolder = this;\n super.activate();\n for (const f of this.onActivate) f();\n }\n\n readonly registry: ActionsRegistry = {\n register: (action: Action) => {\n validateActionId(action.id);\n validateActionDefaultBinding(action);\n const stack = this.actions.get(action.id);\n if (stack) stack.push(action);\n else this.actions.set(action.id, [action]);\n this.changed();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const cur = this.actions.get(action.id);\n if (!cur) return;\n // Our own entry, wherever it now sits: a registrant that was already\n // displaced must take itself out without disturbing the one above it.\n const i = cur.lastIndexOf(action);\n if (i === -1) return;\n cur.splice(i, 1);\n // An emptied stack holds the id's place in registration order until\n // the tick ends, so a release followed at once by a register — what\n // `useAction` does when its action object changes — keeps its slot.\n if (cur.length === 0) {\n queueMicrotask(() => {\n if (cur.length === 0 && this.actions.get(action.id) === cur) this.actions.delete(action.id);\n });\n }\n this.changed();\n };\n },\n unregister: (id: string) => {\n if (this.actions.delete(id)) this.changed();\n },\n mute: (id: string) => {\n this.muted.set(id, (this.muted.get(id) ?? 0) + 1);\n this.changed();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const held = this.muted.get(id);\n if (held === undefined) return;\n if (held > 1) this.muted.set(id, held - 1);\n else this.muted.delete(id);\n this.changed();\n };\n },\n tune: (id: string, tuning: ActionTuning) => {\n let stack = this.tunings.get(id);\n if (!stack) this.tunings.set(id, (stack = []));\n const release = pushOwner(stack, tuning);\n this.changed();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n release();\n if (stack.length === 0) this.tunings.delete(id);\n this.changed();\n };\n },\n paramsOf: (id: string, given?: Record<string, unknown>) => tunedParams(this.tuningsOf(id), given),\n overrideBindings: (overrides: BindingOverrides) => {\n const release = pushOwner(this.overrides, overrides);\n this.changed();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n release();\n this.changed();\n };\n },\n bindingOverrides: () => this.start().overridesHere(),\n list: () => this.snapshot(),\n trigger: (id: string, params?: Record<string, unknown>) => {\n const leaf = this.start();\n const a = leaf.resolve(id);\n if (!a?.invoker || a.invoker.timing !== 'immediate') return false;\n const deps = leaf.depsOf(a);\n if (!evaluateEnabled(a, deps, pointOf(params)).enabled) return false;\n try {\n if (a.invoker.run(deps, params) === 'pass') return false;\n } catch (err) {\n console.error(`weasel ActionsRegistry: action \"${id}\" threw`, err);\n }\n return true;\n },\n preview: (id: string, params?: Record<string, unknown>) => {\n const leaf = this.start();\n const a = leaf.resolve(id);\n if (!a?.preview) return NO_PREVIEW;\n const deps = leaf.depsOf(a);\n if (!evaluateEnabled(a, deps, pointOf(params)).enabled) return NO_PREVIEW;\n let stop: (() => void) | void;\n try {\n stop = a.preview(deps, params);\n } catch (err) {\n console.error(`weasel ActionsRegistry: preview of \"${id}\" threw`, err);\n return NO_PREVIEW;\n }\n if (typeof stop !== 'function') return NO_PREVIEW;\n let down = false;\n return () => {\n if (down) return;\n down = true;\n try {\n stop();\n } catch (err) {\n console.error(`weasel ActionsRegistry: preview of \"${id}\" threw as it ended`, err);\n }\n };\n },\n subscribe: (listener: () => void) => this.tree.listeners.subscribe(listener),\n setDispatcher: (d: Dispatcher | null) => pushOwner(this.dispatchers, d),\n begin: (id: string, params?: Record<string, unknown>) => {\n const leaf = this.start();\n const a = leaf.resolve(id);\n const disp = leaf.dispatcher();\n if (!a || !disp) return null;\n return disp.beginUiOngoing(id, leaf.depsOf(a), params);\n },\n activate: () => this.activate(),\n isActive: () => this.isActive(),\n holdsKeys: () => keyHolder === this,\n dropKeys: () => { if (keyHolder === this) keyHolder = null; },\n };\n}\n\nconst NO_PREVIEW = (): void => {};\n\n/** The world point a trigger's params carry, if any. */\nfunction pointOf(params: Record<string, unknown> | undefined): WorldPoint | undefined {\n return (params as ImmediateParams | undefined)?.world;\n}\n\n/** The node last activated on the page, across every tree: where a key that\n * reaches the page goes. Null until something is pressed or scrolled in. */\nlet keyHolder: ActionsNode | null = null;\n\nconst NODES = new WeakMap<ActionsRegistry, ActionsNode>();\n\n/** The tree node behind `registry`, when it is one of ours. */\nexport function actionsNodeOf(registry: ActionsRegistry | null): ActionsNode | null {\n return registry ? (NODES.get(registry) ?? null) : null;\n}\n\n/**\n * Mounts a root `ActionsRegistry` for its lifetime. Children call\n * `useActionsRegistry()` or `useAction()` to participate. Mounts no input\n * listener of its own — the gesture dispatcher owns input.\n */\nexport function ActionsProvider({ children }: { children: ReactNode }): ReactElement {\n // `trigger` consults the dep registry in scope, so actions can be fired\n // imperatively from ActionBar / palette callers.\n const depReg = useOptionalDepRegistry();\n const depRegRef = useLatest<DepRegistry | null>(depReg);\n const node = useMemo(() => new ActionsNode(null, true, () => depRegRef.current), [depRegRef]);\n return (\n <ActionsContext.Provider value={node.registry}>\n <MenuHostContext.Provider value={node.menuHost()}>{children}</MenuHostContext.Provider>\n </ActionsContext.Provider>\n );\n}\n\nconst IS_DEV = isDev();\n\n/**\n * Returns the `ActionsRegistry` in scope, or `null` when there is none.\n */\nexport function useActionsRegistry(): ActionsRegistry | null {\n return useContext(ActionsContext);\n}\n\n/**\n * Register an `Action` for the lifetime of the calling component. No-op (with\n * a dev-only warning) when no `ActionsProvider` is in scope. Re-registers on\n * `action` reference change (consumers should memoize stable identities to\n * avoid churn).\n */\nexport function useAction(action: Action): void {\n const reg = useActionsRegistry();\n useEffect(() => {\n if (!reg) {\n if (IS_DEV) {\n console.warn(\n `useAction(\"${action.id}\"): no <ActionsProvider> is in scope, so the action was not registered and its bindings will never fire.`,\n );\n }\n return;\n }\n return reg.register(action);\n }, [reg, action]);\n}\n"]}
|
|
@@ -353,7 +353,7 @@ function validateActionDefaultBinding(action) {
|
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
// src/interactions/actions/
|
|
356
|
+
// src/interactions/actions/bindingOpts.ts
|
|
357
357
|
function resolveParams(params) {
|
|
358
358
|
if (params === void 0) return void 0;
|
|
359
359
|
return typeof params === "function" ? params() : params;
|
|
@@ -690,6 +690,7 @@ function unionRows(draw, leaf, key, path, off) {
|
|
|
690
690
|
key: `${path}/${v2}`,
|
|
691
691
|
label: variant2.name,
|
|
692
692
|
checked: v2 === current?.[0],
|
|
693
|
+
radio: true,
|
|
693
694
|
disabled: frozen || !onChange,
|
|
694
695
|
run: onChange ? () => onChange(path, prefVariantDefault(leaf, v2)) : noop
|
|
695
696
|
}));
|
|
@@ -713,6 +714,7 @@ function fieldRows(draw, leaf, key, path, off) {
|
|
|
713
714
|
key: `${path}/${p}`,
|
|
714
715
|
label: l.name || p,
|
|
715
716
|
checked: held === p,
|
|
717
|
+
radio: true,
|
|
716
718
|
disabled: off || leaf.readout === true || !onChange,
|
|
717
719
|
run: onChange ? () => onChange(path, p) : noop
|
|
718
720
|
});
|
|
@@ -848,6 +850,7 @@ function enumRows(ctx, leaf, key, path, off) {
|
|
|
848
850
|
key: `${key}/${o.value}`,
|
|
849
851
|
label: o.label,
|
|
850
852
|
checked: o.value === current,
|
|
853
|
+
radio: true,
|
|
851
854
|
disabled: off || o.disabled === true,
|
|
852
855
|
run: () => onChange(path, write(o.value))
|
|
853
856
|
})),
|
|
@@ -1099,5 +1102,5 @@ function createMenuHost(src) {
|
|
|
1099
1102
|
}
|
|
1100
1103
|
|
|
1101
1104
|
export { ActionDisabledReason, DepNode, NO_OVERRIDES, ScopeNode, actionBindings, actionCursor, actionItemTitle, actionItems, actionSettingsParams, actionShortcuts, bindingId, buildDepsFromRequires, createDepRegistry, createMenuHost, depNodeOf, evaluateActive, evaluateEnabled, keySpecShortcut, keysHeld, mergeMenuDefs, overriddenBindings, overrideActionBindings, paramsMatch, pickMenu, platformRoleKeys, pushOwner, readActionSettings, resolveBindingOverrides, resolveMenu, resolveParams, resolveRoles, resolveSchemaMenu, roleKeysOf, roleReader, tuneAction, tunedParams, validateActionDefaultBinding, validateActionId };
|
|
1102
|
-
//# sourceMappingURL=chunk-
|
|
1103
|
-
//# sourceMappingURL=chunk-
|
|
1105
|
+
//# sourceMappingURL=chunk-Z2BZBJ7W.js.map
|
|
1106
|
+
//# sourceMappingURL=chunk-Z2BZBJ7W.js.map
|