@solidtv/renderer 1.6.2 → 1.6.4
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/dist/exports/index.d.ts +1 -0
- package/dist/exports/index.js +3 -0
- package/dist/exports/index.js.map +1 -1
- package/dist/src/core/lib/ImageWorker.d.ts +2 -1
- package/dist/src/core/lib/ImageWorker.js +25 -3
- package/dist/src/core/lib/ImageWorker.js.map +1 -1
- package/dist/src/core/text-rendering/CanvasFontHandler.js +28 -8
- package/dist/src/core/text-rendering/CanvasFontHandler.js.map +1 -1
- package/dist/src/core/text-rendering/FontPrefetch.d.ts +55 -0
- package/dist/src/core/text-rendering/FontPrefetch.js +140 -0
- package/dist/src/core/text-rendering/FontPrefetch.js.map +1 -0
- package/dist/src/core/text-rendering/SdfFontHandler.js +42 -10
- package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -1
- package/dist/src/main-api/Renderer.d.ts +10 -10
- package/dist/src/main-api/Renderer.js +3 -3
- package/dist/src/main-api/Renderer.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/exports/index.ts +7 -0
- package/package.json +1 -1
- package/src/core/lib/ImageWorker.test.ts +26 -2
- package/src/core/lib/ImageWorker.ts +24 -3
- package/src/core/text-rendering/CanvasFontHandler.ts +32 -11
- package/src/core/text-rendering/FontPrefetch.ts +195 -0
- package/src/core/text-rendering/SdfFontHandler.ts +50 -10
- package/src/core/text-rendering/tests/FontPrefetch.test.ts +341 -0
- package/src/core/text-rendering/tests/SdfFontHandler.test.ts +43 -0
- package/src/main-api/Renderer.ts +13 -13
|
@@ -4,11 +4,13 @@ import {
|
|
|
4
4
|
waitingForFont,
|
|
5
5
|
isFontLoaded,
|
|
6
6
|
getFontData,
|
|
7
|
+
canRenderFont,
|
|
7
8
|
MAX_FONT_LOAD_RETRIES,
|
|
8
9
|
} from '../SdfFontHandler.js';
|
|
9
10
|
import { EventEmitter } from '../../../common/EventEmitter.js';
|
|
10
11
|
import { TextureError, TextureErrorCode } from '../../TextureError.js';
|
|
11
12
|
import type { Stage } from '../../Stage.js';
|
|
13
|
+
import type { TrProps } from '../TextRenderer.js';
|
|
12
14
|
|
|
13
15
|
// Minimal XHR stand-in: synchronously delivers valid SDF font JSON so loadFont
|
|
14
16
|
// proceeds to create the atlas texture and attach its event listeners.
|
|
@@ -294,6 +296,47 @@ describe('SdfFontHandler loadFont — multiple names for one font', () => {
|
|
|
294
296
|
}
|
|
295
297
|
});
|
|
296
298
|
|
|
299
|
+
it('reports every name as renderable while the font is still loading', async () => {
|
|
300
|
+
const { stage, textures } = makeStage();
|
|
301
|
+
const names = ['MidLoadPrimary', 'MidLoadAlias'];
|
|
302
|
+
|
|
303
|
+
const promise = loadFont(stage, opts(names));
|
|
304
|
+
|
|
305
|
+
// Mid-load: nothing is in fontCache yet, so this is answered purely by the
|
|
306
|
+
// in-flight markers. An alias that answers `false` here makes the stage
|
|
307
|
+
// resolve a *different* text renderer for the node — silently substituting
|
|
308
|
+
// a Canvas face, or throwing "No compatible text renderer found" when SDF
|
|
309
|
+
// is the only engine. Both names must answer the same.
|
|
310
|
+
for (let i = 0; i < names.length; i++) {
|
|
311
|
+
expect(canRenderFont({ fontFamily: names[i]! } as TrProps)).toBe(true);
|
|
312
|
+
}
|
|
313
|
+
expect(isFontLoaded(names[1]!)).toBe(false);
|
|
314
|
+
|
|
315
|
+
await flush();
|
|
316
|
+
textures[0]!.emit('loaded');
|
|
317
|
+
await promise;
|
|
318
|
+
|
|
319
|
+
for (let i = 0; i < names.length; i++) {
|
|
320
|
+
expect(canRenderFont({ fontFamily: names[i]! } as TrProps)).toBe(true);
|
|
321
|
+
expect(isFontLoaded(names[i]!)).toBe(true);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('dedupes a load requested under an alias onto the in-flight load', async () => {
|
|
326
|
+
const { stage, textures } = makeStage();
|
|
327
|
+
|
|
328
|
+
const first = loadFont(stage, opts(['DedupePrimary', 'DedupeAlias']));
|
|
329
|
+
const second = loadFont(stage, opts('DedupeAlias'));
|
|
330
|
+
|
|
331
|
+
expect(second).toBe(first);
|
|
332
|
+
|
|
333
|
+
await flush();
|
|
334
|
+
// A single atlas fetch served both calls.
|
|
335
|
+
expect(textures.length).toBe(1);
|
|
336
|
+
textures[0]!.emit('loaded');
|
|
337
|
+
await first;
|
|
338
|
+
});
|
|
339
|
+
|
|
297
340
|
it('wakes nodes parked under an alias, not just the primary name', async () => {
|
|
298
341
|
const { stage, textures } = makeStage();
|
|
299
342
|
const names = ['MultiWakePrimary', 'MultiWakeAlias'];
|
package/src/main-api/Renderer.ts
CHANGED
|
@@ -654,16 +654,16 @@ export type RendererMainSettings = RendererRuntimeSettings & {
|
|
|
654
654
|
* ignore it, returning straight (non-premultiplied) alpha. This causes edge
|
|
655
655
|
* "ghosting" on images with transparency.
|
|
656
656
|
*
|
|
657
|
-
* `'auto'`
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
* @defaultValue `
|
|
657
|
+
* Set to `'auto'` to detect via a cheap startup probe (one 1×1 PNG decode +
|
|
658
|
+
* texture upload + framebuffer readback). On devices that honor the option —
|
|
659
|
+
* the vast majority — the probe returns `true` and behavior is identical to
|
|
660
|
+
* assuming it honored; only devices that actually ignore it (e.g. the
|
|
661
|
+
* Movistar STB) switch to the WebGL-side premultiply fallback. Set to a
|
|
662
|
+
* boolean to force the value (`false` forces the GL-premultiply fallback;
|
|
663
|
+
* `true` skips it). Leave unset to assume the option is honored — the
|
|
664
|
+
* default, which preserves existing behavior with no probe overhead.
|
|
665
|
+
*
|
|
666
|
+
* @defaultValue `true` (assume honored; no probe)
|
|
667
667
|
*/
|
|
668
668
|
premultiplyAlphaHonored?: boolean | 'auto';
|
|
669
669
|
|
|
@@ -825,11 +825,11 @@ export class RendererMain extends EventEmitter {
|
|
|
825
825
|
textureProcessingTimeLimit: settings.textureProcessingTimeLimit || 10,
|
|
826
826
|
canvas: settings.canvas,
|
|
827
827
|
createImageBitmapSupport: settings.createImageBitmapSupport || 'auto',
|
|
828
|
-
// undefined ->
|
|
829
|
-
// explicit boolean -> force the value
|
|
828
|
+
// undefined -> true (assume honored, no probe); 'auto' -> probe;
|
|
829
|
+
// explicit boolean -> force the value.
|
|
830
830
|
premultiplyAlphaHonored:
|
|
831
831
|
settings.premultiplyAlphaHonored === undefined
|
|
832
|
-
?
|
|
832
|
+
? true
|
|
833
833
|
: settings.premultiplyAlphaHonored,
|
|
834
834
|
platform: settings.platform || null,
|
|
835
835
|
maxRetryCount: settings.maxRetryCount ?? 5,
|