@songsid/agend 2.3.1 → 2.3.2-beta.10
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/THIRD_PARTY_NOTICES.md +40 -0
- package/dist/agent-cli.js +21 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.js +5 -0
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/antigravity-usage-scan.d.ts +58 -0
- package/dist/antigravity-usage-scan.js +257 -0
- package/dist/antigravity-usage-scan.js.map +1 -0
- package/dist/antigravity-usage-worker.d.ts +1 -0
- package/dist/antigravity-usage-worker.js +10 -0
- package/dist/antigravity-usage-worker.js.map +1 -0
- package/dist/auth-api.js +4 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/authority-state.d.ts +4 -0
- package/dist/authority/authority-state.js +16 -10
- package/dist/authority/authority-state.js.map +1 -1
- package/dist/authority/session-authorizations.d.ts +7 -1
- package/dist/authority/session-authorizations.js +6 -4
- package/dist/authority/session-authorizations.js.map +1 -1
- package/dist/authority/web-authority.d.ts +19 -6
- package/dist/authority/web-authority.js +22 -8
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/backend/kiro-identity.d.ts +64 -0
- package/dist/backend/kiro-identity.js +101 -0
- package/dist/backend/kiro-identity.js.map +1 -1
- package/dist/backend/kiro-retired-model.d.ts +62 -0
- package/dist/backend/kiro-retired-model.js +160 -0
- package/dist/backend/kiro-retired-model.js.map +1 -0
- package/dist/backend/kiro.d.ts +71 -2
- package/dist/backend/kiro.js +352 -11
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +59 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-signin-guide.d.ts +1 -0
- package/dist/backend-signin-guide.js +9 -0
- package/dist/backend-signin-guide.js.map +1 -0
- package/dist/backend-signin-pending.d.ts +10 -0
- package/dist/backend-signin-pending.js +44 -0
- package/dist/backend-signin-pending.js.map +1 -0
- package/dist/browser-backend-signins.d.ts +56 -0
- package/dist/browser-backend-signins.js +189 -0
- package/dist/browser-backend-signins.js.map +1 -0
- package/dist/cache-ledger.d.ts +38 -2
- package/dist/cache-ledger.js +133 -8
- package/dist/cache-ledger.js.map +1 -1
- package/dist/cache-prices.d.ts +2 -1
- package/dist/cache-prices.js +5 -2
- package/dist/cache-prices.js.map +1 -1
- package/dist/cache-service.d.ts +68 -0
- package/dist/cache-service.js +355 -13
- package/dist/cache-service.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +13 -0
- package/dist/channel/adapters/discord.js +103 -16
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/mcp-tools.js +34 -7
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/tool-router.js +2 -1
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/channel/types.d.ts +11 -0
- package/dist/classic-channel-manager.d.ts +11 -0
- package/dist/classic-channel-manager.js +39 -1
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/cli.js +21 -2
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.d.ts +7 -1
- package/dist/config-validator.js +92 -12
- package/dist/config-validator.js.map +1 -1
- package/dist/config.d.ts +19 -0
- package/dist/config.js +31 -1
- package/dist/config.js.map +1 -1
- package/dist/cpu-quota.d.ts +23 -0
- package/dist/cpu-quota.js +86 -0
- package/dist/cpu-quota.js.map +1 -0
- package/dist/daemon.d.ts +57 -3
- package/dist/daemon.js +330 -50
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard-permissions.d.ts +20 -6
- package/dist/dashboard-permissions.js +58 -9
- package/dist/dashboard-permissions.js.map +1 -1
- package/dist/delivery-outbox.d.ts +12 -1
- package/dist/delivery-outbox.js +67 -15
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.js +11 -1
- package/dist/doctor.js.map +1 -1
- package/dist/event-log.d.ts +5 -0
- package/dist/event-log.js +13 -0
- package/dist/event-log.js.map +1 -1
- package/dist/fleet-manager.d.ts +212 -0
- package/dist/fleet-manager.js +914 -111
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-process-handlers.d.ts +1 -0
- package/dist/fleet-process-handlers.js +9 -1
- package/dist/fleet-process-handlers.js.map +1 -1
- package/dist/forged-envelope-scan.d.ts +9 -0
- package/dist/forged-envelope-scan.js +30 -5
- package/dist/forged-envelope-scan.js.map +1 -1
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +5 -2
- package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +14 -1
- package/dist/general-knowledge/skills/web-appearance/SKILL.canvas-worker-off.md +28 -5
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +31 -8
- package/dist/general-knowledge/skills/web-dashboard/SKILL.canvas-worker-off.md +138 -59
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +145 -61
- package/dist/guest-seen-people.d.ts +38 -0
- package/dist/guest-seen-people.js +78 -0
- package/dist/guest-seen-people.js.map +1 -0
- package/dist/instance-config-impact.js +14 -6
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +20 -0
- package/dist/instance-lifecycle.js +71 -13
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/kiro-db-reader.d.ts +5 -0
- package/dist/kiro-db-reader.js +18 -0
- package/dist/kiro-db-reader.js.map +1 -1
- package/dist/kiro-engine-status.d.ts +2 -0
- package/dist/kiro-engine-status.js +9 -0
- package/dist/kiro-engine-status.js.map +1 -1
- package/dist/kiro-migrate.d.ts +49 -0
- package/dist/kiro-migrate.js +105 -0
- package/dist/kiro-migrate.js.map +1 -0
- package/dist/kiro-transcript-lane.d.ts +2 -0
- package/dist/kiro-transcript-lane.js.map +1 -1
- package/dist/kiro-transcript-worker.js +1 -0
- package/dist/kiro-transcript-worker.js.map +1 -1
- package/dist/kiro-tui-forensic.d.ts +7 -0
- package/dist/kiro-tui-forensic.js +110 -0
- package/dist/kiro-tui-forensic.js.map +1 -0
- package/dist/kiro-usage-run.d.ts +7 -0
- package/dist/kiro-usage-run.js +39 -0
- package/dist/kiro-usage-run.js.map +1 -0
- package/dist/kiro-usage-scan.d.ts +49 -0
- package/dist/kiro-usage-scan.js +223 -0
- package/dist/kiro-usage-scan.js.map +1 -0
- package/dist/kiro-usage-worker.d.ts +1 -0
- package/dist/kiro-usage-worker.js +10 -0
- package/dist/kiro-usage-worker.js.map +1 -0
- package/dist/kiro-usage.d.ts +58 -0
- package/dist/kiro-usage.js +310 -0
- package/dist/kiro-usage.js.map +1 -0
- package/dist/locale.js +120 -12
- package/dist/locale.js.map +1 -1
- package/dist/log-service.js +1 -1
- package/dist/log-service.js.map +1 -1
- package/dist/login-url.d.ts +4 -0
- package/dist/login-url.js +22 -0
- package/dist/login-url.js.map +1 -0
- package/dist/mac-auto-restore.d.ts +117 -0
- package/dist/mac-auto-restore.js +294 -0
- package/dist/mac-auto-restore.js.map +1 -0
- package/dist/needs-you-hub.d.ts +2 -1
- package/dist/needs-you-hub.js +1 -1
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +8 -2
- package/dist/needs-you.js +6 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/notice-delivery.d.ts +16 -0
- package/dist/notice-delivery.js +35 -0
- package/dist/notice-delivery.js.map +1 -0
- package/dist/office-share-page.d.ts +16 -0
- package/dist/office-share-page.js +85 -0
- package/dist/office-share-page.js.map +1 -0
- package/dist/office-share-service.d.ts +91 -0
- package/dist/office-share-service.js +176 -0
- package/dist/office-share-service.js.map +1 -0
- package/dist/office-share.d.ts +258 -0
- package/dist/office-share.js +549 -0
- package/dist/office-share.js.map +1 -0
- package/dist/opencode-usage-scan.d.ts +28 -0
- package/dist/opencode-usage-scan.js +92 -0
- package/dist/opencode-usage-scan.js.map +1 -0
- package/dist/opencode-usage-worker.d.ts +1 -0
- package/dist/opencode-usage-worker.js +10 -0
- package/dist/opencode-usage-worker.js.map +1 -0
- package/dist/outbound-handlers.js +22 -2
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +28 -2
- package/dist/outbound-schemas.js +29 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +16 -2
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/quickstart-api.js +13 -2
- package/dist/quickstart-api.js.map +1 -1
- package/dist/quickstart.js +2 -1
- package/dist/quickstart.js.map +1 -1
- package/dist/remote-card-answer.d.ts +83 -0
- package/dist/remote-card-answer.js +208 -0
- package/dist/remote-card-answer.js.map +1 -0
- package/dist/reply-triggers.d.ts +2 -0
- package/dist/reply-triggers.js +3 -0
- package/dist/reply-triggers.js.map +1 -0
- package/dist/settings-api.d.ts +28 -0
- package/dist/settings-api.js +148 -17
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +54 -17
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.js +12 -3
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-instance-patch.js +4 -1
- package/dist/settings-instance-patch.js.map +1 -1
- package/dist/setup-form.d.ts +1 -1
- package/dist/setup-form.js +55 -6
- package/dist/setup-form.js.map +1 -1
- package/dist/setup-host.d.ts +9 -0
- package/dist/setup-host.js +127 -6
- package/dist/setup-host.js.map +1 -1
- package/dist/setup-signin-assets.d.ts +2 -0
- package/dist/setup-signin-assets.js +6 -0
- package/dist/setup-signin-assets.js.map +1 -0
- package/dist/setup-wizard.js +2 -0
- package/dist/setup-wizard.js.map +1 -1
- package/dist/start-attempt.d.ts +9 -5
- package/dist/start-attempt.js +27 -8
- package/dist/start-attempt.js.map +1 -1
- package/dist/start-failure-chat.d.ts +4 -0
- package/dist/start-failure-chat.js +23 -6
- package/dist/start-failure-chat.js.map +1 -1
- package/dist/start-failure-notice.d.ts +4 -0
- package/dist/start-failure-notice.js +8 -0
- package/dist/start-failure-notice.js.map +1 -1
- package/dist/start-failure.d.ts +25 -0
- package/dist/start-failure.js +75 -2
- package/dist/start-failure.js.map +1 -1
- package/dist/structured-signin-transport.d.ts +8 -0
- package/dist/structured-signin-transport.js +79 -0
- package/dist/structured-signin-transport.js.map +1 -0
- package/dist/structured-signin.d.ts +131 -0
- package/dist/structured-signin.js +388 -0
- package/dist/structured-signin.js.map +1 -0
- package/dist/tool-permissions.js +12 -0
- package/dist/tool-permissions.js.map +1 -1
- package/dist/topic-commands.js +6 -2
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-sources.d.ts +26 -2
- package/dist/transcript-sources.js +103 -40
- package/dist/transcript-sources.js.map +1 -1
- package/dist/turn-reply-guard.d.ts +25 -0
- package/dist/turn-reply-guard.js +111 -12
- package/dist/turn-reply-guard.js.map +1 -1
- package/dist/types.d.ts +46 -9
- package/dist/ui/backend-signin.js +68 -12
- package/dist/ui/chat-ambient.js +1 -1
- package/dist/ui/chat-effects.js +4 -4
- package/dist/ui/chat-render.js +5 -2
- package/dist/ui/chat-strings.js +4 -4
- package/dist/ui/chat-thread.js +2 -2
- package/dist/ui/first-run.js +2 -2
- package/dist/ui/fleet-canvas-view.js +114 -0
- package/dist/ui/fleet-canvas.js +15 -77
- package/dist/ui/fleet-office-editor.js +94 -14
- package/dist/ui/fleet-office-layout.js +235 -0
- package/dist/ui/fleet-office-model.js +12 -6
- package/dist/ui/fleet-office-overview.js +167 -0
- package/dist/ui/fleet-office-pack.d.ts +44 -0
- package/dist/ui/fleet-office-pack.js +352 -37
- package/dist/ui/fleet-office-skin.js +220 -36
- package/dist/ui/fleet-office-store.js +112 -7
- package/dist/ui/fleet-office-view.js +155 -0
- package/dist/ui/fleet-office-zones.js +264 -42
- package/dist/ui/fleet-office.js +957 -160
- package/dist/ui/fleet-usage.js +26 -21
- package/dist/ui/office-share-dialog.js +145 -0
- package/dist/ui/office-share-page.js +164 -0
- package/dist/ui/panel-chat.js +9 -2
- package/dist/ui/panel-details.js +2 -2
- package/dist/ui/panel-fleet.js +11 -77
- package/dist/ui/panel-log.js +4 -4
- package/dist/ui/panel-needs.js +4 -4
- package/dist/ui/panel-settings.js +608 -167
- package/dist/ui/search-dialog.js +26 -7
- package/dist/ui/settings-appearance.js +82 -29
- package/dist/ui/settings-apply.js +42 -7
- package/dist/ui/settings-dialogs.js +76 -23
- package/dist/ui/settings-draft.js +51 -0
- package/dist/ui/settings-guests.js +255 -79
- package/dist/ui/settings-learn.js +2 -2
- package/dist/ui/settings-model.js +16 -6
- package/dist/ui/settings-registry.js +146 -0
- package/dist/ui/settings-strings.js +116 -44
- package/dist/ui/settings-web-authority.js +34 -23
- package/dist/ui/shared/app-i18n.js +18 -2
- package/dist/ui/shared/app-nav.js +10 -5
- package/dist/ui/shared/app-prefs.js +80 -2
- package/dist/ui/shared/app-route.js +39 -5
- package/dist/ui/shared/app-shell.js +73 -10
- package/dist/ui/shared/app-stream.js +3 -1
- package/dist/ui/shared/app.css +307 -17
- package/dist/ui/shared/app.js +3 -0
- package/dist/ui/shared/effect-stock-trust.js +1 -1
- package/dist/ui/shared/identity-color.js +4 -4
- package/dist/ui/shared/office/cozy.png +0 -0
- package/dist/ui/shared/side-panel.js +95 -0
- package/dist/ui/shared/signin.js +2 -2
- package/dist/ui/shared/ui-dialog.js +6 -1
- package/dist/ui/shared/ui-icons.js +2 -0
- package/dist/ui/shared/web-authorize.js +13 -12
- package/dist/ui/structured-signin.js +115 -0
- package/dist/usage-report.d.ts +20 -0
- package/dist/usage-report.js +54 -17
- package/dist/usage-report.js.map +1 -1
- package/dist/usage-rollup.d.ts +9 -1
- package/dist/usage-rollup.js +20 -4
- package/dist/usage-rollup.js.map +1 -1
- package/dist/web-api.d.ts +26 -2
- package/dist/web-api.js +361 -5
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.js +8 -2
- package/dist/web-auth.js.map +1 -1
- package/dist/web-backend-login.d.ts +1 -7
- package/dist/web-backend-login.js +2 -24
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-experimental.d.ts +1 -1
- package/dist/web-experimental.js +1 -1
- package/dist/web-experimental.js.map +1 -1
- package/dist/web-mod-agent.js +2 -2
- package/dist/web-mod-agent.js.map +1 -1
- package/dist/web-office-acts.d.ts +173 -0
- package/dist/web-office-acts.js +285 -0
- package/dist/web-office-acts.js.map +1 -0
- package/dist/web-office-skins.d.ts +109 -0
- package/dist/web-office-skins.js +299 -0
- package/dist/web-office-skins.js.map +1 -0
- package/dist/web-office-store.d.ts +8 -2
- package/dist/web-office-store.js +77 -14
- package/dist/web-office-store.js.map +1 -1
- package/dist/web-settings-patch.d.ts +8 -1
- package/dist/web-settings-patch.js +65 -5
- package/dist/web-settings-patch.js.map +1 -1
- package/dist/web-shell-routes.d.ts +4 -2
- package/dist/web-shell-routes.js +17 -7
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/working-recovery.d.ts +104 -0
- package/dist/working-recovery.js +298 -0
- package/dist/working-recovery.js.map +1 -0
- package/dist/working-state-journal.d.ts +5 -1
- package/dist/working-state-journal.js +31 -3
- package/dist/working-state-journal.js.map +1 -1
- package/package.json +3 -2
- package/templates/windows-shortcuts.ps1 +155 -140
package/dist/ui/chat-thread.js
CHANGED
|
@@ -14,7 +14,7 @@ import { chatTime, chatTimeFull, onDayChange } from "./chat-time.js";
|
|
|
14
14
|
import { textLinkSegments } from "/assets/app-route.js";
|
|
15
15
|
|
|
16
16
|
const R = () => globalThis.AgendChatRender;
|
|
17
|
-
/** #1589: the public link
|
|
17
|
+
/** #1589: the public link plays no media in the page (its page says so: <body data-public-link="1">); #2547: its text cards show. */
|
|
18
18
|
const PUBLIC_LINK = () => globalThis.document?.body?.dataset?.publicLink === "1";
|
|
19
19
|
/** #1589: how much of a text attachment is shown before "Show all". */
|
|
20
20
|
export const TEXT_PREVIEW_LINES = 200;
|
|
@@ -146,7 +146,7 @@ export function createThread(list, scroller, opts) {
|
|
|
146
146
|
// #2272: reply to it — a hover strip at its top right (phones: swipe left or long-press; R on a focused message).
|
|
147
147
|
const key = msgKey(x);
|
|
148
148
|
const act = opts.canReply?.() === false ? "" : `<div data-trust="thread-control" class="msg-actions"><button type="button" class="chip-btn icon-only" data-act="reply" data-arg="${escAttr(key)}" title="${escAttr(tr("chat.reply"))}" aria-label="${escAttr(tr("chat.reply"))}">${REPLY}</button></div>`;
|
|
149
|
-
return `<div class="msg ${u ? "user" : "agent"}" data-key="${escAttr(key)}" tabindex="-1">${act}<div class="meta"><span class="sender">${escAttr(x.sender)}</span>${time}${ticks}</div>${quoteHtml(x.replyTo)}<div class="body">${clicked ? clickHtml(x.click) : `<div class="md">${renderedMarkdown(x.text, x.role === "agent", opts.emojis, opts.mentions)}</div>`}${R().attachmentsHtml(x.attachments, { htmlCards: x.role === "agent", goneTitle: tr("chat.attGone"), goneLabel: tr("chat.attUnavailable"), inlinePreviews: !PUBLIC_LINK() })}${buttons}</div>${R().reactionsHtml(x.reactions, tr("chat.reactedBy", x.instance || ""))}${tools}</div>`;
|
|
149
|
+
return `<div class="msg ${u ? "user" : "agent"}" data-key="${escAttr(key)}" tabindex="-1">${act}<div class="meta"><span class="sender">${escAttr(x.sender)}</span>${time}${ticks}</div>${quoteHtml(x.replyTo)}<div class="body">${clicked ? clickHtml(x.click) : `<div class="md">${renderedMarkdown(x.text, x.role === "agent", opts.emojis, opts.mentions)}</div>`}${R().attachmentsHtml(x.attachments, { htmlCards: x.role === "agent", goneTitle: tr("chat.attGone"), goneLabel: tr("chat.attUnavailable"), inlinePreviews: !PUBLIC_LINK(), textPreviews: true })}${buttons}</div>${R().reactionsHtml(x.reactions, tr("chat.reactedBy", x.instance || ""))}${tools}</div>`;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* A message this page is sending (chat-store.js): its own bubble at once, dimmed with "Sending…" until the server
|
package/dist/ui/first-run.js
CHANGED
|
@@ -5,7 +5,7 @@ import { html } from "/assets/app-html.js";
|
|
|
5
5
|
import { register, t } from "/assets/app-i18n.js";
|
|
6
6
|
import { appStore, createStore, useStore } from "/assets/app-store.js";
|
|
7
7
|
import { navigate } from "/assets/app-nav.js";
|
|
8
|
-
import {
|
|
8
|
+
import { sectionPath } from "/assets/app-route.js";
|
|
9
9
|
import { Icon } from "/assets/ui-icons.js";
|
|
10
10
|
|
|
11
11
|
register("firstRun", {
|
|
@@ -52,7 +52,7 @@ export function useFirstRun() {
|
|
|
52
52
|
export function FirstRunCard({ onConnect }) {
|
|
53
53
|
const shown = useFirstRun();
|
|
54
54
|
if (!shown) return null;
|
|
55
|
-
const connect = onConnect || (() => { local.set({ wizard: true }); navigate(
|
|
55
|
+
const connect = onConnect || (() => { local.set({ wizard: true }); navigate(sectionPath("bots")); });
|
|
56
56
|
return html`<section class="card first-run" aria-labelledby="first-run-title">
|
|
57
57
|
<h3 id="first-run-title"><${Icon} name="plug" size=${14} /> ${t("firstRun.title")}</h3>
|
|
58
58
|
<p>${t("firstRun.body")}</p>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// The Fleet canvases' shared view (#1918's org chart canvas, fleet-canvas.js; #2540's Office, fleet-office.js): the pure
|
|
2
|
+
// pan and zoom math and the pointer gestures, so both feel the same. A view is { k, x, y }: a world point (wx, wy) is
|
|
3
|
+
// drawn at (x + wx·k, y + wy·k) in the viewport's CSS px.
|
|
4
|
+
//
|
|
5
|
+
// - One pointer pans once it has moved a few px (so a tap still opens what it is on); two pinch: the world point under
|
|
6
|
+
// their old midpoint goes to the new one, scaled by how their span changed (a two-finger move pans too). The pointer
|
|
7
|
+
// is captured only once it drags: a capture at once would send the tap's click to the viewport, not what was tapped.
|
|
8
|
+
// The click that ends a drag or a pinch opens nothing.
|
|
9
|
+
// - The wheel zooms about the pointer; + / − / 0 zoom in, out and fit (with no Alt, Ctrl or Meta held).
|
|
10
|
+
|
|
11
|
+
export const K_MIN = 0.2, K_MAX = 2.5;
|
|
12
|
+
/** `k` kept in [lo, hi] (the org canvas's range by default). */
|
|
13
|
+
export const clampK = (k, lo = K_MIN, hi = K_MAX) => Math.min(hi, Math.max(lo, k));
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The view that shows region `r` in a `size` viewport: as large as fits (at most `maxK`), centred across, from the top.
|
|
17
|
+
* `minK`: never smaller than this (a phone's opening); a region that is then wider than the viewport starts at its left.
|
|
18
|
+
* `widthOnly`: fit the width, let the height run on (the opening: the rest is below).
|
|
19
|
+
*/
|
|
20
|
+
export function fitView(r, size, { margin = 24, minK = K_MIN, maxK = 1.25, widthOnly = false } = {}) {
|
|
21
|
+
const across = (size.w - 2 * margin) / r.w, down = widthOnly ? Infinity : (size.h - 2 * margin) / r.h;
|
|
22
|
+
const k = clampK(Math.max(minK, Math.min(across, down, maxK)));
|
|
23
|
+
const x = r.w * k > size.w - 2 * margin ? margin - r.x * k : size.w / 2 - (r.x + r.w / 2) * k;
|
|
24
|
+
return { k, x, y: margin - r.y * k };
|
|
25
|
+
}
|
|
26
|
+
/** The view at scale `k` with the viewport point (cx, cy) on the same world point as in `v`. */
|
|
27
|
+
export function zoomTo(v, k, cx, cy) {
|
|
28
|
+
return { k, x: cx - (cx - v.x) * (k / v.k), y: cy - (cy - v.y) * (k / v.k) };
|
|
29
|
+
}
|
|
30
|
+
/** Zoom by `f` about the viewport point (cx, cy): the canvas point under it stays under it. */
|
|
31
|
+
export function zoomAt(v, f, cx, cy) { return zoomTo(v, clampK(v.k * f), cx, cy); }
|
|
32
|
+
/** A pinch step at scale `k`: the world point under the old midpoint goes to the new midpoint. */
|
|
33
|
+
export function pinchTo(v, from, to, k) {
|
|
34
|
+
const wx = (from.mid.x - v.x) / v.k, wy = (from.mid.y - v.y) / v.k;
|
|
35
|
+
return { k, x: to.mid.x - wx * k, y: to.mid.y - wy * k };
|
|
36
|
+
}
|
|
37
|
+
/** A pinch step: the canvas point under the old midpoint goes to the new midpoint, the zoom scaled by the spans' ratio. */
|
|
38
|
+
export function pinchView(v, from, to) { return pinchTo(v, from, to, clampK(v.k * (to.dist / from.dist))); }
|
|
39
|
+
/** Viewport CSS px → world units, and back. */
|
|
40
|
+
export const toWorld = (v, sx, sy) => ({ x: (sx - v.x) / v.k, y: (sy - v.y) / v.k });
|
|
41
|
+
export const toScreen = (v, wx, wy) => ({ x: v.x + wx * v.k, y: v.y + wy * v.k });
|
|
42
|
+
/** The view at the same scale with world point (wx, wy) in the middle of a `size` viewport. */
|
|
43
|
+
export const centreOn = (v, size, wx, wy) => ({ k: v.k, x: size.w / 2 - wx * v.k, y: size.h / 2 - wy * v.k });
|
|
44
|
+
/**
|
|
45
|
+
* The world point a click on an overview at `rect` (its client box) shows, for an overview of world box `box` drawn
|
|
46
|
+
* whole and centred in it (an SVG viewBox's xMidYMid meet); null when it has no size.
|
|
47
|
+
*/
|
|
48
|
+
export function miniPoint(rect, box, clientX, clientY) {
|
|
49
|
+
if (!rect || !rect.width || !rect.height) return null;
|
|
50
|
+
const scale = Math.min(rect.width / box.w, rect.height / box.h);
|
|
51
|
+
return { x: box.x + (clientX - rect.left - (rect.width - box.w * scale) / 2) / scale, y: box.y + (clientY - rect.top - (rect.height - box.h * scale) / 2) / scale };
|
|
52
|
+
}
|
|
53
|
+
/** The wheel's zoom factor (a notch is about 15%; a trackpad's small deltas zoom a little). */
|
|
54
|
+
export const wheelFactor = (e) => Math.exp(-e.deltaY * 0.0015);
|
|
55
|
+
/** What a key does to the view: "in", "out", "fit" (0), or null (any other key, or with Alt, Ctrl or Meta). */
|
|
56
|
+
export function zoomKey(e) {
|
|
57
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return null;
|
|
58
|
+
if (e.key === "+" || e.key === "=") return "in";
|
|
59
|
+
if (e.key === "-" || e.key === "_") return "out";
|
|
60
|
+
if (e.key === "0") return "fit";
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ── The pointer gestures: the state lives in the caller's ref (it outlives a render), the handlers are made per render ──
|
|
65
|
+
|
|
66
|
+
export const SLOP = 5;
|
|
67
|
+
/** A fresh gesture state: the pointers down, how far the one has moved, the pinch's last span, whether to swallow the click. */
|
|
68
|
+
export const gestureState = () => ({ pts: new Map(), moved: 0, span: null, swallow: false });
|
|
69
|
+
/**
|
|
70
|
+
* The handlers for state `d`: `el()` the element measured and captured; `pan(dx, dy)` and `pinch(from, to)` move the
|
|
71
|
+
* view. `move` returns whether it was a drag or a pinch (not a hover). `busy()`: a drag or pinch is under way.
|
|
72
|
+
*/
|
|
73
|
+
export function gestures(d, { el, pan, pinch }) {
|
|
74
|
+
const spanOf = () => {
|
|
75
|
+
const [a, b] = [...d.pts.values()], r = el().getBoundingClientRect();
|
|
76
|
+
return { mid: { x: (a.x + b.x) / 2 - r.left, y: (a.y + b.y) / 2 - r.top }, dist: Math.hypot(a.x - b.x, a.y - b.y) };
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
down(e) {
|
|
80
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
81
|
+
d.pts.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
82
|
+
if (d.pts.size === 1) { d.moved = 0; d.swallow = false; d.span = null; }
|
|
83
|
+
else if (d.pts.size === 2) { d.swallow = true; d.span = spanOf(); }
|
|
84
|
+
},
|
|
85
|
+
move(e) {
|
|
86
|
+
const prev = d.pts.get(e.pointerId);
|
|
87
|
+
if (!prev) return false;
|
|
88
|
+
d.pts.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
89
|
+
if (d.pts.size === 1) {
|
|
90
|
+
d.moved += Math.abs(e.clientX - prev.x) + Math.abs(e.clientY - prev.y);
|
|
91
|
+
if (d.moved < SLOP) return false;
|
|
92
|
+
if (!d.swallow) { d.swallow = true; try { el().setPointerCapture(e.pointerId); } catch { /* gone already */ } }
|
|
93
|
+
pan(e.clientX - prev.x, e.clientY - prev.y);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (d.pts.size !== 2) return true;
|
|
97
|
+
d.swallow = true;
|
|
98
|
+
const next = spanOf();
|
|
99
|
+
if (d.span && d.span.dist > 0 && next.dist > 0) pinch(d.span, next);
|
|
100
|
+
d.span = next;
|
|
101
|
+
return true;
|
|
102
|
+
},
|
|
103
|
+
up(e) {
|
|
104
|
+
d.pts.delete(e.pointerId);
|
|
105
|
+
// Back to one finger: it pans on at once (the pinch already swallows the click); two again: a new span.
|
|
106
|
+
d.span = d.pts.size === 2 ? spanOf() : null;
|
|
107
|
+
if (d.pts.size === 1) d.moved = SLOP;
|
|
108
|
+
// The click that ends a drag comes after this: let it be swallowed, then forget.
|
|
109
|
+
if (d.swallow && !d.pts.size) setTimeout(() => { if (!d.pts.size) d.swallow = false; }, 0);
|
|
110
|
+
},
|
|
111
|
+
clickCapture(e) { if (d.swallow) { e.preventDefault(); e.stopPropagation(); } },
|
|
112
|
+
busy: () => d.swallow && d.pts.size > 0,
|
|
113
|
+
};
|
|
114
|
+
}
|
package/dist/ui/fleet-canvas.js
CHANGED
|
@@ -32,6 +32,7 @@ import { Office } from "./fleet-office.js";
|
|
|
32
32
|
import { OC, REST_KEY, SUM_LINE, canvasLayout, hits, needle, openingRegion, summaryRows } from "./fleet-canvas-layout.js";
|
|
33
33
|
import { createTrafficStore, FAR_K, HEAD, POLL_MS, sendingBy, trafficEdges } from "./fleet-traffic.js";
|
|
34
34
|
import { routeScene } from "./fleet-route-scene.js";
|
|
35
|
+
import { K_MAX, K_MIN, fitView, gestureState, gestures, miniPoint, pinchView, wheelFactor, zoomAt, zoomKey } from "./fleet-canvas-view.js";
|
|
35
36
|
import { createRouteClient } from "./fleet-route.js";
|
|
36
37
|
|
|
37
38
|
register("orgc", {
|
|
@@ -62,32 +63,9 @@ const tc = (k, ...v) => t(`orgc.${k}`, ...v);
|
|
|
62
63
|
|
|
63
64
|
export { OC, REST_KEY, SUM_LINE, canvasLayout, openingRegion, summaryRows };
|
|
64
65
|
|
|
65
|
-
// ── The view: pan, zoom, fit (
|
|
66
|
+
// ── The view: pan, zoom, fit and the gestures (fleet-canvas-view.js, shared with the Office view) ──
|
|
66
67
|
|
|
67
|
-
export
|
|
68
|
-
const clampK = (k) => Math.min(K_MAX, Math.max(K_MIN, k));
|
|
69
|
-
/**
|
|
70
|
-
* The view that shows region `r` in a `size` viewport: as large as fits (at most `maxK`), centred across, from the top.
|
|
71
|
-
* `minK`: never smaller than this (a phone's opening); a region that is then wider than the viewport starts at its left.
|
|
72
|
-
* `widthOnly`: fit the width, let the height run on (the opening: the rest is below).
|
|
73
|
-
*/
|
|
74
|
-
export function fitView(r, size, { margin = 24, minK = K_MIN, maxK = 1.25, widthOnly = false } = {}) {
|
|
75
|
-
const across = (size.w - 2 * margin) / r.w, down = widthOnly ? Infinity : (size.h - 2 * margin) / r.h;
|
|
76
|
-
const k = clampK(Math.max(minK, Math.min(across, down, maxK)));
|
|
77
|
-
const x = r.w * k > size.w - 2 * margin ? margin - r.x * k : size.w / 2 - (r.x + r.w / 2) * k;
|
|
78
|
-
return { k, x, y: margin - r.y * k };
|
|
79
|
-
}
|
|
80
|
-
/** A pinch step: the canvas point under the old midpoint goes to the new midpoint, the zoom scaled by the spans' ratio. */
|
|
81
|
-
export function pinchView(v, from, to) {
|
|
82
|
-
const k = clampK(v.k * (to.dist / from.dist));
|
|
83
|
-
const wx = (from.mid.x - v.x) / v.k, wy = (from.mid.y - v.y) / v.k;
|
|
84
|
-
return { k, x: to.mid.x - wx * k, y: to.mid.y - wy * k };
|
|
85
|
-
}
|
|
86
|
-
/** Zoom by `f` about the viewport point (cx, cy): the canvas point under it stays under it. */
|
|
87
|
-
export function zoomAt(v, f, cx, cy) {
|
|
88
|
-
const k = clampK(v.k * f);
|
|
89
|
-
return { k, x: cx - (cx - v.x) * (k / v.k), y: cy - (cy - v.y) * (k / v.k) };
|
|
90
|
-
}
|
|
68
|
+
export { K_MIN, K_MAX, fitView, pinchView, zoomAt };
|
|
91
69
|
|
|
92
70
|
// ── Per device ──
|
|
93
71
|
|
|
@@ -316,7 +294,7 @@ function Canvas({ view, folded, onFold, q, jump, traffic }) {
|
|
|
316
294
|
const L = useMemo(() => canvasLayout(view, folded, { narrow, label: (s, n) => `${n} ${STATE_LABEL(s)}` }), [view, folded, narrow]);
|
|
317
295
|
const svgRef = useRef(null), worldRef = useRef(null), miniRef = useRef(null), miniViewRef = useRef(null);
|
|
318
296
|
const vp = useRef(null);
|
|
319
|
-
const drag = useRef(
|
|
297
|
+
const drag = useRef(gestureState());
|
|
320
298
|
const size = () => {
|
|
321
299
|
const r = svgRef.current ? svgRef.current.getBoundingClientRect() : null;
|
|
322
300
|
return r && r.width > 0 && r.height > 0 ? { w: r.width, h: r.height } : { w: 960, h: 600 };
|
|
@@ -364,58 +342,20 @@ function Canvas({ view, folded, onFold, q, jump, traffic }) {
|
|
|
364
342
|
});
|
|
365
343
|
|
|
366
344
|
const open = openChat;
|
|
367
|
-
// The click that ends a drag or a pinch opens nothing and folds nothing.
|
|
368
|
-
const
|
|
345
|
+
// The click that ends a drag or a pinch opens nothing and folds nothing (fleet-canvas-view.js gestures).
|
|
346
|
+
const g = gestures(drag.current, { el: () => svgRef.current, pan: (dx, dy) => set({ ...vp.current, x: vp.current.x + dx, y: vp.current.y + dy }),
|
|
347
|
+
pinch: (from, to) => set(pinchView(vp.current, from, to)) });
|
|
348
|
+
const onClickCapture = g.clickCapture;
|
|
369
349
|
const onWheel = (e) => {
|
|
370
350
|
e.preventDefault();
|
|
371
351
|
const r = svgRef.current.getBoundingClientRect();
|
|
372
|
-
set(zoomAt(vp.current,
|
|
373
|
-
};
|
|
374
|
-
// One pointer pans (after a few pixels, so a tap still opens a card); two pinch: the canvas point under their old
|
|
375
|
-
// midpoint goes to the new one, scaled by how their span changed (so a two-finger move pans too). The pointer is
|
|
376
|
-
// captured only once it drags: a capture at once would send the tap's click to the canvas, not the card.
|
|
377
|
-
const spanOf = () => {
|
|
378
|
-
const [a, b] = [...drag.current.pts.values()], r = svgRef.current.getBoundingClientRect();
|
|
379
|
-
return { mid: { x: (a.x + b.x) / 2 - r.left, y: (a.y + b.y) / 2 - r.top }, dist: Math.hypot(a.x - b.x, a.y - b.y) };
|
|
380
|
-
};
|
|
381
|
-
const onPointerDown = (e) => {
|
|
382
|
-
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
383
|
-
const d = drag.current;
|
|
384
|
-
d.pts.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
385
|
-
if (d.pts.size === 1) { d.moved = 0; d.swallow = false; d.span = null; }
|
|
386
|
-
else if (d.pts.size === 2) { d.swallow = true; d.span = spanOf(); }
|
|
387
|
-
};
|
|
388
|
-
const onPointerMove = (e) => {
|
|
389
|
-
const d = drag.current, prev = d.pts.get(e.pointerId);
|
|
390
|
-
if (!prev) return;
|
|
391
|
-
d.pts.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
392
|
-
if (d.pts.size === 1) {
|
|
393
|
-
d.moved += Math.abs(e.clientX - prev.x) + Math.abs(e.clientY - prev.y);
|
|
394
|
-
if (d.moved < 5) return;
|
|
395
|
-
if (!d.swallow) { d.swallow = true; try { svgRef.current.setPointerCapture(e.pointerId); } catch { /* gone already */ } }
|
|
396
|
-
set({ ...vp.current, x: vp.current.x + e.clientX - prev.x, y: vp.current.y + e.clientY - prev.y });
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
if (d.pts.size !== 2) return;
|
|
400
|
-
d.swallow = true;
|
|
401
|
-
const next = spanOf();
|
|
402
|
-
if (d.span && d.span.dist > 0 && next.dist > 0) set(pinchView(vp.current, d.span, next));
|
|
403
|
-
d.span = next;
|
|
404
|
-
};
|
|
405
|
-
const onPointerUp = (e) => {
|
|
406
|
-
const d = drag.current;
|
|
407
|
-
d.pts.delete(e.pointerId);
|
|
408
|
-
// Back to one finger: it pans on at once (the pinch already swallows the click); two again: a new span.
|
|
409
|
-
d.span = d.pts.size === 2 ? spanOf() : null;
|
|
410
|
-
if (d.pts.size === 1) d.moved = 5;
|
|
411
|
-
// The click that ends a drag comes after this: let it be swallowed, then forget.
|
|
412
|
-
if (d.swallow && !d.pts.size) setTimeout(() => { if (!d.pts.size) d.swallow = false; }, 0);
|
|
352
|
+
set(zoomAt(vp.current, wheelFactor(e), e.clientX - r.left, e.clientY - r.top));
|
|
413
353
|
};
|
|
354
|
+
const onPointerDown = g.down, onPointerMove = g.move, onPointerUp = g.up;
|
|
414
355
|
const onKeyDown = (e) => {
|
|
415
356
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
416
|
-
|
|
417
|
-
if (e.
|
|
418
|
-
if (e.key === "0") { e.preventDefault(); fit(); return; }
|
|
357
|
+
const z = zoomKey(e);
|
|
358
|
+
if (z) { e.preventDefault(); if (z === "fit") fit(); else zoomBy(z === "in" ? 1.25 : 0.8); return; }
|
|
419
359
|
const dir = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[e.key];
|
|
420
360
|
const card = e.target && e.target.closest ? e.target.closest(".oc-node") : null;
|
|
421
361
|
if (card && (e.key === "Enter" || e.key === " ")) {
|
|
@@ -436,12 +376,10 @@ function Canvas({ view, folded, onFold, q, jump, traffic }) {
|
|
|
436
376
|
if (c) show(c, false);
|
|
437
377
|
};
|
|
438
378
|
const onMini = (e) => {
|
|
439
|
-
const
|
|
440
|
-
if (!
|
|
441
|
-
const scale = Math.min(r.width / box.w, r.height / box.h);
|
|
442
|
-
const wx = box.x + (e.clientX - r.left - (r.width - box.w * scale) / 2) / scale, wy = box.y + (e.clientY - r.top - (r.height - box.h * scale) / 2) / scale;
|
|
379
|
+
const w = miniPoint(miniRef.current.getBoundingClientRect(), miniBox(L), e.clientX, e.clientY);
|
|
380
|
+
if (!w) return;
|
|
443
381
|
const s = size(), v = vp.current;
|
|
444
|
-
set({ k: v.k, x: s.w / 2 -
|
|
382
|
+
set({ k: v.k, x: s.w / 2 - w.x * v.k, y: s.h / 2 - w.y * v.k });
|
|
445
383
|
};
|
|
446
384
|
|
|
447
385
|
const box = miniBox(L);
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
// editor). An admin session adds an office, renames it, chooses its style (Desks / Studio), picks who is in it (whole
|
|
3
3
|
// teams, or one instance at a time; none: everyone) and deletes one — then saves the whole list with the rev it read
|
|
4
4
|
// (PUT /ui/offices; a change made meanwhile is a 409: read again, nothing overwritten). A stored office's layout (seats,
|
|
5
|
-
// paths)
|
|
6
|
-
//
|
|
5
|
+
// paths) and its layout overrides (Edit layout, fleet-office-layout.js) are kept as they are. Skin packs (#2513): the
|
|
6
|
+
// packs the host keeps are styles to choose; an admin uploads one here (its manifest.json and its PNGs, picked together
|
|
7
|
+
// or as a folder — sent at once, checked by the host, which keeps it whole) or deletes one. Never offered to a guest,
|
|
8
|
+
// the public link or a read-only session (the host refuses them too).
|
|
7
9
|
import { html, useMemo, useState } from "/assets/app-html.js";
|
|
8
10
|
import { t, register } from "/assets/app-i18n.js";
|
|
9
|
-
import {
|
|
11
|
+
import { SidePanel } from "/assets/side-panel.js";
|
|
10
12
|
import { toast } from "/assets/ui-toast.js";
|
|
11
13
|
import { nodeText } from "./fleet-org.js";
|
|
14
|
+
import { BUILT_IN_SKINS } from "./fleet-office-skin.js";
|
|
12
15
|
|
|
13
16
|
register("orge", {
|
|
14
17
|
en: {
|
|
@@ -22,6 +25,10 @@ register("orge", {
|
|
|
22
25
|
rateLimited: "Too many saves. Try again in a minute.",
|
|
23
26
|
failed: "The offices were not saved ({0}).", layoutKept: "Its seats and paths are kept.",
|
|
24
27
|
styleUnknown: "{0} (not available here: drawn as Desks)",
|
|
28
|
+
packs: "Skin packs", packsLead: "Styles drawn from an artist's pictures. Pick a pack's manifest.json and all its PNG files together (or its folder).",
|
|
29
|
+
packsNone: "No skin packs yet.", upload: "Upload a skin pack", uploadFolder: "Upload a folder", uploading: "Uploading…", uploaded: "Skin pack “{0}” uploaded.",
|
|
30
|
+
uploadFailed: "The skin pack was not uploaded: {0}", noManifest: "no manifest.json among the files", badManifest: "manifest.json is not JSON",
|
|
31
|
+
removePack: "Delete {0}", removedPack: "Skin pack “{0}” deleted.", removeFailed: "The skin pack was not deleted ({0}).",
|
|
25
32
|
},
|
|
26
33
|
"zh-TW": {
|
|
27
34
|
edit: "編輯辦公室", title: "辦公室", lead: "這個 fleet 的每個人在辦公室檢視中都會看到這些辦公室。沒有選任何成員的辦公室會顯示全部。",
|
|
@@ -34,11 +41,78 @@ register("orge", {
|
|
|
34
41
|
rateLimited: "儲存太頻繁,請一分鐘後再試。",
|
|
35
42
|
failed: "辦公室沒有儲存({0})。", layoutKept: "它的座位與路徑會保留。",
|
|
36
43
|
styleUnknown: "{0}(這裡沒有:以辦公桌顯示)",
|
|
44
|
+
packs: "外觀包", packsLead: "用畫師的圖片畫出的風格。請把外觀包的 manifest.json 和所有 PNG 檔一起選取(或選整個資料夾)。",
|
|
45
|
+
packsNone: "還沒有外觀包。", upload: "上傳外觀包", uploadFolder: "上傳資料夾", uploading: "上傳中…", uploaded: "已上傳外觀包「{0}」。",
|
|
46
|
+
uploadFailed: "外觀包沒有上傳:{0}", noManifest: "檔案中沒有 manifest.json", badManifest: "manifest.json 不是 JSON",
|
|
47
|
+
removePack: "刪除 {0}", removedPack: "已刪除外觀包「{0}」。", removeFailed: "外觀包沒有刪除({0})。",
|
|
37
48
|
},
|
|
38
49
|
});
|
|
39
50
|
const te = (k, ...v) => t(`orge.${k}`, ...v);
|
|
40
51
|
export const MAX_OFFICES = 20;
|
|
41
|
-
const STYLES =
|
|
52
|
+
const STYLES = BUILT_IN_SKINS;
|
|
53
|
+
|
|
54
|
+
/** A file's bytes as base64 (in slices: a large picture never goes through one huge string call). */
|
|
55
|
+
export function base64Of(bytes) {
|
|
56
|
+
let out = "";
|
|
57
|
+
for (let i = 0; i < bytes.length; i += 0x8000) out += String.fromCharCode.apply(null, bytes.subarray(i, i + 0x8000));
|
|
58
|
+
return btoa(out);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* What an upload sends, from the files a person picked: { body } or { error }. A folder's files keep their path inside
|
|
62
|
+
* it (its first part, the folder's own name, dropped), so a manifest naming "sprites/idle.png" finds it.
|
|
63
|
+
*/
|
|
64
|
+
export async function packUpload(files) {
|
|
65
|
+
const named = [];
|
|
66
|
+
for (const f of files) {
|
|
67
|
+
const rel = typeof f.webkitRelativePath === "string" && f.webkitRelativePath ? f.webkitRelativePath.split("/").slice(1).join("/") : f.name;
|
|
68
|
+
named.push({ name: rel || f.name, file: f });
|
|
69
|
+
}
|
|
70
|
+
const man = named.find((x) => x.name === "manifest.json") || named.find((x) => x.name.endsWith("/manifest.json") || x.file.name === "manifest.json");
|
|
71
|
+
if (!man) return { error: te("noManifest") };
|
|
72
|
+
let manifest;
|
|
73
|
+
try { manifest = JSON.parse(await man.file.text()); } catch { return { error: te("badManifest") }; }
|
|
74
|
+
const out = {};
|
|
75
|
+
for (const x of named) {
|
|
76
|
+
if (x === man || !/\.png$/i.test(x.name)) continue;
|
|
77
|
+
out[x.name] = base64Of(new Uint8Array(await x.file.arrayBuffer()));
|
|
78
|
+
}
|
|
79
|
+
return { body: { manifest, files: out } };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function Packs({ packs, store }) {
|
|
83
|
+
const [busy, setBusy] = useState(false);
|
|
84
|
+
const [msg, setMsg] = useState("");
|
|
85
|
+
const send = async (e) => {
|
|
86
|
+
const input = e.target, files = [...(input.files || [])];
|
|
87
|
+
if (!files.length) return;
|
|
88
|
+
setBusy(true); setMsg(te("uploading"));
|
|
89
|
+
try {
|
|
90
|
+
const up = await packUpload(files);
|
|
91
|
+
if (up.error) { setMsg(te("uploadFailed", up.error)); return; }
|
|
92
|
+
const r = await store.uploadSkin(up.body);
|
|
93
|
+
if (r.ok) { setMsg(""); toast(te("uploaded", (r.pack && r.pack.name) || up.body.manifest.id)); }
|
|
94
|
+
else setMsg(te("uploadFailed", r.detail ? `${r.error} — ${r.detail}` : r.error));
|
|
95
|
+
} finally { setBusy(false); try { input.value = ""; } catch { /* a read-only value */ } }
|
|
96
|
+
};
|
|
97
|
+
const remove = async (pk) => {
|
|
98
|
+
setBusy(true); setMsg("");
|
|
99
|
+
try {
|
|
100
|
+
const r = await store.deleteSkin(pk.id);
|
|
101
|
+
if (r.ok) toast(te("removedPack", pk.name)); else setMsg(te("removeFailed", r.error || r.status));
|
|
102
|
+
} finally { setBusy(false); }
|
|
103
|
+
};
|
|
104
|
+
return html`<fieldset class="oe-packs oe-form" disabled=${busy}>
|
|
105
|
+
<legend class="oe-label">${te("packs")}</legend>
|
|
106
|
+
<p class="note">${te("packsLead")}</p>
|
|
107
|
+
${packs.length ? html`<ul class="oe-pack-list">${packs.map((pk) => html`<li key=${pk.id} class="oe-pack" data-pack=${pk.id}>
|
|
108
|
+
<span>${pk.name}</span>${pk.name !== pk.id ? html` <span class="muted mono">${pk.id}</span>` : null}
|
|
109
|
+
<button type="button" class="btn btn-sm btn-danger oe-pack-remove" onClick=${() => remove(pk)} aria-label=${te("removePack", pk.name)}>${te("remove")}</button></li>`)}</ul>`
|
|
110
|
+
: html`<p class="note" id="oePacksNone">${te("packsNone")}</p>`}
|
|
111
|
+
<label class="btn btn-sm oe-upload">${te("upload")}<input type="file" class="sr-only oe-upload-files" multiple accept=".json,.png,application/json,image/png" onChange=${send} /></label>
|
|
112
|
+
<label class="btn btn-sm oe-upload">${te("uploadFolder")}<input type="file" class="sr-only oe-upload-dir" webkitdirectory="" multiple onChange=${send} /></label>
|
|
113
|
+
${msg ? html`<p class="note oe-pack-msg" role="status">${msg}</p>` : null}
|
|
114
|
+
</fieldset>`;
|
|
115
|
+
}
|
|
42
116
|
|
|
43
117
|
/** A new office's id: unique among `taken`, the store's pattern ([A-Za-z0-9_-], never "auto"). */
|
|
44
118
|
export function newOfficeId(taken, rand = Math.random) {
|
|
@@ -49,7 +123,7 @@ export function newOfficeId(taken, rand = Math.random) {
|
|
|
49
123
|
}
|
|
50
124
|
/** What is sent: the office as the host stores it (no empty layout key). */
|
|
51
125
|
export function officeForSave(o) {
|
|
52
|
-
return { id: o.id, name: o.name.trim(), skin: o.skin, members: [...o.members], ...(o.layout ? { layout: o.layout } : {}) };
|
|
126
|
+
return { id: o.id, name: o.name.trim(), skin: o.skin, members: [...o.members], ...(o.layout ? { layout: o.layout } : {}), ...(o.overrides ? { overrides: o.overrides } : {}) };
|
|
53
127
|
}
|
|
54
128
|
|
|
55
129
|
function Members({ office, view, everyone, onChange }) {
|
|
@@ -69,13 +143,16 @@ function Members({ office, view, everyone, onChange }) {
|
|
|
69
143
|
* the snapshot in force (the page keeps a newer one it already shows: #2431 review); `current()` that snapshot now (null:
|
|
70
144
|
* not known), read when the person chooses after a 409 (#2449 review); `onClose`.
|
|
71
145
|
*/
|
|
72
|
-
export function OfficeEditor({ offices, rev, view, store, ask = () => 0, current = () => null, onSaved, onClose }) {
|
|
146
|
+
export function OfficeEditor({ offices, rev, view, store, packs = [], ask = () => 0, current = () => null, onSaved, onClose }) {
|
|
73
147
|
// The draft and the rev it was read at go together (#2424 review): a list the stream re-reads meanwhile never moves
|
|
74
148
|
// the rev under an older draft (a save would then overwrite what it never showed). After a 409 the person chooses
|
|
75
149
|
// (#2431): keep their edits (on the newer rev: Save then replaces what was saved meanwhile, knowingly) or load the
|
|
76
150
|
// newer list — never their draft thrown away unasked.
|
|
77
|
-
|
|
151
|
+
// `saved`: the list the draft is measured against (as read, or the newer one loaded) — the draft holds changes when
|
|
152
|
+
// it differs (#2585: leaving the page beside the docked editor then asks first).
|
|
153
|
+
const [base, setBase] = useState(() => ({ rev, saved: JSON.stringify(offices), draft: offices.map((o) => ({ ...o, members: [...o.members] })) }));
|
|
78
154
|
const draft = base.draft;
|
|
155
|
+
const dirty = JSON.stringify(draft) !== base.saved;
|
|
79
156
|
const setDraft = (next) => setBase((b) => ({ ...b, draft: typeof next === "function" ? next(b.draft) : next }));
|
|
80
157
|
const [open, setOpen] = useState(null); // the office whose members are shown
|
|
81
158
|
const [busy, setBusy] = useState(false);
|
|
@@ -84,14 +161,14 @@ export function OfficeEditor({ offices, rev, view, store, ask = () => 0, current
|
|
|
84
161
|
const copy = (list) => list.map((o) => ({ ...o, members: [...o.members] }));
|
|
85
162
|
// The choice takes the snapshot in force when it is made: the stream may have read a newer one since the 409 (#2449).
|
|
86
163
|
const inForce = () => current() || conflict;
|
|
87
|
-
const keepMine = () => { const now = inForce(); setBase((b) => ({ rev: now.rev, draft: b.draft })); setConflict(null); setMsg(te("keptMine")); };
|
|
88
|
-
const loadTheirs = () => { const now = inForce(); setBase({ rev: now.rev, draft: copy(now.offices) }); setOpen(null); setConflict(null); setMsg(""); };
|
|
164
|
+
const keepMine = () => { const now = inForce(); setBase((b) => ({ rev: now.rev, saved: JSON.stringify(now.offices), draft: b.draft })); setConflict(null); setMsg(te("keptMine")); };
|
|
165
|
+
const loadTheirs = () => { const now = inForce(); setBase({ rev: now.rev, saved: JSON.stringify(now.offices), draft: copy(now.offices) }); setOpen(null); setConflict(null); setMsg(""); };
|
|
89
166
|
const everyone = useMemo(() => { const m = new Map(); for (const n of [...view.top, ...view.teams.flatMap((tm) => tm.nodes), ...view.rest.nodes]) if (!m.has(n.name)) m.set(n.name, n); return [...m.values()]; }, [view]);
|
|
90
167
|
const set = (id, patch) => setDraft((d) => d.map((o) => (o.id === id ? { ...o, ...patch } : o)));
|
|
91
168
|
const add = () => {
|
|
92
169
|
if (draft.length >= MAX_OFFICES) return;
|
|
93
170
|
const id = newOfficeId(new Set(draft.map((o) => o.id)));
|
|
94
|
-
setDraft((d) => [...d, { id, name: te("newName"), skin: "
|
|
171
|
+
setDraft((d) => [...d, { id, name: te("newName"), skin: "cozy", members: [], layout: null }]); // #2631: a new office is cozy
|
|
95
172
|
setOpen(id);
|
|
96
173
|
};
|
|
97
174
|
// Everything is frozen from Save until its answer (and a 409's re-read) is in (#2424 review): no edit made meanwhile
|
|
@@ -118,7 +195,8 @@ export function OfficeEditor({ offices, rev, view, store, ask = () => 0, current
|
|
|
118
195
|
};
|
|
119
196
|
const actions = html`<button type="button" class="btn" onClick=${onClose} disabled=${busy}>${te("cancel")}</button>
|
|
120
197
|
<button type="button" class="btn btn-primary" id="oeSave" onClick=${save} disabled=${busy || !!conflict}>${te("save")}</button>`;
|
|
121
|
-
|
|
198
|
+
// #2585: docked on the right on a wide desk (the page beside it in use); the centred dialog elsewhere.
|
|
199
|
+
return html`<${SidePanel} title=${te("title")} onClose=${onClose} actions=${actions} busy=${busy} dirty=${dirty}>
|
|
122
200
|
<p class="note">${te("lead")}</p>
|
|
123
201
|
<fieldset class="oe-form" disabled=${busy}>
|
|
124
202
|
${draft.length ? null : html`<p class="note" id="oeNone">${te("none")}</p>`}
|
|
@@ -128,8 +206,9 @@ export function OfficeEditor({ offices, rev, view, store, ask = () => 0, current
|
|
|
128
206
|
<input type="text" class="oe-name" maxlength="60" value=${o.name} onInput=${(e) => set(o.id, { name: e.target.value })} /></label>
|
|
129
207
|
<label class="oe-field"><span class="oe-label">${te("styleLabel")}</span>
|
|
130
208
|
<select class="tb-select oe-style" value=${o.skin} onChange=${(e) => set(o.id, { skin: e.target.value })}>
|
|
131
|
-
${STYLES.map((s) => html`<option key=${s} value=${s}>${t(`orgo.style_${s}`)}</option>`)}
|
|
132
|
-
${
|
|
209
|
+
${STYLES.filter((s) => !packs.some((pk) => pk.id === s)).map((s) => html`<option key=${s} value=${s}>${t(`orgo.style_${s}`)}</option>`)}
|
|
210
|
+
${packs.map((pk) => html`<option key=${`pack:${pk.id}`} value=${pk.id}>${pk.name}</option>`)}
|
|
211
|
+
${STYLES.includes(o.skin) || packs.some((pk) => pk.id === o.skin) ? null : html`<option key=${o.skin} value=${o.skin}>${te("styleUnknown", o.skin)}</option>`}</select></label>
|
|
133
212
|
<button type="button" class="btn btn-sm oe-members-btn" aria-expanded=${open === o.id ? "true" : "false"} onClick=${() => setOpen(open === o.id ? null : o.id)}>
|
|
134
213
|
${te("members")}: ${o.members.length ? te("membersN", o.members.length) : te("everyone")}</button>
|
|
135
214
|
<button type="button" class="btn btn-sm btn-danger oe-remove" onClick=${() => { setDraft((d) => d.filter((x) => x.id !== o.id)); if (open === o.id) setOpen(null); }}>${te("remove")}</button>
|
|
@@ -141,9 +220,10 @@ export function OfficeEditor({ offices, rev, view, store, ask = () => 0, current
|
|
|
141
220
|
${draft.length >= MAX_OFFICES ? html`<span class="note">${te("tooMany", MAX_OFFICES)}</span>` : null}
|
|
142
221
|
</fieldset>
|
|
143
222
|
${msg ? html`<p class="note oe-msg" role="status">${msg}</p>` : null}
|
|
223
|
+
${store.uploadSkin ? html`<${Packs} packs=${packs} store=${store} />` : null}
|
|
144
224
|
${conflict ? html`<div class="oe-conflict">
|
|
145
225
|
<button type="button" class="btn btn-sm" id="oeKeepMine" onClick=${keepMine} disabled=${busy}>${te("keepMine")}</button>
|
|
146
226
|
<button type="button" class="btn btn-sm" id="oeLoadTheirs" onClick=${loadTheirs} disabled=${busy}>${te("loadTheirs")}</button>
|
|
147
227
|
</div>` : null}
|
|
148
|
-
</${
|
|
228
|
+
</${SidePanel}>`;
|
|
149
229
|
}
|