chirkle 0.0.0-stage → 0.2.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.
Files changed (139) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +326 -2
  3. package/package.json +76 -4
  4. package/pb_hooks/federation/config.js +276 -0
  5. package/pb_hooks/federation/inbox.js +316 -0
  6. package/pb_hooks/federation/messages.js +420 -0
  7. package/pb_hooks/federation/mirror.js +277 -0
  8. package/pb_hooks/federation/net.js +247 -0
  9. package/pb_hooks/federation/peers.js +490 -0
  10. package/pb_hooks/federation/people.js +376 -0
  11. package/pb_hooks/federation/rooms.js +552 -0
  12. package/pb_hooks/federation/worker.js +413 -0
  13. package/pb_hooks/federation.pb.js +141 -0
  14. package/pb_hooks/lib/access.js +102 -0
  15. package/pb_hooks/lib/account.js +31 -0
  16. package/pb_hooks/lib/anonymous.js +189 -0
  17. package/pb_hooks/lib/bulk.js +187 -0
  18. package/pb_hooks/lib/collections.js +587 -0
  19. package/pb_hooks/lib/dms.js +123 -0
  20. package/pb_hooks/lib/emoji.js +28 -0
  21. package/pb_hooks/lib/enrich.js +75 -0
  22. package/pb_hooks/lib/features.js +31 -0
  23. package/pb_hooks/lib/files.js +375 -0
  24. package/pb_hooks/lib/http.js +146 -0
  25. package/pb_hooks/lib/images.js +160 -0
  26. package/pb_hooks/lib/keepalive.js +31 -0
  27. package/pb_hooks/lib/lists.js +173 -0
  28. package/pb_hooks/lib/media.js +635 -0
  29. package/pb_hooks/lib/messages.js +519 -0
  30. package/pb_hooks/lib/moderation.js +128 -0
  31. package/pb_hooks/lib/outbound.js +116 -0
  32. package/pb_hooks/lib/pages.js +171 -0
  33. package/pb_hooks/lib/previews.js +346 -0
  34. package/pb_hooks/lib/reactions.js +110 -0
  35. package/pb_hooks/lib/reads.js +181 -0
  36. package/pb_hooks/lib/records.js +77 -0
  37. package/pb_hooks/lib/rooms.js +148 -0
  38. package/pb_hooks/lib/site.js +102 -0
  39. package/pb_hooks/lib/text.js +110 -0
  40. package/pb_hooks/lib/users.js +81 -0
  41. package/pb_hooks/lib/worker.js +159 -0
  42. package/pb_hooks/main.pb.js +324 -0
  43. package/pb_hooks/telegram/api.js +129 -0
  44. package/pb_hooks/telegram/inbound.js +553 -0
  45. package/pb_hooks/telegram/links.js +157 -0
  46. package/pb_hooks/telegram/outbound.js +352 -0
  47. package/pb_hooks/telegram/people.js +166 -0
  48. package/pb_hooks/telegram/reactions.js +137 -0
  49. package/pb_hooks/telegram/rich.js +192 -0
  50. package/pb_hooks/telegram/worker.js +182 -0
  51. package/pb_hooks/telegram.pb.js +47 -0
  52. package/pb_migrations/1760000000_init.js +150 -0
  53. package/pb_migrations/1760000001_qa_fixes.js +69 -0
  54. package/pb_migrations/1760000002_avatars.js +39 -0
  55. package/pb_migrations/1760000003_direct_messages.js +142 -0
  56. package/pb_migrations/1760000004_attachments.js +28 -0
  57. package/pb_migrations/1760000005_file_names.js +16 -0
  58. package/pb_migrations/1760000006_room_reads.js +41 -0
  59. package/pb_migrations/1760000007_replies.js +23 -0
  60. package/pb_migrations/1760000008_lowercase_emails.js +24 -0
  61. package/pb_migrations/1760000009_reactions.js +32 -0
  62. package/pb_migrations/1760000010_fit_thumbs.js +18 -0
  63. package/pb_migrations/1760000011_forwarding.js +39 -0
  64. package/pb_migrations/1760000012_accounts.js +55 -0
  65. package/pb_migrations/1760000013_qa_pass5.js +19 -0
  66. package/pb_migrations/1760000014_room_access.js +96 -0
  67. package/pb_migrations/1760000015_site.js +46 -0
  68. package/pb_migrations/1760000016_forward_refs.js +43 -0
  69. package/pb_migrations/1760000017_no_dms.js +18 -0
  70. package/pb_migrations/1760000018_attachment_limits.js +24 -0
  71. package/pb_migrations/1760000019_telegram.js +109 -0
  72. package/pb_migrations/1760000020_service_messages.js +21 -0
  73. package/pb_migrations/1760000021_forward_view_index.js +41 -0
  74. package/pb_migrations/1760000022_link_previews.js +43 -0
  75. package/pb_migrations/1760000023_room_writers.js +49 -0
  76. package/pb_migrations/1760000024_message_search.js +51 -0
  77. package/pb_migrations/1760000025_search_dotted_i.js +16 -0
  78. package/pb_migrations/1760000026_push.js +67 -0
  79. package/pb_migrations/1760000027_push_tokens_per_user.js +31 -0
  80. package/pb_migrations/1760000028_media_grid_thumbs.js +18 -0
  81. package/pb_migrations/1760000029_media.js +71 -0
  82. package/pb_migrations/1760000030_collections.js +140 -0
  83. package/pb_migrations/1760000031_unread_limit.js +20 -0
  84. package/pb_migrations/1760000032_federation.js +227 -0
  85. package/pb_migrations/1760000033_federation_requests.js +44 -0
  86. package/pb_migrations/1760000034_telegram_parts.js +26 -0
  87. package/pb_migrations/1760000035_telegram_anonymous.js +16 -0
  88. package/pb_migrations/1760000036_chirkle.js +20 -0
  89. package/pb_migrations/1760000037_file_dims.js +35 -0
  90. package/pb_migrations/1760000038_drop_push.js +64 -0
  91. package/pb_migrations/1760000039_anonymous_rooms.js +40 -0
  92. package/pb_migrations/1760000040_moderators.js +42 -0
  93. package/pb_migrations/1760000041_shared_files.js +500 -0
  94. package/pb_migrations/1760000042_files_src.js +17 -0
  95. package/pb_migrations/1760000043_telegram_reactions.js +21 -0
  96. package/pb_public/assets/access-ALBW2MT2.js +2 -0
  97. package/pb_public/assets/access-ALBW2MT2.js.map +7 -0
  98. package/pb_public/assets/access-PB77EH4F.css +2 -0
  99. package/pb_public/assets/access-PB77EH4F.css.map +7 -0
  100. package/pb_public/assets/app-A3SXD3FF.css +2 -0
  101. package/pb_public/assets/app-A3SXD3FF.css.map +7 -0
  102. package/pb_public/assets/app-NDSIQW4L.js +3 -0
  103. package/pb_public/assets/app-NDSIQW4L.js.map +7 -0
  104. package/pb_public/assets/collections-DHJEOLHW.css +2 -0
  105. package/pb_public/assets/collections-DHJEOLHW.css.map +7 -0
  106. package/pb_public/assets/emoji-WSTVXAW5.css +2 -0
  107. package/pb_public/assets/emoji-WSTVXAW5.css.map +7 -0
  108. package/pb_public/assets/emoji-picker-QYRX6NYL.js +609 -0
  109. package/pb_public/assets/emoji-picker-QYRX6NYL.js.map +7 -0
  110. package/pb_public/assets/inter-cyrillic-JEOLYBOO.woff2 +0 -0
  111. package/pb_public/assets/inter-cyrillic-ext-IYF56FF6.woff2 +0 -0
  112. package/pb_public/assets/inter-greek-IRE366VL.woff2 +0 -0
  113. package/pb_public/assets/inter-latin-NRMW37G5.woff2 +0 -0
  114. package/pb_public/assets/inter-latin-ext-HA22NDSG.woff2 +0 -0
  115. package/pb_public/assets/lazy-4CXRBHHM.js +2 -0
  116. package/pb_public/assets/lazy-4CXRBHHM.js.map +7 -0
  117. package/pb_public/assets/media-7TCBG7WM.css +2 -0
  118. package/pb_public/assets/media-7TCBG7WM.css.map +7 -0
  119. package/pb_public/assets/media-FPRU2QH5.js +2 -0
  120. package/pb_public/assets/media-FPRU2QH5.js.map +7 -0
  121. package/pb_public/assets/notify-L6GERFNO.js +2 -0
  122. package/pb_public/assets/notify-L6GERFNO.js.map +7 -0
  123. package/pb_public/assets/search-3UT4HMES.js +2 -0
  124. package/pb_public/assets/search-3UT4HMES.js.map +7 -0
  125. package/pb_public/assets/switcher-CEUKRLEY.js +2 -0
  126. package/pb_public/assets/switcher-CEUKRLEY.js.map +7 -0
  127. package/pb_public/assets/viewer-DXT7SKOU.js +2 -0
  128. package/pb_public/assets/viewer-DXT7SKOU.js.map +7 -0
  129. package/pb_public/assets/viewer-P7GYCBYM.css +2 -0
  130. package/pb_public/assets/viewer-P7GYCBYM.css.map +7 -0
  131. package/pb_public/icons/apple-touch-icon.png +0 -0
  132. package/pb_public/icons/icon-192.png +0 -0
  133. package/pb_public/icons/icon-512.png +0 -0
  134. package/pb_public/icons/icon.svg +1 -0
  135. package/pb_public/icons/maskable-512.png +0 -0
  136. package/pb_public/index.html +21 -0
  137. package/pb_public/sw.js +1 -0
  138. package/scripts/fetch-pocketbase.sh +63 -0
  139. package/scripts/start.mjs +93 -0
