@dasl/tile-loader 3.1.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 +818 -34
  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 +247 -13
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +746 -51
  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 +837 -52
  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
@@ -0,0 +1,80 @@
1
+ import type { MaslResponseError } from '@dasl/tile-lexicon';
2
+ /**
3
+ * What went wrong:
4
+ *
5
+ * - `record-changed`: the tile is not the one its host expected (`expected`,
6
+ * `actual`, and `manifestCid` for what is there now).
7
+ * - `record-invalid`: not a tile's record, or not one that can be checked.
8
+ * - `not-found`: the DID, the record or a resource does not exist.
9
+ * - `integrity`: bytes are not what the CID that names them says (`path`,
10
+ * `expected`, `actual`).
11
+ * - `too-large`: an answer was longer than it is allowed to be (`limit`).
12
+ * - `over-budget`: the tile asks for more than a tile may have (`limit`, and
13
+ * `amount` for what it asks).
14
+ * - `destination`: a DID, a DID document or a PDS the loader does not fetch
15
+ * from.
16
+ * - `rate-limited`: a server said 429 (`retryAfter`, in seconds, when it
17
+ * says).
18
+ * - `upstream`: a server failed (5xx), or answered what is no answer.
19
+ * - `timeout`: no answer in time.
20
+ * - `network`: the request failed: unreachable, refused by the browser, or
21
+ * answered with a redirect.
22
+ *
23
+ * The last four may pass: `retryable` says so.
24
+ */
25
+ export type TileLoadErrorCode = 'record-changed' | 'record-invalid' | 'not-found' | 'integrity' | 'too-large' | 'over-budget' | 'destination' | 'rate-limited' | 'upstream' | 'timeout' | 'network';
26
+ /** What a TileLoadError can say besides its code. */
27
+ export interface TileLoadErrorDetails {
28
+ /** The resource it happened on, when it was one. */
29
+ path?: string;
30
+ /** The CID that was expected. */
31
+ expected?: string;
32
+ /** The CID that was found in its place. */
33
+ actual?: string;
34
+ /** The CID of the manifest that was found, when a tile is not the one expected. */
35
+ manifestCid?: string;
36
+ /** The HTTP status a server answered with. */
37
+ status?: number;
38
+ /** How long a server that is limiting requests asks to be left alone, in seconds. */
39
+ retryAfter?: number;
40
+ /** The limit that was passed. */
41
+ limit?: number;
42
+ /** How much there was of what the limit is on. */
43
+ amount?: number;
44
+ }
45
+ /**
46
+ * Why a tile could not be loaded, or why something of it could not be had.
47
+ * `code` says which kind of failure it is, so that a host can tell a tile
48
+ * that is not what it should be from one that is simply not there.
49
+ */
50
+ export declare class TileLoadError extends Error implements TileLoadErrorDetails {
51
+ code: TileLoadErrorCode;
52
+ /** Whether trying again later can help. */
53
+ retryable: boolean;
54
+ path?: string;
55
+ expected?: string;
56
+ actual?: string;
57
+ manifestCid?: string;
58
+ status?: number;
59
+ retryAfter?: number;
60
+ limit?: number;
61
+ amount?: number;
62
+ constructor(code: TileLoadErrorCode, message: string, details?: TileLoadErrorDetails);
63
+ }
64
+ /**
65
+ * The `error` event of a tile when something of it could not be had: `error`
66
+ * says why. It has no `reason`, which is what the other `error` of a tile has
67
+ * (TileErrorEvent, for a start that failed for some other cause).
68
+ */
69
+ export interface TileLoadErrorEvent extends Event {
70
+ error: TileLoadError;
71
+ }
72
+ /** A resource that could not be served, with the reason. */
73
+ export interface TileLoadFailure extends MaslResponseError {
74
+ error: TileLoadError;
75
+ }
76
+ /** `error`, as it happened to the resource at `path`: a copy, since one failure can be several resources'. */
77
+ export declare function onPath(error: TileLoadError, path: string): TileLoadError;
78
+ /** The answer for a resource that failed with `error`. */
79
+ export declare function failure(error: TileLoadError): TileLoadFailure;
80
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAAG,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,aAAa,GAC7G,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAIxD,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAM,YAAW,oBAAoB;IACtE,IAAI,EAAE,iBAAiB,CAAC;IACxB,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;gBACH,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB;CAO1F;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,KAAK;IAC/C,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,4DAA4D;AAC5D,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,KAAK,EAAE,aAAa,CAAC;CACtB;AAWD,8GAA8G;AAC9G,wBAAgB,MAAM,CAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAEzE;AAED,0DAA0D;AAC1D,wBAAgB,OAAO,CAAE,KAAK,EAAE,aAAa,GAAG,eAAe,CAG9D"}
@@ -0,0 +1,44 @@
1
+ const RETRYABLE = ['rate-limited', 'upstream', 'timeout', 'network'];
2
+ /**
3
+ * Why a tile could not be loaded, or why something of it could not be had.
4
+ * `code` says which kind of failure it is, so that a host can tell a tile
5
+ * that is not what it should be from one that is simply not there.
6
+ */
7
+ export class TileLoadError extends Error {
8
+ code;
9
+ /** Whether trying again later can help. */
10
+ retryable;
11
+ path;
12
+ expected;
13
+ actual;
14
+ manifestCid;
15
+ status;
16
+ retryAfter;
17
+ limit;
18
+ amount;
19
+ constructor(code, message, details = {}) {
20
+ super(message);
21
+ this.name = 'TileLoadError';
22
+ this.code = code;
23
+ this.retryable = RETRYABLE.includes(code);
24
+ Object.assign(this, details);
25
+ }
26
+ }
27
+ // What a tile is answered for one of its resources that could not be had.
28
+ // Never 404: that is for a path the tile does not have, and a resource its
29
+ // record lists and its PDS lacks is a broken tile, not an unknown path.
30
+ const STATUS = {
31
+ 'rate-limited': [503, 'Service Unavailable'],
32
+ timeout: [504, 'Gateway Timeout'],
33
+ 'over-budget': [507, 'Insufficient Storage'],
34
+ };
35
+ /** `error`, as it happened to the resource at `path`: a copy, since one failure can be several resources'. */
36
+ export function onPath(error, path) {
37
+ return Object.assign(new TileLoadError(error.code, error.message), error, { path });
38
+ }
39
+ /** The answer for a resource that failed with `error`. */
40
+ export function failure(error) {
41
+ const [status, statusText] = STATUS[error.code] ?? [502, 'Bad Gateway'];
42
+ return { ok: false, status, statusText, error };
43
+ }
44
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AA8BA,MAAM,SAAS,GAAwB,CAAC,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAsB1F;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,IAAI,CAAoB;IACxB,2CAA2C;IAC3C,SAAS,CAAU;IACnB,IAAI,CAAU;IACd,QAAQ,CAAU;IAClB,MAAM,CAAU;IAChB,WAAW,CAAU;IACrB,MAAM,CAAU;IAChB,UAAU,CAAU;IACpB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,YAAa,IAAuB,EAAE,OAAe,EAAE,UAAgC,EAAE;QACvF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF;AAgBD,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,MAAM,MAAM,GAAyD;IACnE,cAAc,EAAE,CAAC,GAAG,EAAE,qBAAqB,CAAC;IAC5C,OAAO,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,CAAC,GAAG,EAAE,sBAAsB,CAAC;CAC7C,CAAC;AAEF,8GAA8G;AAC9G,MAAM,UAAU,MAAM,CAAE,KAAoB,EAAE,IAAY;IACxD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AACtF,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,OAAO,CAAE,KAAoB;IAC3C,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACxE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type Fetch = typeof globalThis.fetch;
2
+ export declare function careful(given?: Fetch, anonymous?: boolean): Fetch;
3
+ export interface Bounds {
4
+ /** The most bytes the answer may have. */
5
+ maxBytes: number;
6
+ /** How long it may take, headers and body, in milliseconds. */
7
+ ms: number;
8
+ /** What is being asked for, for the error that says it could not be had. */
9
+ what: string;
10
+ headers?: Record<string, string>;
11
+ }
12
+ /**
13
+ * GETs `url` and gives its body, within a time and a size. What goes wrong
14
+ * is a TileLoadError that says what it was: `timeout`, `network` (the request
15
+ * failed: unreachable, refused by the browser, a redirect), `rate-limited`,
16
+ * `upstream` (a server error), `not-found`, `too-large`. `fetch` is expected
17
+ * to stop when its signal says so and to give a body that streams; one that
18
+ * does neither is still held to the time, and to the size once it has
19
+ * answered.
20
+ */
21
+ export declare function get(fetch: Fetch, url: string, { maxBytes, ms, what, headers }: Bounds): Promise<Uint8Array>;
22
+ /** What `bytes` say as JSON. An answer that is not JSON is a server failing (`upstream`). */
23
+ export declare function parseJSON(bytes: Uint8Array, what: string): unknown;
24
+ //# sourceMappingURL=fetching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetching.d.ts","sourceRoot":"","sources":["../../src/lib/fetching.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,KAAK,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AAS5C,wBAAgB,OAAO,CAAE,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,UAAO,GAAG,KAAK,CAI/D;AAED,MAAM,WAAW,MAAM;IACrB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAmED;;;;;;;;GAQG;AACH,wBAAsB,GAAG,CAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA6BlH;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGnE"}
@@ -0,0 +1,135 @@
1
+ import { TileLoadError } from "./errors.js";
2
+ // How a loader asks. It follows no redirect: where it goes is checked before
3
+ // it asks, and a redirect is a server sending the viewer's browser on to
4
+ // somewhere that was not checked. Where a tile's author says where to go
5
+ // (`anonymous`), the page's own fetch also sends nothing of the viewer's but
6
+ // the request itself. A `fetch` the host gave us is the host's way to its own
7
+ // backend, which may need the session it has there, so that much is left to
8
+ // it.
9
+ export function careful(given, anonymous = true) {
10
+ if (given)
11
+ return (input, init) => given(input, { ...init, redirect: 'error' });
12
+ if (!anonymous)
13
+ return (input, init) => globalThis.fetch(input, { ...init, redirect: 'error' });
14
+ return (input, init) => globalThis.fetch(input, { ...init, redirect: 'error', credentials: 'omit', referrerPolicy: 'no-referrer' });
15
+ }
16
+ // What an answer that is not a success means. A server that is busy or broken
17
+ // is not a server that says there is no such thing.
18
+ function refusal(res, what) {
19
+ const { status } = res;
20
+ if (status === 429) {
21
+ // Retry-After is only readable across origins if the server exposes it;
22
+ // RateLimit-Reset is what a PDS exposes. A PDS gives it in seconds since
23
+ // the epoch; the header as it is being specified is in seconds from now,
24
+ // which no time since the epoch can be taken for.
25
+ const after = Number(res.headers?.get('retry-after'));
26
+ const reset = Number(res.headers?.get('ratelimit-reset'));
27
+ let retryAfter;
28
+ if (Number.isFinite(after) && after > 0)
29
+ retryAfter = Math.ceil(after);
30
+ else if (Number.isFinite(reset) && reset > 0)
31
+ retryAfter = Math.max(1, Math.ceil(reset > 1e9 ? reset - Date.now() / 1000 : reset));
32
+ return new TileLoadError('rate-limited', `${what}: the server is limiting requests (429)`, { status, retryAfter });
33
+ }
34
+ if (status >= 500)
35
+ return new TileLoadError('upstream', `${what}: the server failed (${status})`, { status });
36
+ if (status >= 300 && status < 400)
37
+ return new TileLoadError('network', `${what}: the answer is a redirect (${status}), and none is followed`, { status });
38
+ return new TileLoadError('not-found', `${what}: not found${status ? ` (${status})` : ''}`, { status });
39
+ }
40
+ // The body, read no further than `maxBytes`.
41
+ async function read(res, maxBytes, what) {
42
+ const tooLarge = () => new TileLoadError('too-large', `${what}: more than the ${maxBytes} bytes allowed`, { limit: maxBytes });
43
+ // A length that is announced is the length on the wire, which for a
44
+ // compressed body is not the one counted below: it only serves to refuse at
45
+ // once what is far too long, with room for what compressing adds to
46
+ // something that does not compress.
47
+ const announced = Number(res.headers?.get('content-length'));
48
+ if (Number.isFinite(announced) && announced > maxBytes + 1024 + maxBytes / 64) {
49
+ res.body?.cancel().catch(() => { });
50
+ throw tooLarge();
51
+ }
52
+ const reader = res.body?.getReader?.();
53
+ if (!reader) {
54
+ // A fetch of the host's without streams: the length is known afterwards.
55
+ const all = new Uint8Array(await res.arrayBuffer());
56
+ if (all.byteLength > maxBytes)
57
+ throw tooLarge();
58
+ return all;
59
+ }
60
+ const chunks = [];
61
+ let length = 0;
62
+ for (;;) {
63
+ const { done, value } = await reader.read();
64
+ if (done)
65
+ break;
66
+ length += value.byteLength;
67
+ if (length > maxBytes) {
68
+ reader.cancel().catch(() => { });
69
+ throw tooLarge();
70
+ }
71
+ chunks.push(value);
72
+ }
73
+ // What is returned has a buffer of its own, and only its own bytes in it: it
74
+ // is handed on to the tile, buffer and all.
75
+ const [only] = chunks;
76
+ if (chunks.length === 1 && only.byteOffset === 0 && only.byteLength === only.buffer.byteLength)
77
+ return only;
78
+ const all = new Uint8Array(length);
79
+ let at = 0;
80
+ for (const chunk of chunks) {
81
+ all.set(chunk, at);
82
+ at += chunk.byteLength;
83
+ }
84
+ return all;
85
+ }
86
+ /**
87
+ * GETs `url` and gives its body, within a time and a size. What goes wrong
88
+ * is a TileLoadError that says what it was: `timeout`, `network` (the request
89
+ * failed: unreachable, refused by the browser, a redirect), `rate-limited`,
90
+ * `upstream` (a server error), `not-found`, `too-large`. `fetch` is expected
91
+ * to stop when its signal says so and to give a body that streams; one that
92
+ * does neither is still held to the time, and to the size once it has
93
+ * answered.
94
+ */
95
+ export async function get(fetch, url, { maxBytes, ms, what, headers }) {
96
+ const stop = new AbortController();
97
+ let late;
98
+ const timeout = new Promise((_, reject) => {
99
+ late = setTimeout(() => {
100
+ reject(new TileLoadError('timeout', `${what}: no answer within ${ms} ms`));
101
+ stop.abort();
102
+ }, Math.min(ms, 2 ** 31 - 1)); // as long as a timer can be set for
103
+ });
104
+ const answer = (async () => {
105
+ const res = await fetch(url, { signal: stop.signal, ...(headers ? { headers } : {}) });
106
+ if (!res.ok) {
107
+ res.body?.cancel().catch(() => { });
108
+ throw refusal(res, what);
109
+ }
110
+ return read(res, maxBytes, what);
111
+ })();
112
+ // Once the time is up the answer is nobody's: what it fails with then is not news.
113
+ answer.catch(() => { });
114
+ try {
115
+ return await Promise.race([answer, timeout]);
116
+ }
117
+ catch (err) {
118
+ if (err instanceof TileLoadError)
119
+ throw err;
120
+ throw new TileLoadError('network', `${what}: the request failed (${err?.message ?? err})`);
121
+ }
122
+ finally {
123
+ clearTimeout(late);
124
+ }
125
+ }
126
+ /** What `bytes` say as JSON. An answer that is not JSON is a server failing (`upstream`). */
127
+ export function parseJSON(bytes, what) {
128
+ try {
129
+ return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
130
+ }
131
+ catch {
132
+ throw new TileLoadError('upstream', `${what}: the answer is not JSON`);
133
+ }
134
+ }
135
+ //# sourceMappingURL=fetching.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetching.js","sourceRoot":"","sources":["../../src/lib/fetching.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,6EAA6E;AAC7E,yEAAyE;AACzE,yEAAyE;AACzE,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,MAAM;AACN,MAAM,UAAU,OAAO,CAAE,KAAa,EAAE,SAAS,GAAG,IAAI;IACtD,IAAI,KAAK;QAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,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AAE,IAAI,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,EAAE,CAAC;IACL,mFAAmF;IACnF,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,GAAG,YAAY,aAAa;YAAE,MAAM,GAAG,CAAC;QAC5C,MAAM,IAAI,aAAa,CAAC,SAAS,EAAE,GAAG,IAAI,yBAA0B,GAAa,EAAE,OAAO,IAAI,GAAG,GAAG,CAAC,CAAC;IACxG,CAAC;YACO,CAAC;QACP,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,SAAS,CAAE,KAAiB,EAAE,IAAY;IACxD,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAAC,CAAC;IACnF,MAAM,CAAC;QAAC,MAAM,IAAI,aAAa,CAAC,UAAU,EAAE,GAAG,IAAI,0BAA0B,CAAC,CAAC;IAAC,CAAC;AACnF,CAAC"}
@@ -0,0 +1,34 @@
1
+ export interface LoaderLimits {
2
+ /** A DID document, in bytes. */
3
+ didDocumentBytes: number;
4
+ /** A record as a PDS gives it, in bytes. */
5
+ recordBytes: number;
6
+ /** Any one resource of a tile, in bytes. A resource whose record declares its size is held to that. */
7
+ resourceBytes: number;
8
+ /** How many resources a tile may have that are not the same bytes. */
9
+ resources: number;
10
+ /** All the resources of a tile together, in bytes: what a running tile holds in the host page's memory. */
11
+ tileBytes: number;
12
+ /** A resource asked for before the tile is run, in bytes: a card's picture, of which a feed draws many. */
13
+ cardBytes: number;
14
+ /** A tile that comes as one file (a .tile, a .xdc), whole, in bytes. */
15
+ archiveBytes: number;
16
+ /** How many requests for a tile's resources are under way at once. Resources whose record declares no size are asked for one at a time. */
17
+ concurrency: number;
18
+ /** One request, from asking to the last byte of the answer, in milliseconds. */
19
+ requestMs: number;
20
+ /** All of a tile, from the moment it is run to the moment everything it lists is here, in milliseconds. A tile that comes as one file has as long to arrive. */
21
+ prepareMs: number;
22
+ /** How many times a resource is asked for again after a server error or a failed request. Never after a 429. */
23
+ retries: number;
24
+ /** How long to wait before asking again, in milliseconds. Up to as much again is added, so that viewers do not all come back at once. */
25
+ retryMs: number;
26
+ }
27
+ export declare const DEFAULT_LIMITS: LoaderLimits;
28
+ /**
29
+ * The limits a loader works to: these, and what its host put in their place.
30
+ * A limit is a number that is not negative; `Infinity` is no limit, except
31
+ * for how often to ask again, which has to end.
32
+ */
33
+ export declare function limitsOf(given?: Partial<LoaderLimits>): LoaderLimits;
34
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/lib/limits.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,uGAAuG;IACvG,aAAa,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,CAAC;IAClB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB,2IAA2I;IAC3I,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,gKAAgK;IAChK,SAAS,EAAE,MAAM,CAAC;IAClB,gHAAgH;IAChH,OAAO,EAAE,MAAM,CAAC;IAChB,yIAAyI;IACzI,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,cAAc,EAAE,YAa5B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,QAAQ,CAAE,KAAK,GAAE,OAAO,CAAC,YAAY,CAAM,GAAG,YAAY,CAOzE"}
@@ -0,0 +1,33 @@
1
+ // How much a loader takes, and how long it waits. What a tile is made of
2
+ // comes from its author's servers, and a server can answer without end, or
3
+ // not at all. Every figure here is a first guess: a host that knows better
4
+ // replaces any of them with the `limits` option of a loader.
5
+ export const DEFAULT_LIMITS = {
6
+ didDocumentBytes: 64 * 1024,
7
+ recordBytes: 1024 * 1024,
8
+ resourceBytes: 10 * 1024 * 1024,
9
+ resources: 256,
10
+ tileBytes: 25 * 1024 * 1024,
11
+ cardBytes: 2 * 1024 * 1024,
12
+ archiveBytes: 32 * 1024 * 1024,
13
+ concurrency: 6,
14
+ requestMs: 20_000,
15
+ prepareMs: 60_000,
16
+ retries: 1,
17
+ retryMs: 300,
18
+ };
19
+ /**
20
+ * The limits a loader works to: these, and what its host put in their place.
21
+ * A limit is a number that is not negative; `Infinity` is no limit, except
22
+ * for how often to ask again, which has to end.
23
+ */
24
+ export function limitsOf(given = {}) {
25
+ const limits = { ...DEFAULT_LIMITS };
26
+ for (const key of Object.keys(limits)) {
27
+ const value = given[key];
28
+ if (typeof value === 'number' && value >= 0 && (key !== 'retries' || Number.isFinite(value)))
29
+ limits[key] = value;
30
+ }
31
+ return limits;
32
+ }
33
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/lib/limits.ts"],"names":[],"mappings":"AACA,yEAAyE;AACzE,2EAA2E;AAC3E,2EAA2E;AAC3E,6DAA6D;AA6B7D,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,gBAAgB,EAAE,EAAE,GAAG,IAAI;IAC3B,WAAW,EAAE,IAAI,GAAG,IAAI;IACxB,aAAa,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC/B,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC3B,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IAC1B,YAAY,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC9B,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,GAAG;CACb,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAE,QAA+B,EAAE;IACzD,MAAM,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC;IACrC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAA8B,EAAE,CAAC;QACnE,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACpH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,83 @@
1
+ export interface PointerState {
2
+ /**
3
+ * `unknown`: nothing seen yet. `host`: over the page itself, at (x, y).
4
+ * `frame`: inside a frame, somewhere (it went in at x, y). `away`: out of
5
+ * the window. `none`: the last pointer was a finger, and it is up.
6
+ */
7
+ kind: 'unknown' | 'host' | 'frame' | 'away' | 'none';
8
+ /** `mouse`, `pen` or `touch`: the last pointer seen. Empty before any. */
9
+ type: string;
10
+ /** Where it was last seen, in client coordinates. */
11
+ x: number;
12
+ y: number;
13
+ /** When that was (performance.now()). */
14
+ at: number;
15
+ /**
16
+ * Whether it got there by moving: it was last seen somewhere else. A
17
+ * pointer that shows up in a frame at the very place the page last saw it
18
+ * has not moved: the frame was put under it (the page scrolled, or was laid
19
+ * out again), and the browser is only bringing hover up to date.
20
+ */
21
+ moved: boolean;
22
+ }
23
+ export interface PointerWatch {
24
+ readonly state: PointerState;
25
+ /** The frame the pointer is in, when it is in one. */
26
+ readonly frame: Element | undefined;
27
+ /** Whether what this user points with hovers (a mouse, a pen) or not (a finger). */
28
+ readonly hovers: boolean;
29
+ /**
30
+ * Whether this screen takes fingers at all. Where it does, a finger may
31
+ * land in a frame at any moment, unseen, wherever the mouse is known to be.
32
+ */
33
+ readonly fingers: boolean;
34
+ /** Whether the pointer is, or may be, inside `frame`. */
35
+ inside(frame: Element): boolean;
36
+ /**
37
+ * Has `fn` called after the pointer was seen somewhere else. `fn` is held
38
+ * weakly: whoever asks keeps it, and it goes when they do. Returns a
39
+ * function that stops it.
40
+ */
41
+ onChange(fn: () => void): () => void;
42
+ }
43
+ /** The pointer in `doc`, followed from now on. One watch per document. */
44
+ export declare function watchPointer(doc: Document): PointerWatch;
45
+ /** A rectangle in client coordinates. */
46
+ export interface Box {
47
+ left: number;
48
+ top: number;
49
+ width: number;
50
+ height: number;
51
+ }
52
+ export interface ShieldOptions {
53
+ /** How long it stays after the last press on it, in milliseconds. */
54
+ ms: number;
55
+ /** How long it stays while a mouse rests on it without pressing, in milliseconds. */
56
+ dwellMs: number;
57
+ /** Stay until a press has been taken (then `ms`), or for `maxMs`. */
58
+ sticky?: boolean;
59
+ maxMs?: number;
60
+ /** An element whose box the rectangle follows: it is placed again whenever that box changes. */
61
+ follow?: Element;
62
+ /** Called with each press it takes. */
63
+ onAbsorb?: () => void;
64
+ }
65
+ export interface Shield {
66
+ /** Whether it has gone. */
67
+ readonly gone: boolean;
68
+ remove(): void;
69
+ }
70
+ /** The class of a shield's element, for a host's own rules to know it by. */
71
+ export declare const SHIELD_CLASS = "tile-shield";
72
+ /**
73
+ * A piece of the page that takes no press for a moment: a block of the
74
+ * host's, all but invisible, on top of everything, where `rect()` says (and
75
+ * it is asked again as the page scrolls). It goes `ms` after the last press
76
+ * on it; a press on it is swallowed and starts the wait again; and while a
77
+ * mouse rests on it, it stays until the mouse has left, or has rested there
78
+ * `dwellMs` without pressing. A `sticky` one stays until it has swallowed a
79
+ * press (then `ms`), or for `maxMs`. A wheel or a finger still scrolls the
80
+ * page through it.
81
+ */
82
+ export declare function shield(doc: Document, rect: () => Box | undefined, options: ShieldOptions): Shield;
83
+ //# sourceMappingURL=pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/lib/pointer.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACrD,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yDAAyD;IACzD,MAAM,CAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAE,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CACvC;AAUD,0EAA0E;AAC1E,wBAAgB,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