@dasl/tile-loader 3.0.0 → 3.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 (87) hide show
  1. package/README.md +841 -26
  2. package/dist/at.d.ts +126 -12
  3. package/dist/at.d.ts.map +1 -1
  4. package/dist/at.js +574 -90
  5. package/dist/at.js.map +1 -1
  6. package/dist/car.d.ts +21 -2
  7. package/dist/car.d.ts.map +1 -1
  8. package/dist/car.js +78 -15
  9. package/dist/car.js.map +1 -1
  10. package/dist/content-scheme.d.ts +17 -3
  11. package/dist/content-scheme.d.ts.map +1 -1
  12. package/dist/content-scheme.js +32 -6
  13. package/dist/content-scheme.js.map +1 -1
  14. package/dist/guard.d.ts +242 -0
  15. package/dist/guard.d.ts.map +1 -0
  16. package/dist/guard.js +956 -0
  17. package/dist/guard.js.map +1 -0
  18. package/dist/index.d.ts +297 -13
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +917 -78
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/cid.d.ts +25 -0
  23. package/dist/lib/cid.d.ts.map +1 -0
  24. package/dist/lib/cid.js +65 -0
  25. package/dist/lib/cid.js.map +1 -0
  26. package/dist/lib/defaults.d.ts +8 -0
  27. package/dist/lib/defaults.d.ts.map +1 -0
  28. package/dist/lib/defaults.js +14 -0
  29. package/dist/lib/defaults.js.map +1 -0
  30. package/dist/lib/destinations.d.ts +25 -0
  31. package/dist/lib/destinations.d.ts.map +1 -0
  32. package/dist/lib/destinations.js +94 -0
  33. package/dist/lib/destinations.js.map +1 -0
  34. package/dist/lib/drisl.d.ts +10 -0
  35. package/dist/lib/drisl.d.ts.map +1 -0
  36. package/dist/lib/drisl.js +169 -0
  37. package/dist/lib/drisl.js.map +1 -0
  38. package/dist/lib/errors.d.ts +80 -0
  39. package/dist/lib/errors.d.ts.map +1 -0
  40. package/dist/lib/errors.js +44 -0
  41. package/dist/lib/errors.js.map +1 -0
  42. package/dist/lib/fetching.d.ts +24 -0
  43. package/dist/lib/fetching.d.ts.map +1 -0
  44. package/dist/lib/fetching.js +135 -0
  45. package/dist/lib/fetching.js.map +1 -0
  46. package/dist/lib/limits.d.ts +34 -0
  47. package/dist/lib/limits.d.ts.map +1 -0
  48. package/dist/lib/limits.js +33 -0
  49. package/dist/lib/limits.js.map +1 -0
  50. package/dist/lib/pointer.d.ts +83 -0
  51. package/dist/lib/pointer.d.ts.map +1 -0
  52. package/dist/lib/pointer.js +244 -0
  53. package/dist/lib/pointer.js.map +1 -0
  54. package/dist/link.d.ts +110 -13
  55. package/dist/link.d.ts.map +1 -1
  56. package/dist/link.js +336 -43
  57. package/dist/link.js.map +1 -1
  58. package/dist/memory.d.ts +1 -0
  59. package/dist/memory.d.ts.map +1 -1
  60. package/dist/memory.js +5 -0
  61. package/dist/memory.js.map +1 -1
  62. package/dist/mount.d.ts +54 -0
  63. package/dist/mount.d.ts.map +1 -0
  64. package/dist/mount.js +286 -0
  65. package/dist/mount.js.map +1 -0
  66. package/dist/size.d.ts +43 -2
  67. package/dist/size.d.ts.map +1 -1
  68. package/dist/size.js +296 -15
  69. package/dist/size.js.map +1 -1
  70. package/package.json +13 -3
  71. package/src/at.ts +582 -84
  72. package/src/car.ts +75 -16
  73. package/src/content-scheme.ts +38 -7
  74. package/src/guard.ts +1013 -0
  75. package/src/index.ts +1011 -80
  76. package/src/lib/cid.ts +65 -0
  77. package/src/lib/defaults.ts +12 -0
  78. package/src/lib/destinations.ts +79 -0
  79. package/src/lib/drisl.ts +160 -0
  80. package/src/lib/errors.ts +111 -0
  81. package/src/lib/fetching.ts +138 -0
  82. package/src/lib/limits.ts +61 -0
  83. package/src/lib/pointer.ts +290 -0
  84. package/src/link.ts +365 -48
  85. package/src/memory.ts +5 -0
  86. package/src/mount.ts +356 -0
  87. package/src/size.ts +304 -16
