Skip to content

Commit 17653b4

Browse files
wcandillonchrfalch
authored andcommitted
Rename Data to SkData
1 parent 64ae5f7 commit 17653b4

File tree

11 files changed

+27
-28
lines changed

11 files changed

+27
-28
lines changed

package/src/skia/core/Data.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { useRef, useEffect, useState } from "react";
33
import { Image } from "react-native";
44

55
import { Skia } from "../Skia";
6-
import type { Data, DataSource } from "../types";
6+
import type { SkData, DataSource } from "../types";
77

88
export const useDataCollection = <T>(
99
sources: DataSource[],
10-
factory: (data: Data[]) => T,
10+
factory: (data: SkData[]) => T,
1111
deps: DependencyList = []
1212
) => {
1313
const [data, setData] = useState<T | null>(null);
@@ -34,7 +34,7 @@ export const useDataCollection = <T>(
3434

3535
export const useRawData = <T>(
3636
source: DataSource | null | undefined,
37-
factory: (data: Data) => T,
37+
factory: (data: SkData) => T,
3838
onError?: (err: Error) => void
3939
) => {
4040
const [data, setData] = useState<T | null>(null);
@@ -44,7 +44,7 @@ export const useRawData = <T>(
4444
if (prevSourceRef.current !== source) {
4545
prevSourceRef.current = source;
4646
if (source !== null && source !== undefined) {
47-
const factoryWrapper = (data2: Data) => {
47+
const factoryWrapper = (data2: SkData) => {
4848
const factoryResult = factory(data2);
4949
if (factoryResult === null) {
5050
onError && onError(new Error("Could not load data"));
@@ -70,7 +70,7 @@ export const useRawData = <T>(
7070
return data;
7171
};
7272

73-
const identity = (data: Data) => data;
73+
const identity = (data: SkData) => data;
7474

7575
export const useData = (
7676
source: DataSource | null | undefined,

package/src/skia/types/Data/Data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { SkJSIInstance } from "../JsiInstance";
22

3-
export type Data = SkJSIInstance<"Data">;
3+
export type SkData = SkJSIInstance<"Data">;
44

55
export type DataSource = ReturnType<typeof require> | string | Uint8Array;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import type { Data } from "./Data";
1+
import type { SkData } from "./Data";
22

33
export interface DataFactory {
44
/**
55
* Creates a new Data object from an Uri, either locally or remotely.
66
* @param uri Uri to a valid resource
77
*/
8-
fromURI(uri: string): Promise<Data>;
8+
fromURI(uri: string): Promise<SkData>;
99
/**
1010
* Creates a new Data object from a byte array.
1111
* @param bytes An array of bytes representing the data
1212
*/
13-
fromBytes(bytes: Uint8Array): Data;
13+
fromBytes(bytes: Uint8Array): SkData;
1414
/**
1515
* Creates a new Data object from a base64 encoded string.
1616
* @param base64 A Base64 encoded string representing the data
1717
*/
18-
fromBase64(base64: string): Data;
18+
fromBase64(base64: string): SkData;
1919
}

package/src/skia/types/Image/ImageFactory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable camelcase */
2-
import type { Data } from "../Data";
2+
import type { SkData } from "../Data";
33

44
import type { SkImage } from "./Image";
55

@@ -62,7 +62,7 @@ export interface ImageFactory {
6262
* @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded
6363
* image, nullptr is returned.
6464
*/
65-
MakeImageFromEncoded: (encoded: Data) => SkImage | null;
65+
MakeImageFromEncoded: (encoded: SkData) => SkImage | null;
6666

6767
/**
6868
* Returns an image with the given pixel data and format.
@@ -74,5 +74,5 @@ export interface ImageFactory {
7474
* @param data - bytes representing the pixel data.
7575
* @param bytesPerRow
7676
*/
77-
MakeImage(info: ImageInfo, data: Data, bytesPerRow: number): SkImage | null;
77+
MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;
7878
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { Data } from "../Data";
1+
import type { SkData } from "../Data";
22

33
import type { SkSVG } from "./SVG";
44

55
export interface SVGFactory {
6-
MakeFromData(data: Data): SkSVG | null;
6+
MakeFromData(data: SkData): SkSVG | null;
77
MakeFromString(str: string): SkSVG | null;
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Data } from "../Data";
1+
import type { SkData } from "../Data";
22

33
import type { SkTypeface } from "./Typeface";
44

55
export interface TypefaceFactory {
6-
MakeFreeTypeFaceFromData(data: Data): SkTypeface | null;
6+
MakeFreeTypeFaceFromData(data: SkData): SkTypeface | null;
77
}

package/src/skia/web/api/JsiSkData.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { CanvasKit } from "canvaskit-wasm";
22

3-
// TODO: rename Data to SkData
4-
import type { Data as SkData } from "../../types";
3+
import type { SkData } from "../../types";
54

65
import { HostObject } from "./Host";
76

package/src/skia/web/api/JsiSkDataFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CanvasKit } from "canvaskit-wasm";
22

3-
import type { Data } from "../../types";
3+
import type { SkData } from "../../types";
44
import type { DataFactory } from "../../types/Data/DataFactory";
55

66
import { Host, NotImplementedOnRNWeb } from "./Host";
@@ -27,7 +27,7 @@ export class JsiSkDataFactory extends Host implements DataFactory {
2727
* Creates a new Data object from a base64 encoded string.
2828
* @param base64 A Base64 encoded string representing the data
2929
*/
30-
fromBase64(_base64: string): Data {
30+
fromBase64(_base64: string): SkData {
3131
throw new NotImplementedOnRNWeb();
3232
}
3333
}

package/src/skia/web/api/JsiSkImageFactory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CanvasKit } from "canvaskit-wasm";
22

3-
import type { Data, ImageInfo } from "../../types";
3+
import type { SkData, ImageInfo } from "../../types";
44
import type { ImageFactory } from "../../types/Image/ImageFactory";
55

66
import { Host, toValue, ckEnum } from "./Host";
@@ -11,15 +11,15 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
1111
super(CanvasKit);
1212
}
1313

14-
MakeImageFromEncoded(encoded: Data) {
14+
MakeImageFromEncoded(encoded: SkData) {
1515
const image = this.CanvasKit.MakeImageFromEncoded(toValue(encoded));
1616
if (image === null) {
1717
return null;
1818
}
1919
return new JsiSkImage(this.CanvasKit, image);
2020
}
2121

22-
MakeImage(info: ImageInfo, data: Data, bytesPerRow: number) {
22+
MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number) {
2323
// see toSkImageInfo() from canvaskit
2424
const image = this.CanvasKit.MakeImage(
2525
{

package/src/skia/web/api/JsiSkSVGFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CanvasKit } from "canvaskit-wasm";
22

3-
import type { Data, SkSVG } from "../../types";
3+
import type { SkData, SkSVG } from "../../types";
44
import type { SVGFactory } from "../../types/SVG/SVGFactory";
55

66
import { Host, NotImplementedOnRNWeb } from "./Host";
@@ -10,7 +10,7 @@ export class JsiSkSVGFactory extends Host implements SVGFactory {
1010
super(CanvasKit);
1111
}
1212

13-
MakeFromData(_data: Data): SkSVG | null {
13+
MakeFromData(_data: SkData): SkSVG | null {
1414
throw new NotImplementedOnRNWeb();
1515
}
1616

0 commit comments

Comments
 (0)