Skip to content

Commit

Permalink
fix: TS Type Definition
Browse files Browse the repository at this point in the history
There is no `fontsBuffers` option in `index.d.ts`, which is currently specific to Wasm.

And, let's keep the original manually corrected type.
  • Loading branch information
yisibl committed Aug 5, 2023
1 parent f056379 commit 39c8125
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 30 deletions.
34 changes: 12 additions & 22 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
/// <reference types="node" />

export type ResvgRenderOptions = {
font?: SystemFontsOptions | CustomFontsOptions
font?: {
loadSystemFonts?: boolean // Default: true. if set to false, it will be faster.
fontFiles?: string[] // A list of local font file paths to load.
fontDirs?: string[] // A list of local font directories to load.
defaultFontSize?: number // Default: 12
defaultFontFamily?: string
serifFamily?: string
sansSerifFamily?: string
cursiveFamily?: string
fantasyFamily?: string
monospaceFamily?: string
}
dpi?: number
languages?: string[]
shapeRendering?:
Expand Down Expand Up @@ -29,27 +40,6 @@ export type ResvgRenderOptions = {
}
logLevel?: 'off' | 'error' | 'warn' | 'info' | 'debug' | 'trace'
}

export type FontOptions = {
defaultFontSize?: number // Default: 12
defaultFontFamily?: string
serifFamily?: string
sansSerifFamily?: string
cursiveFamily?: string
fantasyFamily?: string
monospaceFamily?: string
}

export type CustomFontsOptions = {
fontsBuffers: Uint8Array[] // A list of raw font files to load.
} & FontOptions

export type SystemFontsOptions = {
loadSystemFonts?: boolean // Default: true. if set to false, it will be faster.
fontFiles?: string[] // A list of local font file paths to load.
fontDirs?: string[] // A list of local font directories to load.
} & FontOptions

export class BBox {
x: number
y: number
Expand Down
3 changes: 1 addition & 2 deletions wasm-binding.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import init, { Resvg as _Resvg, InitInput } from './wasm/dist'

import { CustomFontsOptions, ResvgRenderOptions, SystemFontsOptions } from './index'
import { CustomFontsOptions, ResvgRenderOptions, SystemFontsOptions } from './wasm/index'

let initialized = false

Expand Down
8 changes: 2 additions & 6 deletions wasm/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Generated by dts-bundle-generator v8.0.1
// Generated by dts-bundle-generator v6.13.0

declare class BBox {
free(): void;
Expand Down Expand Up @@ -68,7 +67,6 @@ export type ResvgRenderOptions = {
right?: number;
bottom?: number;
};
logLevel?: "off" | "error" | "warn" | "info" | "debug" | "trace";
};
export type FontOptions = {
defaultFontSize?: number; // Default: 12
Expand All @@ -94,18 +92,16 @@ export type SystemFontsOptions = {
*/
export declare const initWasm: (module_or_path: Promise<InitInput> | InitInput) => Promise<void>;
export declare const Resvg: {
new (svg: Uint8Array | string, options?: ResvgRenderOptions): {
new (svg: Uint8Array | string, options?: ResvgRenderOptions | undefined): {
free(): void;
render(): RenderedImage;
toString(): string;
innerBBox(): BBox | undefined;
getBBox(): BBox | undefined;
cropByBBox(bbox: BBox): void;
imagesToResolve(): any[];
imagesToResolve(): Array<string>;
resolveImage(href: string, buffer: Uint8Array): void;
readonly height: number;
readonly width: number;
};
};

export {};
Binary file modified wasm/index_bg.wasm
Binary file not shown.

0 comments on commit 39c8125

Please sign in to comment.