@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.
Files changed (109) hide show
  1. package/.claude/skills/joined/reference.md +57 -18
  2. package/docs/design.md +93 -38
  3. package/docs/introduction.md +9 -9
  4. package/docs/light-and-shadow.svg +1 -0
  5. package/docs/links-and-trust.svg +1 -0
  6. package/docs/stories-to-code.svg +2 -1
  7. package/docs/wire-op.svg +1 -0
  8. package/examples/app.css +9 -0
  9. package/examples/cafe/cafe.css +87 -69
  10. package/examples/cafe/generated/staff.elements.ts +7 -2
  11. package/examples/cafe/generated/staff.rules.ts +3 -0
  12. package/examples/cafe/generated/supplies.rules.ts +5 -0
  13. package/examples/cafe/kitchen.css +11 -19
  14. package/examples/cafe/kitchen.ts +6 -2
  15. package/examples/cafe/migrations/002-guard-supplies.ts +15 -0
  16. package/examples/cafe/order.html +2 -1
  17. package/examples/cafe/order.ts +1 -1
  18. package/examples/cafe/staff.json +5 -0
  19. package/examples/cafe/stories.jsonl +4 -2
  20. package/examples/cafe/supplies.html +1 -0
  21. package/examples/cafe/supplies.ts +45 -28
  22. package/examples/cafe/till.ts +14 -10
  23. package/examples/cafe/views.ts +7 -5
  24. package/examples/chart/arches.ts +5 -3
  25. package/examples/chart/chart.css +7 -2
  26. package/examples/desk/desk.css +6 -10
  27. package/examples/desk/generated/elements.ts +1 -1
  28. package/examples/desk/index.html +1 -1
  29. package/examples/desk/lanes.css +21 -19
  30. package/examples/desk/stories.jsonl +1 -1
  31. package/examples/desk/tally.css +1 -1
  32. package/examples/docs.ts +7 -4
  33. package/examples/index.html +16 -7
  34. package/examples/notes/generated/queries.ts +8 -2
  35. package/examples/notes/index.html +1 -1
  36. package/examples/notes/stories.jsonl +3 -0
  37. package/examples/page.ts +9 -2
  38. package/examples/people/links.ts +7 -9
  39. package/examples/people/people.css +1 -1
  40. package/examples/people/view.ts +1 -1
  41. package/examples/trip/generated/elements.ts +1 -1
  42. package/examples/trip/stays.css +1 -1
  43. package/examples/trip/stays.ts +1 -1
  44. package/examples/trips/generated/elements.ts +1 -1
  45. package/examples/trips/trips.css +24 -23
  46. package/examples/welcome.css +41 -33
  47. package/package.json +1 -1
  48. package/src/attachment.ts +17 -2
  49. package/src/board.css +2 -1
  50. package/src/board.ts +4 -4
  51. package/src/cli.ts +14 -2
  52. package/src/compile.ts +255 -77
  53. package/src/definitions.ts +62 -14
  54. package/src/demo.css +2 -5
  55. package/src/draft.ts +10 -4
  56. package/src/drawer.ts +30 -4
  57. package/src/engine.ts +14 -5
  58. package/src/fields.ts +88 -15
  59. package/src/file-value.ts +12 -2
  60. package/src/files.ts +113 -35
  61. package/src/icon-names.ts +4 -0
  62. package/src/keep.ts +16 -3
  63. package/src/map.css +23 -16
  64. package/src/map.ts +3 -3
  65. package/src/mcp.ts +24 -3
  66. package/src/members/group.ts +41 -17
  67. package/src/members/keys.ts +3 -3
  68. package/src/members/panel.css +17 -18
  69. package/src/members/panel.ts +9 -2
  70. package/src/migrate.ts +58 -21
  71. package/src/migrations/005-change-kept.ts +7 -0
  72. package/src/month.css +6 -2
  73. package/src/month.ts +5 -5
  74. package/src/ops.ts +40 -1
  75. package/src/page.css +3 -2
  76. package/src/page.ts +64 -16
  77. package/src/parts.css +178 -86
  78. package/src/parts.ts +60 -20
  79. package/src/plane.css +9 -4
  80. package/src/plane.ts +4 -2
  81. package/src/reading.css +1 -5
  82. package/src/rows.css +2 -21
  83. package/src/rows.ts +123 -39
  84. package/src/server.ts +157 -30
  85. package/src/sheet.ts +4 -2
  86. package/src/slots.css +0 -4
  87. package/src/specs.ts +1 -1
  88. package/src/starter.ts +15 -1
  89. package/src/store.ts +40 -18
  90. package/src/surface.ts +7 -2
  91. package/src/time.ts +2 -0
  92. package/src/timeline.ts +14 -5
  93. package/src/together.ts +15 -17
  94. package/src/tokens.css +12 -3
  95. package/src/tokens.json +38 -7
  96. package/src/tool.ts +6 -7
  97. package/src/upkeep.ts +31 -4
  98. package/src/views.css +8 -9
  99. package/src/views.ts +23 -6
  100. package/src/week.css +1 -2
  101. package/src/week.ts +11 -7
  102. package/src/write.ts +130 -15
  103. package/starter/CHANGELOG.md +8 -0
  104. package/starter/CLAUDE.md +7 -1
  105. package/starter/bunfig +2 -1
  106. package/starter/githooks/pre-commit +13 -0
  107. package/starter/prettierignore +1 -0
  108. package/starter/tests/records.test.ts +40 -0
  109. package/starter/todo.jsonl +0 -0
