@dasl/tile-loader 3.1.0 → 4.0.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.
- package/README.md +1463 -36
- package/dist/at.d.ts +126 -12
- package/dist/at.d.ts.map +1 -1
- package/dist/at.js +582 -90
- package/dist/at.js.map +1 -1
- package/dist/car.d.ts +21 -2
- package/dist/car.d.ts.map +1 -1
- package/dist/car.js +82 -15
- package/dist/car.js.map +1 -1
- package/dist/content-scheme.d.ts +17 -3
- package/dist/content-scheme.d.ts.map +1 -1
- package/dist/content-scheme.js +32 -6
- package/dist/content-scheme.js.map +1 -1
- package/dist/guard.d.ts +342 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +1544 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.d.ts +416 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +999 -74
- package/dist/index.js.map +1 -1
- package/dist/lib/cid.d.ts +25 -0
- package/dist/lib/cid.d.ts.map +1 -0
- package/dist/lib/cid.js +65 -0
- package/dist/lib/cid.js.map +1 -0
- package/dist/lib/defaults.d.ts +8 -0
- package/dist/lib/defaults.d.ts.map +1 -0
- package/dist/lib/defaults.js +14 -0
- package/dist/lib/defaults.js.map +1 -0
- package/dist/lib/destinations.d.ts +25 -0
- package/dist/lib/destinations.d.ts.map +1 -0
- package/dist/lib/destinations.js +94 -0
- package/dist/lib/destinations.js.map +1 -0
- package/dist/lib/drisl.d.ts +10 -0
- package/dist/lib/drisl.d.ts.map +1 -0
- package/dist/lib/drisl.js +169 -0
- package/dist/lib/drisl.js.map +1 -0
- package/dist/lib/errors.d.ts +80 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +44 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/fetching.d.ts +24 -0
- package/dist/lib/fetching.d.ts.map +1 -0
- package/dist/lib/fetching.js +135 -0
- package/dist/lib/fetching.js.map +1 -0
- package/dist/lib/limits.d.ts +34 -0
- package/dist/lib/limits.d.ts.map +1 -0
- package/dist/lib/limits.js +33 -0
- package/dist/lib/limits.js.map +1 -0
- package/dist/lib/pointer.d.ts +83 -0
- package/dist/lib/pointer.d.ts.map +1 -0
- package/dist/lib/pointer.js +244 -0
- package/dist/lib/pointer.js.map +1 -0
- package/dist/lib/tab-order.d.ts +16 -0
- package/dist/lib/tab-order.d.ts.map +1 -0
- package/dist/lib/tab-order.js +66 -0
- package/dist/lib/tab-order.js.map +1 -0
- package/dist/link.d.ts +110 -13
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +336 -43
- package/dist/link.js.map +1 -1
- package/dist/memory.d.ts +1 -0
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +5 -0
- package/dist/memory.js.map +1 -1
- package/dist/mount.d.ts +54 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +289 -0
- package/dist/mount.js.map +1 -0
- package/dist/size.d.ts +43 -2
- package/dist/size.d.ts.map +1 -1
- package/dist/size.js +296 -15
- package/dist/size.js.map +1 -1
- package/package.json +13 -3
- package/src/at.ts +590 -84
- package/src/car.ts +79 -16
- package/src/content-scheme.ts +38 -7
- package/src/guard.ts +1659 -0
- package/src/index.ts +1124 -74
- package/src/lib/cid.ts +65 -0
- package/src/lib/defaults.ts +12 -0
- package/src/lib/destinations.ts +79 -0
- package/src/lib/drisl.ts +160 -0
- package/src/lib/errors.ts +111 -0
- package/src/lib/fetching.ts +138 -0
- package/src/lib/limits.ts +61 -0
- package/src/lib/pointer.ts +290 -0
- package/src/lib/tab-order.ts +66 -0
- package/src/link.ts +365 -48
- package/src/memory.ts +5 -0
- package/src/mount.ts +359 -0
- package/src/size.ts +304 -16
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// Where the user's pointer is, as far as a page that frames a tile can know,
|
|
2
|
+
// and a way to keep presses off a piece of that page for a moment. For the
|
|
3
|
+
// modules that hold a tile to one rule: it does not get to move what the
|
|
4
|
+
// user is about to press.
|
|
5
|
+
//
|
|
6
|
+
// What the page can and cannot know decides everything here, so, once:
|
|
7
|
+
//
|
|
8
|
+
// - A mouse over a tile's frame is invisible to the page, except that it is
|
|
9
|
+
// there: the frame element gets a pointerover when the mouse goes in, with
|
|
10
|
+
// coordinates, the page gets a pointermove when it comes out, and nothing
|
|
11
|
+
// in between. A press inside the frame is never seen.
|
|
12
|
+
// - A finger gives no warning at all: nothing is seen of a touch that lands
|
|
13
|
+
// on the frame. And where a screen takes fingers as well as a mouse, one
|
|
14
|
+
// may come down in the frame whatever the page knows of the mouse.
|
|
15
|
+
const now = () => performance.now();
|
|
16
|
+
const watches = new WeakMap();
|
|
17
|
+
const isFrame = (el) => el?.localName === 'iframe' || el?.localName === 'frame';
|
|
18
|
+
// What an event was dispatched at. For a frame inside a shadow tree the
|
|
19
|
+
// document is told the tree's host instead; the event's path still starts
|
|
20
|
+
// at the frame (where the tree is closed it does not: `inside()` then goes
|
|
21
|
+
// by whether the frame is hovered).
|
|
22
|
+
const targetOf = (e) => e.composedPath?.()[0] ?? e.target;
|
|
23
|
+
/** The pointer in `doc`, followed from now on. One watch per document. */
|
|
24
|
+
export function watchPointer(doc) {
|
|
25
|
+
const known = watches.get(doc);
|
|
26
|
+
if (known)
|
|
27
|
+
return known;
|
|
28
|
+
const win = doc.defaultView;
|
|
29
|
+
const state = { kind: 'unknown', type: '', x: 0, y: 0, at: 0, moved: false };
|
|
30
|
+
// Weakly: the frame is the host's, and may be gone before the pointer moves again.
|
|
31
|
+
let frame;
|
|
32
|
+
const listeners = new Set();
|
|
33
|
+
let queued = false;
|
|
34
|
+
const tell = () => {
|
|
35
|
+
if (queued)
|
|
36
|
+
return;
|
|
37
|
+
queued = true;
|
|
38
|
+
queueMicrotask(() => {
|
|
39
|
+
queued = false;
|
|
40
|
+
for (const ref of [...listeners]) {
|
|
41
|
+
const fn = ref.deref();
|
|
42
|
+
if (fn)
|
|
43
|
+
fn();
|
|
44
|
+
else
|
|
45
|
+
listeners.delete(ref);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const on = (ev) => {
|
|
50
|
+
// Only the user's own pointer counts, not an event a script made up.
|
|
51
|
+
if (!ev.isTrusted)
|
|
52
|
+
return;
|
|
53
|
+
const e = ev;
|
|
54
|
+
const type = e.pointerType || 'mouse';
|
|
55
|
+
// A pointer that went into a frame comes out of it with a move the page
|
|
56
|
+
// gets to see. A bare pointerover on something of the page's, with no
|
|
57
|
+
// move, is the browser bringing hover up to date (a dialog opened over
|
|
58
|
+
// the frame, the frame was hidden): it is dispatched where the PAGE last
|
|
59
|
+
// saw the pointer, which is where it went into the frame, not where it
|
|
60
|
+
// is. It says nothing about the pointer having left.
|
|
61
|
+
const target = targetOf(e);
|
|
62
|
+
if (e.type === 'pointerover' && type !== 'touch' && state.kind === 'frame' && !isFrame(target))
|
|
63
|
+
return;
|
|
64
|
+
const here = e.clientX === state.x && e.clientY === state.y;
|
|
65
|
+
const again = here && state.kind === 'frame' && frame?.deref() === target;
|
|
66
|
+
// (Told twice of the same arrival, it is still the one arrival.)
|
|
67
|
+
if (!isFrame(target) || type === 'touch')
|
|
68
|
+
state.moved = true;
|
|
69
|
+
else if (!again)
|
|
70
|
+
state.moved = state.kind === 'away' || ((state.kind === 'host' || state.kind === 'frame') && !here);
|
|
71
|
+
state.type = type;
|
|
72
|
+
state.at = now();
|
|
73
|
+
state.x = e.clientX;
|
|
74
|
+
state.y = e.clientY;
|
|
75
|
+
if (type === 'touch') {
|
|
76
|
+
state.kind = e.type === 'pointerup' || e.type === 'pointercancel' ? 'none' : 'host';
|
|
77
|
+
frame = undefined;
|
|
78
|
+
}
|
|
79
|
+
else if (isFrame(target)) {
|
|
80
|
+
state.kind = 'frame';
|
|
81
|
+
frame = new WeakRef(target);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
state.kind = 'host';
|
|
85
|
+
frame = undefined;
|
|
86
|
+
}
|
|
87
|
+
tell();
|
|
88
|
+
};
|
|
89
|
+
for (const type of ['pointerover', 'pointermove', 'pointerdown', 'pointerup', 'pointercancel']) {
|
|
90
|
+
doc.addEventListener(type, on, { capture: true, passive: true });
|
|
91
|
+
}
|
|
92
|
+
// Out of the window altogether. (The root element is also "left" when a
|
|
93
|
+
// modal dialog opens under a pointer that has not moved, since everything
|
|
94
|
+
// but the dialog goes inert: that is not the pointer going anywhere, and it
|
|
95
|
+
// shows in where the event says the pointer is.)
|
|
96
|
+
doc.documentElement.addEventListener('pointerleave', (ev) => {
|
|
97
|
+
const e = ev;
|
|
98
|
+
if (!e.isTrusted || e.pointerType === 'touch')
|
|
99
|
+
return;
|
|
100
|
+
if (e.clientX > 1 && e.clientY > 1 && e.clientX < win.innerWidth - 1 && e.clientY < win.innerHeight - 1)
|
|
101
|
+
return;
|
|
102
|
+
state.kind = 'away';
|
|
103
|
+
state.moved = true;
|
|
104
|
+
frame = undefined;
|
|
105
|
+
state.at = now();
|
|
106
|
+
tell();
|
|
107
|
+
});
|
|
108
|
+
const watch = {
|
|
109
|
+
state,
|
|
110
|
+
get frame() { return frame?.deref(); },
|
|
111
|
+
get hovers() {
|
|
112
|
+
if (state.type)
|
|
113
|
+
return state.type !== 'touch';
|
|
114
|
+
return win.matchMedia?.('(hover: hover)').matches ?? true;
|
|
115
|
+
},
|
|
116
|
+
get fingers() { return (win.navigator?.maxTouchPoints ?? 0) > 0; },
|
|
117
|
+
inside(el) {
|
|
118
|
+
return (state.kind === 'frame' && frame?.deref() === el) || (state.type !== 'touch' && el.matches(':hover'));
|
|
119
|
+
},
|
|
120
|
+
onChange(fn) {
|
|
121
|
+
const ref = new WeakRef(fn);
|
|
122
|
+
listeners.add(ref);
|
|
123
|
+
return () => { listeners.delete(ref); };
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
watches.set(doc, watch);
|
|
127
|
+
return watch;
|
|
128
|
+
}
|
|
129
|
+
/** The class of a shield's element, for a host's own rules to know it by. */
|
|
130
|
+
export const SHIELD_CLASS = 'tile-shield';
|
|
131
|
+
// Not quite transparent, on purpose. Which process gets a press, the page's
|
|
132
|
+
// or a frame's under it, is the browser's to decide, from what the page last
|
|
133
|
+
// drew. A block that paints nothing changes nothing in what was drawn, and a
|
|
134
|
+
// press on a pointer that has not moved then goes straight to the frame
|
|
135
|
+
// underneath. A tint too faint to see is enough.
|
|
136
|
+
const SHIELD_TINT = 'rgba(127,127,127,0.03)';
|
|
137
|
+
const SWALLOWED = ['pointerdown', 'pointerup', 'mousedown', 'mouseup', 'click', 'dblclick', 'auxclick', 'contextmenu'];
|
|
138
|
+
// Where a block has to be put to lie over `el`: in the page's body, unless
|
|
139
|
+
// `el` is shown in the browser's top layer (a modal dialog, a popover, an
|
|
140
|
+
// element gone fullscreen), which is drawn over everything in the body.
|
|
141
|
+
function layerOf(el, doc) {
|
|
142
|
+
for (let node = el ?? null; node; node = node.parentNode ?? node.host ?? null) {
|
|
143
|
+
if (node.nodeType !== 1)
|
|
144
|
+
continue;
|
|
145
|
+
const e = node;
|
|
146
|
+
if (e === doc.fullscreenElement || (e.localName === 'dialog' && e.open))
|
|
147
|
+
return e;
|
|
148
|
+
try {
|
|
149
|
+
if (e.hasAttribute('popover') && e.matches(':popover-open'))
|
|
150
|
+
return e;
|
|
151
|
+
}
|
|
152
|
+
catch { /* a browser without popovers */ }
|
|
153
|
+
}
|
|
154
|
+
return doc.body;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A piece of the page that takes no press for a moment: a block of the
|
|
158
|
+
* host's, all but invisible, on top of everything, where `rect()` says (and
|
|
159
|
+
* it is asked again as the page scrolls). It goes `ms` after the last press
|
|
160
|
+
* on it; a press on it is swallowed and starts the wait again; and while a
|
|
161
|
+
* mouse rests on it, it stays until the mouse has left, or has rested there
|
|
162
|
+
* `dwellMs` without pressing. A `sticky` one stays until it has swallowed a
|
|
163
|
+
* press (then `ms`), or for `maxMs`. A wheel or a finger still scrolls the
|
|
164
|
+
* page through it.
|
|
165
|
+
*/
|
|
166
|
+
export function shield(doc, rect, options) {
|
|
167
|
+
const win = doc.defaultView;
|
|
168
|
+
const { ms, dwellMs, sticky = false, maxMs = ms } = options;
|
|
169
|
+
const el = doc.createElement('div');
|
|
170
|
+
el.className = SHIELD_CLASS;
|
|
171
|
+
el.setAttribute('aria-hidden', 'true');
|
|
172
|
+
el.style.cssText = `position:fixed;z-index:2147483647;margin:0;padding:0;border:0;background:${SHIELD_TINT};`;
|
|
173
|
+
const born = now();
|
|
174
|
+
let armed = born;
|
|
175
|
+
let absorbed = 0;
|
|
176
|
+
let over = false;
|
|
177
|
+
let overSince = 0;
|
|
178
|
+
let gone = false;
|
|
179
|
+
const place = () => {
|
|
180
|
+
const r = rect();
|
|
181
|
+
if (!r || r.width <= 0 || r.height <= 0) {
|
|
182
|
+
el.style.display = 'none';
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
el.style.display = 'block';
|
|
186
|
+
el.style.left = `${r.left}px`;
|
|
187
|
+
el.style.top = `${r.top}px`;
|
|
188
|
+
el.style.width = `${r.width}px`;
|
|
189
|
+
el.style.height = `${r.height}px`;
|
|
190
|
+
};
|
|
191
|
+
const swallow = (ev) => {
|
|
192
|
+
const e = ev;
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
// A finger going down may be the start of a scroll: that is let be, and the tap it may become is what is refused.
|
|
195
|
+
if (e.type !== 'pointerdown' || e.pointerType !== 'touch')
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
if (e.type === 'pointerdown' || e.type === 'click') {
|
|
198
|
+
armed = now();
|
|
199
|
+
overSince = armed;
|
|
200
|
+
if (e.type === 'pointerdown') {
|
|
201
|
+
absorbed++;
|
|
202
|
+
options.onAbsorb?.();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
for (const type of SWALLOWED)
|
|
207
|
+
el.addEventListener(type, swallow);
|
|
208
|
+
el.addEventListener('pointerenter', (e) => { if (e.pointerType !== 'touch') {
|
|
209
|
+
over = true;
|
|
210
|
+
overSince = now();
|
|
211
|
+
} });
|
|
212
|
+
el.addEventListener('pointerleave', () => { over = false; });
|
|
213
|
+
const observer = options.follow && typeof ResizeObserver === 'function' ? new ResizeObserver(place) : undefined;
|
|
214
|
+
const remove = () => {
|
|
215
|
+
if (gone)
|
|
216
|
+
return;
|
|
217
|
+
gone = true;
|
|
218
|
+
el.remove();
|
|
219
|
+
observer?.disconnect();
|
|
220
|
+
win.removeEventListener('scroll', place, true);
|
|
221
|
+
win.removeEventListener('resize', place);
|
|
222
|
+
};
|
|
223
|
+
const tick = () => {
|
|
224
|
+
if (gone)
|
|
225
|
+
return;
|
|
226
|
+
const t = now();
|
|
227
|
+
// A sticky one waits for the press it is there to take: a tile that has
|
|
228
|
+
// its user pressing to a beat slower than `ms` gets past one that only waits.
|
|
229
|
+
const waited = sticky && !absorbed ? t - born >= maxMs : t - armed >= ms;
|
|
230
|
+
if (waited && (!over || t - overSince >= dwellMs))
|
|
231
|
+
return remove();
|
|
232
|
+
place();
|
|
233
|
+
win.setTimeout(tick, 50);
|
|
234
|
+
};
|
|
235
|
+
win.addEventListener('scroll', place, true);
|
|
236
|
+
win.addEventListener('resize', place);
|
|
237
|
+
if (options.follow)
|
|
238
|
+
observer?.observe(options.follow);
|
|
239
|
+
place();
|
|
240
|
+
layerOf(options.follow, doc).append(el);
|
|
241
|
+
win.setTimeout(tick, 50);
|
|
242
|
+
return { get gone() { return gone; }, remove };
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=pointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.js","sourceRoot":"","sources":["../../src/lib/pointer.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAC3E,yEAAyE;AACzE,0BAA0B;AAC1B,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,wDAAwD;AACxD,4EAA4E;AAC5E,2EAA2E;AAC3E,qE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,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzB,OAAO,EAAE,IAAI,IAAI,KAAM,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes `frame` out of the tab order until the function it returns is
|
|
3
|
+
* called. That puts it back only if nothing else holds it out by then; a
|
|
4
|
+
* second call does nothing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function holdOut(frame: Element): () => void;
|
|
7
|
+
/**
|
|
8
|
+
* Lets `frame`, which something holds out of the tab order, into it for a
|
|
9
|
+
* moment, until the function it returns is called or something takes it out
|
|
10
|
+
* again (a hold taken meanwhile): the user's next Tab can then take them into
|
|
11
|
+
* it, as a Tab into any frame in the tab order does. Then it is out, for as
|
|
12
|
+
* long as anything holds it, and as its host made it once nothing does. A
|
|
13
|
+
* frame nothing holds out is where its host put it, and is left so.
|
|
14
|
+
*/
|
|
15
|
+
export declare function letIn(frame: Element): () => void;
|
|
16
|
+
//# sourceMappingURL=tab-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-order.d.ts","sourceRoot":"","sources":["../../src/lib/tab-order.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,wBAAgB,OAAO,CAAE,KAAK,EAAE,OAAO,GAAG,MAAM,IAAI,CAoBnD;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAE,KAAK,EAAE,OAAO,GAAG,MAAM,IAAI,CAWjD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// A tile's frame out of the tab order, for as long as something needs it
|
|
2
|
+
// out: a layer of the page's over the tile, which is where Tab stops then,
|
|
3
|
+
// or a tile that waits to be picked. More than one may need it out at once,
|
|
4
|
+
// and each lets go in its own time. Were each to note the frame's tabindex
|
|
5
|
+
// and put back what it found, one that let go after another had taken the
|
|
6
|
+
// frame out would put it back in under the other's layer, or one that took
|
|
7
|
+
// it out after another would leave it out for good. So they all go through
|
|
8
|
+
// here: the frame is out while anything holds it, and once the last lets go
|
|
9
|
+
// it is given back the tabindex its host gave it, or none if it had none.
|
|
10
|
+
// And a frame held out can be let in for a moment, for one Tab of the
|
|
11
|
+
// user's into it, which goes through here as well (see `letIn`).
|
|
12
|
+
const held = new WeakMap();
|
|
13
|
+
/**
|
|
14
|
+
* Takes `frame` out of the tab order until the function it returns is
|
|
15
|
+
* called. That puts it back only if nothing else holds it out by then; a
|
|
16
|
+
* second call does nothing.
|
|
17
|
+
*/
|
|
18
|
+
export function holdOut(frame) {
|
|
19
|
+
let hold = held.get(frame);
|
|
20
|
+
if (!hold) {
|
|
21
|
+
hold = { own: frame.getAttribute('tabindex'), holds: 0 };
|
|
22
|
+
held.set(frame, hold);
|
|
23
|
+
}
|
|
24
|
+
const mine = hold;
|
|
25
|
+
mine.holds++;
|
|
26
|
+
// (Out, whatever let it in a moment ago: something needs it out now.)
|
|
27
|
+
mine.open = undefined;
|
|
28
|
+
frame.setAttribute('tabindex', '-1');
|
|
29
|
+
let done = false;
|
|
30
|
+
return () => {
|
|
31
|
+
if (done)
|
|
32
|
+
return;
|
|
33
|
+
done = true;
|
|
34
|
+
if (--mine.holds > 0)
|
|
35
|
+
return;
|
|
36
|
+
held.delete(frame);
|
|
37
|
+
if (mine.own === null)
|
|
38
|
+
frame.removeAttribute('tabindex');
|
|
39
|
+
else
|
|
40
|
+
frame.setAttribute('tabindex', mine.own);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Lets `frame`, which something holds out of the tab order, into it for a
|
|
45
|
+
* moment, until the function it returns is called or something takes it out
|
|
46
|
+
* again (a hold taken meanwhile): the user's next Tab can then take them into
|
|
47
|
+
* it, as a Tab into any frame in the tab order does. Then it is out, for as
|
|
48
|
+
* long as anything holds it, and as its host made it once nothing does. A
|
|
49
|
+
* frame nothing holds out is where its host put it, and is left so.
|
|
50
|
+
*/
|
|
51
|
+
export function letIn(frame) {
|
|
52
|
+
const hold = held.get(frame);
|
|
53
|
+
if (!hold)
|
|
54
|
+
return () => { };
|
|
55
|
+
const moment = {};
|
|
56
|
+
hold.open = moment;
|
|
57
|
+
frame.setAttribute('tabindex', '0');
|
|
58
|
+
return () => {
|
|
59
|
+
if (hold.open !== moment)
|
|
60
|
+
return;
|
|
61
|
+
hold.open = undefined;
|
|
62
|
+
if (held.get(frame) === hold)
|
|
63
|
+
frame.setAttribute('tabindex', '-1');
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=tab-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-order.js","sourceRoot":"","sources":["../../src/lib/tab-order.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,0EAA0E;AAC1E,sEAAsE;AACtE,iEAAiE;AAOjE,MAAM,IAAI,GAAG,IAAI,OAAO,EAAiB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAE,KAAc;IACrC,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,sEAAsE;IACtE,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACtB,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACrC,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,OAAO,GAAG,EAAE;QACV,IAAI,IAAI;YAAE,OAAO;QACjB,IAAI,GAAG,IAAI,CAAC;QACZ,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;YAAE,OAAO;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI;YAAE,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;;YACpD,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAE,KAAc;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,IAAI;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;IACnB,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACpC,OAAO,GAAG,EAAE;QACV,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO;QACjC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI;YAAE,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/link.d.ts
CHANGED
|
@@ -3,17 +3,41 @@ import type { Tile } from './index.js';
|
|
|
3
3
|
export declare const LINK_PROTOCOL = "link";
|
|
4
4
|
export interface LinkRequest {
|
|
5
5
|
/**
|
|
6
|
-
* Whether the user has just
|
|
7
|
-
*
|
|
8
|
-
* itself
|
|
6
|
+
* Whether the user has just pressed or typed inside this tile: its dock,
|
|
7
|
+
* which the tile cannot script, says so with the request. False means the
|
|
8
|
+
* tile is asking by itself, or while the user is busy elsewhere on the
|
|
9
|
+
* page; a host has every reason to refuse then.
|
|
10
|
+
*
|
|
11
|
+
* A loading server from before its dock said this leaves the older, wider
|
|
12
|
+
* meaning: the user has just interacted with the page, anywhere on it.
|
|
9
13
|
*/
|
|
10
14
|
activated: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The dock's word by itself: whether the user has just pressed or typed
|
|
17
|
+
* inside this tile. Left out where the dock said nothing. `activated` is
|
|
18
|
+
* this and `pageActivated` together; a host with a rule of its own reads
|
|
19
|
+
* them here. Read it to refuse, never by itself to grant: a loading server
|
|
20
|
+
* from before its dock said this passes on, under the dock's name,
|
|
21
|
+
* whatever the tile put there.
|
|
22
|
+
*/
|
|
23
|
+
dockActivated?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The page's word by itself: whether the user has just pressed or typed
|
|
26
|
+
* anywhere on the page (`navigator.userActivation.isActive`). Left out
|
|
27
|
+
* where the browser does not say, as some WebViews do not.
|
|
28
|
+
*/
|
|
29
|
+
pageActivated?: boolean;
|
|
11
30
|
/**
|
|
12
31
|
* Set when the tile asked from script and waits for an answer. A handler
|
|
13
32
|
* that returns nothing answers later itself, with
|
|
14
33
|
* `tile.sendProtocol('link', 'result', { id, opened })`.
|
|
15
34
|
*/
|
|
16
35
|
id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The tile's frame, when the host named it to `tileLinks`: where the tile
|
|
38
|
+
* may have had its user pressing, which a prompt keeps clear of.
|
|
39
|
+
*/
|
|
40
|
+
frame?: HTMLElement;
|
|
17
41
|
}
|
|
18
42
|
/**
|
|
19
43
|
* Decides about one link: `true` if the host opened it, `false` if it did
|
|
@@ -25,6 +49,17 @@ export interface TileLinksOptions {
|
|
|
25
49
|
open?: LinkHandler;
|
|
26
50
|
/** The URL schemes that reach `open`; any other is refused. Default: `http:` and `https:`. */
|
|
27
51
|
schemes?: string[];
|
|
52
|
+
/** The frame the tile runs in. It is handed to `open` with each request, for a prompt to keep clear of. */
|
|
53
|
+
frame?: HTMLElement;
|
|
54
|
+
/** The longest address, in characters, that reaches `open`, as the tile sent it and as `open` is handed it; a longer one is refused. Default: 8192. */
|
|
55
|
+
maxLength?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a request that arrives while `open` is still deciding about
|
|
58
|
+
* another (it returned a promise that has not settled) is refused, as it
|
|
59
|
+
* is by default, or handed to `open` as well (`false`), for a host that
|
|
60
|
+
* queues them or decides about several at once.
|
|
61
|
+
*/
|
|
62
|
+
oneAtATime?: boolean;
|
|
28
63
|
}
|
|
29
64
|
export interface TileLinksControl {
|
|
30
65
|
/** Stops listening. Links out of the tile then do nothing, and go unanswered. */
|
|
@@ -39,23 +74,85 @@ export declare function tileLinks(tile: Tile, options?: TileLinksOptions): TileL
|
|
|
39
74
|
*/
|
|
40
75
|
export declare function openInNewTab(url: URL): boolean;
|
|
41
76
|
export interface LinkPromptOptions {
|
|
42
|
-
/** The words before the destination. Default: "This tile wants to open". */
|
|
77
|
+
/** The words before the destination. Default: "This tile wants to open a page on". */
|
|
43
78
|
label?: string;
|
|
44
79
|
/** The word on the button that refuses. Default: "Dismiss". */
|
|
45
80
|
dismiss?: string;
|
|
81
|
+
/** The word before the destination on the button that opens. Default: "Open". */
|
|
82
|
+
open?: string;
|
|
83
|
+
/** What is said of an address that is not what it may look like. Each has a default, in English. */
|
|
84
|
+
notes?: {
|
|
85
|
+
/** The link is plain http. */
|
|
86
|
+
insecure?: string;
|
|
87
|
+
/** The address has a user name in it, which can be made to read like a host. */
|
|
88
|
+
userinfo?: string;
|
|
89
|
+
/** The host's name is in its encoded form (`xn--`), so in letters other than the ones shown. */
|
|
90
|
+
encoded?: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The registrable domain of a host name (`example.co.uk` for
|
|
94
|
+
* `a.b.example.co.uk`), from a public suffix list of the host's own. With
|
|
95
|
+
* it the prompt sets the site apart from its subdomains; without it the
|
|
96
|
+
* whole name is given the same weight.
|
|
97
|
+
*/
|
|
98
|
+
registrableDomain?: (host: string) => string | undefined;
|
|
99
|
+
/** How long the button that opens does nothing: after the prompt appears, and after any press or key that came too soon. Milliseconds; `LINK_PROMPT.armMs` by default. */
|
|
100
|
+
armMs?: number;
|
|
101
|
+
/** How far the pointer has to really move before that button works. Pixels; `LINK_PROMPT.travel` by default. */
|
|
102
|
+
travel?: number;
|
|
103
|
+
/** How long no prompt is shown after the user has dismissed one. Milliseconds; `LINK_PROMPT.restMs` by default. */
|
|
104
|
+
restMs?: number;
|
|
105
|
+
/** How much of a long address is shown after its host. Characters; `LINK_PROMPT.maxShown` by default. */
|
|
106
|
+
maxShown?: number;
|
|
46
107
|
}
|
|
108
|
+
/** The numbers `linkPrompt` goes by where a host gives none. First guesses. */
|
|
109
|
+
export declare const LINK_PROMPT: Readonly<{
|
|
110
|
+
armMs: number;
|
|
111
|
+
travel: number;
|
|
112
|
+
restMs: number;
|
|
113
|
+
maxShown: number;
|
|
114
|
+
}>;
|
|
47
115
|
/**
|
|
48
|
-
* A link handler that leaves it to the user:
|
|
49
|
-
* the tile wants to go
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* the user follows the link, and it opens in a new tab, never in the tile.
|
|
116
|
+
* A link handler that leaves it to the user: a dialog of the host's own says
|
|
117
|
+
* where the tile wants to go and offers a link to follow, with a button to
|
|
118
|
+
* dismiss it. Nothing opens unless the user follows the link, and it opens
|
|
119
|
+
* in a new tab, never in the tile.
|
|
53
120
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
121
|
+
* - It says where. The host's name stands alone on a line, large; a user
|
|
122
|
+
* name in the address, plain http and an encoded name are called out; and
|
|
123
|
+
* the whole address is there to read, since the address is where a tile
|
|
124
|
+
* would put what it wants to send out.
|
|
125
|
+
* - One at a time, for the whole page: while one is showing, a request from
|
|
126
|
+
* any tile is refused. Nothing replaces what the user is reading, and for
|
|
127
|
+
* `restMs` after they have dismissed one nothing comes up in its place: a
|
|
128
|
+
* prompt that is back at once, with its link where the button that
|
|
129
|
+
* dismisses was, is not one anybody has read. A request that arrives when
|
|
130
|
+
* the user has not acted in the tile is refused outright.
|
|
131
|
+
* - It is a modal dialog, on top of the page: nothing a tile does to its
|
|
132
|
+
* size or to the page's scroll moves it.
|
|
133
|
+
* - The link does nothing for `armMs` after the dialog appears, and any press
|
|
134
|
+
* or key in that time starts the wait again: a press that was already on
|
|
135
|
+
* its way when the dialog came up opens nothing, nor does the third of a
|
|
136
|
+
* run of them. A press is judged by when it was made, not by when a page
|
|
137
|
+
* that was busy got to hear of it. Focus starts on the button that
|
|
138
|
+
* dismisses, which always works, as does Escape. A press beside the dialog
|
|
139
|
+
* does nothing.
|
|
140
|
+
* - The link also waits until the pointer has really moved (`travel`
|
|
141
|
+
* pixels), or the keyboard has been taken to it (Tab, a screen reader):
|
|
142
|
+
* a pointer that rests where the link came up opens nothing, however
|
|
143
|
+
* long the tile has its user wait.
|
|
144
|
+
* - It keeps clear of the tile that asked, when `tileLinks` was told its
|
|
145
|
+
* frame: the dialog goes above or below the frame, where there is room.
|
|
146
|
+
* That is not somewhere the pointer cannot be: a tile can move itself, and
|
|
147
|
+
* the page, between the press and the prompt.
|
|
148
|
+
* - Where it was takes no press for a moment once a press has dismissed it:
|
|
149
|
+
* the second click of a double click does not go through to the page.
|
|
56
150
|
*
|
|
57
|
-
* The
|
|
58
|
-
*
|
|
151
|
+
* The dialog element is put in `container` (so it is styled with that part
|
|
152
|
+
* of the page, and goes with it), wherever in the page that is. It is plain
|
|
153
|
+
* elements with a few class names for a host to style: `tile-link-dialog`,
|
|
154
|
+
* `tile-link-host`, `tile-link-note`, `tile-link-url`, `tile-link-open`,
|
|
155
|
+
* `tile-link-dismiss`.
|
|
59
156
|
*/
|
|
60
157
|
export declare function linkPrompt(container: HTMLElement, options?: LinkPromptOptions): LinkHandler;
|
|
61
158
|
//# sourceMappingURL=link.d.ts.map
|
package/dist/link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAA4B,IAAI,EAAE,MAAM,YAAY,CAAC;AAGjE,6CAA6C;AAC7C,eAAO,MAAM,aAAa,SAAS,CAAC;AAKpC,MAAM,WAAW,WAAW;IAC1B;;;;;;;;OAQG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAEvG,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,2GAA2G;IAC3G,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,uJAAuJ;IACvJ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,IAAI,IAAK,IAAI,CAAC;CACf;AAmBD,wEAAwE;AACxE,wBAAgB,SAAS,CAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,gBAAqB,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