resvg-napi 0.2.0 → 0.3.1
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 +141 -35
- package/THIRD-PARTY-NOTICES.md +653 -0
- package/index.d.ts +48 -109
- package/index.js +81 -82
- package/package.json +29 -23
- package/resvg-napi.wasi-browser.js +2 -2
- package/resvg-napi.wasi.cjs +20 -17
- package/resvg-napi.wasi.d.cts +48 -109
- package/wasi-worker-browser.mjs +1 -3
- package/wasi-worker.mjs +31 -23
package/resvg-napi.wasi.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
|
|
3
4
|
/** Read-only handle on a `usvg::ClipPath`. */
|
|
4
5
|
export declare class ClipPath {
|
|
5
6
|
/**
|
|
@@ -44,6 +45,11 @@ export declare class Font {
|
|
|
44
45
|
get stretch(): FontStretch
|
|
45
46
|
get weight(): number
|
|
46
47
|
get variations(): Array<FontVariation>
|
|
48
|
+
/**
|
|
49
|
+
* Families this span asked for, in order. Never empty: usvg appends
|
|
50
|
+
* `RenderOptions.fontFamily` as the last resort.
|
|
51
|
+
*/
|
|
52
|
+
get families(): Array<string>
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
/** Opaque wrapper over `fontdb::Database` (memory-mapped faces, no JSON form). */
|
|
@@ -360,6 +366,23 @@ export declare class Resvg {
|
|
|
360
366
|
* `FontDatabase` and re-parse to fix the output.
|
|
361
367
|
*/
|
|
362
368
|
pendingFonts(): Array<string>
|
|
369
|
+
/**
|
|
370
|
+
* The face that actually drew a glyph, from the database this
|
|
371
|
+
* document was parsed with.
|
|
372
|
+
*
|
|
373
|
+
* `pendingFonts()` names the families that were missing; this names
|
|
374
|
+
* what was used instead, glyph by glyph, which is the half a
|
|
375
|
+
* document-wide list cannot answer. A fallback that renders is the
|
|
376
|
+
* failure nobody sees.
|
|
377
|
+
*
|
|
378
|
+
* The lookup lives here rather than on `FontDatabase` because
|
|
379
|
+
* `PositionedGlyph.font` is a `fontdb::ID` -- a slotmap key with no
|
|
380
|
+
* public numeric form, and meaningless against any other database.
|
|
381
|
+
* The glyph carries it the way `FontFace` carries one for
|
|
382
|
+
* `FontDatabase.face`, and `null` means exactly that: a glyph from
|
|
383
|
+
* another document.
|
|
384
|
+
*/
|
|
385
|
+
faceOf(glyph: PositionedGlyph): FontFace | null
|
|
363
386
|
/**
|
|
364
387
|
* Supplies one image and re-parses the document.
|
|
365
388
|
*
|
|
@@ -690,18 +713,7 @@ export declare class TextSpan {
|
|
|
690
713
|
}
|
|
691
714
|
|
|
692
715
|
/** An alignment baseline property. */
|
|
693
|
-
export type AlignmentBaseline =
|
|
694
|
-
'baseline'|
|
|
695
|
-
'beforeEdge'|
|
|
696
|
-
'textBeforeEdge'|
|
|
697
|
-
'middle'|
|
|
698
|
-
'central'|
|
|
699
|
-
'afterEdge'|
|
|
700
|
-
'textAfterEdge'|
|
|
701
|
-
'ideographic'|
|
|
702
|
-
'alphabetic'|
|
|
703
|
-
'hanging'|
|
|
704
|
-
'mathematical';
|
|
716
|
+
export type AlignmentBaseline = 'auto' | 'baseline' | 'beforeEdge' | 'textBeforeEdge' | 'middle' | 'central' | 'afterEdge' | 'textAfterEdge' | 'ideographic' | 'alphabetic' | 'hanging' | 'mathematical'
|
|
705
717
|
|
|
706
718
|
/** `BaselineShift::Number`. */
|
|
707
719
|
export interface BaselineShiftNumber {
|
|
@@ -736,22 +748,7 @@ export interface Blend {
|
|
|
736
748
|
*
|
|
737
749
|
* `mix-blend-mode` attribute in the SVG.
|
|
738
750
|
*/
|
|
739
|
-
export type BlendMode =
|
|
740
|
-
'multiply'|
|
|
741
|
-
'screen'|
|
|
742
|
-
'overlay'|
|
|
743
|
-
'darken'|
|
|
744
|
-
'lighten'|
|
|
745
|
-
'colorDodge'|
|
|
746
|
-
'colorBurn'|
|
|
747
|
-
'hardLight'|
|
|
748
|
-
'softLight'|
|
|
749
|
-
'difference'|
|
|
750
|
-
'exclusion'|
|
|
751
|
-
'hue'|
|
|
752
|
-
'saturation'|
|
|
753
|
-
'color'|
|
|
754
|
-
'luminosity';
|
|
751
|
+
export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'colorDodge' | 'colorBurn' | 'hardLight' | 'softLight' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity'
|
|
755
752
|
|
|
756
753
|
/** Plain view of a `Color`. */
|
|
757
754
|
export interface Color {
|
|
@@ -761,18 +758,14 @@ export interface Color {
|
|
|
761
758
|
}
|
|
762
759
|
|
|
763
760
|
/** A color channel. */
|
|
764
|
-
export type ColorChannel =
|
|
765
|
-
'g'|
|
|
766
|
-
'b'|
|
|
767
|
-
'a';
|
|
761
|
+
export type ColorChannel = 'r' | 'g' | 'b' | 'a'
|
|
768
762
|
|
|
769
763
|
/**
|
|
770
764
|
* A color interpolation mode.
|
|
771
765
|
*
|
|
772
766
|
* The default is `ColorInterpolation::LinearRGB`.
|
|
773
767
|
*/
|
|
774
|
-
export type ColorInterpolation =
|
|
775
|
-
'linearRgb';
|
|
768
|
+
export type ColorInterpolation = 'srgb' | 'linearRgb'
|
|
776
769
|
|
|
777
770
|
/** Plain view of a `ColorMatrix`. */
|
|
778
771
|
export interface ColorMatrix {
|
|
@@ -889,18 +882,7 @@ export interface DistantLight {
|
|
|
889
882
|
}
|
|
890
883
|
|
|
891
884
|
/** A dominant baseline property. */
|
|
892
|
-
export type DominantBaseline =
|
|
893
|
-
'useScript'|
|
|
894
|
-
'noChange'|
|
|
895
|
-
'resetSize'|
|
|
896
|
-
'ideographic'|
|
|
897
|
-
'alphabetic'|
|
|
898
|
-
'hanging'|
|
|
899
|
-
'mathematical'|
|
|
900
|
-
'central'|
|
|
901
|
-
'middle'|
|
|
902
|
-
'textAfterEdge'|
|
|
903
|
-
'textBeforeEdge';
|
|
885
|
+
export type DominantBaseline = 'auto' | 'useScript' | 'noChange' | 'resetSize' | 'ideographic' | 'alphabetic' | 'hanging' | 'mathematical' | 'central' | 'middle' | 'textAfterEdge' | 'textBeforeEdge'
|
|
904
886
|
|
|
905
887
|
/** Plain view of a `DropShadow`. */
|
|
906
888
|
export interface DropShadow {
|
|
@@ -914,9 +896,7 @@ export interface DropShadow {
|
|
|
914
896
|
}
|
|
915
897
|
|
|
916
898
|
/** An edges processing mode. */
|
|
917
|
-
export type EdgeMode =
|
|
918
|
-
'duplicate'|
|
|
919
|
-
'wrap';
|
|
899
|
+
export type EdgeMode = 'none' | 'duplicate' | 'wrap'
|
|
920
900
|
|
|
921
901
|
/** Plain view of a `Fill`. */
|
|
922
902
|
export interface Fill {
|
|
@@ -930,8 +910,7 @@ export interface Fill {
|
|
|
930
910
|
*
|
|
931
911
|
* `fill-rule` attribute in the SVG.
|
|
932
912
|
*/
|
|
933
|
-
export type FillRule =
|
|
934
|
-
'evenOdd';
|
|
913
|
+
export type FillRule = 'nonZero' | 'evenOdd'
|
|
935
914
|
|
|
936
915
|
/** Plain view of a `Flood`. */
|
|
937
916
|
export interface Flood {
|
|
@@ -940,9 +919,7 @@ export interface Flood {
|
|
|
940
919
|
}
|
|
941
920
|
|
|
942
921
|
/** Allows italic or oblique faces to be selected. */
|
|
943
|
-
export type FontFaceStyle =
|
|
944
|
-
'italic'|
|
|
945
|
-
'oblique';
|
|
922
|
+
export type FontFaceStyle = 'normal' | 'italic' | 'oblique'
|
|
946
923
|
|
|
947
924
|
/**
|
|
948
925
|
* A font optical sizing property.
|
|
@@ -950,24 +927,13 @@ export type FontFaceStyle = 'normal'|
|
|
|
950
927
|
* Controls automatic adjustment of the `opsz` axis in variable fonts
|
|
951
928
|
* based on font size. Matches CSS `font-optical-sizing`.
|
|
952
929
|
*/
|
|
953
|
-
export type FontOpticalSizing =
|
|
954
|
-
'none';
|
|
930
|
+
export type FontOpticalSizing = 'auto' | 'none'
|
|
955
931
|
|
|
956
932
|
/** A font stretch property. */
|
|
957
|
-
export type FontStretch =
|
|
958
|
-
'extraCondensed'|
|
|
959
|
-
'condensed'|
|
|
960
|
-
'semiCondensed'|
|
|
961
|
-
'normal'|
|
|
962
|
-
'semiExpanded'|
|
|
963
|
-
'expanded'|
|
|
964
|
-
'extraExpanded'|
|
|
965
|
-
'ultraExpanded';
|
|
933
|
+
export type FontStretch = 'ultraCondensed' | 'extraCondensed' | 'condensed' | 'semiCondensed' | 'normal' | 'semiExpanded' | 'expanded' | 'extraExpanded' | 'ultraExpanded'
|
|
966
934
|
|
|
967
935
|
/** A font style property. */
|
|
968
|
-
export type FontStyle =
|
|
969
|
-
'italic'|
|
|
970
|
-
'oblique';
|
|
936
|
+
export type FontStyle = 'normal' | 'italic' | 'oblique'
|
|
971
937
|
|
|
972
938
|
/** Plain view of a `FontVariation`. */
|
|
973
939
|
export interface FontVariation {
|
|
@@ -993,12 +959,7 @@ export interface ImageKindSvg {
|
|
|
993
959
|
*
|
|
994
960
|
* `image-rendering` attribute in the SVG.
|
|
995
961
|
*/
|
|
996
|
-
export type ImageRendering =
|
|
997
|
-
'optimizeSpeed'|
|
|
998
|
-
'smooth'|
|
|
999
|
-
'highQuality'|
|
|
1000
|
-
'crispEdges'|
|
|
1001
|
-
'pixelated';
|
|
962
|
+
export type ImageRendering = 'optimizeQuality' | 'optimizeSpeed' | 'smooth' | 'highQuality' | 'crispEdges' | 'pixelated'
|
|
1002
963
|
|
|
1003
964
|
/** The payload-free variants of `Input`. */
|
|
1004
965
|
export interface InputPlain {
|
|
@@ -1132,8 +1093,7 @@ export interface KindTurbulence {
|
|
|
1132
1093
|
}
|
|
1133
1094
|
|
|
1134
1095
|
/** A length adjust property. */
|
|
1135
|
-
export type LengthAdjust =
|
|
1136
|
-
'spacingAndGlyphs';
|
|
1096
|
+
export type LengthAdjust = 'spacing' | 'spacingAndGlyphs'
|
|
1137
1097
|
|
|
1138
1098
|
/** `LightSource::DistantLight`. */
|
|
1139
1099
|
export interface LightSourceDistantLight {
|
|
@@ -1161,23 +1121,17 @@ export interface LightSourceSpotLight {
|
|
|
1161
1121
|
*
|
|
1162
1122
|
* `stroke-linecap` attribute in the SVG.
|
|
1163
1123
|
*/
|
|
1164
|
-
export type LineCap =
|
|
1165
|
-
'round'|
|
|
1166
|
-
'square';
|
|
1124
|
+
export type LineCap = 'butt' | 'round' | 'square'
|
|
1167
1125
|
|
|
1168
1126
|
/**
|
|
1169
1127
|
* A line join.
|
|
1170
1128
|
*
|
|
1171
1129
|
* `stroke-linejoin` attribute in the SVG.
|
|
1172
1130
|
*/
|
|
1173
|
-
export type LineJoin =
|
|
1174
|
-
'miterClip'|
|
|
1175
|
-
'round'|
|
|
1176
|
-
'bevel';
|
|
1131
|
+
export type LineJoin = 'miter' | 'miterClip' | 'round' | 'bevel'
|
|
1177
1132
|
|
|
1178
1133
|
/** A mask type. */
|
|
1179
|
-
export type MaskType =
|
|
1180
|
-
'alpha';
|
|
1134
|
+
export type MaskType = 'luminance' | 'alpha'
|
|
1181
1135
|
|
|
1182
1136
|
/**
|
|
1183
1137
|
* An affine transform. Field names and order are tiny-skia's.
|
|
@@ -1212,14 +1166,10 @@ export interface Morphology {
|
|
|
1212
1166
|
}
|
|
1213
1167
|
|
|
1214
1168
|
/** A morphology operation. */
|
|
1215
|
-
export type MorphologyOperator =
|
|
1216
|
-
'dilate';
|
|
1169
|
+
export type MorphologyOperator = 'erode' | 'dilate'
|
|
1217
1170
|
|
|
1218
1171
|
/** Which flavour of node this is. */
|
|
1219
|
-
export type NodeKind =
|
|
1220
|
-
'path'|
|
|
1221
|
-
'image'|
|
|
1222
|
-
'text';
|
|
1172
|
+
export type NodeKind = 'group' | 'path' | 'image' | 'text'
|
|
1223
1173
|
|
|
1224
1174
|
/** Plain view of a `Offset`. */
|
|
1225
1175
|
export interface Offset {
|
|
@@ -1250,8 +1200,7 @@ export interface PaintLinearGradient {
|
|
|
1250
1200
|
*
|
|
1251
1201
|
* [`paint-order`]: https://www.w3.org/TR/SVG2/painting.html#PaintOrder
|
|
1252
1202
|
*/
|
|
1253
|
-
export type PaintOrder =
|
|
1254
|
-
'strokeAndFill';
|
|
1203
|
+
export type PaintOrder = 'fillAndStroke' | 'strokeAndFill'
|
|
1255
1204
|
|
|
1256
1205
|
/** `Paint::Pattern`. */
|
|
1257
1206
|
export interface PaintPattern {
|
|
@@ -1457,9 +1406,7 @@ export declare function setLogLevel(level: 'off' | 'error' | 'warn' | 'info' | '
|
|
|
1457
1406
|
*
|
|
1458
1407
|
* `shape-rendering` attribute in the SVG.
|
|
1459
1408
|
*/
|
|
1460
|
-
export type ShapeRendering =
|
|
1461
|
-
'crispEdges'|
|
|
1462
|
-
'geometricPrecision';
|
|
1409
|
+
export type ShapeRendering = 'optimizeSpeed' | 'crispEdges' | 'geometricPrecision'
|
|
1463
1410
|
|
|
1464
1411
|
/** Plain view of a `SpecularLighting`. */
|
|
1465
1412
|
export interface SpecularLighting {
|
|
@@ -1488,9 +1435,7 @@ export interface SpotLight {
|
|
|
1488
1435
|
*
|
|
1489
1436
|
* `spreadMethod` attribute in the SVG.
|
|
1490
1437
|
*/
|
|
1491
|
-
export type SpreadMethod =
|
|
1492
|
-
'reflect'|
|
|
1493
|
-
'repeat';
|
|
1438
|
+
export type SpreadMethod = 'pad' | 'reflect' | 'repeat'
|
|
1494
1439
|
|
|
1495
1440
|
/** Plain view of a `Stop`. */
|
|
1496
1441
|
export interface Stop {
|
|
@@ -1515,9 +1460,7 @@ export interface Stroke {
|
|
|
1515
1460
|
export declare function takeLogs(): Array<string>
|
|
1516
1461
|
|
|
1517
1462
|
/** A text chunk anchor property. */
|
|
1518
|
-
export type TextAnchor =
|
|
1519
|
-
'middle'|
|
|
1520
|
-
'end';
|
|
1463
|
+
export type TextAnchor = 'start' | 'middle' | 'end'
|
|
1521
1464
|
|
|
1522
1465
|
/** Plain view of a `TextDecoration`. */
|
|
1523
1466
|
export interface TextDecoration {
|
|
@@ -1550,9 +1493,7 @@ export interface TextFlowPlain {
|
|
|
1550
1493
|
*
|
|
1551
1494
|
* `text-rendering` attribute in the SVG.
|
|
1552
1495
|
*/
|
|
1553
|
-
export type TextRendering =
|
|
1554
|
-
'optimizeLegibility'|
|
|
1555
|
-
'geometricPrecision';
|
|
1496
|
+
export type TextRendering = 'optimizeSpeed' | 'optimizeLegibility' | 'geometricPrecision'
|
|
1556
1497
|
|
|
1557
1498
|
/** Plain view of a `Tile`. */
|
|
1558
1499
|
export interface Tile {
|
|
@@ -1607,8 +1548,7 @@ export interface Turbulence {
|
|
|
1607
1548
|
}
|
|
1608
1549
|
|
|
1609
1550
|
/** A turbulence kind for the `feTurbulence` filter. */
|
|
1610
|
-
export type TurbulenceKind =
|
|
1611
|
-
'turbulence';
|
|
1551
|
+
export type TurbulenceKind = 'fractalNoise' | 'turbulence'
|
|
1612
1552
|
|
|
1613
1553
|
/**
|
|
1614
1554
|
* Mirror of `usvg::WriteOptions`, for `Resvg.toString()`. Every field is
|
|
@@ -1662,5 +1602,4 @@ export interface WriteOptions {
|
|
|
1662
1602
|
}
|
|
1663
1603
|
|
|
1664
1604
|
/** A writing mode. */
|
|
1665
|
-
export type WritingMode =
|
|
1666
|
-
'topToBottom';
|
|
1605
|
+
export type WritingMode = 'leftToRight' | 'topToBottom'
|
package/wasi-worker-browser.mjs
CHANGED
|
@@ -13,10 +13,9 @@ const handler = new MessageHandler({
|
|
|
13
13
|
// eslint-disable-next-line no-console
|
|
14
14
|
console.log.apply(console, arguments)
|
|
15
15
|
},
|
|
16
|
-
printErr: function() {
|
|
16
|
+
printErr: function () {
|
|
17
17
|
// eslint-disable-next-line no-console
|
|
18
18
|
console.error.apply(console, arguments)
|
|
19
|
-
|
|
20
19
|
},
|
|
21
20
|
})
|
|
22
21
|
return instantiateNapiModuleSync(wasmModule, {
|
|
@@ -37,7 +36,6 @@ const handler = new MessageHandler({
|
|
|
37
36
|
},
|
|
38
37
|
})
|
|
39
38
|
},
|
|
40
|
-
|
|
41
39
|
})
|
|
42
40
|
|
|
43
41
|
globalThis.onmessage = function (e) {
|
package/wasi-worker.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { createRequire } from
|
|
3
|
-
import { parse } from
|
|
4
|
-
import { WASI } from
|
|
5
|
-
import { parentPort, Worker } from
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
3
|
+
import { parse } from 'node:path'
|
|
4
|
+
import { WASI } from 'node:wasi'
|
|
5
|
+
import { parentPort, Worker, workerData } from 'node:worker_threads'
|
|
6
6
|
|
|
7
|
-
const require = createRequire(import.meta.url)
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
10
|
instantiateNapiModuleSync,
|
|
@@ -12,12 +12,12 @@ const {
|
|
|
12
12
|
getDefaultContext,
|
|
13
13
|
emnapiAsyncWorkPlugin,
|
|
14
14
|
emnapiTSFNPlugin,
|
|
15
|
-
} = require(
|
|
15
|
+
} = require('@napi-rs/wasm-runtime')
|
|
16
16
|
|
|
17
17
|
if (parentPort) {
|
|
18
|
-
parentPort.on(
|
|
19
|
-
globalThis.onmessage({ data })
|
|
20
|
-
})
|
|
18
|
+
parentPort.on('message', (data) => {
|
|
19
|
+
globalThis.onmessage({ data })
|
|
20
|
+
})
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
Object.assign(globalThis, {
|
|
@@ -25,18 +25,25 @@ Object.assign(globalThis, {
|
|
|
25
25
|
require,
|
|
26
26
|
Worker,
|
|
27
27
|
importScripts: function (f) {
|
|
28
|
-
|
|
28
|
+
// oxlint-disable-next-line no-eval -- WASI importScripts polyfill
|
|
29
|
+
;(0, eval)(fs.readFileSync(f, 'utf8') + '//# sourceURL=' + f)
|
|
29
30
|
},
|
|
30
31
|
postMessage: function (msg) {
|
|
31
32
|
if (parentPort) {
|
|
32
|
-
parentPort.postMessage(msg)
|
|
33
|
+
parentPort.postMessage(msg)
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
|
-
})
|
|
36
|
+
})
|
|
36
37
|
|
|
37
|
-
const emnapiContext = getDefaultContext()
|
|
38
|
+
const emnapiContext = getDefaultContext()
|
|
38
39
|
|
|
39
|
-
const
|
|
40
|
+
const __cwd = process.cwd()
|
|
41
|
+
const __rootDir =
|
|
42
|
+
(workerData && typeof workerData.rootDir === 'string' && workerData.rootDir) ||
|
|
43
|
+
parse(__cwd).root
|
|
44
|
+
const __hostRoot =
|
|
45
|
+
(workerData && typeof workerData.hostRoot === 'string' && workerData.hostRoot) ||
|
|
46
|
+
(process.platform === 'android' ? __cwd : __rootDir)
|
|
40
47
|
|
|
41
48
|
const handler = new MessageHandler({
|
|
42
49
|
onLoad({ wasmModule, wasmMemory }) {
|
|
@@ -44,9 +51,10 @@ const handler = new MessageHandler({
|
|
|
44
51
|
version: 'preview1',
|
|
45
52
|
env: process.env,
|
|
46
53
|
preopens: {
|
|
47
|
-
[__rootDir]:
|
|
54
|
+
[__rootDir]: __hostRoot,
|
|
55
|
+
[__hostRoot]: __hostRoot,
|
|
48
56
|
},
|
|
49
|
-
})
|
|
57
|
+
})
|
|
50
58
|
|
|
51
59
|
return instantiateNapiModuleSync(wasmModule, {
|
|
52
60
|
childThread: true,
|
|
@@ -62,13 +70,13 @@ const handler = new MessageHandler({
|
|
|
62
70
|
...importObject.env,
|
|
63
71
|
...importObject.napi,
|
|
64
72
|
...importObject.emnapi,
|
|
65
|
-
memory: wasmMemory
|
|
66
|
-
}
|
|
73
|
+
memory: wasmMemory,
|
|
74
|
+
}
|
|
67
75
|
},
|
|
68
|
-
})
|
|
76
|
+
})
|
|
69
77
|
},
|
|
70
|
-
})
|
|
78
|
+
})
|
|
71
79
|
|
|
72
80
|
globalThis.onmessage = function (e) {
|
|
73
|
-
handler.handle(e)
|
|
74
|
-
}
|
|
81
|
+
handler.handle(e)
|
|
82
|
+
}
|