@dasl/tile-loader 2.3.0 → 2.5.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 +18 -4
- package/dist/data.d.ts +14 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +36 -0
- package/dist/data.js.map +1 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/size.d.ts +32 -0
- package/dist/size.d.ts.map +1 -0
- package/dist/size.js +159 -0
- package/dist/size.js.map +1 -0
- package/package.json +12 -2
- package/src/data.ts +47 -0
- package/src/index.ts +19 -6
- package/src/size.ts +183 -0
package/README.md
CHANGED
|
@@ -77,10 +77,24 @@ Three cooperating layers, all talking over `postMessage`:
|
|
|
77
77
|
(metadata only; safe to render many at once). `options.contentHeight` presets the
|
|
78
78
|
height used when the card is clicked to expand.
|
|
79
79
|
- **`renderContent(height?)`** — the sandboxed iframe that runs the tile.
|
|
80
|
-
- **`
|
|
81
|
-
the rendered tile over
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
- **`sendProtocol(protocol, kind, payload?)`** and the **`protocol`** event
|
|
81
|
+
(`ev.protocol`, `ev.kind`, `ev.payload`) — talk to the rendered tile over
|
|
82
|
+
[tiles protocols](https://dasl.ing/tiles-protocols.html). The loader attaches
|
|
83
|
+
no meaning to any protocol.
|
|
84
|
+
- For [tp-size](https://dasl.ing/tp-size.html), `@dasl/tile-loader/size` is the
|
|
85
|
+
context's side of a tile negotiating its size:
|
|
86
|
+
`tileSize(tile, frame, { limits: { maxHeight: 800 } })` starts the frame at
|
|
87
|
+
the size the manifest's `sizing` asks for, follows what the tile asks for
|
|
88
|
+
from then on (its own requests, or its content's size when the manifest
|
|
89
|
+
declares `fit`), inside your limits and never under the floor, and tells
|
|
90
|
+
the tile what it got. `apply: false` is for a host that sizes its own box
|
|
91
|
+
(it gets each request in `onRequest`); `width: 'tile'` hands the width over
|
|
92
|
+
too. The rules are `resolveSize` in `@dasl/tile-lexicon`.
|
|
93
|
+
- For [tp-data](https://dasl.ing/tp-data.html), `@dasl/tile-loader/data` names
|
|
94
|
+
the two kinds: `const data = tileData(tile)`, then `data.send(payload)`,
|
|
95
|
+
`data.onData(fn)` and `data.onReady(fn)` (each `on…` returns a function that
|
|
96
|
+
stops it). `Tile.sendData()` and the `data` / `data-ready` events still work
|
|
97
|
+
and are deprecated: they go in the next major version.
|
|
84
98
|
- **`url`**, **`manifest`** — the tile's URL and MASL metadata.
|
|
85
99
|
|
|
86
100
|
### Loaders
|
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Tile } from './index.js';
|
|
2
|
+
/** The tiles protocol this module speaks. */
|
|
3
|
+
export declare const DATA_PROTOCOL = "data";
|
|
4
|
+
export interface TileData {
|
|
5
|
+
/** Sends a payload to the tile; it is structured-cloned on the way. Throws if the tile is not rendered yet. */
|
|
6
|
+
send(payload: unknown): void;
|
|
7
|
+
/** Calls `handler` with each payload the tile sends. Returns a function that stops it. */
|
|
8
|
+
onData(handler: (payload: unknown) => void): () => void;
|
|
9
|
+
/** Calls `handler` when the tile says it is ready for data (`listen()`). Returns a function that stops it. */
|
|
10
|
+
onReady(handler: () => void): () => void;
|
|
11
|
+
}
|
|
12
|
+
/** tp-data on a tile: send it payloads, hear the ones it sends and when it is ready. */
|
|
13
|
+
export declare function tileData(tile: Tile): TileData;
|
|
14
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAiB,IAAI,EAAE,MAAM,YAAY,CAAC;AAEtD,6CAA6C;AAC7C,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC,MAAM,WAAW,QAAQ;IACvB,+GAA+G;IAC/G,IAAI,CAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,0FAA0F;IAC1F,MAAM,CAAE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACzD,8GAA8G;IAC9G,OAAO,CAAE,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC3C;AAED,wFAAwF;AACxF,wBAAgB,QAAQ,CAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,CAc9C"}
|
package/dist/data.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The host side of tp-data (https://dasl.ing/tp-data.html), the tiles
|
|
2
|
+
// protocol for passing data to and from a tile, as a convenience over the
|
|
3
|
+
// generic protocol API.
|
|
4
|
+
//
|
|
5
|
+
// The loader itself attaches no meaning to any protocol: `Tile.sendProtocol()`
|
|
6
|
+
// sends one message down, and what a tile sends up arrives as `protocol`
|
|
7
|
+
// events. tp-data is two kinds on the `data` protocol, `ready` (the tile has
|
|
8
|
+
// called `listen()`) and `payload`. This module names them:
|
|
9
|
+
//
|
|
10
|
+
// import { tileData } from '@dasl/tile-loader/data';
|
|
11
|
+
// const data = tileData(tile);
|
|
12
|
+
// data.onReady(() => data.send({ name: 'world' }));
|
|
13
|
+
// const stop = data.onData((payload) => console.log(payload));
|
|
14
|
+
//
|
|
15
|
+
// It replaces `Tile.sendData()` and the `data` / `data-ready` events, which
|
|
16
|
+
// the loader still has but deprecates.
|
|
17
|
+
/** The tiles protocol this module speaks. */
|
|
18
|
+
export const DATA_PROTOCOL = 'data';
|
|
19
|
+
/** tp-data on a tile: send it payloads, hear the ones it sends and when it is ready. */
|
|
20
|
+
export function tileData(tile) {
|
|
21
|
+
const on = (kind, handler) => {
|
|
22
|
+
const listener = (ev) => {
|
|
23
|
+
const { protocol, kind: got, payload } = ev;
|
|
24
|
+
if (protocol === DATA_PROTOCOL && got === kind)
|
|
25
|
+
handler(payload);
|
|
26
|
+
};
|
|
27
|
+
tile.addEventListener('protocol', listener);
|
|
28
|
+
return () => tile.removeEventListener('protocol', listener);
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
send: (payload) => tile.sendProtocol(DATA_PROTOCOL, 'payload', payload),
|
|
32
|
+
onData: (handler) => on('payload', handler),
|
|
33
|
+
onReady: (handler) => on('ready', () => handler()),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=data.js.map
|
package/dist/data.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,0EAA0E;AAC1E,wBAAwB;AACxB,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,6EAA6E;AAC7E,4DAA4D;AAC5D,EAAE;AACF,uDAAuD;AACvD,iCAAiC;AACjC,sDAAsD;AACtD,iEAAiE;AACjE,EAAE;AACF,4EAA4E;AAC5E,uCAAuC;AAIvC,6CAA6C;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAWpC,wFAAwF;AACxF,MAAM,UAAU,QAAQ,CAAE,IAAU;IAClC,MAAM,EAAE,GAAG,CAAC,IAAY,EAAE,OAAmC,EAAE,EAAE;QAC/D,MAAM,QAAQ,GAAG,CAAC,EAAS,EAAE,EAAE;YAC7B,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAmB,CAAC;YAC7D,IAAI,QAAQ,KAAK,aAAa,IAAI,GAAG,KAAK,IAAI;gBAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACnE,CAAC,CAAC;QACF,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,OAAO;QACL,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC;QACvE,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC;QAC3C,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,13 +15,17 @@ export interface TileLoader {
|
|
|
15
15
|
export interface TilePathLoader {
|
|
16
16
|
resolvePath(path: string): Promise<MaslResponse>;
|
|
17
17
|
}
|
|
18
|
-
/** A tiles-protocol message from a tile: `protocol` ("data"), `kind` ("payload", "ready"), and its `payload`. */
|
|
18
|
+
/** A tiles-protocol message from a tile: `protocol` ("data"), `kind` ("payload", "ready"), and its `payload`. The mothership attaches no meaning to any of them. */
|
|
19
19
|
export interface ProtocolEvent extends Event {
|
|
20
20
|
protocol: string;
|
|
21
21
|
kind: string;
|
|
22
22
|
payload: unknown;
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* A tp-data message from a tile; `payload` is what the tile sent.
|
|
26
|
+
* @deprecated The `data` and `data-ready` events go in the next major
|
|
27
|
+
* version. Use `tileData()` from `@dasl/tile-loader/data`, or the `protocol` event.
|
|
28
|
+
*/
|
|
25
29
|
export interface DataEvent extends Event {
|
|
26
30
|
payload: unknown;
|
|
27
31
|
}
|
|
@@ -56,11 +60,15 @@ export declare class Tile extends EventTarget {
|
|
|
56
60
|
getLoadSource(): string;
|
|
57
61
|
/**
|
|
58
62
|
* Sends a tiles-protocol message down to the rendered tile. Messages the
|
|
59
|
-
* tile sends up arrive as `protocol` events
|
|
60
|
-
*
|
|
63
|
+
* tile sends up arrive as `protocol` events on this object. What a protocol
|
|
64
|
+
* means is up to the caller (see `@dasl/tile-loader/data` for tp-data).
|
|
61
65
|
*/
|
|
62
66
|
sendProtocol(protocol: string, kind: string, payload?: unknown): void;
|
|
63
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Sends a tp-data payload to the tile (https://dasl.ing/tp-data.html).
|
|
69
|
+
* @deprecated Goes in the next major version. Use `tileData(tile).send()`
|
|
70
|
+
* from `@dasl/tile-loader/data`, or `sendProtocol('data', 'payload', payload)`.
|
|
71
|
+
*/
|
|
64
72
|
sendData(payload: unknown): void;
|
|
65
73
|
attachIframe(ifr: HTMLIFrameElement): void;
|
|
66
74
|
renderContent(height?: number): HTMLIFrameElement;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,+FAA+F;IAC/F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;CACnF;AACD,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACnD;AAqBD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,+FAA+F;IAC/F,UAAU,CAAC,EAAE,MAAM,CAAC;IACp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EAAE,UAAU,EAAE,cAAc;IAoBnG,IAAI,GAAG,IAAK,MAAM,CAEjB;IACD,IAAI,QAAQ,IAAK,OAAO,CAEvB;IACK,WAAW,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAIjD,UAAU,CAAE,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAgD7E,aAAa,IAAK,MAAM;IAGxB;;;;OAIG;IACH,YAAY,CAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IAI/D;;;;OAIG;IACH,QAAQ,CAAE,OAAO,EAAE,OAAO;IAG1B,YAAY,CAAE,GAAG,EAAE,iBAAiB;IAIpC,aAAa,CAAE,MAAM,SAAM,GAAG,iBAAiB;CAahD"}
|
package/dist/index.js
CHANGED
|
@@ -107,6 +107,8 @@ export class TileMothership {
|
|
|
107
107
|
const kind = rest.slice(dash + 1);
|
|
108
108
|
const { payload } = ev.data;
|
|
109
109
|
tile.dispatchEvent(Object.assign(new Event('protocol'), { protocol, kind, payload }));
|
|
110
|
+
// Deprecated: tp-data also raised as events of its own, until the
|
|
111
|
+
// next major version (see @dasl/tile-loader/data).
|
|
110
112
|
if (protocol === 'data') {
|
|
111
113
|
tile.dispatchEvent(Object.assign(new Event(kind === 'payload' ? 'data' : `data-${kind}`), { payload }));
|
|
112
114
|
}
|
|
@@ -142,7 +144,10 @@ export class TileMothership {
|
|
|
142
144
|
return id;
|
|
143
145
|
}
|
|
144
146
|
startShuttle(id) {
|
|
145
|
-
|
|
147
|
+
// The manifest's `sizing` goes along: the shuttle measures the content of
|
|
148
|
+
// a tile that declares `fit` (see @dasl/tile-loader/size).
|
|
149
|
+
const sizing = this.#id2tile.get(id)?.manifest?.sizing;
|
|
150
|
+
this.sendToShuttle(id, SND_SHUTTLE_LOAD, { id, webrtcGuard: this.#conf.webrtcGuard ?? 'exhaust', ...(sizing ? { sizing } : {}) });
|
|
146
151
|
}
|
|
147
152
|
// Adds a loader that will handle matching requests to load a tile.
|
|
148
153
|
// - `loader` is an object that knows how to load a tile for a specific scheme
|
|
@@ -256,15 +261,19 @@ export class Tile extends EventTarget {
|
|
|
256
261
|
}
|
|
257
262
|
/**
|
|
258
263
|
* Sends a tiles-protocol message down to the rendered tile. Messages the
|
|
259
|
-
* tile sends up arrive as `protocol` events
|
|
260
|
-
*
|
|
264
|
+
* tile sends up arrive as `protocol` events on this object. What a protocol
|
|
265
|
+
* means is up to the caller (see `@dasl/tile-loader/data` for tp-data).
|
|
261
266
|
*/
|
|
262
267
|
sendProtocol(protocol, kind, payload) {
|
|
263
268
|
if (!this.#shuttleId)
|
|
264
269
|
throw new Error('The tile is not rendered yet.');
|
|
265
270
|
this.#mothership.sendToShuttle(this.#shuttleId, `${PROTOCOL_DOWN}${protocol}-${kind}`, payload);
|
|
266
271
|
}
|
|
267
|
-
/**
|
|
272
|
+
/**
|
|
273
|
+
* Sends a tp-data payload to the tile (https://dasl.ing/tp-data.html).
|
|
274
|
+
* @deprecated Goes in the next major version. Use `tileData(tile).send()`
|
|
275
|
+
* from `@dasl/tile-loader/data`, or `sendProtocol('data', 'payload', payload)`.
|
|
276
|
+
*/
|
|
268
277
|
sendData(payload) {
|
|
269
278
|
this.sendProtocol('data', 'payload', payload);
|
|
270
279
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BE;AAEF,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAqBzD,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,gBAAgB,GAA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AAE,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC,CAAC;IACtF,CAAC;IACD,aAAa,CAAE,MAAM,GAAG,GAAG;QACzB,MAAM,GAAG,GAAG,EAAE,CAAC,QAAQ,EAAE;YACvB,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE;YACrC,KAAK,EAAE;gBACL,OAAO,EAAE,OAAO;gBAChB,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,GAAG,MAAM,IAAI;gBACrB,MAAM,EAAE,MAAM;aACf;SACF,CAAsB,CAAC;QACxB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
package/dist/size.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SizeLimits, TileSize } from '@dasl/tile-lexicon';
|
|
2
|
+
import type { Tile } from './index.js';
|
|
3
|
+
export type { SizeLimits, TileSize } from '@dasl/tile-lexicon';
|
|
4
|
+
/** The tiles protocol this module speaks. */
|
|
5
|
+
export declare const SIZE_PROTOCOL = "size";
|
|
6
|
+
export interface TileSizeOptions {
|
|
7
|
+
/** The context's limits; the floor (SIZE_FLOOR) is under them regardless. */
|
|
8
|
+
limits?: SizeLimits;
|
|
9
|
+
/** Size the frame here (the default), or leave its box to the host (`false`). */
|
|
10
|
+
apply?: boolean;
|
|
11
|
+
/** Who sets the width: the context's layout (the default), or the tile, within the limits. */
|
|
12
|
+
width?: 'context' | 'tile';
|
|
13
|
+
/** Called with each thing the tile asks for and the size the rules give it. */
|
|
14
|
+
onRequest?: (want: Partial<TileSize>, resolved: TileSize) => void;
|
|
15
|
+
/** Called with the tile's size whenever it changes. */
|
|
16
|
+
onSize?: (size: TileSize) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface TileSizeControl {
|
|
19
|
+
/** The size the tile has now. */
|
|
20
|
+
readonly size: TileSize;
|
|
21
|
+
/** The limits in force, floor included. */
|
|
22
|
+
readonly limits: SizeLimits;
|
|
23
|
+
/** Changes the context's limits; the tile is resized to fit them and told. */
|
|
24
|
+
setLimits(limits: SizeLimits): void;
|
|
25
|
+
/** The context asks for a size itself; the same rules apply. */
|
|
26
|
+
request(want: Partial<TileSize>): TileSize;
|
|
27
|
+
/** Stops listening and observing. The frame keeps its size. */
|
|
28
|
+
stop(): void;
|
|
29
|
+
}
|
|
30
|
+
/** Negotiates the size of a rendered tile's frame with the tile. */
|
|
31
|
+
export declare function tileSize(tile: Tile, frame: HTMLElement, options?: TileSizeOptions): TileSizeControl;
|
|
32
|
+
//# sourceMappingURL=size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../src/size.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAiB,IAAI,EAAE,MAAM,YAAY,CAAC;AAEtD,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE/D,6CAA6C;AAC7C,eAAO,MAAM,aAAa,SAAS,CAAC;AAWpC,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,iFAAiF;IACjF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IAClE,uDAAuD;IACvD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,8EAA8E;IAC9E,SAAS,CAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACrC,gEAAgE;IAChE,OAAO,CAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IAC5C,+DAA+D;IAC/D,IAAI,IAAK,IAAI,CAAC;CACf;AAID,oEAAoE;AACpE,wBAAgB,QAAQ,CAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,eAAe,CAoHxG"}
|
package/dist/size.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// The context side of the size protocol (https://dasl.ing/tp-size.html): a
|
|
2
|
+
// tile asks how big it may be, the context that frames it decides.
|
|
3
|
+
//
|
|
4
|
+
// import { tileSize } from '@dasl/tile-loader/size';
|
|
5
|
+
// const frame = tile.renderContent();
|
|
6
|
+
// const sizing = tileSize(tile, frame, { limits: { maxHeight: 800 } });
|
|
7
|
+
//
|
|
8
|
+
// That is all a host needs: the frame starts at the size the manifest's
|
|
9
|
+
// `sizing` asks for, inside the limits; it follows the tile's requests (its
|
|
10
|
+
// own, over `/.well-known/web-tiles/size.js`, or the runtime's for a manifest
|
|
11
|
+
// with `sizing.fit`), inside the limits; and the tile is told what it got. The
|
|
12
|
+
// rules are `resolveSize` in @dasl/tile-lexicon, the same for every context,
|
|
13
|
+
// with the floor no tile goes under.
|
|
14
|
+
//
|
|
15
|
+
// A host that lays the frame out itself passes `apply: false` and resizes its
|
|
16
|
+
// own box in `onRequest`; the tile is still told its real size whenever the
|
|
17
|
+
// frame's box changes. The width is the context's by default (the frame
|
|
18
|
+
// keeps the width its layout gives it): `width: 'tile'` hands that over too.
|
|
19
|
+
import { effectiveLimits, resolveSize } from '@dasl/tile-lexicon';
|
|
20
|
+
/** The tiles protocol this module speaks. */
|
|
21
|
+
export const SIZE_PROTOCOL = 'size';
|
|
22
|
+
/** What a frame is given before anything is known or laid out. */
|
|
23
|
+
const DEFAULT_SIZE = { width: 300, height: 300 };
|
|
24
|
+
// A tile may ask as often as it likes; the frame moves at most this often, so
|
|
25
|
+
// the page around it is not jerked about.
|
|
26
|
+
const SETTLE_MS = 100;
|
|
27
|
+
// How long a host that sizes its own box gets to do it before the tile is
|
|
28
|
+
// answered with what there is.
|
|
29
|
+
const HOST_APPLIES_MS = 250;
|
|
30
|
+
const positive = (v) => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : undefined);
|
|
31
|
+
/** Negotiates the size of a rendered tile's frame with the tile. */
|
|
32
|
+
export function tileSize(tile, frame, options = {}) {
|
|
33
|
+
const apply = options.apply !== false;
|
|
34
|
+
const tileWidth = options.width === 'tile';
|
|
35
|
+
const sizing = tile.manifest?.sizing;
|
|
36
|
+
let limits = options.limits ?? {};
|
|
37
|
+
// What the tile has asked for so far, kept so that a change of limits can
|
|
38
|
+
// be settled again against its wishes.
|
|
39
|
+
const wish = {};
|
|
40
|
+
let current = { ...DEFAULT_SIZE };
|
|
41
|
+
let told = '';
|
|
42
|
+
let reported = ''; // the last size the host was told of
|
|
43
|
+
let timer;
|
|
44
|
+
let lastApplied = 0;
|
|
45
|
+
const waiting = []; // request ids to answer once the box has settled
|
|
46
|
+
// The frame's real box, when it has one.
|
|
47
|
+
const box = () => {
|
|
48
|
+
const r = frame.getBoundingClientRect?.();
|
|
49
|
+
return r && r.width > 0 && r.height > 0 ? { width: Math.round(r.width), height: Math.round(r.height) } : undefined;
|
|
50
|
+
};
|
|
51
|
+
const settle = () => resolveSize({
|
|
52
|
+
want: tileWidth ? wish : { height: wish.height },
|
|
53
|
+
sizing: tileWidth ? sizing : { ...sizing, width: undefined, minWidth: undefined, maxWidth: undefined },
|
|
54
|
+
limits,
|
|
55
|
+
fallback: box() ?? current,
|
|
56
|
+
});
|
|
57
|
+
const grant = (id) => {
|
|
58
|
+
const size = box() ?? current;
|
|
59
|
+
current = size;
|
|
60
|
+
const dims = `${size.width}x${size.height}`;
|
|
61
|
+
const changed = dims !== reported;
|
|
62
|
+
reported = dims;
|
|
63
|
+
const key = `${size.width}x${size.height}/${JSON.stringify(effectiveLimits(limits))}`;
|
|
64
|
+
if (changed)
|
|
65
|
+
options.onSize?.(size);
|
|
66
|
+
if (!id && key === told)
|
|
67
|
+
return;
|
|
68
|
+
told = key;
|
|
69
|
+
try {
|
|
70
|
+
tile.sendProtocol(SIZE_PROTOCOL, 'grant', { ...(id ? { id } : {}), ...size, limits: effectiveLimits(limits) });
|
|
71
|
+
}
|
|
72
|
+
catch { /* not rendered yet: it asks when it is */ }
|
|
73
|
+
};
|
|
74
|
+
const answer = () => {
|
|
75
|
+
const ids = waiting.splice(0);
|
|
76
|
+
if (ids.length)
|
|
77
|
+
ids.forEach(id => grant(id));
|
|
78
|
+
else
|
|
79
|
+
grant();
|
|
80
|
+
};
|
|
81
|
+
const put = (size) => {
|
|
82
|
+
current = size;
|
|
83
|
+
if (!apply)
|
|
84
|
+
return;
|
|
85
|
+
frame.style.height = `${size.height}px`;
|
|
86
|
+
if (tileWidth)
|
|
87
|
+
frame.style.width = `${size.width}px`;
|
|
88
|
+
};
|
|
89
|
+
// At most one move per SETTLE_MS: the first at once, the rest together.
|
|
90
|
+
const move = () => {
|
|
91
|
+
const go = () => {
|
|
92
|
+
timer = undefined;
|
|
93
|
+
lastApplied = Date.now();
|
|
94
|
+
put(settle());
|
|
95
|
+
if (apply)
|
|
96
|
+
answer();
|
|
97
|
+
else
|
|
98
|
+
setTimeout(answer, HOST_APPLIES_MS); // the host resizes its box; the observer may answer sooner
|
|
99
|
+
};
|
|
100
|
+
if (timer)
|
|
101
|
+
return;
|
|
102
|
+
const since = Date.now() - lastApplied;
|
|
103
|
+
if (since >= SETTLE_MS)
|
|
104
|
+
go();
|
|
105
|
+
else
|
|
106
|
+
timer = setTimeout(go, SETTLE_MS - since);
|
|
107
|
+
};
|
|
108
|
+
const onProtocol = (ev) => {
|
|
109
|
+
const { protocol, kind, payload } = ev;
|
|
110
|
+
if (protocol !== SIZE_PROTOCOL)
|
|
111
|
+
return;
|
|
112
|
+
if (kind === 'ready') {
|
|
113
|
+
told = ''; // asked: answer even if nothing changed
|
|
114
|
+
return grant();
|
|
115
|
+
}
|
|
116
|
+
if (kind !== 'request')
|
|
117
|
+
return;
|
|
118
|
+
const p = (payload && typeof payload === 'object' ? payload : {});
|
|
119
|
+
const want = {};
|
|
120
|
+
if (positive(p.width))
|
|
121
|
+
want.width = p.width;
|
|
122
|
+
if (positive(p.height))
|
|
123
|
+
want.height = p.height;
|
|
124
|
+
Object.assign(wish, want);
|
|
125
|
+
if (typeof p.id === 'string' && p.id)
|
|
126
|
+
waiting.push(p.id);
|
|
127
|
+
options.onRequest?.(want, settle());
|
|
128
|
+
move();
|
|
129
|
+
};
|
|
130
|
+
tile.addEventListener('protocol', onProtocol);
|
|
131
|
+
// The context's layout changes the box too (a narrower column, a rotated
|
|
132
|
+
// phone): the tile is told its new size.
|
|
133
|
+
const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(() => answer()) : undefined;
|
|
134
|
+
observer?.observe(frame);
|
|
135
|
+
put(settle());
|
|
136
|
+
reported = `${current.width}x${current.height}`; // the host knows where it starts
|
|
137
|
+
lastApplied = 0; // the first request moves at once
|
|
138
|
+
return {
|
|
139
|
+
get size() { return box() ?? current; },
|
|
140
|
+
get limits() { return effectiveLimits(limits); },
|
|
141
|
+
setLimits(next) {
|
|
142
|
+
limits = next ?? {};
|
|
143
|
+
move();
|
|
144
|
+
},
|
|
145
|
+
request(want) {
|
|
146
|
+
Object.assign(wish, want);
|
|
147
|
+
const resolved = settle();
|
|
148
|
+
move();
|
|
149
|
+
return resolved;
|
|
150
|
+
},
|
|
151
|
+
stop() {
|
|
152
|
+
tile.removeEventListener('protocol', onProtocol);
|
|
153
|
+
observer?.disconnect();
|
|
154
|
+
if (timer)
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=size.js.map
|
package/dist/size.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.js","sourceRoot":"","sources":["../src/size.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,mEAAmE;AACnE,EAAE;AACF,uDAAuD;AACvD,wCAAwC;AACxC,0EAA0E;AAC1E,EAAE;AACF,wEAAwE;AACxE,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,qCAAqC;AACrC,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,wEAAwE;AACxE,6EAA6E;AAE7E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMlE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC,kEAAkE;AAClE,MAAM,YAAY,GAAa,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AAC3D,8EAA8E;AAC9E,0CAA0C;AAC1C,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,0EAA0E;AAC1E,+BAA+B;AAC/B,MAAM,eAAe,GAAG,GAAG,CAAC;AA4B5B,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAE5H,oEAAoE;AACpE,MAAM,UAAU,QAAQ,CAAE,IAAU,EAAE,KAAkB,EAAE,UAA2B,EAAE;IACrF,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC;IACtC,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,KAAK,MAA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,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjD,SAAS,CAAE,IAAI;YACb,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACpB,IAAI,EAAE,CAAC;QACT,CAAC;QACD,OAAO,CAAE,IAAI;YACX,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC1B,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC;YAC1B,IAAI,EAAE,CAAC;YACP,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI;YACF,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YACjD,QAAQ,EAAE,UAAU,EAAE,CAAC;YACvB,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dasl/tile-loader",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"description": "Browser architecture for safely loading DASL tiles (mothership, shuttle, worker)",
|
|
6
6
|
"author": "Robin Berjon <robin@berjon.com>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -26,6 +26,16 @@
|
|
|
26
26
|
"import": "./dist/car.js",
|
|
27
27
|
"default": "./dist/car.js"
|
|
28
28
|
},
|
|
29
|
+
"./data": {
|
|
30
|
+
"types": "./dist/data.d.ts",
|
|
31
|
+
"import": "./dist/data.js",
|
|
32
|
+
"default": "./dist/data.js"
|
|
33
|
+
},
|
|
34
|
+
"./size": {
|
|
35
|
+
"types": "./dist/size.d.ts",
|
|
36
|
+
"import": "./dist/size.js",
|
|
37
|
+
"default": "./dist/size.js"
|
|
38
|
+
},
|
|
29
39
|
"./memory": {
|
|
30
40
|
"types": "./dist/memory.d.ts",
|
|
31
41
|
"import": "./dist/memory.js",
|
|
@@ -64,7 +74,7 @@
|
|
|
64
74
|
"dependencies": {
|
|
65
75
|
"@atcute/car": "^6.0.0",
|
|
66
76
|
"@atcute/cid": "^2.4.1",
|
|
67
|
-
"@dasl/tile-lexicon": "^2.
|
|
77
|
+
"@dasl/tile-lexicon": "^2.2.0",
|
|
68
78
|
"jszip": "^3.10.1",
|
|
69
79
|
"mime": "^4.1.0",
|
|
70
80
|
"smol-toml": "^1.6.1"
|
package/src/data.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// The host side of tp-data (https://dasl.ing/tp-data.html), the tiles
|
|
2
|
+
// protocol for passing data to and from a tile, as a convenience over the
|
|
3
|
+
// generic protocol API.
|
|
4
|
+
//
|
|
5
|
+
// The loader itself attaches no meaning to any protocol: `Tile.sendProtocol()`
|
|
6
|
+
// sends one message down, and what a tile sends up arrives as `protocol`
|
|
7
|
+
// events. tp-data is two kinds on the `data` protocol, `ready` (the tile has
|
|
8
|
+
// called `listen()`) and `payload`. This module names them:
|
|
9
|
+
//
|
|
10
|
+
// import { tileData } from '@dasl/tile-loader/data';
|
|
11
|
+
// const data = tileData(tile);
|
|
12
|
+
// data.onReady(() => data.send({ name: 'world' }));
|
|
13
|
+
// const stop = data.onData((payload) => console.log(payload));
|
|
14
|
+
//
|
|
15
|
+
// It replaces `Tile.sendData()` and the `data` / `data-ready` events, which
|
|
16
|
+
// the loader still has but deprecates.
|
|
17
|
+
|
|
18
|
+
import type { ProtocolEvent, Tile } from './index.js';
|
|
19
|
+
|
|
20
|
+
/** The tiles protocol this module speaks. */
|
|
21
|
+
export const DATA_PROTOCOL = 'data';
|
|
22
|
+
|
|
23
|
+
export interface TileData {
|
|
24
|
+
/** Sends a payload to the tile; it is structured-cloned on the way. Throws if the tile is not rendered yet. */
|
|
25
|
+
send (payload: unknown): void;
|
|
26
|
+
/** Calls `handler` with each payload the tile sends. Returns a function that stops it. */
|
|
27
|
+
onData (handler: (payload: unknown) => void): () => void;
|
|
28
|
+
/** Calls `handler` when the tile says it is ready for data (`listen()`). Returns a function that stops it. */
|
|
29
|
+
onReady (handler: () => void): () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** tp-data on a tile: send it payloads, hear the ones it sends and when it is ready. */
|
|
33
|
+
export function tileData (tile: Tile): TileData {
|
|
34
|
+
const on = (kind: string, handler: (payload: unknown) => void) => {
|
|
35
|
+
const listener = (ev: Event) => {
|
|
36
|
+
const { protocol, kind: got, payload } = ev as ProtocolEvent;
|
|
37
|
+
if (protocol === DATA_PROTOCOL && got === kind) handler(payload);
|
|
38
|
+
};
|
|
39
|
+
tile.addEventListener('protocol', listener);
|
|
40
|
+
return () => tile.removeEventListener('protocol', listener);
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
send: (payload) => tile.sendProtocol(DATA_PROTOCOL, 'payload', payload),
|
|
44
|
+
onData: (handler) => on('payload', handler),
|
|
45
|
+
onReady: (handler) => on('ready', () => handler()),
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -69,13 +69,17 @@ const TILES_ERROR = `${TILES_PFX}error`; // shuttle errors
|
|
|
69
69
|
const PROTOCOL_UP = 'tiles-protocol-up-';
|
|
70
70
|
const PROTOCOL_DOWN = 'tiles-protocol-down-';
|
|
71
71
|
|
|
72
|
-
/** A tiles-protocol message from a tile: `protocol` ("data"), `kind` ("payload", "ready"), and its `payload`. */
|
|
72
|
+
/** A tiles-protocol message from a tile: `protocol` ("data"), `kind` ("payload", "ready"), and its `payload`. The mothership attaches no meaning to any of them. */
|
|
73
73
|
export interface ProtocolEvent extends Event {
|
|
74
74
|
protocol: string;
|
|
75
75
|
kind: string;
|
|
76
76
|
payload: unknown;
|
|
77
77
|
}
|
|
78
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* A tp-data message from a tile; `payload` is what the tile sent.
|
|
80
|
+
* @deprecated The `data` and `data-ready` events go in the next major
|
|
81
|
+
* version. Use `tileData()` from `@dasl/tile-loader/data`, or the `protocol` event.
|
|
82
|
+
*/
|
|
79
83
|
export interface DataEvent extends Event {
|
|
80
84
|
payload: unknown;
|
|
81
85
|
}
|
|
@@ -137,6 +141,8 @@ export class TileMothership {
|
|
|
137
141
|
const kind = rest.slice(dash + 1);
|
|
138
142
|
const { payload } = ev.data;
|
|
139
143
|
tile.dispatchEvent(Object.assign(new Event('protocol'), { protocol, kind, payload }));
|
|
144
|
+
// Deprecated: tp-data also raised as events of its own, until the
|
|
145
|
+
// next major version (see @dasl/tile-loader/data).
|
|
140
146
|
if (protocol === 'data') {
|
|
141
147
|
tile.dispatchEvent(Object.assign(new Event(kind === 'payload' ? 'data' : `data-${kind}`), { payload }));
|
|
142
148
|
}
|
|
@@ -169,7 +175,10 @@ export class TileMothership {
|
|
|
169
175
|
return id;
|
|
170
176
|
}
|
|
171
177
|
startShuttle (id: string) {
|
|
172
|
-
|
|
178
|
+
// The manifest's `sizing` goes along: the shuttle measures the content of
|
|
179
|
+
// a tile that declares `fit` (see @dasl/tile-loader/size).
|
|
180
|
+
const sizing = this.#id2tile.get(id)?.manifest?.sizing;
|
|
181
|
+
this.sendToShuttle(id, SND_SHUTTLE_LOAD, { id, webrtcGuard: this.#conf.webrtcGuard ?? 'exhaust', ...(sizing ? { sizing } : {}) });
|
|
173
182
|
}
|
|
174
183
|
// Adds a loader that will handle matching requests to load a tile.
|
|
175
184
|
// - `loader` is an object that knows how to load a tile for a specific scheme
|
|
@@ -285,14 +294,18 @@ export class Tile extends EventTarget {
|
|
|
285
294
|
}
|
|
286
295
|
/**
|
|
287
296
|
* Sends a tiles-protocol message down to the rendered tile. Messages the
|
|
288
|
-
* tile sends up arrive as `protocol` events
|
|
289
|
-
*
|
|
297
|
+
* tile sends up arrive as `protocol` events on this object. What a protocol
|
|
298
|
+
* means is up to the caller (see `@dasl/tile-loader/data` for tp-data).
|
|
290
299
|
*/
|
|
291
300
|
sendProtocol (protocol: string, kind: string, payload?: unknown) {
|
|
292
301
|
if (!this.#shuttleId) throw new Error('The tile is not rendered yet.');
|
|
293
302
|
this.#mothership.sendToShuttle(this.#shuttleId, `${PROTOCOL_DOWN}${protocol}-${kind}`, payload);
|
|
294
303
|
}
|
|
295
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* Sends a tp-data payload to the tile (https://dasl.ing/tp-data.html).
|
|
306
|
+
* @deprecated Goes in the next major version. Use `tileData(tile).send()`
|
|
307
|
+
* from `@dasl/tile-loader/data`, or `sendProtocol('data', 'payload', payload)`.
|
|
308
|
+
*/
|
|
296
309
|
sendData (payload: unknown) {
|
|
297
310
|
this.sendProtocol('data', 'payload', payload);
|
|
298
311
|
}
|
package/src/size.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// The context side of the size protocol (https://dasl.ing/tp-size.html): a
|
|
2
|
+
// tile asks how big it may be, the context that frames it decides.
|
|
3
|
+
//
|
|
4
|
+
// import { tileSize } from '@dasl/tile-loader/size';
|
|
5
|
+
// const frame = tile.renderContent();
|
|
6
|
+
// const sizing = tileSize(tile, frame, { limits: { maxHeight: 800 } });
|
|
7
|
+
//
|
|
8
|
+
// That is all a host needs: the frame starts at the size the manifest's
|
|
9
|
+
// `sizing` asks for, inside the limits; it follows the tile's requests (its
|
|
10
|
+
// own, over `/.well-known/web-tiles/size.js`, or the runtime's for a manifest
|
|
11
|
+
// with `sizing.fit`), inside the limits; and the tile is told what it got. The
|
|
12
|
+
// rules are `resolveSize` in @dasl/tile-lexicon, the same for every context,
|
|
13
|
+
// with the floor no tile goes under.
|
|
14
|
+
//
|
|
15
|
+
// A host that lays the frame out itself passes `apply: false` and resizes its
|
|
16
|
+
// own box in `onRequest`; the tile is still told its real size whenever the
|
|
17
|
+
// frame's box changes. The width is the context's by default (the frame
|
|
18
|
+
// keeps the width its layout gives it): `width: 'tile'` hands that over too.
|
|
19
|
+
|
|
20
|
+
import { effectiveLimits, resolveSize } from '@dasl/tile-lexicon';
|
|
21
|
+
import type { SizeLimits, TileSize } from '@dasl/tile-lexicon';
|
|
22
|
+
import type { ProtocolEvent, Tile } from './index.js';
|
|
23
|
+
|
|
24
|
+
export type { SizeLimits, TileSize } from '@dasl/tile-lexicon';
|
|
25
|
+
|
|
26
|
+
/** The tiles protocol this module speaks. */
|
|
27
|
+
export const SIZE_PROTOCOL = 'size';
|
|
28
|
+
|
|
29
|
+
/** What a frame is given before anything is known or laid out. */
|
|
30
|
+
const DEFAULT_SIZE: TileSize = { width: 300, height: 300 };
|
|
31
|
+
// A tile may ask as often as it likes; the frame moves at most this often, so
|
|
32
|
+
// the page around it is not jerked about.
|
|
33
|
+
const SETTLE_MS = 100;
|
|
34
|
+
// How long a host that sizes its own box gets to do it before the tile is
|
|
35
|
+
// answered with what there is.
|
|
36
|
+
const HOST_APPLIES_MS = 250;
|
|
37
|
+
|
|
38
|
+
export interface TileSizeOptions {
|
|
39
|
+
/** The context's limits; the floor (SIZE_FLOOR) is under them regardless. */
|
|
40
|
+
limits?: SizeLimits;
|
|
41
|
+
/** Size the frame here (the default), or leave its box to the host (`false`). */
|
|
42
|
+
apply?: boolean;
|
|
43
|
+
/** Who sets the width: the context's layout (the default), or the tile, within the limits. */
|
|
44
|
+
width?: 'context' | 'tile';
|
|
45
|
+
/** Called with each thing the tile asks for and the size the rules give it. */
|
|
46
|
+
onRequest?: (want: Partial<TileSize>, resolved: TileSize) => void;
|
|
47
|
+
/** Called with the tile's size whenever it changes. */
|
|
48
|
+
onSize?: (size: TileSize) => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface TileSizeControl {
|
|
52
|
+
/** The size the tile has now. */
|
|
53
|
+
readonly size: TileSize;
|
|
54
|
+
/** The limits in force, floor included. */
|
|
55
|
+
readonly limits: SizeLimits;
|
|
56
|
+
/** Changes the context's limits; the tile is resized to fit them and told. */
|
|
57
|
+
setLimits (limits: SizeLimits): void;
|
|
58
|
+
/** The context asks for a size itself; the same rules apply. */
|
|
59
|
+
request (want: Partial<TileSize>): TileSize;
|
|
60
|
+
/** Stops listening and observing. The frame keeps its size. */
|
|
61
|
+
stop (): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const positive = (v: unknown): number | undefined => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : undefined);
|
|
65
|
+
|
|
66
|
+
/** Negotiates the size of a rendered tile's frame with the tile. */
|
|
67
|
+
export function tileSize (tile: Tile, frame: HTMLElement, options: TileSizeOptions = {}): TileSizeControl {
|
|
68
|
+
const apply = options.apply !== false;
|
|
69
|
+
const tileWidth = options.width === 'tile';
|
|
70
|
+
const sizing = tile.manifest?.sizing;
|
|
71
|
+
let limits = options.limits ?? {};
|
|
72
|
+
// What the tile has asked for so far, kept so that a change of limits can
|
|
73
|
+
// be settled again against its wishes.
|
|
74
|
+
const wish: Partial<TileSize> = {};
|
|
75
|
+
let current: TileSize = { ...DEFAULT_SIZE };
|
|
76
|
+
let told = '';
|
|
77
|
+
let reported = ''; // the last size the host was told of
|
|
78
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
79
|
+
let lastApplied = 0;
|
|
80
|
+
const waiting: string[] = []; // request ids to answer once the box has settled
|
|
81
|
+
|
|
82
|
+
// The frame's real box, when it has one.
|
|
83
|
+
const box = (): TileSize | undefined => {
|
|
84
|
+
const r = frame.getBoundingClientRect?.();
|
|
85
|
+
return r && r.width > 0 && r.height > 0 ? { width: Math.round(r.width), height: Math.round(r.height) } : undefined;
|
|
86
|
+
};
|
|
87
|
+
const settle = (): TileSize => resolveSize({
|
|
88
|
+
want: tileWidth ? wish : { height: wish.height },
|
|
89
|
+
sizing: tileWidth ? sizing : { ...sizing, width: undefined, minWidth: undefined, maxWidth: undefined },
|
|
90
|
+
limits,
|
|
91
|
+
fallback: box() ?? current,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const grant = (id?: string) => {
|
|
95
|
+
const size = box() ?? current;
|
|
96
|
+
current = size;
|
|
97
|
+
const dims = `${size.width}x${size.height}`;
|
|
98
|
+
const changed = dims !== reported;
|
|
99
|
+
reported = dims;
|
|
100
|
+
const key = `${size.width}x${size.height}/${JSON.stringify(effectiveLimits(limits))}`;
|
|
101
|
+
if (changed) options.onSize?.(size);
|
|
102
|
+
if (!id && key === told) return;
|
|
103
|
+
told = key;
|
|
104
|
+
try {
|
|
105
|
+
tile.sendProtocol(SIZE_PROTOCOL, 'grant', { ...(id ? { id } : {}), ...size, limits: effectiveLimits(limits) });
|
|
106
|
+
}
|
|
107
|
+
catch { /* not rendered yet: it asks when it is */ }
|
|
108
|
+
};
|
|
109
|
+
const answer = () => {
|
|
110
|
+
const ids = waiting.splice(0);
|
|
111
|
+
if (ids.length) ids.forEach(id => grant(id));
|
|
112
|
+
else grant();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const put = (size: TileSize) => {
|
|
116
|
+
current = size;
|
|
117
|
+
if (!apply) return;
|
|
118
|
+
frame.style.height = `${size.height}px`;
|
|
119
|
+
if (tileWidth) frame.style.width = `${size.width}px`;
|
|
120
|
+
};
|
|
121
|
+
// At most one move per SETTLE_MS: the first at once, the rest together.
|
|
122
|
+
const move = () => {
|
|
123
|
+
const go = () => {
|
|
124
|
+
timer = undefined;
|
|
125
|
+
lastApplied = Date.now();
|
|
126
|
+
put(settle());
|
|
127
|
+
if (apply) answer();
|
|
128
|
+
else setTimeout(answer, HOST_APPLIES_MS); // the host resizes its box; the observer may answer sooner
|
|
129
|
+
};
|
|
130
|
+
if (timer) return;
|
|
131
|
+
const since = Date.now() - lastApplied;
|
|
132
|
+
if (since >= SETTLE_MS) go();
|
|
133
|
+
else timer = setTimeout(go, SETTLE_MS - since);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const onProtocol = (ev: Event) => {
|
|
137
|
+
const { protocol, kind, payload } = ev as ProtocolEvent;
|
|
138
|
+
if (protocol !== SIZE_PROTOCOL) return;
|
|
139
|
+
if (kind === 'ready') {
|
|
140
|
+
told = ''; // asked: answer even if nothing changed
|
|
141
|
+
return grant();
|
|
142
|
+
}
|
|
143
|
+
if (kind !== 'request') return;
|
|
144
|
+
const p = (payload && typeof payload === 'object' ? payload : {}) as { id?: unknown; width?: unknown; height?: unknown };
|
|
145
|
+
const want: Partial<TileSize> = {};
|
|
146
|
+
if (positive(p.width)) want.width = p.width as number;
|
|
147
|
+
if (positive(p.height)) want.height = p.height as number;
|
|
148
|
+
Object.assign(wish, want);
|
|
149
|
+
if (typeof p.id === 'string' && p.id) waiting.push(p.id);
|
|
150
|
+
options.onRequest?.(want, settle());
|
|
151
|
+
move();
|
|
152
|
+
};
|
|
153
|
+
tile.addEventListener('protocol', onProtocol);
|
|
154
|
+
|
|
155
|
+
// The context's layout changes the box too (a narrower column, a rotated
|
|
156
|
+
// phone): the tile is told its new size.
|
|
157
|
+
const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(() => answer()) : undefined;
|
|
158
|
+
observer?.observe(frame);
|
|
159
|
+
|
|
160
|
+
put(settle());
|
|
161
|
+
reported = `${current.width}x${current.height}`; // the host knows where it starts
|
|
162
|
+
lastApplied = 0; // the first request moves at once
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
get size () { return box() ?? current; },
|
|
166
|
+
get limits () { return effectiveLimits(limits); },
|
|
167
|
+
setLimits (next) {
|
|
168
|
+
limits = next ?? {};
|
|
169
|
+
move();
|
|
170
|
+
},
|
|
171
|
+
request (want) {
|
|
172
|
+
Object.assign(wish, want);
|
|
173
|
+
const resolved = settle();
|
|
174
|
+
move();
|
|
175
|
+
return resolved;
|
|
176
|
+
},
|
|
177
|
+
stop () {
|
|
178
|
+
tile.removeEventListener('protocol', onProtocol);
|
|
179
|
+
observer?.disconnect();
|
|
180
|
+
if (timer) clearTimeout(timer);
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|