@blueshed/joined 0.3.0 → 0.3.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/.claude/skills/joined/reference.md +57 -18
- package/docs/design.md +93 -38
- package/docs/introduction.md +9 -9
- package/docs/light-and-shadow.svg +1 -0
- package/docs/links-and-trust.svg +1 -0
- package/docs/stories-to-code.svg +2 -1
- package/docs/wire-op.svg +1 -0
- package/examples/app.css +9 -0
- package/examples/cafe/cafe.css +87 -69
- package/examples/cafe/generated/staff.elements.ts +7 -2
- package/examples/cafe/generated/staff.rules.ts +3 -0
- package/examples/cafe/generated/supplies.rules.ts +5 -0
- package/examples/cafe/kitchen.css +11 -19
- package/examples/cafe/kitchen.ts +6 -2
- package/examples/cafe/migrations/002-guard-supplies.ts +15 -0
- package/examples/cafe/order.html +2 -1
- package/examples/cafe/order.ts +1 -1
- package/examples/cafe/staff.json +5 -0
- package/examples/cafe/stories.jsonl +4 -2
- package/examples/cafe/supplies.html +1 -0
- package/examples/cafe/supplies.ts +45 -28
- package/examples/cafe/till.ts +14 -10
- package/examples/cafe/views.ts +7 -5
- package/examples/chart/arches.ts +5 -3
- package/examples/chart/chart.css +7 -2
- package/examples/desk/desk.css +6 -10
- package/examples/desk/generated/elements.ts +1 -1
- package/examples/desk/index.html +1 -1
- package/examples/desk/lanes.css +21 -19
- package/examples/desk/stories.jsonl +1 -1
- package/examples/desk/tally.css +1 -1
- package/examples/docs.ts +7 -4
- package/examples/index.html +16 -7
- package/examples/notes/generated/queries.ts +8 -2
- package/examples/notes/index.html +1 -1
- package/examples/notes/stories.jsonl +3 -0
- package/examples/page.ts +9 -2
- package/examples/people/links.ts +7 -9
- package/examples/people/people.css +1 -1
- package/examples/people/view.ts +1 -1
- package/examples/trip/generated/elements.ts +1 -1
- package/examples/trip/stays.css +1 -1
- package/examples/trip/stays.ts +1 -1
- package/examples/trips/generated/elements.ts +1 -1
- package/examples/trips/trips.css +24 -23
- package/examples/welcome.css +41 -33
- package/package.json +1 -1
- package/src/attachment.ts +17 -2
- package/src/board.css +2 -1
- package/src/board.ts +4 -4
- package/src/cli.ts +14 -2
- package/src/compile.ts +255 -77
- package/src/definitions.ts +62 -14
- package/src/demo.css +2 -5
- package/src/draft.ts +10 -4
- package/src/drawer.ts +30 -4
- package/src/engine.ts +14 -5
- package/src/fields.ts +88 -15
- package/src/file-value.ts +12 -2
- package/src/files.ts +113 -35
- package/src/icon-names.ts +4 -0
- package/src/keep.ts +16 -3
- package/src/map.css +23 -16
- package/src/map.ts +3 -3
- package/src/mcp.ts +24 -3
- package/src/members/group.ts +41 -17
- package/src/members/keys.ts +3 -3
- package/src/members/panel.css +17 -18
- package/src/members/panel.ts +9 -2
- package/src/migrate.ts +58 -21
- package/src/migrations/005-change-kept.ts +7 -0
- package/src/month.css +6 -2
- package/src/month.ts +5 -5
- package/src/ops.ts +40 -1
- package/src/page.css +3 -2
- package/src/page.ts +64 -16
- package/src/parts.css +178 -86
- package/src/parts.ts +60 -20
- package/src/plane.css +9 -4
- package/src/plane.ts +4 -2
- package/src/reading.css +1 -5
- package/src/rows.css +2 -21
- package/src/rows.ts +123 -39
- package/src/server.ts +157 -30
- package/src/sheet.ts +4 -2
- package/src/slots.css +0 -4
- package/src/specs.ts +1 -1
- package/src/starter.ts +15 -1
- package/src/store.ts +40 -18
- package/src/surface.ts +7 -2
- package/src/time.ts +2 -0
- package/src/timeline.ts +14 -5
- package/src/together.ts +15 -17
- package/src/tokens.css +12 -3
- package/src/tokens.json +38 -7
- package/src/tool.ts +6 -7
- package/src/upkeep.ts +31 -4
- package/src/views.css +8 -9
- package/src/views.ts +23 -6
- package/src/week.css +1 -2
- package/src/week.ts +11 -7
- package/src/write.ts +130 -15
- package/starter/CHANGELOG.md +8 -0
- package/starter/CLAUDE.md +7 -1
- package/starter/bunfig +2 -1
- package/starter/githooks/pre-commit +13 -0
- package/starter/prettierignore +1 -0
- package/starter/tests/records.test.ts +40 -0
- package/starter/todo.jsonl +0 -0
package/src/timeline.ts
CHANGED
|
@@ -22,7 +22,7 @@ type Lane = { key: string; words: string; bars: Bar[]; rows: number };
|
|
|
22
22
|
export class JTimeline extends Reading {
|
|
23
23
|
static override sheets = [SHEET];
|
|
24
24
|
#name = el("h3");
|
|
25
|
-
#adding = el("button", { type: "button", className: "act small adding" }, icon("add"), "Add");
|
|
25
|
+
#adding = el("button", { type: "button", className: "act small adding", part: "add" }, icon("add"), "Add");
|
|
26
26
|
#scroll = el("div", { className: "scroll" });
|
|
27
27
|
#shown = "";
|
|
28
28
|
#placed = false;
|
|
@@ -32,7 +32,7 @@ export class JTimeline extends Reading {
|
|
|
32
32
|
}
|
|
33
33
|
protected made() {
|
|
34
34
|
this.#adding.addEventListener("click", () => this.add({}));
|
|
35
|
-
this.root.append(el("header", { className: "head" }, this.#name, this.#adding), this.#scroll);
|
|
35
|
+
this.root.append(el("header", { className: "head", part: "head" }, this.#name, this.#adding), this.#scroll);
|
|
36
36
|
}
|
|
37
37
|
protected draw() {
|
|
38
38
|
const when = this.when;
|
|
@@ -113,12 +113,17 @@ export class JTimeline extends Reading {
|
|
|
113
113
|
track.style.setProperty("--rows", String(lane.rows));
|
|
114
114
|
for (const b of lane.bars) track.append(this.#bar(b, start, unit, hours));
|
|
115
115
|
chart.append(
|
|
116
|
-
el(
|
|
116
|
+
el(
|
|
117
|
+
"div",
|
|
118
|
+
{ className: "row" },
|
|
119
|
+
el("div", { className: "lane", part: "lane", title: lane.words }, lane.words),
|
|
120
|
+
track,
|
|
121
|
+
),
|
|
117
122
|
);
|
|
118
123
|
}
|
|
119
124
|
const nowMs = wall(now());
|
|
120
125
|
if (nowMs >= start && nowMs < end) {
|
|
121
|
-
const line = el("i", { className: "now", ariaHidden: "true" });
|
|
126
|
+
const line = el("i", { className: "now", part: "now", ariaHidden: "true" });
|
|
122
127
|
line.style.setProperty("--x", String((nowMs - start) / unit));
|
|
123
128
|
chart.append(line);
|
|
124
129
|
}
|
|
@@ -178,7 +183,11 @@ export class JTimeline extends Reading {
|
|
|
178
183
|
const when = this.when!.name,
|
|
179
184
|
length = this.#length?.name,
|
|
180
185
|
w = String(b.it.data[when]),
|
|
181
|
-
bar = el(
|
|
186
|
+
bar = el(
|
|
187
|
+
"button",
|
|
188
|
+
{ type: "button", className: "item bar", part: "item", title: this.named(b.it) },
|
|
189
|
+
this.named(b.it),
|
|
190
|
+
);
|
|
182
191
|
bar.style.setProperty("--x", String((b.from - start) / unit));
|
|
183
192
|
bar.style.setProperty("--w", String((b.to - b.from) / unit));
|
|
184
193
|
bar.style.setProperty("--row-at", String(b.row));
|
package/src/together.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import type { Story } from "./compile.ts";
|
|
13
13
|
import { Refused } from "./engine.ts";
|
|
14
|
-
import { docParts, madeBy, NTH, parts, type Op } from "./ops.ts";
|
|
14
|
+
import { docParts, linksNamed, madeBy, NTH, parts, type Linked, type Op } from "./ops.ts";
|
|
15
15
|
|
|
16
16
|
/** One document's part of a write: its ops, and why, as a write of one document is. */
|
|
17
17
|
export type Part = { doc: string; ops: Op[]; why?: string };
|
|
@@ -31,20 +31,17 @@ export { madeBy };
|
|
|
31
31
|
const addsOf = (ops: Op[]) =>
|
|
32
32
|
ops.filter((o) => o.op === "add" && parts(o.path).key === "-" && parts(o.path).field === undefined);
|
|
33
33
|
|
|
34
|
-
/** A part as its write names it, after the adds before it (`adds`): "$n" naming one of those, its id
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* before it makes. */
|
|
38
|
-
export function named(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
? Object.fromEntries(Object.entries(v).map(([k, x]) => [k, value(x)]))
|
|
46
|
-
: v;
|
|
47
|
-
};
|
|
34
|
+
/** A part as its write names it, after the adds before it (`adds`): "$n" naming one of those, its id where a link is
|
|
35
|
+
* (`collectionsOf` a document's collections, by its name: src/ops.ts, linksNamed), and as its document the instance it
|
|
36
|
+
* made, where it's an add to its kind's root (`rootOf` a kind's root, by its name); naming one of the part's own,
|
|
37
|
+
* numbered from its first, as a write of one document numbers them. Refused: a document no add before it makes. */
|
|
38
|
+
export function named(
|
|
39
|
+
w: Part,
|
|
40
|
+
adds: Added[],
|
|
41
|
+
rootOf: (name: string) => string | undefined,
|
|
42
|
+
collectionsOf: (name: string) => Linked | undefined,
|
|
43
|
+
): Part {
|
|
44
|
+
const nth = (n: number) => (n <= adds.length ? adds[n - 1]!.id : `$${n - adds.length}`);
|
|
48
45
|
const { name, key = "" } = docParts(w.doc),
|
|
49
46
|
n = NTH.exec(key)?.[1];
|
|
50
47
|
const made = n === undefined ? undefined : adds[Number(n) - 1];
|
|
@@ -54,7 +51,7 @@ export function named(w: Part, adds: Added[], rootOf: (name: string) => string |
|
|
|
54
51
|
return {
|
|
55
52
|
...w,
|
|
56
53
|
doc: made ? w.doc.replace(`:${key}`, `:${made.id}`) : w.doc,
|
|
57
|
-
ops: w.ops.map((o) => (
|
|
54
|
+
ops: w.ops.map((o) => linksNamed(o, collectionsOf(name), nth)),
|
|
58
55
|
};
|
|
59
56
|
}
|
|
60
57
|
|
|
@@ -127,11 +124,12 @@ export function writtenBefore(
|
|
|
127
124
|
state: State,
|
|
128
125
|
write: (state: State, w: Part) => State,
|
|
129
126
|
rootOf: (name: string) => string | undefined,
|
|
127
|
+
collectionsOf: (name: string) => Linked | undefined,
|
|
130
128
|
) {
|
|
131
129
|
const adds: Added[] = [];
|
|
132
130
|
const nameOf = (w: Part) => {
|
|
133
131
|
try {
|
|
134
|
-
return named(w, adds, rootOf);
|
|
132
|
+
return named(w, adds, rootOf, collectionsOf);
|
|
135
133
|
} catch (e) {
|
|
136
134
|
throw new Error(`"${s.story}": ${(e as Error).message}`);
|
|
137
135
|
}
|
package/src/tokens.css
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
--paper: #f8f9fa;
|
|
13
13
|
--card: #ffffff;
|
|
14
14
|
--card-hover: #f0f0f0;
|
|
15
|
+
--pin-ring: #ffffff;
|
|
15
16
|
--well: #e9ecef;
|
|
16
17
|
--ink: #1a1a1a;
|
|
17
18
|
--muted: #555555;
|
|
@@ -37,7 +38,9 @@
|
|
|
37
38
|
--hue-9: #bab0ac;
|
|
38
39
|
--tint: 16%;
|
|
39
40
|
--tint-strong: 28%;
|
|
41
|
+
--choose: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23555555%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20aria-hidden%3D%22true%22%3E%3Cpath%20d%3D%22m6%209%206%206%206-6%22%2F%3E%3C%2Fsvg%3E");
|
|
40
42
|
--sans: system-ui, -apple-system, sans-serif;
|
|
43
|
+
--mono: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
41
44
|
--font-body: 400 15px/1.45 var(--sans);
|
|
42
45
|
--font-display: 650 clamp(34px, 5vw, 52px)/1.05 var(--sans);
|
|
43
46
|
--font-lead: 400 18px/1.55 var(--sans);
|
|
@@ -45,9 +48,9 @@
|
|
|
45
48
|
--font-name: 650 20px/1.25 var(--sans);
|
|
46
49
|
--font-heading: 600 20px/1.25 var(--sans);
|
|
47
50
|
--font-title: 600 17px/1.3 var(--sans);
|
|
48
|
-
--font-row: 400
|
|
51
|
+
--font-row: 400 16px/1.45 var(--sans);
|
|
49
52
|
--font-label: 600 13px/16px var(--sans);
|
|
50
|
-
--font-tool: 400
|
|
53
|
+
--font-tool: 400 16px/1.45 var(--sans);
|
|
51
54
|
--font-small: 400 13px/1.45 var(--sans);
|
|
52
55
|
--font-tiny: 400 12px/1.45 var(--sans);
|
|
53
56
|
--font-field: 400 16px/1.45 var(--sans);
|
|
@@ -72,11 +75,13 @@
|
|
|
72
75
|
--size-finger: 44px;
|
|
73
76
|
--size-touch: 32px;
|
|
74
77
|
--size-control: 32px;
|
|
75
|
-
--size-panel:
|
|
78
|
+
--size-panel: 360px;
|
|
76
79
|
--size-modal: 25rem;
|
|
77
80
|
--size-sheet: 22rem;
|
|
81
|
+
--size-phone: 40rem;
|
|
78
82
|
--size-list: 40rem;
|
|
79
83
|
--size-said: 36rem;
|
|
84
|
+
--size-ring: 2px;
|
|
80
85
|
--size-pin: 16px;
|
|
81
86
|
--size-dot: 7px;
|
|
82
87
|
--size-grip: 7px;
|
|
@@ -142,6 +147,9 @@
|
|
|
142
147
|
--wa-tooltip-background-color: var(--ink);
|
|
143
148
|
--wa-tooltip-content-color: var(--card);
|
|
144
149
|
--wa-tooltip-border-radius: var(--radius);
|
|
150
|
+
--wa-shadow-s: none;
|
|
151
|
+
--wa-shadow-m: none;
|
|
152
|
+
--wa-shadow-l: none;
|
|
145
153
|
}
|
|
146
154
|
@media (prefers-color-scheme: dark) {
|
|
147
155
|
:root {
|
|
@@ -163,5 +171,6 @@
|
|
|
163
171
|
--scrim: rgba(0, 0, 0, 0.55);
|
|
164
172
|
--tint: 28%;
|
|
165
173
|
--tint-strong: 40%;
|
|
174
|
+
--choose: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23a8a8a8%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20aria-hidden%3D%22true%22%3E%3Cpath%20d%3D%22m6%209%206%206%206-6%22%2F%3E%3C%2Fsvg%3E");
|
|
166
175
|
}
|
|
167
176
|
}
|
package/src/tokens.json
CHANGED
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
},
|
|
38
38
|
"usage": "A card under the pointer: a place found, a person's link."
|
|
39
39
|
},
|
|
40
|
+
{
|
|
41
|
+
"name": "pin-ring",
|
|
42
|
+
"value": "#ffffff",
|
|
43
|
+
"usage": "A pin's ring, white in light and dark: the pin stands off the map's tiles, which are light in both."
|
|
44
|
+
},
|
|
40
45
|
{
|
|
41
46
|
"name": "well",
|
|
42
47
|
"value": {
|
|
@@ -196,7 +201,8 @@
|
|
|
196
201
|
"type": {
|
|
197
202
|
"fonts": [],
|
|
198
203
|
"families": {
|
|
199
|
-
"sans": "system-ui, -apple-system, sans-serif"
|
|
204
|
+
"sans": "system-ui, -apple-system, sans-serif",
|
|
205
|
+
"mono": "ui-monospace, SFMono-Regular, Menlo, monospace"
|
|
200
206
|
},
|
|
201
207
|
"groups": [
|
|
202
208
|
{
|
|
@@ -254,10 +260,10 @@
|
|
|
254
260
|
},
|
|
255
261
|
{
|
|
256
262
|
"name": "row",
|
|
257
|
-
"fontSize": "
|
|
263
|
+
"fontSize": "16px",
|
|
258
264
|
"lineHeight": 1.45,
|
|
259
265
|
"fontWeight": 400,
|
|
260
|
-
"usage": "A row's words: a greeting, a member; the words inside a drawer, a modal and a sheet."
|
|
266
|
+
"usage": "A row's words: a greeting, a member; the words inside a drawer, a modal and a sheet. A row is a control: its words are a field's size (Apple's HIG: a control's words are the size of the fields beside it)."
|
|
261
267
|
},
|
|
262
268
|
{
|
|
263
269
|
"name": "label",
|
|
@@ -268,10 +274,10 @@
|
|
|
268
274
|
},
|
|
269
275
|
{
|
|
270
276
|
"name": "tool",
|
|
271
|
-
"fontSize": "
|
|
277
|
+
"fontSize": "16px",
|
|
272
278
|
"lineHeight": 1.45,
|
|
273
279
|
"fontWeight": 400,
|
|
274
|
-
"usage": "A button's
|
|
280
|
+
"usage": "A control's words: a button's, a chip's, a tab's, a link drawn as a button: the size of a field's, never smaller or lighter than the boxes beside it (Apple's HIG). The button that makes or keeps (.act.ink) in 600."
|
|
275
281
|
},
|
|
276
282
|
{
|
|
277
283
|
"name": "small",
|
|
@@ -417,8 +423,8 @@
|
|
|
417
423
|
},
|
|
418
424
|
{
|
|
419
425
|
"name": "panel",
|
|
420
|
-
"value": "
|
|
421
|
-
"usage": "The drawer docked at the right."
|
|
426
|
+
"value": "360px",
|
|
427
|
+
"usage": "The drawer docked at the right: wide enough for its foot's three deeds (Remove, Never mind, Save) on one line, their words a field's size."
|
|
422
428
|
},
|
|
423
429
|
{
|
|
424
430
|
"name": "modal",
|
|
@@ -430,6 +436,11 @@
|
|
|
430
436
|
"value": "22rem",
|
|
431
437
|
"usage": "A sheet's width at most, within the screen less 1rem a side."
|
|
432
438
|
},
|
|
439
|
+
{
|
|
440
|
+
"name": "phone",
|
|
441
|
+
"value": "40rem",
|
|
442
|
+
"usage": "The one breakpoint: below it a phone (a drawer and a sheet rise from the foot, the week is a strip of its days). A stylesheet's @media says it as its value, since CSS reads no custom property there, and a page's matchMedia is joined/parts' phone; tests/sizes.test.ts holds every one to this."
|
|
443
|
+
},
|
|
433
444
|
{
|
|
434
445
|
"name": "list",
|
|
435
446
|
"value": "40rem",
|
|
@@ -440,6 +451,11 @@
|
|
|
440
451
|
"value": "36rem",
|
|
441
452
|
"usage": "A toast's and the group's notice's width at most, as wide as their words, within the screen less 1rem a side."
|
|
442
453
|
},
|
|
454
|
+
{
|
|
455
|
+
"name": "ring",
|
|
456
|
+
"value": "2px",
|
|
457
|
+
"usage": "Focus from the keyboard, an accent ring this wide, this far out."
|
|
458
|
+
},
|
|
443
459
|
{
|
|
444
460
|
"name": "pin",
|
|
445
461
|
"value": "16px",
|
|
@@ -735,6 +751,21 @@
|
|
|
735
751
|
{
|
|
736
752
|
"name": "tooltip-border-radius",
|
|
737
753
|
"value": "var(--radius)"
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
"name": "shadow-s",
|
|
757
|
+
"value": "none",
|
|
758
|
+
"usage": "No shadows (design.md, Layout): a modal, a phone's sheet, a peek and the toast are set apart by their edge and the scrim."
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"name": "shadow-m",
|
|
762
|
+
"value": "none",
|
|
763
|
+
"usage": "No shadows (design.md, Layout): a modal, a phone's sheet, a peek and the toast are set apart by their edge and the scrim."
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"name": "shadow-l",
|
|
767
|
+
"value": "none",
|
|
768
|
+
"usage": "No shadows (design.md, Layout): a modal, a phone's sheet, a peek and the toast are set apart by their edge and the scrim."
|
|
738
769
|
}
|
|
739
770
|
]
|
|
740
771
|
}
|
package/src/tool.ts
CHANGED
|
@@ -98,7 +98,7 @@ export async function applied(map: Reading, tools: Tools, it: Item | null, at: R
|
|
|
98
98
|
item = [...(document.getElementsByTagName(s.tag) as HTMLCollectionOf<Item>)].find(
|
|
99
99
|
(x) => x.isConnected && Object.entries(named).every(([k, v]) => x.data[k] === v),
|
|
100
100
|
);
|
|
101
|
-
if (clears) said(item ? await tools.kept(item.removeItem!()
|
|
101
|
+
if (clears) said(item ? await tools.kept(item.removeItem!()) : undefined);
|
|
102
102
|
else if (item) said(await tools.kept(item.replace!(values(s))));
|
|
103
103
|
else
|
|
104
104
|
said(
|
|
@@ -111,7 +111,7 @@ export async function applied(map: Reading, tools: Tools, it: Item | null, at: R
|
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
if (clears) {
|
|
114
|
-
if (it) said(await tools.kept(it.removeItem!()
|
|
114
|
+
if (it) said(await tools.kept(it.removeItem!()));
|
|
115
115
|
return true;
|
|
116
116
|
}
|
|
117
117
|
for (const t of chosen.filter((t) => t.adds)) {
|
|
@@ -168,16 +168,15 @@ export class Tools {
|
|
|
168
168
|
const kinds = new Set(pressed.map((t) => t.kind));
|
|
169
169
|
return [...pressed, ...this.all.filter((t) => t.default && !kinds.has(t.kind))];
|
|
170
170
|
}
|
|
171
|
-
/** A write of the map's, its version kept as it lands (its `landed
|
|
172
|
-
|
|
173
|
-
async kept(request: Promise<Answer>, from: EventTarget = document) {
|
|
171
|
+
/** A write of the map's, its version kept as it lands (its `landed`, heard on the document), so Undo can put it back. */
|
|
172
|
+
async kept(request: Promise<Answer>) {
|
|
174
173
|
const landed = (e: Event) => this.#made.push((e as CustomEvent<{ doc: string; version: number }>).detail);
|
|
175
|
-
|
|
174
|
+
document.addEventListener("landed", landed);
|
|
176
175
|
this.#sending = request.catch(() => {});
|
|
177
176
|
try {
|
|
178
177
|
return await request;
|
|
179
178
|
} finally {
|
|
180
|
-
|
|
179
|
+
document.removeEventListener("landed", landed);
|
|
181
180
|
this.draw();
|
|
182
181
|
}
|
|
183
182
|
}
|
package/src/upkeep.ts
CHANGED
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
// and on SQLite, which never gives back the pages a removed row left, gathers what the planner reads, or copies the
|
|
3
3
|
// file anywhere, those too (Postgres has its own autovacuum and backups). joined does it when it's idle: a VACUUM and
|
|
4
4
|
// PRAGMA optimize once enough has been written (what's let go first: `trim`, the old changes), and a backup once a day, a copy the store's own size
|
|
5
|
-
// (VACUUM INTO), the last seven kept. A backup is
|
|
5
|
+
// (VACUUM INTO), the last seven kept. A backup is copied to a name of its own (`.part`) and given its name only once
|
|
6
|
+
// it's whole, so a copy cut short (the disk full, joined killed) is never counted as one, nor lets a good one go; one a
|
|
7
|
+
// crash left is cleared as the upkeep starts. A backup is a store: to go back to one, stop joined and put it in the
|
|
6
8
|
// store's place (JOINED_DB), with no -wal or -shm beside it.
|
|
7
9
|
|
|
8
10
|
import type { Engine } from "./engine.ts";
|
|
9
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
closeSync,
|
|
13
|
+
fsyncSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
openSync,
|
|
16
|
+
readdirSync,
|
|
17
|
+
renameSync,
|
|
18
|
+
rmSync,
|
|
19
|
+
statSync,
|
|
20
|
+
unlinkSync,
|
|
21
|
+
} from "node:fs";
|
|
10
22
|
|
|
11
23
|
const IDLE = 10_000; // no write for this long: idle
|
|
12
24
|
const WRITES = 500; // vacuum after this many writes, or an hour after the first
|
|
@@ -32,7 +44,10 @@ export function upkeep(
|
|
|
32
44
|
let lastWrite = 0,
|
|
33
45
|
writes = 0,
|
|
34
46
|
vacuumedAt = Date.now();
|
|
35
|
-
if (sqlite)
|
|
47
|
+
if (sqlite) {
|
|
48
|
+
mkdirSync(backups, { recursive: true });
|
|
49
|
+
for (const part of readdirSync(backups).filter((f) => f.endsWith(PART))) unlinkSync(`${backups}/${part}`);
|
|
50
|
+
}
|
|
36
51
|
const kept = sqlite ? files(backups) : [];
|
|
37
52
|
let backedUpAt = kept.length ? statSync(`${backups}/${kept.at(-1)}`).mtimeMs : 0;
|
|
38
53
|
|
|
@@ -57,7 +72,17 @@ export function upkeep(
|
|
|
57
72
|
}
|
|
58
73
|
if (sqlite && (now || at - backedUpAt > DAY)) {
|
|
59
74
|
done.backup = `${backups}/${new Date(at).toISOString().replace(/[:.]/g, "-")}.sqlite`;
|
|
60
|
-
|
|
75
|
+
const part = done.backup + PART;
|
|
76
|
+
try {
|
|
77
|
+
await db.run("VACUUM INTO ?", [part]);
|
|
78
|
+
// on the disk before it has its name: a power cut never leaves a backup's name on an empty file
|
|
79
|
+
const fd = openSync(part, "r");
|
|
80
|
+
fsyncSync(fd);
|
|
81
|
+
closeSync(fd);
|
|
82
|
+
renameSync(part, done.backup);
|
|
83
|
+
} finally {
|
|
84
|
+
rmSync(part, { force: true });
|
|
85
|
+
}
|
|
61
86
|
backedUpAt = at;
|
|
62
87
|
for (const old of files(backups).slice(0, -KEEP)) unlinkSync(`${backups}/${old}`);
|
|
63
88
|
log(`backed up to ${done.backup}`);
|
|
@@ -77,6 +102,8 @@ export function upkeep(
|
|
|
77
102
|
};
|
|
78
103
|
}
|
|
79
104
|
|
|
105
|
+
/** A backup being copied: not one until it's renamed. */
|
|
106
|
+
const PART = ".part";
|
|
80
107
|
// Backups, oldest first: their names are their times.
|
|
81
108
|
const files = (dir: string) =>
|
|
82
109
|
readdirSync(dir)
|
package/src/views.css
CHANGED
|
@@ -4,14 +4,20 @@
|
|
|
4
4
|
:host {
|
|
5
5
|
display: block;
|
|
6
6
|
}
|
|
7
|
+
/* the tabs in the list's own width, in the middle of a wide page, as the search over them and the rows under them
|
|
8
|
+
are (rows.css, search.css): one column, its edges shared; a wider reading (a week, a month) runs on past it */
|
|
7
9
|
.tabs {
|
|
8
|
-
|
|
10
|
+
max-width: var(--size-list);
|
|
11
|
+
margin-inline: auto;
|
|
9
12
|
}
|
|
10
13
|
.tabs::part(body) {
|
|
11
14
|
display: none;
|
|
12
15
|
}
|
|
13
16
|
.tab {
|
|
14
|
-
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: var(--space-6);
|
|
20
|
+
font: var(--font-tool);
|
|
15
21
|
}
|
|
16
22
|
/* its icon and its word, a space apart: they're laid out in its part, where they're slotted */
|
|
17
23
|
.tab::part(tab) {
|
|
@@ -26,9 +32,6 @@
|
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
@media (max-width: 40rem) {
|
|
29
|
-
.tabs {
|
|
30
|
-
padding-inline: var(--space-12);
|
|
31
|
-
}
|
|
32
35
|
.tab:not([active])::part(tab) {
|
|
33
36
|
justify-content: center;
|
|
34
37
|
min-width: var(--size-finger);
|
|
@@ -38,7 +41,3 @@
|
|
|
38
41
|
display: none;
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
|
-
/* only the chosen reading is shown, whatever display its own sheet gives it */
|
|
42
|
-
::slotted([hidden]) {
|
|
43
|
-
display: none;
|
|
44
|
-
}
|
package/src/views.ts
CHANGED
|
@@ -7,11 +7,16 @@
|
|
|
7
7
|
// <j-plans-rows label="List"><j-plans></j-plans></j-plans-rows>
|
|
8
8
|
// <j-week for="plans"></j-week>
|
|
9
9
|
// <j-map for="plans"></j-map>
|
|
10
|
+
// <my-reading label="Papers" icon="read-only"></my-reading>
|
|
10
11
|
// </j-views>
|
|
12
|
+
//
|
|
13
|
+
// A reading of the app's own says its word (`label`) and its icon (`icon`, one of joined's names). Each tab is a part,
|
|
14
|
+
// `tab` and `tab-<its word>` (j-views::part(tab-papers)); and a reading hidden stays hidden, whatever display its own
|
|
15
|
+
// stylesheet gives it (parts.css).
|
|
11
16
|
|
|
12
17
|
import { el } from "./fields.ts";
|
|
13
18
|
import { icon } from "./icons.ts";
|
|
14
|
-
import type
|
|
19
|
+
import { ICONS, type IconName } from "./icon-names.ts";
|
|
15
20
|
import { adopt } from "./parts.ts";
|
|
16
21
|
import STYLE from "./views.css" with { type: "text" };
|
|
17
22
|
|
|
@@ -55,6 +60,11 @@ export class JViews extends HTMLElement {
|
|
|
55
60
|
#word(r: Element) {
|
|
56
61
|
return r.getAttribute("label") ?? READINGS[r.localName]?.[0] ?? "List";
|
|
57
62
|
}
|
|
63
|
+
/** Each reading's icon: its own (one of joined's names), its kind's, else a list's. */
|
|
64
|
+
#icon(r: Element): IconName {
|
|
65
|
+
const own = r.getAttribute("icon");
|
|
66
|
+
return own && own in ICONS ? (own as IconName) : (READINGS[r.localName]?.[1] ?? "list");
|
|
67
|
+
}
|
|
58
68
|
/** The reading chosen: the address's, else the first. */
|
|
59
69
|
get chosen() {
|
|
60
70
|
const said = new URLSearchParams(location.search).get(this.#param),
|
|
@@ -73,15 +83,22 @@ export class JViews extends HTMLElement {
|
|
|
73
83
|
const chosen = this.chosen,
|
|
74
84
|
all = [...this.children];
|
|
75
85
|
// a tab each (Web Awesome's), made again only when the readings change
|
|
76
|
-
const words = all.map((r) => this.#word(r))
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
const words = all.map((r) => this.#word(r)),
|
|
87
|
+
shows = all.map((r, i) => `${words[i]} ${this.#icon(r)}`).join();
|
|
88
|
+
if (this.#tabs.dataset.shows !== shows) {
|
|
89
|
+
this.#tabs.dataset.shows = shows;
|
|
79
90
|
this.#tabs.replaceChildren(
|
|
80
91
|
...all.map((r, i) =>
|
|
81
92
|
el(
|
|
82
93
|
"wa-tab" as "div",
|
|
83
|
-
{
|
|
84
|
-
|
|
94
|
+
{
|
|
95
|
+
slot: "nav",
|
|
96
|
+
className: "tab",
|
|
97
|
+
part: `tab tab-${words[i]!.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-")}`,
|
|
98
|
+
ariaLabel: words[i],
|
|
99
|
+
title: words[i],
|
|
100
|
+
},
|
|
101
|
+
icon(this.#icon(r)),
|
|
85
102
|
el("span", {}, words[i]!),
|
|
86
103
|
),
|
|
87
104
|
),
|
package/src/week.css
CHANGED
package/src/week.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// from, each marked where it has something. The week shown is kept in the address (?day=2026-11-15).
|
|
8
8
|
|
|
9
9
|
import { follow } from "./follow.ts";
|
|
10
|
+
import { phone } from "./parts.ts";
|
|
10
11
|
import { iconButton } from "./icons.ts";
|
|
11
12
|
import { keep, type Row } from "./keep.ts";
|
|
12
13
|
import { el, Reading } from "./reading.ts";
|
|
@@ -23,7 +24,7 @@ export class JWeek extends Reading {
|
|
|
23
24
|
static override sheets = [SHEET];
|
|
24
25
|
#name = el("h3");
|
|
25
26
|
#strip = el("div", { className: "strip", role: "tablist", ariaLabel: "The week's days" });
|
|
26
|
-
#hours = el("div", { className: "hours", ariaHidden: "true" });
|
|
27
|
+
#hours = el("div", { className: "hours", part: "hours", ariaHidden: "true" });
|
|
27
28
|
#cols = el("div", { className: "cols" });
|
|
28
29
|
#heads = new Map<string, { shows: string; el: HTMLElement }>();
|
|
29
30
|
#days = new Map<string, { shows: string; el: HTMLElement }>();
|
|
@@ -32,12 +33,12 @@ export class JWeek extends Reading {
|
|
|
32
33
|
return this.field("length") ?? this.spec?.fields.find((f) => f.type === "duration");
|
|
33
34
|
}
|
|
34
35
|
protected made() {
|
|
35
|
-
const today = el("button", { type: "button", className: "act small today" }, "Today");
|
|
36
|
+
const today = el("button", { type: "button", className: "act small today", part: "today" }, "Today");
|
|
36
37
|
today.addEventListener("click", () => (this.day = dayOf(now())));
|
|
37
38
|
this.root.append(
|
|
38
39
|
el(
|
|
39
40
|
"header",
|
|
40
|
-
{ className: "head" },
|
|
41
|
+
{ className: "head", part: "head" },
|
|
41
42
|
this.#name,
|
|
42
43
|
today,
|
|
43
44
|
iconButton("back", "The week before", () => (this.day = this.day - 7)),
|
|
@@ -94,11 +95,13 @@ export class JWeek extends Reading {
|
|
|
94
95
|
type: "button",
|
|
95
96
|
role: "tab",
|
|
96
97
|
className: "dayhead",
|
|
98
|
+
part: "day-head",
|
|
97
99
|
ariaLabel: dated(d, { weekday: "long", day: "numeric", month: "long" }),
|
|
98
100
|
},
|
|
99
101
|
el("span", { className: "wd" }, dated(d, { weekday: "short" })),
|
|
100
102
|
el("span", { className: "dn" }, String(new Date(d * DAY).getUTCDate())),
|
|
101
|
-
|
|
103
|
+
// a day with nothing on keeps its mark's room, the mark unseen (never hidden: hidden takes the room too)
|
|
104
|
+
el("i", { className: had.has(d) ? "mark" : "mark none" }),
|
|
102
105
|
);
|
|
103
106
|
b.ariaSelected = String(d === day);
|
|
104
107
|
b.toggleAttribute("today", d === today);
|
|
@@ -141,13 +144,14 @@ export class JWeek extends Reading {
|
|
|
141
144
|
#column(d: number, here: Placed[], first: number, nowAt: number | null) {
|
|
142
145
|
const col = el("div", {
|
|
143
146
|
className: "col",
|
|
147
|
+
part: "day",
|
|
144
148
|
ariaLabel: dated(d, { weekday: "long", day: "numeric", month: "long" }),
|
|
145
149
|
});
|
|
146
150
|
col.toggleAttribute("chosen", d === this.day);
|
|
147
151
|
col.dataset.day = String(d);
|
|
148
152
|
for (const p of here) col.append(this.#block(p, first));
|
|
149
153
|
if (nowAt !== null && nowAt >= 0) {
|
|
150
|
-
const line = el("i", { className: "now", ariaHidden: "true" });
|
|
154
|
+
const line = el("i", { className: "now", part: "now", ariaHidden: "true" });
|
|
151
155
|
line.style.setProperty("--at", String(nowAt / 60));
|
|
152
156
|
col.append(line);
|
|
153
157
|
}
|
|
@@ -175,7 +179,7 @@ export class JWeek extends Reading {
|
|
|
175
179
|
at = local(wall(w)).slice(11, 16),
|
|
176
180
|
b = el(
|
|
177
181
|
"button",
|
|
178
|
-
{ type: "button", className: "item block", title: `${at} ${this.named(p.it)}` },
|
|
182
|
+
{ type: "button", className: "item block", part: "item", title: `${at} ${this.named(p.it)}` },
|
|
179
183
|
el("span", { className: "at" }, at),
|
|
180
184
|
" ",
|
|
181
185
|
el("span", { className: "what" }, this.named(p.it)),
|
|
@@ -194,7 +198,7 @@ export class JWeek extends Reading {
|
|
|
194
198
|
? (dx, dy, done) => {
|
|
195
199
|
const mins = Math.round(((dy / hourPx()) * 60) / SNAP) * SNAP,
|
|
196
200
|
// on a phone, one day is shown: a drag moves within it
|
|
197
|
-
days =
|
|
201
|
+
days = phone.matches ? 0 : Math.round(dx / colPx());
|
|
198
202
|
b.style.translate = done ? "" : `${days * colPx()}px ${(mins / 60) * hourPx()}px`;
|
|
199
203
|
if (done && (mins || days)) void this.change(p.it, { [when]: local(wall(w) + days * DAY + mins * MIN) });
|
|
200
204
|
}
|