Fix minor issues in the Typescript declaration
Change-Id: I90b4bc906377f6816677b4418227828f1b5ef5f4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549936
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/modules/canvaskit/CHANGELOG.md b/modules/canvaskit/CHANGELOG.md
index fee938c..c85e3d0 100644
--- a/modules/canvaskit/CHANGELOG.md
+++ b/modules/canvaskit/CHANGELOG.md
@@ -6,6 +6,9 @@
## [Unreleased]
+### Fixed
+ - Minor bug fixes in the TypeScript type declaration.
+
## [0.34.1] - 2022-06-02
### Added
diff --git a/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts b/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts
index 525b089..c7e2afa 100644
--- a/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts
+++ b/modules/canvaskit/npm_build/types/canvaskit-wasm-tests.ts
@@ -1,7 +1,6 @@
// This file is type-checked by the Typescript definitions. It is not actually executed.
// Test it by running `npm run dtslint` in the parent directory.
-import {
- CanvasKitInit,
+import CanvasKitInit, {
AnimatedImage,
Canvas,
CanvasKit,
@@ -278,7 +277,7 @@
const s2 = mm.makeShaderOptions(CK.TileMode.Decal, CK.TileMode.Repeat, // $ExpectType Shader
CK.FilterMode.Nearest, CK.MipmapMode.Linear,
CK.Matrix.identity());
- const pixels = img.readPixels(85, 1000, { // $ExpectType Float32Array | Uint8Array | null
+ const pixels = img.readPixels(85, 1000, { // $ExpectType Uint8Array | Float32Array | null
width: 79,
height: 205,
colorType: CK.ColorType.RGBA_8888,
@@ -512,8 +511,8 @@
const g = p.getMaxIntrinsicWidth(); // $ExpectType number
const h = p.getMaxWidth(); // $ExpectType number
const i = p.getMinIntrinsicWidth(); // $ExpectType number
- const j = p.getRectsForPlaceholders(); // $ExpectType Float32Array
- const k = p.getRectsForRange(2, 10, CK.RectHeightStyle.Max, // $ExpectType Float32Array
+ const j = p.getRectsForPlaceholders(); // $ExpectType Float32Array[]
+ const k = p.getRectsForRange(2, 10, CK.RectHeightStyle.Max, // $ExpectType Float32Array[]
CK.RectWidthStyle.Tight);
const l = p.getWordBoundary(10); // $ExpectType URange
p.layout(300);
diff --git a/modules/canvaskit/npm_build/types/index.d.ts b/modules/canvaskit/npm_build/types/index.d.ts
index f305079..33bb9a3 100644
--- a/modules/canvaskit/npm_build/types/index.d.ts
+++ b/modules/canvaskit/npm_build/types/index.d.ts
@@ -1,5 +1,5 @@
-// Minimum TypeScript Version: 3.7
-export function CanvasKitInit(opts: CanvasKitInitOptions): Promise<CanvasKit>;
+// Minimum TypeScript Version: 4.1
+export default function CanvasKitInit(opts: CanvasKitInitOptions): Promise<CanvasKit>;
export interface CanvasKitInitOptions {
/**
@@ -847,7 +847,7 @@
getMaxIntrinsicWidth(): number;
getMaxWidth(): number;
getMinIntrinsicWidth(): number;
- getRectsForPlaceholders(): FlattenedRectangleArray;
+ getRectsForPlaceholders(): Rect[];
/**
* Returns bounding boxes that enclose all text in the range of glpyh indexes [start, end).
@@ -857,7 +857,7 @@
* @param wStyle
*/
getRectsForRange(start: number, end: number, hStyle: RectHeightStyle,
- wStyle: RectWidthStyle): FlattenedRectangleArray;
+ wStyle: RectWidthStyle): Rect[];
/**
* Finds the first and last glyphs that define a word containing the glyph at index offset.
@@ -1018,6 +1018,7 @@
rows: number;
/** The index into the uniforms array that this uniform begins. */
slot: number;
+ isInteger: boolean;
}
/**
@@ -1992,7 +1993,7 @@
* Sets the current color filter, replacing the existing one if there was one.
* @param filter
*/
- setColorFilter(filter: ColorFilter): void;
+ setColorFilter(filter: ColorFilter | null): void;
/**
* Sets the color used when stroking and filling. The color values are interpreted as being in
@@ -2006,25 +2007,25 @@
* Sets the current image filter, replacing the existing one if there was one.
* @param filter
*/
- setImageFilter(filter: ImageFilter): void;
+ setImageFilter(filter: ImageFilter | null): void;
/**
* Sets the current mask filter, replacing the existing one if there was one.
* @param filter
*/
- setMaskFilter(filter: MaskFilter): void;
+ setMaskFilter(filter: MaskFilter | null): void;
/**
* Sets the current path effect, replacing the existing one if there was one.
* @param effect
*/
- setPathEffect(effect: PathEffect): void;
+ setPathEffect(effect: PathEffect | null): void;
/**
* Sets the current shader, replacing the existing one if there was one.
* @param shader
*/
- setShader(shader: Shader): void;
+ setShader(shader: Shader | null): void;
/**
* Sets the geometry drawn at the beginning and end of strokes.