package/dist/link.js CHANGED
@@ -17,15 +17,39 @@
17
17
  // link of the host's own making with the destination in plain sight, and a
18
18
  // host with a handler of its own should do no less. Whatever the host does,
19
19
  // it does somewhere of its own: the tile's frame is never navigated.
20
+ //
21
+ // The tile also chooses the moment it asks, and where on the page its user
22
+ // is pressing at that moment. A prompt that comes up under a press that was
23
+ // already on its way has not asked anybody anything: see `linkPrompt` for
24
+ // what it does about that, which a host's own prompt should do as well.
25
+ import { shield } from './lib/pointer.js';
20
26
  /** The tiles protocol this module speaks. */
21
27
  export const LINK_PROTOCOL = 'link';
22
28
  // Longer than any link a person follows; a tile has no call to send more.
23
29
  const MAX_URL_LENGTH = 8192;
30
+ // Whether the user has just acted inside the tile. The page's own activation
31
+ // says they did something on the page, in any frame of it, in the last few
32
+ // seconds; the tile's dock says whether that was inside this tile. Both have
33
+ // to hold. The dock's word can only take away from the page's, so where a
34
+ // dock does not say (and what arrives under its name is not its own), the
35
+ // answer is what it always was, and never more.
36
+ function userActed(dock) {
37
+ const onPage = pageActivation() ?? false;
38
+ return onPage && (dock ? dock.activated : true);
39
+ }
40
+ // The page's own activation, where the browser says.
41
+ function pageActivation() {
42
+ const isActive = globalThis.navigator?.userActivation?.isActive;
43
+ return typeof isActive === 'boolean' ? isActive : undefined;
44
+ }
24
45
  /** Hears a rendered tile's requests to open links, and answers them. */
