@react-x11/components 0.4.0 → 0.6.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 +143 -8
- package/dist/charts/components.d.ts +3 -1
- package/dist/charts/components.d.ts.map +1 -1
- package/dist/charts/components.js +8 -4
- package/dist/charts/components.js.map +1 -1
- package/dist/charts/node.d.ts +13 -6
- package/dist/charts/node.d.ts.map +1 -1
- package/dist/charts/node.js +75 -24
- package/dist/charts/node.js.map +1 -1
- package/dist/charts/render.d.ts +4 -0
- package/dist/charts/render.d.ts.map +1 -1
- package/dist/charts/render.js +11 -6
- package/dist/charts/render.js.map +1 -1
- package/dist/code-editor/node.d.ts +47 -16
- package/dist/code-editor/node.d.ts.map +1 -1
- package/dist/code-editor/node.js +121 -51
- package/dist/code-editor/node.js.map +1 -1
- package/dist/flow/draw.d.ts +19 -1
- package/dist/flow/draw.d.ts.map +1 -1
- package/dist/flow/draw.js +64 -35
- package/dist/flow/draw.js.map +1 -1
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +24 -8
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/model.d.ts +4 -2
- package/dist/flow/model.d.ts.map +1 -1
- package/dist/flow/model.js +4 -2
- package/dist/flow/model.js.map +1 -1
- package/dist/flow/node.d.ts +40 -9
- package/dist/flow/node.d.ts.map +1 -1
- package/dist/flow/node.js +142 -53
- package/dist/flow/node.js.map +1 -1
- package/dist/flow/types.d.ts +46 -21
- package/dist/flow/types.d.ts.map +1 -1
- package/dist/formula/index.d.ts +4 -2
- package/dist/formula/index.d.ts.map +1 -1
- package/dist/formula/index.js.map +1 -1
- package/dist/formula/node.d.ts +5 -1
- package/dist/formula/node.d.ts.map +1 -1
- package/dist/formula/node.js +19 -3
- package/dist/formula/node.js.map +1 -1
- package/dist/html/controls.d.ts +4 -1
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js.map +1 -1
- package/dist/html/css/cascade.d.ts +11 -5
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +18 -8
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/parse.d.ts +15 -10
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +41 -16
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +3 -0
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +3 -1
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/values.d.ts +14 -1
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js +11 -8
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +1 -0
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +12 -5
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +7 -4
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +22 -1
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/node.d.ts +22 -8
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +97 -15
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +3 -0
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +2 -2
- package/dist/html/paint.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/maps/clip.d.ts +43 -0
- package/dist/maps/clip.d.ts.map +1 -0
- package/dist/maps/clip.js +171 -0
- package/dist/maps/clip.js.map +1 -0
- package/dist/maps/gzip.d.ts +15 -0
- package/dist/maps/gzip.d.ts.map +1 -0
- package/dist/maps/gzip.js +56 -0
- package/dist/maps/gzip.js.map +1 -0
- package/dist/maps/index.d.ts +55 -0
- package/dist/maps/index.d.ts.map +1 -0
- package/dist/maps/index.js +141 -0
- package/dist/maps/index.js.map +1 -0
- package/dist/maps/labels.d.ts +123 -0
- package/dist/maps/labels.d.ts.map +1 -0
- package/dist/maps/labels.js +323 -0
- package/dist/maps/labels.js.map +1 -0
- package/dist/maps/mvt.d.ts +244 -0
- package/dist/maps/mvt.d.ts.map +1 -0
- package/dist/maps/mvt.js +820 -0
- package/dist/maps/mvt.js.map +1 -0
- package/dist/maps/node.d.ts +278 -0
- package/dist/maps/node.d.ts.map +1 -0
- package/dist/maps/node.js +1459 -0
- package/dist/maps/node.js.map +1 -0
- package/dist/maps/overlay.d.ts +157 -0
- package/dist/maps/overlay.d.ts.map +1 -0
- package/dist/maps/overlay.js +472 -0
- package/dist/maps/overlay.js.map +1 -0
- package/dist/maps/paint.d.ts +226 -0
- package/dist/maps/paint.d.ts.map +1 -0
- package/dist/maps/paint.js +705 -0
- package/dist/maps/paint.js.map +1 -0
- package/dist/maps/proj.d.ts +281 -0
- package/dist/maps/proj.d.ts.map +1 -0
- package/dist/maps/proj.js +451 -0
- package/dist/maps/proj.js.map +1 -0
- package/dist/maps/sources.d.ts +256 -0
- package/dist/maps/sources.d.ts.map +1 -0
- package/dist/maps/sources.js +210 -0
- package/dist/maps/sources.js.map +1 -0
- package/dist/maps/style.d.ts +141 -0
- package/dist/maps/style.d.ts.map +1 -0
- package/dist/maps/style.js +147 -0
- package/dist/maps/style.js.map +1 -0
- package/dist/maps/styles.d.ts +82 -0
- package/dist/maps/styles.d.ts.map +1 -0
- package/dist/maps/styles.js +898 -0
- package/dist/maps/styles.js.map +1 -0
- package/dist/maps/tiles.d.ts +283 -0
- package/dist/maps/tiles.d.ts.map +1 -0
- package/dist/maps/tiles.js +469 -0
- package/dist/maps/tiles.js.map +1 -0
- package/dist/maps/types.d.ts +244 -0
- package/dist/maps/types.d.ts.map +1 -0
- package/dist/maps/types.js +2 -0
- package/dist/maps/types.js.map +1 -0
- package/dist/markdown/ast.d.ts +80 -6
- package/dist/markdown/ast.d.ts.map +1 -1
- package/dist/markdown/ast.js +13 -4
- package/dist/markdown/ast.js.map +1 -1
- package/dist/markdown/expressions.d.ts +27 -0
- package/dist/markdown/expressions.d.ts.map +1 -0
- package/dist/markdown/expressions.js +203 -0
- package/dist/markdown/expressions.js.map +1 -0
- package/dist/markdown/index.d.ts +61 -2
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/markdown/index.js +101 -2
- package/dist/markdown/index.js.map +1 -1
- package/dist/markdown/parse.d.ts +1 -1
- package/dist/markdown/parse.d.ts.map +1 -1
- package/dist/markdown/parse.js +163 -15
- package/dist/markdown/parse.js.map +1 -1
- package/dist/markdown/spans.d.ts.map +1 -1
- package/dist/markdown/spans.js +4 -0
- package/dist/markdown/spans.js.map +1 -1
- package/dist/markdown/tags.d.ts +35 -0
- package/dist/markdown/tags.d.ts.map +1 -0
- package/dist/markdown/tags.js +213 -0
- package/dist/markdown/tags.js.map +1 -0
- package/dist/reorder/hx.d.ts +18 -0
- package/dist/reorder/hx.d.ts.map +1 -0
- package/dist/reorder/hx.js +10 -0
- package/dist/reorder/hx.js.map +1 -0
- package/dist/reorder/index.d.ts +314 -0
- package/dist/reorder/index.d.ts.map +1 -0
- package/dist/reorder/index.js +1539 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/model.d.ts +107 -0
- package/dist/reorder/model.d.ts.map +1 -0
- package/dist/reorder/model.js +162 -0
- package/dist/reorder/model.js.map +1 -0
- package/dist/richtext/node.d.ts +15 -5
- package/dist/richtext/node.d.ts.map +1 -1
- package/dist/richtext/node.js +40 -11
- package/dist/richtext/node.js.map +1 -1
- package/dist/richtext/runs.d.ts +35 -13
- package/dist/richtext/runs.d.ts.map +1 -1
- package/dist/richtext/runs.js +83 -27
- package/dist/richtext/runs.js.map +1 -1
- package/dist/tabs/index.d.ts +17 -0
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +849 -186
- package/dist/tabs/index.js.map +1 -1
- package/dist/terminal/vt/fonts.d.ts +45 -15
- package/dist/terminal/vt/fonts.d.ts.map +1 -1
- package/dist/terminal/vt/fonts.js +89 -19
- package/dist/terminal/vt/fonts.js.map +1 -1
- package/dist/terminal/vt/node.d.ts +42 -0
- package/dist/terminal/vt/node.d.ts.map +1 -1
- package/dist/terminal/vt/node.js +95 -11
- package/dist/terminal/vt/node.js.map +1 -1
- package/dist/terminal/vt/renderer.d.ts.map +1 -1
- package/dist/terminal/vt/renderer.js +13 -3
- package/dist/terminal/vt/renderer.js.map +1 -1
- package/package.json +14 -3
- package/src/charts/components.ts +14 -7
- package/src/charts/node.ts +81 -26
- package/src/charts/render.ts +16 -6
- package/src/code-editor/node.ts +147 -53
- package/src/flow/draw.ts +104 -35
- package/src/flow/index.ts +33 -13
- package/src/flow/model.ts +4 -2
- package/src/flow/node.ts +158 -59
- package/src/flow/types.ts +46 -21
- package/src/formula/index.ts +4 -2
- package/src/formula/node.ts +24 -5
- package/src/html/controls.ts +4 -1
- package/src/html/css/cascade.ts +18 -7
- package/src/html/css/parse.ts +46 -21
- package/src/html/css/style.ts +6 -1
- package/src/html/css/values.ts +25 -9
- package/src/html/index.ts +1 -0
- package/src/html/layout/boxes.ts +19 -9
- package/src/html/layout/inline.ts +23 -1
- package/src/html/node.ts +110 -17
- package/src/html/paint.ts +17 -2
- package/src/index.ts +102 -0
- package/src/maps/clip.ts +184 -0
- package/src/maps/gzip.ts +66 -0
- package/src/maps/index.ts +316 -0
- package/src/maps/labels.ts +442 -0
- package/src/maps/mvt.ts +857 -0
- package/src/maps/node.ts +1819 -0
- package/src/maps/overlay.ts +639 -0
- package/src/maps/paint.ts +978 -0
- package/src/maps/proj.ts +641 -0
- package/src/maps/sources.ts +425 -0
- package/src/maps/style.ts +309 -0
- package/src/maps/styles.ts +1040 -0
- package/src/maps/tiles.ts +676 -0
- package/src/maps/types.ts +260 -0
- package/src/markdown/ast.ts +85 -9
- package/src/markdown/expressions.ts +223 -0
- package/src/markdown/index.ts +190 -5
- package/src/markdown/parse.ts +230 -15
- package/src/markdown/spans.ts +4 -0
- package/src/markdown/tags.ts +240 -0
- package/src/reorder/hx.ts +31 -0
- package/src/reorder/index.ts +2223 -0
- package/src/reorder/model.ts +232 -0
- package/src/richtext/node.ts +49 -14
- package/src/richtext/runs.ts +115 -30
- package/src/tabs/index.ts +1040 -204
- package/src/terminal/vt/fonts.ts +128 -36
- package/src/terminal/vt/node.ts +105 -12
- package/src/terminal/vt/renderer.ts +13 -3
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { parseTile } from './mvt.js';
|
|
2
|
+
import { tileKey } from './proj.js';
|
|
3
|
+
import { pyramidOf } from './sources.js';
|
|
4
|
+
/**
|
|
5
|
+
* One tile as the cover asked for it, and its renderings.
|
|
6
|
+
*
|
|
7
|
+
* The data behind it is `data`, which is this tile until the cover goes
|
|
8
|
+
* deeper than the source does. The status accessors read through, so
|
|
9
|
+
* everything that only wants "is there anything to draw" reads the same
|
|
10
|
+
* names it always did.
|
|
11
|
+
*/
|
|
12
|
+
export class CachedTile {
|
|
13
|
+
key;
|
|
14
|
+
sourceId;
|
|
15
|
+
tile;
|
|
16
|
+
/** The source tile whose bytes this draws. Itself, or an ancestor. */
|
|
17
|
+
data;
|
|
18
|
+
/** Where this tile sits inside `data`: cell `(x, y)` of `span × span`. */
|
|
19
|
+
sub;
|
|
20
|
+
/**
|
|
21
|
+
* The rendering that is on screen. **Always finished**, which is the
|
|
22
|
+
* whole point of the pair.
|
|
23
|
+
*
|
|
24
|
+
* A tile is re-rasterized whenever its size, its style zoom or the cache
|
|
25
|
+
* generation moves. Drawn in place, each of those clears the surface and
|
|
26
|
+
* leaves the tile blank for the six or so frames it takes to redraw: a
|
|
27
|
+
* visible flash, and many more of them on a backend that paints more
|
|
28
|
+
* frames. So the new rendering goes into {@link drawing} and this one
|
|
29
|
+
* keeps being composited until it is ready to be replaced.
|
|
30
|
+
*/
|
|
31
|
+
shown = null;
|
|
32
|
+
/** The rendering being drawn, or null when there is nothing to draw. */
|
|
33
|
+
drawing = null;
|
|
34
|
+
/** Frame counter of the last frame that wanted it — what eviction sorts
|
|
35
|
+
* on. */
|
|
36
|
+
lastUsed = 0;
|
|
37
|
+
constructor(key, sourceId, tile, data, sub) {
|
|
38
|
+
this.key = key;
|
|
39
|
+
this.sourceId = sourceId;
|
|
40
|
+
this.tile = tile;
|
|
41
|
+
this.data = data;
|
|
42
|
+
this.sub = sub;
|
|
43
|
+
}
|
|
44
|
+
get status() {
|
|
45
|
+
return this.data.status;
|
|
46
|
+
}
|
|
47
|
+
get error() {
|
|
48
|
+
return this.data.error;
|
|
49
|
+
}
|
|
50
|
+
get vector() {
|
|
51
|
+
return this.data.vector;
|
|
52
|
+
}
|
|
53
|
+
get raster() {
|
|
54
|
+
return this.data.raster;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const DEFAULT_SURFACE_BUDGET = 128 * 1024 * 1024;
|
|
58
|
+
const DEFAULT_DATA_BUDGET = 192;
|
|
59
|
+
/**
|
|
60
|
+
* The cache.
|
|
61
|
+
*
|
|
62
|
+
* One per element. Nothing in it knows about the camera: it is asked for
|
|
63
|
+
* tiles by name, and told once a frame which ones are still wanted.
|
|
64
|
+
*/
|
|
65
|
+
export class TileCache {
|
|
66
|
+
_entries = new Map();
|
|
67
|
+
/** The source's own tiles, shared by every rendering that draws one. */
|
|
68
|
+
_data = new Map();
|
|
69
|
+
_options;
|
|
70
|
+
_frame = 0;
|
|
71
|
+
_surfaceBytes = 0;
|
|
72
|
+
/** Bumped by a style change, which retires every surface without
|
|
73
|
+
* touching the data behind it. */
|
|
74
|
+
_generation = 0;
|
|
75
|
+
constructor(options = {}) {
|
|
76
|
+
this._options = options;
|
|
77
|
+
}
|
|
78
|
+
/** Bumped once per paint; `lastUsed` is stamped from it. */
|
|
79
|
+
beginFrame() {
|
|
80
|
+
return ++this._frame;
|
|
81
|
+
}
|
|
82
|
+
get generation() {
|
|
83
|
+
return this._generation;
|
|
84
|
+
}
|
|
85
|
+
/** Every rendered surface is stale — a new style, a new display scale. */
|
|
86
|
+
invalidateStyle() {
|
|
87
|
+
this._generation++;
|
|
88
|
+
}
|
|
89
|
+
/** How much the rendered surfaces are holding, in bytes. */
|
|
90
|
+
get surfaceBytes() {
|
|
91
|
+
return this._surfaceBytes;
|
|
92
|
+
}
|
|
93
|
+
get size() {
|
|
94
|
+
return this._entries.size;
|
|
95
|
+
}
|
|
96
|
+
key(sourceId, tile) {
|
|
97
|
+
return `${sourceId}:${tileKey(tile)}`;
|
|
98
|
+
}
|
|
99
|
+
peek(sourceId, tile) {
|
|
100
|
+
return this._entries.get(this.key(sourceId, tile));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The entry for a tile the cover asked for, and the data behind it,
|
|
104
|
+
* asking the source for that data if nothing has yet.
|
|
105
|
+
*
|
|
106
|
+
* `dataTile` is the tile whose bytes serve this one — itself, until the
|
|
107
|
+
* cover goes deeper than the source cuts. Marks both used by the current
|
|
108
|
+
* frame, which is what keeps them out of the next eviction.
|
|
109
|
+
*/
|
|
110
|
+
want(source, sourceId, tile, dataTile = tile, sub = { x: 0, y: 0, span: 1 }) {
|
|
111
|
+
const data = this._wantData(source, sourceId, dataTile);
|
|
112
|
+
const key = this.key(sourceId, tile);
|
|
113
|
+
let entry = this._entries.get(key);
|
|
114
|
+
if (!entry) {
|
|
115
|
+
entry = new CachedTile(key, sourceId, tile, data, sub);
|
|
116
|
+
this._entries.set(key, entry);
|
|
117
|
+
}
|
|
118
|
+
entry.lastUsed = this._frame;
|
|
119
|
+
return entry;
|
|
120
|
+
}
|
|
121
|
+
_wantData(source, sourceId, tile) {
|
|
122
|
+
const key = this.key(sourceId, tile);
|
|
123
|
+
let data = this._data.get(key);
|
|
124
|
+
if (!data) {
|
|
125
|
+
data = {
|
|
126
|
+
key,
|
|
127
|
+
tile,
|
|
128
|
+
status: 'idle',
|
|
129
|
+
error: null,
|
|
130
|
+
vector: null,
|
|
131
|
+
raster: null,
|
|
132
|
+
abort: null,
|
|
133
|
+
attempts: 0,
|
|
134
|
+
retryAt: 0,
|
|
135
|
+
lastUsed: 0,
|
|
136
|
+
};
|
|
137
|
+
this._data.set(key, data);
|
|
138
|
+
}
|
|
139
|
+
data.lastUsed = this._frame;
|
|
140
|
+
if (data.status === 'idle') {
|
|
141
|
+
this._load(source, sourceId, data);
|
|
142
|
+
}
|
|
143
|
+
else if (data.status === 'error' && Date.now() >= data.retryAt) {
|
|
144
|
+
// A failed tile is retried, but on a backoff rather than on every
|
|
145
|
+
// frame. Without it a source that is down — or an application whose
|
|
146
|
+
// `load` throws on the first call, which is how this was found — is
|
|
147
|
+
// asked for every visible tile sixty times a second, which is a
|
|
148
|
+
// retry storm pointed at somebody else's servers.
|
|
149
|
+
this._load(source, sourceId, data);
|
|
150
|
+
}
|
|
151
|
+
return data;
|
|
152
|
+
}
|
|
153
|
+
_load(source, sourceId, entry) {
|
|
154
|
+
entry.status = 'loading';
|
|
155
|
+
entry.error = null;
|
|
156
|
+
// A **real** `AbortController` where the runtime has one. A look-alike
|
|
157
|
+
// is not good enough: `fetch` checks `instanceof AbortSignal` and
|
|
158
|
+
// throws `TypeError` on anything else, so handing a source a plain
|
|
159
|
+
// object with an `aborted` getter fails every load a source makes the
|
|
160
|
+
// documented way — which is exactly what it did.
|
|
161
|
+
const Controller = globalThis.AbortController;
|
|
162
|
+
let aborted = false;
|
|
163
|
+
const controller = Controller ? new Controller() : null;
|
|
164
|
+
const signal = controller
|
|
165
|
+
? controller.signal
|
|
166
|
+
: {
|
|
167
|
+
get aborted() {
|
|
168
|
+
return aborted;
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
entry.abort = () => {
|
|
172
|
+
aborted = true;
|
|
173
|
+
controller?.abort();
|
|
174
|
+
};
|
|
175
|
+
const fail = (error) => {
|
|
176
|
+
entry.status = 'error';
|
|
177
|
+
entry.error = error;
|
|
178
|
+
entry.attempts++;
|
|
179
|
+
// 0.5s, 1, 2, 4, 8, 16, then 30s — long enough that a dead source
|
|
180
|
+
// costs nothing, short enough that a blip repairs itself.
|
|
181
|
+
entry.retryAt =
|
|
182
|
+
Date.now() + Math.min(30_000, 500 * 2 ** (entry.attempts - 1));
|
|
183
|
+
};
|
|
184
|
+
const settle = (fn) => {
|
|
185
|
+
// A load that finished after its tile was evicted must not resurrect
|
|
186
|
+
// it: the entry is gone from the map, so writing to it would leak a
|
|
187
|
+
// surface nothing composites.
|
|
188
|
+
if (aborted || this._data.get(entry.key) !== entry)
|
|
189
|
+
return;
|
|
190
|
+
entry.abort = null;
|
|
191
|
+
fn();
|
|
192
|
+
if (entry.status === 'error')
|
|
193
|
+
this._options.onError?.(entry);
|
|
194
|
+
this._options.onChange?.(entry);
|
|
195
|
+
};
|
|
196
|
+
let result;
|
|
197
|
+
try {
|
|
198
|
+
result = source.load({ ...entry.tile, sourceId, signal });
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
settle(() => fail(error));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const accept = (data) => settle(() => {
|
|
205
|
+
entry.attempts = 0;
|
|
206
|
+
entry.retryAt = 0;
|
|
207
|
+
if (data === null) {
|
|
208
|
+
entry.status = 'empty';
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (data.kind === 'vector') {
|
|
212
|
+
try {
|
|
213
|
+
entry.vector = parseTile(data.data);
|
|
214
|
+
entry.status = 'ready';
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
fail(error);
|
|
218
|
+
}
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
entry.raster = data;
|
|
222
|
+
entry.status = 'ready';
|
|
223
|
+
});
|
|
224
|
+
if (result && typeof result.then === 'function') {
|
|
225
|
+
result.then(accept, (error) => settle(() => fail(error)));
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
accept(result);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The nearest ancestor of `tile` that already has a drawn surface, or
|
|
233
|
+
* null.
|
|
234
|
+
*
|
|
235
|
+
* What covers a hole. A zoom in has the previous level's tiles in hand
|
|
236
|
+
* and the new level's on the way, so the coarse picture is scaled up
|
|
237
|
+
* under the fine one until it arrives — which is the difference between a
|
|
238
|
+
* map that fills in and a map that flashes empty. Bounded, because
|
|
239
|
+
* scaling one tile over sixteen screenfuls is worse than the hole.
|
|
240
|
+
*/
|
|
241
|
+
ancestorWithSurface(sourceId, tile, levels = 5) {
|
|
242
|
+
let z = tile.z - 1;
|
|
243
|
+
let x = tile.x >> 1;
|
|
244
|
+
let y = tile.y >> 1;
|
|
245
|
+
for (let up = 0; up < levels && z >= 0; up++, z--, x >>= 1, y >>= 1) {
|
|
246
|
+
const entry = this._entries.get(this.key(sourceId, { z, x, y }));
|
|
247
|
+
// `shown` is finished by construction, so an ancestor is never a
|
|
248
|
+
// half-drawn picture.
|
|
249
|
+
if (entry?.shown) {
|
|
250
|
+
// Stamped, because for as long as it is covering a hole it is on
|
|
251
|
+
// screen — and an unstamped entry is the *first* thing eviction
|
|
252
|
+
// takes, which would drop the only picture the map is showing.
|
|
253
|
+
entry.lastUsed = this._frame;
|
|
254
|
+
return entry;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The finished **descendants** of a tile, and where each sits inside it.
|
|
261
|
+
*
|
|
262
|
+
* The mirror of {@link ancestorWithSurface}, and the half a map needs
|
|
263
|
+
* when it zooms *out*: the tiles already in hand are then the target's
|
|
264
|
+
* children, and walking up the pyramid finds nothing. Without this a
|
|
265
|
+
* zoom-out shows the background — with the labels and markers still drawn
|
|
266
|
+
* over it, which is exactly as odd as it sounds — until the coarser tile
|
|
267
|
+
* has been fetched, rasterized and composited.
|
|
268
|
+
*
|
|
269
|
+
* `depth` is how many levels down to look, and it is small on purpose: a
|
|
270
|
+
* level down is 4 tiles, two is 16, and beyond that the pieces are too
|
|
271
|
+
* small to be worth the composites.
|
|
272
|
+
*/
|
|
273
|
+
descendantsWithSurface(sourceId, tile, depth = 2) {
|
|
274
|
+
for (let down = 1; down <= depth; down++) {
|
|
275
|
+
const span = 1 << down;
|
|
276
|
+
const found = [];
|
|
277
|
+
for (let dy = 0; dy < span; dy++) {
|
|
278
|
+
for (let dx = 0; dx < span; dx++) {
|
|
279
|
+
const entry = this._entries.get(this.key(sourceId, {
|
|
280
|
+
z: tile.z + down,
|
|
281
|
+
x: (tile.x << down) + dx,
|
|
282
|
+
y: (tile.y << down) + dy,
|
|
283
|
+
}));
|
|
284
|
+
if (entry?.shown) {
|
|
285
|
+
entry.lastUsed = this._frame;
|
|
286
|
+
found.push({ entry, x: dx, y: dy, span });
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// The nearest level that has anything wins: one level down is both
|
|
291
|
+
// the sharpest and the fewest composites.
|
|
292
|
+
if (found.length > 0)
|
|
293
|
+
return found;
|
|
294
|
+
}
|
|
295
|
+
return [];
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* The rendering this tile should be drawn into, or null when what is on
|
|
299
|
+
* screen is already right.
|
|
300
|
+
*
|
|
301
|
+
* The size, the zoom and the cache generation are all part of what makes
|
|
302
|
+
* a rendering valid: one drawn at the wrong size composites blurry, and
|
|
303
|
+
* one drawn at another zoom carries the wrong road widths and the wrong
|
|
304
|
+
* layers.
|
|
305
|
+
*
|
|
306
|
+
* When something is already on screen and a *new* rendering is needed,
|
|
307
|
+
* this hands back a second surface and leaves the first one composited
|
|
308
|
+
* until {@link promote} swaps them. That is the whole of the
|
|
309
|
+
* double-buffering: without it a re-rasterization clears the surface and
|
|
310
|
+
* the tile is blank for the several frames it takes to redraw, which
|
|
311
|
+
* above a source's `maxZoom` happens at every integer zoom — the same
|
|
312
|
+
* z14 tile serves 15, 16, 17 and on.
|
|
313
|
+
*/
|
|
314
|
+
beginRender(entry, size, zoom, make) {
|
|
315
|
+
if (this._matches(entry.shown, size, zoom))
|
|
316
|
+
return null;
|
|
317
|
+
if (this._matches(entry.drawing, size, zoom))
|
|
318
|
+
return entry.drawing;
|
|
319
|
+
// A draft for something else — an intermediate zoom the camera swept
|
|
320
|
+
// past — is thrown away rather than finished.
|
|
321
|
+
if (entry.drawing)
|
|
322
|
+
this._release(entry.drawing);
|
|
323
|
+
entry.drawing = null;
|
|
324
|
+
const surface = make(size);
|
|
325
|
+
if (!surface)
|
|
326
|
+
return null;
|
|
327
|
+
this._surfaceBytes += size * size * 4;
|
|
328
|
+
entry.drawing = {
|
|
329
|
+
surface,
|
|
330
|
+
context: surface.getContext('2d'),
|
|
331
|
+
size,
|
|
332
|
+
zoom,
|
|
333
|
+
generation: this._generation,
|
|
334
|
+
progress: 0,
|
|
335
|
+
progressLayer: 0,
|
|
336
|
+
};
|
|
337
|
+
return entry.drawing;
|
|
338
|
+
}
|
|
339
|
+
_matches(render, size, zoom) {
|
|
340
|
+
return (render !== null &&
|
|
341
|
+
render.size === size &&
|
|
342
|
+
render.zoom === zoom &&
|
|
343
|
+
render.generation === this._generation);
|
|
344
|
+
}
|
|
345
|
+
/** The finished draft becomes what is on screen, and the old one goes.
|
|
346
|
+
* True when that happened, which is the one moment a tile's pixels
|
|
347
|
+
* change and therefore the one moment worth claiming damage for. */
|
|
348
|
+
promote(entry) {
|
|
349
|
+
if (!entry.drawing || entry.drawing.progress !== -1)
|
|
350
|
+
return false;
|
|
351
|
+
if (entry.shown)
|
|
352
|
+
this._release(entry.shown);
|
|
353
|
+
entry.shown = entry.drawing;
|
|
354
|
+
entry.drawing = null;
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
/** Note where a tile's rasterization stopped: at run `run`, having
|
|
358
|
+
* finished `layer` of its active layers (`-1` for all of them). */
|
|
359
|
+
advance(render, run, layer, style) {
|
|
360
|
+
render.progress = run >= style.runs.length ? -1 : run;
|
|
361
|
+
render.progressLayer = layer < 0 ? 0 : layer;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Drop what is no longer worth keeping.
|
|
365
|
+
*
|
|
366
|
+
* Surfaces go first and by least-recently-wanted, because they are two
|
|
367
|
+
* orders of magnitude larger than the data behind them and much cheaper
|
|
368
|
+
* to lose: a dropped surface is one re-rasterization, a dropped tile is a
|
|
369
|
+
* network request.
|
|
370
|
+
*/
|
|
371
|
+
sweep() {
|
|
372
|
+
if (this._surfaceBytes >
|
|
373
|
+
(this._options.surfaceBudget ?? DEFAULT_SURFACE_BUDGET)) {
|
|
374
|
+
const withSurfaces = [...this._entries.values()]
|
|
375
|
+
.filter((entry) => entry.shown !== null || entry.drawing !== null)
|
|
376
|
+
.sort((a, b) => a.lastUsed - b.lastUsed);
|
|
377
|
+
const budget = this._options.surfaceBudget ?? DEFAULT_SURFACE_BUDGET;
|
|
378
|
+
for (const entry of withSurfaces) {
|
|
379
|
+
if (this._surfaceBytes <= budget)
|
|
380
|
+
break;
|
|
381
|
+
// Never the frame being drawn: a surface evicted this frame is one
|
|
382
|
+
// that will be rebuilt this frame.
|
|
383
|
+
if (entry.lastUsed >= this._frame)
|
|
384
|
+
continue;
|
|
385
|
+
this._dropSurface(entry);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const dataBudget = this._options.dataBudget ?? DEFAULT_DATA_BUDGET;
|
|
389
|
+
if (this._entries.size > dataBudget) {
|
|
390
|
+
const all = [...this._entries.values()].sort((a, b) => a.lastUsed - b.lastUsed);
|
|
391
|
+
for (const entry of all) {
|
|
392
|
+
if (this._entries.size <= dataBudget)
|
|
393
|
+
break;
|
|
394
|
+
if (entry.lastUsed >= this._frame)
|
|
395
|
+
continue;
|
|
396
|
+
this._drop(entry);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (this._data.size > dataBudget) {
|
|
400
|
+
const all = [...this._data.values()].sort((a, b) => a.lastUsed - b.lastUsed);
|
|
401
|
+
for (const data of all) {
|
|
402
|
+
if (this._data.size <= dataBudget)
|
|
403
|
+
break;
|
|
404
|
+
if (data.lastUsed >= this._frame)
|
|
405
|
+
continue;
|
|
406
|
+
this._dropData(data);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
_dropSurface(entry) {
|
|
411
|
+
if (entry.shown)
|
|
412
|
+
this._release(entry.shown);
|
|
413
|
+
if (entry.drawing)
|
|
414
|
+
this._release(entry.drawing);
|
|
415
|
+
entry.shown = null;
|
|
416
|
+
entry.drawing = null;
|
|
417
|
+
}
|
|
418
|
+
_release(render) {
|
|
419
|
+
this._surfaceBytes -= render.size * render.size * 4;
|
|
420
|
+
render.context?.destroy?.();
|
|
421
|
+
render.surface.destroy();
|
|
422
|
+
}
|
|
423
|
+
_drop(entry) {
|
|
424
|
+
this._dropSurface(entry);
|
|
425
|
+
this._entries.delete(entry.key);
|
|
426
|
+
}
|
|
427
|
+
/** Drop a source tile's bytes, and abort a load still in flight for it.
|
|
428
|
+
* Only when no rendering still points at it. */
|
|
429
|
+
_dropData(data) {
|
|
430
|
+
for (const entry of this._entries.values()) {
|
|
431
|
+
if (entry.data === data)
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
data.abort?.();
|
|
435
|
+
this._data.delete(data.key);
|
|
436
|
+
}
|
|
437
|
+
/** Release everything. Called from the element's `destroySubtree`. */
|
|
438
|
+
destroy() {
|
|
439
|
+
for (const entry of [...this._entries.values()])
|
|
440
|
+
this._drop(entry);
|
|
441
|
+
this._entries.clear();
|
|
442
|
+
for (const data of this._data.values())
|
|
443
|
+
data.abort?.();
|
|
444
|
+
this._data.clear();
|
|
445
|
+
this._surfaceBytes = 0;
|
|
446
|
+
}
|
|
447
|
+
/** Every entry — for a test, and for the `onTiles` diagnostic. */
|
|
448
|
+
entries() {
|
|
449
|
+
return this._entries.values();
|
|
450
|
+
}
|
|
451
|
+
/** Every source tile whose bytes are held. What labels are collected
|
|
452
|
+
* from: a label belongs to the tile the data came from, and past a
|
|
453
|
+
* source's depth many renderings share one of those. */
|
|
454
|
+
dataEntries() {
|
|
455
|
+
return this._data.values();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/** A source's pyramid, memoized per source object so the defaults are not
|
|
459
|
+
* refilled per frame. */
|
|
460
|
+
const pyramids = new WeakMap();
|
|
461
|
+
export function pyramid(source) {
|
|
462
|
+
let found = pyramids.get(source);
|
|
463
|
+
if (!found) {
|
|
464
|
+
found = pyramidOf(source);
|
|
465
|
+
pyramids.set(source, found);
|
|
466
|
+
}
|
|
467
|
+
return found;
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=tiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiles.js","sourceRoot":"","sources":["../../src/maps/tiles.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAqFzC;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACZ,GAAG,CAAS;IACZ,QAAQ,CAAS;IACjB,IAAI,CAAS;IACtB,sEAAsE;IAC7D,IAAI,CAAgB;IAC7B,0EAA0E;IACjE,GAAG,CAAyC;IAErD;;;;;;;;;;OAUG;IACH,KAAK,GAAsB,IAAI,CAAC;IAChC,wEAAwE;IACxE,OAAO,GAAsB,IAAI,CAAC;IAClC;cACU;IACV,QAAQ,GAAG,CAAC,CAAC;IAEb,YACE,GAAW,EACX,QAAgB,EAChB,IAAY,EACZ,IAAmB,EACnB,GAA2C;QAE3C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAA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