@@ -25,7 +25,7 @@ export class Person extends JPerson {
25
25
  #said = Object.assign(document.createElement("p"), { className: "said", role: "status" }); // a refusal's why
26
26
  // taken off the list: asked first, in a modal (design.md)
27
27
  #gone = iconButton("person-remove", "", () =>
28
- askOnPage(`Take ${this.data.name} off the list?`, () => said(this.#said, this.removeItem())),
28
+ askOnPage(`${this.data.name} will be taken off the list.`, () => said(this.#said, this.removeItem())),
29
29
  );
30
30
  connectedCallback() {
31
31
  if (this.childElementCount) return this.draw();
@@ -17,7 +17,7 @@ const send = (from: Element, ops: object[], why?: string) => new Promise<Answer>
17
17
  /** An event's fields, as the stories give them. */
18
18
  export type JEventData = { "title": string; "start": string; "duration": string; "location"?: string; "coordinates"?: string; "people"?: number[]; "zone"?: string; "asked"?: number[]; "keen"?: number[]; "declined"?: number[]; "arrives"?: number[]; "leaves"?: number[] };
19
19
  /** An add of an event, as it's sent: its fields as the stories write them. */
20
- export type JEventValue = { "title": string; "start": string; "duration": string; "location"?: string; "coordinates"?: string; "people"?: number[]; "zone"?: string; "asked"?: number[]; "keen"?: number[]; "declined"?: number[]; "arrives"?: number[]; "leaves"?: number[] };
20
+ export type JEventValue = { "title": string; "start": string; "duration": string; "location"?: string; "coordinates"?: string; "people"?: (number | `$${number}`)[]; "zone"?: string; "asked"?: (number | `$${number}`)[]; "keen"?: (number | `$${number}`)[]; "declined"?: (number | `$${number}`)[]; "arrives"?: (number | `$${number}`)[]; "leaves"?: (number | `$${number}`)[] };
21
21
 
22
22
  /** <j-event key>: title (string), start (date-time), duration (duration), location (string), coordinates (place), people (ids in people), zone (zone), asked (ids in people), keen (ids in people), declined (ids in people), arrives (ids in people), leaves (ids in people), each an attribute. */
23
23
  export class JEvent extends HTMLElement {
@@ -11,7 +11,7 @@ j-stay {
11
11
  align-items: center;
12
12
  }
13
13
  j-stay .stripe {
14
- width: 3px;
14
+ width: var(--size-stripe);
15
15
  align-self: stretch;
16
16
  grid-row: span 2;
17
17
  border-radius: 2px;
@@ -15,7 +15,7 @@ export class Stay extends JStay {
15
15
  #when = Object.assign(document.createElement("p"), { className: "when" });
16
16
  #said = Object.assign(document.createElement("p"), { className: "said", role: "status" });
17
17
  #gone = iconButton("remove", "", () =>
18
- askOnPage(`Cancel ${this.data.name}?`, () => said(this.#said, this.removeItem()), "Cancel it"),
18
+ askOnPage(`${this.data.name} will be cancelled.`, () => said(this.#said, this.removeItem()), "Cancel it"),
19
19
  );
20
20
  connectedCallback() {
21
21
  if (this.childElementCount) return this.draw();
@@ -17,7 +17,7 @@ const send = (from: Element, ops: object[], why?: string) => new Promise<Answer>
17
17
  /** A trip's fields, as the stories give them. */
18
18
  export type JTripData = { "name": string; "organisers": number[]; "travellers": number[] };
19
19
  /** An add of a trip, as it's sent: its fields as the stories write them. */
20
- export type JTripValue = { "name": string; "organisers": number[]; "travellers": number[] };
20
+ export type JTripValue = { "name": string; "organisers": (number | `$${number}`)[]; "travellers": (number | `$${number}`)[] };
21
21
 
22
22
  /** <j-trip key>: name (string), organisers (ids in members), travellers (ids in members), each an attribute. */
23
23
  export class JTrip extends HTMLElement {
@@ -6,7 +6,6 @@
6
6
  display: flex;
7
7
  align-items: center;
8
8
  gap: var(--space-16);
9
- padding: var(--space-20) 0 0;
10
9
  }
11
10
  .trips .brand {
12
11
  flex: 1;
@@ -27,7 +26,7 @@
27
26
  margin: 0;
28
27
  }
29
28
  .trips .head .new {
30
- min-height: 44px;
29
+ min-height: var(--size-finger);
31
30
  padding: 0 var(--space-16);
32
31
  }
33
32
 
@@ -47,7 +46,7 @@ j-trips:empty::before {
47
46
  min-height: 18rem;
48
47
  background: var(--card);
49
48
  border: 1px solid var(--edge);
50
- border-radius: 4px;
49
+ border-radius: var(--radius);
51
50
  overflow: hidden;
52
51
  color: var(--ink);
53
52
  text-decoration: none;
@@ -76,30 +75,32 @@ j-trips:empty::before {
76
75
  width: 256px;
77
76
  height: 256px;
78
77
  }
78
+ /* a pin: solid in its hue, in a white ring (design.md, Colour); no shadow */
79
79
  .map .pin {
80
80
  position: absolute;
81
- width: 14px;
82
- height: 14px;
83
- margin: -7px 0 0 -7px;
84
- border: 2px solid var(--card);
85
- border-radius: 50%;
81
+ box-sizing: border-box;
82
+ width: var(--size-pin);
83
+ height: var(--size-pin);
84
+ margin: calc(var(--size-pin) / -2) 0 0 calc(var(--size-pin) / -2);
85
+ border: var(--size-ring) solid var(--pin-ring);
86
+ border-radius: var(--radius-dot);
86
87
  background: var(--hue);
87
- box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25);
88
88
  }
89
89
  .map small {
90
90
  position: absolute;
91
- right: 4px;
92
- bottom: 4px;
93
- padding: 0 4px;
94
- border-radius: 3px;
95
- background: rgb(255 255 255 / 0.8);
96
- color: #333;
91
+ right: var(--space-4);
92
+ bottom: var(--space-4);
93
+ padding: 0 var(--space-4);
94
+ border-radius: var(--radius-inner);
95
+ background: color-mix(in srgb, var(--card) 80%, transparent);
96
+ color: var(--muted);
97
97
  font: var(--font-tiny);
98
98
  }
99
99
  .map.none {
100
100
  display: grid;
101
101
  place-items: center;
102
- background: color-mix(in srgb, var(--hue-3) var(--tint), var(--card));
102
+ /* no map yet: the well, as a map before its tiles (design.md, Colour); a hue is a thing's, and this is none */
103
+ background: var(--well);
103
104
  color: var(--muted);
104
105
  font: var(--font-small);
105
106
  }
@@ -120,10 +121,10 @@ j-trips:empty::before {
120
121
  }
121
122
  .next {
122
123
  display: grid;
123
- gap: 2px;
124
+ gap: var(--space-4);
124
125
  padding: var(--space-10) var(--space-12);
125
- border-radius: 3px;
126
- background: color-mix(in srgb, var(--hue-0) var(--tint), var(--card));
126
+ border-radius: var(--radius-inner);
127
+ background: var(--well);
127
128
  font: var(--font-small);
128
129
  }
129
130
  .next .label {
@@ -151,22 +152,22 @@ j-trips:empty::before {
151
152
  }
152
153
 
153
154
  /* New trip: its name, and who travels, a tick each */
154
- dialog.new-trip fieldset {
155
+ wa-dialog.new-trip fieldset {
155
156
  display: grid;
156
157
  gap: var(--space-6);
157
158
  margin: 0;
158
159
  padding: 0;
159
160
  border: 0;
160
161
  }
161
- dialog.new-trip legend {
162
+ wa-dialog.new-trip legend {
162
163
  margin-bottom: var(--space-6);
163
164
  font: var(--font-label);
164
165
  }
165
- dialog.new-trip label.tick {
166
+ wa-dialog.new-trip label.tick {
166
167
  display: flex;
167
168
  justify-content: space-between;
168
169
  align-items: center;
169
- min-height: 36px;
170
+ min-height: var(--size-touch);
170
171
  font: var(--font-row);
171
172
  }
172
173
 
@@ -7,7 +7,6 @@
7
7
  flex-wrap: wrap;
8
8
  align-items: center;
9
9
  gap: var(--space-12) var(--space-24);
10
- padding: var(--space-20) 0 0;
11
10
  }
12
11
  .welcome .brand {
13
12
  margin: 0;
@@ -20,8 +19,16 @@
20
19
  font: var(--font-row);
21
20
  }
22
21
  .welcome nav a {
22
+ display: inline-flex;
23
+ align-items: center;
24
+ min-height: var(--size-touch);
23
25
  text-decoration: none;
24
26
  }
27
+ @media (max-width: 40rem), (pointer: coarse) {
28
+ .welcome nav a {
29
+ min-height: var(--size-finger);
30
+ }
31
+ }
25
32
  .welcome nav a:hover,
26
33
  .welcome .examples a:hover .open {
27
34
  text-decoration: underline;
@@ -74,7 +81,7 @@
74
81
  margin: var(--space-4) 0 0;
75
82
  }
76
83
  .hero .go .act {
77
- min-height: 44px;
84
+ min-height: var(--size-finger);
78
85
  padding: 0 var(--space-16);
79
86
  text-decoration: none;
80
87
  }
@@ -83,20 +90,18 @@
83
90
  display: grid;
84
91
  gap: var(--space-10);
85
92
  }
86
- /* the trip's picture (docs/trip.png, 1440 by 1240, by bun run design), cut to its page from the top of its head to
87
- the dinner: its margins and its drawer left out */
93
+ /* the trip's picture, light or dark as the page is, cut by the build to the page as far as its week and map run
94
+ (design/scenes.ts): drawn whole, never cropped here */
88
95
  .hero .frame {
89
- aspect-ratio: 1096 / 1128;
90
96
  overflow: hidden;
91
97
  border: 1px solid var(--edge);
92
- border-radius: 4px;
98
+ border-radius: var(--radius);
93
99
  background: var(--paper);
94
100
  }
95
101
  .hero .frame img {
96
102
  display: block;
97
- width: 131.4%;
103
+ width: 100%;
98
104
  height: auto;
99
- margin: -1.1% 0 0 -1.46%;
100
105
  }
101
106
  .hero figcaption {
102
107
  font: var(--font-small);
@@ -117,7 +122,7 @@
117
122
  padding: 0 0 var(--space-16);
118
123
  background: var(--card);
119
124
  border: 1px solid var(--edge);
120
- border-radius: 4px;
125
+ border-radius: var(--radius);
121
126
  overflow: hidden;
122
127
  color: var(--ink);
123
128
  text-decoration: none;
@@ -151,14 +156,19 @@
151
156
  }
152
157
  /* (not .cafe: the cafe's own page has that, and the design system holds both) */
153
158
  .picture.tickets {
159
+ align-items: flex-start;
154
160
  background: color-mix(in srgb, var(--hue-1) var(--tint), var(--card));
155
161
  }
162
+ /* (a picture light or dark: the picture element only chooses, the img is what's drawn) */
163
+ .examples picture {
164
+ display: contents;
165
+ }
156
166
  /* the trip read as a line, its beads and their events */
157
167
  .picture.shot {
158
168
  width: 100%;
159
169
  padding: 0;
160
170
  object-fit: cover;
161
- object-position: 50% 60%;
171
+ object-position: top;
162
172
  border-bottom: 1px solid var(--line);
163
173
  }
164
174
  .mini {
@@ -171,7 +181,7 @@
171
181
  box-sizing: border-box;
172
182
  background: var(--card);
173
183
  border: 1px solid var(--edge);
174
- border-radius: 4px;
184
+ border-radius: var(--radius);
175
185
  font: var(--font-small);
176
186
  }
177
187
  .mini > b {
@@ -180,12 +190,12 @@
180
190
  }
181
191
  .mini .field {
182
192
  border: 1px solid var(--edge);
183
- border-radius: 4px;
193
+ border-radius: var(--radius);
184
194
  padding: var(--space-4) var(--space-8);
185
195
  color: var(--muted);
186
196
  }
187
197
  .mini .button {
188
- border-radius: 4px;
198
+ border-radius: var(--radius);
189
199
  padding: var(--space-4) var(--space-10);
190
200
  background: var(--ink);
191
201
  color: var(--card);
@@ -204,10 +214,10 @@
204
214
  }
205
215
  .pill {
206
216
  align-self: flex-start;
207
- border-radius: 99px;
217
+ border-radius: var(--radius-pill);
208
218
  padding: 0 var(--space-8);
209
- background: var(--hue-1);
210
- color: #111;
219
+ background: color-mix(in srgb, var(--hue-1) var(--tint-strong), var(--card));
220
+ color: var(--ink);
211
221
  font: var(--font-tiny);
212
222
  }
213
223
  .pill.ready {
@@ -237,13 +247,12 @@
237
247
  padding: var(--space-12) var(--space-14);
238
248
  background: var(--card);
239
249
  border: 1px solid var(--edge);
240
- border-radius: 4px;
241
- font:
242
- 400 12.5px/1.55 ui-monospace,
243
- Menlo,
244
- monospace;
245
- white-space: pre;
246
- overflow-x: auto;
250
+ border-radius: var(--radius);
251
+ /* the small style, in a monospace face; a line wrapped, never cut at the box's edge */
252
+ font: var(--font-small);
253
+ font-family: var(--mono);
254
+ white-space: pre-wrap;
255
+ overflow-wrap: anywhere;
247
256
  }
248
257
 
249
258
  /* what two AIs said, in ink (a .said is a refusal, in danger), side by side where there's room */
@@ -267,16 +276,22 @@ section.quotes figcaption {
267
276
  font: var(--font-small);
268
277
  }
269
278
 
270
- /* the film */
279
+ /* the film: its own play at the poster's foot, at its start (the poster's words are at its middle) */
271
280
  figure.film {
281
+ position: relative;
272
282
  margin: var(--space-48) 0 0;
273
283
  }
284
+ figure.film .play {
285
+ position: absolute;
286
+ left: var(--space-16);
287
+ top: var(--space-16);
288
+ }
274
289
  figure.film video {
275
290
  display: block;
276
291
  width: 100%;
277
292
  height: auto;
278
- border-radius: 4px;
279
- background: #1a1f36;
293
+ border-radius: var(--radius);
294
+ background: var(--well);
280
295
  }
281
296
  figure.film figcaption {
282
297
  margin-top: var(--space-8);
@@ -291,11 +306,4 @@ figure.film figcaption {
291
306
  .welcome .brand {
292
307
  flex: 1;
293
308
  }
294
- .hero .frame {
295
- aspect-ratio: 375 / 600;
296
- }
297
- .hero .frame img {
298
- width: 100%;
299
- margin: -94.5% 0 0;
300
- }
301
309
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueshed/joined",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Compiled documents, talking to web components as elements in the DOM.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/attachment.ts CHANGED
@@ -43,6 +43,17 @@ export function attachment(doc: () => string, put: (file: string) => Promise<Ans
43
43
  const choose = Object.assign(document.createElement("label"), { className: "act small" });
44
44
  choose.append(icon("upload"), words, input);
45
45
  const line = Object.assign(document.createElement("p"), { className: "said", role: "status" });
46
+ // the file just chosen, as this browser has it: shown until the server serves it, which it does only once an item
47
+ // names it (a drawer's draft, before Save)
48
+ let chosen: { value: string; url: string } | null = null;
49
+ picture.addEventListener("error", () => {
50
+ if (
51
+ chosen &&
52
+ picture.getAttribute("src") !== chosen.url &&
53
+ shown.getAttribute("href")?.endsWith(chosen.value.slice("file:".length))
54
+ )
55
+ picture.src = chosen.url;
56
+ });
46
57
  const off = iconButton("remove", "Take the file off", () => void said(line, take!()));
47
58
  el.append(shown, choose, off, line);
48
59
  input.addEventListener("change", async () => {
@@ -53,13 +64,17 @@ export function attachment(doc: () => string, put: (file: string) => Promise<Ans
53
64
  const kept = await upload(doc(), file);
54
65
  [input.disabled, choose.ariaBusy, input.value] = [false, null, ""];
55
66
  if ("refused" in kept) line.textContent = `Refused: ${kept.refused}`;
56
- else await said(line, put(kept.file));
67
+ else {
68
+ if (chosen) URL.revokeObjectURL(chosen.url);
69
+ chosen = { value: kept.file, url: URL.createObjectURL(file) };
70
+ await said(line, put(kept.file));
71
+ }
57
72
  });
58
73
  return {
59
74
  el,
60
75
  /** Drawn as the item has it: its value, and whether its person may put a file in it, or take it off. */
61
76
  draw(value: string | undefined, may: { put?: boolean; take?: boolean } = {}) {
62
- const url = value && fileUrl(value);
77
+ const url = value && fileUrl(value, doc());
63
78
  if (url && shown.getAttribute("href") !== url) {
64
79
  // a PDF or a Markdown file, a link to it, named; a photo or an SVG, its picture
65
80
  const linked = url.endsWith(".pdf") ? "PDF" : url.endsWith(".md") ? "Markdown" : undefined;
package/src/board.css CHANGED
@@ -18,7 +18,8 @@
18
18
  background: var(--well);
19
19
  }
20
20
  .lane[over] {
21
- box-shadow: inset 0 0 0 calc(var(--space-4) / 2) var(--accent);
21
+ outline: var(--size-ring) solid var(--accent);
22
+ outline-offset: calc(-1 * var(--size-ring));
22
23
  }
23
24
  .lane h3 {
24
25
  display: flex;
package/src/board.ts CHANGED
@@ -87,13 +87,13 @@ export class JBoard extends Reading {
87
87
  const k = key(lane.value);
88
88
  let d = this.#lanes.get(k);
89
89
  if (!d) {
90
- const count = el("span", { className: "count" }),
90
+ const count = el("span", { className: "count", part: "count" }),
91
91
  list = el("ol"),
92
- add = el("button", { type: "button", className: "act small adding" }, icon("add"), "Add");
92
+ add = el("button", { type: "button", className: "act small adding", part: "add" }, icon("add"), "Add");
93
93
  add.addEventListener("click", () => this.add(lane.value === undefined ? {} : { [f.name]: lane.value }));
94
94
  const section = el(
95
95
  "section",
96
- { className: "lane", ariaLabel: lane.words },
96
+ { className: "lane", part: "lane", ariaLabel: lane.words },
97
97
  el("h3", {}, lane.words, count),
98
98
  list,
99
99
  add,
@@ -131,7 +131,7 @@ export class JBoard extends Reading {
131
131
  const w = when ? it.data[when] : undefined,
132
132
  card = el(
133
133
  "button",
134
- { type: "button", className: "item card" },
134
+ { type: "button", className: "item card", part: "item" },
135
135
  el("span", { className: "what" }, this.named(it)),
136
136
  ...(typeof w === "string"
137
137
  ? [
package/src/cli.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // joined init an app's folder begun: hello, the skill, a CLAUDE.md, the scripts (./starter.ts)
5
5
  // joined upgrade [version] joined at another version (the newest, if none is said), the skill refreshed
6
6
  // joined compile [dir] each app's generated/ and its next migration, from its stories
7
- // joined start [dir] the apps served, on PORT or 3380
7
+ // joined start [dir] the apps served, on PORT or 3380, until it's stopped (SIGTERM, Ctrl-C): its store closed
8
8
  // joined link <name> a member's link, printed
9
9
  // joined page show <doc> a document as a member sees it, by their link (JOINED_LINK, never printed)
10
10
  // joined page watch <doc> each change to it, a line each, as it comes
@@ -25,12 +25,24 @@ export async function run([command, arg, ...rest]: string[], dir = arg ? resolve
25
25
  if (command === "init") return init(process.cwd());
26
26
  if (command === "upgrade") return upgrade(arg, process.cwd());
27
27
  if (command === "compile") return [await writeAll(dir)];
28
- if (command === "start") return await startUp(await start({ dir }));
28
+ if (command === "start") {
29
+ const server = await start({ dir }),
30
+ stop = stopping(server);
31
+ // stopped by its host (a deploy's SIGTERM, a Ctrl-C): the server stopped and its store closed, then gone
32
+ for (const signal of ["SIGTERM", "SIGINT"] as const) process.once(signal, stop);
33
+ return await startUp(server);
34
+ }
29
35
  if (command === "link") return [await linkFor(arg, {})];
30
36
  if (command === "page") return paged(arg, rest);
31
37
  throw new Error(USAGE);
32
38
  }
33
39
 
40
+ /** How joined goes when it's told to: its server stopped, which closes its store (a SQLite file whole, its -wal folded
41
+ * in), then the process gone, as asked. */
42
+ export const stopping =
43
+ (server: { stop(closeActive?: boolean): Promise<unknown> }, exit: (code: number) => unknown = process.exit) =>
44
+ async () => (await server.stop(true), exit(0));
45
+
34
46
  /** A member's page, from a terminal: by their link in JOINED_LINK, a document shown, watched, or written. */
35
47
  async function paged(what: string | undefined, [doc, ops, why]: string[]) {
36
48
  const link = Bun.env.JOINED_LINK;