@popcorn245/cornfield 0.57.1 → 0.57.2
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/explorer/engine/render.js +1 -1
- package/explorer/labels.js +11 -1
- package/explorer/work-badges.js +7 -1
- package/package.json +1 -1
|
@@ -83,7 +83,7 @@ export function createMap(inst, opts = {}) {
|
|
|
83
83
|
if (!state.labelCanvas) return null;
|
|
84
84
|
if (!labelLayer || labelLayerCanvas !== state.labelCanvas) {
|
|
85
85
|
if (labelLayer) labelLayer.destroy();
|
|
86
|
-
labelLayer = createLabelLayer(state.labelCanvas, { mapStyle });
|
|
86
|
+
labelLayer = createLabelLayer(state.labelCanvas, { mapStyle, redraw: render }); // a web font that arrives asks for a frame
|
|
87
87
|
labelLayerCanvas = state.labelCanvas;
|
|
88
88
|
if (state.width) labelLayer.resize(state.width, state.height, inst.dpr());
|
|
89
89
|
}
|
package/explorer/labels.js
CHANGED
|
@@ -314,7 +314,8 @@ export function labelHit(placed, camera, x, y) {
|
|
|
314
314
|
/**
|
|
315
315
|
* A transparent 2D canvas that draws the chosen labels over the map
|
|
316
316
|
* @param {HTMLCanvasElement} canvas
|
|
317
|
-
* @param {{mapStyle?: () => import('./map-style.js').MapStyle}} [opts] `mapStyle`: where the theme's map tokens come from (the instance's: `mapStyleOf(inst).get`; none: no theme);
|
|
317
|
+
* @param {{mapStyle?: () => import('./map-style.js').MapStyle, redraw?: () => void}} [opts] `mapStyle`: where the theme's map tokens come from (the instance's: `mapStyleOf(inst).get`; none: no theme);
|
|
318
|
+
* `redraw`: asks the map for a frame (a web font arrived, so the labels are measured and placed again);
|
|
318
319
|
* a node's label colour is the theme's `--corn-map-label`, and the outline under every label its `--corn-map-label-halo`, when it sets them
|
|
319
320
|
* @returns {{hit: (x: number, y: number) => string|null, draw: (scene: import('./scene.js').Scene, camera: import('./scene.js').Camera, extras?: {hover?: string|null}) => boolean, resize: (width: number, height: number, dpr: number) => void, destroy: () => void}}
|
|
320
321
|
* `draw` returns whether it painted: false when the camera, the scene, the size and the hovered node were unchanged; `extras.hover` is the
|
|
@@ -344,6 +345,14 @@ export function createLabelLayer(canvas, opts = {}) {
|
|
|
344
345
|
return w;
|
|
345
346
|
};
|
|
346
347
|
|
|
348
|
+
// A web font that arrives late changes every width measured in the face used until then, and the family string is the same: measure again.
|
|
349
|
+
// `dirty` makes the next draw place every label again; `kept` stays until then, so `hit` still answers for the labels on the screen.
|
|
350
|
+
// The next draw is asked for (`opts.redraw`): the map's style asks only when the theme names a label font, and a face in the labels' own stack can arrive too
|
|
351
|
+
const fonts = canvas.ownerDocument && canvas.ownerDocument.fonts; // the canvas's own document: none in a test's fake canvas
|
|
352
|
+
const redraw = typeof opts.redraw === 'function' ? opts.redraw : null;
|
|
353
|
+
const fontsArrived = () => { if (destroyed) return; widths.clear(); dirty = true; if (redraw) redraw(); };
|
|
354
|
+
if (fonts && fonts.addEventListener) fonts.addEventListener('loadingdone', fontsArrived);
|
|
355
|
+
|
|
347
356
|
return {
|
|
348
357
|
/** The node whose label is drawn under a screen point (a cluster's title: input.js frames the cluster), or null */
|
|
349
358
|
hit(x, y) {
|
|
@@ -397,6 +406,7 @@ export function createLabelLayer(canvas, opts = {}) {
|
|
|
397
406
|
|
|
398
407
|
destroy() {
|
|
399
408
|
destroyed = true;
|
|
409
|
+
if (fonts && fonts.removeEventListener) fonts.removeEventListener('loadingdone', fontsArrived);
|
|
400
410
|
lastScene = null;
|
|
401
411
|
kept = null;
|
|
402
412
|
widths.clear();
|
package/explorer/work-badges.js
CHANGED
|
@@ -139,5 +139,11 @@ export function createWorkBadges({ stage, state, style, colorOf, wanted, doc = d
|
|
|
139
139
|
for (const [id, el] of pills) if (!seen.has(id)) { el.remove(); pills.delete(id); }
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
// A web font that arrives late (the page's, the pill's text; the theme's label font, the names') changes the widths and the pill's height measured in the face used
|
|
143
|
+
// until then, and the family strings are the same (issue #285): measure and place again at the next paint (the map asks for one: labels.js)
|
|
144
|
+
const fonts = doc && doc.fonts;
|
|
145
|
+
const fontsArrived = () => { widths.clear(); tall = { key: '', h: 0 }; placed = null; placedKey = ''; drawnKey = ''; };
|
|
146
|
+
if (fonts && fonts.addEventListener) fonts.addEventListener('loadingdone', fontsArrived);
|
|
147
|
+
|
|
148
|
+
return { sync, clear, destroy() { clear(); if (fonts && fonts.removeEventListener) fonts.removeEventListener('loadingdone', fontsArrived); if (layer) layer.remove(); layer = null; } };
|
|
143
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popcorn245/cornfield",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.2",
|
|
4
4
|
"description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "popcorn245 (https://github.com/popcorn245)",
|