samagotchi 0.164.0 → 0.165.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -1
- data/docs/architecture.md +7 -5
- data/docs/cli.md +20 -13
- data/docs/configuration.md +5 -1
- data/docs/guardrails.md +13 -16
- data/docs/internals/block-renderers.md +1 -1
- data/docs/internals/bridge.md +4 -3
- data/docs/internals/bundles.md +4 -2
- data/docs/internals/inline-widgets.md +8 -1
- data/docs/internals/web-frontend.md +36 -9
- data/docs/memory.md +12 -7
- data/docs/plugins.md +6 -4
- data/docs/releasing.md +6 -2
- data/docs/scheduling.md +25 -3
- data/docs/sessions.md +8 -6
- data/docs/testing.md +28 -4
- data/lib/samagotchi/block_renderers.rb +3 -6
- data/lib/samagotchi/bridge/card_store.rb +2 -1
- data/lib/samagotchi/bridge/turn_accumulator.rb +7 -8
- data/lib/samagotchi/bridge.rb +45 -3
- data/lib/samagotchi/bundle_command/installed_check.rb +2 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/chi_home.rb +44 -2
- data/lib/samagotchi/client_id.rb +34 -3
- data/lib/samagotchi/compat.rb +36 -0
- data/lib/samagotchi/context_command.rb +3 -0
- data/lib/samagotchi/context_providers.rb +5 -6
- data/lib/samagotchi/context_sources.rb +2 -2
- data/lib/samagotchi/continue_intent.rb +50 -5
- data/lib/samagotchi/events.rb +4 -4
- data/lib/samagotchi/extension_load.rb +2 -1
- data/lib/samagotchi/guardrails/child_boundary.rb +7 -27
- data/lib/samagotchi/guardrails/rules.rb +11 -9
- data/lib/samagotchi/guardrails/targets.rb +3 -4
- data/lib/samagotchi/inline_widgets.rb +16 -1
- data/lib/samagotchi/memory_bundle/provenance.rb +46 -4
- data/lib/samagotchi/memory_bundle/status.rb +2 -1
- data/lib/samagotchi/memory_command.rb +3 -0
- data/lib/samagotchi/memory_orphans.rb +4 -7
- data/lib/samagotchi/memory_paths.rb +64 -7
- data/lib/samagotchi/memory_usage.rb +1 -1
- data/lib/samagotchi/plugin/sessions.rb +4 -2
- data/lib/samagotchi/project_command.rb +4 -1
- data/lib/samagotchi/project_id_clash.rb +37 -26
- data/lib/samagotchi/project_init.rb +24 -7
- data/lib/samagotchi/reply_wait/poll.rb +2 -1
- data/lib/samagotchi/schedules.rb +124 -106
- data/lib/samagotchi/send_command.rb +71 -18
- data/lib/samagotchi/session.rb +3 -2
- data/lib/samagotchi/session_access/local.rb +19 -2
- data/lib/samagotchi/session_access/remote.rb +15 -4
- data/lib/samagotchi/session_chain/links.rb +109 -0
- data/lib/samagotchi/session_chain.rb +7 -19
- data/lib/samagotchi/session_continue.rb +138 -54
- data/lib/samagotchi/session_inbox_delivery.rb +57 -38
- data/lib/samagotchi/session_manager/delivery.rb +104 -18
- data/lib/samagotchi/session_manager/removal.rb +13 -7
- data/lib/samagotchi/session_manager.rb +1 -0
- data/lib/samagotchi/session_retention.rb +20 -10
- data/lib/samagotchi/session_setup.rb +31 -1
- data/lib/samagotchi/state_format.rb +12 -8
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +6 -7
- data/lib/samagotchi/terminal_ui.rb +20 -9
- data/lib/samagotchi/tools/delegate.rb +2 -1
- data/lib/samagotchi/verify_fresh.rb +4 -1
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/activity.js +2 -2
- data/lib/samagotchi/web/public/app.js +13 -13
- data/lib/samagotchi/web/public/bar_fold.js +293 -0
- data/lib/samagotchi/web/public/card.js +1 -1
- data/lib/samagotchi/web/public/composer_mode.js +5 -7
- data/lib/samagotchi/web/public/index.html +132 -65
- data/lib/samagotchi/web/public/info_bar.js +28 -16
- data/lib/samagotchi/web/public/info_bar_model.js +70 -1
- data/lib/samagotchi/web/public/more_sheet.js +98 -40
- data/lib/samagotchi/web/public/stage_view.js +3 -1
- data/lib/samagotchi/web/public/stream_handlers.js +1 -1
- data/lib/samagotchi/web/public/turn_events.js +0 -122
- data/lib/samagotchi/web/public/turn_model.js +1 -1
- data/lib/samagotchi/web/public/widget_picks.js +18 -3
- data/lib/samagotchi/web/session_control.rb +15 -2
- data/lib/samagotchi/web/session_create.rb +4 -2
- data/lib/samagotchi/web/update_check.rb +27 -8
- metadata +3 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// The session bar's fold (#infoBar): the bar is one row at every width, and
|
|
2
|
+
// what doesn't fit folds into ⋯ (more_sheet.js), the lowest rank first
|
|
3
|
+
// (info_bar_model.js BAR_ITEMS). foldPlan is the rule, pure, over measured
|
|
4
|
+
// widths; createBarFold is its watcher on the page: it measures, caches the
|
|
5
|
+
// widths, recomputes only when an input changes and writes the plan as three
|
|
6
|
+
// attributes on #infoBar that index.html's CSS hides by:
|
|
7
|
+
// data-folded="notes toolkit dir" (the folded keys: display:none, still in
|
|
8
|
+
// the DOM, so a click from ⋯ reaches them)
|
|
9
|
+
// data-compact="settings" (⚙ as its icon, the dot when own)
|
|
10
|
+
// data-empty-groups="relations" (a group with nothing on the row, and
|
|
11
|
+
// the hairline before it)
|
|
12
|
+
// lit renders into #infoText, inside #infoBar, so the attributes survive its
|
|
13
|
+
// redraws. docs/internals/web-frontend.md ("The session bar: one row").
|
|
14
|
+
|
|
15
|
+
import { BAR_ITEMS } from "./info_bar_model.js";
|
|
16
|
+
import { chipModel as settingsChipModel } from "./settings_chip.js";
|
|
17
|
+
|
|
18
|
+
// The page's phone width (index.html's 600 px cut): only phone: "row" items
|
|
19
|
+
// are row candidates there.
|
|
20
|
+
export const PHONE_QUERY = "(max-width: 600px)";
|
|
21
|
+
|
|
22
|
+
// The .meta's groups, left to right (info_bar.js infoBarHtml); the actions
|
|
23
|
+
// (#infoActions and ⋯) follow them.
|
|
24
|
+
export const META_GROUPS = Object.freeze(["identity", "setup", "relations", "trail"]);
|
|
25
|
+
|
|
26
|
+
// The chips a running turn rewrites: their text changes every tick, so they
|
|
27
|
+
// are left out of the signature and kept within a width budget instead.
|
|
28
|
+
export const LIVE_KEYS = Object.freeze(["ctx", "speed", "time"]);
|
|
29
|
+
|
|
30
|
+
// Items that are always in ⋯ and so don't count on it (more_sheet.js moreCount).
|
|
31
|
+
const UNCOUNTED = new Set(["archive", "delete", "more"]);
|
|
32
|
+
|
|
33
|
+
const pinned = (item) => item.rank === "pinned";
|
|
34
|
+
const rankOf = (item) => (pinned(item) ? Infinity : item.rank);
|
|
35
|
+
|
|
36
|
+
// The row's width with +row+ (items) on it, +compact+ (keys) in their compact
|
|
37
|
+
// form. +spacing+: {item: the gap between two chips of a group, group: from
|
|
38
|
+
// one group's last chip to the next's first (its hairline and gaps), bar:
|
|
39
|
+
// #infoBar's gap (between .info, #infoActions and ⋯), actions: the gap
|
|
40
|
+
// between two buttons}. +countWidth+: what the count on ⋯ adds, when any.
|
|
41
|
+
export function rowWidth(row, { widths, compact = new Set(), spacing, countWidth = 0, counted = false }) {
|
|
42
|
+
const w = (item) => {
|
|
43
|
+
const m = widths[item.key] || { full: 0 };
|
|
44
|
+
return compact.has(item.key) && m.compact !== undefined ? m.compact : m.full;
|
|
45
|
+
};
|
|
46
|
+
let meta = 0;
|
|
47
|
+
let drawn = 0;
|
|
48
|
+
for (const group of META_GROUPS) {
|
|
49
|
+
const its = row.filter((item) => item.group === group);
|
|
50
|
+
if (!its.length) continue;
|
|
51
|
+
meta += (drawn ? spacing.group : 0) + its.reduce((sum, item) => sum + w(item), 0) + spacing.item * (its.length - 1);
|
|
52
|
+
drawn += 1;
|
|
53
|
+
}
|
|
54
|
+
const buttons = row.filter((item) => item.group === "actions" && item.key !== "more");
|
|
55
|
+
const acts = buttons.reduce((sum, item) => sum + w(item), 0) + spacing.actions * Math.max(0, buttons.length - 1);
|
|
56
|
+
const more = row.find((item) => item.key === "more");
|
|
57
|
+
return meta + spacing.bar + acts + (more ? spacing.bar + w(more) + (counted ? countWidth : 0) : 0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// The fold for +items+ (the BAR_ITEMS the session's bar has), +widths+
|
|
61
|
+
// ({key: {full, compact?}}, px), +available+ (the bar's content width, px)
|
|
62
|
+
// and +profile+ ("desktop" | "phone"):
|
|
63
|
+
// 1. every row candidate at its full form (on the phone only phone: "row"
|
|
64
|
+
// ones, ⚙ there compact from the start; "menu" items never);
|
|
65
|
+
// 2. while the row is wider than +available+: the lowest rank still on it
|
|
66
|
+
// (all of that rank together) goes compact when it has a compact form
|
|
67
|
+
// not yet used, else it folds;
|
|
68
|
+
// 3. pinned items never fold: with only those left the row clips.
|
|
69
|
+
// @return {folded: Set, compact: Set, emptyGroups: [group]} (emptyGroups: the
|
|
70
|
+
// META_GROUPS with no item on the row, in their order)
|
|
71
|
+
export function foldPlan({ items, widths, available, profile = "desktop", spacing, countWidth = 0 }) {
|
|
72
|
+
const phone = profile === "phone";
|
|
73
|
+
const candidate = (item) => item.rank !== "menu" && (!phone || item.phone === "row");
|
|
74
|
+
const folded = new Set(items.filter((item) => !candidate(item)).map((item) => item.key));
|
|
75
|
+
const compact = new Set(phone ? items.filter((item) => candidate(item) && item.compact).map((item) => item.key) : []);
|
|
76
|
+
const onRow = () => items.filter((item) => !folded.has(item.key));
|
|
77
|
+
const counted = () => [...folded].some((key) => !UNCOUNTED.has(key));
|
|
78
|
+
const fits = () => rowWidth(onRow(), { widths, compact, spacing, countWidth, counted: counted() }) <= available;
|
|
79
|
+
while (!fits()) {
|
|
80
|
+
const foldable = onRow().filter((item) => !pinned(item));
|
|
81
|
+
if (!foldable.length) break;
|
|
82
|
+
const low = Math.min(...foldable.map(rankOf));
|
|
83
|
+
const its = foldable.filter((item) => rankOf(item) === low);
|
|
84
|
+
const shrink = its.filter((item) => item.compact && !compact.has(item.key));
|
|
85
|
+
if (shrink.length) shrink.forEach((item) => compact.add(item.key));
|
|
86
|
+
else its.forEach((item) => { folded.add(item.key); compact.delete(item.key); });
|
|
87
|
+
}
|
|
88
|
+
const row = onRow();
|
|
89
|
+
const emptyGroups = META_GROUPS.filter((group) => !row.some((item) => item.group === group));
|
|
90
|
+
return { folded, compact, emptyGroups };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// What, besides the bar's width, changes the fold: the items present and the
|
|
94
|
+
// text of each one that isn't live (a status, "set 9" → "set 10", a delegate
|
|
95
|
+
// starting to wait, the model's name), as one string. +bar+, +buttons+:
|
|
96
|
+
// info_bar_model.js sessionBar's.
|
|
97
|
+
export function foldSignature(bar, buttons) {
|
|
98
|
+
if (!bar) return "";
|
|
99
|
+
const gear = bar.settings ? settingsChipModel(bar.settings) : null;
|
|
100
|
+
return JSON.stringify([
|
|
101
|
+
bar.id, bar.status, bar.model?.text, bar.model?.mismatch, gear?.text, gear?.own,
|
|
102
|
+
bar.toolkit?.summary?.name, bar.toolkit?.summary?.label, bar.toolkit?.defaultKit, bar.notes?.text,
|
|
103
|
+
bar.workingSet ? [bar.workingSet.chip?.n] : (bar.memories || []).join(","),
|
|
104
|
+
bar.participants?.text, bar.participants?.count,
|
|
105
|
+
bar.chain?.prev?.date, bar.chain?.prev?.id, bar.chain?.next?.date, bar.chain?.next?.id, bar.chain?.pruned,
|
|
106
|
+
bar.parent?.id, bar.kids?.text, bar.kids?.waitingText, bar.dir, !!bar.speed,
|
|
107
|
+
bar.worker?.badge?.text, bar.worker?.badge?.restart, bar.worker?.busy,
|
|
108
|
+
buttons?.continue?.shown, buttons?.continue?.text, buttons?.stop?.shown,
|
|
109
|
+
buttons?.archive?.shown, buttons?.delete?.shown,
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const px = (value) => parseFloat(value) || 0;
|
|
114
|
+
|
|
115
|
+
// The watcher. +barEl+: #infoBar; +win+: the window (matchMedia,
|
|
116
|
+
// ResizeObserver, getComputedStyle; a fake in the tests); +keysFor(bar,
|
|
117
|
+
// buttons)+: the BAR_ITEMS keys present (info_bar_model.js barItemKeys).
|
|
118
|
+
// update({bar, buttons}) after each render (app.js updateInfoBar, in the
|
|
119
|
+
// same task, before paint) → {folded, compact} (Sets); it recomputes only
|
|
120
|
+
// when the signature, the profile or the bar's width changed, or a live chip
|
|
121
|
+
// outgrew its budget. +onChange()+: a recompute the watcher started by itself
|
|
122
|
+
// (a resize, the fonts, a zoom), so the page can redraw ⋯ from the new fold.
|
|
123
|
+
// @return {update, recompute, folded(), compact()}
|
|
124
|
+
export function createBarFold({ barEl, keysFor, win = globalThis, doc = win.document, onChange = () => {} }) {
|
|
125
|
+
const phoneQuery = win.matchMedia(PHONE_QUERY);
|
|
126
|
+
// Natural widths per key + text (+ form); the live chips' budgets per key.
|
|
127
|
+
const cache = new Map();
|
|
128
|
+
const budgets = new Map();
|
|
129
|
+
let last = { bar: null, buttons: null };
|
|
130
|
+
let signature = null;
|
|
131
|
+
let profile = null;
|
|
132
|
+
let width = null;
|
|
133
|
+
let plan = { folded: new Set(), compact: new Set(), emptyGroups: [] };
|
|
134
|
+
|
|
135
|
+
const elOf = (item) => barEl.querySelector(item.selector);
|
|
136
|
+
const textOf = (el) => `${el.className}|${el.textContent}`;
|
|
137
|
+
const live = (item) => LIVE_KEYS.includes(item.key);
|
|
138
|
+
// ⋯'s own width is read with its count blank (the count is countWidth).
|
|
139
|
+
const cacheKey = (item, el, form) => (live(item) || item.key === "more" ? `${item.key}|${form}` : `${item.key}|${form}|${textOf(el)}`);
|
|
140
|
+
const boxWidth = (el) => (el.getClientRects().length ? el.getBoundingClientRect().width : 0);
|
|
141
|
+
const contentWidth = () => {
|
|
142
|
+
const style = win.getComputedStyle(barEl);
|
|
143
|
+
return barEl.clientWidth - px(style.paddingLeft) - px(style.paddingRight);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
function setAttr(name, values) {
|
|
147
|
+
const text = [...values].join(" ");
|
|
148
|
+
if (text) barEl.setAttribute(name, text);
|
|
149
|
+
else barEl.removeAttribute(name);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function apply(next) {
|
|
153
|
+
plan = next;
|
|
154
|
+
setAttr("data-folded", next.folded);
|
|
155
|
+
setAttr("data-compact", next.compact);
|
|
156
|
+
setAttr("data-empty-groups", next.emptyGroups);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// The spacing the row's CSS has now (a phone's groups are display:contents
|
|
160
|
+
// with no hairline; a desktop's are flex boxes with one).
|
|
161
|
+
function spacing() {
|
|
162
|
+
const meta = barEl.querySelector(".meta");
|
|
163
|
+
const group = barEl.querySelector(".meta .bar-group");
|
|
164
|
+
const sep = barEl.querySelector(".meta .bar-sep");
|
|
165
|
+
const metaGap = meta ? px(win.getComputedStyle(meta).columnGap) : 0;
|
|
166
|
+
const groupStyle = group ? win.getComputedStyle(group) : null;
|
|
167
|
+
const item = groupStyle && groupStyle.display !== "contents" ? px(groupStyle.columnGap) : metaGap;
|
|
168
|
+
const sepWidth = sep && win.getComputedStyle(sep).display !== "none" ? boxWidth(sep) : 0;
|
|
169
|
+
const actions = barEl.querySelector("#infoActions");
|
|
170
|
+
return {
|
|
171
|
+
item,
|
|
172
|
+
group: sepWidth ? sepWidth + 2 * metaGap : metaGap,
|
|
173
|
+
bar: px(win.getComputedStyle(barEl).columnGap),
|
|
174
|
+
actions: actions ? px(win.getComputedStyle(actions).columnGap) : 0,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Every candidate's width, measured where none is cached: with the fold's
|
|
179
|
+
// attributes off (a folded item has no box to read), and the row's children are
|
|
180
|
+
// flex:none (index.html), so a width is its natural one. Synchronous: no
|
|
181
|
+
// paint sees the unfolded row. The count on ⋯ is measured with two digits.
|
|
182
|
+
function measure(items) {
|
|
183
|
+
const forms = items.flatMap((item) => [["full", item], ...(item.compact ? [["compact", item]] : [])]);
|
|
184
|
+
const need = () => forms.some(([form, item]) => { const el = elOf(item); return el && !cache.has(cacheKey(item, el, form)); })
|
|
185
|
+
|| !cache.has("more|count");
|
|
186
|
+
if (need()) {
|
|
187
|
+
const saved = ["data-folded", "data-compact", "data-empty-groups"].map((name) => [name, barEl.getAttribute(name)]);
|
|
188
|
+
saved.forEach(([name]) => barEl.removeAttribute(name));
|
|
189
|
+
const read = (form) => forms.filter(([f]) => f === form).forEach(([, item]) => {
|
|
190
|
+
const el = elOf(item);
|
|
191
|
+
if (el) cache.set(cacheKey(item, el, form), boxWidth(el));
|
|
192
|
+
});
|
|
193
|
+
const more = barEl.querySelector("#infoMoreBtn");
|
|
194
|
+
const count = more?.querySelector(".more-count");
|
|
195
|
+
const before = count ? count.textContent : "";
|
|
196
|
+
if (count) count.textContent = "";
|
|
197
|
+
read("full");
|
|
198
|
+
if (count) {
|
|
199
|
+
const bare = boxWidth(more);
|
|
200
|
+
count.textContent = "88";
|
|
201
|
+
cache.set("more|count", Math.max(0, boxWidth(more) - bare));
|
|
202
|
+
count.textContent = before;
|
|
203
|
+
} else {
|
|
204
|
+
cache.set("more|count", 0);
|
|
205
|
+
}
|
|
206
|
+
barEl.setAttribute("data-compact", items.filter((item) => item.compact).map((item) => item.key).join(" "));
|
|
207
|
+
read("compact");
|
|
208
|
+
saved.forEach(([name, value]) => (value === null ? barEl.removeAttribute(name) : barEl.setAttribute(name, value)));
|
|
209
|
+
}
|
|
210
|
+
const widths = {};
|
|
211
|
+
for (const item of items) {
|
|
212
|
+
const el = elOf(item);
|
|
213
|
+
if (!el) continue;
|
|
214
|
+
const full = cache.get(cacheKey(item, el, "full")) || 0;
|
|
215
|
+
const entry = { full: live(item) ? Math.max(full, budgets.get(item.key) || 0) : full };
|
|
216
|
+
if (item.compact) entry.compact = cache.get(cacheKey(item, el, "compact")) || 0;
|
|
217
|
+
if (live(item)) budgets.set(item.key, entry.full);
|
|
218
|
+
widths[item.key] = entry;
|
|
219
|
+
}
|
|
220
|
+
return widths;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function recompute() {
|
|
224
|
+
const { bar, buttons } = last;
|
|
225
|
+
if (!bar) {
|
|
226
|
+
apply({ folded: new Set(), compact: new Set(), emptyGroups: [] });
|
|
227
|
+
return plan;
|
|
228
|
+
}
|
|
229
|
+
const available = contentWidth();
|
|
230
|
+
width = barEl.clientWidth;
|
|
231
|
+
// A bar with no box (the start page, a hidden view): nothing to measure;
|
|
232
|
+
// the resize that gives it one recomputes.
|
|
233
|
+
if (!width) return plan;
|
|
234
|
+
const keys = new Set(keysFor(bar, buttons));
|
|
235
|
+
const items = BAR_ITEMS.filter((item) => keys.has(item.key));
|
|
236
|
+
const phone = profile === "phone";
|
|
237
|
+
const candidates = items.filter((item) => item.rank !== "menu" && (!phone || item.phone === "row"));
|
|
238
|
+
const widths = measure(candidates);
|
|
239
|
+
apply(foldPlan({ items, widths, available: available - 1, profile, spacing: spacing(),
|
|
240
|
+
countWidth: phone ? 0 : cache.get("more|count") || 0 }));
|
|
241
|
+
return plan;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// A live chip on the row wider than its budget (a 3-digit speed, ctx ~100%).
|
|
245
|
+
function outgrown() {
|
|
246
|
+
return LIVE_KEYS.some((key) => {
|
|
247
|
+
const item = BAR_ITEMS.find((i) => i.key === key);
|
|
248
|
+
if (plan.folded.has(key)) return false;
|
|
249
|
+
const el = elOf(item);
|
|
250
|
+
if (!el || !el.getClientRects().length) return false;
|
|
251
|
+
const w = boxWidth(el);
|
|
252
|
+
if (w <= (budgets.get(key) || 0) + 0.5) return false;
|
|
253
|
+
budgets.set(key, w);
|
|
254
|
+
return true;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function update({ bar, buttons }) {
|
|
259
|
+
last = { bar, buttons };
|
|
260
|
+
const sig = foldSignature(bar, buttons);
|
|
261
|
+
const prof = phoneQuery.matches ? "phone" : "desktop";
|
|
262
|
+
if (sig !== signature || prof !== profile || barEl.clientWidth !== width || (bar && outgrown())) {
|
|
263
|
+
// The phone's CSS sizes every chip anew.
|
|
264
|
+
if (prof !== profile) { cache.clear(); budgets.clear(); }
|
|
265
|
+
signature = sig;
|
|
266
|
+
profile = prof;
|
|
267
|
+
recompute();
|
|
268
|
+
}
|
|
269
|
+
return { folded: plan.folded, compact: plan.compact };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Inputs the page's redraws don't carry: the bar's width, the profile, the
|
|
273
|
+
// fonts (a webfont swapped in) and the zoom (both change every width).
|
|
274
|
+
const again = ({ clear = false } = {}) => {
|
|
275
|
+
const prof = phoneQuery.matches ? "phone" : "desktop";
|
|
276
|
+
if (clear || prof !== profile) { cache.clear(); budgets.clear(); }
|
|
277
|
+
profile = prof;
|
|
278
|
+
recompute();
|
|
279
|
+
onChange();
|
|
280
|
+
};
|
|
281
|
+
if (win.ResizeObserver) {
|
|
282
|
+
new win.ResizeObserver(() => { if (barEl.clientWidth !== width) again(); }).observe(barEl);
|
|
283
|
+
}
|
|
284
|
+
phoneQuery.addEventListener?.("change", () => again());
|
|
285
|
+
doc?.fonts?.ready?.then?.(() => again({ clear: true }));
|
|
286
|
+
const watchZoom = () => {
|
|
287
|
+
const query = win.matchMedia(`(resolution: ${win.devicePixelRatio || 1}dppx)`);
|
|
288
|
+
query.addEventListener?.("change", () => { again({ clear: true }); watchZoom(); }, { once: true });
|
|
289
|
+
};
|
|
290
|
+
watchZoom();
|
|
291
|
+
|
|
292
|
+
return { update, recompute, folded: () => plan.folded, compact: () => plan.compact };
|
|
293
|
+
}
|
|
@@ -151,7 +151,7 @@ export function shownElsewhere(notice, capabilities) {
|
|
|
151
151
|
// came during the running turn but aren't its own (an anytime command's,
|
|
152
152
|
// such as /btw: after the running turn once it is drawn, as they came).
|
|
153
153
|
// The running turn's own rows (a hook's notice, a retry) are left out:
|
|
154
|
-
// they come with the turn's parts (
|
|
154
|
+
// they come with the turn's parts (the join's replay). So is a notice the
|
|
155
155
|
// page shows elsewhere (shownElsewhere).
|
|
156
156
|
export function splitSnapshotCards(cards, capabilities = null) {
|
|
157
157
|
const list = (Array.isArray(cards) ? cards : []).filter((c) => !shownElsewhere(c, capabilities));
|
|
@@ -67,10 +67,10 @@ export function composerMode({ selected, owner, running, narrow }) {
|
|
|
67
67
|
// page's session store (selected, current.owner; read only). +liveTurn+:
|
|
68
68
|
// live_turn.js's (running). +startPage+: start_page.js's (restoreStartPick,
|
|
69
69
|
// syncModelPick, dropChoices). +deliveryControl+: delivery_line.js's.
|
|
70
|
-
// +
|
|
70
|
+
// +fitPrompt()+,
|
|
71
71
|
// +placeToast()+: the page's. +win+: the window (matchMedia).
|
|
72
72
|
export function createComposerMode({
|
|
73
|
-
els, store, liveTurn, startPage, deliveryControl,
|
|
73
|
+
els, store, liveTurn, startPage, deliveryControl, fitPrompt, placeToast, win = globalThis,
|
|
74
74
|
}) {
|
|
75
75
|
const narrowScreen = win.matchMedia(NARROW_QUERY);
|
|
76
76
|
let hadSession = false;
|
|
@@ -100,11 +100,9 @@ export function createComposerMode({
|
|
|
100
100
|
if (mode.clearHistory) els.history.replaceChildren();
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (!narrowScreen.matches && moreSheet.isOpen()) moreSheet.close();
|
|
107
|
-
});
|
|
103
|
+
// ⋯'s menu stays open across the width: chip_popover.js turns its sheet
|
|
104
|
+
// into a popover (and back) on the resize.
|
|
105
|
+
narrowScreen.addEventListener("change", () => update());
|
|
108
106
|
|
|
109
107
|
return { update };
|
|
110
108
|
}
|