@@ -0,0 +1,500 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Shared files (DESIGN.md §37): every stored file once, as a row of `files`, which messages and collection items name.
3
+ // Saving to a collection or attaching from one adds a name instead of a copy; the file goes once nothing names it.
4
+ //
5
+ // - files: the file (not protected: no file token, §37.3) with the thumbnails messages had, its original name, whether
6
+ // it is a video, its shape (§17.5), and the media worker's state (ready: thumbnails or poster made; sized: shape read;
7
+ // poster). `refs`: how many messages and items name it. No API access: messages and items serve it (lib/files.js).
8
+ // - messages.files and collection_items.file become plain names (json, text): the same values the clients read now.
9
+ // - The files there are move into it: each message's own, and each item's, except an item saved from a message file
10
+ // (or another item) that is still there, which names that file and whose copy goes. Only the database here: nothing
11
+ // stored is read or copied, so the server starts in seconds whatever the storage (on S3, a copy each file took
12
+ // minutes for a few hundred messages, with nothing served meanwhile). Each row's `src` says where its file still is;
13
+ // the media worker moves it to the row's folder afterwards, and it is served from where it is until then (§37.5).
14
+ // The item copies that go are left to the worker too (storage_cleanup), once this is committed.
15
+ // - The media index and collection items no longer keep the worker's state: the file's row does.
16
+ // - Going down copies every file back to each message and item that names it.
17
+
18
+ // In a function of its own: these names stay this file's.
19
+ (() => {
20
+ const C_THUMBS = ["800x480f", "480x240f", "240x240"];
21
+ const C_MAX_SIZE = 20 * 1024 * 1024;
22
+ const C_NO_FILES = "@request.body.files:isset = false";
23
+ /**
24
+ * The JSON field `files` takes as much as 10 files of 20 MB did: PocketBase holds a create's body to the sum of its
25
+ * fields' sizes, and the uploads come in its request (lib/messages.js setRequestFiles), not in a file field of its own.
26
+ * The value saved is only the names.
27
+ */
28
+ const C_FILES_BODY = 10 * C_MAX_SIZE;
29
+
30
+ /** @typedef {Parameters<Parameters<typeof migrate>[0]>[0]} MigrationApp */
31
+
32
+ const newId = () => $security.randomStringWithAlphabet(15, "abcdefghijklmnopqrstuvwxyz0123456789");
33
+
34
+ /** @param {string} s @param {any} fallback */
35
+ function parse(s, fallback) {
36
+ try {
37
+ const v = JSON.parse(s || "null");
38
+ return v === null || v === undefined ? fallback : v;
39
+ } catch {
40
+ return fallback;
41
+ }
42
+ }
43
+
44
+ /** @param {string} name */
45
+ function isVideo(name) {
46
+ const dot = name.lastIndexOf(".");
47
+ return ["mp4", "m4v", "webm", "mov", "ogv"].includes(dot < 0 ? "" : name.slice(dot + 1).toLowerCase());
48
+ }
49
+
50
+ /**
51
+ * Copy a stored file (key `from`) to `to`, with what PocketBase and the media worker keep next to it (thumbs_{name}/:
52
+ * thumbnails, poster) when the name stays. Whether the file was there. Going down only.
53
+ * @param {filesystem.System} fs
54
+ * @param {string} from
55
+ * @param {string} to
56
+ */
57
+ function copyKey(fs, from, to) {
58
+ if (from === to || !fs.exists(from)) return from === to;
59
+ fs.copy(from, to);
60
+ const name = (/** @type {string} */ k) => k.slice(k.lastIndexOf("/") + 1);
61
+ if (name(from) !== name(to)) return true;
62
+ const dir = (/** @type {string} */ k) => `${k.slice(0, k.lastIndexOf("/"))}/thumbs_${name(k)}/`;
63
+ const thumbs = dir(from);
64
+ for (const obj of fs.list(thumbs)) {
65
+ if (!obj || obj.key.endsWith(".attrs")) continue;
66
+ fs.copy(obj.key, `${dir(to)}${obj.key.slice(thumbs.length)}`);
67
+ }
68
+ return true;
69
+ }
70
+
71
+ /**
72
+ * A stored name not taken yet in `files` (PocketBase's names are random, but two records could have had the same).
73
+ * @param {MigrationApp} app
74
+ * @param {string} name
75
+ */
76
+ function freeName(app, name) {
77
+ const taken = (/** @type {string} */ n) => count(app, "SELECT COUNT(*) AS n FROM files WHERE file = {:n}", { n }) > 0;
78
+ if (!taken(name)) return name;
79
+ for (;;) {
80
+ const dot = name.lastIndexOf(".");
81
+ const stem = (dot > 0 ? name.slice(0, dot) : name).replace(/_[a-z0-9]{10}$/, "");
82
+ const next = `${stem}_${$security.randomStringWithAlphabet(10, "abcdefghijklmnopqrstuvwxyz0123456789")}${dot > 0 ? name.slice(dot) : ""}`;
83
+ if (!taken(next)) return next;
84
+ }
85
+ }
86
+
87
+ /** @param {MigrationApp} app @param {string} sql @param {Record<string, any>} params */
88
+ function count(app, sql, params) {
89
+ const row = new DynamicModel({ n: 0 });
90
+ app.db().newQuery(sql).bind(params).one(row);
91
+ return row.n;
92
+ }
93
+
94
+ /**
95
+ * A new `files` row for the stored file `name` of folder `from` (`as` in `files`), which stays where it is
96
+ * (`src`) until the media worker moves it. `done`: what the worker had made of it (thumbnails, poster), as the old
97
+ * columns say.
98
+ * @param {MigrationApp} app
99
+ * @param {{ from: string, name: string, as: string, original: string, dims: any, created: string, done: { ready: boolean, poster: boolean } }} f
100
+ */
101
+ function addRow(app, f) {
102
+ const id = newId();
103
+ const video = isVideo(f.as);
104
+ // Renamed: its thumbnails carry the old name, and are made again once it is moved.
105
+ const kept = f.as === f.name;
106
+ const poster = kept && video && f.done.poster;
107
+ const dims = Array.isArray(f.dims) && f.dims.length === 2 ? JSON.stringify(f.dims) : "null";
108
+ app
109
+ .db()
110
+ .newQuery(
111
+ `INSERT INTO files (id, file, name, video, dims, poster, ready, sized, refs, src, created)
112
+ VALUES ({:id}, {:file}, {:name}, {:video}, {:dims}, {:poster}, {:ready}, {:sized}, 0, {:src}, {:created})`,
113
+ )
114
+ .bind({
115
+ id,
116
+ file: f.as,
117
+ name: String(f.original || f.as).slice(0, 200),
118
+ video,
119
+ dims,
120
+ poster,
121
+ // What the worker had made stays: a video without its poster, or a file renamed, gets another look.
122
+ ready: kept && f.done.ready && (!video || poster),
123
+ sized: dims !== "null" || !video,
124
+ src: `${f.from}/${f.name}`,
125
+ created: f.created,
126
+ })
127
+ .execute();
128
+ return id;
129
+ }
130
+
131
+ /**
132
+ * What the worker had made of a message's file (the media index's columns); a file not in the index has nothing to make.
133
+ * @param {MigrationApp} app
134
+ * @param {string} message
135
+ * @param {string} name
136
+ */
137
+ function doneOfMessage(app, message, name) {
138
+ const row = new DynamicModel({ ready: false, poster: false });
139
+ try {
140
+ app
141
+ .db()
142
+ .newQuery("SELECT ready, poster FROM media WHERE source = {:m} AND file = {:f} LIMIT 1")
143
+ .bind({ m: message, f: name })
144
+ .one(row);
145
+ return { ready: !!row.ready, poster: !!row.poster };
146
+ } catch {
147
+ return { ready: true, poster: false };
148
+ }
149
+ }
150
+
151
+ /** @param {MigrationApp} app @param {string} id */
152
+ function ref(app, id) {
153
+ app.db().newQuery("UPDATE files SET refs = refs + 1 WHERE id = {:id}").bind({ id }).execute();
154
+ }
155
+
156
+ /** @param {MigrationApp} app @param {string} prefix */
157
+ function cleanupLater(app, prefix) {
158
+ app.db().newQuery("INSERT INTO storage_cleanup (id, prefix) VALUES ({:id}, {:prefix})").bind({ id: newId(), prefix }).execute();
159
+ }
160
+
161
+ /**
162
+ * Replace field `name` of `collection` by `field` (another type), keeping its values: the new one is added under a
163
+ * temporary name, the values copied by SQL, the old one removed and the new one renamed.
164
+ * @param {MigrationApp} app
165
+ * @param {string} collection
166
+ * @param {string} name
167
+ * @param {any} field
168
+ * @param {string} copy SQL expression of the old column (`{old}`) for the new one
169
+ */
170
+ function retype(app, collection, name, field, copy) {
171
+ const tmp = `${name}_new`;
172
+ let c = app.findCollectionByNameOrId(collection);
173
+ field.name = tmp;
174
+ c.fields.add(field);
175
+ app.save(c);
176
+ app
177
+ .db()
178
+ .newQuery(`UPDATE ${collection} SET ${tmp} = ${copy.split("{old}").join(`[[${name}]]`)}`)
179
+ .execute();
180
+ c = app.findCollectionByNameOrId(collection);
181
+ c.fields.removeByName(name);
182
+ app.save(c);
183
+ c = app.findCollectionByNameOrId(collection);
184
+ c.fields.getByName(tmp).name = name;
185
+ app.save(c);
186
+ }
187
+
188
+ migrate(
189
+ (app) => {
190
+ app.save(
191
+ new Collection(
192
+ /** @type {any} */ ({
193
+ type: "base",
194
+ name: "files",
195
+ listRule: null,
196
+ viewRule: null,
197
+ createRule: null,
198
+ updateRule: null,
199
+ deleteRule: null,
200
+ fields: [
201
+ { type: "file", name: "file", required: true, maxSelect: 1, maxSize: C_MAX_SIZE, protected: false, thumbs: C_THUMBS },
202
+ { type: "text", name: "name", max: 200 },
203
+ { type: "bool", name: "video" },
204
+ { type: "json", name: "dims", maxSize: 64 },
205
+ { type: "bool", name: "poster" },
206
+ { type: "bool", name: "ready" },
207
+ { type: "bool", name: "sized" },
208
+ { type: "number", name: "refs", onlyInt: true },
209
+ // Where the file still is (collection/record/name) until the media worker moves it into this row's folder.
210
+ { type: "text", name: "src", max: 255 },
211
+ { type: "autodate", name: "created", onCreate: true, onUpdate: false },
212
+ ],
213
+ indexes: [
214
+ "CREATE UNIQUE INDEX idx_files_file ON files (file)",
215
+ "CREATE INDEX idx_files_pending ON files (created) WHERE ready = FALSE",
216
+ "CREATE INDEX idx_files_unsized ON files (created) WHERE sized = FALSE",
217
+ "CREATE INDEX idx_files_unmoved ON files (created) WHERE src != ''",
218
+ ],
219
+ }),
220
+ ),
221
+ );
222
+ app.save(
223
+ new Collection(
224
+ /** @type {any} */ ({
225
+ type: "base",
226
+ name: "storage_cleanup",
227
+ listRule: null,
228
+ viewRule: null,
229
+ createRule: null,
230
+ updateRule: null,
231
+ deleteRule: null,
232
+ fields: [{ type: "text", name: "prefix", required: true, max: 255 }],
233
+ }),
234
+ ),
235
+ );
236
+
237
+ const messagesDir = app.findCollectionByNameOrId("messages").id;
238
+ const itemsDir = app.findCollectionByNameOrId("collection_items").id;
239
+ // Each message's files, with their names, shapes and where they came from under the new names when renamed.
240
+ /** @type {Map<string, string>} "message/name" → files row id */
241
+ const ofMessage = new Map();
242
+ const msgs = arrayOf(new DynamicModel({ id: "", files: "", file_names: "", file_dims: "", file_sources: "", created: "" }));
243
+ app
244
+ .db()
245
+ .newQuery(
246
+ `SELECT id, COALESCE(files, '') AS files, COALESCE(file_names, '') AS file_names, COALESCE(file_dims, '') AS file_dims,
247
+ COALESCE(file_sources, '') AS file_sources, created
248
+ FROM messages WHERE files != '' AND files != '[]' AND files IS NOT NULL`,
249
+ )
250
+ .all(msgs);
251
+ for (const m of msgs) {
252
+ const list = parse(m.files, []);
253
+ if (!Array.isArray(list) || !list.length) continue;
254
+ const names = parse(m.file_names, {});
255
+ const dims = parse(m.file_dims, {});
256
+ const sources = parse(m.file_sources, {});
257
+ /** @type {string[]} */
258
+ const out = [];
259
+ let renamed = false;
260
+ /** @type {Record<string, any>} */
261
+ const outNames = {};
262
+ /** @type {Record<string, any>} */
263
+ const outDims = {};
264
+ /** @type {Record<string, any>} */
265
+ const outSources = {};
266
+ for (const name of list) {
267
+ if (typeof name !== "string" || !name) continue;
268
+ const as = freeName(app, name);
269
+ if (as !== name) renamed = true;
270
+ const id = addRow(app, {
271
+ from: `${messagesDir}/${m.id}`,
272
+ name,
273
+ as,
274
+ original: typeof names[name] === "string" ? names[name] : "",
275
+ dims: dims[name],
276
+ created: m.created,
277
+ done: doneOfMessage(app, m.id, name),
278
+ });
279
+ ref(app, id);
280
+ ofMessage.set(`${m.id}/${name}`, id);
281
+ out.push(as);
282
+ if (names[name] !== undefined) outNames[as] = names[name];
283
+ if (dims[name] !== undefined) outDims[as] = dims[name];
284
+ if (sources[name] !== undefined) outSources[as] = sources[name];
285
+ }
286
+ if (renamed) {
287
+ app
288
+ .db()
289
+ .newQuery("UPDATE messages SET files = {:f}, file_names = {:n}, file_dims = {:d}, file_sources = {:s} WHERE id = {:id}")
290
+ .bind({
291
+ id: m.id,
292
+ f: JSON.stringify(out),
293
+ n: JSON.stringify(outNames),
294
+ d: JSON.stringify(outDims),
295
+ s: JSON.stringify(outSources),
296
+ })
297
+ .execute();
298
+ // The media index names the new ones.
299
+ for (let i = 0; i < list.length; i++) {
300
+ if (list[i] !== out[i]) {
301
+ app
302
+ .db()
303
+ .newQuery("UPDATE media SET file = {:to} WHERE source = {:m} AND file = {:from}")
304
+ .bind({ m: m.id, from: list[i], to: out[i] })
305
+ .execute();
306
+ }
307
+ }
308
+ }
309
+ }
310
+
311
+ // Each item, oldest first: one saved from a message file or an item still there names that file instead.
312
+ /** @type {Map<string, string>} item id → files row id */
313
+ const ofItem = new Map();
314
+ const savedItems = arrayOf(
315
+ new DynamicModel({ id: "", collection: "", file: "", name: "", origin: "", created: "", ready: false, poster: false }),
316
+ );
317
+ app
318
+ .db()
319
+ .newQuery(
320
+ `SELECT id, collection, COALESCE(file, '') AS file, COALESCE(name, '') AS name, COALESCE(origin, '') AS origin, created,
321
+ COALESCE(ready, FALSE) AS ready, COALESCE(poster, FALSE) AS poster
322
+ FROM collection_items ORDER BY created, id`,
323
+ )
324
+ .all(savedItems);
325
+ for (const it of savedItems) {
326
+ let id = "";
327
+ const m = /^m:([a-z0-9]+)\/(.+)$/.exec(it.origin);
328
+ const i = /^i:([a-z0-9]+)$/.exec(it.origin);
329
+ if (m) id = ofMessage.get(`${m[1]}/${m[2]}`) ?? "";
330
+ else if (i) id = ofItem.get(i[1]) ?? "";
331
+ // The same file in this collection already (one saved twice, by two ways): this one goes.
332
+ if (
333
+ id &&
334
+ count(app, "SELECT COUNT(*) AS n FROM collection_items WHERE collection = {:c} AND origin = {:o} AND id != {:id}", {
335
+ c: it.collection,
336
+ o: id,
337
+ id: it.id,
338
+ })
339
+ ) {
340
+ app.db().newQuery("DELETE FROM collection_items WHERE id = {:id}").bind({ id: it.id }).execute();
341
+ app.db().newQuery("UPDATE collections SET items = MAX(0, items - 1) WHERE id = {:c}").bind({ c: it.collection }).execute();
342
+ cleanupLater(app, `${itemsDir}/${it.id}`);
343
+ continue;
344
+ }
345
+ let name = it.file;
346
+ if (id) {
347
+ name = count(app, "SELECT COUNT(*) AS n FROM files WHERE id = {:id}", { id }) ? fileOf(app, id) : "";
348
+ }
349
+ const own = !id || !name;
350
+ if (own) {
351
+ const as = freeName(app, it.file);
352
+ id = addRow(app, {
353
+ from: `${itemsDir}/${it.id}`,
354
+ name: it.file,
355
+ as,
356
+ original: it.name,
357
+ dims: null,
358
+ created: it.created,
359
+ done: { ready: !!it.ready, poster: !!it.poster },
360
+ });
361
+ name = as;
362
+ }
363
+ ref(app, id);
364
+ ofItem.set(it.id, id);
365
+ const poster = count(app, "SELECT COUNT(*) AS n FROM files WHERE id = {:id} AND poster = TRUE", { id }) > 0;
366
+ app
367
+ .db()
368
+ .newQuery("UPDATE collection_items SET file = {:file}, origin = {:origin}, poster = {:poster} WHERE id = {:id}")
369
+ .bind({ id: it.id, file: name, origin: id, poster })
370
+ .execute();
371
+ // Its own copy, no longer named: the file it was saved from is.
372
+ if (!own) cleanupLater(app, `${itemsDir}/${it.id}`);
373
+ }
374
+
375
+ // The fields: plain names now.
376
+ let messages = app.findCollectionByNameOrId("messages");
377
+ messages.updateRule = (messages.updateRule ?? "").replace(` && ${C_NO_FILES}`, "");
378
+ app.save(messages);
379
+ retype(
380
+ app,
381
+ "messages",
382
+ "files",
383
+ new JSONField({ maxSize: C_FILES_BODY }),
384
+ "CASE WHEN json_valid({old}) AND json_type({old}) = 'array' THEN {old} ELSE '[]' END",
385
+ );
386
+ messages = app.findCollectionByNameOrId("messages");
387
+ messages.updateRule = `${messages.updateRule} && ${C_NO_FILES}`;
388
+ app.save(messages);
389
+ // A message never has null for none (lib/messages.js beforeMessageCreate): the ones without files say so.
390
+ app.db().newQuery("UPDATE messages SET files = '[]' WHERE files IS NULL OR files = '' OR files = 'null'").execute();
391
+
392
+ const items = app.findCollectionByNameOrId("collection_items");
393
+ items.removeIndex("idx_collection_items_pending");
394
+ items.fields.removeByName("ready");
395
+ app.save(items);
396
+ retype(app, "collection_items", "file", new TextField({ required: true, max: 255 }), "COALESCE({old}, '')");
397
+
398
+ const media = app.findCollectionByNameOrId("media");
399
+ media.removeIndex("idx_media_pending");
400
+ media.removeIndex("idx_media_unsized");
401
+ for (const f of ["ready", "sized", "poster"]) media.fields.removeByName(f);
402
+ media.addIndex("idx_media_file", false, "file", "");
403
+ app.save(media);
404
+ },
405
+ (app) => {
406
+ const filesDir = app.findCollectionByNameOrId("files").id;
407
+ const messagesDir = app.findCollectionByNameOrId("messages").id;
408
+ const itemsDir = app.findCollectionByNameOrId("collection_items").id;
409
+
410
+ const media = app.findCollectionByNameOrId("media");
411
+ media.removeIndex("idx_media_file");
412
+ media.fields.add(new BoolField({ name: "ready" }));
413
+ media.fields.add(new BoolField({ name: "poster" }));
414
+ media.fields.add(new BoolField({ name: "sized" }));
415
+ media.addIndex("idx_media_pending", false, "sent", "ready = FALSE");
416
+ media.addIndex("idx_media_unsized", false, "sent", "sized = FALSE");
417
+ app.save(media);
418
+ app
419
+ .db()
420
+ .newQuery(
421
+ "UPDATE media SET ready = TRUE, sized = TRUE, poster = COALESCE((SELECT poster FROM files f WHERE f.file = media.file), FALSE)",
422
+ )
423
+ .execute();
424
+
425
+ // Every file back in each message's and item's own folder.
426
+ const fs = app.newFilesystem();
427
+ try {
428
+ // A file the worker hasn't moved yet is still where it was (src): perhaps the very place it goes back to.
429
+ const at = (/** @type {string} */ name) => {
430
+ const row = rowOf(app, name);
431
+ return row ? row.src || `${filesDir}/${row.id}/${name}` : "";
432
+ };
433
+ const rows = arrayOf(new DynamicModel({ id: "", files: "" }));
434
+ app.db().newQuery("SELECT id, files FROM messages WHERE files != '[]' AND files != '' AND files IS NOT NULL").all(rows);
435
+ for (const m of rows) {
436
+ for (const name of parse(m.files, [])) {
437
+ const from = at(name);
438
+ if (from) copyKey(fs, from, `${messagesDir}/${m.id}/${name}`);
439
+ }
440
+ }
441
+ const items = arrayOf(new DynamicModel({ id: "", file: "" }));
442
+ app.db().newQuery("SELECT id, file FROM collection_items").all(items);
443
+ for (const it of items) {
444
+ const from = at(it.file);
445
+ if (from) copyKey(fs, from, `${itemsDir}/${it.id}/${it.file}`);
446
+ }
447
+ } finally {
448
+ fs.close();
449
+ }
450
+
451
+ let messages = app.findCollectionByNameOrId("messages");
452
+ messages.updateRule = (messages.updateRule ?? "").replace(` && ${C_NO_FILES}`, "");
453
+ app.save(messages);
454
+ retype(
455
+ app,
456
+ "messages",
457
+ "files",
458
+ new FileField(/** @type {any} */ ({ maxSelect: 10, maxSize: C_MAX_SIZE, protected: true, thumbs: C_THUMBS })),
459
+ "{old}",
460
+ );
461
+ messages = app.findCollectionByNameOrId("messages");
462
+ messages.updateRule = `${messages.updateRule} && ${C_NO_FILES}`;
463
+ app.save(messages);
464
+
465
+ retype(
466
+ app,
467
+ "collection_items",
468
+ "file",
469
+ new FileField(/** @type {any} */ ({ required: true, maxSelect: 1, maxSize: C_MAX_SIZE, protected: true, thumbs: C_THUMBS })),
470
+ "{old}",
471
+ );
472
+ const items = app.findCollectionByNameOrId("collection_items");
473
+ items.fields.add(new BoolField({ name: "ready", hidden: true }));
474
+ items.addIndex("idx_collection_items_pending", false, "created", "ready = FALSE");
475
+ app.save(items);
476
+ app.db().newQuery("UPDATE collection_items SET ready = TRUE").execute();
477
+
478
+ app.delete(app.findCollectionByNameOrId("storage_cleanup"));
479
+ app.delete(app.findCollectionByNameOrId("files"));
480
+ },
481
+ );
482
+
483
+ /** @param {MigrationApp} app @param {string} id */
484
+ function fileOf(app, id) {
485
+ const row = new DynamicModel({ file: "" });
486
+ app.db().newQuery("SELECT file FROM files WHERE id = {:id}").bind({ id }).one(row);
487
+ return row.file;
488
+ }
489
+
490
+ /** @param {MigrationApp} app @param {string} name @returns {{ id: string, src: string } | null} */
491
+ function rowOf(app, name) {
492
+ const row = new DynamicModel({ id: "", src: "" });
493
+ try {
494
+ app.db().newQuery("SELECT id, COALESCE(src, '') AS src FROM files WHERE file = {:name}").bind({ name }).one(row);
495
+ } catch {
496
+ return null;
497
+ }
498
+ return { id: row.id, src: row.src };
499
+ }
500
+ })();
@@ -0,0 +1,17 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Shared files moved in the background (DESIGN.md §37.5): `files.src`, where a file still is until the media worker
3
+ // moves it into its row's folder. 1760000041 makes it now; a server that ran that migration before it did (it copied
4
+ // every file there and then, nothing served meanwhile) gets it here, empty: its files are all moved.
5
+
6
+ migrate(
7
+ (app) => {
8
+ const files = app.findCollectionByNameOrId("files");
9
+ if (files.fields.getByName("src")) return;
10
+ files.fields.add(new TextField({ name: "src", max: 255 }));
11
+ files.addIndex("idx_files_unmoved", false, "created", "src != ''");
12
+ app.save(files);
13
+ },
14
+ () => {
15
+ // Kept: 1760000041 made it, or going down from it removes the collection.
16
+ },
17
+ );
@@ -0,0 +1,21 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Telegram bridge (DESIGN.md §26.9): tg_queue's "react" op, which sets the bot's reaction on a Telegram message to
3
+ // what its chat message's reactions are.
4
+
5
+ /**
6
+ * @param {MigrationApp} app
7
+ * @param {string[]} values
8
+ */
9
+ function setOps(app, values) {
10
+ const queue = app.findCollectionByNameOrId("tg_queue");
11
+ /** @type {any} */ (queue.fields.getByName("op")).values = values;
12
+ app.save(queue);
13
+ }
14
+
15
+ migrate(
16
+ (app) => setOps(app, ["send", "edit", "delete", "album", "react"]),
17
+ (app) => {
18
+ app.db().newQuery("DELETE FROM tg_queue WHERE op = 'react'").execute();
19
+ setOps(app, ["send", "edit", "delete", "album"]);
20
+ },
21
+ );
@@ -0,0 +1,2 @@
1
+ var H=null;function ue(a){return H??=new Promise(l=>{let E=a("link",{rel:"stylesheet",href:"/assets/access-PB77EH4F.css",on:{load:()=>l(),error:()=>{E.remove(),H=null,l()}}});document.head.append(E)}),H}var me=["private","public","open"],Q={private:"ic i-lock",open:"ic i-globe",everyone:"ic i-users",selected:"ic i-check"},he={everyone:{label:"Everyone who can see it",icon:"",hint:"Guests of an Open Air room only read."},selected:{label:"Only people you choose",icon:"",hint:"Everyone else reads and reacts, but can't post."}};function be(a,l,t){return a===l?"":l==="open"?"Everything ever written here, and everything to come, becomes readable by anyone on the web.":a==="private"?"Everyone with an account will be able to read the whole history.":l==="private"?`Only ${t?"you and the people you add":"its creator and the people added"} will see this room. Everyone else loses it from their list.`:"People without an account won't see this room any more."}function pe(a){let{signal:l}=a,{h:t,uniqueId:E,avatar:X,createUserSearch:Z,SearchError:ee,reasonOf:te,isAddress:ne,postingOf:se,visibilityOf:_,VISIBILITY:ie}=a.kit,A={roomMembers:a.kit.maxMembers},w=E("access"),B=t("h2",{id:`${w}-title`}),D=t("p",{class:"dialog-sub"});function q(e,n,s){let o=t("legend",{}),c=new Map;return{el:t("fieldset",{class:"vis-choices"},[o,...e.map(i=>{let v=t("input",{type:"radio",name:`${w}-${e[0]}`,value:i,"aria-labelledby":`${w}-${i}-label`,"aria-describedby":`${w}-${i}-hint`,on:{change:()=>s(i)},signal:l});return c.set(i,v),t("label",{class:`vis-choice vis-${i}`},[v,t("span",{class:`vis-icon ${Q[i]??""}`,"aria-hidden":"true"},Q[i]?"":n[i].icon),t("span",{class:"vis-text"},[t("span",{id:`${w}-${i}-label`,class:"vis-label"},n[i].label),t("span",{id:`${w}-${i}-hint`,class:"vis-hint"},n[i].hint)])])})]),legend:o,radios:c}}let I=q(me,ie,e=>{p=e,K()});I.legend.textContent="Who can see it";let P=q(["everyone","selected"],he,e=>{$=e,K()});P.legend.textContent="Who can post";function N(e,n,s){let o=t("h3",{}),c=t("ul",{class:"member-list","aria-label":e}),r=t("button",{type:"button",class:"add-member ic i-plus",on:{click:()=>C(U)},signal:l},"Add people"),i=t("div",{class:"member-search"}),v=t("section",{class:n},[t("div",{class:"people-head"},[o,r]),i,c]),U={el:v,addBtn:r,slot:i,pickable:s,list:[],render(){let z=v.hidden?[]:U.list.filter(W);o.textContent=`${e} \xB7 ${z.length}`;let F=U.list.length>=A.roomMembers;r.hidden=!m||f?.p===U,r.disabled=F,r.title=F?`A room can have up to ${A.roomMembers} ${e.toLowerCase()}.`:"",c.replaceChildren(...z.map(y=>{let J=y.id===d?.created_by;return t("li",{class:"member",dataset:{userId:y.id}},[X(y,32,a.avatarUrl),t("span",{class:"member-name"},[y.name,y.id===T?t("span",{}," (you)"):null]),J?t("span",{class:"member-role"},"Creator"):null,y.instance?t("span",{class:"member-role"},y.instance):null,m&&!J?t("button",{type:"button",class:"remove-member","aria-label":`Remove ${y.name}`,on:{click:()=>ae(U,y.id)},signal:l},"Remove"):null])}))}};return U}let h=N("Members","members",()=>!0),u=N("Who can post","writers",e=>p!=="private"||O(h,e)),Y=t("p",{class:"access-warning",role:"status"}),V=t("p",{class:"access-shared"}),g=t("p",{class:"field-error",role:"alert"}),x=t("button",{type:"button",class:"cancel",on:{click:()=>k()},signal:l},"Cancel"),M=t("button",{type:"button",class:"primary save",on:{click:()=>{de()}},signal:l},"Save"),oe=t("div",{class:"dialog-actions"},[x,M]),R=t("button",{type:"button",class:"icon-button ic i-x",tabindex:"-1","aria-hidden":"true",on:{click:()=>k()},signal:l}),re=t("div",{class:"dialog-head"},[t("div",{},[B,D]),R]),le=t("div",{class:"access-body"},[V,I.el,h.el,P.el,u.el,Y,g]),b=t("dialog",{class:"access","aria-labelledby":B.id},[re,le,oe]),d=null,T,m=!1,p="public",$="everyone",O=(e,n)=>e.list.some(s=>s.id===n.id),W=e=>!e.no_dms||!!e.instance,G=()=>d?.shared?.with??[],f=null,L=!1;function K(){g.textContent="",p==="private"&&(u.list=u.list.filter(e=>O(h,e))),S()}function S(){if(!d)return;for(let[n,s]of I.radios)s.checked=n===p;for(let[n,s]of P.radios)s.checked=n===$;I.el.hidden=P.el.hidden=!m,h.el.hidden=p!=="private",u.el.hidden=$!=="selected",h.render(),u.render(),Y.textContent=m?be(_(d),p,d.created_by===T):"";let e=G();V.hidden=!e.length,V.textContent=e.length?d.shared?.home?`This room's home is ${d.shared.home}: who is in it is decided there.`:`Shared with ${e.join(", ")}: its messages are kept there too.${m?` Add people there by their address, like ann@${e[0]}.`:""}`:"",M.hidden=!m,x.textContent=m?"Cancel":"Close"}function ae(e,n){let s=e.el.querySelector("ul"),o=[...s.children].findIndex(r=>r.dataset.userId===n);e.list=e.list.filter(r=>r.id!==n),e===h&&(u.list=u.list.filter(r=>r.id!==n)),S();let c=[...s.querySelectorAll("button.remove-member")];(c[Math.min(o-1,c.length-1)]??e.addBtn).focus()}function ce(e,n){if(O(e,n))e.list=e.list.filter(s=>s.id!==n.id),e===h&&(u.list=u.list.filter(s=>s.id!==n.id));else if(e.list.length>=A.roomMembers){g.textContent=`A room can have up to ${A.roomMembers} ${e===h?"members":"people who post"}.`;return}else e.list=[...e.list,n];g.textContent="",S(),f?.ui.mark()}function C(e){if(e!==(f?.p??null))if(f?.ac.abort(),f?.p.slot.replaceChildren(),f=null,e){let n=new AbortController;l.addEventListener("abort",()=>n.abort(),{once:!0});let s=Z({search:async(o,c)=>{if(!ne(o)||!d||!G().length||!a.remoteUser)return(await a.searchUsers(o,c)).filter(r=>W(r)&&e.pickable(r));try{let r=await a.remoteUser(o,d.id);return e.pickable(r)?[r]:[]}catch(r){throw new ee(te(r))}},avatarUrl:a.avatarUrl,onPick:o=>ce(e,o),isPicked:o=>O(e,o),onClose:()=>{C(null),e.addBtn.focus()},signal:n.signal});f={ac:n,ui:s,p:e},e.slot.replaceChildren(s.el),S(),s.focus(),e.el.firstElementChild?.scrollIntoView?.({block:"start"})}else S()}async function de(){if(L||!d||!m)return;L=!0,M.disabled=x.disabled=R.disabled=!0,g.textContent="";let e=s=>s.list.map(o=>o.id),n=await a.onSave(p,e(h),$,e(u));if(L=!1,M.disabled=x.disabled=R.disabled=!1,!l.aborted){if(n===null)return k();g.textContent=n,b.open||b.showModal()}}function k(){C(null),b.open&&b.close()}b.addEventListener("cancel",e=>{if(L)e.preventDefault();else if(f){e.preventDefault();let n=f.p;C(null),n.addBtn.focus()}},{signal:l}),b.addEventListener("close",()=>C(null),{signal:l}),l.addEventListener("abort",k,{once:!0});function j(e,n,s,o){let c=new Map([...e.expand?.members??[],...s??[]].map(i=>[i.id,i]));return o&&!c.has(o.id)&&c.set(o.id,o),[...new Set(n.length?n:[e.created_by,T||e.created_by])].map(i=>c.get(i)??{id:i,name:"Unknown"}).sort((i,v)=>+(v.id===e.created_by)-+(i.id===e.created_by))}return{el:b,open(e,n,s){d=e,T=s?.id,m=n,p=_(e),$=se(e),h.list=j(e,e.members??[],void 0,s),u.list=j(e,e.writers??[],e.expand?.writers,s),B.textContent=m?"Room access":"Members",D.textContent=`#${e.name}`,g.textContent="",C(null),S(),ue(t).then(()=>{l.aborted||d!==e||(b.open||b.showModal(),(m?I.radios.get(p):x)?.focus())})},close:k}}export{pe as createAccessDialog};
2
+ //# sourceMappingURL=access-ALBW2MT2.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../web/src/views/room/access.ts"],
4
+ "sourcesContent": ["// Room access dialog (\u00A723.2, \u00A723.6): the creator (or a moderator, \u00A736) chooses who can see the room (Private, Public or Open Air) and, for a\n// private room, who its members are; then who can post: everyone who can see it, or only the people they choose.\n// Anyone else in a private room gets the same dialog to see who is in it (and who can post), read-only.\n// Telegram stand-ins (no_dms, \u00A726.3) are left out of it: the bridge adds them itself, so adding or removing one does\n// nothing. They stay members (and writers) when it is saved. People on linked instances (\u00A733) are listed with their\n// instance; in a room shared with theirs, the creator adds them by address (\"ann@b.example\"), and the dialog says\n// where else the room's messages are kept (\u00A733.9).\n// A modal <dialog>: it keeps focus inside, Escape closes it, and focus goes back to where it was.\n//\n// A lazy chunk, like search (\u00A729): the room view import()s it when the dialog is first opened, and it links its own\n// stylesheet (web/styles/access.css) before showing. It imports types only; what it needs from app.js comes in its\n// options (`kit`).\n\nimport type { reasonOf } from \"../../api.ts\";\nimport type { h, uniqueId } from \"../../dom.ts\";\nimport type { isAddress, postingOf, VISIBILITY, visibilityOf } from \"../../lib/rooms.ts\";\nimport type { Posting, Room, User, Visibility } from \"../../lib/types.ts\";\nimport type { AvatarUrl, avatar } from \"../../ui/avatar.ts\";\nimport type { createUserSearch, SearchError, UserSearch } from \"../../ui/user-search.ts\";\n\n/** What the dialog uses of app.js. */\nexport interface AccessKit {\n h: typeof h;\n uniqueId: typeof uniqueId;\n avatar: typeof avatar;\n createUserSearch: typeof createUserSearch;\n SearchError: typeof SearchError;\n reasonOf: typeof reasonOf;\n isAddress: typeof isAddress;\n postingOf: typeof postingOf;\n visibilityOf: typeof visibilityOf;\n VISIBILITY: typeof VISIBILITY;\n /** Most members (and writers) a room has (LIMITS.roomMembers). */\n maxMembers: number;\n}\n\nexport interface AccessDialog {\n readonly el: HTMLDialogElement;\n /** Open it for `room`: to change its access when `editable`, else to see its members. `me` names you in the list. */\n open(room: Room, editable: boolean, me: User | null): void;\n close(): void;\n}\n\ndeclare const ACCESS_CSS: string;\n\nlet stylesheet: Promise<void> | null = null;\n/** The dialog's stylesheet, linked once, like the media grid's: a failed load is tried again next time, and it opens anyway. */\nfunction loadStylesheet(h: typeof import(\"../../dom.ts\")[\"h\"]): Promise<void> {\n stylesheet ??= new Promise((resolve) => {\n const failed = () => {\n link.remove();\n stylesheet = null;\n resolve();\n };\n const link = h(\"link\", { rel: \"stylesheet\", href: ACCESS_CSS, on: { load: () => resolve(), error: failed } });\n document.head.append(link);\n });\n return stylesheet;\n}\n\nconst CHOICES: readonly Visibility[] = [\"private\", \"public\", \"open\"];\n\n/** Who can post (\u00A723.6), shown like the visibilities. */\n/** The choices' icons (.i-* in icons.css); Public keeps its \"#\". */\nconst ICONS: Record<string, string> = { private: \"ic i-lock\", open: \"ic i-globe\", everyone: \"ic i-users\", selected: \"ic i-check\" };\n\nconst POSTING: Record<Posting, { label: string; icon: string; hint: string }> = {\n everyone: { label: \"Everyone who can see it\", icon: \"\", hint: \"Guests of an Open Air room only read.\" },\n selected: { label: \"Only people you choose\", icon: \"\", hint: \"Everyone else reads and reacts, but can't post.\" },\n};\n\n/** What a change of visibility does that may not be obvious, or \"\". */\nfunction warning(from: Visibility, to: Visibility, mine: boolean): string {\n if (from === to) return \"\";\n if (to === \"open\") return \"Everything ever written here, and everything to come, becomes readable by anyone on the web.\";\n if (from === \"private\") return \"Everyone with an account will be able to read the whole history.\";\n if (to === \"private\")\n return `Only ${mine ? \"you and the people you add\" : \"its creator and the people added\"} will see this room. Everyone else loses it from their list.`;\n return \"People without an account won't see this room any more.\";\n}\n\n/** A list of people with Add and Remove: the members, or who can post. */\ninterface People {\n readonly el: HTMLElement;\n readonly addBtn: HTMLButtonElement;\n /** Where its search goes. */\n readonly slot: HTMLElement;\n /** Who its search offers. */\n pickable(u: User): boolean;\n list: User[];\n render(): void;\n}\n\nexport function createAccessDialog(opts: {\n kit: AccessKit;\n searchUsers: (query: string, signal: AbortSignal) => Promise<User[]>;\n /** Someone on a linked instance by address, to add to this shared room (\u00A733.5). */\n remoteUser?: (address: string, room: string) => Promise<User>;\n avatarUrl: AvatarUrl;\n /** Save. Resolves to what went wrong, or null once it is saved (the dialog then closes). */\n onSave: (visibility: Visibility, members: string[], posting: Posting, writers: string[]) => Promise<string | null>;\n signal: AbortSignal;\n}): AccessDialog {\n const { signal } = opts;\n const { h, uniqueId, avatar, createUserSearch, SearchError, reasonOf, isAddress, postingOf, visibilityOf, VISIBILITY } = opts.kit;\n const LIMITS = { roomMembers: opts.kit.maxMembers };\n const id = uniqueId(\"access\");\n const title = h(\"h2\", { id: `${id}-title` });\n const sub = h(\"p\", { class: \"dialog-sub\" });\n\n /** Radio cards: one fieldset of `values`, each with its icon, label and hint. */\n function cards<T extends string>(\n values: readonly T[],\n info: Record<T, { label: string; icon: string; hint: string }>,\n set: (v: T) => void,\n ) {\n const legend = h(\"legend\", {});\n const radios = new Map<T, HTMLInputElement>();\n const el = h(\"fieldset\", { class: \"vis-choices\" }, [\n legend,\n ...values.map((v) => {\n const input = h(\"input\", {\n type: \"radio\",\n name: `${id}-${values[0]}`,\n value: v,\n \"aria-labelledby\": `${id}-${v}-label`,\n \"aria-describedby\": `${id}-${v}-hint`,\n on: { change: () => set(v) },\n signal,\n });\n radios.set(v, input);\n return h(\"label\", { class: `vis-choice vis-${v}` }, [\n input,\n h(\"span\", { class: `vis-icon ${ICONS[v] ?? \"\"}`, \"aria-hidden\": \"true\" }, ICONS[v] ? \"\" : info[v].icon),\n h(\"span\", { class: \"vis-text\" }, [\n h(\"span\", { id: `${id}-${v}-label`, class: \"vis-label\" }, info[v].label),\n h(\"span\", { id: `${id}-${v}-hint`, class: \"vis-hint\" }, info[v].hint),\n ]),\n ]);\n }),\n ]);\n return { el, legend, radios };\n }\n\n const choices = cards(CHOICES, VISIBILITY, (v) => {\n visibility = v;\n changed();\n });\n choices.legend.textContent = \"Who can see it\";\n const postingChoices = cards([\"everyone\", \"selected\"] as const, POSTING, (p) => {\n posting = p;\n changed();\n });\n postingChoices.legend.textContent = \"Who can post\";\n\n /**\n * One list of people. `pickable` says who its search offers: the members are anyone; who can post, in a private\n * room, only its members.\n */\n function people(label: string, cls: string, pickable: (u: User) => boolean): People {\n const head = h(\"h3\", {});\n const ul = h(\"ul\", { class: \"member-list\", \"aria-label\": label });\n const addBtn = h(\n \"button\",\n { type: \"button\", class: \"add-member ic i-plus\", on: { click: () => toggleSearch(p) }, signal },\n \"Add people\",\n );\n const slot = h(\"div\", { class: \"member-search\" });\n // Search above the list, so it stays in reach however many people there are.\n const el = h(\"section\", { class: cls }, [h(\"div\", { class: \"people-head\" }, [head, addBtn]), slot, ul]);\n const p: People = {\n el,\n addBtn,\n slot,\n pickable,\n list: [],\n render() {\n // Hidden, it lists nobody: only the lists in use are in the page.\n const shown = el.hidden ? [] : p.list.filter(listed);\n head.textContent = `${label} \u00B7 ${shown.length}`;\n const full = p.list.length >= LIMITS.roomMembers;\n addBtn.hidden = !editable || search?.p === p;\n addBtn.disabled = full;\n addBtn.title = full ? `A room can have up to ${LIMITS.roomMembers} ${label.toLowerCase()}.` : \"\";\n ul.replaceChildren(\n ...shown.map((u) => {\n const owner = u.id === room?.created_by;\n return h(\"li\", { class: \"member\", dataset: { userId: u.id } }, [\n avatar(u, 32, opts.avatarUrl),\n h(\"span\", { class: \"member-name\" }, [u.name, u.id === myId ? h(\"span\", {}, \" (you)\") : null]),\n owner ? h(\"span\", { class: \"member-role\" }, \"Creator\") : null,\n u.instance ? h(\"span\", { class: \"member-role\" }, u.instance) : null,\n editable && !owner\n ? h(\n \"button\",\n {\n type: \"button\",\n class: \"remove-member\",\n \"aria-label\": `Remove ${u.name}`,\n on: { click: () => remove(p, u.id) },\n signal,\n },\n \"Remove\",\n )\n : null,\n ]);\n }),\n );\n },\n };\n return p;\n }\n\n const members = people(\"Members\", \"members\", () => true);\n const writers = people(\"Who can post\", \"writers\", (u) => visibility !== \"private\" || has(members, u));\n const warn = h(\"p\", { class: \"access-warning\", role: \"status\" });\n const sharedEl = h(\"p\", { class: \"access-shared\" });\n const error = h(\"p\", { class: \"field-error\", role: \"alert\" });\n const cancel = h(\"button\", { type: \"button\", class: \"cancel\", on: { click: () => close() }, signal }, \"Cancel\");\n const save = h(\"button\", { type: \"button\", class: \"primary save\", on: { click: () => void submit() }, signal }, \"Save\");\n const buttons = h(\"div\", { class: \"dialog-actions\" }, [cancel, save]);\n // For the pointer only: the footer's Cancel/Close and Escape do the same, so it isn't a second \"Close\" to tab to or hear.\n const x = h(\"button\", {\n type: \"button\",\n class: \"icon-button ic i-x\",\n tabindex: \"-1\",\n \"aria-hidden\": \"true\",\n on: { click: () => close() },\n signal,\n });\n const head = h(\"div\", { class: \"dialog-head\" }, [h(\"div\", {}, [title, sub]), x]);\n // The body scrolls; the title and the buttons stay put.\n const body = h(\"div\", { class: \"access-body\" }, [sharedEl, choices.el, members.el, postingChoices.el, writers.el, warn, error]);\n const el = h(\"dialog\", { class: \"access\", \"aria-labelledby\": title.id }, [head, body, buttons]);\n\n let room: Room | null = null;\n let myId: string | undefined;\n let editable = false;\n let visibility: Visibility = \"public\";\n let posting: Posting = \"everyone\";\n const has = (p: People, u: User) => p.list.some((x) => x.id === u.id);\n /** Who the lists show: not Telegram's stand-ins, but people on linked instances (\u00A733.4) even without DMs. */\n const listed = (u: User) => !u.no_dms || !!u.instance;\n const sharedHosts = () => room?.shared?.with ?? [];\n let search: { ac: AbortController; ui: UserSearch; p: People } | null = null;\n let busy = false;\n\n function changed() {\n error.textContent = \"\";\n // Made private: only members can post.\n if (visibility === \"private\") writers.list = writers.list.filter((u) => has(members, u));\n render();\n }\n\n function render() {\n if (!room) return;\n for (const [v, input] of choices.radios) input.checked = v === visibility;\n for (const [v, input] of postingChoices.radios) input.checked = v === posting;\n choices.el.hidden = postingChoices.el.hidden = !editable;\n members.el.hidden = visibility !== \"private\";\n writers.el.hidden = posting !== \"selected\";\n members.render();\n writers.render();\n warn.textContent = editable ? warning(visibilityOf(room), visibility, room.created_by === myId) : \"\";\n const hosts = sharedHosts();\n sharedEl.hidden = !hosts.length;\n sharedEl.textContent = !hosts.length\n ? \"\"\n : room.shared?.home\n ? `This room's home is ${room.shared.home}: who is in it is decided there.`\n : `Shared with ${hosts.join(\", \")}: its messages are kept there too.${editable ? ` Add people there by their address, like ann@${hosts[0]}.` : \"\"}`;\n save.hidden = !editable;\n cancel.textContent = editable ? \"Cancel\" : \"Close\";\n }\n\n function remove(p: People, userId: string) {\n const ul = p.el.querySelector(\"ul\")!;\n const at = [...ul.children].findIndex((li) => (li as HTMLElement).dataset.userId === userId);\n p.list = p.list.filter((u) => u.id !== userId);\n // A member taken out can't post either.\n if (p === members) writers.list = writers.list.filter((u) => u.id !== userId);\n render();\n // Focus stays in the list: on the next person's Remove, else the previous one's, else Add people.\n const buttons = [...ul.querySelectorAll<HTMLButtonElement>(\"button.remove-member\")];\n (buttons[Math.min(at - 1, buttons.length - 1)] ?? p.addBtn).focus();\n }\n\n /** A search result picked: add them, or take them out again when they are in. */\n function toggle(p: People, u: User) {\n if (has(p, u)) {\n p.list = p.list.filter((x) => x.id !== u.id);\n if (p === members) writers.list = writers.list.filter((x) => x.id !== u.id);\n } else if (p.list.length >= LIMITS.roomMembers) {\n error.textContent = `A room can have up to ${LIMITS.roomMembers} ${p === members ? \"members\" : \"people who post\"}.`;\n return;\n } else p.list = [...p.list, u];\n error.textContent = \"\";\n render();\n search?.ui.mark();\n }\n\n /** Open the people search under `p`'s Add button (closing any other), or close it (null). */\n function toggleSearch(p: People | null) {\n if (p === (search?.p ?? null)) return;\n search?.ac.abort();\n search?.p.slot.replaceChildren();\n search = null;\n if (p) {\n const ac = new AbortController();\n signal.addEventListener(\"abort\", () => ac.abort(), { once: true });\n const ui = createUserSearch({\n search: async (q, sig) => {\n if (!isAddress(q) || !room || !sharedHosts().length || !opts.remoteUser) {\n return (await opts.searchUsers(q, sig)).filter((u) => listed(u) && p.pickable(u));\n }\n try {\n const u = await opts.remoteUser(q, room.id);\n return p.pickable(u) ? [u] : [];\n } catch (e) {\n throw new SearchError(reasonOf(e));\n }\n },\n avatarUrl: opts.avatarUrl,\n onPick: (u) => toggle(p, u),\n isPicked: (u) => has(p, u),\n onClose: () => {\n toggleSearch(null);\n p.addBtn.focus();\n },\n signal: ac.signal,\n });\n search = { ac, ui, p };\n p.slot.replaceChildren(ui.el);\n render();\n ui.focus();\n // Room for the results under it, on a small screen too.\n p.el.firstElementChild?.scrollIntoView?.({ block: \"start\" });\n } else render();\n }\n\n async function submit() {\n if (busy || !room || !editable) return;\n busy = true;\n save.disabled = cancel.disabled = x.disabled = true;\n error.textContent = \"\";\n const ids = (p: People) => p.list.map((u) => u.id);\n const problem = await opts.onSave(visibility, ids(members), posting, ids(writers));\n busy = false;\n save.disabled = cancel.disabled = x.disabled = false;\n if (signal.aborted) return;\n if (problem === null) return close();\n error.textContent = problem;\n if (!el.open) el.showModal();\n }\n\n function close() {\n toggleSearch(null);\n if (el.open) el.close();\n }\n\n // Escape in the people search closes the search, not the dialog; while saving, nothing closes it.\n el.addEventListener(\n \"cancel\",\n (e) => {\n if (busy) e.preventDefault();\n else if (search) {\n e.preventDefault();\n const p = search.p;\n toggleSearch(null);\n p.addBtn.focus();\n }\n },\n { signal },\n );\n el.addEventListener(\"close\", () => toggleSearch(null), { signal });\n signal.addEventListener(\"abort\", close, { once: true });\n\n /** The people `ids` names, as expanded, the creator first (as the server keeps them). */\n function users(r: Room, ids: string[], expanded: User[] | undefined, me: User | null) {\n const known = new Map([...(r.expand?.members ?? []), ...(expanded ?? [])].map((u) => [u.id, u]));\n // A room made private (or posting chosen) starts with its creator, who isn't expanded yet, and a moderator making\n // it so with themselves (\u00A736), who would otherwise lose it.\n if (me && !known.has(me.id)) known.set(me.id, me);\n const list = [...new Set(ids.length ? ids : [r.created_by, myId || r.created_by])].map(\n (uid) => known.get(uid) ?? { id: uid, name: \"Unknown\" },\n );\n return list.sort((a, b) => Number(b.id === r.created_by) - Number(a.id === r.created_by));\n }\n\n return {\n el,\n open(r, canEdit, me) {\n room = r;\n myId = me?.id;\n editable = canEdit;\n visibility = visibilityOf(r);\n posting = postingOf(r);\n members.list = users(r, r.members ?? [], undefined, me);\n writers.list = users(r, r.writers ?? [], r.expand?.writers, me);\n title.textContent = editable ? \"Room access\" : \"Members\";\n sub.textContent = `#${r.name}`;\n error.textContent = \"\";\n toggleSearch(null);\n render();\n void loadStylesheet(h).then(() => {\n if (signal.aborted || room !== r) return;\n if (!el.open) el.showModal();\n (editable ? choices.radios.get(visibility) : cancel)?.focus();\n });\n },\n close,\n };\n}\n"],
5
+ "mappings": "AA6CA,IAAIA,EAAmC,KAEvC,SAASC,GAAeC,EAAsD,CAC5E,OAAAF,IAAe,IAAI,QAASG,GAAY,CAMtC,IAAMC,EAAOF,EAAE,OAAQ,CAAE,IAAK,aAAc,KAAM,8BAAY,GAAI,CAAE,KAAM,IAAMC,EAAQ,EAAG,MAL5E,IAAM,CACnBC,EAAK,OAAO,EACZJ,EAAa,KACbG,EAAQ,CACV,CACyG,CAAE,CAAC,EAC5G,SAAS,KAAK,OAAOC,CAAI,CAC3B,CAAC,EACMJ,CACT,CAEA,IAAMK,GAAiC,CAAC,UAAW,SAAU,MAAM,EAI7DC,EAAgC,CAAE,QAAS,YAAa,KAAM,aAAc,SAAU,aAAc,SAAU,YAAa,EAE3HC,GAA0E,CAC9E,SAAU,CAAE,MAAO,0BAA2B,KAAM,GAAI,KAAM,uCAAwC,EACtG,SAAU,CAAE,MAAO,yBAA0B,KAAM,GAAI,KAAM,iDAAkD,CACjH,EAGA,SAASC,GAAQC,EAAkBC,EAAgBC,EAAuB,CACxE,OAAIF,IAASC,EAAW,GACpBA,IAAO,OAAe,+FACtBD,IAAS,UAAkB,mEAC3BC,IAAO,UACF,QAAQC,EAAO,6BAA+B,kCAAkC,+DAClF,yDACT,CAcO,SAASC,GAAmBC,EASlB,CACf,GAAM,CAAE,OAAAC,CAAO,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AC/C5B,EAAI,YAAc,IAAIgE,EAAE,IAAI,GAC5BxB,EAAM,YAAc,GACpBlB,EAAa,IAAI,EACjB4B,EAAO,EACF5E,GAAeC,CAAC,EAAE,KAAK,IAAM,CAC5BY,EAAO,SAAW6C,IAASgC,IAC1BxC,EAAG,MAAMA,EAAG,UAAU,GAC1BI,EAAWnB,EAAQ,OAAO,IAAIC,CAAU,EAAI+B,IAAS,MAAM,EAC9D,CAAC,CACH,EACA,MAAAC,CACF,CACF",
6
+ "names": ["stylesheet", "loadStylesheet", "h", "resolve", "link", "CHOICES", "ICONS", "POSTING", "warning", "from", "to", "mine", "createAccessDialog", "opts", "signal", "uniqueId", "avatar", "createUserSearch", "SearchError", "reasonOf", "isAddress", "postingOf", "visibilityOf", "VISIBILITY", "LIMITS", "id", "title", "sub", "cards", "values", "info", "set", "legend", "radios", "v", "input", "choices", "visibility", "changed", "postingChoices", "p", "posting", "people", "label", "cls", "pickable", "head", "ul", "addBtn", "toggleSearch", "slot", "el", "shown", "listed", "full", "editable", "search", "u", "owner", "room", "myId", "remove", "members", "writers", "has", "warn", "sharedEl", "error", "cancel", "close", "save", "submit", "buttons", "x", "body", "sharedHosts", "busy", "render", "hosts", "userId", "at", "li", "toggle", "ac", "ui", "q", "sig", "e", "ids", "problem", "users", "r", "expanded", "me", "known", "uid", "a", "b", "canEdit"]
7
+ }
@@ -0,0 +1,2 @@
1
+ dialog.access[open],.access-body{display:flex;flex-direction:column}.dialog-head{display:flex;gap:12px;align-items:center;padding:18px 16px 14px 24px;border-bottom:1px solid var(--border)}.dialog-head>div{flex:1;min-width:0}dialog.access h2{margin:0;font-size:1.125rem;letter-spacing:-.01em}.dialog-sub{margin:2px 0 0;color:var(--muted);font-size:.8125rem}.access-body{gap:22px;min-height:0;padding:18px 24px 22px;overflow-y:auto}dialog.access .dialog-actions{padding:14px 24px;border-top:1px solid var(--border);background:var(--bg)}dialog.access .cancel{border-color:transparent;background:none}.vis-choices{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;border:0}.vis-choices legend,dialog.access h3{margin:0;padding:0 0 8px;color:var(--text);font-size:.8125rem;font-weight:600}.vis-choice{display:flex;gap:14px;align-items:center;padding:12px 14px;border:1px solid var(--border);border-radius:12px;cursor:pointer}.vis-choice:has(input:checked){border-color:color-mix(in srgb,var(--accent) 60%,transparent);background:var(--tint)}.vis-choice input{appearance:none;flex:none;order:1;width:20px;height:20px;margin:0 0 0 auto;padding:0;border:2px solid color-mix(in srgb,var(--dim) 55%,transparent);border-radius:50%}.vis-choice input:checked{border-color:var(--accent);background:radial-gradient(var(--accent) 4.5px,transparent 5.5px)}.vis-icon{display:flex;flex:none;align-items:center;justify-content:center;width:38px;height:38px;border-radius:10px;background:var(--hover);color:var(--muted);font-size:1rem;font-weight:700}.vis-choice:has(:checked) .vis-icon{background:color-mix(in srgb,var(--fill) 22%,transparent);color:var(--fg)}.vis-text{display:flex;flex-direction:column;gap:2px}.vis-label{font-weight:600}.vis-hint{color:var(--muted);font-size:.8125rem;line-height:1.4}.members,.writers{display:flex;flex-direction:column;gap:6px}.people-head{display:flex;align-items:center;justify-content:space-between}dialog.access .people-head h3{padding:0}.add-member{gap:6px;height:32px;padding:0 10px;border:0;border-radius:8px;background:var(--tint);color:var(--accent);font-size:.8125rem}.add-member:before{width:14px;height:14px}.member-list{margin:0;padding:0;border:1px solid var(--border);border-radius:12px;list-style:none}.member-list:empty{display:none}.member{display:flex;gap:12px;align-items:center;height:52px;padding:0 8px 0 12px}.member+.member{border-top:1px solid var(--line)}.member .avatar{width:30px;height:30px;font-size:.6875rem}.member-name{flex:1;min-width:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.member-name span{color:var(--muted);font-weight:400}.member-role{padding:3px 8px;border-radius:6px;background:var(--hover);color:var(--muted);font-size:.75rem;font-weight:600}.remove-member{height:32px;padding:0 10px;border:0;background:none;color:var(--muted);font-size:.8125rem}.member .remove-member,.search-results [aria-pressed]:after{margin-left:auto}.search-results [aria-pressed=true]:after{content:"\2713 Added";flex:none;color:var(--muted);font-size:.8rem}.access-warning:empty,dialog.access .field-error:empty{display:none}.access-warning,.access-shared{margin:0;padding:.5rem .7rem;border-radius:var(--radius);background:var(--highlight);font-size:.85rem}.dialog-actions{display:flex;gap:.5rem;justify-content:flex-end}dialog.access{width:min(32.5rem,calc(100% - 2rem));max-height:min(52rem,calc(100dvh - 2rem));padding:0;overflow:hidden}
2
+ /*# sourceMappingURL=access-PB77EH4F.css.map */