@songsid/agend 2.3.1 → 2.3.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/channel/adapters/discord.d.ts +2 -0
- package/dist/channel/adapters/discord.js +33 -3
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/mcp-tools.js +5 -5
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/types.d.ts +11 -0
- package/dist/config-validator.js +40 -3
- package/dist/config-validator.js.map +1 -1
- package/dist/daemon.d.ts +34 -3
- package/dist/daemon.js +227 -46
- package/dist/daemon.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 +9 -0
- 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 +140 -0
- package/dist/fleet-manager.js +414 -29
- 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/general-knowledge/skills/web-appearance/SKILL.canvas-worker-off.md +4 -4
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +7 -7
- package/dist/general-knowledge/skills/web-dashboard/SKILL.canvas-worker-off.md +113 -55
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +114 -56
- 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 +4 -1
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +1 -0
- package/dist/instance-lifecycle.js +16 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +38 -10
- package/dist/locale.js.map +1 -1
- 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/outbound-schemas.d.ts +2 -0
- package/dist/outbound-schemas.js +2 -0
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +9 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/settings-api.d.ts +26 -0
- package/dist/settings-api.js +107 -1
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +37 -3
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.js +5 -2
- package/dist/settings-effect.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/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 +18 -1
- package/dist/ui/backend-signin.js +5 -2
- 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 +2 -2
- 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 +80 -5
- package/dist/ui/fleet-office-layout.js +197 -0
- package/dist/ui/fleet-office-model.js +6 -3
- package/dist/ui/fleet-office-overview.js +167 -0
- package/dist/ui/fleet-office-pack.d.ts +39 -0
- package/dist/ui/fleet-office-pack.js +240 -29
- package/dist/ui/fleet-office-skin.js +140 -29
- package/dist/ui/fleet-office-store.js +84 -5
- package/dist/ui/fleet-office-view.js +154 -0
- package/dist/ui/fleet-office-zones.js +95 -33
- package/dist/ui/fleet-office.js +779 -140
- package/dist/ui/fleet-usage.js +7 -6
- package/dist/ui/panel-chat.js +1 -1
- package/dist/ui/panel-details.js +2 -2
- package/dist/ui/panel-fleet.js +11 -77
- package/dist/ui/panel-log.js +2 -2
- package/dist/ui/panel-settings.js +578 -163
- 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 +68 -22
- package/dist/ui/settings-draft.js +51 -0
- package/dist/ui/settings-guests.js +244 -78
- package/dist/ui/settings-learn.js +2 -2
- package/dist/ui/settings-model.js +2 -0
- package/dist/ui/settings-registry.js +142 -0
- package/dist/ui/settings-strings.js +102 -44
- package/dist/ui/settings-web-authority.js +34 -23
- package/dist/ui/shared/app-i18n.js +14 -0
- 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 +59 -4
- package/dist/ui/shared/app-stream.js +2 -1
- package/dist/ui/shared/app.css +254 -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/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/web-api.d.ts +8 -2
- package/dist/web-api.js +160 -5
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.js +7 -1
- package/dist/web-auth.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-skins.d.ts +108 -0
- package/dist/web-office-skins.js +298 -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 +37 -7
- package/dist/web-office-store.js.map +1 -1
- package/dist/web-settings-patch.d.ts +6 -0
- package/dist/web-settings-patch.js +61 -4
- 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 +263 -0
- package/dist/working-recovery.js.map +1 -0
- package/dist/working-state-journal.d.ts +3 -1
- package/dist/working-state-journal.js +15 -2
- package/dist/working-state-journal.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/fleet-office.js
CHANGED
|
@@ -5,8 +5,14 @@
|
|
|
5
5
|
// - Two layouts, by skin. Desks (the built-in "pixel" skin, the default): each team is a room, each member a desk with a
|
|
6
6
|
// name tag; General and the instances in no team share the lobby; a grid that wraps at the stage's width
|
|
7
7
|
// (fleet-office-model.js autoLayout). Zones (a skin whose pack maps states to areas — the built-in "studio"): a
|
|
8
|
-
// 1280×720 scene
|
|
9
|
-
//
|
|
8
|
+
// 1280×720 scene; each instance takes a seat in the area for its state and walks there along the pack's waypoints
|
|
9
|
+
// when its state changes (fleet-office-zones.js).
|
|
10
|
+
// - #2540: the canvas fills the Fleet panel (no frame: the whole width of the Fleet area, down to the window's foot);
|
|
11
|
+
// the scene is panned and zoomed as the org chart's canvas is (fleet-canvas-view.js: drag, wheel, pinch, + / − / Fit
|
|
12
|
+
// and the `+ - 0` keys, an overview), Fit filling the panel (contain; Fill: cover), + and − in pixel levels, the zoom
|
|
13
|
+
// shown as a percentage, around it a matte (fleet-office-view.js). The view (zoom and centre) and the fit mode are
|
|
14
|
+
// kept per device per office and style. Everything on the scene — hit-testing, tooltips, Edit layout's handles —
|
|
15
|
+
// goes through the same view transform.
|
|
10
16
|
// - Speech bubbles: now and then a short line for its state (typed out; at once with reduced motion) — the page's own
|
|
11
17
|
// lines or the skin's, never anything an agent said. Furniture can react: an item with `activeWhen` animates while
|
|
12
18
|
// anyone shown is in that state.
|
|
@@ -20,24 +26,55 @@
|
|
|
20
26
|
// - Who is shown: an office switcher (the whole fleet, or an office from the host), and for the whole fleet a team (or
|
|
21
27
|
// the lobby) and pinned people — kept per browser (fleet-office-store.js).
|
|
22
28
|
// - One requestAnimationFrame loop, drawing only when a frame changes; it stops while the tab is hidden and when the view
|
|
23
|
-
// goes. Reduced motion: still poses, nothing in the air. Colours are the dashboard's
|
|
24
|
-
//
|
|
29
|
+
// goes. Reduced motion: still poses, nothing in the air (zoom and pan are never animated). Colours are the dashboard's
|
|
30
|
+
// tokens (dark and light).
|
|
31
|
+
// - Drawing is the skin's (fleet-office-skin.js); a skin pack an admin uploaded (fleet-office-pack.js, #2513) replaces
|
|
32
|
+
// any part — an office names it as its style; one this page cannot load is drawn as Desks, and says so.
|
|
33
|
+
// - Crowds (#2513): an area with more people than seats packs the rest into a tighter grid, then counts who is left
|
|
34
|
+
// ("+N", in its corner, never over its name); there idle and asleep people say nothing, at most a few speak (calls
|
|
35
|
+
// first, then work), no bubble covers a name tag, and the tags show on hover or focus only. "Hide paused and stopped"
|
|
36
|
+
// (per browser) leaves the sleepers out.
|
|
37
|
+
// - Edit layout (an admin, a stored office on a zones skin): fleet-office-layout.js, saved as the office's overrides.
|
|
38
|
+
// An editing session (#2513 review) is bound to the office it opened on, that office's style (the pack's id and sha)
|
|
39
|
+
// and the list and rev read then: a re-read of the offices meanwhile (the stream) changes the view, never the session,
|
|
40
|
+
// so Save sends that rev and a change made meanwhile is a 409 (the session then takes the list read again, and Save
|
|
41
|
+
// again is the person's decision). While it is open the office picker and Edit offices wait; if the office goes or its
|
|
42
|
+
// style changes underneath it, the editor says so and only Cancel is left.
|
|
43
|
+
// - Fullscreen (#2540): a button by the zoom controls, or `f`; Esc leaves. The Fullscreen API on the view's container
|
|
44
|
+
// (webkit's prefix too); where a page cannot take an element fullscreen (an iPhone) or the browser refuses, "immersive":
|
|
45
|
+
// the container covers the window (CSS). Either way only the stage shows, with its floating controls (zoom, Fit, the
|
|
46
|
+
// overview, a compact office switcher, Exit); the stage's resize handling re-fits it. Nothing about it is kept.
|
|
47
|
+
// - All offices (#2554; offered with two or more stored offices): every stored office as a tile on one canvas, each
|
|
48
|
+
// drawn as its own view would be — its style (a pack loaded once and shared), its members, seats, poses, bubbles,
|
|
49
|
+
// walking and in-office traffic — scaled into its tile (fleet-office-overview.js: the tiles, the lobby tile of whoever
|
|
50
|
+
// is in no office, hit-testing, culling, the flights between tiles). The same canvas, controls and loop; tiles off
|
|
51
|
+
// screen are not drawn. A tile's label (a button, a readable size whatever the zoom) or a double-click on it opens
|
|
52
|
+
// that office; a person opens their chat. A tile too small to read (under TAG_MIN_K) shows name tags on hover only;
|
|
53
|
+
// bubbles are drawn after every tile (never cut at a tile's edge). Fit keeps the tiles clear of the controls
|
|
54
|
+
// (FIT_PAD). Edit offices and Edit layout wait for a single office.
|
|
25
55
|
import { html, useEffect, useLayoutEffect, useMemo, useRef, useState } from "/assets/app-html.js";
|
|
26
56
|
import { appStore } from "/assets/app-store.js";
|
|
27
57
|
import { t, lang, register } from "/assets/app-i18n.js";
|
|
28
58
|
import { identityOf } from "/assets/identity-color.js";
|
|
59
|
+
import { Icon } from "/assets/ui-icons.js";
|
|
29
60
|
import { nodeText } from "./fleet-org.js";
|
|
30
61
|
import { hits, needle } from "./fleet-canvas-layout.js";
|
|
31
62
|
import { AUTO_ID, LOBBY, autoLayout, backingScale, coatOf, createFlights, customLayout, deskAt, desksOf, filterOk, lampOf, layoutOk, lightOf, membersOf,
|
|
32
63
|
officePose, officeRooms, signOf, workOn } from "./fleet-office-model.js";
|
|
33
|
-
import { CHAR_DEPTH, DEFAULT_PAL, bubbleBox, modeOf, skinFor } from "./fleet-office-skin.js";
|
|
34
|
-
import { CALLING, activeFurniture, bubbleAt, createWalkers, linesFor, personAt, placeBubbles, zonesLayout } from "./fleet-office-zones.js";
|
|
64
|
+
import { BUILT_IN_SKINS, CHAR_DEPTH, DEFAULT_PAL, bubbleBox, loadPackSkin, modeOf, skinFor, tagBox } from "./fleet-office-skin.js";
|
|
65
|
+
import { CALLING, activeFurniture, bubbleAt, bubbleRank, createWalkers, linesFor, personAt, placeBubbles, thinBubbles, zonesLayout } from "./fleet-office-zones.js";
|
|
35
66
|
import { createOfficeStore } from "./fleet-office-store.js";
|
|
36
|
-
import { OfficeEditor } from "./fleet-office-editor.js";
|
|
67
|
+
import { OfficeEditor, officeForSave } from "./fleet-office-editor.js";
|
|
68
|
+
import { LayoutEditor, handlesOf } from "./fleet-office-layout.js";
|
|
69
|
+
import { applyOverrides } from "./fleet-office-pack.js";
|
|
70
|
+
import { ALL_ID, LOBBY_TILE, OV, createCrossFlights, cropToRooms, fromTile, inTile, labelAt, lobbyNodes, overviewOk, tileAt, tileBox, tileLayout, visibleTiles } from "./fleet-office-overview.js";
|
|
71
|
+
import { centreOn, gestureState, gestures, miniPoint, toScreen, toWorld, wheelFactor, zoomKey, zoomTo } from "./fleet-canvas-view.js";
|
|
72
|
+
import { OK_MAX, OK_MIN, clampPan, desksK, edgeMatte, edgeStrips, fitScene, layerScale, miniBox, miniFrame, openingView, pinchOffice, savedOf, stepK, viewFromSaved,
|
|
73
|
+
zoomLabel, zoomOffice } from "./fleet-office-view.js";
|
|
37
74
|
|
|
38
75
|
register("orgo", {
|
|
39
76
|
en: {
|
|
40
|
-
label: "Office: each team is a room and each instance a desk; General and the instances in no team are in the lobby.",
|
|
77
|
+
label: "Office: each team is a room and each instance a desk; General and the instances in no team are in the lobby. Drag to pan; the wheel, a pinch, + and − zoom, 0 fits, F is fullscreen.",
|
|
41
78
|
office: "Office", allOffice: "Whole fleet", show: "Show", allTeams: "All teams", lobby: "Lobby (General, no team)", lobbyRoom: "Lobby",
|
|
42
79
|
people: "People", peopleN: "People ({0})", findPerson: "Find a person", everyone: "Show everyone", nobody: "No one here matches this filter.",
|
|
43
80
|
unseated: "{0} without a seat", skinUnknown: "Its style “{0}” is not available here: drawn as Desks.", closed: "Closed", desks: "Desks", tapAgain: "Tap again to open the chat",
|
|
@@ -46,9 +83,14 @@ register("orgo", {
|
|
|
46
83
|
b_working: "On it.|Typing…|Almost there|In the zone|One more test", b_idle: "Tea time|Ready when you are|Stretching|Anything for me?",
|
|
47
84
|
b_paused: "Zzz…|Back later", b_stopped: "Off duty|Zzz…", b_needs: "Need you!|A question for you|Over here!",
|
|
48
85
|
b_crashed: "Ouch, crashed|Help!", b_stuck: "Hmm, stuck?|Still thinking…",
|
|
86
|
+
hideAsleep: "Hide paused and stopped", layoutIgnored: "Its saved layout does not fit this style: drawn as the style's own.",
|
|
87
|
+
fit: "Fit the office", overview: "Overview: click to move there", fullscreen: "Fullscreen", exitFullscreen: "Exit fullscreen",
|
|
88
|
+
fill: "Fill", fillTitle: "Fill the panel (the scene's overflow is cropped; drag to see it)", zoomLevel: "Zoom {0}",
|
|
89
|
+
allOffices: "All offices", labelAll: "All offices: each office is a tile, drawn in its own style. Drag to pan; the wheel, a pinch, + and − zoom, 0 fits, F is fullscreen. Double-click a tile to open that office.",
|
|
90
|
+
tileLabel: "{0} ({1})", openOffice: "Open the office {0}", lobbyTile: "Lobby tile (in no office)", lobbyEveryone: "Everyone is in an office", overviewNoEdit: "Pick one office to edit offices or a layout",
|
|
49
91
|
},
|
|
50
92
|
"zh-TW": {
|
|
51
|
-
label: "辦公室:每個 team 是一間房間,每個 instance 一張桌子;General 和未加入 team 的 instance
|
|
93
|
+
label: "辦公室:每個 team 是一間房間,每個 instance 一張桌子;General 和未加入 team 的 instance 在大廳。拖曳平移;滾輪、雙指、+ 和 − 縮放,0 顯示整個場景,F 切換全螢幕。",
|
|
52
94
|
office: "辦公室", allOffice: "整個 fleet", show: "顯示", allTeams: "所有 team", lobby: "大廳(General、未加入 team)", lobbyRoom: "大廳",
|
|
53
95
|
people: "成員", peopleN: "成員({0})", findPerson: "尋找成員", everyone: "顯示全部", nobody: "沒有符合這個篩選的成員。",
|
|
54
96
|
unseated: "{0} 位沒有座位", skinUnknown: "這裡沒有它的風格「{0}」:以辦公桌顯示。", closed: "休息中", desks: "桌子", tapAgain: "再點一下開啟聊天",
|
|
@@ -57,6 +99,11 @@ register("orgo", {
|
|
|
57
99
|
b_working: "處理中|打字中…|快好了|專心中|再測一次", b_idle: "喝茶中|隨時可以開工|伸個懶腰|有事找我嗎?",
|
|
58
100
|
b_paused: "Zzz…|晚點回來", b_stopped: "下班了|Zzz…", b_needs: "需要你!|有個問題|在這裡!",
|
|
59
101
|
b_crashed: "糟糕,當掉了|救命!", b_stuck: "嗯,卡住了?|還在想…",
|
|
102
|
+
hideAsleep: "隱藏暫停與停止的成員", layoutIgnored: "它儲存的配置不適用這個風格:以風格本身的配置顯示。",
|
|
103
|
+
fit: "顯示整個辦公室", overview: "總覽:點一下移到那裡", fullscreen: "全螢幕", exitFullscreen: "結束全螢幕",
|
|
104
|
+
fill: "填滿", fillTitle: "填滿整個面板(超出的部分會被裁切,拖曳即可看到)", zoomLevel: "縮放 {0}",
|
|
105
|
+
allOffices: "所有辦公室", labelAll: "所有辦公室:每間辦公室是一格,以它自己的風格顯示。拖曳平移;滾輪、雙指、+ 和 − 縮放,0 顯示全部,F 切換全螢幕。雙擊一格即可開啟那間辦公室。",
|
|
106
|
+
tileLabel: "{0}({1})", openOffice: "開啟辦公室「{0}」", lobbyTile: "大廳格(不在任何辦公室)", lobbyEveryone: "每個成員都已在某間辦公室", overviewNoEdit: "請先選一間辦公室,再編輯辦公室或配置",
|
|
60
107
|
},
|
|
61
108
|
});
|
|
62
109
|
const to = (k, ...v) => t(`orgo.${k}`, ...v);
|
|
@@ -67,10 +114,40 @@ const CAPTION_OF_STATE = { starting: "capStarting", queued: "capQueued" };
|
|
|
67
114
|
export const caption = (pose, state) => to(CAPTION_OF_STATE[state] || CAPTION[pose] || "capIdle");
|
|
68
115
|
|
|
69
116
|
const reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
117
|
+
/** The device's ratio (CSS px → device px), kept sane. */
|
|
118
|
+
const deviceRatio = () => Math.max(0.5, Math.min(4, Number(globalThis.devicePixelRatio) || 1));
|
|
119
|
+
/** The stage's size before it is measured (a test's page has none). */
|
|
120
|
+
const SIZE0 = { w: 960, h: 600 };
|
|
121
|
+
/** #2554: All offices' Fit keeps this many CSS px clear round the tiles (the zoom controls' column and a margin). */
|
|
122
|
+
const FIT_PAD = 60;
|
|
123
|
+
/** #2554: in All offices a tile's name tags show (always) from this many CSS px a unit up; below it on hover only. */
|
|
124
|
+
export const TAG_MIN_K = 0.75;
|
|
125
|
+
const PAN_KEYS = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] };
|
|
126
|
+
/** Typing: no single-key shortcut (the `f` of fullscreen) there. */
|
|
127
|
+
const typing = (el) => !!el && (el.tagName === "INPUT" || el.tagName === "SELECT" || el.tagName === "TEXTAREA" || el.isContentEditable === true);
|
|
128
|
+
/** The element the page has fullscreen (standard, else webkit's), or null. */
|
|
129
|
+
const fullscreenEl = () => { const d = globalThis.document; return (d && (d.fullscreenElement || d.webkitFullscreenElement)) || null; };
|
|
130
|
+
/** A pack's background, sampled once for its matte (fleet-office-view.js edgeMatte): picture → #rrggbb or null. */
|
|
131
|
+
const MATTES = new WeakMap();
|
|
132
|
+
function sampledMatte(img) {
|
|
133
|
+
if (!img || typeof img !== "object") return null;
|
|
134
|
+
if (MATTES.has(img)) return MATTES.get(img);
|
|
135
|
+
let m = null;
|
|
136
|
+
try {
|
|
137
|
+
const c = document.createElement("canvas");
|
|
138
|
+
c.width = 64; c.height = 36;
|
|
139
|
+
const g = c.getContext && c.getContext("2d");
|
|
140
|
+
if (g) { g.imageSmoothingEnabled = false; g.drawImage(img, 0, 0, 64, 36); const st = edgeStrips(c); m = st ? edgeMatte(st) : null; }
|
|
141
|
+
} catch { m = null; }
|
|
142
|
+
MATTES.set(img, m);
|
|
143
|
+
return m;
|
|
144
|
+
}
|
|
70
145
|
const now = () => (typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now());
|
|
71
146
|
/** How often the picture can change when nothing is in the air (the poses loop at 4 fps; a bubble types faster). */
|
|
72
147
|
const FPS = 12;
|
|
73
|
-
const STYLES =
|
|
148
|
+
const STYLES = BUILT_IN_SKINS;
|
|
149
|
+
/** Paused and stopped: left out when "Hide paused and stopped" is on. */
|
|
150
|
+
const ASLEEP = new Set(["paused", "stopped"]);
|
|
74
151
|
const BUBBLE_STATES = ["working", "idle", "paused", "stopped", "needs", "crashed", "stuck"];
|
|
75
152
|
/** The page's own bubble lines, by state, in its language (short, never message content). */
|
|
76
153
|
export const bubbleDefaults = () => Object.fromEntries(BUBBLE_STATES.map((s) => [s, to(`b_${s}`).split("|")]));
|
|
@@ -95,6 +172,149 @@ function teamOptions(view) {
|
|
|
95
172
|
...view.teams.map((tm, i) => ({ value: `t${i}`, team: tm.name, label: tm.name }))];
|
|
96
173
|
}
|
|
97
174
|
|
|
175
|
+
// ── A scene: one office's layout, looks and skin, drawn by itself (the single view) or as a tile (All offices, #2554) ──
|
|
176
|
+
|
|
177
|
+
/** What each desk shows: the pose, the light, the coat; dimmed when the Find box matches someone else. */
|
|
178
|
+
function looksOf(L, work, q, mode, zones) {
|
|
179
|
+
return new Map(L.rooms.flatMap((r) => r.desks).map((d) => {
|
|
180
|
+
const n = d.node;
|
|
181
|
+
if (!n) return [d.key, { name: "", label: "", state: "missing", pose: "away", light: null, lamp: false, sign: null, coat: "", work: 0, dim: !!q, match: false, free: zones }];
|
|
182
|
+
const match = !!q && hits(n, q);
|
|
183
|
+
return [d.key, { name: n.name, label: nodeText(n).primary, state: n.state, pose: officePose(n.state), light: lightOf(n.state), lamp: lampOf(n.state),
|
|
184
|
+
sign: zones ? null : signOf(n.state), coat: coatOf(n.i, n.i ? identityOf(n.i) : null, mode), work: work.get(n.name) || 0, dim: !!q && !match, match, free: zones }];
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
/** A stored office's own layout on a zones style (its overrides); `ignored`: they do not fit this style. */
|
|
188
|
+
function withOverrides(baseSkin, zones, office) {
|
|
189
|
+
const ov = zones && office ? office.overrides : null;
|
|
190
|
+
if (!ov || ov.pack !== baseSkin.id) return { skin: baseSkin, ignored: false };
|
|
191
|
+
const a = applyOverrides(baseSkin.pack, ov);
|
|
192
|
+
return a.ok ? { skin: { ...baseSkin, pack: a.pack }, ignored: false } : { skin: baseSkin, ignored: true };
|
|
193
|
+
}
|
|
194
|
+
/** A stored office's scene (or the lobby tile's): seats in its style's areas, its own seats, or one room wrapping at `deskW`. */
|
|
195
|
+
function officeScene(office, nodes, skin, zones, deskW, prevSeats) {
|
|
196
|
+
if (zones) return zonesLayout(skin.pack, nodes, prevSeats);
|
|
197
|
+
const lay = office.layout || layoutOk(skin.layout);
|
|
198
|
+
return lay ? customLayout({ ...office, layout: lay }, nodes) : autoLayout([{ key: office.id, name: office.name, lobby: !!office.lobby, nodes }], { width: deskW });
|
|
199
|
+
}
|
|
200
|
+
/** What drawPart needs of a scene; its layers are painted on first draw (and again at another resolution). */
|
|
201
|
+
function partOf(L, looks, skin, zones, walkers, flights) {
|
|
202
|
+
const all = L.rooms.flatMap((r) => r.desks);
|
|
203
|
+
const shown = new Set([...looks.values()].map((l) => l.state));
|
|
204
|
+
return { L, looks, skin, zones, walkers, flights, all, desks: all.filter((d) => d.node), layers: null,
|
|
205
|
+
active: zones ? activeFurniture(skin.pack, shown) : new Set(), lines: bubbleDefaults(), lang: lang() };
|
|
206
|
+
}
|
|
207
|
+
/** The back and front layers: pictures of the scene at `ls` layer px per logical unit (`tagsOff`: no name tags but the Find box's matches). */
|
|
208
|
+
function paintLayers(p, env, ls, tagsOff = false) {
|
|
209
|
+
const { L, skin, zones, looks, all } = p;
|
|
210
|
+
const lw = Math.max(1, Math.ceil(L.width * ls)), lh = Math.max(1, Math.ceil(L.height * ls));
|
|
211
|
+
const layer = (fn) => {
|
|
212
|
+
const c = document.createElement("canvas");
|
|
213
|
+
c.width = lw; c.height = lh;
|
|
214
|
+
const g = c.getContext && c.getContext("2d");
|
|
215
|
+
if (!g) return null;
|
|
216
|
+
g.setTransform(ls, 0, 0, ls, 0, 0);
|
|
217
|
+
g.imageSmoothingEnabled = false;
|
|
218
|
+
fn(g);
|
|
219
|
+
return c;
|
|
220
|
+
};
|
|
221
|
+
const back = layer((g) => {
|
|
222
|
+
g.fillStyle = env.pal.bg; g.fillRect(0, 0, L.width, L.height);
|
|
223
|
+
if (zones) {
|
|
224
|
+
skin.drawBackground(g, L, env);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
skin.drawFloor(g, L, env);
|
|
228
|
+
for (const r of L.rooms) skin.drawRoom(g, r, env);
|
|
229
|
+
for (const d of all) skin.drawDeskBack(g, d, looks.get(d.key), env);
|
|
230
|
+
});
|
|
231
|
+
const front = zones ? null : layer((g) => {
|
|
232
|
+
for (const d of all) { const lk = looks.get(d.key); skin.drawDeskFront(g, d, tagsOff && lk && !lk.match ? { ...lk, notag: true } : lk, env); }
|
|
233
|
+
});
|
|
234
|
+
return { ls, tagsOff, back, front };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* One frame of a scene at `ms` (0: still), a logical unit `a` bitmap px, its origin at (ox, oy); `hot`: the desk key
|
|
238
|
+
* hovered (its name tag shows even in a crowd); `tagsOff` (#2554: a tile too small to read them): the name tags show
|
|
239
|
+
* only for the one hovered and the Find box's matches. Whether anything in it is moving (in the air, or someone walking).
|
|
240
|
+
*/
|
|
241
|
+
function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false, defer = null) {
|
|
242
|
+
const sk = p.skin;
|
|
243
|
+
const ls = layerScale(a, p.L.width, p.L.height);
|
|
244
|
+
if (!p.layers || p.layers.ls !== ls || p.layers.tagsOff !== tagsOff) p.layers = paintLayers(p, env, ls, tagsOff);
|
|
245
|
+
const T = () => ctx.setTransform(a, 0, 0, a, ox, oy);
|
|
246
|
+
const blit = (c) => { if (!c) return; ctx.setTransform(a / ls, 0, 0, a / ls, ox, oy); ctx.drawImage(c, 0, 0); T(); };
|
|
247
|
+
blit(p.layers.back);
|
|
248
|
+
T();
|
|
249
|
+
const speakers = [], tags = [];
|
|
250
|
+
const up = still ? [] : p.flights.frame(ms, p.L);
|
|
251
|
+
let walking = false;
|
|
252
|
+
if (p.zones) {
|
|
253
|
+
// Furniture under the people; the people (nearest last) with the furniture whose depth is "y" among them, by base
|
|
254
|
+
// y (a tie: the item first, the person in front); furniture over them; things in the air; the pack's foreground
|
|
255
|
+
// (door frames, pillars, table fronts); then what must stay readable: crowd counts and name tags (bubbles below).
|
|
256
|
+
const t = ms > 0 ? ms : now();
|
|
257
|
+
const people = p.desks.map((d) => {
|
|
258
|
+
const at = p.walkers.at(d.node.name, t) || { ...d.seat, walking: false };
|
|
259
|
+
if (at.walking) walking = true;
|
|
260
|
+
return { d, at, look: p.looks.get(d.key) };
|
|
261
|
+
}).sort((x, y) => x.at.y - y.at.y);
|
|
262
|
+
const furniture = sk.pack.furniture;
|
|
263
|
+
const band = [...furniture.filter((f) => f.depth === "y").map((f) => ({ y: f.y, k: 0, f })), ...people.map((q) => ({ y: q.at.y, k: 1, p: q }))]
|
|
264
|
+
.sort((x, y) => x.y - y.y || x.k - y.k);
|
|
265
|
+
for (const f of furniture) if (f.depth !== "y" && f.depth < CHAR_DEPTH) sk.drawFurniture(ctx, f, p.active.has(f.id), ms, env);
|
|
266
|
+
for (const { f, p: q } of band) {
|
|
267
|
+
if (f) { sk.drawFurniture(ctx, f, p.active.has(f.id), ms, env); continue; }
|
|
268
|
+
const box = { ...q.d, x: q.at.x - 44, y: q.at.y - 53, w: 88, h: 53, seat: { x: q.at.x, y: q.at.y } };
|
|
269
|
+
sk.drawCharacter(ctx, box, q.at.walking ? { ...q.look, pose: "walk", heading: q.at.heading } : q.look, ms, env);
|
|
270
|
+
if (!q.at.walking) speakers.push({ look: q.look, x: q.at.x + 10, y: q.at.y - 50, area: q.d.area });
|
|
271
|
+
}
|
|
272
|
+
for (const f of furniture) if (f.depth !== "y" && f.depth >= CHAR_DEPTH) sk.drawFurniture(ctx, f, p.active.has(f.id), ms, env);
|
|
273
|
+
for (const it of up) sk.drawProp(ctx, it, ms, env);
|
|
274
|
+
if (sk.drawForeground) sk.drawForeground(ctx, p.L, env);
|
|
275
|
+
// Who found no spot in an area: a count in its corner (never over its name).
|
|
276
|
+
for (const [ar, n] of p.L.crowd || []) if (p.L.areas[ar] && sk.drawCrowd) sk.drawCrowd(ctx, p.L.areas[ar], n, env);
|
|
277
|
+
// In an area over capacity the name tags show on hover or focus only (#2513: a crowd's tags covered each other).
|
|
278
|
+
const over = p.L.over || new Set();
|
|
279
|
+
for (const q of people) {
|
|
280
|
+
if ((tagsOff || over.has(q.d.area)) && q.d.key !== hot && !q.look.match) continue;
|
|
281
|
+
sk.drawTag(ctx, q.at.x, q.at.y, q.look, env);
|
|
282
|
+
tags.push(tagBox(ctx, q.at.x, q.at.y, q.look.label));
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
for (const d of p.desks) { const look = p.looks.get(d.key); sk.drawCharacter(ctx, d, look, ms, env); speakers.push({ look, x: d.x + 58, y: d.y + 12 }); }
|
|
286
|
+
blit(p.layers.front);
|
|
287
|
+
// Tags left out of the layer: the hovered desk's front again, with its tag.
|
|
288
|
+
const hd = tagsOff && hot ? p.desks.find((d) => d.key === hot) : null;
|
|
289
|
+
if (hd) sk.drawDeskFront(ctx, hd, p.looks.get(hd.key), env);
|
|
290
|
+
for (const it of up) sk.drawProp(ctx, it, ms, env);
|
|
291
|
+
}
|
|
292
|
+
// Speech bubbles: a short line for the state, now and then (typed out; whole at once when still), placed so no two
|
|
293
|
+
// overlap (placeBubbles; #2431).
|
|
294
|
+
const bubbles = [];
|
|
295
|
+
for (const sp of speakers) {
|
|
296
|
+
if (sp.look.dim || sp.look.pose === "away") continue;
|
|
297
|
+
const b = bubbleAt(sp.look.name, sp.look.state, ms, linesFor(sp.look.state, p.lang, sk.pack, p.lines));
|
|
298
|
+
if (b) bubbles.push({ key: sp.look.name, area: sp.area, state: sp.look.state, calling: CALLING.has(sp.look.state), rank: bubbleRank(sp.look.state), shown: b.shown,
|
|
299
|
+
box: bubbleBox(ctx, sp.x, sp.y, b.text), tail: { x: sp.x, y: sp.y }, sp, b });
|
|
300
|
+
}
|
|
301
|
+
// A crowded area speaks less (thinBubbles: calls, then work, a few at most); no bubble covers a name tag. `defer`
|
|
302
|
+
// (All offices): drawn after every tile, unclipped, so a bubble at a tile's edge is whole.
|
|
303
|
+
const placed = placeBubbles(thinBubbles(bubbles, p.zones ? p.L.over : null), 22, tags);
|
|
304
|
+
const say = () => { T(); for (const { sp, b, dy } of placed) sk.drawBubble(ctx, sp.x, sp.y, [...b.text].slice(0, b.shown).join(""), env, -dy); };
|
|
305
|
+
if (defer) defer.push(say); else say();
|
|
306
|
+
return walking || up.length > 0 || p.flights.size() > 0;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The person at (x, y) in a scene's units, as it draws them: on zones where they walk, in the box the skin draws them
|
|
310
|
+
* in (an uploaded character's strip, anchor and size: #2513 review), nearest first; on desks, the desk.
|
|
311
|
+
*/
|
|
312
|
+
function hitPart(p, x, y, t) {
|
|
313
|
+
if (!p.zones) return deskAt(p.L, x, y);
|
|
314
|
+
return personAt(p.all, x, y, (d) => p.walkers.at(d.node.name, t),
|
|
315
|
+
(d, at) => (p.skin.charBox && p.looks.get(d.key) ? p.skin.charBox(p.looks.get(d.key), at) : null));
|
|
316
|
+
}
|
|
317
|
+
|
|
98
318
|
function People({ nodes, pinned, onChange }) {
|
|
99
319
|
const [open, setOpen] = useState(false);
|
|
100
320
|
const [find, setFind] = useState("");
|
|
@@ -135,15 +355,32 @@ export function Office({ view, traffic, q = "", lease, onOpen }) {
|
|
|
135
355
|
const [choice, setChoice] = useState(() => store.choice());
|
|
136
356
|
const [filter, setFilter] = useState(() => store.filter());
|
|
137
357
|
const [style, setStyle] = useState(() => store.skin());
|
|
138
|
-
const [
|
|
139
|
-
const [
|
|
358
|
+
const [hideAsleep, setHideAsleep] = useState(() => store.hideAsleep());
|
|
359
|
+
const [lobbyOn, setLobbyOn] = useState(() => store.lobbyTile()); // #2554: All offices' lobby tile
|
|
360
|
+
const [packs, setPacks] = useState([]); // the skin packs the host keeps: [{ id, name, sha }]
|
|
361
|
+
const [packSkins, setPackSkins] = useState(() => new Map()); // id@sha → a loaded skin, or null (not a pack)
|
|
362
|
+
// Edit layout's session while it is open: { id, officeId, skin, pack (the style's identity), base (the pack as kept),
|
|
363
|
+
// start, draft, rev, list (the offices and rev read when it opened — what Save sends) }; null when closed.
|
|
364
|
+
const [layout, setLayout] = useState(null);
|
|
365
|
+
const layoutRef = useRef(null), layoutSeq = useRef(0);
|
|
366
|
+
layoutRef.current = layout;
|
|
367
|
+
const [width, setWidth] = useState(SIZE0.w); // the stage's size (CSS px; the canvas fills it)
|
|
368
|
+
const [stageH, setStageH] = useState(0); // (0: not known yet)
|
|
369
|
+
const [dpr, setDpr] = useState(deviceRatio);
|
|
140
370
|
const [themeRev, setThemeRev] = useState(0);
|
|
141
371
|
const [pal, setPal] = useState(DEFAULT_PAL); // the tokens in force (read once the stage is there)
|
|
142
372
|
const [tip, setTip] = useState(null); // the desk key the tooltip is for
|
|
143
373
|
const stageRef = useRef(null), canvasRef = useRef(null), tipRef = useRef(null), lastType = useRef("mouse");
|
|
374
|
+
// Fullscreen: null, "native" (the Fullscreen API) or "immersive" (the CSS cover); per visit, never kept.
|
|
375
|
+
const ooRef = useRef(null), [fs, setFs] = useState(null), fsRef = useRef(null), fsAsked = useRef(false), fsTarget = useRef(null);
|
|
376
|
+
fsRef.current = fs;
|
|
144
377
|
const flights = useMemo(() => createFlights(), []);
|
|
145
378
|
const walkers = useMemo(() => createWalkers(), []);
|
|
146
379
|
const seatsRef = useRef(new Map()); // the zones layout's last seats: kept where they can be
|
|
380
|
+
// #2554: All offices' tiles keep their own: seats (by tile and style), walkers and flights (by tile); and the items
|
|
381
|
+
// flying between tiles.
|
|
382
|
+
const tileSeats = useRef(new Map()), tileWalkers = useRef(new Map()), tileFlights = useRef(new Map());
|
|
383
|
+
const cross = useMemo(() => createCrossFlights(), []);
|
|
147
384
|
const still = useMemo(reducedMotion, []);
|
|
148
385
|
|
|
149
386
|
// The host's offices: on opening, and again whenever the stream says they changed. Answers can arrive out of order
|
|
@@ -169,6 +406,15 @@ export function Office({ view, traffic, q = "", lease, onOpen }) {
|
|
|
169
406
|
const off = sub ? lease.hold(sub("offices", () => { void read(); })) : null;
|
|
170
407
|
return () => { if (off) off(); };
|
|
171
408
|
}, [lease, store]);
|
|
409
|
+
// The skin packs: on opening, and again whenever the stream says one was uploaded or deleted.
|
|
410
|
+
useEffect(() => {
|
|
411
|
+
if (!lease) return undefined;
|
|
412
|
+
const read = async () => { const d = await store.skins(); if (lease.current() && d) setPacks(d.packs); };
|
|
413
|
+
void read();
|
|
414
|
+
const sub = appStore.get().streamOn;
|
|
415
|
+
const off = sub ? lease.hold(sub("office_skins", () => { void read(); })) : null;
|
|
416
|
+
return () => { if (off) off(); };
|
|
417
|
+
}, [lease, store]);
|
|
172
418
|
// Whether this page may edit the offices: an admin session (the host asks again on every save), never a guest page or
|
|
173
419
|
// the public link (whose sessions the host refuses outright).
|
|
174
420
|
useEffect(() => {
|
|
@@ -186,6 +432,7 @@ export function Office({ view, traffic, q = "", lease, onOpen }) {
|
|
|
186
432
|
const w = el && el.clientWidth, h = el && el.clientHeight;
|
|
187
433
|
if (w > 0) setWidth((cur) => (Math.abs(cur - w) >= 1 ? Math.floor(w) : cur));
|
|
188
434
|
if (h > 0) setStageH((cur) => (Math.abs(cur - h) >= 1 ? Math.floor(h) : cur));
|
|
435
|
+
setDpr(deviceRatio()); // the browser's zoom changes it
|
|
189
436
|
};
|
|
190
437
|
measure();
|
|
191
438
|
const ro = typeof ResizeObserver === "function" ? new ResizeObserver(measure) : null;
|
|
@@ -204,126 +451,376 @@ export function Office({ view, traffic, q = "", lease, onOpen }) {
|
|
|
204
451
|
setPal((cur) => (JSON.stringify(cur) === JSON.stringify(next) ? cur : next));
|
|
205
452
|
}, [themeRev]);
|
|
206
453
|
const mode = modeOf(pal);
|
|
454
|
+
const size = { w: width, h: stageH > 0 ? stageH : SIZE0.h };
|
|
455
|
+
// The canvas bitmap's px per CSS px: the device's, unless the bitmap would be too big to paint (backingScale). Zoom
|
|
456
|
+
// snaps to whole numbers of these (fleet-office-view.js), so a pixel-level view maps a logical unit onto whole pixels.
|
|
457
|
+
const ratio = backingScale(size.w, size.h, dpr);
|
|
207
458
|
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
459
|
+
// #2554: All offices — chosen, and at least two offices stored (else the whole fleet, as an office gone is).
|
|
460
|
+
const overview = choice === ALL_ID && overviewOk(stored);
|
|
461
|
+
const custom = choice !== AUTO_ID && !overview ? stored.find((o) => o.id === choice) || null : null;
|
|
462
|
+
// The style: a built-in one, or an uploaded pack once it is loaded (until then, and when it is not one, Desks).
|
|
463
|
+
const wanted = custom ? custom.skin : style;
|
|
464
|
+
const packOf = (id) => (STYLES.includes(id) ? null : packs.find((pk) => pk.id === id) || null);
|
|
465
|
+
const packInfo = packOf(wanted);
|
|
466
|
+
const packKey = packInfo ? `${packInfo.id}@${packInfo.sha}` : null;
|
|
467
|
+
// The packs to load: this office's style; in All offices every tile's (each loaded once, shared by the tiles using it).
|
|
468
|
+
const needed = [...new Map((overview ? [...stored.map((o) => o.skin), ...(lobbyOn ? [style] : [])] : [wanted]).map(packOf).filter(Boolean)
|
|
469
|
+
.map((pk) => [`${pk.id}@${pk.sha}`, pk])).entries()];
|
|
470
|
+
const neededKey = needed.map(([k]) => k).join(",");
|
|
471
|
+
useEffect(() => {
|
|
472
|
+
const want = needed.filter(([k]) => !packSkins.has(k));
|
|
473
|
+
if (!want.length) return undefined;
|
|
474
|
+
let live = true;
|
|
475
|
+
const get = lease ? (path, o) => lease.fetch(path, o) : undefined;
|
|
476
|
+
for (const [k, pk] of want) loadPackSkin(pk.id, pk.sha, get ? { fetch: get } : {}).then((sk) => { if (live) setPackSkins((m) => new Map(m).set(k, sk)); });
|
|
477
|
+
return () => { live = false; };
|
|
478
|
+
}, [neededKey]);
|
|
479
|
+
const loading = !!packInfo && !packSkins.has(packKey);
|
|
480
|
+
const baseSkin = packInfo ? packSkins.get(packKey) || skinFor("pixel") : skinFor(STYLES.includes(wanted) ? wanted : custom ? wanted : "pixel");
|
|
481
|
+
const zones = !!(baseSkin.pack && baseSkin.pack.stateZones);
|
|
482
|
+
/** The style's identity: a pack's id and sha (a pack replaced is another), or the built-in skin's id. */
|
|
483
|
+
const styleKey = packKey || baseSkin.id;
|
|
484
|
+
// An open session no longer on its office and style (the office went, or its style changed meanwhile): only Cancel.
|
|
485
|
+
const layoutStale = !!layout && (!custom || custom.id !== layout.officeId || custom.skin !== layout.skin || styleKey !== layout.pack || !zones || loading);
|
|
486
|
+
// A stored office's own layout on a zones style (its overrides; while Edit layout is open, the draft).
|
|
487
|
+
const placed = useMemo(() => {
|
|
488
|
+
if (zones && layout && !layoutStale) return { skin: { ...baseSkin, pack: layout.draft }, ignored: false };
|
|
489
|
+
return withOverrides(baseSkin, zones, custom);
|
|
490
|
+
}, [baseSkin, zones, custom, layout, layoutStale]);
|
|
491
|
+
const skin = placed.skin;
|
|
492
|
+
const keep = (n) => !(hideAsleep && ASLEEP.has(n.state));
|
|
493
|
+
const single = useMemo(() => {
|
|
494
|
+
if (overview) return { rooms: [], width: 1, height: 1 }; // All offices: the tiles below
|
|
495
|
+
const all = custom ? membersOf(custom, view) : [...new Map(officeRooms(view, filter).flatMap((r) => r.nodes).map((n) => [n.name, n])).values()];
|
|
496
|
+
const nodes = all.filter(keep);
|
|
213
497
|
if (zones) { const z = zonesLayout(skin.pack, nodes, seatsRef.current); seatsRef.current = z.seats; return z; }
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
498
|
+
// The desks wrap at the stage's width at the scale they open on (desksK: a pixel level near one CSS px a unit).
|
|
499
|
+
const deskW = Math.max(240, Math.floor(width / desksK(ratio)));
|
|
500
|
+
if (!custom) return autoLayout(officeRooms(view, filter).map((r) => (hideAsleep ? { ...r, nodes: r.nodes.filter(keep) } : r)), { width: deskW });
|
|
501
|
+
return officeScene(custom, nodes, skin, false, deskW);
|
|
502
|
+
}, [overview, view, filter, custom, width, ratio, skin, hideAsleep]);
|
|
503
|
+
// ── #2554: All offices' tiles — each stored office (then the lobby: whoever is in no office) laid out as its own view
|
|
504
|
+
// lays it out, in its own style (desks wrap at a cell's width), with its own seats, walkers and flights ──
|
|
505
|
+
const lobbyAll = useMemo(() => (overview ? lobbyNodes(stored, view) : []), [overview, stored, view]);
|
|
506
|
+
const lobbyList = lobbyOn ? lobbyAll : [];
|
|
507
|
+
const tiles = useMemo(() => {
|
|
508
|
+
if (!overview) return [];
|
|
509
|
+
const mine = (m, k, make) => { if (!m.current.has(k)) m.current.set(k, make()); return m.current.get(k); };
|
|
510
|
+
const specs = stored.map((o) => ({ key: o.id, office: o, name: o.name, lobby: false, wanted: o.skin, nodes: membersOf(o, view) }));
|
|
511
|
+
if (lobbyList.length) specs.push({ key: LOBBY_TILE, office: { id: LOBBY_TILE, name: null, lobby: true, layout: null }, name: to("lobbyRoom"), lobby: true, wanted: style, nodes: lobbyList });
|
|
512
|
+
return specs.map((sp) => {
|
|
513
|
+
const info = packOf(sp.wanted), pk = info ? `${info.id}@${info.sha}` : null;
|
|
514
|
+
const base = info ? packSkins.get(pk) || skinFor("pixel") : skinFor(sp.wanted);
|
|
515
|
+
const z = !!(base.pack && base.pack.stateZones);
|
|
516
|
+
const sk = withOverrides(base, z, sp.lobby ? null : sp.office).skin;
|
|
517
|
+
const seatKey = `${sp.key}@${pk || base.id}`;
|
|
518
|
+
// A desks office is as large as its rooms (cropped: no margins, no corridors outside them).
|
|
519
|
+
const TL0 = officeScene(sp.office, sp.nodes.filter(keep), sk, z, OV.CELL_W, tileSeats.current.get(seatKey)), TL = z ? TL0 : cropToRooms(TL0);
|
|
520
|
+
if (z) tileSeats.current.set(seatKey, TL0.seats);
|
|
521
|
+
return { key: sp.key, name: sp.name, lobby: sp.lobby, count: sp.nodes.length, skin: sk, zones: z, L: TL, prefix: `${sp.key}\u0001`,
|
|
522
|
+
walkers: mine(tileWalkers, sp.key, createWalkers), flights: mine(tileFlights, sp.key, createFlights) };
|
|
523
|
+
});
|
|
524
|
+
}, [overview, stored, view, packs, packSkins, hideAsleep, lobbyOn, lobbyAll, style]);
|
|
525
|
+
const arranged = useMemo(() => tileLayout(tiles.map((tl) => ({ key: tl.key, w: tl.L.width, h: tl.L.height })), size), [tiles, size.w, size.h]);
|
|
526
|
+
const tileLooks = useMemo(() => { const work = workOn(traffic); return tiles.map((tl) => looksOf(tl.L, work, q, mode, tl.zones)); }, [tiles, traffic, q, mode, themeRev]);
|
|
527
|
+
// The scene the view pans and zooms: the office's, or the overview of every tile.
|
|
528
|
+
const L = useMemo(() => (overview ? { mode: "overview", rooms: [], width: arranged.width, height: arranged.height } : single), [overview, single, arranged]);
|
|
529
|
+
const looks = useMemo(() => looksOf(L, workOn(traffic), q, mode, zones), [L, traffic, q, mode, themeRev]);
|
|
230
530
|
useEffect(() => { flights.sync(traffic || [], now(), still); }, [traffic]);
|
|
231
531
|
// Zones: everyone's seat is where they walk to.
|
|
232
532
|
useEffect(() => {
|
|
233
|
-
if (!zones) return;
|
|
533
|
+
if (!zones || overview) return;
|
|
234
534
|
walkers.sync(new Map(desksOf(L).map((d) => [d.node.name, d.seat])), now(), L, still);
|
|
235
535
|
loop.current?.wake();
|
|
236
536
|
}, [L]);
|
|
537
|
+
// …and in each tile on a zones style; the traffic within a tile is its own, between tiles the overview's.
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
for (const tl of tiles) if (tl.zones) tl.walkers.sync(new Map(desksOf(tl.L).map((d) => [d.node.name, d.seat])), now(), tl.L, still);
|
|
540
|
+
loop.current?.wake();
|
|
541
|
+
}, [tiles]);
|
|
542
|
+
useEffect(() => {
|
|
543
|
+
if (!overview) return;
|
|
544
|
+
for (const tl of tiles) tl.flights.sync(traffic || [], now(), still);
|
|
545
|
+
cross.sync(traffic || [], now(), still);
|
|
546
|
+
loop.current?.wake();
|
|
547
|
+
}, [traffic, tiles]);
|
|
548
|
+
|
|
549
|
+
// ── The view (#2540): { k, x, y } as the org chart canvas's (fleet-canvas-view.js) — logical units → the stage's CSS
|
|
550
|
+
// px. Set without a render (a ref): the canvas redraws, the overview, the tooltip and Edit layout's overlay follow ──
|
|
551
|
+
const vp = useRef(null), raw = useRef(1); // raw: the wheel's and a pinch's zoom (before the range)
|
|
552
|
+
// touched: a person moved the view (it is kept); fitted: the view is a fit (a resize fits it again, to the new size).
|
|
553
|
+
const touched = useRef(false), fitted = useRef(false), drag = useRef(gestureState());
|
|
554
|
+
const miniViewRef = useRef(null), miniRef = useRef(null), overlayEl = useRef(null), tipDeskRef = useRef(null), pctRef = useRef(null);
|
|
555
|
+
const labelEls = useRef(new Map()); // #2554: the tiles' labels (tile key → element)
|
|
556
|
+
// What a view is kept for: the office and its style (All offices: its own key).
|
|
557
|
+
const officeKey = overview ? `${ALL_ID}@tiles` : `${custom ? custom.id : AUTO_ID}@${baseSkin.id}`;
|
|
558
|
+
const keyRef = useRef(officeKey), saveTimer = useRef(0);
|
|
559
|
+
// The fit mode (Fit: contain; Fill: cover), kept per office and style like the view.
|
|
560
|
+
const [fitRev, setFitRev] = useState(0);
|
|
561
|
+
const fitMode = useMemo(() => store.fitMode(officeKey), [store, officeKey, fitRev]);
|
|
562
|
+
const view0 = () => vp.current || { k: 1, x: 0, y: 0 };
|
|
563
|
+
const flushSave = () => {
|
|
564
|
+
if (saveTimer.current) { clearTimeout(saveTimer.current); saveTimer.current = 0; }
|
|
565
|
+
if (touched.current && vp.current) store.saveView(keyRef.current, savedOf(vp.current, sizeRef.current, fitted.current));
|
|
566
|
+
};
|
|
567
|
+
const sizeRef = useRef(size);
|
|
568
|
+
sizeRef.current = size;
|
|
569
|
+
/** Edit layout's overlay over the scene (placed through the CSSOM, never a style attribute: #1300). */
|
|
570
|
+
const placeOverlay = (el) => {
|
|
571
|
+
overlayEl.current = el || null;
|
|
572
|
+
if (!el || !el.style) return;
|
|
573
|
+
const v = view0();
|
|
574
|
+
el.style.setProperty("left", `${v.x}px`); el.style.setProperty("top", `${v.y}px`);
|
|
575
|
+
el.style.setProperty("width", `${L.width * v.k}px`); el.style.setProperty("height", `${L.height * v.k}px`);
|
|
576
|
+
};
|
|
577
|
+
/** The tooltip: what the canvas's card says, above the desk (below it at the top edge), wherever the view puts it. */
|
|
578
|
+
const placeTip = () => {
|
|
579
|
+
const el = tipRef.current, d = tipDeskRef.current;
|
|
580
|
+
if (!el || !d || !el.style) return;
|
|
581
|
+
const v = view0(), p = toScreen(v, d.x, d.y), x = Math.max(4, Math.min(p.x, size.w - 244)), above = p.y > 90;
|
|
582
|
+
el.style.setProperty("transform", above ? `translate(${x}px, ${p.y + 6}px) translateY(-100%)` : `translate(${x}px, ${p.y + d.h * v.k}px)`);
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Put the view on everything that shows it beside the canvas: the overview's frame (the part of the scene in view;
|
|
586
|
+
* the whole view on its data-k/x/y), the zoom's percentage, the overlay, the tooltip.
|
|
587
|
+
*/
|
|
588
|
+
const mark = () => {
|
|
589
|
+
const v = view0(), m = miniViewRef.current;
|
|
590
|
+
if (m) {
|
|
591
|
+
const f = miniFrame(v, size, L.width, L.height);
|
|
592
|
+
for (const [a, val] of [["x", f.x], ["y", f.y], ["width", f.width], ["height", f.height], ["data-k", v.k], ["data-x", v.x], ["data-y", v.y]]) m.setAttribute(a, String(val));
|
|
593
|
+
}
|
|
594
|
+
const mb = miniRef.current;
|
|
595
|
+
if (mb && mb.style) { // the overview: inside the stage, scaled to it
|
|
596
|
+
const b = miniBox(size, L.width, L.height);
|
|
597
|
+
for (const [a, val] of [["left", b.x], ["top", b.y], ["width", b.w], ["height", b.h]]) mb.style.setProperty(a, `${val}px`);
|
|
598
|
+
}
|
|
599
|
+
const pc = pctRef.current;
|
|
600
|
+
if (pc) { const lb = zoomLabel(v.k); if (pc.textContent !== lb) pc.textContent = lb; pc.setAttribute("aria-label", to("zoomLevel", lb)); }
|
|
601
|
+
if (overlayEl.current) placeOverlay(overlayEl.current);
|
|
602
|
+
// All offices: each tile's label just above it, as wide as the room up to the next label in its row (or the stage's
|
|
603
|
+
// edge); hidden while its tile is off screen (nothing past the stage's edge for a focus to scroll it to: the
|
|
604
|
+
// controls stay where they are).
|
|
605
|
+
const shownTiles = overview ? new Set(visibleTiles(arranged, v, size).map((tt) => tt.key)) : null;
|
|
606
|
+
for (const [i, tt] of (overview ? arranged.tiles : []).entries()) {
|
|
607
|
+
const el = labelEls.current.get(tt.key);
|
|
608
|
+
if (!el || !el.style) continue;
|
|
609
|
+
const lp = toScreen(v, tt.x, tt.y), next = arranged.tiles[i + 1];
|
|
610
|
+
const room = next && next.label.y === tt.label.y ? (next.x - tt.x) * v.k - 6 : size.w - lp.x - 8;
|
|
611
|
+
el.style.setProperty("left", `${lp.x}px`); el.style.setProperty("top", `${lp.y}px`);
|
|
612
|
+
el.style.setProperty("max-width", `${Math.max(40, room)}px`);
|
|
613
|
+
el.style.setProperty("visibility", shownTiles.has(tt.key) ? "visible" : "hidden");
|
|
614
|
+
}
|
|
615
|
+
const st = stageRef.current;
|
|
616
|
+
if (st && (st.scrollLeft || st.scrollTop)) { st.scrollLeft = 0; st.scrollTop = 0; }
|
|
617
|
+
placeTip();
|
|
618
|
+
};
|
|
619
|
+
/** …and redraw. */
|
|
620
|
+
const apply = () => {
|
|
621
|
+
mark();
|
|
622
|
+
if (scene.current) { scene.current.dirty = true; if (still) { if (!globalThis.document?.hidden) draw(0); } else loop.current?.wake(); }
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
625
|
+
* A new view (kept on the scene: clampPan); `user`: a person moved it (it is kept, a moment later); `fit`: it is a
|
|
626
|
+
* fit (a resize fits it again).
|
|
627
|
+
*/
|
|
628
|
+
const setView = (v, user = true, fit = false) => {
|
|
629
|
+
vp.current = clampPan(v, L.width, L.height, size);
|
|
630
|
+
fitted.current = fit;
|
|
631
|
+
apply();
|
|
632
|
+
if (!user) return;
|
|
633
|
+
touched.current = true;
|
|
634
|
+
if (saveTimer.current) clearTimeout(saveTimer.current);
|
|
635
|
+
saveTimer.current = setTimeout(flushSave, 400);
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
638
|
+
* The scene fitted (`mode`: contain or cover). All offices' contain keeps FIT_PAD px clear all round, so no tile sits
|
|
639
|
+
* under the zoom controls at the side.
|
|
640
|
+
*/
|
|
641
|
+
const fitL = (mode) => fitScene(L.width, L.height, size, mode, overview && mode !== "cover" ? FIT_PAD : 0);
|
|
642
|
+
/** The view an office opens on: its kept one (a kept fit: fitted to this size), else its opening; and whether a fit. */
|
|
643
|
+
const openView = () => {
|
|
644
|
+
const kept = store.view(officeKey);
|
|
645
|
+
if (kept && kept.fit) return { v: fitL(fitMode), fit: true };
|
|
646
|
+
if (kept) return { v: viewFromSaved(kept, size), fit: false };
|
|
647
|
+
const fitted0 = zones || overview; // All offices opens whole, as a zones scene
|
|
648
|
+
return { v: overview ? fitL(fitMode) : openingView(L.width, L.height, size, ratio, fitted0, fitMode), fit: fitted0 };
|
|
649
|
+
};
|
|
650
|
+
// An office (or style) opened: its kept view, else its opening (zones fitted; desks from the top left). A resize fits
|
|
651
|
+
// a fitted view again (and opens an untouched one again); a view a person moved keeps the same point in the middle.
|
|
652
|
+
// Either way it is then kept on the scene (clampPan): a kept view from a bigger panel cannot leave it off-screen.
|
|
653
|
+
const opened = useRef(null), sized = useRef(null);
|
|
654
|
+
useLayoutEffect(() => {
|
|
655
|
+
const was = sized.current;
|
|
656
|
+
sized.current = { w: size.w, h: size.h, ratio };
|
|
657
|
+
const reopen = () => { const o = openView(); vp.current = o.v; fitted.current = o.fit; };
|
|
658
|
+
if (opened.current !== officeKey) {
|
|
659
|
+
if (opened.current !== null) flushSave();
|
|
660
|
+
opened.current = officeKey; keyRef.current = officeKey; touched.current = false;
|
|
661
|
+
reopen();
|
|
662
|
+
} else if (was && (was.w !== size.w || was.h !== size.h || was.ratio !== ratio)) {
|
|
663
|
+
if (fitted.current) vp.current = fitL(fitMode);
|
|
664
|
+
else if (!touched.current) reopen();
|
|
665
|
+
else { const v = vp.current, cx = (was.w / 2 - v.x) / v.k, cy = (was.h / 2 - v.y) / v.k; vp.current = { k: v.k, x: size.w / 2 - cx * v.k, y: size.h / 2 - cy * v.k }; }
|
|
666
|
+
} else if (fitted.current) vp.current = fitL(fitMode); // the scene's size changed
|
|
667
|
+
vp.current = clampPan(view0(), L.width, L.height, size);
|
|
668
|
+
raw.current = vp.current.k;
|
|
669
|
+
}, [officeKey, size.w, size.h, ratio, L.width, L.height]);
|
|
670
|
+
useEffect(() => () => flushSave(), []);
|
|
671
|
+
/** Fit (the button, `0`): the office's mode — `mode` when it was just switched. */
|
|
672
|
+
const fit = (mode = fitMode) => { const v = fitL(mode); raw.current = v.k; setView(v, true, true); };
|
|
673
|
+
/** Fill on or off: kept for this office, and fitted at once. */
|
|
674
|
+
const toggleFill = () => {
|
|
675
|
+
const next = fitMode === "cover" ? "contain" : "cover";
|
|
676
|
+
store.saveFitMode(officeKey, next); setFitRev((n) => n + 1);
|
|
677
|
+
fit(next);
|
|
678
|
+
};
|
|
679
|
+
/** + / −: the next pixel level about the stage's middle. */
|
|
680
|
+
const zoomStep = (dir) => { const v = view0(), k = stepK(v.k, dir, ratio); raw.current = k; setView(zoomTo(v, k, size.w / 2, size.h / 2)); };
|
|
681
|
+
/** Bring a box (logical units) into view, unchanged when it already is. */
|
|
682
|
+
const show = (b) => {
|
|
683
|
+
const v = view0(), p = toScreen(v, b.x, b.y);
|
|
684
|
+
if (p.x >= 8 && p.y >= 8 && p.x + b.w * v.k <= size.w - 8 && p.y + b.h * v.k <= size.h - 8) return;
|
|
685
|
+
setView(centreOn(v, size, b.x + b.w / 2, b.y + b.h / 2));
|
|
686
|
+
};
|
|
237
687
|
|
|
238
|
-
// ──
|
|
239
|
-
//
|
|
688
|
+
// ── Fullscreen: the API on the container where the page may (its promise, or webkit's events, say how it went), else
|
|
689
|
+
// immersive; leaving undoes whichever it was ──
|
|
690
|
+
const enterFs = () => {
|
|
691
|
+
const el = ooRef.current, d = globalThis.document;
|
|
692
|
+
if (!el || fsRef.current) return;
|
|
693
|
+
const req = el.requestFullscreen || el.webkitRequestFullscreen;
|
|
694
|
+
const enabled = d ? (d.fullscreenEnabled ?? d.webkitFullscreenEnabled) : false;
|
|
695
|
+
if (typeof req !== "function" || enabled === false) { setFs("immersive"); return; }
|
|
696
|
+
fsAsked.current = true; fsTarget.current = el;
|
|
697
|
+
let r;
|
|
698
|
+
try { r = req.call(el); } catch { fsAsked.current = false; setFs("immersive"); return; }
|
|
699
|
+
if (r && typeof r.then === "function") {
|
|
700
|
+
r.then(() => { if (ooRef.current === el && fullscreenEl() === el) setFs("native"); },
|
|
701
|
+
() => { if (fsAsked.current && ooRef.current === el) { fsAsked.current = false; setFs("immersive"); } });
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
const exitFs = () => {
|
|
705
|
+
fsAsked.current = false;
|
|
706
|
+
const el = ooRef.current, d = globalThis.document;
|
|
707
|
+
if (el && d && fullscreenEl() === el) {
|
|
708
|
+
const ex = d.exitFullscreen || d.webkitExitFullscreen;
|
|
709
|
+
try { const r = typeof ex === "function" ? ex.call(d) : null; if (r && typeof r.catch === "function") r.catch(() => {}); } catch { /* already out */ }
|
|
710
|
+
}
|
|
711
|
+
setFs(null);
|
|
712
|
+
};
|
|
713
|
+
const toggleFs = () => { if (fsRef.current) exitFs(); else enterFs(); };
|
|
714
|
+
const editingRef = useRef(false);
|
|
715
|
+
editingRef.current = editing;
|
|
716
|
+
// The browser's own way out (its Esc, its UI) and its refusals; `f` and Esc; leaving the page leaves fullscreen.
|
|
717
|
+
useEffect(() => {
|
|
718
|
+
const d = globalThis.document;
|
|
719
|
+
if (!d || typeof d.addEventListener !== "function") return undefined;
|
|
720
|
+
const change = () => {
|
|
721
|
+
const on = !!ooRef.current && fullscreenEl() === ooRef.current;
|
|
722
|
+
if (on) fsAsked.current = false;
|
|
723
|
+
setFs((cur) => (on ? "native" : cur === "native" ? null : cur));
|
|
724
|
+
};
|
|
725
|
+
const refused = () => { if (!fsAsked.current) return; fsAsked.current = false; setFs("immersive"); };
|
|
726
|
+
const key = (e) => {
|
|
727
|
+
if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
728
|
+
if (e.key === "Escape") { if (fsRef.current === "immersive") { e.preventDefault(); exitFs(); } return; }
|
|
729
|
+
if (e.key !== "f" && e.key !== "F") return;
|
|
730
|
+
const el = ooRef.current, tg = e.target;
|
|
731
|
+
// Only here: from inside the view, or with nothing focused (never while typing, nor over Edit offices' dialog).
|
|
732
|
+
if (!el || typing(tg) || editingRef.current || !(tg === d.body || tg === d.documentElement || tg === d || (tg && el.contains(tg)))) return;
|
|
733
|
+
e.preventDefault();
|
|
734
|
+
toggleFs();
|
|
735
|
+
};
|
|
736
|
+
const evs = [["fullscreenchange", change], ["webkitfullscreenchange", change], ["fullscreenerror", refused], ["webkitfullscreenerror", refused], ["keydown", key]];
|
|
737
|
+
for (const [n, fn] of evs) d.addEventListener(n, fn);
|
|
738
|
+
return () => {
|
|
739
|
+
for (const [n, fn] of evs) d.removeEventListener(n, fn);
|
|
740
|
+
fsAsked.current = false;
|
|
741
|
+
const el = fullscreenEl(), ex = d.exitFullscreen || d.webkitExitFullscreen;
|
|
742
|
+
if (el && (el === ooRef.current || el === fsTarget.current) && typeof ex === "function") {
|
|
743
|
+
try { const r = ex.call(d); if (r && typeof r.catch === "function") r.catch(() => {}); } catch { /* already out */ }
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
}, []);
|
|
747
|
+
// Immersive: the dashboard's band the view sits in is lifted over the header, the tabs and the nav (app.css).
|
|
748
|
+
useEffect(() => {
|
|
749
|
+
const root = fs === "immersive" ? globalThis.document?.documentElement : null;
|
|
750
|
+
if (!root || !root.classList) return undefined;
|
|
751
|
+
root.classList.add("oo-immersive");
|
|
752
|
+
return () => root.classList.remove("oo-immersive");
|
|
753
|
+
}, [fs]);
|
|
754
|
+
/** A desk opens its chat: out of fullscreen first (the chat is beside the view, or instead of it). */
|
|
755
|
+
const open = (name) => { if (fsRef.current) exitFs(); onOpen(name); };
|
|
756
|
+
|
|
757
|
+
// ── Drawing: the back and front layers are pictures of the scene at the view's resolution (remade when the office
|
|
758
|
+
// or the zoom changes, never on a pan); each frame draws the matte, the layers, the people and the items in the air ──
|
|
240
759
|
const scene = useRef(null);
|
|
241
760
|
const loop = useRef(null);
|
|
761
|
+
// The matte around the scene: the pack's own, else its background's edge (sampled once), else the skin's (tokens);
|
|
762
|
+
// All offices: the dashboard's background (each tile is its own scene).
|
|
763
|
+
const matte = overview ? pal.bg : (skin.pack && skin.pack.matte) || sampledMatte(skin.backdrop) || (skin.matte ? skin.matte({ pal, mode }) : pal.bg);
|
|
764
|
+
// …and behind the canvas too (the stage), so no page grey shows while it is (re)sized.
|
|
765
|
+
useLayoutEffect(() => { const el = stageRef.current; if (el && el.style) el.style.setProperty("background-color", matte); }, [matte]);
|
|
242
766
|
useLayoutEffect(() => {
|
|
243
767
|
const cv = canvasRef.current;
|
|
244
768
|
const ctx = cv && typeof cv.getContext === "function" ? cv.getContext("2d") : null;
|
|
245
769
|
if (!ctx) { scene.current = null; return; }
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const dpr = backingScale(W, H, Math.max(1, Math.min(3, globalThis.devicePixelRatio || 1)));
|
|
249
|
-
const BW = Math.max(1, Math.floor(W * dpr)), BH = Math.max(1, Math.floor(H * dpr));
|
|
770
|
+
// The canvas is the stage: its bitmap at `ratio` px per CSS px (never larger than a browser paints).
|
|
771
|
+
const BW = Math.max(1, Math.floor(size.w * ratio)), BH = Math.max(1, Math.floor(size.h * ratio));
|
|
250
772
|
if (cv.width !== BW || cv.height !== BH) { cv.width = BW; cv.height = BH; }
|
|
251
|
-
cv.style.setProperty("width", `${
|
|
252
|
-
cv.style.setProperty("height", `${
|
|
773
|
+
cv.style.setProperty("width", `${BW / ratio}px`);
|
|
774
|
+
cv.style.setProperty("height", `${BH / ratio}px`);
|
|
253
775
|
const env = { pal, mode, labels: { lobby: to("lobbyRoom"), closed: to("closed"), areas: { desks: to("area_desks"), lounge: to("area_lounge"), alert: to("area_alert"), nap: to("area_nap") } } };
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
paint(g);
|
|
263
|
-
return c;
|
|
264
|
-
};
|
|
265
|
-
const all = L.rooms.flatMap((r) => r.desks);
|
|
266
|
-
const back = layer((g) => {
|
|
267
|
-
g.fillStyle = env.pal.bg; g.fillRect(0, 0, L.width, L.height);
|
|
268
|
-
if (zones) { skin.drawBackground(g, L, env); return; }
|
|
269
|
-
skin.drawFloor(g, L, env);
|
|
270
|
-
for (const r of L.rooms) skin.drawRoom(g, r, env);
|
|
271
|
-
for (const d of all) skin.drawDeskBack(g, d, looks.get(d.key), env);
|
|
272
|
-
});
|
|
273
|
-
const front = zones ? null : layer((g) => { for (const d of all) skin.drawDeskFront(g, d, looks.get(d.key), env); });
|
|
274
|
-
const shown = new Set([...looks.values()].map((l) => l.state));
|
|
275
|
-
scene.current = { ctx, scale, BW, BH, back, front, env, desks: all.filter((d) => d.node), looks, L, skin, zones, dirty: true,
|
|
276
|
-
active: zones ? activeFurniture(skin.pack, shown) : new Set(), lines: bubbleDefaults(), lang: lang() };
|
|
776
|
+
const base = { ctx, ratio, BW, BH, matte, env, dirty: true };
|
|
777
|
+
if (overview) {
|
|
778
|
+
// Each tile a scene of its own, where the overview puts it (arranged.tiles, in the same order).
|
|
779
|
+
const parts = tiles.map((tl, i) => ({ ...partOf(tl.L, tileLooks[i], tl.skin, tl.zones, tl.walkers, tl.flights), key: tl.key, prefix: tl.prefix, tile: arranged.tiles[i] }));
|
|
780
|
+
scene.current = { ...base, overview: true, parts, lay: arranged };
|
|
781
|
+
} else {
|
|
782
|
+
scene.current = { ...base, overview: false, part: partOf(L, looks, skin, zones, walkers, flights) };
|
|
783
|
+
}
|
|
277
784
|
if (still) draw(0); else loop.current?.wake();
|
|
278
|
-
}, [L, looks, skin, pal,
|
|
785
|
+
}, [L, looks, skin, pal, size.w, size.h, ratio, matte, overview, tiles, tileLooks, arranged]);
|
|
279
786
|
|
|
280
787
|
/** One frame at `ms` (0: still); whether anything is moving (in the air, or someone walking). */
|
|
281
788
|
function draw(ms) {
|
|
282
789
|
const s = scene.current;
|
|
283
790
|
if (!s) return false;
|
|
284
|
-
const { ctx,
|
|
791
|
+
const { ctx, BW, BH, env } = s;
|
|
792
|
+
// The view in bitmap px: a logical unit is `a` px (a whole number at a pixel level), the origin on a whole px.
|
|
793
|
+
const v = view0(), a = v.k * s.ratio, ox = Math.round(v.x * s.ratio), oy = Math.round(v.y * s.ratio);
|
|
285
794
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
286
795
|
ctx.clearRect(0, 0, BW, BH);
|
|
287
|
-
|
|
288
|
-
ctx.setTransform(scale, 0, 0, scale, 0, 0);
|
|
796
|
+
ctx.fillStyle = s.matte; ctx.fillRect(0, 0, BW, BH);
|
|
289
797
|
ctx.imageSmoothingEnabled = false;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const furniture = s.skin.pack.furniture;
|
|
301
|
-
for (const f of furniture) if (f.depth < CHAR_DEPTH) sk.drawFurniture(ctx, f, s.active.has(f.id), ms, env);
|
|
302
|
-
for (const p of people) {
|
|
303
|
-
const box = { ...p.d, x: p.at.x - 44, y: p.at.y - 53, w: 88, h: 53, seat: { x: p.at.x, y: p.at.y } };
|
|
304
|
-
sk.drawCharacter(ctx, box, p.at.walking ? { ...p.look, pose: "walk" } : p.look, ms, env);
|
|
305
|
-
if (!p.at.walking) speakers.push({ look: p.look, x: p.at.x + 10, y: p.at.y - 50 });
|
|
306
|
-
}
|
|
307
|
-
for (const f of furniture) if (f.depth >= CHAR_DEPTH) sk.drawFurniture(ctx, f, s.active.has(f.id), ms, env);
|
|
308
|
-
for (const p of people) sk.drawTag(ctx, p.at.x, p.at.y, p.look, env);
|
|
309
|
-
} else {
|
|
310
|
-
for (const d of s.desks) { const look = s.looks.get(d.key); sk.drawCharacter(ctx, d, look, ms, env); speakers.push({ look, x: d.x + 58, y: d.y + 12 }); }
|
|
798
|
+
if (!s.overview) return drawPart(ctx, s.part, a, ox, oy, ms, still, tipNow.current, env);
|
|
799
|
+
// All offices: each tile on screen drawn as its own view, scaled into it and clipped to it; one off screen is not
|
|
800
|
+
// drawn (its flights still land). Then a frame round each tile, and the items flying between tiles.
|
|
801
|
+
const hot = tipNow.current, on = new Set(visibleTiles(s.lay, v, sizeRef.current).map((tt) => tt.key)), said = [];
|
|
802
|
+
let moving = false;
|
|
803
|
+
for (const p of s.parts) {
|
|
804
|
+
const tt = p.tile;
|
|
805
|
+
if (!on.has(tt.key)) { if (!still) p.flights.frame(ms, p.L); continue; }
|
|
806
|
+
const tx = Math.round((v.x + tt.x * v.k) * s.ratio), ty = Math.round((v.y + tt.y * v.k) * s.ratio), tw = tt.w * v.k * s.ratio, th = tt.h * v.k * s.ratio;
|
|
807
|
+
ctx.save();
|
|
311
808
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
312
|
-
|
|
313
|
-
ctx.
|
|
809
|
+
ctx.beginPath(); ctx.rect(tx, ty, tw, th); ctx.clip();
|
|
810
|
+
if (drawPart(ctx, p, a * tt.s, tx, ty, ms, still, hot && hot.startsWith(p.prefix) ? hot.slice(p.prefix.length) : null, env, v.k * tt.s < TAG_MIN_K, said)) moving = true;
|
|
811
|
+
ctx.restore();
|
|
812
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
813
|
+
ctx.strokeStyle = env.pal.border; ctx.lineWidth = 1;
|
|
814
|
+
ctx.strokeRect(tx - 0.5, ty - 0.5, tw + 1, th + 1);
|
|
314
815
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (sp.look.dim || sp.look.pose === "away") continue;
|
|
322
|
-
const b = bubbleAt(sp.look.name, sp.look.state, ms, linesFor(sp.look.state, s.lang, sk.pack, s.lines));
|
|
323
|
-
if (b) bubbles.push({ key: sp.look.name, calling: CALLING.has(sp.look.state), shown: b.shown, box: bubbleBox(ctx, sp.x, sp.y, b.text), tail: { x: sp.x, y: sp.y }, sp, b });
|
|
816
|
+
for (const say of said) say();
|
|
817
|
+
const up = still ? [] : cross.frame(ms, s.parts);
|
|
818
|
+
if (up.length) {
|
|
819
|
+
ctx.setTransform(a, 0, 0, a, ox, oy);
|
|
820
|
+
const prop = skinFor("pixel").drawProp;
|
|
821
|
+
for (const it of up) prop(ctx, it, ms, env);
|
|
324
822
|
}
|
|
325
|
-
|
|
326
|
-
return walking || up.length > 0 || flights.size() > 0;
|
|
823
|
+
return moving || up.length > 0 || cross.size() > 0;
|
|
327
824
|
}
|
|
328
825
|
// The loop: drawing only when the frame (FPS) changed or something is in the air; stopped while the tab is hidden,
|
|
329
826
|
// gone with the view. Office review: while something walks or flies, one requestAnimationFrame per display frame (the
|
|
@@ -359,76 +856,218 @@ export function Office({ view, traffic, q = "", lease, onOpen }) {
|
|
|
359
856
|
}, []);
|
|
360
857
|
useEffect(() => { loop.current?.wake(); }, [traffic]);
|
|
361
858
|
|
|
362
|
-
//
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const
|
|
859
|
+
// The person hovered or focused: their name tag shows even in a crowd.
|
|
860
|
+
const tipNow = useRef(null);
|
|
861
|
+
tipNow.current = tip;
|
|
862
|
+
useEffect(() => { if (!scene.current) return; scene.current.dirty = true; if (still) draw(0); else loop.current?.wake(); }, [tip]);
|
|
863
|
+
|
|
864
|
+
// Everyone drawn: { key, node, box (the desk, in the view's units), dot (where the overview marks them), office (All
|
|
865
|
+
// offices: the tile's name) }. In All offices a key is the tile's prefix and the desk's key: one person in two
|
|
866
|
+
// offices is two people here.
|
|
867
|
+
const people = overview
|
|
868
|
+
? tiles.flatMap((tl, i) => { const tt = arranged.tiles[i];
|
|
869
|
+
return tt ? desksOf(tl.L).map((d) => ({ key: tl.prefix + d.key, node: d.node, box: tileBox(tt, d), office: tl.name,
|
|
870
|
+
dot: fromTile(tt, tl.zones ? d.seat : { x: d.x + d.w / 2, y: d.y + d.h / 2 }) })) : []; })
|
|
871
|
+
: desksOf(L).map((d) => ({ key: d.key, node: d.node, box: d, office: null, dot: zones ? d.seat : { x: d.x + d.w / 2, y: d.y + d.h / 2 } }));
|
|
872
|
+
// Preact owns the markup, not the view: put it back on the overview, the overlay and the tooltip after every render.
|
|
873
|
+
const tipDesk = tip ? people.find((d) => d.key === tip) || null : null;
|
|
874
|
+
tipDeskRef.current = tipDesk ? tipDesk.box : null;
|
|
875
|
+
useLayoutEffect(mark);
|
|
876
|
+
// ── Pointing (#2540: through the view): hover (or a first tap) shows a desk's card, a click (or a second tap) opens
|
|
877
|
+
// its chat; a drag on the scene pans it (never on Edit layout's handles: they move), the wheel and a pinch zoom ──
|
|
878
|
+
/** The view's point under a pointer event (logical units), or null. */
|
|
879
|
+
const pointOf = (e) => {
|
|
371
880
|
const r = canvasRef.current ? canvasRef.current.getBoundingClientRect() : null;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
881
|
+
return r ? toWorld(view0(), e.clientX - r.left, e.clientY - r.top) : null;
|
|
882
|
+
};
|
|
883
|
+
/** The person under a pointer event as drawn ({ key, node }), or null; All offices: in the tile there, in its own units. */
|
|
884
|
+
const deskOf = (e) => {
|
|
885
|
+
const w = pointOf(e), s = scene.current;
|
|
886
|
+
if (!w) return null;
|
|
887
|
+
// The zones scene draws people where they walk: they are hit there, not at the seat they are heading for (hitPart).
|
|
888
|
+
if (!s || !s.overview) {
|
|
889
|
+
if (overview) return null;
|
|
890
|
+
return hitPart(s && s.part ? s.part : { L, zones, walkers, skin, looks, all: L.rooms.flatMap((rm) => rm.desks) }, w.x, w.y, now());
|
|
891
|
+
}
|
|
892
|
+
const tt = tileAt(s.lay, w.x, w.y), p = tt ? s.parts.find((x) => x.tile.key === tt.key) : null;
|
|
893
|
+
if (!p) return null;
|
|
894
|
+
const at = inTile(tt, w.x, w.y), d = hitPart(p, at.x, at.y, now());
|
|
895
|
+
return d ? { key: p.prefix + d.key, node: d.node } : null;
|
|
896
|
+
};
|
|
897
|
+
const g = gestures(drag.current, { el: () => stageRef.current, pan: (dx, dy) => { const v = view0(); setView({ ...v, x: v.x + dx, y: v.y + dy }); },
|
|
898
|
+
pinch: (from, to) => { raw.current = Math.min(OK_MAX, Math.max(OK_MIN, raw.current * (to.dist / from.dist))); setView(pinchOffice(view0(), from, to, raw.current)); } });
|
|
899
|
+
/** Where a drag pans: the canvas, and Edit layout's overlay off its handles (the controls, the bar and the list: never). */
|
|
900
|
+
const onScene = (el) => !!el && (el === canvasRef.current || (typeof el.closest === "function" && !!el.closest(".ol-svg") && !el.closest(".ol-handle")));
|
|
901
|
+
const onDown = (e) => {
|
|
902
|
+
lastType.current = e.pointerType || "mouse";
|
|
903
|
+
if (!onScene(e.target)) return;
|
|
904
|
+
g.down(e);
|
|
905
|
+
if (drag.current.pts.size === 2) raw.current = view0().k; // a pinch starts from the zoom shown
|
|
906
|
+
};
|
|
907
|
+
const onWheel = (e) => {
|
|
908
|
+
if (!onScene(e.target) && !(typeof e.target?.closest === "function" && e.target.closest(".ol-handle, .oo-tile-label"))) return;
|
|
909
|
+
e.preventDefault();
|
|
910
|
+
const r = stageRef.current.getBoundingClientRect(), v = view0();
|
|
911
|
+
raw.current = Math.min(OK_MAX, Math.max(OK_MIN, raw.current * wheelFactor(e)));
|
|
912
|
+
if (raw.current !== v.k) setView(zoomOffice(v, raw.current, e.clientX - r.left, e.clientY - r.top));
|
|
376
913
|
};
|
|
377
|
-
const
|
|
914
|
+
const onKeyDown = (e) => {
|
|
915
|
+
if (e.defaultPrevented) return; // Edit layout's handles move with the arrows
|
|
916
|
+
const tag = e.target && e.target.tagName;
|
|
917
|
+
if (tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA") return;
|
|
918
|
+
const z = zoomKey(e);
|
|
919
|
+
if (z) { e.preventDefault(); if (z === "fit") fit(); else zoomStep(z === "in" ? 1 : -1); return; }
|
|
920
|
+
const dir = PAN_KEYS[e.key];
|
|
921
|
+
if (dir && e.target === canvasRef.current && !e.altKey && !e.ctrlKey && !e.metaKey) { e.preventDefault(); const v = view0(); setView({ ...v, x: v.x - dir[0] * 80, y: v.y - dir[1] * 80 }); }
|
|
922
|
+
};
|
|
923
|
+
// The keyboard's way through: a desk in the list, or a handle of Edit layout, is brought into view when focused.
|
|
924
|
+
const onFocusIn = (e) => {
|
|
925
|
+
const el = e.target;
|
|
926
|
+
if (!el || typeof el.getAttribute !== "function") return;
|
|
927
|
+
const hk = el.getAttribute("data-handle");
|
|
928
|
+
if (hk && layout) { const hd = handlesOf(layout.draft).find((x) => x.key === hk); if (hd) show({ x: hd.x - 12, y: hd.y - 12, w: 24, h: 24 }); return; }
|
|
929
|
+
const key = el.classList && el.classList.contains("oo-desk") ? el.getAttribute("data-key") : null;
|
|
930
|
+
const d = key ? people.find((x) => x.key === key) : null;
|
|
931
|
+
if (d) show(d.box);
|
|
932
|
+
};
|
|
933
|
+
const onMove = (e) => { if (e.pointerType === "touch" || g.busy()) return; const d = deskOf(e); const key = d ? d.key : null; if (key !== tip) setTip(key); };
|
|
378
934
|
const onClick = (e) => {
|
|
379
935
|
const d = deskOf(e);
|
|
380
936
|
if (!d || !d.node.i) { setTip(null); return; }
|
|
381
937
|
if (lastType.current === "touch" && tip !== d.key) { setTip(d.key); return; } // a first tap shows; a second opens
|
|
382
|
-
|
|
938
|
+
open(d.node.name);
|
|
939
|
+
};
|
|
940
|
+
// All offices: a double-click on a tile (off its people) opens that office; the lobby is no office.
|
|
941
|
+
const onDblClick = (e) => {
|
|
942
|
+
const s = scene.current, w = pointOf(e);
|
|
943
|
+
if (!overview || !s || !s.overview || !w || deskOf(e)) return;
|
|
944
|
+
const tt = tileAt(s.lay, w.x, w.y) || labelAt(s.lay, w.x, w.y), tl = tt ? tiles.find((x) => x.key === tt.key) : null;
|
|
945
|
+
if (tl && !tl.lobby) pick(tl.key);
|
|
946
|
+
};
|
|
947
|
+
const onMini = (e) => {
|
|
948
|
+
const w = miniPoint(miniRef.current ? miniRef.current.getBoundingClientRect() : null, { x: 0, y: 0, w: L.width, h: L.height }, e.clientX, e.clientY);
|
|
949
|
+
if (w) setView(centreOn(view0(), size, w.x, w.y));
|
|
383
950
|
};
|
|
384
951
|
|
|
385
|
-
const auto = !custom;
|
|
952
|
+
const auto = !custom && !overview;
|
|
953
|
+
// Edit layout: an admin, a stored office, a zones style (built in, or a pack loaded here); not while the offices'
|
|
954
|
+
// editor is open, nor a second session (nor in All offices: custom is null there).
|
|
955
|
+
const canLayout = canEdit && storedRev !== null && !!custom && zones && !loading && baseSkin.id === custom.skin && !editing && !layout;
|
|
956
|
+
const openLayout = () => {
|
|
957
|
+
setLayout({ id: ++layoutSeq.current, officeId: custom.id, skin: custom.skin, pack: styleKey, base: baseSkin.pack, start: skin.pack, draft: skin.pack, rev: storedRev, list: stored });
|
|
958
|
+
setTip(null);
|
|
959
|
+
};
|
|
960
|
+
const closeLayout = () => setLayout(null);
|
|
961
|
+
const onDraft = (draft) => setLayout((cur) => (cur ? { ...cur, draft } : cur));
|
|
962
|
+
// Save: the session's list, this office's overrides replaced (none: back to the style's own), with the session's rev.
|
|
963
|
+
// A change made meanwhile (409) reads the list again: the session takes it (the view too), the draft is kept, and
|
|
964
|
+
// Save again — the person's call, told so — puts it on that list.
|
|
965
|
+
const saveLayout = async (ov) => {
|
|
966
|
+
const s = layoutRef.current;
|
|
967
|
+
const mine = s && s.list.find((o) => o.id === s.officeId);
|
|
968
|
+
if (!s || !mine || mine.skin !== s.skin) return { ok: false, message: t("orgl.stale") };
|
|
969
|
+
const list = s.list.map((o) => (o.id === s.officeId ? (({ overrides: _gone, ...rest }) => (ov ? { ...rest, overrides: ov } : rest))(o) : o)).map(officeForSave);
|
|
970
|
+
const sent = ask();
|
|
971
|
+
const r = await store.saveOffices(list, s.rev);
|
|
972
|
+
if (r.ok) { adopt({ rev: r.rev, offices: r.offices }, sent); return { ok: true }; }
|
|
973
|
+
if (r.status === 409) {
|
|
974
|
+
const at = ask(); const cur = adopt(await store.offices(), at);
|
|
975
|
+
if (cur) setLayout((c) => (c && c.id === s.id ? { ...c, list: cur.offices, rev: cur.rev } : c));
|
|
976
|
+
return { ok: false, message: t("orgl.changed") };
|
|
977
|
+
}
|
|
978
|
+
return { ok: false, message: r.status === 429 ? t("orgl.rateLimited") : t("orgl.failed", r.error || r.status) };
|
|
979
|
+
};
|
|
980
|
+
const styleName = (id) => (STYLES.includes(id) ? to(`style_${id}`) : (packs.find((pk) => pk.id === id) || { name: id }).name);
|
|
386
981
|
const f = filterOk(filter);
|
|
387
982
|
const opts = teamOptions(view);
|
|
388
983
|
const teamValue = (opts.find((o) => o.team === f.team) || opts[0]).value;
|
|
389
984
|
const setF = (next) => { const v = filterOk(next); store.saveFilter(v); setFilter(v); };
|
|
390
|
-
|
|
985
|
+
// While Edit layout is open the office stays (its picker is disabled; this is the guard behind it).
|
|
986
|
+
const pick = (id) => { if (layoutRef.current) return; store.saveChoice(id); setChoice(id); setTip(null); };
|
|
391
987
|
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]);
|
|
392
|
-
const desks = desksOf(L);
|
|
393
988
|
const tipText = tipDesk ? nodeText(tipDesk.node) : null;
|
|
394
|
-
|
|
989
|
+
// The overview: the scene's rooms (or areas; All offices: the tiles) and a dot for each person (a call in its colour),
|
|
990
|
+
// the view's frame on it.
|
|
991
|
+
const miniRects = overview ? arranged.tiles.map((tt) => ({ key: tt.key, x: tt.x, y: tt.y, w: tt.w, h: tt.h }))
|
|
992
|
+
: zones ? Object.values(L.areas || {}).map((a) => ({ key: a.name, ...a.rect })) : L.rooms.map((r) => ({ key: r.key, x: r.x, y: r.y, w: r.w, h: r.h }));
|
|
993
|
+
const dotR = Math.max(L.width, L.height) / 90;
|
|
994
|
+
// The switcher: the whole fleet, All offices (two or more stored), each stored office.
|
|
995
|
+
const officeSelect = (cls) => html`<select class=${`tb-select ${cls}`} value=${layout ? layout.officeId : overview ? ALL_ID : custom ? custom.id : AUTO_ID} disabled=${!!layout}
|
|
996
|
+
aria-label=${to("office")} onChange=${(e) => pick(e.target.value)}>
|
|
997
|
+
<option value=${AUTO_ID}>${to("allOffice")}</option>
|
|
998
|
+
${overviewOk(stored) ? html`<option value=${ALL_ID}>${to("allOffices")}</option>` : null}
|
|
999
|
+
${stored.map((o) => html`<option key=${o.id} value=${o.id}>${o.name}</option>`)}
|
|
1000
|
+
</select>`;
|
|
1001
|
+
return html`<div class=${`oo${fs ? ` fs ${fs}` : ""}`} ref=${ooRef}>
|
|
395
1002
|
<div class="oo-bar">
|
|
396
|
-
<label class="oo-pick"><span class="oo-pick-label">${to("office")}</span>
|
|
397
|
-
<select class="tb-select" value=${custom ? custom.id : AUTO_ID} onChange=${(e) => pick(e.target.value)}>
|
|
398
|
-
<option value=${AUTO_ID}>${to("allOffice")}</option>
|
|
399
|
-
${stored.map((o) => html`<option key=${o.id} value=${o.id}>${o.name}</option>`)}
|
|
400
|
-
</select></label>
|
|
1003
|
+
<label class="oo-pick"><span class="oo-pick-label">${to("office")}</span>${officeSelect("oo-office")}</label>
|
|
401
1004
|
${auto ? html`<label class="oo-pick"><span class="oo-pick-label">${to("styleLabel")}</span>
|
|
402
|
-
<select class="tb-select" value=${skin.id} onChange=${(e) => { store.saveSkin(e.target.value); setStyle(e.target.value); setTip(null); }}>
|
|
1005
|
+
<select class="tb-select" value=${STYLES.includes(style) || packs.some((pk) => pk.id === style) ? style : skin.id} onChange=${(e) => { store.saveSkin(e.target.value); setStyle(e.target.value); setTip(null); }}>
|
|
403
1006
|
${STYLES.map((id) => html`<option key=${id} value=${id}>${to(`style_${id}`)}</option>`)}
|
|
1007
|
+
${packs.map((pk) => html`<option key=${`pack:${pk.id}`} value=${pk.id}>${pk.name}</option>`)}
|
|
404
1008
|
</select></label>` : null}
|
|
405
1009
|
${auto ? html`<label class="oo-pick"><span class="oo-pick-label">${to("show")}</span>
|
|
406
1010
|
<select class="tb-select" value=${teamValue} onChange=${(e) => { const o = opts.find((x) => x.value === e.target.value); setF({ ...f, team: o ? o.team : "" }); }}>
|
|
407
1011
|
${opts.map((o) => html`<option key=${o.value} value=${o.value}>${o.label}</option>`)}
|
|
408
1012
|
</select></label>
|
|
409
1013
|
<${People} nodes=${everyone} pinned=${f.pinned} onChange=${(pinned) => setF({ ...f, pinned })} />` : null}
|
|
410
|
-
|
|
1014
|
+
<label class="check oo-hide-asleep"><input type="checkbox" checked=${hideAsleep} onChange=${() => { const v = !hideAsleep; store.saveHideAsleep(v); setHideAsleep(v); setTip(null); }} /><span>${to("hideAsleep")}</span></label>
|
|
1015
|
+
${overview ? html`<label class="check oo-lobby-tile" title=${lobbyAll.length ? undefined : to("lobbyEveryone")}><input type="checkbox" checked=${lobbyOn && lobbyAll.length > 0}
|
|
1016
|
+
disabled=${!lobbyAll.length} onChange=${() => { const v = !lobbyOn; store.saveLobbyTile(v); setLobbyOn(v); setTip(null); }} /><span>${to("lobbyTile")}</span></label>
|
|
1017
|
+
${lobbyAll.length ? null : html`<span class="muted oo-note oo-lobby-none">${to("lobbyEveryone")}</span>`}` : null}
|
|
1018
|
+
${custom && baseSkin.id !== custom.skin && !loading ? html`<span class="muted oo-note">${to("skinUnknown", styleName(custom.skin))}</span>` : null}
|
|
1019
|
+
${placed.ignored ? html`<span class="muted oo-note">${to("layoutIgnored")}</span>` : null}
|
|
411
1020
|
${L.unseated ? html`<span class="muted oo-note">${to("unseated", L.unseated)}</span>` : null}
|
|
412
|
-
${canEdit && storedRev !== null ? html`<button type="button" class="btn btn-sm oo-edit" onClick=${() => setEditing(true)}
|
|
1021
|
+
${canEdit && storedRev !== null ? html`<button type="button" class="btn btn-sm oo-edit" onClick=${() => { if (!overview) setEditing(true); }} disabled=${!!layout || overview}
|
|
1022
|
+
title=${overview ? to("overviewNoEdit") : undefined}>${t("orge.edit")}</button>` : null}
|
|
1023
|
+
${canLayout ? html`<button type="button" class="btn btn-sm oo-layout" onClick=${openLayout}>${t("orgl.edit")}</button>` : null}
|
|
413
1024
|
</div>
|
|
414
|
-
${editing ? html`<${OfficeEditor} offices=${stored} rev=${storedRev} view=${view} store=${store}
|
|
1025
|
+
${editing && !overview ? html`<${OfficeEditor} offices=${stored} rev=${storedRev} view=${view} store=${store} packs=${packs}
|
|
415
1026
|
ask=${ask} current=${() => shown.current} onSaved=${adopt} onClose=${() => setEditing(false)} />` : null}
|
|
416
|
-
${
|
|
417
|
-
<div class
|
|
418
|
-
|
|
419
|
-
|
|
1027
|
+
${overview || people.length || L.rooms.length ? null : html`<p class="note oo-empty">${to("nobody")} ${auto && (f.team || f.pinned.length) ? html`<button type="button" class="btn btn-sm" onClick=${() => setF({ team: "", pinned: [] })}>${to("everyone")}</button>` : null}</p>`}
|
|
1028
|
+
<div class=${`oo-stage${layout ? " editing" : ""}`} ref=${stageRef} onPointerDown=${onDown} onPointerMove=${g.move} onPointerUp=${g.up} onPointerCancel=${g.up}
|
|
1029
|
+
onWheel=${onWheel} onKeyDown=${onKeyDown} onFocusIn=${onFocusIn} onClickCapture=${g.clickCapture}>
|
|
1030
|
+
<canvas ref=${canvasRef} class=${`oo-canvas${tipDesk && tipDesk.node.i ? " hot" : ""}`} role="application" tabindex="0" aria-label=${to(overview ? "labelAll" : "label")}
|
|
1031
|
+
onPointerMove=${onMove} onPointerLeave=${() => setTip(null)} onClick=${onClick} ondblclick=${onDblClick}></canvas>
|
|
1032
|
+
${overview ? tiles.map((tl) => {
|
|
1033
|
+
const text = to("tileLabel", tl.name, tl.count), at = (el) => { if (el) labelEls.current.set(tl.key, el); else labelEls.current.delete(tl.key); };
|
|
1034
|
+
return tl.lobby ? html`<span key=${tl.key} ref=${at} class="oo-tile-label lobby">${text}</span>`
|
|
1035
|
+
: html`<button key=${tl.key} ref=${at} type="button" class="oo-tile-label" data-office=${tl.key} title=${to("openOffice", tl.name)} aria-label=${to("openOffice", tl.name)}
|
|
1036
|
+
onClick=${() => pick(tl.key)}>${text}</button>`;
|
|
1037
|
+
}) : null}
|
|
1038
|
+
${layout ? html`<${LayoutEditor} key=${layout.id} base=${layout.base} start=${layout.start} place=${placeOverlay}
|
|
1039
|
+
stale=${layoutStale ? t("orgl.stale") : ""} onChange=${onDraft} onSave=${saveLayout} onClose=${closeLayout} />` : null}
|
|
420
1040
|
${tipText ? html`<div ref=${tipRef} class="oo-tip" role="tooltip">
|
|
421
1041
|
<strong>${tipText.primary}</strong>${tipText.secondary ? html` <span class="muted mono">${tipText.secondary}</span>` : null}
|
|
422
1042
|
<div>${tipText.sub}</div><div class="muted">${caption(officePose(tipDesk.node.state), tipDesk.node.state)}</div>
|
|
1043
|
+
${tipDesk.office ? html`<div class="muted oo-tip-office">${tipDesk.office}</div>` : null}
|
|
423
1044
|
${tipDesk.node.i && lastType.current === "touch" ? html`<div class="muted">${to("tapAgain")}</div>` : null}
|
|
424
1045
|
</div>` : null}
|
|
425
|
-
<ul class="oo-desks" aria-label=${to("desks")}>${
|
|
426
|
-
const nt = nodeText(d.node), cap = caption(officePose(d.node.state), d.node.state);
|
|
1046
|
+
<ul class="oo-desks" aria-label=${to("desks")}>${people.map((d) => {
|
|
1047
|
+
const nt = nodeText(d.node), cap = caption(officePose(d.node.state), d.node.state), where = d.office ? ` · ${d.office}` : "";
|
|
427
1048
|
return html`<li key=${d.key}>${d.node.i
|
|
428
|
-
? html`<button type="button" class="oo-desk" data-name=${d.node.name} aria-label=${`${nt.full} · ${cap}. ${t("orgc.openChat")}`}
|
|
429
|
-
onFocus=${() => setTip(d.key)} onBlur=${() => setTip(null)} onClick=${() =>
|
|
430
|
-
: html`<span class="oo-desk" data-name=${d.node.name}>${nt.full}</span>`}</li>`;
|
|
1049
|
+
? html`<button type="button" class="oo-desk" data-name=${d.node.name} data-key=${d.key} aria-label=${`${nt.full}${where} · ${cap}. ${t("orgc.openChat")}`}
|
|
1050
|
+
onFocus=${() => setTip(d.key)} onBlur=${() => setTip(null)} onClick=${() => open(d.node.name)}>${nt.primary}</button>`
|
|
1051
|
+
: html`<span class="oo-desk" data-name=${d.node.name} data-key=${d.key}>${nt.full}</span>`}</li>`;
|
|
431
1052
|
})}</ul>
|
|
1053
|
+
<div class="oc-zoom oo-zoom" role="group" aria-label=${t("orgc.view")}>
|
|
1054
|
+
<output ref=${pctRef} class="oo-zoom-pct"></output>
|
|
1055
|
+
<button type="button" class="icon-btn oo-zoom-in" aria-label=${t("orgc.zoomIn")} title=${t("orgc.zoomIn")} onClick=${() => zoomStep(1)}><${Icon} name="plus" size=${16} /></button>
|
|
1056
|
+
<button type="button" class="icon-btn oo-zoom-out" aria-label=${t("orgc.zoomOut")} title=${t("orgc.zoomOut")} onClick=${() => zoomStep(-1)}><${Icon} name="minus" size=${16} /></button>
|
|
1057
|
+
<button type="button" class="icon-btn oo-fit" aria-label=${to("fit")} title=${to("fit")} onClick=${() => fit()}><${Icon} name="fitwidth" size=${16} /></button>
|
|
1058
|
+
<button type="button" class=${`icon-btn oo-fill${fitMode === "cover" ? " on" : ""}`} aria-pressed=${fitMode === "cover" ? "true" : "false"} aria-label=${to("fillTitle")}
|
|
1059
|
+
title=${to("fillTitle")} onClick=${toggleFill}>${to("fill")}</button>
|
|
1060
|
+
<button type="button" class="icon-btn oo-fs" aria-label=${to(fs ? "exitFullscreen" : "fullscreen")} title=${to(fs ? "exitFullscreen" : "fullscreen")} onClick=${toggleFs}><${Icon} name=${fs ? "fullscreenexit" : "fullscreen"} size=${16} /></button>
|
|
1061
|
+
</div>
|
|
1062
|
+
${fs ? html`<div class="oo-fs-bar">${officeSelect("oo-fs-office")}</div>` : null}
|
|
1063
|
+
<svg ref=${miniRef} class="oc-mini oo-mini" viewBox=${`0 0 ${Math.max(1, L.width)} ${Math.max(1, L.height)}`} aria-hidden="true" onClick=${onMini}>
|
|
1064
|
+
<title>${to("overview")}</title>
|
|
1065
|
+
<rect class="oo-mini-matte" x=${-L.width} y=${-L.height} width=${L.width * 3} height=${L.height * 3} fill=${matte} />
|
|
1066
|
+
<rect class="oo-mini-scene" x="0" y="0" width=${L.width} height=${L.height} />
|
|
1067
|
+
${miniRects.map((r) => html`<rect key=${r.key} class="oo-mini-room" x=${r.x} y=${r.y} width=${r.w} height=${r.h} />`)}
|
|
1068
|
+
${people.map((d) => html`<circle key=${d.key} class=${`oo-mini-dot st-${d.node.state}${q && hits(d.node, q) ? " match" : ""}`} cx=${d.dot.x} cy=${d.dot.y} r=${dotR} />`)}
|
|
1069
|
+
<rect ref=${miniViewRef} class="oc-mini-view oo-mini-view" />
|
|
1070
|
+
</svg>
|
|
432
1071
|
</div>
|
|
433
1072
|
</div>`;
|
|
434
1073
|
}
|