@napi-rs/canvas 0.1.88 → 0.1.90

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.
Files changed (2) hide show
  1. package/index.d.ts +43 -4
  2. package/package.json +13 -13
package/index.d.ts CHANGED
@@ -584,6 +584,25 @@ export interface SKRSContext2D extends CanvasRenderingContext2D {
584
584
  dw: number,
585
585
  dh: number,
586
586
  ): void
587
+ /**
588
+ * Draw another canvas, preserving vector graphics when possible.
589
+ * When the source canvas has recorded operations, this method preserves the
590
+ * SkPicture representation without rasterization, which can be faster than
591
+ * drawImage. Falls back to bitmap rendering if no picture is available.
592
+ */
593
+ drawCanvas(canvas: Canvas, dx: number, dy: number): void
594
+ drawCanvas(canvas: Canvas, dx: number, dy: number, dWidth: number, dHeight: number): void
595
+ drawCanvas(
596
+ canvas: Canvas,
597
+ sx: number,
598
+ sy: number,
599
+ sWidth: number,
600
+ sHeight: number,
601
+ dx: number,
602
+ dy: number,
603
+ dWidth: number,
604
+ dHeight: number,
605
+ ): void
587
606
  createPattern(
588
607
  image: Image | ImageData | Canvas | SvgCanvas,
589
608
  repeat: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' | null,
@@ -830,6 +849,7 @@ export function createCanvas(width: number, height: number, svgExportFlag: SvgEx
830
849
  export declare class FontKey {
831
850
  // make it a unique type
832
851
  private readonly key: symbol
852
+ readonly typefaceId: number
833
853
  }
834
854
 
835
855
  export interface FontVariationAxis {
@@ -849,13 +869,32 @@ export interface FontVariationAxis {
849
869
 
850
870
  interface IGlobalFonts {
851
871
  readonly families: { family: string; styles: { weight: number; width: string; style: string }[] }[]
852
- // return true if succeeded
872
+ // return FontKey if succeeded, null if failed
853
873
  register(font: Buffer, nameAlias?: string): FontKey | null
854
- // absolute path
855
- registerFromPath(path: string, nameAlias?: string): boolean
874
+ // absolute path - returns FontKey if succeeded, null if failed
875
+ registerFromPath(path: string, nameAlias?: string): FontKey | null
856
876
  has(name: string): boolean
857
877
  loadFontsFromDir(path: string): number
858
- remove(key: FontKey): void
878
+ /**
879
+ * Set an alias for a font family.
880
+ * @param fontName The original font family name
881
+ * @param alias The alias name to set
882
+ * @returns true if the alias was set successfully, false if the font family doesn't exist
883
+ */
884
+ setAlias(fontName: string, alias: string): boolean
885
+ remove(key: FontKey): boolean
886
+ /**
887
+ * Remove multiple fonts by their keys in a single operation.
888
+ * More efficient than calling remove() multiple times as it triggers only one rebuild.
889
+ * @param fontKeys Array of FontKey objects to remove
890
+ * @returns Number of fonts successfully removed
891
+ */
892
+ removeBatch(fontKeys: FontKey[]): number
893
+ /**
894
+ * Remove ALL registered fonts.
895
+ * @returns Number of fonts removed
896
+ */
897
+ removeAll(): number
859
898
  /**
860
899
  * Get variation axes for a specific font instance
861
900
  * @param familyName The font family name
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/canvas",
3
- "version": "0.1.88",
3
+ "version": "0.1.90",
4
4
  "description": "Canvas for Node.js with skia backend",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -93,7 +93,7 @@
93
93
  "conventional-changelog-cli": "^5.0.0",
94
94
  "core-js": "^3.47.0",
95
95
  "echarts": "^6.0.0",
96
- "electron": "^39.2.7",
96
+ "electron": "^40.0.0",
97
97
  "husky": "^9.1.7",
98
98
  "lint-staged": "^16.2.7",
99
99
  "lodash": "^4.17.21",
@@ -150,16 +150,16 @@
150
150
  },
151
151
  "packageManager": "yarn@4.12.0",
152
152
  "optionalDependencies": {
153
- "@napi-rs/canvas-linux-x64-gnu": "0.1.88",
154
- "@napi-rs/canvas-darwin-x64": "0.1.88",
155
- "@napi-rs/canvas-win32-x64-msvc": "0.1.88",
156
- "@napi-rs/canvas-win32-arm64-msvc": "0.1.88",
157
- "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.88",
158
- "@napi-rs/canvas-linux-x64-musl": "0.1.88",
159
- "@napi-rs/canvas-linux-arm64-gnu": "0.1.88",
160
- "@napi-rs/canvas-linux-arm64-musl": "0.1.88",
161
- "@napi-rs/canvas-darwin-arm64": "0.1.88",
162
- "@napi-rs/canvas-android-arm64": "0.1.88",
163
- "@napi-rs/canvas-linux-riscv64-gnu": "0.1.88"
153
+ "@napi-rs/canvas-linux-x64-gnu": "0.1.90",
154
+ "@napi-rs/canvas-darwin-x64": "0.1.90",
155
+ "@napi-rs/canvas-win32-x64-msvc": "0.1.90",
156
+ "@napi-rs/canvas-win32-arm64-msvc": "0.1.90",
157
+ "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.90",
158
+ "@napi-rs/canvas-linux-x64-musl": "0.1.90",
159
+ "@napi-rs/canvas-linux-arm64-gnu": "0.1.90",
160
+ "@napi-rs/canvas-linux-arm64-musl": "0.1.90",
161
+ "@napi-rs/canvas-darwin-arm64": "0.1.90",
162
+ "@napi-rs/canvas-android-arm64": "0.1.90",
163
+ "@napi-rs/canvas-linux-riscv64-gnu": "0.1.90"
164
164
  }
165
165
  }