Something went wrong. Try again.
tile-veil repo
Something went wrong. Try again.
Files
README.md
# tile-veil
A loading screen for [Web Tiles](https://dasl.ing/). It covers the
tile frame from `tile.renderContent()` until the tile is ready to show. It
shows the tile's name, colour, and picture, and what the start is waiting
for. It removes the white block that a frame shows while the tile starts.
| Without tile-veil | With tile-veil |
| --- | --- |
|  |  |
Status: 0.1.0, not yet on npm.
## Install
```sh
npm install tile-veil @dasl/tile-loader
```
`@dasl/tile-loader` 5.0.0 or later is a peer dependency. `tile-veil` has no
other dependencies.
## Quick start
```js
import { TileMothership } from '@dasl/tile-loader';
import { createVeil } from 'tile-veil';
const ship = new TileMothership({ loadDomain: 'load.example.com' });
ship.init();
// On the press: the veil shows at once, before the tile exists.
const veil = createVeil({
name, background, // what the host knows already, if anything
poster: screenshotUrl, // the picture the user pressed, if any
height: 480, // holds the space until the frame is in
onRetry: () => runAgain(), // shows "Try again" on a failure
});
box.replaceChildren(veil.element);
let tile;
try {
tile = await ship.loadTile(uri);
if (tile) veil.attach(tile, tile.renderContent(480));
else veil.fail(); // no loader takes this address
}
catch (err) {
veil.fail(err); // the failure shows in the veil
}
// When the tile closes:
veil.stop();
if (tile) await tile.close();
```
`loadTile()` resolves the address and fetches the manifest first. On a real
network that takes up to a second. `createVeil()` covers that wait. Call
`attach()` in the same task as `tile.renderContent()`, before the frame is in
the document.
With the tile already in hand, `veilTile(t…