@ai-matrx/alchemy 0.6.2 → 0.8.2
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/CHANGELOG.md +58 -0
- package/dist/actions.cjs +374 -0
- package/dist/actions.cjs.map +1 -0
- package/dist/actions.d.cts +773 -0
- package/dist/actions.d.ts +773 -0
- package/dist/actions.js +351 -0
- package/dist/actions.js.map +1 -0
- package/dist/checks.cjs +31 -2
- package/dist/checks.cjs.map +1 -1
- package/dist/checks.d.cts +24 -1
- package/dist/checks.d.ts +24 -1
- package/dist/checks.js +31 -2
- package/dist/checks.js.map +1 -1
- package/dist/core.cjs +1757 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +595 -1
- package/dist/core.d.ts +595 -1
- package/dist/core.js +1749 -2
- package/dist/core.js.map +1 -1
- package/dist/declare.cjs +12 -10
- package/dist/declare.cjs.map +1 -1
- package/dist/declare.d.cts +18 -2
- package/dist/declare.d.ts +18 -2
- package/dist/declare.js +12 -10
- package/dist/declare.js.map +1 -1
- package/dist/index.cjs +1757 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +595 -1
- package/dist/index.d.ts +595 -1
- package/dist/index.js +1749 -2
- package/dist/index.js.map +1 -1
- package/dist/menu.cjs +436 -0
- package/dist/menu.cjs.map +1 -0
- package/dist/menu.d.cts +834 -0
- package/dist/menu.d.ts +834 -0
- package/dist/menu.js +413 -0
- package/dist/menu.js.map +1 -0
- package/dist/operate-document.cjs +163 -0
- package/dist/operate-document.cjs.map +1 -0
- package/dist/operate-document.d.cts +132 -0
- package/dist/operate-document.d.ts +132 -0
- package/dist/operate-document.js +130 -0
- package/dist/operate-document.js.map +1 -0
- package/dist/operate-rich-html.cjs +129 -0
- package/dist/operate-rich-html.cjs.map +1 -0
- package/dist/operate-rich-html.d.cts +136 -0
- package/dist/operate-rich-html.d.ts +136 -0
- package/dist/operate-rich-html.js +96 -0
- package/dist/operate-rich-html.js.map +1 -0
- package/dist/operate-server.cjs +157 -0
- package/dist/operate-server.cjs.map +1 -0
- package/dist/operate-server.d.cts +183 -0
- package/dist/operate-server.d.ts +183 -0
- package/dist/operate-server.js +134 -0
- package/dist/operate-server.js.map +1 -0
- package/dist/operate-xlsx.cjs +248 -0
- package/dist/operate-xlsx.cjs.map +1 -0
- package/dist/operate-xlsx.d.cts +129 -0
- package/dist/operate-xlsx.d.ts +129 -0
- package/dist/operate-xlsx.js +215 -0
- package/dist/operate-xlsx.js.map +1 -0
- package/dist/operate.cjs +1774 -0
- package/dist/operate.cjs.map +1 -0
- package/dist/operate.d.cts +595 -0
- package/dist/operate.d.ts +595 -0
- package/dist/operate.js +1750 -0
- package/dist/operate.js.map +1 -0
- package/dist/ports.cjs.map +1 -1
- package/dist/ports.d.cts +361 -3
- package/dist/ports.d.ts +361 -3
- package/dist/react-bar.cjs +686 -0
- package/dist/react-bar.cjs.map +1 -0
- package/dist/react-bar.d.cts +379 -0
- package/dist/react-bar.d.ts +379 -0
- package/dist/react-bar.js +665 -0
- package/dist/react-bar.js.map +1 -0
- package/dist/react-host.cjs +301 -0
- package/dist/react-host.cjs.map +1 -0
- package/dist/react-host.d.cts +820 -0
- package/dist/react-host.d.ts +820 -0
- package/dist/react-host.js +269 -0
- package/dist/react-host.js.map +1 -0
- package/dist/react-menu.cjs +735 -0
- package/dist/react-menu.cjs.map +1 -0
- package/dist/react-menu.d.cts +370 -0
- package/dist/react-menu.d.ts +370 -0
- package/dist/react-menu.js +722 -0
- package/dist/react-menu.js.map +1 -0
- package/dist/react-overflow.cjs +592 -0
- package/dist/react-overflow.cjs.map +1 -0
- package/dist/react-overflow.d.cts +817 -0
- package/dist/react-overflow.d.ts +817 -0
- package/dist/react-overflow.js +571 -0
- package/dist/react-overflow.js.map +1 -0
- package/dist/react-palette.cjs +489 -0
- package/dist/react-palette.cjs.map +1 -0
- package/dist/react-palette.d.cts +359 -0
- package/dist/react-palette.d.ts +359 -0
- package/dist/react-palette.js +457 -0
- package/dist/react-palette.js.map +1 -0
- package/dist/react-selection.cjs +617 -0
- package/dist/react-selection.cjs.map +1 -0
- package/dist/react-selection.d.cts +357 -0
- package/dist/react-selection.d.ts +357 -0
- package/dist/react-selection.js +596 -0
- package/dist/react-selection.js.map +1 -0
- package/dist/react-sheet.cjs +616 -0
- package/dist/react-sheet.cjs.map +1 -0
- package/dist/react-sheet.d.cts +361 -0
- package/dist/react-sheet.d.ts +361 -0
- package/dist/react-sheet.js +595 -0
- package/dist/react-sheet.js.map +1 -0
- package/package.json +148 -5
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/react/palette.tsx
|
|
4
|
+
import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@ai-matrx/design-system";
|
|
5
|
+
|
|
6
|
+
// src/menu/layouts.ts
|
|
7
|
+
function isLeaf(node) {
|
|
8
|
+
return node.kind === "item" || node.kind === "checkbox" || node.kind === "link";
|
|
9
|
+
}
|
|
10
|
+
function palette(model) {
|
|
11
|
+
const leaves = [];
|
|
12
|
+
const walk = (nodes, trail) => {
|
|
13
|
+
for (const n of nodes) {
|
|
14
|
+
if (isLeaf(n)) leaves.push({ node: n, breadcrumb: trail });
|
|
15
|
+
else if (n.kind === "submenu") {
|
|
16
|
+
if (n.lazy) leaves.push({ node: n, breadcrumb: trail });
|
|
17
|
+
else walk(n.children, [...trail, n.label]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
for (const s of model.sections) walk(s.nodes, s.label ? [s.label] : []);
|
|
22
|
+
return { leaves };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/react/engine.tsx
|
|
26
|
+
import * as React2 from "react";
|
|
27
|
+
|
|
28
|
+
// src/declare/sensitivity.ts
|
|
29
|
+
var DEFAULT_SENSITIVITY = Object.freeze({
|
|
30
|
+
exportable: true,
|
|
31
|
+
classification: "ordinary",
|
|
32
|
+
includedByDefault: true
|
|
33
|
+
});
|
|
34
|
+
function resolveSensitivity(value) {
|
|
35
|
+
return {
|
|
36
|
+
exportable: value.sensitivity?.exportable ?? DEFAULT_SENSITIVITY.exportable,
|
|
37
|
+
classification: value.sensitivity?.classification ?? DEFAULT_SENSITIVITY.classification,
|
|
38
|
+
includedByDefault: value.sensitivity?.includedByDefault ?? DEFAULT_SENSITIVITY.includedByDefault
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/actions/projection.ts
|
|
43
|
+
function toJson(value) {
|
|
44
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return void 0;
|
|
45
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
46
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
47
|
+
if (typeof value === "bigint") return value.toString();
|
|
48
|
+
if (value instanceof Date) return value.toISOString();
|
|
49
|
+
if (Array.isArray(value)) return value.map((v) => toJson(v) ?? null);
|
|
50
|
+
if (typeof value === "object") {
|
|
51
|
+
const out = {};
|
|
52
|
+
for (const [k, v] of Object.entries(value)) {
|
|
53
|
+
const j = toJson(v);
|
|
54
|
+
if (j !== void 0) out[k] = j;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
function projectValues(raw, declared, pathPrefix = "") {
|
|
61
|
+
const byName = new Map(declared.map((d) => [d.name, d]));
|
|
62
|
+
const values = {};
|
|
63
|
+
const omissions = [];
|
|
64
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
65
|
+
const path = pathPrefix ? `${pathPrefix}.${name}` : name;
|
|
66
|
+
const decl = byName.get(name);
|
|
67
|
+
if (!decl) {
|
|
68
|
+
omissions.push({ path, reason: "filtered" });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const sensitivity = resolveSensitivity(decl);
|
|
72
|
+
if (sensitivity.classification !== "ordinary") {
|
|
73
|
+
omissions.push({ path, reason: "excluded", classification: sensitivity.classification });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (!sensitivity.exportable) {
|
|
77
|
+
omissions.push({ path, reason: "excluded" });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const json = toJson(value);
|
|
81
|
+
if (json === void 0) continue;
|
|
82
|
+
values[name] = json;
|
|
83
|
+
}
|
|
84
|
+
return { values, omissions };
|
|
85
|
+
}
|
|
86
|
+
function createProjectedReads(source) {
|
|
87
|
+
return {
|
|
88
|
+
async values(signal) {
|
|
89
|
+
if (!source.surface || !source.declaration) return { values: {}, omissions: [] };
|
|
90
|
+
const raw = await source.surface.readValues(signal);
|
|
91
|
+
const screenValues = source.declaration.values;
|
|
92
|
+
return projectValues(raw, screenValues);
|
|
93
|
+
},
|
|
94
|
+
async item(signal) {
|
|
95
|
+
const item = source.item;
|
|
96
|
+
if (!item || !source.declaration) return null;
|
|
97
|
+
const type = source.declaration.itemTypes?.find((t) => t.name === item.itemType);
|
|
98
|
+
if (!type) return { values: {}, omissions: [{ path: item.itemType, reason: "filtered" }] };
|
|
99
|
+
const raw = await item.readValues(signal);
|
|
100
|
+
return projectValues(raw, type.values, item.itemType);
|
|
101
|
+
},
|
|
102
|
+
async live(signal) {
|
|
103
|
+
if (!source.surface?.readLive) return {};
|
|
104
|
+
return source.surface.readLive(signal);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/actions/run.ts
|
|
110
|
+
async function runAction(action, target, options) {
|
|
111
|
+
const { ports } = options;
|
|
112
|
+
if (action.requiresAuth && !target.auth.authenticated) {
|
|
113
|
+
if (!ports.auth) {
|
|
114
|
+
ports.diagnostics.capture(new Error(`requiresAuth action "${action.id}" ran signed out with no auth port`), {
|
|
115
|
+
area: "actions",
|
|
116
|
+
detail: { actionId: action.id }
|
|
117
|
+
});
|
|
118
|
+
return { status: "failed", error: new Error("sign-in unavailable") };
|
|
119
|
+
}
|
|
120
|
+
ports.auth.signInThenResume({ actionId: action.id, contentFingerprint: options.contentFingerprint ?? action.id });
|
|
121
|
+
return { status: "auth-pending" };
|
|
122
|
+
}
|
|
123
|
+
const reads = createProjectedReads(options.source ?? { surface: null, declaration: target.declaration, item: null });
|
|
124
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
125
|
+
try {
|
|
126
|
+
const outcome = await action.run(target, { reads, ports, signal });
|
|
127
|
+
return { status: "ran", outcome };
|
|
128
|
+
} catch (error) {
|
|
129
|
+
ports.diagnostics.capture(error, { area: "actions", detail: { actionId: action.id, stage: "run" } });
|
|
130
|
+
const label = typeof action.label === "string" ? action.label : action.id;
|
|
131
|
+
ports.notify?.error(`${label} did not finish.`, "Try again; if it keeps failing, report it from the feedback button.");
|
|
132
|
+
return { status: "failed", error };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/menu/model.ts
|
|
137
|
+
var CATEGORY_GROUP = {
|
|
138
|
+
clipboard: "clipboard",
|
|
139
|
+
copy: "transfer",
|
|
140
|
+
export: "transfer",
|
|
141
|
+
save: "document",
|
|
142
|
+
share: "document",
|
|
143
|
+
edit: "editable",
|
|
144
|
+
history: "history",
|
|
145
|
+
ai: "ai",
|
|
146
|
+
ask: "ai",
|
|
147
|
+
listen: "tools",
|
|
148
|
+
study: "tools",
|
|
149
|
+
app: "tools",
|
|
150
|
+
feedback: "quick",
|
|
151
|
+
creator: "admin",
|
|
152
|
+
admin: "admin",
|
|
153
|
+
"surface-info": "surface-info"
|
|
154
|
+
};
|
|
155
|
+
var GROUP_ORDER = [
|
|
156
|
+
"clipboard",
|
|
157
|
+
"editable",
|
|
158
|
+
"transfer",
|
|
159
|
+
"document",
|
|
160
|
+
"history",
|
|
161
|
+
"ai",
|
|
162
|
+
"tools",
|
|
163
|
+
"quick",
|
|
164
|
+
"surface",
|
|
165
|
+
"admin",
|
|
166
|
+
"surface-info"
|
|
167
|
+
];
|
|
168
|
+
var CATEGORY_ORDER = [
|
|
169
|
+
"clipboard",
|
|
170
|
+
"edit",
|
|
171
|
+
"copy",
|
|
172
|
+
"export",
|
|
173
|
+
"save",
|
|
174
|
+
"share",
|
|
175
|
+
"history",
|
|
176
|
+
"ask",
|
|
177
|
+
"ai",
|
|
178
|
+
"listen",
|
|
179
|
+
"study",
|
|
180
|
+
"app",
|
|
181
|
+
"feedback",
|
|
182
|
+
"creator",
|
|
183
|
+
"admin",
|
|
184
|
+
"surface-info"
|
|
185
|
+
];
|
|
186
|
+
function translate(i18n, key, fallback) {
|
|
187
|
+
if (!i18n) return fallback;
|
|
188
|
+
try {
|
|
189
|
+
return i18n.t(key, fallback);
|
|
190
|
+
} catch {
|
|
191
|
+
return fallback;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function actionToNode(resolved, target, options = {}) {
|
|
195
|
+
const { action, eligibility } = resolved;
|
|
196
|
+
const rawLabel = typeof action.label === "function" ? action.label(target) : action.label;
|
|
197
|
+
const label = translate(options.i18n, action.labelKey ?? action.id, rawLabel);
|
|
198
|
+
const base = {
|
|
199
|
+
id: action.id,
|
|
200
|
+
actionId: action.id,
|
|
201
|
+
...action.icon !== void 0 ? { icon: action.icon } : {},
|
|
202
|
+
...action.placement !== void 0 ? { placement: action.placement } : {}
|
|
203
|
+
};
|
|
204
|
+
if (action.expand) {
|
|
205
|
+
const node = {
|
|
206
|
+
...base,
|
|
207
|
+
kind: "submenu",
|
|
208
|
+
label,
|
|
209
|
+
lazy: true,
|
|
210
|
+
loading: false,
|
|
211
|
+
children: [],
|
|
212
|
+
...action.emptyLabel !== void 0 ? { emptyLabel: action.emptyLabel } : {}
|
|
213
|
+
};
|
|
214
|
+
return node;
|
|
215
|
+
}
|
|
216
|
+
if (action.href !== void 0) {
|
|
217
|
+
const href = typeof action.href === "function" ? action.href(target) : action.href;
|
|
218
|
+
return { ...base, kind: "link", label, href };
|
|
219
|
+
}
|
|
220
|
+
if (action.toggle) {
|
|
221
|
+
return {
|
|
222
|
+
...base,
|
|
223
|
+
kind: "checkbox",
|
|
224
|
+
label,
|
|
225
|
+
checked: action.pressed?.(target) ?? false,
|
|
226
|
+
...action.description !== void 0 ? { description: action.description } : {}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const state = action.stateIcon?.(target) ?? null;
|
|
230
|
+
const pressed = action.pressed?.(target);
|
|
231
|
+
const hint = action.hint !== void 0 ? translate(options.i18n, action.hintKey ?? `${action.id}.hint`, action.hint) : void 0;
|
|
232
|
+
return {
|
|
233
|
+
...base,
|
|
234
|
+
kind: "item",
|
|
235
|
+
label,
|
|
236
|
+
...action.iconTone !== void 0 ? { iconTone: action.iconTone } : {},
|
|
237
|
+
...state ? { stateIcon: state } : {},
|
|
238
|
+
...action.description !== void 0 ? { description: action.description } : {},
|
|
239
|
+
...hint !== void 0 ? { hint } : {},
|
|
240
|
+
...pressed !== void 0 ? { pressed } : {},
|
|
241
|
+
...action.destructive ? { destructive: true } : {},
|
|
242
|
+
...action.preserveSelection ? { preserveSelection: true } : {},
|
|
243
|
+
...eligibility.status === "unavailable-verb" ? { unavailable: { sentence: eligibility.sentence } } : {}
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function buildMenuModel(target, resolved, options = {}) {
|
|
247
|
+
const ordered = resolved.map((r, index) => ({ r, index })).sort((a, b) => {
|
|
248
|
+
const ca = CATEGORY_ORDER.indexOf(a.r.action.category);
|
|
249
|
+
const cb = CATEGORY_ORDER.indexOf(b.r.action.category);
|
|
250
|
+
if (ca !== cb) return ca - cb;
|
|
251
|
+
const oa = a.r.action.order ?? 0;
|
|
252
|
+
const ob = b.r.action.order ?? 0;
|
|
253
|
+
if (oa !== ob) return oa - ob;
|
|
254
|
+
return a.index - b.index;
|
|
255
|
+
}).map((x) => x.r);
|
|
256
|
+
const sections = /* @__PURE__ */ new Map();
|
|
257
|
+
const roles = {};
|
|
258
|
+
const explicit = /* @__PURE__ */ new Map();
|
|
259
|
+
resolved.forEach((r, index) => {
|
|
260
|
+
const sec = r.action.section;
|
|
261
|
+
if (!sec) return;
|
|
262
|
+
const entry = explicit.get(sec.id) ?? { group: CATEGORY_GROUP[r.action.category], rows: [] };
|
|
263
|
+
entry.rows.push({ r, index });
|
|
264
|
+
explicit.set(sec.id, entry);
|
|
265
|
+
});
|
|
266
|
+
const placed = /* @__PURE__ */ new Set();
|
|
267
|
+
for (const r of ordered) {
|
|
268
|
+
const sec = r.action.section;
|
|
269
|
+
if (sec && placed.has(sec.id)) continue;
|
|
270
|
+
const group = sec ? explicit.get(sec.id)?.group ?? CATEGORY_GROUP[r.action.category] : CATEGORY_GROUP[r.action.category];
|
|
271
|
+
const sectionId = sec ? `section:${sec.id}` : group;
|
|
272
|
+
let section = sections.get(sectionId);
|
|
273
|
+
if (!section) {
|
|
274
|
+
section = {
|
|
275
|
+
id: sectionId,
|
|
276
|
+
group,
|
|
277
|
+
nodes: [],
|
|
278
|
+
...sec ? { label: translate(options.i18n, sec.labelKey ?? `section.${sec.id}`, sec.label) } : {},
|
|
279
|
+
...sec?.icon !== void 0 ? { icon: sec.icon } : {},
|
|
280
|
+
...sec?.primary ? { primary: true } : {}
|
|
281
|
+
};
|
|
282
|
+
sections.set(sectionId, section);
|
|
283
|
+
}
|
|
284
|
+
const rows = sec ? (explicit.get(sec.id)?.rows ?? []).sort((x, y) => (x.r.action.order ?? 0) - (y.r.action.order ?? 0) || x.index - y.index).map((x) => x.r) : [r];
|
|
285
|
+
if (sec) placed.add(sec.id);
|
|
286
|
+
for (const row of rows) {
|
|
287
|
+
section.nodes.push(actionToNode(row, target, options));
|
|
288
|
+
if (row.action.verb) roles[row.action.verb] = row.action.id;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const list = [...sections.values()].sort((a, b) => {
|
|
292
|
+
if (Boolean(a.primary) !== Boolean(b.primary)) return a.primary ? -1 : 1;
|
|
293
|
+
return GROUP_ORDER.indexOf(a.group) - GROUP_ORDER.indexOf(b.group);
|
|
294
|
+
});
|
|
295
|
+
const selected = target.selection?.text?.trim();
|
|
296
|
+
const content = options.content?.trim();
|
|
297
|
+
const header = selected ? { label: "Selected", text: target.selection?.text ?? "" } : content ? { label: "Content", text: options.content ?? "" } : null;
|
|
298
|
+
return { header, sections: list, roles };
|
|
299
|
+
}
|
|
300
|
+
function withExpandedChildren(model, nodeId, children) {
|
|
301
|
+
const visit = (nodes) => nodes.map((n) => {
|
|
302
|
+
if (n.kind !== "submenu") return n;
|
|
303
|
+
if (n.id === nodeId) {
|
|
304
|
+
return children === "loading" ? { ...n, loading: true } : { ...n, lazy: false, loading: false, children };
|
|
305
|
+
}
|
|
306
|
+
return { ...n, children: visit(n.children) };
|
|
307
|
+
});
|
|
308
|
+
return { ...model, sections: model.sections.map((s) => ({ ...s, nodes: visit(s.nodes) })) };
|
|
309
|
+
}
|
|
310
|
+
function findNode(nodes, id) {
|
|
311
|
+
for (const n of nodes) {
|
|
312
|
+
if (n.id === id) return n;
|
|
313
|
+
if (n.kind === "submenu") {
|
|
314
|
+
const hit = findNode(n.children, id);
|
|
315
|
+
if (hit) return hit;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/react/context.ts
|
|
322
|
+
import * as React from "react";
|
|
323
|
+
var KEY = /* @__PURE__ */ Symbol.for("ai-matrx.alchemy.actions-context");
|
|
324
|
+
var AlchemyActionsContext = globalThis[KEY] ??= React.createContext(null);
|
|
325
|
+
function useAlchemyActions() {
|
|
326
|
+
const value = React.useContext(AlchemyActionsContext);
|
|
327
|
+
if (!value) throw new Error("Alchemy actions: render inside <AlchemyActionsProvider> (@ai-matrx/alchemy/react/host).");
|
|
328
|
+
return value;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// src/react/engine.tsx
|
|
332
|
+
import { jsx } from "react/jsx-runtime";
|
|
333
|
+
function useMenuEngine(target, options = {}) {
|
|
334
|
+
const { registry, ports } = useAlchemyActions();
|
|
335
|
+
const [resolved, setResolved] = React2.useState([]);
|
|
336
|
+
const [model, setModel] = React2.useState(null);
|
|
337
|
+
const [tick, setTick] = React2.useState(0);
|
|
338
|
+
const expanded = React2.useRef(/* @__PURE__ */ new Map());
|
|
339
|
+
const active = options.active ?? true;
|
|
340
|
+
const optionsRef = React2.useRef(options);
|
|
341
|
+
optionsRef.current = options;
|
|
342
|
+
React2.useEffect(() => registry.subscribe(() => setTick((t) => t + 1)), [registry]);
|
|
343
|
+
React2.useEffect(() => {
|
|
344
|
+
if (!target || !active) return;
|
|
345
|
+
let live = true;
|
|
346
|
+
void registry.resolve(target, optionsRef.current.restrict).then((list) => {
|
|
347
|
+
if (!live) return;
|
|
348
|
+
expanded.current.clear();
|
|
349
|
+
setResolved(list);
|
|
350
|
+
setModel(buildMenuModel(target, list, { ...ports.i18n ? { i18n: ports.i18n } : {}, content: optionsRef.current.content ?? null }));
|
|
351
|
+
});
|
|
352
|
+
return () => {
|
|
353
|
+
live = false;
|
|
354
|
+
};
|
|
355
|
+
}, [registry, ports, target, active, tick, options.revision]);
|
|
356
|
+
React2.useEffect(() => {
|
|
357
|
+
if (!target) return;
|
|
358
|
+
const offs = resolved.map((r) => r.action.subscribe?.(() => setTick((t) => t + 1), target)).filter((off) => typeof off === "function");
|
|
359
|
+
return () => offs.forEach((off) => off());
|
|
360
|
+
}, [resolved, target]);
|
|
361
|
+
const findAction = React2.useCallback(
|
|
362
|
+
(id) => resolved.find((r) => r.action.id === id)?.action ?? expanded.current.get(id),
|
|
363
|
+
[resolved]
|
|
364
|
+
);
|
|
365
|
+
const run = React2.useCallback(
|
|
366
|
+
async (nodeId) => {
|
|
367
|
+
if (!target || !model) return null;
|
|
368
|
+
const node = model.sections.map((s) => findNode(s.nodes, nodeId)).find(Boolean) ?? null;
|
|
369
|
+
const action = findAction(node && "actionId" in node && node.actionId ? node.actionId : nodeId);
|
|
370
|
+
if (!action) return null;
|
|
371
|
+
const o = optionsRef.current;
|
|
372
|
+
const result = await runAction(action, target, {
|
|
373
|
+
ports,
|
|
374
|
+
...o.source ? { source: o.source } : {},
|
|
375
|
+
...o.contentFingerprint ? { contentFingerprint: o.contentFingerprint } : {}
|
|
376
|
+
});
|
|
377
|
+
o.onRan?.(nodeId, result);
|
|
378
|
+
return result;
|
|
379
|
+
},
|
|
380
|
+
[target, model, findAction, ports]
|
|
381
|
+
);
|
|
382
|
+
const expand = React2.useCallback(
|
|
383
|
+
async (nodeId) => {
|
|
384
|
+
const action = findAction(nodeId);
|
|
385
|
+
if (!target || !action?.expand) return;
|
|
386
|
+
setModel((m) => m ? withExpandedChildren(m, nodeId, "loading") : m);
|
|
387
|
+
try {
|
|
388
|
+
const children = await action.expand(target, new AbortController().signal);
|
|
389
|
+
const nodes = children.map((child) => {
|
|
390
|
+
expanded.current.set(child.id, child);
|
|
391
|
+
return actionToNode({ action: child, eligibility: { status: "available" } }, target, ports.i18n ? { i18n: ports.i18n } : {});
|
|
392
|
+
});
|
|
393
|
+
setModel((m) => m ? withExpandedChildren(m, nodeId, nodes) : m);
|
|
394
|
+
} catch (error) {
|
|
395
|
+
ports.diagnostics.capture(error, { area: "menu", detail: { nodeId, stage: "expand" } });
|
|
396
|
+
setModel((m) => m ? withExpandedChildren(m, nodeId, []) : m);
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
[findAction, target, ports]
|
|
400
|
+
);
|
|
401
|
+
const icon = React2.useCallback(
|
|
402
|
+
(key, tone) => {
|
|
403
|
+
if (!key || !ports.icons) return null;
|
|
404
|
+
const Resolved = ports.icons.resolve(key);
|
|
405
|
+
return Resolved ? /* @__PURE__ */ jsx(Resolved, { className: `h-4 w-4 shrink-0 ${tone ?? ""}`, "aria-hidden": true }) : null;
|
|
406
|
+
},
|
|
407
|
+
[ports.icons]
|
|
408
|
+
);
|
|
409
|
+
return { model, resolved, run, expand, icon };
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// src/react/palette.tsx
|
|
413
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
414
|
+
function ActionPalette({ target, open, onOpenChange, placeholder = "Search actions\u2026", ...options }) {
|
|
415
|
+
const engine = useMenuEngine(target, {
|
|
416
|
+
...options,
|
|
417
|
+
active: open,
|
|
418
|
+
onRan: (id, r) => {
|
|
419
|
+
options.onRan?.(id, r);
|
|
420
|
+
onOpenChange(false);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
const arranged = engine.model ? palette(engine.model) : { leaves: [] };
|
|
424
|
+
return /* @__PURE__ */ jsxs(CommandDialog, { open, onOpenChange, children: [
|
|
425
|
+
/* @__PURE__ */ jsx2(CommandInput, { placeholder }),
|
|
426
|
+
/* @__PURE__ */ jsxs(CommandList, { "data-alchemy-layout": "palette", children: [
|
|
427
|
+
/* @__PURE__ */ jsx2(CommandEmpty, { children: "No action matches." }),
|
|
428
|
+
/* @__PURE__ */ jsx2(CommandGroup, { children: arranged.leaves.map(({ node, breadcrumb }) => {
|
|
429
|
+
const unavailable = node.kind === "item" ? node.unavailable : void 0;
|
|
430
|
+
return /* @__PURE__ */ jsxs(
|
|
431
|
+
CommandItem,
|
|
432
|
+
{
|
|
433
|
+
value: `${node.label} ${breadcrumb.join(" ")} ${node.id}`,
|
|
434
|
+
"data-alchemy-node": node.id,
|
|
435
|
+
disabled: Boolean(unavailable),
|
|
436
|
+
onSelect: () => {
|
|
437
|
+
if (node.kind === "submenu") void engine.expand(node.id);
|
|
438
|
+
else if (node.kind === "link") window.location.assign(node.href);
|
|
439
|
+
else void engine.run(node.id);
|
|
440
|
+
},
|
|
441
|
+
className: "gap-2",
|
|
442
|
+
children: [
|
|
443
|
+
"icon" in node ? engine.icon(node.icon) : null,
|
|
444
|
+
/* @__PURE__ */ jsx2("span", { className: "flex-1 truncate", children: node.label }),
|
|
445
|
+
/* @__PURE__ */ jsx2("span", { className: "text-xs text-muted-foreground", children: unavailable ? unavailable.sentence : breadcrumb.join(" \u203A ") })
|
|
446
|
+
]
|
|
447
|
+
},
|
|
448
|
+
node.id
|
|
449
|
+
);
|
|
450
|
+
}) })
|
|
451
|
+
] })
|
|
452
|
+
] });
|
|
453
|
+
}
|
|
454
|
+
export {
|
|
455
|
+
ActionPalette
|
|
456
|
+
};
|
|
457
|
+
//# sourceMappingURL=react-palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react/palette.tsx","../src/menu/layouts.ts","../src/react/engine.tsx","../src/declare/sensitivity.ts","../src/actions/projection.ts","../src/actions/run.ts","../src/menu/model.ts","../src/react/context.ts"],"sourcesContent":["\"use client\";\n/**\n * `@ai-matrx/alchemy/react/palette` — the command palette layout (Linear):\n * every leaf of the one model, flattened with its breadcrumb, type to filter.\n */\nimport * as React from \"react\";\nimport { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from \"@ai-matrx/design-system\";\nimport { palette } from \"../menu/layouts\";\nimport type { ClickTarget } from \"../actions/types\";\nimport { useMenuEngine, type MenuEngineOptions } from \"./engine\";\n\nexport interface ActionPaletteProps extends MenuEngineOptions {\n target: ClickTarget;\n open: boolean;\n onOpenChange(open: boolean): void;\n placeholder?: string;\n}\n\nexport function ActionPalette({ target, open, onOpenChange, placeholder = \"Search actions…\", ...options }: ActionPaletteProps): React.ReactElement {\n const engine = useMenuEngine(target, {\n ...options,\n active: open,\n onRan: (id, r) => {\n options.onRan?.(id, r);\n onOpenChange(false);\n },\n });\n const arranged = engine.model ? palette(engine.model) : { leaves: [] };\n return (\n <CommandDialog open={open} onOpenChange={onOpenChange}>\n <CommandInput placeholder={placeholder} />\n <CommandList data-alchemy-layout=\"palette\">\n <CommandEmpty>No action matches.</CommandEmpty>\n <CommandGroup>\n {arranged.leaves.map(({ node, breadcrumb }) => {\n const unavailable = node.kind === \"item\" ? node.unavailable : undefined;\n return (\n <CommandItem\n key={node.id}\n value={`${node.label} ${breadcrumb.join(\" \")} ${node.id}`}\n data-alchemy-node={node.id}\n disabled={Boolean(unavailable)}\n onSelect={() => {\n if (node.kind === \"submenu\") void engine.expand(node.id);\n else if (node.kind === \"link\") window.location.assign(node.href);\n else void engine.run(node.id);\n }}\n className=\"gap-2\"\n >\n {\"icon\" in node ? engine.icon(node.icon) : null}\n <span className=\"flex-1 truncate\">{node.label}</span>\n <span className=\"text-xs text-muted-foreground\">{unavailable ? unavailable.sentence : breadcrumb.join(\" › \")}</span>\n </CommandItem>\n );\n })}\n </CommandGroup>\n </CommandList>\n </CommandDialog>\n );\n}\n\nexport default ActionPalette;\n","/**\n * Layouts — pure arrangements of one MenuModel (CONTRACT §2.5).\n *\n * Every layout is a function over the SAME model: it decides which nodes sit\n * at the top level, which fold under a named submenu and which go into a\n * strip. None adds, drops or renames a leaf — `leafIds(arranged)` equals\n * `leafIds(model)` for every layout (THE LOSSLESS LAW, proven by test).\n *\n * The clipboard group IS the universal verb strip: in the strip layouts it is\n * drawn icon-only; elsewhere its rows are drawn in place. Unavailable verbs\n * (the only greyed nodes, R1 c) appear in every layout identically.\n */\nimport type {\n ArrangedBar,\n ArrangedContext,\n ArrangedPalette,\n ArrangedSelectionToolbar,\n ArrangedSheet,\n ContextArrangement,\n MenuLeafNode,\n MenuModel,\n MenuNode,\n MenuSection,\n MenuSubmenuNode,\n} from \"./types\";\n\n/** A section with more rows than this folds under its label in tiered/command/sheet. */\nexport const INLINE_SECTION_MAX = 3;\n\n/**\n * A section's heading is ONLY the name its actions declare (an approved\n * heading the classic menu already uses: \"Save as\", \"Copy as\", \"History\").\n * A group with no declared name has no heading and is never folded — its rows\n * show inline. The package never coins a heading (chair ruling, ALC-15).\n */\nexport function sectionLabel(section: MenuSection): string | null {\n return section.label ?? null;\n}\n\nfunction isLeaf(node: MenuNode): node is MenuLeafNode {\n return node.kind === \"item\" || node.kind === \"checkbox\" || node.kind === \"link\";\n}\n\n/** Every actionable id in a node list, depth-first. A lazy submenu counts as one leaf. */\nfunction collect(nodes: readonly MenuNode[], out: string[]): void {\n for (const n of nodes) {\n if (isLeaf(n)) out.push(n.id);\n else if (n.kind === \"submenu\") {\n if (n.lazy) out.push(n.id);\n else collect(n.children, out);\n }\n }\n}\n\ntype Arranged =\n | MenuModel\n | ArrangedBar\n | ArrangedContext\n | ArrangedSheet\n | ArrangedPalette\n | ArrangedSelectionToolbar\n | MenuSection[];\n\n/** Proof obligation for every layout: its leaf set equals the model's (sorted, de-duplicated). */\nexport function leafIds(arranged: Arranged): readonly string[] {\n const out: string[] = [];\n if (Array.isArray(arranged)) {\n for (const s of arranged) collect(s.nodes, out);\n } else if (\"leaves\" in arranged) {\n for (const l of arranged.leaves) out.push(l.node.id);\n } else if (\"primary\" in arranged && \"overflow\" in arranged) {\n collect(arranged.primary, out);\n for (const s of arranged.overflow) collect(s.nodes, out);\n } else if (\"root\" in arranged) {\n collect(arranged.strip, out);\n collect(arranged.root, out);\n } else if (\"more\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.more) collect(s.nodes, out);\n } else if (\"filterable\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.sections) collect(s.nodes, out);\n } else {\n for (const s of arranged.sections) collect(s.nodes, out);\n }\n return [...new Set(out)].sort();\n}\n\n/** Only a NAMED section folds; callers check `section.label` first. */\nfunction fold(section: MenuSection & { label: string }): MenuSubmenuNode {\n return {\n kind: \"submenu\",\n id: `${section.id}:fold`,\n label: section.label,\n ...(section.icon !== undefined ? { icon: section.icon } : {}),\n children: section.nodes,\n };\n}\n\nfunction rowCount(nodes: readonly MenuNode[]): number {\n return nodes.filter((n) => n.kind !== \"separator\" && n.kind !== \"label\").length;\n}\n\nfunction stripOf(model: MenuModel): MenuLeafNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter(isLeaf) : [];\n}\n\nfunction clipboardRest(model: MenuModel): MenuNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter((n) => !isLeaf(n) && n.kind === \"submenu\") : [];\n}\n\nfunction placementOf(node: MenuNode): \"primary\" | \"overflow\" | \"both\" {\n return \"placement\" in node && node.placement ? node.placement : \"overflow\";\n}\n\n/** The historical flat column: every section top-level. */\nfunction classic(model: MenuModel): ArrangedContext {\n return { strip: [], sections: model.sections, filterable: false };\n}\n\n/**\n * Tiered / command: the universal verbs as an icon strip; every other row by\n * its own name; the clicked target's (primary) section first, inline, heading\n * kept; a long non-primary section folds under ITS OWN label (never a coined\n * heading); History is the one approved grouping and already a group.\n */\nfunction tiered(model: MenuModel, filterable: boolean): ArrangedContext {\n const strip = stripOf(model);\n const hierarchical = model.sections.some((s) => s.primary);\n const sections: MenuSection[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n if (s.group === \"clipboard\" && !s.primary) {\n if (rest.length) sections.push({ ...s, nodes: rest });\n continue;\n }\n if (s.primary) {\n sections.push(s);\n continue;\n }\n if (!s.label || s.group === \"surface-info\" || rowCount(s.nodes) <= INLINE_SECTION_MAX) {\n if (hierarchical) sections.push(s);\n else {\n const { label: _label, ...unlabelled } = s;\n sections.push(unlabelled);\n }\n continue;\n }\n sections.push({ id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] });\n }\n return { strip, sections, filterable };\n}\n\nexport function context(model: MenuModel, arrangement: ContextArrangement): ArrangedContext {\n if (arrangement === \"classic\") return classic(model);\n return tiered(model, arrangement === \"command\");\n}\n\n/**\n * A long NAMED section folds under its own name (\"Save as ▸\", \"Copy as ▸\");\n * primary sections and unnamed groups stay inline. Folding moves rows, never\n * renames or drops them, and never under a coined heading.\n */\nfunction foldNamed(sections: readonly MenuSection[]): MenuSection[] {\n return sections.map((s) =>\n s.label && !s.primary && rowCount(s.nodes) > INLINE_SECTION_MAX ? { id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] } : s,\n );\n}\n\n/** ⋯ overflow: every section in classic order; long named sections fold under their own name. */\nexport function overflow(model: MenuModel): MenuSection[] {\n return foldNamed(model.sections);\n}\n\n/**\n * The action bar: primary buttons inline, EVERYTHING else under ⋯. A \"both\"\n * action is mirrored in both halves (the leaf set is still the model's).\n * `mini` changes presentation only (icon-only primaries), never membership.\n */\nexport function bar(model: MenuModel, _options: { mini?: boolean } = {}): ArrangedBar {\n const primary: MenuNode[] = [];\n const overflowSections: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n if (n.kind === \"separator\" || n.kind === \"label\") {\n rest.push(n);\n continue;\n }\n const p = placementOf(n);\n if (p === \"primary\" || p === \"both\") primary.push(n);\n if (p === \"overflow\" || p === \"both\") rest.push(n);\n }\n if (rowCount(rest) > 0) overflowSections.push({ ...s, nodes: rest });\n }\n return { primary, overflow: foldNamed(overflowSections) };\n}\n\n/** Selection toolbar: the verbs plus primary actions as a strip; the rest under More. */\nexport function selectionToolbar(model: MenuModel): ArrangedSelectionToolbar {\n const strip: MenuNode[] = [];\n const more: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n const inStrip = (s.group === \"clipboard\" && !s.primary && isLeaf(n)) || placementOf(n) !== \"overflow\";\n if (inStrip) strip.push(n);\n else rest.push(n);\n }\n if (rowCount(rest) > 0) more.push({ ...s, nodes: rest });\n }\n return { strip, more };\n}\n\n/**\n * Mobile bottom sheet: the verb strip on top; primary and short sections\n * inline; longer sections become one drill-down row named by the section.\n * Consumes the model directly, so it can never drift from desktop.\n */\nexport function sheet(model: MenuModel): ArrangedSheet {\n const strip = stripOf(model);\n const root: MenuNode[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n const nodes = s.group === \"clipboard\" && !s.primary ? rest : s.nodes;\n if (rowCount(nodes) === 0) continue;\n if (root.length) root.push({ kind: \"separator\", id: `${s.id}:sep` });\n if (s.primary || !s.label || rowCount(nodes) <= INLINE_SECTION_MAX) {\n if (s.label) root.push({ kind: \"label\", id: `${s.id}:label`, label: s.label });\n root.push(...nodes);\n } else {\n root.push(fold({ ...s, label: s.label, nodes }));\n }\n }\n return { strip, root };\n}\n\n/** Command palette: every leaf flattened with its breadcrumb (Linear). */\nexport function palette(model: MenuModel): ArrangedPalette {\n const leaves: ArrangedPalette[\"leaves\"] = [];\n const walk = (nodes: readonly MenuNode[], trail: string[]) => {\n for (const n of nodes) {\n if (isLeaf(n)) leaves.push({ node: n, breadcrumb: trail });\n else if (n.kind === \"submenu\") {\n if (n.lazy) leaves.push({ node: n, breadcrumb: trail });\n else walk(n.children, [...trail, n.label]);\n }\n }\n };\n for (const s of model.sections) walk(s.nodes, s.label ? [s.label] : []);\n return { leaves };\n}\n\n/** Filter the palette by a query (every word must match label or breadcrumb). */\nexport function filterPalette(arranged: ArrangedPalette, query: string): ArrangedPalette {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (!words.length) return arranged;\n return {\n leaves: arranged.leaves.filter((l) => {\n const hay = `${l.node.label} ${l.breadcrumb.join(\" \")}`.toLowerCase();\n return words.every((w) => hay.includes(w));\n }),\n };\n}\n\nexport const layouts = { bar, overflow, context, selectionToolbar, sheet, palette };\n","\"use client\";\n/**\n * The React half of T1e: one hook every renderer uses to resolve the registry\n * at a target, build the model and run a node. Handlers never live in a\n * renderer — they live in providers and run through `runAction`.\n *\n * The context object is shared through globalThis so every per-layout entry\n * (each bundled separately) reads the same provider (module state is banned\n * across dual-loader graphs).\n */\nimport * as React from \"react\";\nimport { runAction, type RunResult } from \"../actions/run\";\nimport type { ProjectionSource } from \"../actions/projection\";\nimport type { Action, ClickTarget, ResolveRestriction, ResolvedAction } from \"../actions/types\";\nimport { actionToNode, buildMenuModel, findNode, withExpandedChildren } from \"../menu/model\";\nimport type { MenuModel, MenuNode } from \"../menu/types\";\nimport { useAlchemyActions } from \"./context\";\n\nexport interface MenuEngineOptions {\n restrict?: ResolveRestriction;\n /** Raw sources for projection (the host's mounted surface / clicked item). */\n source?: ProjectionSource;\n /** Content the menu acts on when nothing is selected (header text). */\n content?: string | null;\n contentFingerprint?: string;\n /** Called after a node ran (close the menu, announce). */\n onRan?: (nodeId: string, result: RunResult) => void;\n /** Resolve only while true (renderers resolve on open). Default true. */\n active?: boolean;\n /**\n * Re-resolve when this changes even if the target object is the same (a\n * host that keeps one target per mount and reads live state through it).\n */\n revision?: string | number;\n}\n\nexport interface MenuEngine {\n model: MenuModel | null;\n resolved: readonly ResolvedAction[];\n run(nodeId: string): Promise<RunResult | null>;\n expand(nodeId: string): Promise<void>;\n /** The host's glyph for a key; `tone` is the action's colour class (iconTone). */\n icon(key: string | undefined, tone?: string): React.ReactNode;\n}\n\nexport function useMenuEngine(target: ClickTarget | null, options: MenuEngineOptions = {}): MenuEngine {\n const { registry, ports } = useAlchemyActions();\n const [resolved, setResolved] = React.useState<readonly ResolvedAction[]>([]);\n const [model, setModel] = React.useState<MenuModel | null>(null);\n const [tick, setTick] = React.useState(0);\n const expanded = React.useRef(new Map<string, Action>());\n const active = options.active ?? true;\n const optionsRef = React.useRef(options);\n optionsRef.current = options;\n\n React.useEffect(() => registry.subscribe(() => setTick((t) => t + 1)), [registry]);\n\n React.useEffect(() => {\n if (!target || !active) return;\n let live = true;\n void registry.resolve(target, optionsRef.current.restrict).then((list) => {\n if (!live) return;\n expanded.current.clear();\n setResolved(list);\n setModel(buildMenuModel(target, list, { ...(ports.i18n ? { i18n: ports.i18n } : {}), content: optionsRef.current.content ?? null }));\n });\n return () => {\n live = false;\n };\n }, [registry, ports, target, active, tick, options.revision]);\n\n // Live toggles (read-aloud, thumbs): re-build when an action's store changes.\n React.useEffect(() => {\n if (!target) return;\n const offs = resolved\n .map((r) => r.action.subscribe?.(() => setTick((t) => t + 1), target))\n .filter((off): off is () => void => typeof off === \"function\");\n return () => offs.forEach((off) => off());\n }, [resolved, target]);\n\n const findAction = React.useCallback(\n (id: string): Action | undefined => resolved.find((r) => r.action.id === id)?.action ?? expanded.current.get(id),\n [resolved],\n );\n\n const run = React.useCallback(\n async (nodeId: string) => {\n if (!target || !model) return null;\n const node = model.sections.map((s) => findNode(s.nodes, nodeId)).find(Boolean) ?? null;\n const action = findAction(node && \"actionId\" in node && node.actionId ? node.actionId : nodeId);\n if (!action) return null;\n const o = optionsRef.current;\n const result = await runAction(action, target, {\n ports,\n ...(o.source ? { source: o.source } : {}),\n ...(o.contentFingerprint ? { contentFingerprint: o.contentFingerprint } : {}),\n });\n o.onRan?.(nodeId, result);\n return result;\n },\n [target, model, findAction, ports],\n );\n\n const expand = React.useCallback(\n async (nodeId: string) => {\n const action = findAction(nodeId);\n if (!target || !action?.expand) return;\n setModel((m) => (m ? withExpandedChildren(m, nodeId, \"loading\") : m));\n try {\n const children = await action.expand(target, new AbortController().signal);\n const nodes: MenuNode[] = children.map((child) => {\n expanded.current.set(child.id, child);\n return actionToNode({ action: child, eligibility: { status: \"available\" } }, target, ports.i18n ? { i18n: ports.i18n } : {});\n });\n setModel((m) => (m ? withExpandedChildren(m, nodeId, nodes) : m));\n } catch (error) {\n ports.diagnostics.capture(error, { area: \"menu\", detail: { nodeId, stage: \"expand\" } });\n setModel((m) => (m ? withExpandedChildren(m, nodeId, []) : m));\n }\n },\n [findAction, target, ports],\n );\n\n const icon = React.useCallback(\n (key: string | undefined, tone?: string): React.ReactNode => {\n if (!key || !ports.icons) return null;\n const Resolved = ports.icons.resolve(key) as React.ComponentType<{ className?: string; \"aria-hidden\"?: boolean }> | null;\n return Resolved ? <Resolved className={`h-4 w-4 shrink-0 ${tone ?? \"\"}`} aria-hidden /> : null;\n },\n [ports.icons],\n );\n\n return { model, resolved, run, expand, icon };\n}\n","/**\n * Sensitivity defaults and resolution (CONTRACT §2.1). Its own module so the\n * lightweight entries (`/actions`, the T0 React host) can project without\n * pulling the declaration registry.\n */\nimport type { DeclaredValue, Sensitivity } from \"./types\";\n\nexport const DEFAULT_SENSITIVITY: Sensitivity = Object.freeze({\n exportable: true,\n classification: \"ordinary\",\n includedByDefault: true,\n});\n\nexport function resolveSensitivity(value: Pick<DeclaredValue, \"sensitivity\">): Sensitivity {\n return {\n exportable: value.sensitivity?.exportable ?? DEFAULT_SENSITIVITY.exportable,\n classification: value.sensitivity?.classification ?? DEFAULT_SENSITIVITY.classification,\n includedByDefault: value.sensitivity?.includedByDefault ?? DEFAULT_SENSITIVITY.includedByDefault,\n };\n}\n","/**\n * PROJECTION BEFORE PROVIDERS (CONTRACT §2.4).\n *\n * The only place a raw read (`MountedSurface.readValues`,\n * `InternalResolvedItem.readValues`) is consumed on behalf of an action.\n * What leaves is projected: a value is kept only when it is DECLARED, its\n * classification is \"ordinary\" and it is exportable. Everything removed is\n * recorded as an omission, so the person and the agent can see what was held\n * back. No caller can relax this.\n */\nimport { resolveSensitivity } from \"../declare/sensitivity\";\nimport type { InternalResolvedItem, MountedSurface } from \"../declare/host\";\nimport type { DeclaredValue, Json, LiveValues, ResolvedSurfaceDeclaration } from \"../declare/types\";\nimport type { ProjectedReads, ReadOmission } from \"./types\";\n\nexport interface ProjectionSource {\n surface: MountedSurface | null;\n declaration: ResolvedSurfaceDeclaration | null;\n item: InternalResolvedItem | null;\n}\n\nfunction toJson(value: unknown): Json | undefined {\n if (value === undefined || typeof value === \"function\" || typeof value === \"symbol\") return undefined;\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return Number.isFinite(value) ? value : null;\n if (typeof value === \"bigint\") return value.toString();\n if (value instanceof Date) return value.toISOString();\n if (Array.isArray(value)) return value.map((v) => toJson(v) ?? null);\n if (typeof value === \"object\") {\n const out: { [key: string]: Json } = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const j = toJson(v);\n if (j !== undefined) out[k] = j;\n }\n return out;\n }\n return undefined;\n}\n\n/** Keep declared, ordinary, exportable values; record every removal. */\nexport function projectValues(\n raw: Record<string, unknown>,\n declared: readonly Pick<DeclaredValue, \"name\" | \"sensitivity\">[],\n pathPrefix = \"\",\n): { values: Record<string, Json>; omissions: ReadOmission[] } {\n const byName = new Map(declared.map((d) => [d.name, d]));\n const values: Record<string, Json> = {};\n const omissions: ReadOmission[] = [];\n for (const [name, value] of Object.entries(raw)) {\n const path = pathPrefix ? `${pathPrefix}.${name}` : name;\n const decl = byName.get(name);\n if (!decl) {\n omissions.push({ path, reason: \"filtered\" });\n continue;\n }\n const sensitivity = resolveSensitivity(decl);\n if (sensitivity.classification !== \"ordinary\") {\n omissions.push({ path, reason: \"excluded\", classification: sensitivity.classification });\n continue;\n }\n if (!sensitivity.exportable) {\n omissions.push({ path, reason: \"excluded\" });\n continue;\n }\n const json = toJson(value);\n if (json === undefined) continue;\n values[name] = json;\n }\n return { values, omissions };\n}\n\nexport function createProjectedReads(source: ProjectionSource): ProjectedReads {\n return {\n async values(signal) {\n if (!source.surface || !source.declaration) return { values: {}, omissions: [] };\n const raw = await source.surface.readValues(signal);\n const screenValues = source.declaration.values;\n return projectValues(raw, screenValues);\n },\n async item(signal) {\n const item = source.item;\n if (!item || !source.declaration) return null;\n const type = source.declaration.itemTypes?.find((t) => t.name === item.itemType);\n if (!type) return { values: {}, omissions: [{ path: item.itemType, reason: \"filtered\" }] };\n const raw = await item.readValues(signal);\n return projectValues(raw, type.values, item.itemType);\n },\n async live(signal): Promise<LiveValues> {\n if (!source.surface?.readLive) return {};\n return source.surface.readLive(signal);\n },\n };\n}\n","/**\n * The one run path (T1e). Every layout runs an action through here, so the\n * sign-in-then-resume rule, projection and failure capture live once.\n */\nimport type { TransferOutcome } from \"@ai-matrx/kit/content-transfer\";\nimport type { AlchemyHostPorts } from \"../ports\";\nimport { createProjectedReads, type ProjectionSource } from \"./projection\";\nimport type { Action, ClickTarget } from \"./types\";\n\nexport interface RunActionOptions {\n ports: AlchemyHostPorts;\n /** Raw sources; projected before the action sees them. */\n source?: ProjectionSource;\n /** Stable fingerprint of the content, for sign-in-then-resume. */\n contentFingerprint?: string;\n signal?: AbortSignal;\n}\n\nexport type RunResult =\n | { status: \"ran\"; outcome: TransferOutcome | void }\n | { status: \"auth-pending\" }\n | { status: \"failed\"; error: unknown };\n\nexport async function runAction(action: Action, target: ClickTarget, options: RunActionOptions): Promise<RunResult> {\n const { ports } = options;\n if (action.requiresAuth && !target.auth.authenticated) {\n if (!ports.auth) {\n // Unreachable through resolve (the action is absent without the port); guard direct callers.\n ports.diagnostics.capture(new Error(`requiresAuth action \"${action.id}\" ran signed out with no auth port`), {\n area: \"actions\",\n detail: { actionId: action.id },\n });\n return { status: \"failed\", error: new Error(\"sign-in unavailable\") };\n }\n ports.auth.signInThenResume({ actionId: action.id, contentFingerprint: options.contentFingerprint ?? action.id });\n return { status: \"auth-pending\" };\n }\n const reads = createProjectedReads(options.source ?? { surface: null, declaration: target.declaration, item: null });\n const signal = options.signal ?? new AbortController().signal;\n try {\n const outcome = await action.run(target, { reads, ports, signal });\n return { status: \"ran\", outcome };\n } catch (error) {\n ports.diagnostics.capture(error, { area: \"actions\", detail: { actionId: action.id, stage: \"run\" } });\n const label = typeof action.label === \"string\" ? action.label : action.id;\n ports.notify?.error(`${label} did not finish.`, \"Try again; if it keeps failing, report it from the feedback button.\");\n return { status: \"failed\", error };\n }\n}\n","/**\n * buildMenuModel — WHAT exists at a click target, as one framework-neutral\n * tree (CONTRACT §2.5). Categories GROUP, never gate: eligibility already ran\n * in the registry; this only arranges the resolved set into sections.\n */\nimport type { ActionCategory, ClickTarget, ResolvedAction } from \"../actions/types\";\nimport type { I18nPort } from \"../ports\";\nimport type { MenuGroup, MenuModel, MenuNode, MenuSection, MenuSubmenuNode } from \"./types\";\n\n/** THE category → menu group table (CONTRACT §2.5). */\nexport const CATEGORY_GROUP: Readonly<Record<ActionCategory, MenuGroup>> = {\n clipboard: \"clipboard\",\n copy: \"transfer\",\n export: \"transfer\",\n save: \"document\",\n share: \"document\",\n edit: \"editable\",\n history: \"history\",\n ai: \"ai\",\n ask: \"ai\",\n listen: \"tools\",\n study: \"tools\",\n app: \"tools\",\n feedback: \"quick\",\n creator: \"admin\",\n admin: \"admin\",\n \"surface-info\": \"surface-info\",\n};\n\n/** Classic order of the groups. `surface-info` is engine-built and always last. */\nexport const GROUP_ORDER: readonly MenuGroup[] = [\n \"clipboard\",\n \"editable\",\n \"transfer\",\n \"document\",\n \"history\",\n \"ai\",\n \"tools\",\n \"quick\",\n \"surface\",\n \"admin\",\n \"surface-info\",\n];\n\nconst CATEGORY_ORDER: readonly ActionCategory[] = [\n \"clipboard\",\n \"edit\",\n \"copy\",\n \"export\",\n \"save\",\n \"share\",\n \"history\",\n \"ask\",\n \"ai\",\n \"listen\",\n \"study\",\n \"app\",\n \"feedback\",\n \"creator\",\n \"admin\",\n \"surface-info\",\n];\n\nexport interface BuildMenuModelOptions {\n i18n?: I18nPort;\n /** Content the menu acts on when nothing is selected. */\n content?: string | null;\n}\n\nfunction translate(i18n: I18nPort | undefined, key: string, fallback: string): string {\n if (!i18n) return fallback;\n try {\n return i18n.t(key, fallback);\n } catch {\n return fallback;\n }\n}\n\n/** One resolved action → one model node (item, checkbox, link or lazy submenu). */\nexport function actionToNode(\n resolved: ResolvedAction,\n target: ClickTarget,\n options: BuildMenuModelOptions = {},\n): MenuNode {\n const { action, eligibility } = resolved;\n const rawLabel = typeof action.label === \"function\" ? action.label(target) : action.label;\n const label = translate(options.i18n, action.labelKey ?? action.id, rawLabel);\n const base = {\n id: action.id,\n actionId: action.id,\n ...(action.icon !== undefined ? { icon: action.icon } : {}),\n ...(action.placement !== undefined ? { placement: action.placement } : {}),\n };\n if (action.expand) {\n const node: MenuSubmenuNode = {\n ...base,\n kind: \"submenu\",\n label,\n lazy: true,\n loading: false,\n children: [],\n ...(action.emptyLabel !== undefined ? { emptyLabel: action.emptyLabel } : {}),\n };\n return node;\n }\n if (action.href !== undefined) {\n const href = typeof action.href === \"function\" ? action.href(target) : action.href;\n return { ...base, kind: \"link\", label, href };\n }\n if (action.toggle) {\n return {\n ...base,\n kind: \"checkbox\",\n label,\n checked: action.pressed?.(target) ?? false,\n ...(action.description !== undefined ? { description: action.description } : {}),\n };\n }\n const state = action.stateIcon?.(target) ?? null;\n const pressed = action.pressed?.(target);\n const hint = action.hint !== undefined ? translate(options.i18n, action.hintKey ?? `${action.id}.hint`, action.hint) : undefined;\n return {\n ...base,\n kind: \"item\",\n label,\n ...(action.iconTone !== undefined ? { iconTone: action.iconTone } : {}),\n ...(state ? { stateIcon: state } : {}),\n ...(action.description !== undefined ? { description: action.description } : {}),\n ...(hint !== undefined ? { hint } : {}),\n ...(pressed !== undefined ? { pressed } : {}),\n ...(action.destructive ? { destructive: true } : {}),\n ...(action.preserveSelection ? { preserveSelection: true } : {}),\n ...(eligibility.status === \"unavailable-verb\" ? { unavailable: { sentence: eligibility.sentence } } : {}),\n };\n}\n\nexport function buildMenuModel(\n target: ClickTarget,\n resolved: readonly ResolvedAction[],\n options: BuildMenuModelOptions = {},\n): MenuModel {\n const ordered = resolved\n .map((r, index) => ({ r, index }))\n .sort((a, b) => {\n const ca = CATEGORY_ORDER.indexOf(a.r.action.category);\n const cb = CATEGORY_ORDER.indexOf(b.r.action.category);\n if (ca !== cb) return ca - cb;\n const oa = a.r.action.order ?? 0;\n const ob = b.r.action.order ?? 0;\n if (oa !== ob) return oa - ob;\n return a.index - b.index;\n })\n .map((x) => x.r);\n\n const sections = new Map<string, MenuSection>();\n const roles: Record<string, string> = {};\n // An explicit section sits in the group of its first-registered action and\n // keeps its own row order (order, then registration) across categories.\n const explicit = new Map<string, { group: MenuGroup; rows: { r: ResolvedAction; index: number }[] }>();\n resolved.forEach((r, index) => {\n const sec = r.action.section;\n if (!sec) return;\n const entry = explicit.get(sec.id) ?? { group: CATEGORY_GROUP[r.action.category], rows: [] };\n entry.rows.push({ r, index });\n explicit.set(sec.id, entry);\n });\n const placed = new Set<string>();\n for (const r of ordered) {\n const sec = r.action.section;\n if (sec && placed.has(sec.id)) continue;\n const group = sec ? (explicit.get(sec.id)?.group ?? CATEGORY_GROUP[r.action.category]) : CATEGORY_GROUP[r.action.category];\n const sectionId = sec ? `section:${sec.id}` : group;\n let section = sections.get(sectionId);\n if (!section) {\n section = {\n id: sectionId,\n group,\n nodes: [],\n ...(sec ? { label: translate(options.i18n, sec.labelKey ?? `section.${sec.id}`, sec.label) } : {}),\n ...(sec?.icon !== undefined ? { icon: sec.icon } : {}),\n ...(sec?.primary ? { primary: true } : {}),\n };\n sections.set(sectionId, section);\n }\n const rows = sec\n ? (explicit.get(sec.id)?.rows ?? [])\n .sort((x, y) => (x.r.action.order ?? 0) - (y.r.action.order ?? 0) || x.index - y.index)\n .map((x) => x.r)\n : [r];\n if (sec) placed.add(sec.id);\n for (const row of rows) {\n section.nodes.push(actionToNode(row, target, options));\n if (row.action.verb) roles[row.action.verb] = row.action.id;\n }\n }\n\n const list = [...sections.values()].sort((a, b) => {\n if (Boolean(a.primary) !== Boolean(b.primary)) return a.primary ? -1 : 1;\n return GROUP_ORDER.indexOf(a.group) - GROUP_ORDER.indexOf(b.group);\n });\n\n const selected = target.selection?.text?.trim();\n const content = options.content?.trim();\n const header = selected\n ? { label: \"Selected\" as const, text: target.selection?.text ?? \"\" }\n : content\n ? { label: \"Content\" as const, text: options.content ?? \"\" }\n : null;\n\n return { header, sections: list, roles };\n}\n\n/** Fill a lazy submenu's rows once they load (pure: returns a new model). */\nexport function withExpandedChildren(model: MenuModel, nodeId: string, children: MenuNode[] | \"loading\"): MenuModel {\n const visit = (nodes: MenuNode[]): MenuNode[] =>\n nodes.map((n) => {\n if (n.kind !== \"submenu\") return n;\n if (n.id === nodeId) {\n return children === \"loading\" ? { ...n, loading: true } : { ...n, lazy: false, loading: false, children };\n }\n return { ...n, children: visit(n.children) };\n });\n return { ...model, sections: model.sections.map((s) => ({ ...s, nodes: visit(s.nodes) })) };\n}\n\n/** Find a node anywhere in a tree. */\nexport function findNode(nodes: readonly MenuNode[], id: string): MenuNode | null {\n for (const n of nodes) {\n if (n.id === id) return n;\n if (n.kind === \"submenu\") {\n const hit = findNode(n.children, id);\n if (hit) return hit;\n }\n }\n return null;\n}\n","/**\n * The shared React context (T0-safe: imports only React and types). Shared\n * through globalThis so every per-layout bundle reads the same provider.\n */\nimport * as React from \"react\";\nimport type { ActionRegistry } from \"../actions/types\";\nimport type { AlchemyHostPorts } from \"../ports\";\n\nexport interface AlchemyActionsValue {\n registry: ActionRegistry;\n ports: AlchemyHostPorts;\n}\n\nconst KEY = Symbol.for(\"ai-matrx.alchemy.actions-context\");\ntype Holder = { [KEY]?: React.Context<AlchemyActionsValue | null> };\nexport const AlchemyActionsContext: React.Context<AlchemyActionsValue | null> =\n ((globalThis as Holder)[KEY] ??= React.createContext<AlchemyActionsValue | null>(null));\n\nexport function useAlchemyActions(): AlchemyActionsValue {\n const value = React.useContext(AlchemyActionsContext);\n if (!value) throw new Error(\"Alchemy actions: render inside <AlchemyActionsProvider> (@ai-matrx/alchemy/react/host).\");\n return value;\n}\n"],"mappings":";;;AAMA,SAAS,eAAe,cAAc,cAAc,cAAc,aAAa,mBAAmB;;;ACiClG,SAAS,OAAO,MAAsC;AACpD,SAAO,KAAK,SAAS,UAAU,KAAK,SAAS,cAAc,KAAK,SAAS;AAC3E;AAuMO,SAAS,QAAQ,OAAmC;AACzD,QAAM,SAAoC,CAAC;AAC3C,QAAM,OAAO,CAAC,OAA4B,UAAoB;AAC5D,eAAW,KAAK,OAAO;AACrB,UAAI,OAAO,CAAC,EAAG,QAAO,KAAK,EAAE,MAAM,GAAG,YAAY,MAAM,CAAC;AAAA,eAChD,EAAE,SAAS,WAAW;AAC7B,YAAI,EAAE,KAAM,QAAO,KAAK,EAAE,MAAM,GAAG,YAAY,MAAM,CAAC;AAAA,YACjD,MAAK,EAAE,UAAU,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC;AAAA,MAC3C;AAAA,IACF;AAAA,EACF;AACA,aAAW,KAAK,MAAM,SAAU,MAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;AACtE,SAAO,EAAE,OAAO;AAClB;;;ACnPA,YAAYA,YAAW;;;ACHhB,IAAM,sBAAmC,OAAO,OAAO;AAAA,EAC5D,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,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