Skip to content

Commit

Permalink
refactor!: re-export async loadImage from @napi-rs/canvas (#516)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: When using @napi/rs loader the `loadImage` function is now an async function returning a `Promise`
  • Loading branch information
imranbarbhuiya authored Sep 1, 2022
1 parent efad17e commit c5ad068
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main.ts.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { \
GlobalFonts, \
Image as NativeImage, \
Path2D, \
loadImage, \
type AvifConfig, \
type SKRSContext2D as NativeCanvasRenderingContext2D \
} from '@napi-rs/canvas';
Expand Down Expand Up @@ -2358,7 +2359,7 @@ interface ResolvedCircularCoordinates {
}

// IF(CAIRO): export { loadImage, loadFont, NativeImage as Image };
// IF(NAPI_RS): export { Path2D, GlobalFonts, NativeImage as Image };
// IF(NAPI_RS): export { loadImage, Path2D, GlobalFonts, NativeImage as Image };
// IF(SKIA): export { Path2D, FontLibrary, NativeImage as Image, loadImage };

// IF(BROWSER): \
Expand All @@ -2384,12 +2385,6 @@ export function loadImage(src: string, options?: Partial<HTMLImageElement>): Pro
}

// IF(!BROWSER): export const resolveImage = deprecate(loadImage, 'resolveImage() is deprecated. Use loadImage() instead.');
// IF(NAPI_RS): \
export function loadImage(data: Buffer) { \
const image = new NativeImage(); \
image.src = data; \
return image; \
}

// IF(NAPI_RS): \
export function loadFont(font: Buffer, alias?: string): boolean; \
Expand Down

0 comments on commit c5ad068

Please sign in to comment.