@soffits/dsh-plugin-sdk 0.0.0-stage → 0.1.0
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 +5 -0
- package/LICENSE +21 -0
- package/LICENSE-lucide +45 -0
- package/NOTICE +9 -0
- package/README.md +42 -2
- package/actions/README.md +67 -0
- package/actions/client.js +606 -0
- package/actions/src/item.js +120 -0
- package/channel/README.md +24 -0
- package/channel/index.js +49 -0
- package/channel/src/answer.js +105 -0
- package/channel/src/config.js +18 -0
- package/channel/src/models.js +210 -0
- package/channel/src/principal.js +153 -0
- package/channel/src/sessions.js +372 -0
- package/channel/src/spool.js +175 -0
- package/channel/src/subagents.js +540 -0
- package/channel/src/voice.js +127 -0
- package/channel/testing.js +132 -0
- package/client.js +1762 -0
- package/cordis.patch.yml +4 -0
- package/host/README.md +44 -0
- package/host/build.js +1 -0
- package/host/index.js +4 -0
- package/host/src/build-client.js +104 -0
- package/host/src/event-streams.js +88 -0
- package/host/src/locales.js +90 -0
- package/host/src/notices.js +66 -0
- package/host/src/people.js +87 -0
- package/icon.svg +1 -0
- package/index.js +7 -0
- package/locale/en.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +80 -4
- package/ui/README.md +87 -0
- package/ui/client.js +1138 -0
- package/ui/icons.json +228 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
/* @soffits/dsh-plugin-sdk/actions: built by scripts/build.mjs from src/client/ and locale/. Do not edit. */
|
|
2
|
+
window.__ModuleLoader__.load({
|
|
3
|
+
id: "@soffits/dsh-plugin-sdk/actions",
|
|
4
|
+
factory: (require) => {
|
|
5
|
+
var module = { exports: {} }
|
|
6
|
+
var exports = module.exports
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name2 in all)
|
|
13
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// actions/src/client/index.js
|
|
26
|
+
var index_exports = {};
|
|
27
|
+
__export(index_exports, {
|
|
28
|
+
NS: () => NS,
|
|
29
|
+
apply: () => apply,
|
|
30
|
+
inject: () => inject,
|
|
31
|
+
name: () => name
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
var import_react5 = require("react");
|
|
35
|
+
|
|
36
|
+
// locales:locales
|
|
37
|
+
var locales_default = { "en": { "meta": { "title": "UI actions", "description": "Shared buttons for plugin pages (ask, done, snooze, open) and items attached to a chat as a card." }, "ui": { "chat": "Ask", "chatAbout": "Chat about this", "done": "Done", "snooze": "Snooze", "event": "Go", "link": "Open", "in3h": "In 3 hours", "tomorrow": "Tomorrow 9:00", "pick": "Pick a time\u2026", "set": "Snooze", "cancel": "Cancel", "sending": "Sending\u2026", "pending": "Waiting for it to be picked up", "handled": "Done", "unhandled": "Nothing picked this up yet", "failed": "Didn\u2019t go through: {message}", "noWorkspace": "Open a conversation once first, then try again.", "noSession": "That conversation didn\u2019t open. Try again from the conversation list.", "busy": "The message box is busy sending; try again in a moment.", "noHandler": "This button has nothing to send its press to.", "starting": "Starting\u2026", "started": "Started", "openSession": "Open conversation" } }, "fr": { "meta": { "title": "Actions d\u2019interface", "description": "Boutons partag\xE9s des pages de plugins (demander, fait, plus tard, ouvrir) et \xE9l\xE9ments joints \xE0 une conversation sous forme de carte." }, "ui": { "chat": "Demander", "chatAbout": "En discuter", "done": "Fait", "snooze": "Plus tard", "event": "Lancer", "link": "Ouvrir", "in3h": "Dans 3 heures", "tomorrow": "Demain 9:00", "pick": "Choisir une heure\u2026", "set": "Rappeler", "cancel": "Annuler", "sending": "Envoi\u2026", "pending": "En attente de traitement", "handled": "Fait", "unhandled": "Personne ne l\u2019a encore pris en charge", "failed": "\xC9chec : {message}", "noWorkspace": "Ouvrez d\u2019abord une conversation, puis r\xE9essayez.", "noSession": "La conversation ne s\u2019est pas ouverte. R\xE9essayez depuis la liste des conversations.", "busy": "La zone de message est en cours d\u2019envoi ; r\xE9essayez dans un instant.", "noHandler": "Ce bouton n\u2019a rien \xE0 qui transmettre l\u2019appui.", "starting": "D\xE9marrage\u2026", "started": "Lanc\xE9", "openSession": "Ouvrir la conversation" } }, "zh": { "meta": { "title": "\u754C\u9762\u64CD\u4F5C", "description": "\u63D2\u4EF6\u9875\u9762\u5171\u7528\u7684\u6309\u94AE\uFF08\u63D0\u95EE\u3001\u5B8C\u6210\u3001\u7A0D\u540E\u63D0\u9192\u3001\u6253\u5F00\uFF09\uFF0C\u4EE5\u53CA\u4EE5\u5361\u7247\u5F62\u5F0F\u9644\u5728\u5BF9\u8BDD\u91CC\u7684\u6761\u76EE\u3002" }, "ui": { "chat": "\u95EE\u95EE", "chatAbout": "\u804A\u804A\u8FD9\u4E2A", "done": "\u5B8C\u6210", "snooze": "\u7A0D\u540E\u63D0\u9192", "event": "\u6267\u884C", "link": "\u6253\u5F00", "in3h": "3 \u5C0F\u65F6\u540E", "tomorrow": "\u660E\u5929 9:00", "pick": "\u9009\u4E2A\u65F6\u95F4\u2026", "set": "\u7A0D\u540E\u63D0\u9192", "cancel": "\u53D6\u6D88", "sending": "\u53D1\u9001\u4E2D\u2026", "pending": "\u7B49\u5F85\u5904\u7406", "handled": "\u5DF2\u5904\u7406", "unhandled": "\u8FD8\u6CA1\u6709\u88AB\u5904\u7406", "failed": "\u6CA1\u6709\u6210\u529F\uFF1A{message}", "noWorkspace": "\u8BF7\u5148\u6253\u5F00\u4E00\u6B21\u5BF9\u8BDD\uFF0C\u518D\u8BD5\u4E00\u6B21\u3002", "noSession": "\u6CA1\u80FD\u6253\u5F00\u90A3\u4E2A\u4F1A\u8BDD\uFF0C\u8BF7\u4ECE\u4F1A\u8BDD\u5217\u8868\u518D\u8BD5\u4E00\u6B21\u3002", "busy": "\u8F93\u5165\u6846\u6B63\u5728\u53D1\u9001\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002", "noHandler": "\u8FD9\u4E2A\u6309\u94AE\u6CA1\u6709\u63A5\u6536\u65B9\u3002", "starting": "\u6B63\u5728\u5F00\u59CB\u2026", "started": "\u5DF2\u5F00\u59CB", "openSession": "\u6253\u5F00\u5BF9\u8BDD" } } };
|
|
38
|
+
|
|
39
|
+
// actions/src/item.js
|
|
40
|
+
var TITLE_MAX = 200;
|
|
41
|
+
var LINE_MAX = 300;
|
|
42
|
+
var MAX_LINES = 15;
|
|
43
|
+
var CONTEXT_MAX = 2e3;
|
|
44
|
+
var MARKER = /^\[Item from (.+) \(([^\s()]+)\)\]$/;
|
|
45
|
+
var CONTEXT = "context: ";
|
|
46
|
+
function oneLine(value, max) {
|
|
47
|
+
const text = String(value ?? "").replace(/\s+/gu, " ").trim();
|
|
48
|
+
const chars = Array.from(text);
|
|
49
|
+
return chars.length > max ? `${chars.slice(0, max - 1).join("")}\u2026` : text;
|
|
50
|
+
}
|
|
51
|
+
function itemText({ source, sourceName, title, lines = [], context }) {
|
|
52
|
+
const id = oneLine(source, 120).replace(/[\s()]/gu, "");
|
|
53
|
+
const name2 = oneLine(sourceName || id, 80).replace(/\]/gu, ")");
|
|
54
|
+
const out = [oneLine(title, TITLE_MAX) || "\u2026", `[Item from ${name2} (${id})]`];
|
|
55
|
+
for (const line of lines) {
|
|
56
|
+
if (out.length > MAX_LINES + 1) break;
|
|
57
|
+
const text = oneLine(line, LINE_MAX);
|
|
58
|
+
if (text !== "") out.push(text);
|
|
59
|
+
}
|
|
60
|
+
if (context !== void 0 && context !== null) {
|
|
61
|
+
const json = JSON.stringify(context);
|
|
62
|
+
if (json !== void 0 && json.length <= CONTEXT_MAX) out.push(`${CONTEXT}${json}`);
|
|
63
|
+
}
|
|
64
|
+
return out.join("\n");
|
|
65
|
+
}
|
|
66
|
+
function parseItem(text) {
|
|
67
|
+
const rows = String(text).replace(/\r\n?/gu, "\n").split("\n");
|
|
68
|
+
const marker = MARKER.exec(rows[1] ?? "");
|
|
69
|
+
if (marker === null || (rows[0] ?? "").trim() === "") return null;
|
|
70
|
+
const lines = rows.slice(2).filter((line) => line.trim() !== "");
|
|
71
|
+
const item = { source: marker[2], sourceName: marker[1], title: rows[0].trim(), lines };
|
|
72
|
+
const last = lines[lines.length - 1];
|
|
73
|
+
if (last?.startsWith(CONTEXT)) {
|
|
74
|
+
try {
|
|
75
|
+
item.context = JSON.parse(last.slice(CONTEXT.length));
|
|
76
|
+
lines.pop();
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return item;
|
|
81
|
+
}
|
|
82
|
+
var unquote = (text) => text.replace(/\r\n?/gu, "\n").replace(/^ {0,3}>[ \t]?/gmu, "");
|
|
83
|
+
function itemRanges(text) {
|
|
84
|
+
const ranges = [];
|
|
85
|
+
for (const match of String(text).matchAll(/^ {0,3}>[^\r\n]*(?:\r?\n {0,3}>[^\r\n]*)*/gmu)) {
|
|
86
|
+
const item = parseItem(unquote(match[0]));
|
|
87
|
+
if (item !== null) ranges.push({ start: match.index, end: match.index + match[0].length, item });
|
|
88
|
+
}
|
|
89
|
+
return ranges;
|
|
90
|
+
}
|
|
91
|
+
function itemSummary({ sourceName, title, lines = [] }) {
|
|
92
|
+
const shown = lines.map((line) => oneLine(line, LINE_MAX)).filter(Boolean);
|
|
93
|
+
return {
|
|
94
|
+
label: oneLine(title, TITLE_MAX) || "\u2026",
|
|
95
|
+
title: oneLine(title, TITLE_MAX) || "\u2026",
|
|
96
|
+
detail: oneLine(sourceName, 80),
|
|
97
|
+
body: shown.join("\n")
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function stepMessage(instruction, item) {
|
|
101
|
+
const quote = itemText(item).split("\n").map((line) => `> ${line}`).join("\n");
|
|
102
|
+
return `${String(instruction).trim()}
|
|
103
|
+
|
|
104
|
+
${quote}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// actions/src/rule.js
|
|
108
|
+
var ITEM_NODE = "ui-actions-item";
|
|
109
|
+
var cache = /* @__PURE__ */ new Map();
|
|
110
|
+
function rangesOf(text) {
|
|
111
|
+
let ranges = cache.get(text);
|
|
112
|
+
if (ranges === void 0) {
|
|
113
|
+
ranges = itemRanges(text);
|
|
114
|
+
if (cache.size > 200) cache.clear();
|
|
115
|
+
cache.set(text, ranges);
|
|
116
|
+
}
|
|
117
|
+
return ranges;
|
|
118
|
+
}
|
|
119
|
+
var itemRule = {
|
|
120
|
+
id: ITEM_NODE,
|
|
121
|
+
order: -20,
|
|
122
|
+
match(text, from) {
|
|
123
|
+
for (const range of rangesOf(text)) {
|
|
124
|
+
const lead = text.slice(0, range.start).match(/\r?\n(?:[ \t]*\r?\n)*$/u)?.[0];
|
|
125
|
+
if (lead && range.start - lead.length >= from) return { id: "text", start: range.start - lead.length, end: range.start, data: { text: lead, display: "\n" } };
|
|
126
|
+
if (range.start >= from) return { id: ITEM_NODE, start: range.start, end: range.end, data: range.item };
|
|
127
|
+
const gap = text.slice(range.end).match(/^\r?\n(?:[ \t]*\r?\n)*/u)?.[0];
|
|
128
|
+
if (range.end >= from && gap) return { id: "text", start: range.end, end: range.end + gap.length, data: { text: gap, display: "\n" } };
|
|
129
|
+
}
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// actions/src/client/bar.js
|
|
135
|
+
var import_react = require("react");
|
|
136
|
+
|
|
137
|
+
// actions/src/text.js
|
|
138
|
+
function pickText(value, language = "en") {
|
|
139
|
+
if (typeof value === "string") return value;
|
|
140
|
+
if (value === null || typeof value !== "object") return "";
|
|
141
|
+
const tags = Object.keys(value);
|
|
142
|
+
const want = String(language).toLowerCase();
|
|
143
|
+
const primary = want.split("-")[0];
|
|
144
|
+
const found = tags.find((tag) => tag.toLowerCase() === want) ?? tags.find((tag) => tag.toLowerCase() === primary) ?? tags.find((tag) => tag.toLowerCase().split("-")[0] === primary) ?? tags.find((tag) => tag.toLowerCase() === "en") ?? tags[0];
|
|
145
|
+
return typeof value[found] === "string" ? value[found] : "";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// actions/src/client/look.js
|
|
149
|
+
var STYLE_ID = "dsh-ui-actions-style";
|
|
150
|
+
var CSS = `
|
|
151
|
+
.ua-bar{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-width:0}
|
|
152
|
+
.ua-btn{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;max-width:100%;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:18px;cursor:pointer;text-decoration:none;box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l3)}
|
|
153
|
+
.ua-btn span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
154
|
+
.ua-btn svg{flex:none;width:14px;height:14px}
|
|
155
|
+
.ua-btn:disabled{cursor:default;opacity:.7}
|
|
156
|
+
@media (hover:hover){.ua-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}
|
|
157
|
+
.ua-icon{width:32px;padding:0;box-shadow:none;color:var(--dsw-alias-label-tertiary)}
|
|
158
|
+
.ua-btn[data-state=pending] svg,.ua-btn[data-state=sending] svg{animation:ua-pulse 1.2s ease-in-out infinite}
|
|
159
|
+
.ua-btn[data-state=done]{color:var(--dsw-alias-state-success-primary)}
|
|
160
|
+
.ua-btn[data-state=unhandled]{color:var(--dsw-alias-state-warn-label,var(--dsw-alias-state-warn-primary))}
|
|
161
|
+
@keyframes ua-pulse{50%{opacity:.35}}
|
|
162
|
+
.ua-wrap{position:relative;display:inline-flex;max-width:100%;flex-wrap:wrap;align-items:center;gap:4px 8px}
|
|
163
|
+
.ua-menu{position:absolute;z-index:20;top:calc(100% + 4px);right:0;min-width:168px;padding:4px;border-radius:12px;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base));box-shadow:0 6px 24px #0000001f,inset 0 0 0 .5px var(--dsw-alias-border-l2);display:flex;flex-direction:column}
|
|
164
|
+
.ua-menu button{display:flex;align-items:center;gap:8px;min-height:36px;padding:7px 10px;border:0;border-radius:8px;background:none;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;text-align:left;cursor:pointer}
|
|
165
|
+
@media (hover:hover){.ua-menu button:hover{background:var(--dsw-alias-interactive-bg-hover)}}
|
|
166
|
+
.ua-menu input{margin:4px 6px;min-height:36px;padding:6px 8px;border:.5px solid var(--dsw-alias-border-l3);border-radius:8px;background:transparent;color:inherit;font:inherit;font-size:16px}
|
|
167
|
+
.ua-menuRow{display:flex;justify-content:flex-end;gap:4px;padding:2px 4px}
|
|
168
|
+
.ua-error{flex-basis:100%;color:var(--dsw-alias-state-error-primary);font-size:12px;overflow-wrap:anywhere}
|
|
169
|
+
@media (width<=768px),(pointer:coarse){
|
|
170
|
+
.ua-btn{min-height:40px}
|
|
171
|
+
.ua-icon{width:40px}
|
|
172
|
+
.ua-menu{position:fixed;z-index:1000;top:auto;left:12px;right:12px;bottom:12px;max-height:60vh;overflow:auto;padding:8px;box-shadow:0 8px 40px #00000040,inset 0 0 0 .5px var(--dsw-alias-border-l2)}
|
|
173
|
+
.ua-menu button{min-height:44px;font-size:15px}
|
|
174
|
+
.ua-menu input{min-height:44px}
|
|
175
|
+
}
|
|
176
|
+
.ua-break{flex-basis:100%;height:0}
|
|
177
|
+
.ua-stepWrap{display:inline-flex;flex-wrap:wrap;align-items:center;gap:4px 8px;max-width:100%}
|
|
178
|
+
.ua-step{box-sizing:border-box;display:inline-flex;align-items:flex-start;gap:8px;min-height:32px;max-width:100%;padding:6px 12px;border:0;border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 10%,transparent);color:var(--dsw-alias-state-business-primary);font:inherit;font-size:13px;line-height:20px;text-align:left;cursor:pointer;white-space:normal;overflow-wrap:anywhere}
|
|
179
|
+
.ua-step svg{flex:none;width:14px;height:14px;margin-top:3px}
|
|
180
|
+
@media (hover:hover){.ua-step:hover:not(:disabled):not([data-state=started]){background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 18%,transparent)}}
|
|
181
|
+
.ua-step:disabled{cursor:default}
|
|
182
|
+
.ua-step[data-state=starting] svg{animation:ua-pulse 1.2s ease-in-out infinite}
|
|
183
|
+
.ua-step[data-state=started]{background:transparent;box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l3);color:var(--dsw-alias-label-secondary);cursor:default}
|
|
184
|
+
.ua-step[data-state=started] svg{color:var(--dsw-alias-state-success-primary)}
|
|
185
|
+
.ua-stepOpen{border:0;background:none;padding:4px 2px;color:var(--dsw-alias-state-business-primary);font:inherit;font-size:13px;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
|
|
186
|
+
@media (width<=640px){.ua-stepWrap,.ua-step{width:100%}.ua-step{min-height:40px;padding:9px 12px}}
|
|
187
|
+
.ua-item{box-sizing:border-box;display:inline-flex;align-items:center;gap:10px;vertical-align:top;width:min(100%,320px);max-width:100%;padding:8px 12px 8px 8px;border-radius:12px;background:var(--dsw-alias-bg-base);box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);text-align:left;white-space:normal;line-height:18px}
|
|
188
|
+
.ua-itemIcon{flex:none;display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:8px;background:var(--dsw-alias-bg-layer-1,var(--dsw-alias-interactive-bg-hover));color:var(--dsw-alias-label-secondary)}
|
|
189
|
+
.ua-itemIcon svg{width:18px;height:18px}
|
|
190
|
+
.ua-itemText{display:flex;flex-direction:column;min-width:0;flex:1}
|
|
191
|
+
.ua-itemText span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
192
|
+
.ua-itemSource{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
|
|
193
|
+
.ua-itemTitle{font-size:13px;font-weight:500}
|
|
194
|
+
.ua-itemLine{color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
195
|
+
`;
|
|
196
|
+
var PATHS = {
|
|
197
|
+
chat: "M3 4.5A1.5 1.5 0 0 1 4.5 3h7A1.5 1.5 0 0 1 13 4.5v5A1.5 1.5 0 0 1 11.5 11H7l-3 2.5V11h.5A1.5 1.5 0 0 1 3 9.5z",
|
|
198
|
+
done: "M3.5 8.5l3 3 6-7",
|
|
199
|
+
snooze: "M8 4.5V8l2.2 1.4M13.5 8a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z",
|
|
200
|
+
event: "M8.8 2.5 4 9h4l-.8 4.5L12 7H8z",
|
|
201
|
+
link: "M6 3.5H3.5v9h9V10M9 3h4v4M13 3 7.5 8.5",
|
|
202
|
+
pending: "M8 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0",
|
|
203
|
+
unhandled: "M8 3.5v5.5M8 12v.5",
|
|
204
|
+
step: "M3 8h8.5M8.5 4.5 12 8l-3.5 3.5",
|
|
205
|
+
item: "M3.5 2.5h6l3 3v8h-9zM9.5 2.5v3h3M5.5 8.5h5M5.5 11h3.5"
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// actions/src/client/bar.js
|
|
209
|
+
function tomorrowMorning(now = /* @__PURE__ */ new Date()) {
|
|
210
|
+
const date = new Date(now);
|
|
211
|
+
date.setDate(date.getDate() + 1);
|
|
212
|
+
date.setHours(9, 0, 0, 0);
|
|
213
|
+
return date.toISOString();
|
|
214
|
+
}
|
|
215
|
+
var DEFAULT_CHAT = Object.freeze({ kind: "chat", id: "_chat" });
|
|
216
|
+
function Glyph({ name: name2 }) {
|
|
217
|
+
return (0, import_react.createElement)(
|
|
218
|
+
"svg",
|
|
219
|
+
{ viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, focusable: "false" },
|
|
220
|
+
(0, import_react.createElement)("path", { d: PATHS[name2] ?? PATHS.event })
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
function createBar({ useWords, useLanguage, chat, start, open }) {
|
|
224
|
+
function SnoozeMenu({ onPick, onClose }) {
|
|
225
|
+
const t = useWords();
|
|
226
|
+
const [picking, setPicking] = (0, import_react.useState)(false);
|
|
227
|
+
const [value, setValue] = (0, import_react.useState)("");
|
|
228
|
+
const ref = (0, import_react.useRef)(null);
|
|
229
|
+
(0, import_react.useEffect)(() => {
|
|
230
|
+
const away = (event) => {
|
|
231
|
+
if (ref.current && !ref.current.contains(event.target)) onClose();
|
|
232
|
+
};
|
|
233
|
+
const escape = (event) => {
|
|
234
|
+
if (event.key === "Escape") onClose();
|
|
235
|
+
};
|
|
236
|
+
document.addEventListener("pointerdown", away);
|
|
237
|
+
document.addEventListener("keydown", escape);
|
|
238
|
+
return () => {
|
|
239
|
+
document.removeEventListener("pointerdown", away);
|
|
240
|
+
document.removeEventListener("keydown", escape);
|
|
241
|
+
};
|
|
242
|
+
}, [onClose]);
|
|
243
|
+
return (0, import_react.createElement)(
|
|
244
|
+
"div",
|
|
245
|
+
{ className: "ua-menu", ref, role: "menu" },
|
|
246
|
+
!picking && (0, import_react.createElement)("button", { type: "button", role: "menuitem", onClick: () => onPick(new Date(Date.now() + 3 * 3600 * 1e3).toISOString()) }, t("in3h")),
|
|
247
|
+
!picking && (0, import_react.createElement)("button", { type: "button", role: "menuitem", onClick: () => onPick(tomorrowMorning()) }, t("tomorrow")),
|
|
248
|
+
!picking && (0, import_react.createElement)("button", { type: "button", role: "menuitem", onClick: () => setPicking(true) }, t("pick")),
|
|
249
|
+
picking && (0, import_react.createElement)("input", { type: "datetime-local", value, autoFocus: true, onChange: (event) => setValue(event.target.value) }),
|
|
250
|
+
picking && (0, import_react.createElement)(
|
|
251
|
+
"div",
|
|
252
|
+
{ className: "ua-menuRow" },
|
|
253
|
+
(0, import_react.createElement)("button", { type: "button", onClick: onClose }, t("cancel")),
|
|
254
|
+
(0, import_react.createElement)("button", { type: "button", disabled: value === "", onClick: () => onPick(new Date(value).toISOString()) }, t("set"))
|
|
255
|
+
)
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
function ActionButton({ action, state, compact = false, about, onPress }) {
|
|
259
|
+
if (action.kind === "step") return (0, import_react.createElement)(StepButton, { action, state, about, onPress });
|
|
260
|
+
const t = useWords();
|
|
261
|
+
const language = useLanguage();
|
|
262
|
+
const [local, setLocal] = (0, import_react.useState)(null);
|
|
263
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
264
|
+
const [menu, setMenu] = (0, import_react.useState)(false);
|
|
265
|
+
(0, import_react.useEffect)(() => {
|
|
266
|
+
if (state) setLocal(null);
|
|
267
|
+
}, [state]);
|
|
268
|
+
const shown = local ?? state;
|
|
269
|
+
const label = pickText(action.label, language) || t(action.kind === "chat" && action.id === DEFAULT_CHAT.id ? "chatAbout" : action.kind);
|
|
270
|
+
const title = shown === "sending" ? t("sending") : shown === "pending" ? t("pending") : shown === "done" ? t("handled") : shown === "unhandled" ? t("unhandled") : error ?? label;
|
|
271
|
+
const icon = shown === "done" ? "done" : shown === "unhandled" ? "unhandled" : action.kind;
|
|
272
|
+
const iconOnly = compact && !(action.kind === "done" && pickText(action.label, language));
|
|
273
|
+
const className = `ua-btn${iconOnly ? " ua-icon" : ""}`;
|
|
274
|
+
const content = [(0, import_react.createElement)(Glyph, { key: "i", name: icon }), !iconOnly && (0, import_react.createElement)("span", { key: "l" }, label)];
|
|
275
|
+
if (action.kind === "link") {
|
|
276
|
+
const url = action.payload?.url;
|
|
277
|
+
const external = /^https?:/i.test(url ?? "");
|
|
278
|
+
return (0, import_react.createElement)("a", { className, href: url, title: label, "aria-label": label, ...external ? { target: "_blank", rel: "noopener noreferrer" } : {} }, content);
|
|
279
|
+
}
|
|
280
|
+
const send = async (extra) => {
|
|
281
|
+
setMenu(false);
|
|
282
|
+
setError(null);
|
|
283
|
+
setLocal("sending");
|
|
284
|
+
try {
|
|
285
|
+
if (action.kind === "chat") {
|
|
286
|
+
const payload = action.payload ?? {};
|
|
287
|
+
await chat({ ...about, ...payload.context === void 0 ? {} : { context: payload.context } }, { prompt: pickText(payload.prompt, language), session: payload.session ?? "new" });
|
|
288
|
+
setLocal(null);
|
|
289
|
+
} else {
|
|
290
|
+
if (onPress === void 0) throw new Error(t("noHandler"));
|
|
291
|
+
await onPress(action, extra ?? {});
|
|
292
|
+
setLocal("pending");
|
|
293
|
+
}
|
|
294
|
+
} catch (reason) {
|
|
295
|
+
setLocal(null);
|
|
296
|
+
setError(t("failed", { message: reason?.message ?? String(reason) }));
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const onClick = () => {
|
|
300
|
+
if (action.kind === "snooze" && action.payload?.until === void 0) setMenu((open2) => !open2);
|
|
301
|
+
else send();
|
|
302
|
+
};
|
|
303
|
+
const busy = shown === "sending" || shown === "pending";
|
|
304
|
+
return (0, import_react.createElement)(
|
|
305
|
+
"span",
|
|
306
|
+
{ className: "ua-wrap" },
|
|
307
|
+
(0, import_react.createElement)("button", { type: "button", className, title, "aria-label": title !== label ? `${label} (${title})` : label, "data-state": shown ?? void 0, disabled: busy, onClick }, content),
|
|
308
|
+
menu && (0, import_react.createElement)(SnoozeMenu, { onPick: (until) => send({ until }), onClose: () => setMenu(false) }),
|
|
309
|
+
error && !iconOnly && (0, import_react.createElement)("span", { className: "ua-error", role: "alert" }, error)
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
function StepButton({ action, state, about, onPress }) {
|
|
313
|
+
const t = useWords();
|
|
314
|
+
const language = useLanguage();
|
|
315
|
+
const [local, setLocal] = (0, import_react.useState)(null);
|
|
316
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
317
|
+
const label = pickText(action.label, language);
|
|
318
|
+
const session = typeof local === "object" && local !== null ? local.session : null;
|
|
319
|
+
const shown = local === "starting" ? "starting" : session || state ? "started" : "ready";
|
|
320
|
+
const run = async () => {
|
|
321
|
+
setError(null);
|
|
322
|
+
setLocal("starting");
|
|
323
|
+
try {
|
|
324
|
+
if (onPress === void 0) throw new Error(t("noHandler"));
|
|
325
|
+
await onPress(action, {});
|
|
326
|
+
const payload = action.payload ?? {};
|
|
327
|
+
const instruction = pickText(payload.prompt, language) || label;
|
|
328
|
+
const id = await start({ ...about, ...payload.context === void 0 ? {} : { context: payload.context } }, { instruction, session: payload.session ?? "new" });
|
|
329
|
+
setLocal({ session: id });
|
|
330
|
+
} catch (reason) {
|
|
331
|
+
setLocal(null);
|
|
332
|
+
setError(t("failed", { message: reason?.message ?? String(reason) }));
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
if (shown === "started") {
|
|
336
|
+
return (0, import_react.createElement)(
|
|
337
|
+
"span",
|
|
338
|
+
{ className: "ua-stepWrap" },
|
|
339
|
+
(0, import_react.createElement)(
|
|
340
|
+
"span",
|
|
341
|
+
{ className: "ua-step", "data-state": "started", title: t("started") },
|
|
342
|
+
(0, import_react.createElement)(Glyph, { name: "done" }),
|
|
343
|
+
(0, import_react.createElement)("span", null, label)
|
|
344
|
+
),
|
|
345
|
+
session !== null && (0, import_react.createElement)("button", { type: "button", className: "ua-stepOpen", onClick: () => open(session) }, t("openSession"))
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
return (0, import_react.createElement)(
|
|
349
|
+
"span",
|
|
350
|
+
{ className: "ua-stepWrap" },
|
|
351
|
+
(0, import_react.createElement)(
|
|
352
|
+
"button",
|
|
353
|
+
{ type: "button", className: "ua-step", "data-state": shown, disabled: shown === "starting", title: shown === "starting" ? t("starting") : label, onClick: run },
|
|
354
|
+
(0, import_react.createElement)(Glyph, { name: shown === "starting" ? "pending" : "step" }),
|
|
355
|
+
(0, import_react.createElement)("span", null, label)
|
|
356
|
+
),
|
|
357
|
+
error && (0, import_react.createElement)("span", { className: "ua-error", role: "alert" }, error)
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
function ActionBar({ actions = [], states = {}, compact = false, about, defaultChat = false, part, onPress, children }) {
|
|
361
|
+
const declared = defaultChat && about !== void 0 && !actions.some((action) => action.kind === "chat") ? [DEFAULT_CHAT, ...actions] : actions;
|
|
362
|
+
const steps = part === "buttons" ? [] : declared.filter((action) => action.kind === "step");
|
|
363
|
+
const rest = part === "steps" ? [] : declared.filter((action) => action.kind !== "step");
|
|
364
|
+
if (steps.length + rest.length === 0) return children ? (0, import_react.createElement)("div", { className: "ua-bar" }, children) : null;
|
|
365
|
+
const button = (action) => (0, import_react.createElement)(ActionButton, { key: action.id, action, state: states[action.id], compact, about, onPress });
|
|
366
|
+
return (0, import_react.createElement)("div", { className: "ua-bar" }, steps.map(button), steps.length > 0 && rest.length > 0 && (0, import_react.createElement)("span", { key: "_break", className: "ua-break", "aria-hidden": true }), rest.map(button), children);
|
|
367
|
+
}
|
|
368
|
+
return { ActionBar, ActionButton };
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// actions/src/client/card.js
|
|
372
|
+
var import_react2 = require("react");
|
|
373
|
+
function createCard({ sources }) {
|
|
374
|
+
return function ItemCard({ node }) {
|
|
375
|
+
const item = node.data;
|
|
376
|
+
const source = sources.useSource(item.source);
|
|
377
|
+
const name2 = source?.name || item.sourceName;
|
|
378
|
+
const Icon = source?.icon;
|
|
379
|
+
const line = item.lines[0];
|
|
380
|
+
return (0, import_react2.createElement)(
|
|
381
|
+
"span",
|
|
382
|
+
{ className: "ua-item", "data-item-source": item.source, title: [`${name2}: ${item.title}`, ...item.lines].join("\n") },
|
|
383
|
+
(0, import_react2.createElement)("span", { className: "ua-itemIcon", "aria-hidden": true }, Icon ? (0, import_react2.createElement)(Icon, { size: 18 }) : (0, import_react2.createElement)(Glyph, { name: "item" })),
|
|
384
|
+
(0, import_react2.createElement)(
|
|
385
|
+
"span",
|
|
386
|
+
{ className: "ua-itemText" },
|
|
387
|
+
(0, import_react2.createElement)("span", { className: "ua-itemSource" }, name2),
|
|
388
|
+
(0, import_react2.createElement)("span", { className: "ua-itemTitle" }, item.title),
|
|
389
|
+
line && (0, import_react2.createElement)("span", { className: "ua-itemLine" }, line)
|
|
390
|
+
)
|
|
391
|
+
);
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// actions/src/client/chat.js
|
|
396
|
+
var import_react3 = require("react");
|
|
397
|
+
|
|
398
|
+
// actions/src/pending.js
|
|
399
|
+
var PENDING_MS = 6e4;
|
|
400
|
+
var sameDraft = (a, b) => a.replace(/\s+/gu, " ").trim() === b.replace(/\s+/gu, " ").trim();
|
|
401
|
+
function draftText(itemText2, prompt = "") {
|
|
402
|
+
const quote = itemText2.split("\n").map((line) => `> ${line}`).join("\n");
|
|
403
|
+
return prompt.trim() === "" ? quote : `${quote}
|
|
404
|
+
|
|
405
|
+
${prompt}`;
|
|
406
|
+
}
|
|
407
|
+
function createPending() {
|
|
408
|
+
let requests = [];
|
|
409
|
+
return {
|
|
410
|
+
/** @param {{ draft: string }} request */
|
|
411
|
+
add(request, now = Date.now()) {
|
|
412
|
+
requests = [...requests.filter((row) => now - row.at < PENDING_MS), { ...request, at: now }];
|
|
413
|
+
},
|
|
414
|
+
/** The fresh request this draft is, removed so it converts once; or undefined. */
|
|
415
|
+
take(draft, now = Date.now()) {
|
|
416
|
+
requests = requests.filter((row) => now - row.at < PENDING_MS);
|
|
417
|
+
const index = requests.findIndex((row) => sameDraft(row.draft, draft));
|
|
418
|
+
if (index < 0) return void 0;
|
|
419
|
+
const [request] = requests.splice(index, 1);
|
|
420
|
+
return request;
|
|
421
|
+
},
|
|
422
|
+
get size() {
|
|
423
|
+
return requests.length;
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// actions/src/workspace.js
|
|
429
|
+
function recentWorkspace(workspaces, sessionsById) {
|
|
430
|
+
let best;
|
|
431
|
+
let bestTime = Number.NEGATIVE_INFINITY;
|
|
432
|
+
for (const workspace of workspaces.items ?? []) {
|
|
433
|
+
let latest = Number.NEGATIVE_INFINITY;
|
|
434
|
+
for (const id of workspace.sessionIds ?? []) latest = Math.max(latest, sessionsById?.[id]?.updatedAt ?? Number.NEGATIVE_INFINITY);
|
|
435
|
+
if (latest === Number.NEGATIVE_INFINITY) latest = Date.parse(workspace.createdAt) || 0;
|
|
436
|
+
if (best === void 0 || latest > bestTime) {
|
|
437
|
+
best = workspace.workspaceId;
|
|
438
|
+
bestTime = latest;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return best;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// actions/src/client/chat.js
|
|
445
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
446
|
+
function createChat({ ctx, t, sources }) {
|
|
447
|
+
const pending = createPending();
|
|
448
|
+
async function inputOf(session) {
|
|
449
|
+
for (let i = 0; i < 50; i += 1) {
|
|
450
|
+
const scope = ctx.get("sessions")?.scope(session);
|
|
451
|
+
const conversation = scope?.get("conversation");
|
|
452
|
+
if (scope !== void 0 && conversation !== void 0) return conversation.input.for(scope);
|
|
453
|
+
await sleep(100);
|
|
454
|
+
}
|
|
455
|
+
return void 0;
|
|
456
|
+
}
|
|
457
|
+
async function chat(about, { prompt = "", session = "new" } = {}) {
|
|
458
|
+
const workspace = ctx.get("uiWorkspace");
|
|
459
|
+
if (workspace === void 0) throw new Error(t("noWorkspace"));
|
|
460
|
+
const item = { ...about, sourceName: about.sourceName ?? sources.name(about.source) ?? about.source };
|
|
461
|
+
const text = itemText(item);
|
|
462
|
+
const summary = itemSummary(item);
|
|
463
|
+
if (session === "new") {
|
|
464
|
+
const draft = draftText(text, prompt);
|
|
465
|
+
pending.add({ draft, text, summary, prompt });
|
|
466
|
+
workspace.startSession(void 0, { prompt: draft, whenDraftExists: "replace" });
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
workspace.openSession(session);
|
|
470
|
+
const input = await inputOf(session);
|
|
471
|
+
if (input === void 0) throw new Error(t("noSession"));
|
|
472
|
+
if (!input.insertQuote(text, summary)) throw new Error(t("busy"));
|
|
473
|
+
const binding = ctx.get("sessions")?.binding(session);
|
|
474
|
+
if (prompt.trim() !== "" && binding !== void 0) ctx.get("conversation")?.input.requestDraftInitialization(binding, { prompt, whenDraftExists: "append" });
|
|
475
|
+
}
|
|
476
|
+
async function start(about, { instruction, session = "new" }) {
|
|
477
|
+
const sessions = ctx.get("sessions");
|
|
478
|
+
if (sessions === void 0) throw new Error(t("noWorkspace"));
|
|
479
|
+
const item = { ...about, sourceName: about.sourceName ?? sources.name(about.source) ?? about.source };
|
|
480
|
+
let id = session;
|
|
481
|
+
if (session === "new") {
|
|
482
|
+
const workspaceId = recentWorkspace(ctx.get("workspaces")?.list.getSnapshot() ?? {}, sessions.list.getSnapshot().byId);
|
|
483
|
+
if (workspaceId === void 0) throw new Error(t("noWorkspace"));
|
|
484
|
+
id = await sessions.create({ workspaceId });
|
|
485
|
+
}
|
|
486
|
+
await sessions.using(id, { source: "uiActionsStep" }, async (reference) => {
|
|
487
|
+
const { session: face } = await reference.ready;
|
|
488
|
+
const result = await face.prompt([{ type: "text", text: stepMessage(instruction, item) }], "queue");
|
|
489
|
+
if (!result.ok) throw new Error(result.error?.message ?? t("noSession"));
|
|
490
|
+
});
|
|
491
|
+
return id;
|
|
492
|
+
}
|
|
493
|
+
function open(session) {
|
|
494
|
+
ctx.get("uiWorkspace")?.openSession(session);
|
|
495
|
+
}
|
|
496
|
+
function Adopter({ inputActions, useInput }) {
|
|
497
|
+
const draft = useInput((state) => state.draft);
|
|
498
|
+
const editable = useInput((state) => state.phase === "plain");
|
|
499
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
500
|
+
if (!editable || draft === "" || pending.size === 0) return;
|
|
501
|
+
const request = pending.take(draft);
|
|
502
|
+
if (request === void 0) return;
|
|
503
|
+
inputActions.setDraft("");
|
|
504
|
+
if (!inputActions.insertQuote(request.text, request.summary)) {
|
|
505
|
+
inputActions.setDraft(request.draft);
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
if (request.prompt.trim() !== "") inputActions.insertText(request.prompt, inputActions.captureInsertion());
|
|
509
|
+
}, [draft, editable]);
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
return { chat, start, open, Adopter };
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// actions/src/client/sources.js
|
|
516
|
+
var import_react4 = require("react");
|
|
517
|
+
function createSources() {
|
|
518
|
+
const entries = /* @__PURE__ */ new Map();
|
|
519
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
520
|
+
let version = 0;
|
|
521
|
+
const changed = () => {
|
|
522
|
+
version += 1;
|
|
523
|
+
for (const listener of listeners) listener();
|
|
524
|
+
};
|
|
525
|
+
const subscribe = (listener) => {
|
|
526
|
+
listeners.add(listener);
|
|
527
|
+
return () => listeners.delete(listener);
|
|
528
|
+
};
|
|
529
|
+
const resolve = (entry) => entry === void 0 ? void 0 : { name: typeof entry.name === "function" ? entry.name() : entry.name, icon: entry.icon };
|
|
530
|
+
return {
|
|
531
|
+
/**
|
|
532
|
+
* @param {{ id: string, name: string | (() => string), icon?: Function }} source - `id` is the package name; `icon` a component taking `{ size }`
|
|
533
|
+
* @returns {() => void} unregisters
|
|
534
|
+
*/
|
|
535
|
+
register(source) {
|
|
536
|
+
if (typeof source?.id !== "string" || source.id === "") throw new TypeError("registerSource needs an id (the package name)");
|
|
537
|
+
const entry = { name: source.name, icon: source.icon };
|
|
538
|
+
entries.set(source.id, entry);
|
|
539
|
+
changed();
|
|
540
|
+
return () => {
|
|
541
|
+
if (entries.get(source.id) === entry) {
|
|
542
|
+
entries.delete(source.id);
|
|
543
|
+
changed();
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
},
|
|
547
|
+
name: (id) => resolve(entries.get(id))?.name,
|
|
548
|
+
useSource(id) {
|
|
549
|
+
(0, import_react4.useSyncExternalStore)(subscribe, () => version);
|
|
550
|
+
return resolve(entries.get(id));
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// actions/src/client/index.js
|
|
556
|
+
var NS = "dsh-ui-actions";
|
|
557
|
+
var name = "ui-actions";
|
|
558
|
+
var inject = ["slots", "locale"];
|
|
559
|
+
function apply(ctx) {
|
|
560
|
+
ctx.effect(() => {
|
|
561
|
+
const disposers = [];
|
|
562
|
+
for (const [tag, file] of Object.entries(locales_default)) {
|
|
563
|
+
try {
|
|
564
|
+
disposers.push(ctx.locale.register(NS, tag, file.ui));
|
|
565
|
+
} catch (error) {
|
|
566
|
+
console.warn(`dsh-ui-actions: no ${tag} words`, error);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return () => {
|
|
570
|
+
for (const dispose of disposers) dispose();
|
|
571
|
+
};
|
|
572
|
+
}, "ui-actions: words");
|
|
573
|
+
if (typeof document !== "undefined") {
|
|
574
|
+
ctx.effect(() => {
|
|
575
|
+
const style = document.createElement("style");
|
|
576
|
+
style.id = STYLE_ID;
|
|
577
|
+
style.dataset.plugin = "@soffits/dsh-plugin-sdk";
|
|
578
|
+
style.textContent = CSS;
|
|
579
|
+
document.head.appendChild(style);
|
|
580
|
+
return () => style.remove();
|
|
581
|
+
}, "ui-actions: styles");
|
|
582
|
+
}
|
|
583
|
+
const t = ctx.locale.bind(NS);
|
|
584
|
+
const useLanguage = () => {
|
|
585
|
+
const subscribe = (0, import_react5.useCallback)((listener) => ctx.locale.subscribe(listener), []);
|
|
586
|
+
return (0, import_react5.useSyncExternalStore)(subscribe, () => ctx.locale.getSnapshot().active);
|
|
587
|
+
};
|
|
588
|
+
const useWords = () => {
|
|
589
|
+
useLanguage();
|
|
590
|
+
return t;
|
|
591
|
+
};
|
|
592
|
+
const sources = createSources();
|
|
593
|
+
const { chat, start, open, Adopter } = createChat({ ctx, t, sources });
|
|
594
|
+
const { ActionBar, ActionButton } = createBar({ useWords, useLanguage, chat, start, open });
|
|
595
|
+
const ItemCard = createCard({ sources });
|
|
596
|
+
ctx.provide("uiActions", { ActionBar, ActionButton, chat, start, registerSource: (source) => sources.register(source) });
|
|
597
|
+
ctx.inject(["uiConversation"], (scope) => {
|
|
598
|
+
scope.effect(() => scope.uiConversation.userText.register(itemRule), "ui-actions: item rule");
|
|
599
|
+
});
|
|
600
|
+
ctx.slots.inject("conversation.user.text.node", () => ctx.slots.register({ name: "conversation.user.text.node", key: ITEM_NODE, priority: 100, locale: NS }, ItemCard));
|
|
601
|
+
ctx.slots.inject("conversation.input.dock", () => ctx.slots.register({ name: "conversation.input.dock", id: "ui-actions.adopt", order: 100 }, Adopter));
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return module.exports
|
|
605
|
+
},
|
|
606
|
+
})
|