resvg-napi 0.3.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.
@@ -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
  /**
@@ -712,18 +713,7 @@ export declare class TextSpan {
712
713
  }
713
714
 
714
715
  /** An alignment baseline property. */
715
- export type AlignmentBaseline = 'auto'|
716
- 'baseline'|
717
- 'beforeEdge'|
718
- 'textBeforeEdge'|
719
- 'middle'|
720
- 'central'|
721
- 'afterEdge'|
722
- 'textAfterEdge'|
723
- 'ideographic'|
724
- 'alphabetic'|
725
- 'hanging'|
726
- 'mathematical';
716
+ export type AlignmentBaseline = 'auto' | 'baseline' | 'beforeEdge' | 'textBeforeEdge' | 'middle' | 'central' | 'afterEdge' | 'textAfterEdge' | 'ideographic' | 'alphabetic' | 'hanging' | 'mathematical'
727
717
 
728
718
  /** `BaselineShift::Number`. */
729
719
  export interface BaselineShiftNumber {
@@ -758,22 +748,7 @@ export interface Blend {
758
748
  *
759
749
  * `mix-blend-mode` attribute in the SVG.
760
750
  */
761
- export type BlendMode = 'normal'|
762
- 'multiply'|
763
- 'screen'|
764
- 'overlay'|
765
- 'darken'|
766
- 'lighten'|
767
- 'colorDodge'|
768
- 'colorBurn'|
769
- 'hardLight'|
770
- 'softLight'|
771
- 'difference'|
772
- 'exclusion'|
773
- 'hue'|
774
- 'saturation'|
775
- 'color'|
776
- 'luminosity';
751
+ export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'colorDodge' | 'colorBurn' | 'hardLight' | 'softLight' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity'
777
752
 
778
753
  /** Plain view of a `Color`. */
779
754
  export interface Color {
@@ -783,18 +758,14 @@ export interface Color {
783
758
  }
784
759
 
785
760
  /** A color channel. */
786
- export type ColorChannel = 'r'|
787
- 'g'|
788
- 'b'|
789
- 'a';
761
+ export type ColorChannel = 'r' | 'g' | 'b' | 'a'
790
762
 
791
763
  /**
792
764
  * A color interpolation mode.
793
765
  *
794
766
  * The default is `ColorInterpolation::LinearRGB`.
795
767
  */
796
- export type ColorInterpolation = 'srgb'|
797
- 'linearRgb';
768
+ export type ColorInterpolation = 'srgb' | 'linearRgb'
798
769
 
799
770
  /** Plain view of a `ColorMatrix`. */
800
771
  export interface ColorMatrix {
@@ -911,18 +882,7 @@ export interface DistantLight {
911
882
  }
912
883
 
913
884
  /** A dominant baseline property. */
914
- export type DominantBaseline = 'auto'|
915
- 'useScript'|
916
- 'noChange'|
917
- 'resetSize'|
918
- 'ideographic'|
919
- 'alphabetic'|
920
- 'hanging'|
921
- 'mathematical'|
922
- 'central'|
923
- 'middle'|
924
- 'textAfterEdge'|
925
- 'textBeforeEdge';
885
+ export type DominantBaseline = 'auto' | 'useScript' | 'noChange' | 'resetSize' | 'ideographic' | 'alphabetic' | 'hanging' | 'mathematical' | 'central' | 'middle' | 'textAfterEdge' | 'textBeforeEdge'
926
886
 
927
887
  /** Plain view of a `DropShadow`. */
928
888
  export interface DropShadow {
@@ -936,9 +896,7 @@ export interface DropShadow {
936
896
  }
937
897
 
938
898
  /** An edges processing mode. */
939
- export type EdgeMode = 'none'|
940
- 'duplicate'|
941
- 'wrap';
899
+ export type EdgeMode = 'none' | 'duplicate' | 'wrap'
942
900
 
943
901
  /** Plain view of a `Fill`. */
944
902
  export interface Fill {
@@ -952,8 +910,7 @@ export interface Fill {
952
910
  *
953
911
  * `fill-rule` attribute in the SVG.
954
912
  */
955
- export type FillRule = 'nonZero'|
956
- 'evenOdd';
913
+ export type FillRule = 'nonZero' | 'evenOdd'
957
914
 
958
915
  /** Plain view of a `Flood`. */
959
916
  export interface Flood {
@@ -962,9 +919,7 @@ export interface Flood {
962
919
  }
963
920
 
964
921
  /** Allows italic or oblique faces to be selected. */
965
- export type FontFaceStyle = 'normal'|
966
- 'italic'|
967
- 'oblique';
922
+ export type FontFaceStyle = 'normal' | 'italic' | 'oblique'
968
923
 
969
924
  /**
970
925
  * A font optical sizing property.
@@ -972,24 +927,13 @@ export type FontFaceStyle = 'normal'|
972
927
  * Controls automatic adjustment of the `opsz` axis in variable fonts
973
928
  * based on font size. Matches CSS `font-optical-sizing`.
974
929
  */
975
- export type FontOpticalSizing = 'auto'|
976
- 'none';
930
+ export type FontOpticalSizing = 'auto' | 'none'
977
931
 
978
932
  /** A font stretch property. */
979
- export type FontStretch = 'ultraCondensed'|
980
- 'extraCondensed'|
981
- 'condensed'|
982
- 'semiCondensed'|
983
- 'normal'|
984
- 'semiExpanded'|
985
- 'expanded'|
986
- 'extraExpanded'|
987
- 'ultraExpanded';
933
+ export type FontStretch = 'ultraCondensed' | 'extraCondensed' | 'condensed' | 'semiCondensed' | 'normal' | 'semiExpanded' | 'expanded' | 'extraExpanded' | 'ultraExpanded'
988
934
 
989
935
  /** A font style property. */
990
- export type FontStyle = 'normal'|
991
- 'italic'|
992
- 'oblique';
936
+ export type FontStyle = 'normal' | 'italic' | 'oblique'
993
937
 
994
938
  /** Plain view of a `FontVariation`. */
995
939
  export interface FontVariation {
@@ -1015,12 +959,7 @@ export interface ImageKindSvg {
1015
959
  *
1016
960
  * `image-rendering` attribute in the SVG.
1017
961
  */
1018
- export type ImageRendering = 'optimizeQuality'|
1019
- 'optimizeSpeed'|
1020
- 'smooth'|
1021
- 'highQuality'|
1022
- 'crispEdges'|
1023
- 'pixelated';
962
+ export type ImageRendering = 'optimizeQuality' | 'optimizeSpeed' | 'smooth' | 'highQuality' | 'crispEdges' | 'pixelated'
1024
963
 
1025
964
  /** The payload-free variants of `Input`. */
1026
965
  export interface InputPlain {
@@ -1154,8 +1093,7 @@ export interface KindTurbulence {
1154
1093
  }
1155
1094
 
1156
1095
  /** A length adjust property. */
1157
- export type LengthAdjust = 'spacing'|
1158
- 'spacingAndGlyphs';
1096
+ export type LengthAdjust = 'spacing' | 'spacingAndGlyphs'
1159
1097
 
1160
1098
  /** `LightSource::DistantLight`. */
1161
1099
  export interface LightSourceDistantLight {
@@ -1183,23 +1121,17 @@ export interface LightSourceSpotLight {
1183
1121
  *
1184
1122
  * `stroke-linecap` attribute in the SVG.
1185
1123
  */
1186
- export type LineCap = 'butt'|
1187
- 'round'|
1188
- 'square';
1124
+ export type LineCap = 'butt' | 'round' | 'square'
1189
1125
 
1190
1126
  /**
1191
1127
  * A line join.
1192
1128
  *
1193
1129
  * `stroke-linejoin` attribute in the SVG.
1194
1130
  */
1195
- export type LineJoin = 'miter'|
1196
- 'miterClip'|
1197
- 'round'|
1198
- 'bevel';
1131
+ export type LineJoin = 'miter' | 'miterClip' | 'round' | 'bevel'
1199
1132
 
1200
1133
  /** A mask type. */
1201
- export type MaskType = 'luminance'|
1202
- 'alpha';
1134
+ export type MaskType = 'luminance' | 'alpha'
1203
1135
 
1204
1136
  /**
1205
1137
  * An affine transform. Field names and order are tiny-skia's.
@@ -1234,14 +1166,10 @@ export interface Morphology {
1234
1166
  }
1235
1167
 
1236
1168
  /** A morphology operation. */
1237
- export type MorphologyOperator = 'erode'|
1238
- 'dilate';
1169
+ export type MorphologyOperator = 'erode' | 'dilate'
1239
1170
 
1240
1171
  /** Which flavour of node this is. */
1241
- export type NodeKind = 'group'|
1242
- 'path'|
1243
- 'image'|
1244
- 'text';
1172
+ export type NodeKind = 'group' | 'path' | 'image' | 'text'
1245
1173
 
1246
1174
  /** Plain view of a `Offset`. */
1247
1175
  export interface Offset {
@@ -1272,8 +1200,7 @@ export interface PaintLinearGradient {
1272
1200
  *
1273
1201
  * [`paint-order`]: https://www.w3.org/TR/SVG2/painting.html#PaintOrder
1274
1202
  */
1275
- export type PaintOrder = 'fillAndStroke'|
1276
- 'strokeAndFill';
1203
+ export type PaintOrder = 'fillAndStroke' | 'strokeAndFill'
1277
1204
 
1278
1205
  /** `Paint::Pattern`. */
1279
1206
  export interface PaintPattern {
@@ -1479,9 +1406,7 @@ export declare function setLogLevel(level: 'off' | 'error' | 'warn' | 'info' | '
1479
1406
  *
1480
1407
  * `shape-rendering` attribute in the SVG.
1481
1408
  */
1482
- export type ShapeRendering = 'optimizeSpeed'|
1483
- 'crispEdges'|
1484
- 'geometricPrecision';
1409
+ export type ShapeRendering = 'optimizeSpeed' | 'crispEdges' | 'geometricPrecision'
1485
1410
 
1486
1411
  /** Plain view of a `SpecularLighting`. */
1487
1412
  export interface SpecularLighting {
@@ -1510,9 +1435,7 @@ export interface SpotLight {
1510
1435
  *
1511
1436
  * `spreadMethod` attribute in the SVG.
1512
1437
  */
1513
- export type SpreadMethod = 'pad'|
1514
- 'reflect'|
1515
- 'repeat';
1438
+ export type SpreadMethod = 'pad' | 'reflect' | 'repeat'
1516
1439
 
1517
1440
  /** Plain view of a `Stop`. */
1518
1441
  export interface Stop {
@@ -1537,9 +1460,7 @@ export interface Stroke {
1537
1460
  export declare function takeLogs(): Array<string>
1538
1461
 
1539
1462
  /** A text chunk anchor property. */
1540
- export type TextAnchor = 'start'|
1541
- 'middle'|
1542
- 'end';
1463
+ export type TextAnchor = 'start' | 'middle' | 'end'
1543
1464
 
1544
1465
  /** Plain view of a `TextDecoration`. */
1545
1466
  export interface TextDecoration {
@@ -1572,9 +1493,7 @@ export interface TextFlowPlain {
1572
1493
  *
1573
1494
  * `text-rendering` attribute in the SVG.
1574
1495
  */
1575
- export type TextRendering = 'optimizeSpeed'|
1576
- 'optimizeLegibility'|
1577
- 'geometricPrecision';
1496
+ export type TextRendering = 'optimizeSpeed' | 'optimizeLegibility' | 'geometricPrecision'
1578
1497
 
1579
1498
  /** Plain view of a `Tile`. */
1580
1499
  export interface Tile {
@@ -1629,8 +1548,7 @@ export interface Turbulence {
1629
1548
  }
1630
1549
 
1631
1550
  /** A turbulence kind for the `feTurbulence` filter. */
1632
- export type TurbulenceKind = 'fractalNoise'|
1633
- 'turbulence';
1551
+ export type TurbulenceKind = 'fractalNoise' | 'turbulence'
1634
1552
 
1635
1553
  /**
1636
1554
  * Mirror of `usvg::WriteOptions`, for `Resvg.toString()`. Every field is
@@ -1684,5 +1602,4 @@ export interface WriteOptions {
1684
1602
  }
1685
1603
 
1686
1604
  /** A writing mode. */
1687
- export type WritingMode = 'leftToRight'|
1688
- 'topToBottom';
1605
+ export type WritingMode = 'leftToRight' | 'topToBottom'
@@ -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 "node:fs";
2
- import { createRequire } from "node:module";
3
- import { parse } from "node:path";
4
- import { WASI } from "node:wasi";
5
- import { parentPort, Worker } from "node:worker_threads";
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("@napi-rs/wasm-runtime");
15
+ } = require('@napi-rs/wasm-runtime')
16
16
 
17
17
  if (parentPort) {
18
- parentPort.on("message", (data) => {
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
- ;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
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 __rootDir = parse(process.cwd()).root;
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]: __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
+ }