@blueshed/joined 0.0.0-stage → 0.1.20
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/SKILL.md +17 -0
- package/.claude/skills/joined/reference.md +768 -0
- package/LICENSE +19 -0
- package/README.md +115 -2
- package/docs/design.md +148 -0
- package/docs/introduction.md +193 -0
- package/docs/learning.md +76 -0
- package/docs/stories.md +82 -0
- package/examples/app.css +27 -0
- package/examples/cafe/books.html +38 -0
- package/examples/cafe/books.json +13 -0
- package/examples/cafe/books.ts +64 -0
- package/examples/cafe/cafe.css +512 -0
- package/examples/cafe/front.html +115 -0
- package/examples/cafe/front.ts +7 -0
- package/examples/cafe/generated/books.elements.ts +52 -0
- package/examples/cafe/generated/books.queries.ts +11 -0
- package/examples/cafe/generated/books.rules.ts +42 -0
- package/examples/cafe/generated/kitchen.elements.ts +87 -0
- package/examples/cafe/generated/kitchen.queries.ts +47 -0
- package/examples/cafe/generated/kitchen.rules.ts +98 -0
- package/examples/cafe/generated/menu.elements.ts +61 -0
- package/examples/cafe/generated/menu.queries.ts +28 -0
- package/examples/cafe/generated/menu.rules.ts +65 -0
- package/examples/cafe/generated/order.elements.ts +87 -0
- package/examples/cafe/generated/order.queries.ts +47 -0
- package/examples/cafe/generated/order.rules.ts +95 -0
- package/examples/cafe/generated/staff.elements.ts +55 -0
- package/examples/cafe/generated/staff.queries.ts +27 -0
- package/examples/cafe/generated/staff.rules.ts +59 -0
- package/examples/cafe/generated/supplies.elements.ts +62 -0
- package/examples/cafe/generated/supplies.queries.ts +43 -0
- package/examples/cafe/generated/supplies.rules.ts +84 -0
- package/examples/cafe/generated/till.elements.ts +93 -0
- package/examples/cafe/generated/till.queries.ts +57 -0
- package/examples/cafe/generated/till.rules.ts +113 -0
- package/examples/cafe/index.html +70 -0
- package/examples/cafe/kitchen.css +107 -0
- package/examples/cafe/kitchen.html +39 -0
- package/examples/cafe/kitchen.ts +125 -0
- package/examples/cafe/menu.html +55 -0
- package/examples/cafe/menu.json +41 -0
- package/examples/cafe/menu.ts +84 -0
- package/examples/cafe/migrations/001-cafe.ts +11 -0
- package/examples/cafe/order.html +37 -0
- package/examples/cafe/order.ts +45 -0
- package/examples/cafe/rail-drag.ts +30 -0
- package/examples/cafe/routes.ts +32 -0
- package/examples/cafe/staff.json +20 -0
- package/examples/cafe/stories.jsonl +43 -0
- package/examples/cafe/supplies.html +77 -0
- package/examples/cafe/supplies.json +33 -0
- package/examples/cafe/supplies.ts +170 -0
- package/examples/cafe/till.json +95 -0
- package/examples/cafe/till.ts +122 -0
- package/examples/cafe/trust.ts +20 -0
- package/examples/cafe/views.ts +171 -0
- package/examples/docs.ts +28 -0
- package/examples/film.jpg +0 -0
- package/examples/hello/generated/elements.ts +45 -0
- package/examples/hello/generated/queries.ts +24 -0
- package/examples/hello/generated/rules.ts +45 -0
- package/examples/hello/hello.css +27 -0
- package/examples/hello/hello.json +1 -0
- package/examples/hello/index.html +32 -0
- package/examples/hello/migrations/001-hello.ts +6 -0
- package/examples/hello/page.ts +49 -0
- package/examples/hello/routes.ts +6 -0
- package/examples/hello/stories.jsonl +3 -0
- package/examples/index.html +146 -0
- package/examples/page.ts +11 -0
- package/examples/people/adding.ts +20 -0
- package/examples/people/generated/elements.ts +68 -0
- package/examples/people/generated/queries.ts +28 -0
- package/examples/people/generated/rules.ts +85 -0
- package/examples/people/links.ts +124 -0
- package/examples/people/migrations/001-people.ts +6 -0
- package/examples/people/migrations/002-add-people-member-and-guard-people.ts +7 -0
- package/examples/people/migrations/003-add-people-rank-and-guard-people.ts +7 -0
- package/examples/people/order.ts +61 -0
- package/examples/people/people.css +65 -0
- package/examples/people/people.json +26 -0
- package/examples/people/routes.ts +12 -0
- package/examples/people/stories.jsonl +20 -0
- package/examples/people/trust.ts +14 -0
- package/examples/people/view.ts +115 -0
- package/examples/routes.ts +11 -0
- package/examples/trip/answer-rows.ts +70 -0
- package/examples/trip/answers.ts +11 -0
- package/examples/trip/bar.ts +89 -0
- package/examples/trip/calendar-map.css +709 -0
- package/examples/trip/calendar-map.ts +249 -0
- package/examples/trip/drags.ts +143 -0
- package/examples/trip/drawer.ts +250 -0
- package/examples/trip/event-form.ts +199 -0
- package/examples/trip/generated/elements.ts +144 -0
- package/examples/trip/generated/queries.ts +46 -0
- package/examples/trip/generated/rules.ts +239 -0
- package/examples/trip/holding.ts +61 -0
- package/examples/trip/ics.ts +117 -0
- package/examples/trip/index.html +82 -0
- package/examples/trip/line-stops.ts +92 -0
- package/examples/trip/line-words.ts +79 -0
- package/examples/trip/line.ts +121 -0
- package/examples/trip/map.ts +234 -0
- package/examples/trip/mercator.ts +28 -0
- package/examples/trip/migrations/001-trip.ts +7 -0
- package/examples/trip/migrations/002-add-events-zone-and-guard-events.ts +7 -0
- package/examples/trip/migrations/003-guard-events-and-create-events_asked-and-more.ts +9 -0
- package/examples/trip/migrations/004-create-stays.ts +6 -0
- package/examples/trip/migrations/005-guard-events-and-create-events_arrives-and-more.ts +8 -0
- package/examples/trip/month.ts +87 -0
- package/examples/trip/other-weeks.ts +67 -0
- package/examples/trip/page.ts +121 -0
- package/examples/trip/peek.ts +71 -0
- package/examples/trip/people-chips.ts +74 -0
- package/examples/trip/place-search.ts +51 -0
- package/examples/trip/places.ts +34 -0
- package/examples/trip/routes.ts +27 -0
- package/examples/trip/shell.ts +39 -0
- package/examples/trip/stays.css +51 -0
- package/examples/trip/stays.ts +68 -0
- package/examples/trip/stories.jsonl +72 -0
- package/examples/trip/time.ts +46 -0
- package/examples/trip/told.ts +48 -0
- package/examples/trip/trip.json +69 -0
- package/examples/trip/trust.ts +51 -0
- package/examples/trip/week.ts +237 -0
- package/examples/trip/words.ts +4 -0
- package/examples/trip/writes.ts +91 -0
- package/examples/trip/zones.ts +16 -0
- package/examples/trips/card.ts +149 -0
- package/examples/trips/generated/elements.ts +60 -0
- package/examples/trips/generated/queries.ts +28 -0
- package/examples/trips/generated/rules.ts +62 -0
- package/examples/trips/index.html +47 -0
- package/examples/trips/map.ts +52 -0
- package/examples/trips/migrations/001-trips.ts +8 -0
- package/examples/trips/new-trip.ts +46 -0
- package/examples/trips/page.ts +9 -0
- package/examples/trips/routes.ts +7 -0
- package/examples/trips/stories.jsonl +12 -0
- package/examples/trips/trips.css +183 -0
- package/examples/trips/trips.json +7 -0
- package/examples/weeks/derive.ts +23 -0
- package/examples/weeks/generated/elements.ts +52 -0
- package/examples/weeks/generated/rules.ts +33 -0
- package/examples/weeks/routes.ts +4 -0
- package/examples/weeks/weeks.json +1 -0
- package/examples/welcome.css +299 -0
- package/package.json +55 -4
- package/src/attachment.ts +70 -0
- package/src/cli.ts +52 -0
- package/src/client.ts +98 -0
- package/src/compile.ts +2034 -0
- package/src/css.d.ts +5 -0
- package/src/definitions.ts +268 -0
- package/src/demo.css +29 -0
- package/src/demo.ts +42 -0
- package/src/draft.ts +69 -0
- package/src/engine.ts +288 -0
- package/src/file-value.ts +13 -0
- package/src/files.ts +187 -0
- package/src/follow.ts +56 -0
- package/src/hues.ts +3 -0
- package/src/icon-names.ts +77 -0
- package/src/icon.png +0 -0
- package/src/icons.ts +32 -0
- package/src/keep.ts +33 -0
- package/src/link.ts +31 -0
- package/src/mcp.ts +252 -0
- package/src/members/demo.ts +53 -0
- package/src/members/generated/elements.ts +68 -0
- package/src/members/generated/queries.ts +29 -0
- package/src/members/generated/rules.ts +65 -0
- package/src/members/group.ts +294 -0
- package/src/members/keys.ts +221 -0
- package/src/members/members.json +9 -0
- package/src/members/migrations/001-members.ts +6 -0
- package/src/members/migrations/002-guard-members.ts +11 -0
- package/src/members/migrations/003-add-members-act-and-guard-members.ts +7 -0
- package/src/members/panel.css +208 -0
- package/src/members/panel.ts +398 -0
- package/src/members/routes.ts +4 -0
- package/src/members/stories.jsonl +27 -0
- package/src/members/trust.ts +116 -0
- package/src/migrate.ts +597 -0
- package/src/migrations/001-joined.ts +13 -0
- package/src/migrations/002-group-keys.ts +16 -0
- package/src/migrations/003-change-inverse.ts +10 -0
- package/src/migrations/004-change-followed.ts +6 -0
- package/src/ops.ts +61 -0
- package/src/page.css +79 -0
- package/src/page.ts +413 -0
- package/src/parts.css +471 -0
- package/src/parts.ts +152 -0
- package/src/server.ts +862 -0
- package/src/settings.ts +94 -0
- package/src/starter.ts +89 -0
- package/src/store.ts +815 -0
- package/src/stories.ts +387 -0
- package/src/toast.ts +52 -0
- package/src/together.ts +167 -0
- package/src/tokens.css +85 -0
- package/src/tokens.json +457 -0
- package/src/upkeep.ts +86 -0
- package/src/visitors.ts +43 -0
- package/src/write.ts +567 -0
- package/starter/CLAUDE.md +37 -0
- package/starter/gitignore +3 -0
- package/starter/tests/hello-page.test.ts +14 -0
- package/starter/tests/hello.test.ts +8 -0
- package/starter/tsconfig.json +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "weeks": [{ "id": 1, "trip": 1, "week": "2026-11-02", "events": 4 }] }
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/* The root page's look: what joined is, then the trip at work beside it; three apps to try, each with a picture
|
|
2
|
+
of itself; how it's made, in three steps; what two AIs said; the film. Its sizes are the tokens' display,
|
|
3
|
+
lead, section and name; the rest is joined's parts. */
|
|
4
|
+
|
|
5
|
+
.welcome > header {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: var(--space-12) var(--space-24);
|
|
10
|
+
padding: var(--space-20) 0 0;
|
|
11
|
+
}
|
|
12
|
+
.welcome .brand {
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
.welcome nav {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-wrap: wrap;
|
|
18
|
+
gap: var(--space-8) var(--space-20);
|
|
19
|
+
flex: 1;
|
|
20
|
+
font: var(--font-row);
|
|
21
|
+
}
|
|
22
|
+
.welcome nav a {
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
}
|
|
25
|
+
.welcome nav a:hover,
|
|
26
|
+
.welcome .examples a:hover .open {
|
|
27
|
+
text-decoration: underline;
|
|
28
|
+
}
|
|
29
|
+
.welcome > section {
|
|
30
|
+
margin-top: var(--space-64);
|
|
31
|
+
}
|
|
32
|
+
/* the demo's line, under the head */
|
|
33
|
+
.welcome joined-demo {
|
|
34
|
+
margin-top: var(--space-12);
|
|
35
|
+
}
|
|
36
|
+
/* the landing page speaks up on a phone too: its lead keeps its size */
|
|
37
|
+
.welcome .lead {
|
|
38
|
+
margin: 0;
|
|
39
|
+
font: var(--font-lead);
|
|
40
|
+
max-width: 36rem;
|
|
41
|
+
}
|
|
42
|
+
.welcome h1 {
|
|
43
|
+
margin: 0;
|
|
44
|
+
font: var(--font-display);
|
|
45
|
+
letter-spacing: -0.02em;
|
|
46
|
+
}
|
|
47
|
+
.welcome h2 {
|
|
48
|
+
margin: 0 0 var(--space-6);
|
|
49
|
+
font: var(--font-section);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* what joined is, and the trip at work beside it */
|
|
53
|
+
.hero {
|
|
54
|
+
display: grid;
|
|
55
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
|
|
56
|
+
gap: var(--space-48);
|
|
57
|
+
align-items: center;
|
|
58
|
+
}
|
|
59
|
+
.hero > div {
|
|
60
|
+
display: grid;
|
|
61
|
+
gap: var(--space-20);
|
|
62
|
+
}
|
|
63
|
+
.kicker {
|
|
64
|
+
margin: 0;
|
|
65
|
+
font: var(--font-label);
|
|
66
|
+
color: var(--muted);
|
|
67
|
+
text-transform: uppercase;
|
|
68
|
+
letter-spacing: 0.08em;
|
|
69
|
+
}
|
|
70
|
+
.hero .go {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
gap: var(--space-10);
|
|
74
|
+
margin: var(--space-4) 0 0;
|
|
75
|
+
}
|
|
76
|
+
.hero .go .act {
|
|
77
|
+
min-height: 44px;
|
|
78
|
+
padding: 0 var(--space-16);
|
|
79
|
+
text-decoration: none;
|
|
80
|
+
}
|
|
81
|
+
.hero figure {
|
|
82
|
+
margin: 0;
|
|
83
|
+
display: grid;
|
|
84
|
+
gap: var(--space-10);
|
|
85
|
+
}
|
|
86
|
+
/* the trip's picture, cut to its map and its week: its page's margins and its drawer left out */
|
|
87
|
+
.hero .frame {
|
|
88
|
+
aspect-ratio: 1280 / 1208;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
border: 1px solid var(--edge);
|
|
91
|
+
border-radius: 4px;
|
|
92
|
+
background: var(--paper);
|
|
93
|
+
}
|
|
94
|
+
.hero .frame img {
|
|
95
|
+
display: block;
|
|
96
|
+
width: 148.7%;
|
|
97
|
+
height: auto;
|
|
98
|
+
margin: -1.5% 0 0 -14.5%;
|
|
99
|
+
}
|
|
100
|
+
.hero figcaption {
|
|
101
|
+
font: var(--font-small);
|
|
102
|
+
color: var(--muted);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* three apps to try, each a card with a picture of itself */
|
|
106
|
+
.examples {
|
|
107
|
+
display: grid;
|
|
108
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
|
|
109
|
+
gap: var(--space-16);
|
|
110
|
+
margin-top: var(--space-20);
|
|
111
|
+
}
|
|
112
|
+
.examples > a {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
gap: var(--space-6);
|
|
116
|
+
padding: 0 0 var(--space-16);
|
|
117
|
+
background: var(--card);
|
|
118
|
+
border: 1px solid var(--edge);
|
|
119
|
+
border-radius: 4px;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
color: var(--ink);
|
|
122
|
+
text-decoration: none;
|
|
123
|
+
font: var(--font-row);
|
|
124
|
+
}
|
|
125
|
+
.examples > a > :not(.picture) {
|
|
126
|
+
margin: 0 var(--space-16);
|
|
127
|
+
}
|
|
128
|
+
.examples > a > b {
|
|
129
|
+
margin-top: var(--space-10);
|
|
130
|
+
font: var(--font-name);
|
|
131
|
+
}
|
|
132
|
+
.examples > a > span:not(.open) {
|
|
133
|
+
color: var(--muted);
|
|
134
|
+
}
|
|
135
|
+
.examples .open {
|
|
136
|
+
padding-top: var(--space-6);
|
|
137
|
+
font: var(--font-label);
|
|
138
|
+
}
|
|
139
|
+
.picture {
|
|
140
|
+
height: 10.5rem;
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
justify-content: center;
|
|
144
|
+
gap: var(--space-10);
|
|
145
|
+
padding: var(--space-20);
|
|
146
|
+
box-sizing: border-box;
|
|
147
|
+
}
|
|
148
|
+
.picture.hello {
|
|
149
|
+
background: color-mix(in srgb, var(--hue-4) var(--tint), var(--card));
|
|
150
|
+
}
|
|
151
|
+
.picture.cafe {
|
|
152
|
+
background: color-mix(in srgb, var(--hue-1) var(--tint), var(--card));
|
|
153
|
+
}
|
|
154
|
+
/* the trip read as a line, its beads and their events */
|
|
155
|
+
.picture.shot {
|
|
156
|
+
width: 100%;
|
|
157
|
+
padding: 0;
|
|
158
|
+
object-fit: cover;
|
|
159
|
+
object-position: 50% 60%;
|
|
160
|
+
border-bottom: 1px solid var(--line);
|
|
161
|
+
}
|
|
162
|
+
.mini {
|
|
163
|
+
display: grid;
|
|
164
|
+
gap: var(--space-10);
|
|
165
|
+
grid-template-columns: 1fr auto;
|
|
166
|
+
width: 100%;
|
|
167
|
+
max-width: 15.5rem;
|
|
168
|
+
padding: var(--space-14);
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
background: var(--card);
|
|
171
|
+
border: 1px solid var(--edge);
|
|
172
|
+
border-radius: 4px;
|
|
173
|
+
font: var(--font-small);
|
|
174
|
+
}
|
|
175
|
+
.mini > b {
|
|
176
|
+
grid-column: 1 / -1;
|
|
177
|
+
font: var(--font-title);
|
|
178
|
+
}
|
|
179
|
+
.mini .field {
|
|
180
|
+
border: 1px solid var(--edge);
|
|
181
|
+
border-radius: 4px;
|
|
182
|
+
padding: var(--space-4) var(--space-8);
|
|
183
|
+
color: var(--muted);
|
|
184
|
+
}
|
|
185
|
+
.mini .button {
|
|
186
|
+
border-radius: 4px;
|
|
187
|
+
padding: var(--space-4) var(--space-10);
|
|
188
|
+
background: var(--ink);
|
|
189
|
+
color: var(--card);
|
|
190
|
+
font: var(--font-label);
|
|
191
|
+
align-self: center;
|
|
192
|
+
}
|
|
193
|
+
.mini.ticket {
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-direction: column;
|
|
196
|
+
gap: var(--space-6);
|
|
197
|
+
max-width: 9.5rem;
|
|
198
|
+
padding: var(--space-10) var(--space-12);
|
|
199
|
+
}
|
|
200
|
+
.mini.ticket > b {
|
|
201
|
+
font: var(--font-label);
|
|
202
|
+
}
|
|
203
|
+
.pill {
|
|
204
|
+
align-self: flex-start;
|
|
205
|
+
border-radius: 99px;
|
|
206
|
+
padding: 0 var(--space-8);
|
|
207
|
+
background: var(--hue-1);
|
|
208
|
+
color: #111;
|
|
209
|
+
font: var(--font-tiny);
|
|
210
|
+
}
|
|
211
|
+
.pill.ready {
|
|
212
|
+
background: none;
|
|
213
|
+
border: 1px solid var(--hue-4);
|
|
214
|
+
color: var(--ink);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* how it's made, in three steps */
|
|
218
|
+
.steps {
|
|
219
|
+
display: grid;
|
|
220
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
|
|
221
|
+
gap: var(--space-16) var(--space-24);
|
|
222
|
+
margin-top: var(--space-16);
|
|
223
|
+
}
|
|
224
|
+
.steps p {
|
|
225
|
+
margin: var(--space-10) 0 0;
|
|
226
|
+
font: var(--font-row);
|
|
227
|
+
}
|
|
228
|
+
.steps .step {
|
|
229
|
+
margin: 0;
|
|
230
|
+
font: var(--font-label);
|
|
231
|
+
color: var(--muted);
|
|
232
|
+
}
|
|
233
|
+
.steps pre {
|
|
234
|
+
margin: var(--space-10) 0 0;
|
|
235
|
+
padding: var(--space-12) var(--space-14);
|
|
236
|
+
background: var(--card);
|
|
237
|
+
border: 1px solid var(--edge);
|
|
238
|
+
border-radius: 4px;
|
|
239
|
+
font:
|
|
240
|
+
400 12.5px/1.55 ui-monospace,
|
|
241
|
+
Menlo,
|
|
242
|
+
monospace;
|
|
243
|
+
white-space: pre;
|
|
244
|
+
overflow-x: auto;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* what two AIs said, in ink (a .said is a refusal, in danger), side by side where there's room */
|
|
248
|
+
section.quotes {
|
|
249
|
+
display: grid;
|
|
250
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
|
|
251
|
+
gap: var(--space-24);
|
|
252
|
+
padding-top: var(--space-24);
|
|
253
|
+
border-top: 1px solid var(--line);
|
|
254
|
+
}
|
|
255
|
+
section.quotes figure {
|
|
256
|
+
margin: 0;
|
|
257
|
+
}
|
|
258
|
+
section.quotes blockquote {
|
|
259
|
+
margin: 0;
|
|
260
|
+
font: var(--font-lead);
|
|
261
|
+
}
|
|
262
|
+
section.quotes figcaption {
|
|
263
|
+
margin-top: var(--space-8);
|
|
264
|
+
color: var(--muted);
|
|
265
|
+
font: var(--font-small);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* the film */
|
|
269
|
+
figure.film {
|
|
270
|
+
margin: var(--space-48) 0 0;
|
|
271
|
+
}
|
|
272
|
+
figure.film video {
|
|
273
|
+
display: block;
|
|
274
|
+
width: 100%;
|
|
275
|
+
height: auto;
|
|
276
|
+
border-radius: 4px;
|
|
277
|
+
background: #1a1f36;
|
|
278
|
+
}
|
|
279
|
+
figure.film figcaption {
|
|
280
|
+
margin-top: var(--space-8);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* on a phone: the name and the group's button on one line, the links on the next; the trip as a phone draws it */
|
|
284
|
+
@media (max-width: 40rem) {
|
|
285
|
+
.welcome nav {
|
|
286
|
+
order: 1;
|
|
287
|
+
flex: 1 1 100%;
|
|
288
|
+
}
|
|
289
|
+
.welcome .brand {
|
|
290
|
+
flex: 1;
|
|
291
|
+
}
|
|
292
|
+
.hero .frame {
|
|
293
|
+
aspect-ratio: 375 / 600;
|
|
294
|
+
}
|
|
295
|
+
.hero .frame img {
|
|
296
|
+
width: 100%;
|
|
297
|
+
margin: -94.5% 0 0;
|
|
298
|
+
}
|
|
299
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueshed/joined",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.20",
|
|
4
|
+
"description": "Compiled documents, talking to web components as elements in the DOM.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/blueshed/joined.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"packageManager": "bun@1.4.4",
|
|
12
|
+
"bin": {
|
|
13
|
+
"joined": "./src/cli.ts"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
"./page": "./src/page.ts",
|
|
17
|
+
"./keep": "./src/keep.ts",
|
|
18
|
+
"./draft": "./src/draft.ts",
|
|
19
|
+
"./client": "./src/client.ts",
|
|
20
|
+
"./parts": "./src/parts.ts",
|
|
21
|
+
"./attachment": "./src/attachment.ts",
|
|
22
|
+
"./follow": "./src/follow.ts",
|
|
23
|
+
"./icons": "./src/icons.ts",
|
|
24
|
+
"./hues": "./src/hues.ts",
|
|
25
|
+
"./toast": "./src/toast.ts",
|
|
26
|
+
"./demo": "./src/demo.ts",
|
|
27
|
+
"./panel": "./src/members/panel.ts",
|
|
28
|
+
"./migrate": "./src/migrate.ts",
|
|
29
|
+
"./server": "./src/server.ts",
|
|
30
|
+
"./compile": "./src/compile.ts",
|
|
31
|
+
"./stories": "./src/stories.ts",
|
|
32
|
+
"./tokens.css": "./src/tokens.css",
|
|
33
|
+
"./page.css": "./src/page.css",
|
|
34
|
+
"./parts.css": "./src/parts.css",
|
|
35
|
+
"./tokens.json": "./src/tokens.json",
|
|
36
|
+
"./icon.png": "./src/icon.png"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"src",
|
|
40
|
+
"!src/release.ts",
|
|
41
|
+
"starter",
|
|
42
|
+
".claude/skills/joined",
|
|
43
|
+
"examples",
|
|
44
|
+
"!examples/film.mp4",
|
|
45
|
+
"!examples/backups",
|
|
46
|
+
"docs/introduction.md",
|
|
47
|
+
"docs/stories.md",
|
|
48
|
+
"docs/design.md",
|
|
49
|
+
"docs/learning.md"
|
|
50
|
+
],
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"lucide": "^1.62.0"
|
|
53
|
+
},
|
|
54
|
+
"optionalDependencies": {
|
|
55
|
+
"@electric-sql/pglite": "0.5.10"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// A file field on the page (Attachment, joined/attachment): what an item holds in it shown, a photo as its picture and
|
|
2
|
+
// a PDF as a link, each opening the file; and, where its person may, a way to choose one, and to take it off. A file
|
|
3
|
+
// chosen is sent to the server for the item's document (/files, src/files.ts), which keeps it and answers its value;
|
|
4
|
+
// that's put in the field by the view's own op (`put`: the item's replace, or an add form's field), never written to
|
|
5
|
+
// the element. Drawn again as the item is, only what changed moves: the picture stays while its file does.
|
|
6
|
+
|
|
7
|
+
import { fileUrl, MOST, TOO_BIG } from "./file-value.ts";
|
|
8
|
+
import { icon, iconButton } from "./icons.ts";
|
|
9
|
+
import type { Answer } from "./page.ts";
|
|
10
|
+
import { said } from "./parts.ts";
|
|
11
|
+
|
|
12
|
+
export { fileUrl };
|
|
13
|
+
|
|
14
|
+
/** A file sent for a document, kept: its value for a field, or why it's refused. One too big isn't sent; an answer
|
|
15
|
+
* that isn't joined's (Bun's own, past what it reads, or a proxy's) is said in words too. */
|
|
16
|
+
export async function upload(doc: string, file: Blob): Promise<{ file: string } | { refused: string }> {
|
|
17
|
+
if (file.size > MOST) return { refused: TOO_BIG };
|
|
18
|
+
let r: Response;
|
|
19
|
+
try {
|
|
20
|
+
r = await fetch(`/files?doc=${encodeURIComponent(doc)}`, { method: "POST", body: file });
|
|
21
|
+
} catch {
|
|
22
|
+
return { refused: "Not connected just now: try again in a moment." };
|
|
23
|
+
}
|
|
24
|
+
return r
|
|
25
|
+
.json()
|
|
26
|
+
.catch(() => ({ refused: r.status === 413 ? TOO_BIG : `That wasn't kept: the server answered ${r.status}.` }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A file field's part: its element, and `draw(value, may)` to call as the item's drawn. `doc` is the item's document
|
|
30
|
+
* as the page holds it (a guest's, with its code); `put` puts a value in the field, and `take` takes it off. */
|
|
31
|
+
export function attachment(doc: () => string, put: (file: string) => Promise<Answer>, take?: () => Promise<Answer>) {
|
|
32
|
+
const el = Object.assign(document.createElement("div"), { className: "j-file" });
|
|
33
|
+
const shown = Object.assign(document.createElement("a"), { target: "_blank", rel: "noopener", hidden: true });
|
|
34
|
+
const picture = Object.assign(document.createElement("img"), { alt: "", loading: "lazy" });
|
|
35
|
+
const input = Object.assign(document.createElement("input"), { type: "file", accept: "image/*,application/pdf" });
|
|
36
|
+
const words = document.createElement("span");
|
|
37
|
+
const choose = Object.assign(document.createElement("label"), { className: "act small" });
|
|
38
|
+
choose.append(icon("upload"), words, input);
|
|
39
|
+
const line = Object.assign(document.createElement("p"), { className: "said", role: "status" });
|
|
40
|
+
const off = iconButton("remove", "Take the file off", () => void said(line, take!()));
|
|
41
|
+
el.append(shown, choose, off, line);
|
|
42
|
+
input.addEventListener("change", async () => {
|
|
43
|
+
const file = input.files?.[0];
|
|
44
|
+
if (!file) return;
|
|
45
|
+
line.textContent = "";
|
|
46
|
+
[input.disabled, choose.ariaBusy] = [true, "true"];
|
|
47
|
+
const kept = await upload(doc(), file);
|
|
48
|
+
[input.disabled, choose.ariaBusy, input.value] = [false, null, ""];
|
|
49
|
+
if ("refused" in kept) line.textContent = `Refused: ${kept.refused}`;
|
|
50
|
+
else await said(line, put(kept.file));
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
el,
|
|
54
|
+
/** Drawn as the item has it: its value, and whether its person may put a file in it, or take it off. */
|
|
55
|
+
draw(value: string | undefined, may: { put?: boolean; take?: boolean } = {}) {
|
|
56
|
+
const url = value && fileUrl(value);
|
|
57
|
+
if (url && shown.getAttribute("href") !== url) {
|
|
58
|
+
const pdf = url.endsWith(".pdf");
|
|
59
|
+
Object.assign(shown, { href: url, className: pdf ? "act small" : "j-file-picture" });
|
|
60
|
+
shown.ariaLabel = pdf ? "Open the PDF" : "Open the picture";
|
|
61
|
+
if (!pdf) picture.src = url;
|
|
62
|
+
shown.replaceChildren(...(pdf ? [icon("download"), "PDF"] : [picture]));
|
|
63
|
+
}
|
|
64
|
+
shown.hidden = !url;
|
|
65
|
+
words.textContent = value ? "Another file" : "Add a file";
|
|
66
|
+
choose.hidden = !may.put;
|
|
67
|
+
off.hidden = !value || !may.take || !take;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// joined, the command, run in a project's folder: its apps are apps/ there (or the folder given), and
|
|
3
|
+
// what the pages change is kept in .data/ there (JOINED_DATA). Bun reads ROOT_TOKEN from the project's .env.
|
|
4
|
+
// joined init an app's folder begun: hello, the skill, a CLAUDE.md, the scripts (./starter.ts)
|
|
5
|
+
// joined upgrade [version] joined at another version (the newest, if none is said), the skill refreshed
|
|
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
|
|
8
|
+
// joined link <name> a member's link, printed
|
|
9
|
+
// joined page show <doc> a document as a member sees it, by their link (JOINED_LINK, never printed)
|
|
10
|
+
// joined page watch <doc> each change to it, a line each, as it comes
|
|
11
|
+
// joined page write <doc> <ops> [why] one write, its ops JSON, and its answer
|
|
12
|
+
|
|
13
|
+
import { resolve } from "node:path";
|
|
14
|
+
import { APPS, writeAll } from "./compile.ts";
|
|
15
|
+
import { open } from "./client.ts";
|
|
16
|
+
import { linkFor } from "./link.ts";
|
|
17
|
+
import { start, startUp } from "./server.ts";
|
|
18
|
+
import { init, upgrade } from "./starter.ts";
|
|
19
|
+
|
|
20
|
+
const USAGE =
|
|
21
|
+
"joined init | joined upgrade [version] | joined compile [dir] | joined start [dir] | joined link <name> | joined page show|watch|write <doc> [ops] [why]";
|
|
22
|
+
|
|
23
|
+
/** What a command says, line by line; start leaves joined serving. */
|
|
24
|
+
export async function run([command, arg, ...rest]: string[], dir = arg ? resolve(arg) : APPS): Promise<string[]> {
|
|
25
|
+
if (command === "init") return init(process.cwd());
|
|
26
|
+
if (command === "upgrade") return upgrade(arg, process.cwd());
|
|
27
|
+
if (command === "compile") return [await writeAll(dir)];
|
|
28
|
+
if (command === "start") return startUp(await start({ dir }));
|
|
29
|
+
if (command === "link") return [await linkFor(arg, {})];
|
|
30
|
+
if (command === "page") return paged(arg, rest);
|
|
31
|
+
throw new Error(USAGE);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** A member's page, from a terminal: by their link in JOINED_LINK, a document shown, watched, or written. */
|
|
35
|
+
async function paged(what: string | undefined, [doc, ops, why]: string[]) {
|
|
36
|
+
const link = Bun.env.JOINED_LINK;
|
|
37
|
+
if (!link) throw new Error("JOINED_LINK is a member's link: set it (it's never printed)");
|
|
38
|
+
if (!doc || !["show", "watch", "write"].includes(what ?? "")) throw new Error(USAGE);
|
|
39
|
+
const page = await open(link);
|
|
40
|
+
if (what === "write") {
|
|
41
|
+
const answer = await page.write(doc, JSON.parse(ops ?? "[]"), why);
|
|
42
|
+
await page.close();
|
|
43
|
+
return [JSON.stringify(answer)];
|
|
44
|
+
}
|
|
45
|
+
const held = await page.hold(doc);
|
|
46
|
+
if (what === "show") return (await page.close(), [JSON.stringify(held.now(), null, 2)]);
|
|
47
|
+
// watched: each change a line, until the terminal's let go
|
|
48
|
+
held.on((change) => console.log(JSON.stringify(change)));
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (import.meta.main) for (const line of await run(Bun.argv.slice(2))) console.log(line);
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// A member's page in a program: their link opened as a socket, a document held as a page holds it (whole, then each
|
|
2
|
+
// change applied as it comes), and written as a page writes it, under the same rules. The command line's `joined
|
|
3
|
+
// page` is this; an agent outside a browser may hold one too. The link is the member's: it's never printed.
|
|
4
|
+
|
|
5
|
+
import type { Op } from "./ops.ts";
|
|
6
|
+
|
|
7
|
+
/** A write's answer: done, at its version; or refused, and why, in the server's words. */
|
|
8
|
+
export type Answered = { done?: number; version?: number; refused?: number; why?: string };
|
|
9
|
+
/** A document held: as it is now, and each change to it, as it comes. */
|
|
10
|
+
export type Held = { doc: string; now(): Record<string, any>; on(heard: (change: Change) => void): void };
|
|
11
|
+
type Change = { doc: string; version: number; ops: Op[]; by?: number | null; via?: string | null };
|
|
12
|
+
|
|
13
|
+
/** An op on a document as the page has it: a collection's item added, changed or taken, an id added to a list or
|
|
14
|
+
* taken from it, a field of the document's own; the whole of it, at the path "". */
|
|
15
|
+
export function applied(doc: Record<string, any>, o: Op): Record<string, any> {
|
|
16
|
+
if (o.path === "") return structuredClone(o.value);
|
|
17
|
+
const [, coll, key, field, link] = o.path.split("/") as [string, string, string?, string?, string?];
|
|
18
|
+
const list = doc[coll];
|
|
19
|
+
// a field of the document's own (/greeting)
|
|
20
|
+
if (!Array.isArray(list) && key === undefined)
|
|
21
|
+
return o.op === "remove" ? (({ [coll]: _, ...rest }) => rest)(doc) : { ...doc, [coll]: o.value };
|
|
22
|
+
const items: Record<string, any>[] = Array.isArray(list) ? list : [];
|
|
23
|
+
if (key === "-") return { ...doc, [coll]: [...items, o.value] };
|
|
24
|
+
const changed = (f: (item: Record<string, any>) => Record<string, any> | null) => ({
|
|
25
|
+
...doc,
|
|
26
|
+
[coll]: items.flatMap((i) => (String(i.id) === key ? (f(i) ?? []) : [i])),
|
|
27
|
+
});
|
|
28
|
+
if (field === undefined) return o.op === "remove" ? changed(() => null) : changed((i) => ({ ...i, ...o.value }));
|
|
29
|
+
// an id added to a list, or taken from it: the rest as it was
|
|
30
|
+
if (link !== undefined)
|
|
31
|
+
return changed((i) => {
|
|
32
|
+
const ids: number[] = i[field] ?? [];
|
|
33
|
+
const now = o.op === "add" ? [...ids, o.value] : ids.filter((k) => String(k) !== link);
|
|
34
|
+
return now.length ? { ...i, [field]: now } : (({ [field]: _, ...rest }) => rest)(i);
|
|
35
|
+
});
|
|
36
|
+
return changed((i) => (o.op === "remove" ? (({ [field]: _, ...rest }) => rest)(i) : { ...i, [field]: o.value }));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A member's page, by their link (https://…/auth/<token>): open while it's wanted, then closed. */
|
|
40
|
+
export async function open(link: string) {
|
|
41
|
+
const { origin, pathname } = new URL(link);
|
|
42
|
+
const token = pathname.split("/").at(-1)!;
|
|
43
|
+
// the link opened as a browser opens it: a member's signs in (and does what their invitation says, once)
|
|
44
|
+
const opened = await fetch(`${origin}/auth/${token}`, { redirect: "manual" });
|
|
45
|
+
if (opened.headers.get("location") !== "/") throw new Error("the link opens nothing: it isn't a member's");
|
|
46
|
+
// Bun's WebSocket takes headers (the cookie a browser would send), which the DOM's types don't know
|
|
47
|
+
const ws = new WebSocket(`${origin.replace(/^http/, "ws")}/ws`, { headers: { cookie: `joined=${token}` } } as any);
|
|
48
|
+
const listeners: ((m: any) => void)[] = [];
|
|
49
|
+
ws.onmessage = (e) => {
|
|
50
|
+
const m = JSON.parse(String(e.data));
|
|
51
|
+
for (const l of [...listeners]) l(m);
|
|
52
|
+
};
|
|
53
|
+
const closed = new Promise<void>((done) => ws.addEventListener("close", () => done()));
|
|
54
|
+
await Promise.race([
|
|
55
|
+
new Promise((done) => ws.addEventListener("open", done)),
|
|
56
|
+
closed.then(() => {
|
|
57
|
+
throw new Error("the server's away");
|
|
58
|
+
}),
|
|
59
|
+
]);
|
|
60
|
+
/** The next message that matches, or none if the socket closes first. */
|
|
61
|
+
const next = (match: (m: any) => boolean) =>
|
|
62
|
+
new Promise<any>((done) => {
|
|
63
|
+
const l = (m: any) => match(m) && (listeners.splice(listeners.indexOf(l), 1), done(m));
|
|
64
|
+
listeners.push(l);
|
|
65
|
+
closed.then(() => done(null));
|
|
66
|
+
});
|
|
67
|
+
let id = 0;
|
|
68
|
+
const holding = new Map<string, Promise<Held>>();
|
|
69
|
+
const page = {
|
|
70
|
+
/** A document held, sent whole and then changed as it changes; refused, why. */
|
|
71
|
+
hold: (doc: string) => holding.get(doc) ?? (holding.set(doc, held(doc)), holding.get(doc)!),
|
|
72
|
+
/** One write, whole or not at all, under the same rules a page's is: its answer. Its document is held first, as a
|
|
73
|
+
* page holds what it writes. */
|
|
74
|
+
async write(doc: string, ops: Op[], why?: string): Promise<Answered> {
|
|
75
|
+
await page.hold(doc);
|
|
76
|
+
const sent = ++id;
|
|
77
|
+
const answer = next((m) => m.done === sent || m.refused === sent);
|
|
78
|
+
ws.send(JSON.stringify({ id: sent, doc, ops, why }));
|
|
79
|
+
return answer;
|
|
80
|
+
},
|
|
81
|
+
close: () => (ws.close(), closed),
|
|
82
|
+
};
|
|
83
|
+
return page;
|
|
84
|
+
|
|
85
|
+
async function held(doc: string): Promise<Held> {
|
|
86
|
+
let now: Record<string, any> = {};
|
|
87
|
+
const heard: ((change: Change) => void)[] = [];
|
|
88
|
+
listeners.push((m) => {
|
|
89
|
+
if (m.doc !== doc || !Array.isArray(m.ops)) return;
|
|
90
|
+
now = m.ops.reduce(applied, now);
|
|
91
|
+
if (m.ops[0]?.path !== "") for (const h of heard) h(m);
|
|
92
|
+
});
|
|
93
|
+
ws.send(JSON.stringify({ subscribe: doc }));
|
|
94
|
+
const first = await next((m) => m.doc === doc && (m.refused === true || m.ops?.[0]?.path === ""));
|
|
95
|
+
if (!first || first.refused) throw new Error(`${doc} isn't yours to hold${first?.why ? `: ${first.why}` : ""}`);
|
|
96
|
+
return { doc, now: () => now, on: (h) => heard.push(h) };
|
|
97
|
+
}
|
|
98
|
+
}
|