25
46
  export function tileLinks(tile, options = {}) {
26
47
  const schemes = options.schemes ?? ['http:', 'https:'];
27
- // One at a time: while the host (or its user) makes up its mind about a
28
- // link, the tile does not get to queue up others.
48
+ const maxLength = options.maxLength ?? MAX_URL_LENGTH;
49
+ // One at a time, unless the host says otherwise: while the host (or its
50
+ // user) makes up its mind about a link, the tile does not get to queue up
51
+ // others.
52
+ const oneAtATime = options.oneAtATime ?? true;
29
53
  let deciding = false;
30
54
  const answer = (id, opened) => {
31
55
  if (typeof id !== 'string' || !id)
@@ -36,25 +60,34 @@ export function tileLinks(tile, options = {}) {
36
60
  catch { /* gone */ }
37
61
  };
38
62
  const onProtocol = async (ev) => {
39
- const { protocol, kind, payload } = ev;
63
+ const { protocol, kind, payload, dock } = ev;
40
64
  if (protocol !== LINK_PROTOCOL || kind !== 'open')
41
65
  return;
42
66
  const { id, url: asked } = (payload && typeof payload === 'object' ? payload : {});
43
67
  let url;
44
- if (typeof asked === 'string' && asked.length <= MAX_URL_LENGTH) {
68
+ if (typeof asked === 'string' && asked.length <= maxLength) {
45
69
  try {
46
70
  url = new URL(asked);
47
71
  }
48
72
  catch { /* not a URL */ }
49
73
  }
50
- if (!url || !schemes.includes(url.protocol) || !options.open || deciding)
74
+ // What is handed on can be longer than what was sent: an address is
75
+ // written out with escapes for what is not plain ASCII. The limit holds
76
+ // for both.
77
+ if (url && url.href.length > maxLength)
78
+ url = undefined;
79
+ if (!url || !schemes.includes(url.protocol) || !options.open || (oneAtATime && deciding))
51
80
  return answer(id, false);
52
81
  deciding = true;
82
+ const onPage = pageActivation();
53
83
  let opened;
54
84
  try {
55
85
  opened = await options.open(url, {
56
- activated: globalThis.navigator?.userActivation?.isActive ?? false,
86
+ activated: userActed(dock),
87
+ ...(typeof dock?.activated === 'boolean' ? { dockActivated: dock.activated } : {}),
88
+ ...(onPage === undefined ? {} : { pageActivated: onPage }),
57
89
  ...(typeof id === 'string' && id ? { id } : {}),
90
+ ...(options.frame ? { frame: options.frame } : {}),
58
91
  });
59
92
  }
60
93
  catch (err) {
@@ -85,57 +118,317 @@ export function openInNewTab(url) {
85
118
  window.open(url.href, '_blank', 'noopener,noreferrer');
86
119
  return true;
87
120
  }
121
+ /** The numbers `linkPrompt` goes by where a host gives none. First guesses. */
122
+ export const LINK_PROMPT = Object.freeze({
123
+ armMs: 800,
124
+ travel: 30,
125
+ restMs: 2000,
126
+ maxShown: 600,
127
+ });
128
+ const NOTES = {
129
+ insecure: 'The connection is not encrypted (http).',
130
+ userinfo: 'The address has a user name in it, struck through below. That is not where the link goes.',
131
+ encoded: 'This name is written in letters other than these: it is shown in its encoded form.',
132
+ };
133
+ // The parts of an address, for showing a user where a link leads. The host is
134
+ // what matters. A user name in the address is never part of where it goes,
135
+ // however much it is made to look like it.
136
+ function parts(url, registrableDomain) {
137
+ const host = url.hostname;
138
+ let site = host;
139
+ try {
140
+ site = registrableDomain?.(host) || host;
141
+ }
142
+ catch { /* the host's own business */ }
143
+ return {
144
+ host,
145
+ site,
146
+ sub: site !== host && host.endsWith(`.${site}`) ? host.slice(0, -site.length) : '',
147
+ port: url.port,
148
+ scheme: url.protocol,
149
+ insecure: url.protocol === 'http:',
150
+ userinfo: url.username || url.password ? `${url.username}${url.password ? ':…' : ''}` : '',
151
+ encoded: host.split('.').some(label => label.startsWith('xn--')),
152
+ rest: `${url.pathname}${url.search}${url.hash}`,
153
+ };
154
+ }
155
+ // The prompt showing in a document, if one is. There is only ever one.
156
+ const showing = new WeakMap();
157
+ // Until when a document shows no prompt, its user having just dismissed one.
158
+ const resting = new WeakMap();
88
159
  /**
89
- * A link handler that leaves it to the user: it shows, in `container`, where
90
- * the tile wants to go, as a link of the host's own that the user can follow,
91
- * with a button to dismiss it. The whole address is shown, since the address
92
- * is where a tile would hide what it wants to send out. Nothing opens unless
93
- * the user follows the link, and it opens in a new tab, never in the tile.
160
+ * A link handler that leaves it to the user: a dialog of the host's own says
161
+ * where the tile wants to go and offers a link to follow, with a button to
162
+ * dismiss it. Nothing opens unless the user follows the link, and it opens
163
+ * in a new tab, never in the tile.
94
164
  *
95
- * A request that arrives when the user has not touched the page is refused
96
- * outright, and a new request replaces one still showing.
165
+ * - It says where. The host's name stands alone on a line, large; a user
166
+ * name in the address, plain http and an encoded name are called out; and
167
+ * the whole address is there to read, since the address is where a tile
168
+ * would put what it wants to send out.
169
+ * - One at a time, for the whole page: while one is showing, a request from
170
+ * any tile is refused. Nothing replaces what the user is reading, and for
171
+ * `restMs` after they have dismissed one nothing comes up in its place: a
172
+ * prompt that is back at once, with its link where the button that
173
+ * dismisses was, is not one anybody has read. A request that arrives when
174
+ * the user has not acted in the tile is refused outright.
175
+ * - It is a modal dialog, on top of the page: nothing a tile does to its
176
+ * size or to the page's scroll moves it.
177
+ * - The link does nothing for `armMs` after the dialog appears, and any press
178
+ * or key in that time starts the wait again: a press that was already on
179
+ * its way when the dialog came up opens nothing, nor does the third of a
180
+ * run of them. A press is judged by when it was made, not by when a page
181
+ * that was busy got to hear of it. Focus starts on the button that
182
+ * dismisses, which always works, as does Escape. A press beside the dialog
183
+ * does nothing.
184
+ * - The link also waits until the pointer has really moved (`travel`
185
+ * pixels), or the keyboard has been taken to it (Tab, a screen reader):
186
+ * a pointer that rests where the link came up opens nothing, however
187
+ * long the tile has its user wait.
188
+ * - It keeps clear of the tile that asked, when `tileLinks` was told its
189
+ * frame: the dialog goes above or below the frame, where there is room.
190
+ * That is not somewhere the pointer cannot be: a tile can move itself, and
191
+ * the page, between the press and the prompt.
192
+ * - Where it was takes no press for a moment once a press has dismissed it:
193
+ * the second click of a double click does not go through to the page.
97
194
  *
98
- * The prompt is plain elements with a few class names (`tile-link-prompt`,
99
- * `tile-link-url`, `tile-link-dismiss`) for a host to style.
195
+ * The dialog element is put in `container` (so it is styled with that part
196
+ * of the page, and goes with it), wherever in the page that is. It is plain
197
+ * elements with a few class names for a host to style: `tile-link-dialog`,
198
+ * `tile-link-host`, `tile-link-note`, `tile-link-url`, `tile-link-open`,
199
+ * `tile-link-dismiss`.
100
200
  */
101
201
  export function linkPrompt(container, options = {}) {
102
- let settle;
103
- return (url, { activated }) => {
104
- if (!activated)
202
+ const armMs = options.armMs ?? LINK_PROMPT.armMs;
203
+ const travel = options.travel ?? LINK_PROMPT.travel;
204
+ const restMs = options.restMs ?? LINK_PROMPT.restMs;
205
+ const maxShown = options.maxShown ?? LINK_PROMPT.maxShown;
206
+ const notes = { ...NOTES, ...options.notes };
207
+ const now = () => performance.now();
208
+ // When a press or a key was made. A page that was busy hears of it later,
209
+ // and what it hears of late was no less early. (Where a browser does not
210
+ // say when on the page's own clock, it is when the page heard of it.)
211
+ const madeAt = (e) => {
212
+ const t = now();
213
+ return e.timeStamp > 0 && e.timeStamp < t ? e.timeStamp : t;
214
+ };
215
+ return (url, request) => {
216
+ if (!request.activated)
105
217
  return false;
106
- settle?.(false);
107
218
  const doc = container.ownerDocument;
108
- const box = doc.createElement('div');
109
- box.className = 'tile-link-prompt';
110
- box.setAttribute('role', 'group');
111
- box.style.cssText = 'display: flex; gap: 0.5em; align-items: baseline; padding: 0.5em 0.75em; font: inherit; overflow-wrap: anywhere;';
112
- const label = doc.createElement('span');
113
- label.textContent = options.label ?? 'This tile wants to open';
114
- const link = doc.createElement('a');
115
- link.className = 'tile-link-url';
219
+ const win = doc.defaultView;
220
+ const before = showing.get(doc);
221
+ if (before?.live())
222
+ return false;
223
+ if (now() < (resting.get(doc) ?? 0))
224
+ return false;
225
+ before?.finish(false); // it went with its part of the page, unanswered
226
+ const make = (name, className, style, text) => {
227
+ const node = doc.createElement(name);
228
+ if (className)
229
+ node.className = className;
230
+ if (style)
231
+ node.style.cssText = style;
232
+ if (text !== undefined)
233
+ node.textContent = text;
234
+ return node;
235
+ };
236
+ const d = parts(url, options.registrableDomain);
237
+ // What a host's own rules for the place it gave us might take away is said again: a prompt nobody can see or press still holds the page.
238
+ const dialog = make('dialog', 'tile-link-dialog', 'position: fixed; box-sizing: border-box; max-width: min(32rem, 92vw); padding: 1.25rem; border: 1px solid #888; border-radius: 10px; font: inherit; visibility: visible; pointer-events: auto;');
239
+ dialog.append(make('p', '', 'margin: 0 0 0.25rem;', options.label ?? 'This tile wants to open a page on'));
240
+ const cut = (text, most) => (text.length > most ? `${text.slice(0, most / 2)} … (${text.length - most} more characters) … ${text.slice(-most / 2)}` : text);
241
+ const where = make('p', 'tile-link-host', 'margin: 0 0 0.75rem; font-size: 1.5em; font-weight: 700; overflow-wrap: anywhere; direction: ltr; unicode-bidi: isolate;');
242
+ if (d.sub)
243
+ where.append(make('span', '', 'font-weight: 400; opacity: 0.65;', d.sub));
244
+ // An address with no host in it (a host may let `mailto:` through): what it names is all there is to show.
245
+ where.append(make('span', '', '', d.host ? d.site : cut(`${d.scheme}${url.pathname}`, 80)));
246
+ if (d.port)
247
+ where.append(make('span', '', 'font-weight: 400; opacity: 0.65;', `:${d.port}`));
248
+ dialog.append(where);
249
+ for (const said of [d.insecure && notes.insecure, d.userinfo && notes.userinfo, d.encoded && notes.encoded]) {
250
+ if (said)
251
+ dialog.append(make('p', 'tile-link-note', 'margin: 0 0 0.5rem; padding-left: 0.5rem; border-left: 3px solid #c00;', said));
252
+ }
253
+ // The whole address, with the host marked: this is where a tile would put what it wants to send out.
254
+ const address = make('p', 'tile-link-url', 'margin: 0 0 1rem; font: 12px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; max-height: 7.5em; overflow: auto; opacity: 0.8; direction: ltr; unicode-bidi: isolate;');
255
+ if (d.host) {
256
+ address.append(make('span', '', '', `${d.scheme}//`));
257
+ if (d.userinfo)
258
+ address.append(make('span', '', 'text-decoration: line-through;', `${d.userinfo}@`));
259
+ address.append(make('strong', '', '', url.host), make('span', '', '', cut(d.rest, maxShown)));
260
+ }
261
+ else
262
+ address.append(make('span', '', '', cut(url.href, maxShown)));
263
+ dialog.append(address);
264
+ const row = make('div', '', 'display: flex; gap: 0.75rem; justify-content: flex-end; align-items: baseline;');
265
+ const dismiss = make('button', 'tile-link-dismiss', 'font: inherit; padding: 0.5rem 1rem;', options.dismiss ?? 'Dismiss');
266
+ dismiss.type = 'button';
267
+ const link = make('a', 'tile-link-open', 'font: inherit; padding: 0.5rem 1rem; border: 1px solid currentColor; border-radius: 6px; text-decoration: none;', `${options.open ?? 'Open'} ${d.host}`.trim());
116
268
  link.href = url.href;
117
269
  link.target = '_blank';
118
270
  link.rel = 'noopener noreferrer';
119
- link.textContent = url.href;
120
- link.style.cssText = 'flex: 1; min-width: 0;';
121
- const dismiss = doc.createElement('button');
122
- dismiss.type = 'button';
123
- dismiss.className = 'tile-link-dismiss';
124
- dismiss.textContent = options.dismiss ?? 'Dismiss';
125
- box.append(label, link, dismiss);
271
+ row.append(dismiss, link);
272
+ dialog.append(row);
126
273
  return new Promise((resolve) => {
127
- const done = (opened) => {
128
- if (settle !== done)
274
+ let armAt = now() + armMs;
275
+ let timer;
276
+ let done = false;
277
+ let needsMove = false;
278
+ let moved = false;
279
+ let finger = false; // the last press on the dialog was a finger's
280
+ let from;
281
+ const armed = (at = now()) => at >= armAt && (!needsMove || moved || finger);
282
+ const show = () => {
283
+ const on = armed();
284
+ link.setAttribute('aria-disabled', on ? 'false' : 'true');
285
+ link.style.opacity = on ? '1' : '0.4';
286
+ };
287
+ const wait = () => {
288
+ clearTimeout(timer);
289
+ timer = setTimeout(show, Math.max(0, armAt - now()) + 5);
290
+ show();
291
+ };
292
+ const onMove = (ev) => {
293
+ const e = ev;
294
+ if (!e.isTrusted || moved || e.pointerType === 'touch')
129
295
  return;
130
- settle = undefined;
131
- box.remove();
296
+ if (!from) {
297
+ from = { x: e.clientX, y: e.clientY };
298
+ return;
299
+ }
300
+ if (Math.hypot(e.clientX - from.x, e.clientY - from.y) >= travel) {
301
+ moved = true;
302
+ show();
303
+ }
304
+ };
305
+ // Above or below the tile that asked, wherever there is room for the whole dialog.
306
+ const keepClear = () => {
307
+ // Wherever it goes, a pointer parked where the link comes up opens
308
+ // nothing, however long the tile has its user wait: the tile may
309
+ // have moved itself, or the page, since the press that asked, and
310
+ // "clear of the tile" is then where the pointer is. (A finger is not
311
+ // parked anywhere: for one, the wait is all there is.)
312
+ needsMove = win.matchMedia?.('(hover: hover)').matches ?? true;
313
+ const room = dialog.getBoundingClientRect().height + 16;
314
+ const f = request.frame?.getBoundingClientRect?.();
315
+ let top;
316
+ if (f) {
317
+ const vh = win.innerHeight;
318
+ const above = Math.max(0, Math.min(f.top, vh));
319
+ const below = vh - Math.max(0, Math.min(f.bottom, vh));
320
+ if (below >= room && (below >= above || above < room))
321
+ top = vh - below + 8;
322
+ else if (above >= room)
323
+ top = above - room + 8;
324
+ }
325
+ if (top === undefined)
326
+ return; // in the middle, which may be over the tile
327
+ dialog.style.top = `${top}px`;
328
+ dialog.style.bottom = 'auto';
329
+ dialog.style.marginTop = '0';
330
+ dialog.style.marginBottom = '0';
331
+ };
332
+ const early = (ev) => {
333
+ const e = ev;
334
+ if (!e.isTrusted)
335
+ return;
336
+ if (e.type === 'pointerdown')
337
+ finger = ev.pointerType === 'touch';
338
+ // Tabbing to the link is the user going to it, as moving the pointer there is.
339
+ if (e.type === 'keydown' && e.key === 'Tab') {
340
+ moved = true;
341
+ show();
342
+ }
343
+ if (armed(madeAt(e)))
344
+ return;
345
+ // Refusing is always the user's to do.
346
+ if (dismiss.contains(e.target) || (e.type === 'keydown' && e.key === 'Escape'))
347
+ return;
348
+ // Too soon to be an answer to what the dialog says: it counts for nothing, and the wait starts over.
349
+ armAt = now() + armMs;
350
+ wait();
351
+ if (e.type !== 'keydown' || e.key !== 'Tab') {
352
+ e.preventDefault();
353
+ e.stopPropagation();
354
+ }
355
+ };
356
+ const EARLY = ['pointerdown', 'mousedown', 'click', 'auxclick', 'keydown'];
357
+ // `press`: the press on the dialog that dismissed it, when it was one.
358
+ const finish = (opened, press) => {
359
+ if (done)
360
+ return;
361
+ done = true;
362
+ if (showing.get(doc) === mine)
363
+ showing.delete(doc);
364
+ clearTimeout(timer);
365
+ doc.removeEventListener('pointermove', onMove, true);
366
+ for (const type of EARLY)
367
+ dialog.removeEventListener(type, early, true);
368
+ if (press) {
369
+ // The dialog goes at once, and the page is there again where it
370
+ // was: a second press on its way to the same spot would land on
371
+ // whatever the tile has put there meanwhile.
372
+ const r = dialog.getBoundingClientRect();
373
+ const where = { left: r.left, top: r.top, width: r.width, height: r.height };
374
+ shield(doc, () => where, { ms: armMs, dwellMs: armMs });
375
+ }
376
+ try {
377
+ dialog.close();
378
+ }
379
+ catch { /* not open */ }
380
+ dialog.remove();
132
381
  resolve(opened);
133
382
  };
134
- settle = done;
135
- // The link is a real one: following it is the user's own navigation.
136
- link.addEventListener('click', () => setTimeout(() => done(true)));
137
- dismiss.addEventListener('click', () => done(false));
138
- container.append(box);
383
+ // The user said no: nothing asks again for a moment.
384
+ const refuse = (press) => {
385
+ if (done)
386
+ return;
387
+ resting.set(doc, now() + restMs);
388
+ finish(false, press);
389
+ };
390
+ // (By the attribute: a browser that knows no dialog element shows ours as a plain box, which serves.)
391
+ const mine = { live: () => !done && dialog.isConnected && dialog.hasAttribute('open'), finish };
392
+ showing.set(doc, mine);
393
+ for (const type of EARLY)
394
+ dialog.addEventListener(type, early, true);
395
+ const follow = (ev) => {
396
+ const e = ev;
397
+ if (e.type === 'auxclick' && e.button !== 1)
398
+ return;
399
+ if (!e.isTrusted || !armed(madeAt(e)))
400
+ return e.preventDefault();
401
+ // The link is a real one: following it is the user's own navigation.
402
+ setTimeout(() => finish(true));
403
+ };
404
+ link.addEventListener('click', follow);
405
+ link.addEventListener('auxclick', follow);
406
+ // The keyboard arriving on the link is the user going to it, however
407
+ // they got there: with Tab, or with a screen reader's own cursor,
408
+ // which presses no key the page sees. (A press on the link that came
409
+ // too soon does not bring the keyboard there: it is stopped above.)
410
+ link.addEventListener('focus', () => { moved = true; show(); });
411
+ // (A click the keyboard made has no press behind it: `detail` is 0.)
412
+ dismiss.addEventListener('click', (ev) => refuse(ev.isTrusted && ev.detail > 0 ? ev : undefined));
413
+ dialog.addEventListener('cancel', (ev) => { ev.preventDefault(); refuse(); });
414
+ dialog.addEventListener('close', () => finish(false));
415
+ container.append(dialog);
416
+ const modal = typeof dialog.showModal === 'function';
417
+ try {
418
+ if (modal)
419
+ dialog.showModal();
420
+ else
421
+ dialog.setAttribute('open', '');
422
+ }
423
+ catch { /* not in a document that can show it: refused below */ }
424
+ // A modal dialog holds the whole page. One that did not come to be
425
+ // shown (its container is not displayed, or not in the page) must not.
426
+ if (!dialog.hasAttribute('open') || (modal && !dialog.getClientRects().length))
427
+ return finish(false);
428
+ keepClear();
429
+ doc.addEventListener('pointermove', onMove, { capture: true, passive: true });
430
+ dismiss.focus({ preventScroll: true });
431
+ wait();
139
432
  });
140
433
  };
141
434
  }
package/dist/link.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.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C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
package/dist/memory.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { InMemoryMasl, MaslResponse } from "@dasl/tile-lexicon";
4
4
  export declare class MemoryTileLoader {
5
5
  #private;
6
6
  addTile(id: string, manifest: InMemoryMasl): void;
7
+ removeTile(id: string): void;
7
8
  load(url: string, mothership: TileMothership): Promise<Tile | false>;
8
9
  }
9
10
  export declare class MemoryPathLoader {
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMrE,qBAAa,gBAAgB;;IAE3B,OAAO,CAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY;IAGrC,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;CAW5E;AAED,qBAAa,gBAAgB;;gBAEd,QAAQ,EAAE,YAAY;IAG7B,WAAW,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAKxD"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMrE,qBAAa,gBAAgB;;IAE3B,OAAO,CAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY;IAK3C,UAAU,CAAE,EAAE,EAAE,MAAM;IAGhB,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;CAW5E;AAED,qBAAa,gBAAgB;;gBAEd,QAAQ,EAAE,YAAY;IAG7B,WAAW,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAKxD"}
package/dist/memory.js CHANGED
@@ -9,6 +9,11 @@ export class MemoryTileLoader {
9
9
  addTile(id, manifest) {
10
10
  this.#tiles[id] = manifest;
11
11
  }
12
+ // Forgets a tile, by the id it was added under. A Tile that was loaded
13
+ // from it before keeps what it has.
14
+ removeTile(id) {
15
+ delete this.#tiles[id];
16
+ }
12
17
  async load(url, mothership) {
13
18
  let u;
14
19
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGxD,oBAAoB;AACpB,iDAAiD;AACjD,wFAAwF;AACxF,+DAA+D;AAC/D,MAAM,OAAO,gBAAgB;IAC3B,MAAM,GAAiC,EAAE,CAAC;IAC1C,OAAO,CAAE,EAAU,EAAE,QAAsB;QACzC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC;IAC7B,CAAC;IACD,KAAK,CAAC,IAAI,CAAE,GAAW,EAAE,UAA0B;QACjD,IAAI,CAAM,CAAC;QACX,IAAI,CAAC;YAAC,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;QACzB,MAAM,CAAC;YAAC,OAAO,KAAK,CAAC;QAAC,CAAC,CAAC,kDAAkD;QAC1E,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC3C,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC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AC;IACD,KAAK,CAAC,IAAI,CAAE,GAAW,EAAE,UAA0B;QACjD,IAAI,CAAM,CAAC;QACX,IAAI,CAAC;YAAC,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;QACzB,MAAM,CAAC;YAAC,OAAO,KAAK,CAAC;QAAC,CAAC,CAAC,kDAAkD;QAC1E,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC3C,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,+BAA+B;QACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACF;AAED,MAAM,OAAO,gBAAgB;IAC3B,SAAS,CAAe;IACxB,YAAa,QAAsB;QACjC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IACD,KAAK,CAAC,WAAW,CAAE,IAAY;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,EAAE,GAAG;YAAE,OAAO,SAAS,CAAC;QAClC,OAAO,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,54 @@
1
+ import type { Tile } from './index.js';
2
+ export interface TileMountOptions {
3
+ /** How many tiles may be live, mounted and running, at once. 6 when left out. */
4
+ maxLive?: number;
5
+ /** How many may be starting at once: mounted, and not loaded yet. 3 when left out. */
6
+ maxStarting?: number;
7
+ /** How long a place has to stay in view before its tile is mounted, in milliseconds. 300 when left out. */
8
+ mountAfter?: number;
9
+ /** How long it has to stay out of view before its tile is closed, in milliseconds. 10 seconds when left out; `Infinity` to close a tile only when another needs its room. */
10
+ closeAfter?: number;
11
+ /**
12
+ * How long a tile counts as starting at most, loaded or not, in
13
+ * milliseconds; and how long the function that loads a tile is waited for
14
+ * before its room is given to another. 5 seconds when left out.
15
+ */
16
+ startLimit?: number;
17
+ /** What a place is in view of, as for an IntersectionObserver: the viewport when left out. */
18
+ root?: Element | Document | null;
19
+ /** A margin around that, as for an IntersectionObserver (`'200px 0px'` mounts a tile a little before it scrolls in). */
20
+ rootMargin?: string;
21
+ }
22
+ export interface TileMountItem {
23
+ /** The tile, or what loads it: called once, the first time its place has been in view long enough. */
24
+ tile: Tile | (() => Tile | false | Promise<Tile | false>);
25
+ /** Makes the tile's frame. `tile.renderContent()` when left out. */
26
+ render?: (tile: Tile) => HTMLIFrameElement;
27
+ /**
28
+ * Called when the tile has been mounted, with its frame: the moment for
29
+ * `tileSize()`, `tileLinks()` and the like. What it returns, if it is a
30
+ * function, is called when the tile is put away, before it is closed.
31
+ */
32
+ onMount?: (tile: Tile, frame: HTMLIFrameElement) => void | (() => void);
33
+ /** Called when the tile has been closed, with whether its origin was wiped (what `Tile.close()` resolved to). */
34
+ onClose?: (tile: Tile, wiped: boolean) => void;
35
+ }
36
+ export interface TileMounts {
37
+ /**
38
+ * Watches a place in the page: its tile is mounted there when the place
39
+ * has been in view for a moment and there is room, and closed when it has
40
+ * been out of view for a while, or sooner if another tile needs the room.
41
+ * Returns what stops watching it, closing its tile if it is live; that
42
+ * resolves when the tile is closed.
43
+ */
44
+ watch(place: Element, item: TileMountItem | TileMountItem['tile']): () => Promise<void>;
45
+ /** How many tiles are live now. */
46
+ readonly live: number;
47
+ /** Stops watching every place and closes every live tile. Resolves when they are closed. */
48
+ stop(): Promise<void>;
49
+ }
50
+ /** The attribute a place has while its tile is live. */
51
+ export declare const LIVE_ATTRIBUTE = "data-tile-live";
52
+ /** Mounts tiles in their places as these come into view, a bounded number at a time. */
53
+ export declare function tileMounts(options?: TileMountOptions): TileMounts;
54
+ //# sourceMappingURL=mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6KAA6K;IAC7K,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8FAA8F;IAC9F,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC;IACjC,wHAAwH;IACxH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,sGAAsG;IACtG,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;IAC1D,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,iBAAiB,CAAC;IAC3C;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACxE,iHAAiH;IACjH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAChD;AAED,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,KAAK,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