@dasl/tile-loader 3.2.0 → 5.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 +773 -41
- package/dist/at.d.ts.map +1 -1
- package/dist/at.js +11 -3
- package/dist/at.js.map +1 -1
- package/dist/car.d.ts.map +1 -1
- package/dist/car.js +6 -2
- package/dist/car.js.map +1 -1
- package/dist/guard.d.ts +110 -10
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +647 -59
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +253 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +512 -56
- package/dist/index.js.map +1 -1
- 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/mount.d.ts.map +1 -1
- package/dist/mount.js +4 -1
- package/dist/mount.js.map +1 -1
- package/package.json +2 -2
- package/src/at.ts +11 -3
- package/src/car.ts +6 -2
- package/src/guard.ts +701 -55
- package/src/index.ts +585 -59
- package/src/lib/tab-order.ts +66 -0
- package/src/mount.ts +4 -1
|
@@ -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
|
+
|
|
13
|
+
interface Held {
|
|
14
|
+
own: string | null; // the host's tabindex, as it was at the first hold
|
|
15
|
+
holds: number;
|
|
16
|
+
open?: object; // the moment it is let in for, while it is (see `letIn`)
|
|
17
|
+
}
|
|
18
|
+
const held = new WeakMap<Element, Held>();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Takes `frame` out of the tab order until the function it returns is
|
|
22
|
+
* called. That puts it back only if nothing else holds it out by then; a
|
|
23
|
+
* second call does nothing.
|
|
24
|
+
*/
|
|
25
|
+
export function holdOut (frame: Element): () => void {
|
|
26
|
+
let hold = held.get(frame);
|
|
27
|
+
if (!hold) {
|
|
28
|
+
hold = { own: frame.getAttribute('tabindex'), holds: 0 };
|
|
29
|
+
held.set(frame, hold);
|
|
30
|
+
}
|
|
31
|
+
const mine = hold;
|
|
32
|
+
mine.holds++;
|
|
33
|
+
// (Out, whatever let it in a moment ago: something needs it out now.)
|
|
34
|
+
mine.open = undefined;
|
|
35
|
+
frame.setAttribute('tabindex', '-1');
|
|
36
|
+
let done = false;
|
|
37
|
+
return () => {
|
|
38
|
+
if (done) return;
|
|
39
|
+
done = true;
|
|
40
|
+
if (--mine.holds > 0) return;
|
|
41
|
+
held.delete(frame);
|
|
42
|
+
if (mine.own === null) frame.removeAttribute('tabindex');
|
|
43
|
+
else frame.setAttribute('tabindex', mine.own);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Lets `frame`, which something holds out of the tab order, into it for a
|
|
49
|
+
* moment, until the function it returns is called or something takes it out
|
|
50
|
+
* again (a hold taken meanwhile): the user's next Tab can then take them into
|
|
51
|
+
* it, as a Tab into any frame in the tab order does. Then it is out, for as
|
|
52
|
+
* long as anything holds it, and as its host made it once nothing does. A
|
|
53
|
+
* frame nothing holds out is where its host put it, and is left so.
|
|
54
|
+
*/
|
|
55
|
+
export function letIn (frame: Element): () => void {
|
|
56
|
+
const hold = held.get(frame);
|
|
57
|
+
if (!hold) return () => {};
|
|
58
|
+
const moment = {};
|
|
59
|
+
hold.open = moment;
|
|
60
|
+
frame.setAttribute('tabindex', '0');
|
|
61
|
+
return () => {
|
|
62
|
+
if (hold.open !== moment) return;
|
|
63
|
+
hold.open = undefined;
|
|
64
|
+
if (held.get(frame) === hold) frame.setAttribute('tabindex', '-1');
|
|
65
|
+
};
|
|
66
|
+
}
|
package/src/mount.ts
CHANGED
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
//
|
|
20
20
|
// A tile that is put away is closed (Tile.close()): its frame goes, and the
|
|
21
21
|
// origin it ran on is wiped. Shown again, it starts afresh, on another
|
|
22
|
-
// origin
|
|
22
|
+
// origin (or on the one its CID names, wiped). So this is for tiles whose
|
|
23
|
+
// state the host does not mean to keep, unless they run on an origin that is
|
|
24
|
+
// kept (a named one: see `tile.ephemeral`), where a tile shown again finds
|
|
25
|
+
// what it stored there.
|
|
23
26
|
//
|
|
24
27
|
// Starting a tile is the costly moment (its runtime spends the browser's
|
|
25
28
|
// WebRTC budget first, where there is one), so tiles are also started a few
|