@glissade/backend-skia 0.4.1 → 0.4.3
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/index.d.ts +13 -2
- package/dist/index.js +15 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { Canvas, Image } from "@napi-rs/canvas";
|
|
2
|
-
import { DisplayList, FontSpec, TextMetricsLite, TextMetricsLite as TextMetricsLite$1, VideoFrameSource } from "@glissade/scene";
|
|
2
|
+
import { DisplayList, FontSpec, TextMeasurer, TextMetricsLite, TextMetricsLite as TextMetricsLite$1, VideoFrameSource } from "@glissade/scene";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
|
|
6
6
|
type Drawable = Canvas | Image;
|
|
7
|
+
/**
|
|
8
|
+
* Factory-time measurement (§3.6): component factories run before any scene
|
|
9
|
+
* exists, so give the process a real measurer up front —
|
|
10
|
+
* setDefaultMeasurer(createMeasurer({ fonts: { 'DejaVu Sans': fontPath } }))
|
|
11
|
+
* Text pulls (measuredSize/lineBoxes/wordBoxes) and un-injected scenes then
|
|
12
|
+
* measure with the SAME rasterizer metrics gs render and the golden harness
|
|
13
|
+
* use; scene-injected measurers still win. The backing canvas is lazy.
|
|
14
|
+
*/
|
|
15
|
+
declare function createMeasurer(opts?: {
|
|
16
|
+
fonts?: Record<string, string>;
|
|
17
|
+
}): TextMeasurer;
|
|
7
18
|
declare class SkiaBackend {
|
|
8
19
|
private readonly canvas;
|
|
9
20
|
private readonly raster;
|
|
@@ -19,4 +30,4 @@ declare class SkiaBackend {
|
|
|
19
30
|
dispose(): void;
|
|
20
31
|
}
|
|
21
32
|
//#endregion
|
|
22
|
-
export { SkiaBackend, type TextMetricsLite };
|
|
33
|
+
export { SkiaBackend, type TextMetricsLite, createMeasurer };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Path2D, createCanvas } from "@napi-rs/canvas";
|
|
1
|
+
import { GlobalFonts, Path2D, createCanvas } from "@napi-rs/canvas";
|
|
2
2
|
import { Raster2D, fontString } from "@glissade/scene";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
/**
|
|
@@ -8,6 +8,19 @@ import { Raster2D, fontString } from "@glissade/scene";
|
|
|
8
8
|
* structurally cannot drift. This file owns only the @napi-rs canvas flavor
|
|
9
9
|
* plus headless concerns (PNG encode, sync readPixels, text measurement).
|
|
10
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Factory-time measurement (§3.6): component factories run before any scene
|
|
13
|
+
* exists, so give the process a real measurer up front —
|
|
14
|
+
* setDefaultMeasurer(createMeasurer({ fonts: { 'DejaVu Sans': fontPath } }))
|
|
15
|
+
* Text pulls (measuredSize/lineBoxes/wordBoxes) and un-injected scenes then
|
|
16
|
+
* measure with the SAME rasterizer metrics gs render and the golden harness
|
|
17
|
+
* use; scene-injected measurers still win. The backing canvas is lazy.
|
|
18
|
+
*/
|
|
19
|
+
function createMeasurer(opts = {}) {
|
|
20
|
+
for (const [family, path] of Object.entries(opts.fonts ?? {})) GlobalFonts.registerFromPath(path, family);
|
|
21
|
+
let backend = null;
|
|
22
|
+
return { measureText: (text, font) => (backend ??= new SkiaBackend(8, 8)).measureText(text, font) };
|
|
23
|
+
}
|
|
11
24
|
var SkiaBackend = class {
|
|
12
25
|
canvas;
|
|
13
26
|
raster;
|
|
@@ -53,4 +66,4 @@ var SkiaBackend = class {
|
|
|
53
66
|
}
|
|
54
67
|
};
|
|
55
68
|
//#endregion
|
|
56
|
-
export { SkiaBackend };
|
|
69
|
+
export { SkiaBackend, createMeasurer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissade/backend-skia",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "glissade headless render backend: DisplayList -> @napi-rs/canvas (Skia). Node-only; the CI-grade deterministic path.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@napi-rs/canvas": "^0.1.65",
|
|
19
|
-
"@glissade/core": "0.4.
|
|
20
|
-
"@glissade/scene": "0.4.
|
|
19
|
+
"@glissade/core": "0.4.3",
|
|
20
|
+
"@glissade/scene": "0.4.3"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|