@songsid/agend 2.4.0-beta.15 → 2.4.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts-profiles.d.ts +1 -1
- package/dist/accounts-view.d.ts +3 -0
- package/dist/accounts-view.js.map +1 -1
- package/dist/auth-api.js +4 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +6 -1
- package/dist/backend/claude-code.js +63 -8
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/kiro.js +6 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +2 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-command.d.ts +4 -2
- package/dist/backend-command.js +3 -0
- package/dist/backend-command.js.map +1 -1
- package/dist/browser-backend-signins.d.ts +1 -0
- package/dist/browser-backend-signins.js +3 -1
- package/dist/browser-backend-signins.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/classic-channel-manager.d.ts +1 -0
- package/dist/classic-channel-manager.js +4 -1
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/claude-credential-change.d.ts +22 -0
- package/dist/claude-credential-change.js +47 -0
- package/dist/claude-credential-change.js.map +1 -0
- package/dist/claude-credential-launch.d.ts +62 -0
- package/dist/claude-credential-launch.js +304 -0
- package/dist/claude-credential-launch.js.map +1 -0
- package/dist/claude-credential-runner.d.ts +1 -0
- package/dist/claude-credential-runner.js +56 -0
- package/dist/claude-credential-runner.js.map +1 -0
- package/dist/claude-credential-vault.d.ts +51 -0
- package/dist/claude-credential-vault.js +252 -0
- package/dist/claude-credential-vault.js.map +1 -0
- package/dist/claude-setup-token-transport.d.ts +9 -0
- package/dist/claude-setup-token-transport.js +82 -0
- package/dist/claude-setup-token-transport.js.map +1 -0
- package/dist/claude-setup-token.d.ts +51 -0
- package/dist/claude-setup-token.js +83 -0
- package/dist/claude-setup-token.js.map +1 -0
- package/dist/cli-audited.js +7 -6
- package/dist/cli-audited.js.map +1 -1
- package/dist/command-report.d.ts +11 -0
- package/dist/command-report.js +2 -0
- package/dist/command-report.js.map +1 -0
- package/dist/config-validator.js +9 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +5 -0
- package/dist/daemon.js +59 -3
- package/dist/daemon.js.map +1 -1
- package/dist/fleet-level-config.d.ts +1 -1
- package/dist/fleet-level-config.js +1 -0
- package/dist/fleet-level-config.js.map +1 -1
- package/dist/fleet-manager.d.ts +39 -2
- package/dist/fleet-manager.js +383 -19
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +4 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +18 -5
- package/dist/host-monitoring-config.d.ts +14 -0
- package/dist/host-monitoring-config.js +31 -0
- package/dist/host-monitoring-config.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +1 -1
- package/dist/instance-config-impact.js +1 -1
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instructions.js +1 -0
- package/dist/instructions.js.map +1 -1
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +13 -1
- package/dist/locale.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/profile-signins.d.ts +1 -0
- package/dist/profile-signins.js +3 -1
- package/dist/profile-signins.js.map +1 -1
- package/dist/public-web-gateway.js +2 -0
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +21 -2
- package/dist/public-web-link.js +22 -2
- package/dist/public-web-link.js.map +1 -1
- package/dist/settings-api.d.ts +12 -0
- package/dist/settings-api.js +146 -7
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +2 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.js +13 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/topic-commands.d.ts +7 -1
- package/dist/topic-commands.js +98 -88
- package/dist/topic-commands.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/ui/accounts-view.js +12 -6
- package/dist/ui/backend-signin.js +3 -1
- package/dist/ui/chat-commands.js +2 -0
- package/dist/ui/chat-popout-transport.js +49 -19
- package/dist/ui/chat-popout.js +15 -1
- package/dist/ui/chat-store.js +1 -1
- package/dist/ui/claude-credentials.js +112 -0
- package/dist/ui/claude-setup-token.js +36 -0
- package/dist/ui/contact-auth-client.js +7 -2
- package/dist/ui/contact-auth-strings.js +45 -14
- package/dist/ui/contact-authorizations.js +47 -26
- package/dist/ui/contact-needs.js +4 -4
- package/dist/ui/fleet-canvas.js +3 -2
- package/dist/ui/fleet-office-card.js +414 -41
- package/dist/ui/fleet-office-dialogue.js +3 -3
- package/dist/ui/fleet-office-pack.d.ts +67 -1
- package/dist/ui/fleet-office-pack.js +412 -18
- package/dist/ui/fleet-office-play.js +262 -3
- package/dist/ui/fleet-office-skin.js +67 -20
- package/dist/ui/fleet-office-zones.js +19 -1
- package/dist/ui/fleet-office.js +393 -47
- package/dist/ui/office-share-page.js +5 -1
- package/dist/ui/panel-chat.js +47 -3
- package/dist/ui/panel-fleet.js +1 -1
- package/dist/ui/panel-settings.js +2 -1
- package/dist/ui/preview-popout.js +134 -0
- package/dist/ui/reply-file-preview.js +1 -1
- package/dist/ui/settings-host-monitoring.js +51 -0
- package/dist/ui/settings-shared.js +3 -2
- package/dist/ui/shared/app.css +211 -27
- package/dist/ui/shared/app.js +7 -1
- package/dist/ui/shared/chat-strings.js +8 -2
- package/dist/ui/shared/info-tip.js +64 -0
- package/dist/ui/shared/office-dialogue.css +12 -0
- package/dist/ui/shared/preview-panel.js +44 -18
- package/dist/ui/shared/preview-popout.css +11 -0
- package/dist/ui/shared/theme.js +11 -1
- package/dist/ui/shared/usage-dialog.js +9 -34
- package/dist/ui/shared/view-strings.js +2 -0
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +1 -1
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/providers.d.ts +1 -0
- package/dist/usage/providers.js +14 -1
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.js +5 -2
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +4 -1
- package/dist/web-api.js +29 -9
- package/dist/web-api.js.map +1 -1
- package/dist/web-claude-credentials.d.ts +31 -0
- package/dist/web-claude-credentials.js +138 -0
- package/dist/web-claude-credentials.js.map +1 -0
- package/dist/web-commands.d.ts +5 -2
- package/dist/web-commands.js +4 -2
- package/dist/web-commands.js.map +1 -1
- package/dist/web-office-skins.d.ts +7 -2
- package/dist/web-office-skins.js +42 -16
- package/dist/web-office-skins.js.map +1 -1
- package/dist/web-session.d.ts +20 -1
- package/dist/web-session.js +27 -0
- package/dist/web-session.js.map +1 -1
- package/dist/web-terminal.d.ts +4 -0
- package/dist/web-terminal.js +16 -1
- package/dist/web-terminal.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,20 +18,24 @@ import { modelSwitchText, modelName, observationLabel } from "/assets/model-obse
|
|
|
18
18
|
// Office; work tokens, today and first seen only where the usage report is served (`detail`). A share link's page (no
|
|
19
19
|
// `onChat`) shows the name, title, state and office only — never the model, the backend or numbers. A title a skin pack
|
|
20
20
|
// pins (`levels.fixed`) shows whatever the level; with hideLevel, no "Lv n" and no XP bar. Levels off: no level rows.
|
|
21
|
-
import { html, useEffect, useRef } from "/assets/app-html.js";
|
|
21
|
+
import { html, useEffect, useLayoutEffect, useMemo, useRef, useState } from "/assets/app-html.js";
|
|
22
22
|
import { t, register } from "/assets/app-i18n.js";
|
|
23
23
|
import { backendLabel, modelText, namesOf } from "/assets/instance-nav.js";
|
|
24
24
|
import { badgeText, fixedOf, tierOf, titleOf, tokens, xpOf } from "./fleet-office-levels.js";
|
|
25
|
+
import { CARD_ROWS, CARD_SECTIONS, contrastRatio, relativeLuminance } from "./fleet-office-pack.js";
|
|
26
|
+
import { nineSlice } from "./fleet-office-dialogue.js";
|
|
25
27
|
|
|
26
28
|
register("ocard", {
|
|
27
29
|
en: {
|
|
28
30
|
card: "{0}'s card", level: "Lv {0}", work: "{0} work tokens", estimated: "estimated", toNext: "{0} to Lv {1}", office: "Office", model: "Model", backend: "Backend",
|
|
29
31
|
today: "Today", todayN: "{0} work tokens · {1} requests", firstSeen: "First seen", day: "Day {0}", now: "Now", find: "Find in office", chat: "Chat", pat: "Pat", feed: "Feed", tell: "Tell {0} (with their next message)", tellNote: "Off: only you see it. On: a line like “[Office] <your name> patted your head ×3” rides the next message they get anyway — it never wakes them.",
|
|
32
|
+
chatWindow: "Open {0}’s chat in a new window",
|
|
30
33
|
close: "Close", xp: "Progress to Lv {0}",
|
|
31
34
|
},
|
|
32
35
|
"zh-TW": {
|
|
33
36
|
card: "{0} 的名片", level: "Lv {0}", work: "{0} 工作 token", estimated: "估算", toNext: "再 {0} 到 Lv {1}", office: "辦公室", model: "模型", backend: "後端",
|
|
34
37
|
today: "今天", todayN: "{0} 工作 token · {1} 次請求", firstSeen: "首次出現", day: "第 {0} 天", now: "現在", find: "在辦公室找他", chat: "聊天", pat: "摸頭", feed: "餵點心", tell: "讓 {0} 知道(隨下一則訊息)", tellNote: "關閉:只有你看得到。開啟:下一則本來就會送給它的訊息會附上一行,例如「[Office] <你的名字> patted your head ×3」,不會叫醒它。",
|
|
38
|
+
chatWindow: "在新視窗開啟 {0} 的聊天",
|
|
35
39
|
close: "關閉", xp: "升到 Lv {0} 的進度",
|
|
36
40
|
},
|
|
37
41
|
});
|
|
@@ -60,61 +64,430 @@ export function cardModel({ node, lv, levels, share = false, state, now, where }
|
|
|
60
64
|
const title = on && fx ? fx.title : e ? titleOf(e.level, levels && levels.titles) : null;
|
|
61
65
|
const detail = !share && !!e && e.workTokens !== undefined;
|
|
62
66
|
const xp = showLevel && detail ? xpOf(e.level, e.workTokens, lv.unit) : null;
|
|
63
|
-
const
|
|
64
|
-
if (!share && it.model)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const rowItems = [{ key: "office", label: tc("office"), value: where }];
|
|
68
|
+
if (!share && it.model) rowItems.push({
|
|
69
|
+
key: "model",
|
|
70
|
+
label: it.model_observation ? observationLabel("selection") : tc("model"),
|
|
71
|
+
value: it.model_observation ? (modelName(it.model_observation.session) || observationLabel("unresolved")) : modelText(it),
|
|
72
|
+
});
|
|
73
|
+
if (!share && it.backend) rowItems.push({ key: "backend", label: tc("backend"), value: backendLabel(it.backend) });
|
|
74
|
+
if (detail) rowItems.push({ key: "today", label: tc("today"), value: tc("todayN", tokens(e.today.workTokens), e.today.requests) });
|
|
75
|
+
if (detail && e.firstSeen) rowItems.push({ key: "firstSeen", label: tc("firstSeen"), value: tc("day", dayOf(e.firstSeen)) });
|
|
76
|
+
const rows = rowItems.map((r) => [r.label, r.value]);
|
|
68
77
|
return {
|
|
69
|
-
name: names.primary, instance: node.name,
|
|
78
|
+
name: names.primary, instance: node.name, state, title,
|
|
70
79
|
stateLine: title ? `${state} · ${title}` : state,
|
|
71
80
|
badge: on && fx && fx.hideLevel ? { mark: true, tier: 0 } : e ? { text: badgeText(e.level), tier: tierOf(e.level) } : null,
|
|
72
81
|
level: showLevel ? { line1: detail ? `${tc("level", e.level)} · ${tc("work", tokens(e.workTokens))}` : tc("level", e.level), estimated: detail && e.estimated,
|
|
73
82
|
line2: xp ? tc("toNext", tokens(xp.toNext), xp.next) : null, pct: xp ? xp.pct : null, next: xp ? xp.next : null } : null,
|
|
74
|
-
rows, now, modelSwitch: !share ? modelSwitchText(it.model_observation?.active) : "",
|
|
83
|
+
rows, rowItems, now, modelSwitch: !share ? modelSwitchText(it.model_observation?.active) : "",
|
|
75
84
|
};
|
|
76
85
|
}
|
|
77
86
|
|
|
87
|
+
// ── M-3433 (#4256): skin-pack card preset, style & layout resolution ──
|
|
88
|
+
|
|
89
|
+
const PRESET_LAYOUTS = {
|
|
90
|
+
default: { avatarSize: "md", avatarSource: "sprite", headerAlign: "left", width: 320, sections: [...CARD_SECTIONS], rows: [...CARD_ROWS], rowColumns: 2, hide: [] },
|
|
91
|
+
rpg: { avatarSize: "lg", avatarSource: "portrait", headerAlign: "center", width: 340, sections: [...CARD_SECTIONS], rows: [...CARD_ROWS], rowColumns: 2, hide: ["instance"] },
|
|
92
|
+
compact: { avatarSize: "sm", avatarSource: "sprite", headerAlign: "left", width: 296, sections: ["header", "rows", "actions"], rows: ["office", "model", "today"], rowColumns: 2, hide: ["instance", "badge", "level", "xpBar", "now"] },
|
|
93
|
+
dossier: { avatarSize: "md", avatarSource: "portrait", headerAlign: "left", width: 352, sections: [...CARD_SECTIONS], rows: [...CARD_ROWS], rowColumns: 1, hide: [] },
|
|
94
|
+
};
|
|
95
|
+
const PRESET_RADIUS = { default: "lg", rpg: "sm", compact: "md", dossier: "md" };
|
|
96
|
+
const AVATAR_PX = { sm: 44, md: 56, lg: 84 };
|
|
97
|
+
const RADIUS_VAR = { none: "0px", sm: "var(--r-sm)", md: "var(--r-md)", lg: "var(--r-lg)" };
|
|
98
|
+
const CARD_CSS_PROPS = [
|
|
99
|
+
"--oo-card-bg", "--oo-card-border", "--oo-card-text", "--oo-card-muted", "--oo-card-accent",
|
|
100
|
+
"--oo-card-bar-track", "--oo-card-bar-fill", "--oo-card-tile-bg", "--oo-card-btn-bg", "--oo-card-btn-text",
|
|
101
|
+
"--oo-card-btn-primary-bg", "--oo-card-btn-primary-text", "--oo-card-radius", "--oo-card-w",
|
|
102
|
+
"--oo-card-avatar", "--oo-card-frame-pad",
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
function fgFor(bgHex, minRatio = 4.5, light = "#f6f4f0", dark = "#18181b") {
|
|
106
|
+
const rl = contrastRatio(light, bgHex), rd = contrastRatio(dark, bgHex);
|
|
107
|
+
if (rl >= rd) return rl >= minRatio ? light : "#ffffff";
|
|
108
|
+
return rd >= minRatio ? dark : "#000000";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function mixHex(fgHex, bgHex, alpha) {
|
|
112
|
+
const ch = (i) => {
|
|
113
|
+
const a = parseInt(fgHex.slice(i, i + 2), 16), b = parseInt(bgHex.slice(i, i + 2), 16);
|
|
114
|
+
return Math.round(a * alpha + b * (1 - alpha)).toString(16).padStart(2, "0");
|
|
115
|
+
};
|
|
116
|
+
return `#${ch(1)}${ch(3)}${ch(5)}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function scrimRgba(hex, alpha) {
|
|
120
|
+
const r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16);
|
|
121
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Resolve a checked pack's optional `card` into concrete layout, CSS custom properties, and backdrop config.
|
|
126
|
+
* Returns null when the pack defines no `card` (legacy default rendering is preserved untouched).
|
|
127
|
+
*/
|
|
128
|
+
export function resolveCardSpec(packCard) {
|
|
129
|
+
if (!packCard || typeof packCard !== "object") return null;
|
|
130
|
+
const preset = PRESET_LAYOUTS[packCard.preset] ? packCard.preset : "default";
|
|
131
|
+
const base = PRESET_LAYOUTS[preset];
|
|
132
|
+
const rawLayout = packCard.layout || {};
|
|
133
|
+
const layout = {
|
|
134
|
+
avatarSize: rawLayout.avatarSize || base.avatarSize,
|
|
135
|
+
avatarSource: rawLayout.avatarSource || base.avatarSource,
|
|
136
|
+
headerAlign: rawLayout.headerAlign || base.headerAlign,
|
|
137
|
+
width: rawLayout.width ?? base.width,
|
|
138
|
+
sections: rawLayout.sections ? [...rawLayout.sections] : [...base.sections],
|
|
139
|
+
rows: rawLayout.rows ? [...rawLayout.rows] : [...base.rows],
|
|
140
|
+
rowColumns: rawLayout.rowColumns ?? base.rowColumns,
|
|
141
|
+
hide: rawLayout.hide ? [...rawLayout.hide] : [...base.hide],
|
|
142
|
+
};
|
|
143
|
+
const s = packCard.style || {};
|
|
144
|
+
const hasSurface = !!(s.background || s.backgroundImage);
|
|
145
|
+
const bgRef = s.background || (s.backgroundImage ? "#181614" : null);
|
|
146
|
+
const lum = bgRef ? relativeLuminance(bgRef) : null;
|
|
147
|
+
const dark = lum !== null && lum < 0.35;
|
|
148
|
+
|
|
149
|
+
let text = s.text || null;
|
|
150
|
+
let muted = s.muted || null;
|
|
151
|
+
let border = s.border || null;
|
|
152
|
+
let accent = s.accent || null;
|
|
153
|
+
let barTrack = s.barTrack || null;
|
|
154
|
+
let barFill = s.barFill || null;
|
|
155
|
+
let tileBgBase = null;
|
|
156
|
+
let buttonBg = s.buttonBg || null;
|
|
157
|
+
let buttonText = s.buttonText || null;
|
|
158
|
+
let buttonPrimaryBg = s.buttonPrimaryBg || null;
|
|
159
|
+
let buttonPrimaryText = s.buttonPrimaryText || null;
|
|
160
|
+
|
|
161
|
+
const pickContrast = (against, minRatio, candidates) => {
|
|
162
|
+
for (const c of candidates) if (c && contrastRatio(c, against) >= minRatio) return c;
|
|
163
|
+
return fgFor(against, minRatio, "#f6f4f0", "#18181b");
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (hasSurface && bgRef) {
|
|
167
|
+
if (!text || contrastRatio(text, bgRef) < 4.5) text = fgFor(bgRef, 4.5, "#f6f4f0", "#18181b");
|
|
168
|
+
if (!border || contrastRatio(border, bgRef) < 3.0) {
|
|
169
|
+
border = pickContrast(bgRef, 3.0, [dark ? "#6e665c" : "#71717a", dark ? "#a8a29e" : "#52525b"]);
|
|
170
|
+
}
|
|
171
|
+
if (accent && contrastRatio(accent, bgRef) < 4.5) accent = text;
|
|
172
|
+
if (!barTrack) {
|
|
173
|
+
barTrack = barFill
|
|
174
|
+
? pickContrast(barFill, 3.0, [dark ? "#342f2a" : "#d4d4d8", "#27272a", "#e4e4e7"])
|
|
175
|
+
: (dark ? "#342f2a" : "#d4d4d8");
|
|
176
|
+
}
|
|
177
|
+
if (!barFill || contrastRatio(barFill, barTrack) < 3.0) {
|
|
178
|
+
barFill = pickContrast(barTrack, 3.0, [s.accent, accent, dark ? "#e5b84b" : "#4f46e5"]);
|
|
179
|
+
}
|
|
180
|
+
// Dual-surface safety for RPG tiles (XP box = 65%, stat tile = 45% tint over bgRef):
|
|
181
|
+
// both text and muted must stay >= 4.5:1 against bgRef AND the tinted tiles simultaneously.
|
|
182
|
+
// If an extreme barTrack (e.g. #ffffff on dark #181614) would break dual-surface contrast,
|
|
183
|
+
// decouple --oo-card-tile-bg from barTrack so the progress bar keeps barTrack while tiles stay readable.
|
|
184
|
+
const mutedPool = [s.muted, dark ? "#d6d0c6" : "#374151", dark ? "#e7e5e0" : "#1f2937", text, "#ffffff", "#000000"].filter(Boolean);
|
|
185
|
+
const surfacesFor = (tb) => (preset === "rpg" && tb ? [bgRef, mixHex(tb, bgRef, 0.65), mixHex(tb, bgRef, 0.45)] : [bgRef]);
|
|
186
|
+
const okOnAll = (c, surfs) => surfs.every((sf) => contrastRatio(c, sf) >= 4.5);
|
|
187
|
+
const pickDualMuted = (surfs) => mutedPool.find((c) => okOnAll(c, surfs)) || null;
|
|
188
|
+
if (preset === "rpg") {
|
|
189
|
+
const tileCandidates = [barTrack, dark ? "#342f2a" : "#d4d4d8", bgRef];
|
|
190
|
+
let chosen = bgRef, chosenMuted = null;
|
|
191
|
+
for (const tb of tileCandidates) {
|
|
192
|
+
const surfs = surfacesFor(tb);
|
|
193
|
+
if (!okOnAll(text, surfs)) continue;
|
|
194
|
+
const m = pickDualMuted(surfs);
|
|
195
|
+
if (m) { chosen = tb; chosenMuted = m; break; }
|
|
196
|
+
}
|
|
197
|
+
tileBgBase = chosen;
|
|
198
|
+
muted = chosenMuted || text;
|
|
199
|
+
} else {
|
|
200
|
+
muted = pickDualMuted([bgRef]) || text;
|
|
201
|
+
}
|
|
202
|
+
if (!buttonBg) {
|
|
203
|
+
buttonBg = buttonText
|
|
204
|
+
? pickContrast(buttonText, 4.5, [dark ? "#2c2622" : "#e4e4e7", "#1f2937", "#f4f4f5"])
|
|
205
|
+
: (dark ? "#2c2622" : "#e4e4e7");
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
// Partial overrides without an explicit card background: pair each supplied side with a contrasting counterpart.
|
|
209
|
+
if (barTrack && (!barFill || contrastRatio(barFill, barTrack) < 3.0)) {
|
|
210
|
+
barFill = pickContrast(barTrack, 3.0, [s.accent, "#4f46e5", "#e5b84b"]);
|
|
211
|
+
} else if (barFill && !barTrack) {
|
|
212
|
+
barTrack = pickContrast(barFill, 3.0, ["#27272a", "#e4e4e7"]);
|
|
213
|
+
}
|
|
214
|
+
if (buttonText && !buttonBg) buttonBg = pickContrast(buttonText, 4.5, ["#1f2937", "#f4f4f5"]);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (buttonBg && (!buttonText || contrastRatio(buttonText, buttonBg) < 4.5)) {
|
|
218
|
+
buttonText = fgFor(buttonBg, 4.5, "#f6f4f0", "#18181b");
|
|
219
|
+
}
|
|
220
|
+
// Primary button falls back to accent in CSS: resolve its foreground explicitly so light/dark surface never breaks contrast.
|
|
221
|
+
if (!buttonPrimaryBg && buttonPrimaryText) {
|
|
222
|
+
buttonPrimaryBg = pickContrast(buttonPrimaryText, 4.5, [accent, "#1d4ed8", "#18181b", "#f4f4f5"]);
|
|
223
|
+
} else if (!buttonPrimaryBg && accent) {
|
|
224
|
+
buttonPrimaryBg = accent;
|
|
225
|
+
}
|
|
226
|
+
if (buttonPrimaryBg && (!buttonPrimaryText || contrastRatio(buttonPrimaryText, buttonPrimaryBg) < 4.5)) {
|
|
227
|
+
buttonPrimaryText = fgFor(buttonPrimaryBg, 4.5, "#f6f4f0", "#18181b");
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const radiusKey = s.radius || PRESET_RADIUS[preset] || "lg";
|
|
231
|
+
const avatarPx = AVATAR_PX[layout.avatarSize] || 56;
|
|
232
|
+
const cssVars = {
|
|
233
|
+
"--oo-card-w": `${layout.width}px`,
|
|
234
|
+
"--oo-card-avatar": `${avatarPx}px`,
|
|
235
|
+
"--oo-card-radius": RADIUS_VAR[radiusKey] || "var(--r-lg)",
|
|
236
|
+
};
|
|
237
|
+
if (s.background) cssVars["--oo-card-bg"] = s.background;
|
|
238
|
+
else if (s.backgroundImage && bgRef) cssVars["--oo-card-bg"] = bgRef;
|
|
239
|
+
if (border) cssVars["--oo-card-border"] = border;
|
|
240
|
+
if (text) cssVars["--oo-card-text"] = text;
|
|
241
|
+
if (muted) cssVars["--oo-card-muted"] = muted;
|
|
242
|
+
if (accent) cssVars["--oo-card-accent"] = accent;
|
|
243
|
+
if (barTrack) cssVars["--oo-card-bar-track"] = barTrack;
|
|
244
|
+
if (barFill) cssVars["--oo-card-bar-fill"] = barFill;
|
|
245
|
+
if (tileBgBase) cssVars["--oo-card-tile-bg"] = tileBgBase;
|
|
246
|
+
if (buttonBg) cssVars["--oo-card-btn-bg"] = buttonBg;
|
|
247
|
+
if (buttonText) cssVars["--oo-card-btn-text"] = buttonText;
|
|
248
|
+
if (buttonPrimaryBg) cssVars["--oo-card-btn-primary-bg"] = buttonPrimaryBg;
|
|
249
|
+
if (buttonPrimaryText) cssVars["--oo-card-btn-primary-text"] = buttonPrimaryText;
|
|
250
|
+
|
|
251
|
+
const backdrop = (s.backgroundImage || s.frame) ? {
|
|
252
|
+
backgroundImage: s.backgroundImage || null,
|
|
253
|
+
frame: s.frame || null,
|
|
254
|
+
slice: s.frame ? (s.slice ?? 8) : 0,
|
|
255
|
+
scrim: s.backgroundImage && bgRef ? scrimRgba(bgRef, dark ? 0.56 : 0.72) : null,
|
|
256
|
+
} : null;
|
|
257
|
+
|
|
258
|
+
return { preset, layout, avatarPx, hideSet: new Set(layout.hide), cssVars, backdrop };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Ordered visible rows for `model` under `spec`; never restores fields stripped by `cardModel` on share links. */
|
|
262
|
+
export function visibleRows(model, spec) {
|
|
263
|
+
const items = Array.isArray(model?.rowItems) ? model.rowItems : [];
|
|
264
|
+
if (!spec) return items;
|
|
265
|
+
const byKey = new Map(items.map((r) => [r.key, r]));
|
|
266
|
+
const out = [];
|
|
267
|
+
for (const k of spec.layout.rows) {
|
|
268
|
+
if (spec.hideSet.has(k)) continue;
|
|
269
|
+
const item = byKey.get(k);
|
|
270
|
+
if (item) out.push(item);
|
|
271
|
+
}
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** Draw optional pack backgroundImage (cover + readability scrim) and 9-slice frame onto the card's backing canvas. */
|
|
276
|
+
export function drawCardBackdrop(cv, { bgIm, frameIm, slice, scale = 2, scrim }) {
|
|
277
|
+
const g = cv && cv.getContext ? cv.getContext("2d") : null;
|
|
278
|
+
if (!g) return 0;
|
|
279
|
+
const w = Math.round(cv.clientWidth || 0), h = Math.round(cv.clientHeight || 0);
|
|
280
|
+
if (w < 2 || h < 2) return 0;
|
|
281
|
+
const r = Math.max(1, Math.min(3, globalThis.devicePixelRatio || 1));
|
|
282
|
+
if (cv.width !== Math.round(w * r) || cv.height !== Math.round(h * r)) {
|
|
283
|
+
cv.width = Math.round(w * r);
|
|
284
|
+
cv.height = Math.round(h * r);
|
|
285
|
+
}
|
|
286
|
+
g.setTransform(r, 0, 0, r, 0, 0);
|
|
287
|
+
g.clearRect(0, 0, w, h);
|
|
288
|
+
if (bgIm) {
|
|
289
|
+
const iw = bgIm.naturalWidth || bgIm.width, ih = bgIm.naturalHeight || bgIm.height;
|
|
290
|
+
if (iw && ih) {
|
|
291
|
+
const k = Math.max(w / iw, h / ih), dw = iw * k, dh = ih * k;
|
|
292
|
+
g.imageSmoothingEnabled = k < 1;
|
|
293
|
+
g.drawImage(bgIm, Math.round((w - dw) / 2), Math.round((h - dh) / 2), Math.round(dw), Math.round(dh));
|
|
294
|
+
if (scrim) { g.fillStyle = scrim; g.fillRect(0, 0, w, h); }
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
let borderPx = 0;
|
|
298
|
+
if (frameIm && slice > 0) {
|
|
299
|
+
const maxBorder = Math.max(4, Math.min(20, Math.floor(Math.min(w, h) * 0.2)));
|
|
300
|
+
const k = Math.max(1, Math.min(scale || 2, Math.floor(maxBorder / slice) || 1));
|
|
301
|
+
g.imageSmoothingEnabled = false;
|
|
302
|
+
if (nineSlice(g, frameIm, slice, 0, 0, w, h, k)) borderPx = slice * k;
|
|
303
|
+
}
|
|
304
|
+
return borderPx;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function drawPortraitAvatar(cv, im, W) {
|
|
308
|
+
const g = cv && cv.getContext ? cv.getContext("2d") : null;
|
|
309
|
+
const iw = im && (im.naturalWidth || im.width), ih = im && (im.naturalHeight || im.height);
|
|
310
|
+
if (!g || !iw || !ih) return false;
|
|
311
|
+
const r = Math.max(1, Math.min(3, globalThis.devicePixelRatio || 1));
|
|
312
|
+
if (cv.width !== Math.round(W * r) || cv.height !== Math.round(W * r)) {
|
|
313
|
+
cv.width = Math.round(W * r);
|
|
314
|
+
cv.height = Math.round(W * r);
|
|
315
|
+
}
|
|
316
|
+
g.setTransform(1, 0, 0, 1, 0, 0);
|
|
317
|
+
g.clearRect(0, 0, cv.width, cv.height);
|
|
318
|
+
const side = Math.min(iw, ih), sx = Math.round((iw - side) / 2), sy = Math.round((ih - side) * 0.18);
|
|
319
|
+
g.imageSmoothingEnabled = side > cv.width;
|
|
320
|
+
g.drawImage(im, sx, sy, side, side, 0, 0, cv.width, cv.height);
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
|
|
78
324
|
/**
|
|
79
|
-
* The card. `model`: cardModel's; `avatar(canvas)`: draws the person's idle frame on it; `sheet`: a bottom
|
|
80
|
-
* phone); `place(el)`: the page positions the popover (beside the person, following them); `onChat` (none on
|
|
81
|
-
* link), `onFind`, `onClose`; M-3293: `onReact(kind)` — Pat and Feed (only where play is on; none on a share
|
|
325
|
+
* The card. `model`: cardModel's; `avatar(canvas, sizePx)`: draws the person's idle frame on it; `sheet`: a bottom
|
|
326
|
+
* sheet (a phone); `place(el)`: the page positions the popover (beside the person, following them); `onChat` (none on
|
|
327
|
+
* a share link), `onFind`, `onClose`; M-3293: `onReact(kind)` — Pat and Feed (only where play is on; none on a share
|
|
328
|
+
* link); M-3433: optional `packCard`, `picture` (lazy image loader), `portrait` (src), `packScale`.
|
|
82
329
|
*/
|
|
83
|
-
export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onClose, onReact = null, tell = null }) {
|
|
84
|
-
const box = useRef(null), canvas = useRef(null), swipe = useRef(null);
|
|
85
|
-
|
|
330
|
+
export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onClose, onReact = null, tell = null, packCard = null, picture = null, portrait = null, packScale = 2 }) {
|
|
331
|
+
const box = useRef(null), canvas = useRef(null), bgCanvas = useRef(null), swipe = useRef(null);
|
|
332
|
+
const [picRev, setPicRev] = useState(0);
|
|
333
|
+
const spec = useMemo(() => resolveCardSpec(packCard), [packCard]);
|
|
334
|
+
const avatarPx = spec ? spec.avatarPx : 56;
|
|
335
|
+
const wantPortrait = !!(spec && spec.layout.avatarSource === "portrait" && portrait && typeof picture === "function");
|
|
336
|
+
|
|
337
|
+
useLayoutEffect(() => {
|
|
338
|
+
const el = box.current;
|
|
339
|
+
if (!el || !el.style) return undefined;
|
|
340
|
+
for (const prop of CARD_CSS_PROPS) {
|
|
341
|
+
const val = spec && spec.cssVars[prop];
|
|
342
|
+
if (val !== undefined) el.style.setProperty(prop, val);
|
|
343
|
+
else el.style.removeProperty(prop);
|
|
344
|
+
}
|
|
345
|
+
if (place) place(el);
|
|
346
|
+
return () => {
|
|
347
|
+
if (!el.style) return;
|
|
348
|
+
for (const prop of CARD_CSS_PROPS) el.style.removeProperty(prop);
|
|
349
|
+
};
|
|
350
|
+
}, [spec, sheet]);
|
|
351
|
+
|
|
352
|
+
useEffect(() => {
|
|
353
|
+
const cv = canvas.current;
|
|
354
|
+
if (!cv) return;
|
|
355
|
+
if (wantPortrait) {
|
|
356
|
+
const im = picture(portrait, () => setPicRev((n) => n + 1));
|
|
357
|
+
if (im && drawPortraitAvatar(cv, im, avatarPx)) return;
|
|
358
|
+
}
|
|
359
|
+
if (avatar) avatar(cv, avatarPx);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
useEffect(() => {
|
|
363
|
+
if (!spec || !spec.backdrop || !bgCanvas.current || typeof picture !== "function") return undefined;
|
|
364
|
+
const wake = () => setPicRev((n) => n + 1);
|
|
365
|
+
const paint = () => {
|
|
366
|
+
const cv = bgCanvas.current, el = box.current;
|
|
367
|
+
if (!cv || !el) return;
|
|
368
|
+
const bgIm = spec.backdrop.backgroundImage ? picture(spec.backdrop.backgroundImage, wake) : null;
|
|
369
|
+
const frameIm = spec.backdrop.frame ? picture(spec.backdrop.frame, wake) : null;
|
|
370
|
+
const borderPx = drawCardBackdrop(cv, { bgIm, frameIm, slice: spec.backdrop.slice, scale: packScale, scrim: spec.backdrop.scrim });
|
|
371
|
+
if (el.style) {
|
|
372
|
+
if (borderPx > 0) el.style.setProperty("--oo-card-frame-pad", `${Math.min(28, borderPx + 6)}px`);
|
|
373
|
+
else el.style.removeProperty("--oo-card-frame-pad");
|
|
374
|
+
}
|
|
375
|
+
if (place) place(el);
|
|
376
|
+
};
|
|
377
|
+
paint();
|
|
378
|
+
const RO = globalThis.ResizeObserver;
|
|
379
|
+
if (typeof RO === "function" && box.current) {
|
|
380
|
+
const ro = new RO(() => paint());
|
|
381
|
+
ro.observe(box.current);
|
|
382
|
+
return () => ro.disconnect();
|
|
383
|
+
}
|
|
384
|
+
return undefined;
|
|
385
|
+
}, [spec, picture, packScale, picRev, sheet]);
|
|
386
|
+
|
|
86
387
|
useEffect(() => { place && place(box.current); });
|
|
87
388
|
// A bottom sheet closes on a swipe down (60 px or more).
|
|
88
389
|
const down = (e) => { if (sheet) swipe.current = e.clientY; };
|
|
89
390
|
const up = (e) => { if (sheet && swipe.current !== null && e.clientY - swipe.current > 60) onClose(); swipe.current = null; };
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<div class="oo-card-
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
<div class="oo-card-
|
|
391
|
+
|
|
392
|
+
// Legacy default path (packs without `card`): preserve exact markup and classes.
|
|
393
|
+
if (!spec) {
|
|
394
|
+
return html`<div ref=${box} class=${`oo-card${sheet ? " sheet" : ""}`} role="dialog" aria-modal="false" aria-label=${tc("card", m.name)}
|
|
395
|
+
onPointerDown=${down} onPointerUp=${up} onPointerCancel=${() => { swipe.current = null; }}>
|
|
396
|
+
${sheet ? html`<div class="oo-card-grip" aria-hidden="true"></div>` : null}
|
|
397
|
+
${m.modelSwitch ? html`<p class="oo-card-now model-switch" role="status"><strong>${m.modelSwitch}</strong></p>` : null}
|
|
398
|
+
<div class="oo-card-head">
|
|
399
|
+
<div class="oo-card-avatar"><canvas ref=${canvas} width="56" height="56" aria-hidden="true"></canvas>
|
|
400
|
+
${m.badge ? html`<span class=${`oo-badge tier-${m.badge.tier}${m.badge.mark ? " mark" : ""}`} aria-hidden="true">${m.badge.mark ? "" : m.badge.text}</span>` : null}</div>
|
|
401
|
+
<div class="oo-card-names">
|
|
402
|
+
<strong class="oo-card-name">${m.name}</strong>
|
|
403
|
+
<div class="oo-card-instance mono" title=${m.instance}>${m.instance}</div>
|
|
404
|
+
<div class="oo-card-state">${m.stateLine}</div>
|
|
405
|
+
</div>
|
|
406
|
+
<button type="button" class="icon-btn oo-card-close" aria-label=${tc("close")} title=${tc("close")} onClick=${onClose}>×</button>
|
|
101
407
|
</div>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
408
|
+
${m.level ? html`<div class="oo-card-xp">
|
|
409
|
+
<div>${m.level.line1}${m.level.estimated ? html` <span class="muted">(${tc("estimated")})</span>` : null}</div>
|
|
410
|
+
${m.level.line2 ? html`<div class="muted">${m.level.line2}</div>` : null}
|
|
411
|
+
${m.level.pct !== null ? html`<progress class="oo-card-bar" max="100" value=${Math.round(m.level.pct * 100)} aria-label=${tc("xp", m.level.next)}></progress>` : null}
|
|
412
|
+
</div>` : null}
|
|
413
|
+
<dl class="oo-card-rows">${(m.rowItems || m.rows.map(([label, value]) => ({ key: "", label, value }))).map((r) => html`<div data-row=${r.key || undefined}><dt>${r.label}</dt><dd>${r.value}</dd></div>`)}</dl>
|
|
414
|
+
${m.now ? html`<div class="oo-card-now"><span class="muted">${tc("now")}:</span> ${m.now}</div>` : null}
|
|
415
|
+
${tell ? html`<label class="check oo-card-tell" title=${tc("tellNote")}><input type="checkbox" checked=${tell.on} onChange=${(e) => tell.set(e.target.checked)} />
|
|
416
|
+
<span>${tc("tell", m.name)}</span></label>` : null}
|
|
417
|
+
<div class="oo-card-actions">
|
|
418
|
+
${onReact ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-pat" onClick=${() => onReact("pat")}>${tc("pat")}</button>
|
|
419
|
+
<button type="button" class="btn btn-sm btn-ghost oo-card-feed" onClick=${() => onReact("feed")}>${tc("feed")}</button>` : null}
|
|
420
|
+
${onFind ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-find" onClick=${onFind}>${tc("find")}</button>` : null}
|
|
421
|
+
${onChat ? html`<button type="button" class="btn btn-sm btn-primary oo-card-chat" title=${tc("chatWindow", m.name)} aria-label=${tc("chatWindow", m.name)} onClick=${onChat}>${tc("chat")}</button>` : null}
|
|
422
|
+
</div>
|
|
423
|
+
</div>`;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const hide = spec.hideSet;
|
|
427
|
+
const rows = visibleRows(m, spec);
|
|
428
|
+
const stateLine = hide.has("title") ? m.state : m.stateLine;
|
|
429
|
+
const classes = [
|
|
430
|
+
"oo-card",
|
|
431
|
+
"oo-card-custom",
|
|
432
|
+
spec.preset !== "default" ? `oo-card-${spec.preset}` : "",
|
|
433
|
+
spec.layout.headerAlign === "center" ? "oo-card-center" : "",
|
|
434
|
+
`oo-card-cols-${spec.layout.rowColumns}`,
|
|
435
|
+
spec.backdrop && spec.backdrop.frame ? "oo-card-framed" : "",
|
|
436
|
+
sheet ? "sheet" : "",
|
|
437
|
+
].filter(Boolean).join(" ");
|
|
438
|
+
|
|
439
|
+
const renderSection = (sec) => {
|
|
440
|
+
if (sec === "header") {
|
|
441
|
+
return html`<div key="header" class="oo-card-head">
|
|
442
|
+
<div class="oo-card-avatar"><canvas ref=${canvas} width=${avatarPx} height=${avatarPx} aria-hidden="true"></canvas>
|
|
443
|
+
${m.badge && !hide.has("badge") ? html`<span class=${`oo-badge tier-${m.badge.tier}${m.badge.mark ? " mark" : ""}`} aria-hidden="true">${m.badge.mark ? "" : m.badge.text}</span>` : null}</div>
|
|
444
|
+
<div class="oo-card-names">
|
|
445
|
+
<strong class="oo-card-name">${m.name}</strong>
|
|
446
|
+
${!hide.has("instance") ? html`<div class="oo-card-instance mono" title=${m.instance}>${m.instance}</div>` : null}
|
|
447
|
+
<div class="oo-card-state">${stateLine}</div>
|
|
448
|
+
</div>
|
|
449
|
+
<button type="button" class="icon-btn oo-card-close" aria-label=${tc("close")} title=${tc("close")} onClick=${onClose}>×</button>
|
|
450
|
+
</div>`;
|
|
451
|
+
}
|
|
452
|
+
if (sec === "level") {
|
|
453
|
+
if (!m.level || hide.has("level")) return null;
|
|
454
|
+
return html`<div key="level" class="oo-card-xp">
|
|
455
|
+
<div>${m.level.line1}${m.level.estimated ? html` <span class="muted">(${tc("estimated")})</span>` : null}</div>
|
|
456
|
+
${m.level.line2 ? html`<div class="muted">${m.level.line2}</div>` : null}
|
|
457
|
+
${m.level.pct !== null && !hide.has("xpBar") ? html`<progress class="oo-card-bar" max="100" value=${Math.round(m.level.pct * 100)} aria-label=${tc("xp", m.level.next)}></progress>` : null}
|
|
458
|
+
</div>`;
|
|
459
|
+
}
|
|
460
|
+
if (sec === "rows") {
|
|
461
|
+
if (!rows.length) return null;
|
|
462
|
+
return html`<dl key="rows" class="oo-card-rows">${rows.map((r) => html`<div key=${r.key} data-row=${r.key}><dt>${r.label}</dt><dd>${r.value}</dd></div>`)}</dl>`;
|
|
463
|
+
}
|
|
464
|
+
if (sec === "now") {
|
|
465
|
+
if (!m.now || hide.has("now")) return null;
|
|
466
|
+
return html`<div key="now" class="oo-card-now"><span class="muted">${tc("now")}:</span> ${m.now}</div>`;
|
|
467
|
+
}
|
|
468
|
+
if (sec === "tell") {
|
|
469
|
+
if (!tell) return null;
|
|
470
|
+
return html`<label key="tell" class="check oo-card-tell" title=${tc("tellNote")}><input type="checkbox" checked=${tell.on} onChange=${(e) => tell.set(e.target.checked)} />
|
|
471
|
+
<span>${tc("tell", m.name)}</span></label>`;
|
|
472
|
+
}
|
|
473
|
+
if (sec === "actions") {
|
|
474
|
+
return html`<div key="actions" class="oo-card-actions">
|
|
475
|
+
${onReact ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-pat" onClick=${() => onReact("pat")}>${tc("pat")}</button>
|
|
476
|
+
<button type="button" class="btn btn-sm btn-ghost oo-card-feed" onClick=${() => onReact("feed")}>${tc("feed")}</button>` : null}
|
|
477
|
+
${onFind ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-find" onClick=${onFind}>${tc("find")}</button>` : null}
|
|
478
|
+
${onChat ? html`<button type="button" class="btn btn-sm btn-primary oo-card-chat" title=${tc("chatWindow", m.name)} aria-label=${tc("chatWindow", m.name)} onClick=${onChat}>${tc("chat")}</button>` : null}
|
|
479
|
+
</div>`;
|
|
480
|
+
}
|
|
481
|
+
return null;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
return html`<div ref=${box} class=${classes} data-preset=${spec.preset} role="dialog" aria-modal="false" aria-label=${tc("card", m.name)}
|
|
485
|
+
onPointerDown=${down} onPointerUp=${up} onPointerCancel=${() => { swipe.current = null; }}>
|
|
486
|
+
${spec.backdrop ? html`<canvas ref=${bgCanvas} class="oo-card-bg" aria-hidden="true"></canvas>` : null}
|
|
487
|
+
<div class="oo-card-body">
|
|
488
|
+
${sheet ? html`<div class="oo-card-grip" aria-hidden="true"></div>` : null}
|
|
489
|
+
${m.modelSwitch ? html`<p class="oo-card-now model-switch" role="status"><strong>${m.modelSwitch}</strong></p>` : null}
|
|
490
|
+
${spec.layout.sections.map(renderSection)}
|
|
118
491
|
</div>
|
|
119
492
|
</div>`;
|
|
120
493
|
}
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
// later. Concurrent conversations queue, newest first; the box shows the first one it may and "+N" for the rest.
|
|
10
10
|
// - On a share link (`share`: the host's `talk`, never any text): a faceless visitor, "Received a message", "Replied".
|
|
11
11
|
// - Only news: a message stamped within FRESH_MS of the server's clock (a replay on reconnect, a poll's catch-up, is not).
|
|
12
|
-
// - Drawn on
|
|
13
|
-
//
|
|
12
|
+
// - Drawn on a separate Office canvas below the map, in CSS px; it never pans or zooms with the scene. The Office
|
|
13
|
+
// loads the dock's versioned stylesheet for a cached shell as well.
|
|
14
14
|
// - Reduced motion: no slide, no typing, no fade.
|
|
15
15
|
// Off unless the Office bar's Dialogue box is ticked (per browser): then nothing here runs at all.
|
|
16
16
|
import { own, PORTRAIT_STATES } from "./fleet-office-pack.js";
|
|
@@ -250,7 +250,7 @@ const roundRect = (ctx, x, y, w, h, r) => {
|
|
|
250
250
|
else ctx.rect(x, y, w, h);
|
|
251
251
|
};
|
|
252
252
|
/** A 9-slice frame `im` over (x, y, w, h): `s` image px a side, drawn `k` CSS px an image px (unsmoothed). */
|
|
253
|
-
function nineSlice(ctx, im, s, x, y, w, h, k) {
|
|
253
|
+
export function nineSlice(ctx, im, s, x, y, w, h, k) {
|
|
254
254
|
const iw = im.naturalWidth || im.width, ih = im.naturalHeight || im.height, d = s * k;
|
|
255
255
|
if (!iw || !ih || w < 2 * d || h < 2 * d) return false;
|
|
256
256
|
const sx = [0, s, iw - s, iw], sy = [0, s, ih - s, ih], dx = [x, x + d, x + w - d, x + w], dy = [y, y + d, y + h - d, y + h];
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
// Types for fleet-office-pack.js: the page's module, which the host imports too (web-office-skins.ts,
|
|
2
2
|
// web-office-store.ts), so both check a skin pack and an office's layout overrides by the same rules.
|
|
3
|
+
/** One sheet of a multi-sheet or frame-list strip (`src` is `frames·w × h` px). */
|
|
4
|
+
export interface PackStripSheet { src: string; frames: number }
|
|
3
5
|
/** `dw` × `dh`: its displayed size in logical units (w·scale × h·scale unless the manifest says otherwise). */
|
|
4
|
-
export interface PackStrip {
|
|
6
|
+
export interface PackStrip {
|
|
7
|
+
src: string; frames: number; w: number; h: number; fps: number; ax: number; ay: number; dw: number; dh: number;
|
|
8
|
+
/** M-3394 (#4231): present on multi-sheet (`src: [...]`) and frame-list (`frames: [{ src, ms? }]`) strips. */
|
|
9
|
+
sheets?: PackStripSheet[];
|
|
10
|
+
/** M-3394: per-frame durations in ms (length === `frames`). */
|
|
11
|
+
durations?: number[];
|
|
12
|
+
/** M-3394: play once and hold the last frame. */
|
|
13
|
+
once?: boolean;
|
|
14
|
+
/** M-3394 (#4231): intro plays `0 .. loopFrom - 1` once, then loops `loopFrom .. frames - 1`. */
|
|
15
|
+
loopFrom?: number;
|
|
16
|
+
}
|
|
5
17
|
export interface PackPoint { x: number; y: number }
|
|
6
18
|
/** #2691: a seat reserved for `for` (lent while they are all elsewhere when `lend`); a plain seat has neither. */
|
|
7
19
|
export interface PackSeat extends PackPoint { for?: string[]; lend?: boolean }
|
|
@@ -27,9 +39,40 @@ export interface CheckedPack {
|
|
|
27
39
|
portraits?: { default?: PackPortrait; byInstance: Record<string, PackPortrait>; byUser: Record<string, PackPortrait>; npc: Record<string, PackPortrait> };
|
|
28
40
|
/** #2861: the dialogue box's look — a 9-slice frame and colours (#rrggbb). */
|
|
29
41
|
dialogBox?: { frame?: string; slice?: number; background?: string; border?: string; text?: string; name?: string };
|
|
42
|
+
/** #4256: optional agent profile card preset, visual style, and layout. */
|
|
43
|
+
card?: PackCard;
|
|
30
44
|
/** #3685: areas an idle person now and then visits (a free seat there, for minSeconds–maxSeconds); absent: none. */
|
|
31
45
|
idleVisits?: Array<{ area: string; weight: number; minSeconds: number; maxSeconds: number }>;
|
|
46
|
+
/** M-3432 (#4255): optional custom snacks the viewer may drag-to-feed or place on the floor. */
|
|
47
|
+
snacks?: PackSnack[];
|
|
48
|
+
}
|
|
49
|
+
/** M-3432 (#4255): one custom snack item from a pack's `snacks` list. */
|
|
50
|
+
export interface PackSnack {
|
|
51
|
+
id: string;
|
|
52
|
+
label?: string | { en?: string; "zh-TW"?: string };
|
|
53
|
+
sprite: PackStrip;
|
|
54
|
+
eat?: PackStrip;
|
|
55
|
+
radius: number;
|
|
56
|
+
}
|
|
57
|
+
/** #4256: agent profile card style and layout from a skin pack. */
|
|
58
|
+
export type CardPreset = "default" | "rpg" | "compact" | "dossier";
|
|
59
|
+
export type CardRadius = "none" | "sm" | "md" | "lg";
|
|
60
|
+
export type CardAvatarSize = "sm" | "md" | "lg";
|
|
61
|
+
export type CardAvatarSource = "sprite" | "portrait";
|
|
62
|
+
export type CardHeaderAlign = "left" | "center";
|
|
63
|
+
export type CardSection = "header" | "level" | "rows" | "now" | "tell" | "actions";
|
|
64
|
+
export type CardRowKey = "office" | "model" | "backend" | "today" | "firstSeen";
|
|
65
|
+
export type CardHideKey = "instance" | "title" | "badge" | "level" | "xpBar" | "office" | "model" | "backend" | "today" | "firstSeen" | "now";
|
|
66
|
+
export interface PackCardStyle {
|
|
67
|
+
background?: string; border?: string; text?: string; muted?: string; accent?: string;
|
|
68
|
+
barTrack?: string; barFill?: string; buttonBg?: string; buttonText?: string; buttonPrimaryBg?: string; buttonPrimaryText?: string;
|
|
69
|
+
backgroundImage?: string; frame?: string; slice?: number; radius?: CardRadius;
|
|
70
|
+
}
|
|
71
|
+
export interface PackCardLayout {
|
|
72
|
+
avatarSize?: CardAvatarSize; avatarSource?: CardAvatarSource; headerAlign?: CardHeaderAlign; width?: number;
|
|
73
|
+
sections?: CardSection[]; rows?: CardRowKey[]; rowColumns?: 1 | 2; hide?: CardHideKey[];
|
|
32
74
|
}
|
|
75
|
+
export interface PackCard { preset?: CardPreset; style?: PackCardStyle; layout?: PackCardLayout }
|
|
33
76
|
/** #2861: a portrait's files by the state it is shown in (at least one). */
|
|
34
77
|
export type PackPortrait = Partial<Record<"idle" | "working" | "needs", string>>;
|
|
35
78
|
/** #2661: the Office levels' words (a pack's `levels`; #3679: the fleet-wide one too). */
|
|
@@ -52,10 +95,33 @@ export const LOGICAL: { w: number; h: number };
|
|
|
52
95
|
export const CHAR_DEPTH: number;
|
|
53
96
|
export const PACK_STATES: string[];
|
|
54
97
|
export const BUBBLE_KEYS: string[];
|
|
98
|
+
export const STRIP_LIMITS: { sheetFrames: number; sheets: number; frames: number; minMs: number; maxMs: number };
|
|
99
|
+
export const SNACK_LIMITS: { max: number; minRadius: number; maxRadius: number; defaultRadius: number; labelMax: number };
|
|
100
|
+
export function snackLabel(snack: PackSnack | null | undefined, lang?: string): string;
|
|
101
|
+
export function stripDurationMs(st: PackStrip | null | undefined): number;
|
|
55
102
|
export function own<T = unknown>(o: unknown, k: unknown): T | undefined;
|
|
56
103
|
export function inherited(k: unknown): boolean;
|
|
57
104
|
export function matteOk(v: unknown): v is string;
|
|
105
|
+
export function relativeLuminance(hex: string): number | null;
|
|
106
|
+
export function contrastRatio(hexA: string, hexB: string): number;
|
|
107
|
+
export const CARD_PRESETS: CardPreset[];
|
|
108
|
+
export const CARD_RADII: CardRadius[];
|
|
109
|
+
export const CARD_AVATAR_SIZES: CardAvatarSize[];
|
|
110
|
+
export const CARD_AVATAR_SOURCES: CardAvatarSource[];
|
|
111
|
+
export const CARD_HEADER_ALIGNS: CardHeaderAlign[];
|
|
112
|
+
export const CARD_SECTIONS: CardSection[];
|
|
113
|
+
export const CARD_ROWS: CardRowKey[];
|
|
114
|
+
export const CARD_HIDE: CardHideKey[];
|
|
115
|
+
export const CARD_STYLE_COLORS: string[];
|
|
116
|
+
export const CARD_LIMITS: { widthMin: number; widthMax: number; sliceMax: number; textContrast: number; uiContrast: number };
|
|
58
117
|
export function checkStrip(v: unknown, at?: string, scale?: number): PackStrip;
|
|
118
|
+
export function stripSheets(st: PackStrip | null | undefined): PackStripSheet[];
|
|
119
|
+
export function stripImages(st: PackStrip | null | undefined): string[];
|
|
120
|
+
export function stripFrameAt(st: PackStrip | null | undefined, ms: number): number;
|
|
121
|
+
export function stripCell(st: PackStrip | null | undefined, frame: number): { src: string; col: number };
|
|
122
|
+
export function stripMaxFps(st: PackStrip | null | undefined): number;
|
|
123
|
+
export function packMaxFps(pack: CheckedPack | null | undefined): number;
|
|
124
|
+
export function createClipClocks(): { elapsed(key: string, strip: PackStrip | null | undefined, ms: number): number; prune(seen: ReadonlySet<string>): void; clear(): void };
|
|
59
125
|
export function checkSkinPack(x: unknown, opts?: { kept?: boolean }): { ok: true; pack: CheckedPack } | { ok: false; error: string };
|
|
60
126
|
/** #3679: a fleet-wide `levels`, by a pack's rules. */
|
|
61
127
|
export function checkLevels(v: unknown): { ok: true; levels: LevelWords } | { ok: false; error: string };
|