@shopify/react-native-skia 2.2.9 → 2.2.10
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.
- package/lib/commonjs/renderer/Canvas.d.ts +1 -0
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +3 -3
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +10 -6
- package/lib/commonjs/views/SkiaPictureView.web.js +253 -20
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +1 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +1 -0
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +3 -3
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
- package/lib/module/views/SkiaPictureView.web.d.ts +10 -6
- package/lib/module/views/SkiaPictureView.web.js +251 -18
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/views/types.d.ts +1 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +11 -1
- package/lib/typescript/lib/commonjs/views/SkiaPictureView.web.d.ts +1 -6
- package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
- package/lib/typescript/lib/module/views/SkiaPictureView.web.d.ts +2 -6
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -0
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +3 -3
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +10 -6
- package/lib/typescript/src/views/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/renderer/Canvas.tsx +1 -0
- package/src/renderer/__tests__/e2e/ParagraphMethods.spec.tsx +115 -110
- package/src/specs/NativeSkiaModule.web.ts +4 -4
- package/src/views/SkiaPictureView.web.tsx +312 -18
- package/src/views/types.ts +4 -0
- package/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -40
- package/lib/commonjs/views/SkiaBaseWebView.js +0 -143
- package/lib/commonjs/views/SkiaBaseWebView.js.map +0 -1
- package/lib/module/views/SkiaBaseWebView.d.ts +0 -40
- package/lib/module/views/SkiaBaseWebView.js +0 -136
- package/lib/module/views/SkiaBaseWebView.js.map +0 -1
- package/lib/typescript/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -39
- package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +0 -36
- package/lib/typescript/src/views/SkiaBaseWebView.d.ts +0 -40
- package/src/views/SkiaBaseWebView.tsx +0 -140
@@ -23,5 +23,6 @@ export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
|
|
23
23
|
onSize?: SharedValue<SkSize>;
|
24
24
|
colorSpace?: "p3" | "srgb";
|
25
25
|
ref?: React.Ref<CanvasRef>;
|
26
|
+
__destroyWebGLContextAfterRender?: boolean;
|
26
27
|
}
|
27
28
|
export declare const Canvas: ({ debug, opaque, children, onSize, colorSpace, ref, onLayout, ...viewProps }: CanvasProps) => React.JSX.Element;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","_global","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useCanvasSize","userRef","ourRef","ref","size","setSize","useState","width","height","useLayoutEffect","current","measure","_x","_y","isFabric","Boolean","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","useMemo","SkiaViewNativeId","root","SkiaSGRoot","Skia","render","useEffect","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(\n () => new SkiaSGRoot(Skia, nativeId, onSize),\n [nativeId, onSize]\n );\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AAC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AAC,EAAE,EAAE,CAAC;EACN,OAAO;IAAEL,GAAG;IAAEC;EAAK,CAAC;AACtB,CAAC;;AAED;AAAAL,OAAA,CAAAC,aAAA,GAAAA,aAAA;AACO,MAAMc,QAAQ,GAAAf,OAAA,CAAAe,QAAA,GAAGC,OAAO,EAAA7C,OAAA,GAAE8C,MAAM,cAAA9C,OAAA,uBAAPA,OAAA,CAAiB+C,qBAAqB,CAAC;
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","_global","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useCanvasSize","userRef","ourRef","ref","size","setSize","useState","width","height","useLayoutEffect","current","measure","_x","_y","isFabric","Boolean","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","useMemo","SkiaViewNativeId","root","SkiaSGRoot","Skia","render","useEffect","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(\n () => new SkiaSGRoot(Skia, nativeId, onSize),\n [nativeId, onSize]\n );\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAgBA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,IAAAM,OAAA;AAAA,SAAAH,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAA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;MAC7B,CAAAA,iBAAA,GAAArB,OAAO,CAAClB,OAAO,cAAAuC,iBAAA,eAAfA,iBAAA,CAAiBD,eAAe,CAACF,QAAQ,CAAC;IAC5C;EACF,CAAC,CACL,CAAC;EAED,oBACEpF,MAAA,CAAAW,OAAA,CAAA6E,aAAA,CAACpF,+BAAA,CAAAO,OAA8B,EAAAkB,QAAA;IAC7BY,GAAG,EAAEyB,OAAQ;IACbuB,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGvB,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA;EAAW,GACnBE,SAAS,CACd,CAAC;AAEN,CAAC;AAAC1B,OAAA,CAAAmB,MAAA,GAAAA,MAAA","ignoreList":[]}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { SkPicture } from "../skia/types";
|
2
2
|
import type { ISkiaViewApi } from "../views/types";
|
3
|
-
import type {
|
3
|
+
import type { SkiaPictureViewHandle } from "../views/SkiaPictureView.web";
|
4
4
|
export type ISkiaViewApiWeb = ISkiaViewApi & {
|
5
|
-
views: Record<string,
|
5
|
+
views: Record<string, SkiaPictureViewHandle>;
|
6
6
|
deferedPictures: Record<string, SkPicture>;
|
7
|
-
registerView(nativeId: string, view:
|
7
|
+
registerView(nativeId: string, view: SkiaPictureViewHandle): void;
|
8
8
|
};
|
9
9
|
declare const _default: {};
|
10
10
|
export default _default;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["global","SkiaViewApi","views","deferedPictures","web","registerView","nativeId","view","setPicture","setJsiProperty","name","value","size","getSize","width","height","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result","Error","_default","exports","default"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type { SkPicture, SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type {
|
1
|
+
{"version":3,"names":["global","SkiaViewApi","views","deferedPictures","web","registerView","nativeId","view","setPicture","setJsiProperty","name","value","size","getSize","width","height","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result","Error","_default","exports","default"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type { SkPicture, SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type { SkiaPictureViewHandle } from \"../views/SkiaPictureView.web\";\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaPictureViewHandle>;\n deferedPictures: Record<string, SkPicture>;\n registerView(nativeId: string, view: SkiaPictureViewHandle): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n web: true,\n registerView(nativeId: string, view: SkiaPictureViewHandle) {\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId]) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n }\n this.views[nativeId] = view;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n if (!this.views[`${nativeId}`]) {\n this.deferedPictures[`${nativeId}`] = value;\n } else {\n this.views[`${nativeId}`].setPicture(value);\n }\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n this.views[`${nativeId}`].redraw();\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n return this.views[`${nativeId}`].makeImageSnapshot(rect);\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const result = this.views[`${nativeId}`].makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n\n// eslint-disable-next-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,CAACZ,QAAgB,EAAEa,IAAa,EAAE;IACjD,OAAO,IAAI,CAACjB,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACY,iBAAiB,CAACC,IAAI,CAAC;EAC1D,CAAC;EACDC,sBAAsBA,CAACd,QAAgB,EAAEa,IAAa,EAAE;IACtD,OAAO,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAMC,MAAM,GAAG,IAAI,CAACtB,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACY,iBAAiB,CAACC,IAAI,CAAC;MAChE,IAAIK,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIE,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;;AAEpB;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe,CAAC,CAAC","ignoreList":[]}
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import type { ViewProps } from "react-native";
|
2
|
-
import { SkiaPictureView } from "../views/SkiaPictureView.web";
|
3
2
|
export interface NativeProps extends ViewProps {
|
4
3
|
debug?: boolean;
|
5
4
|
opaque?: boolean;
|
6
5
|
nativeID: string;
|
7
6
|
}
|
8
|
-
declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").
|
7
|
+
declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("..").SkiaPictureViewNativeProps & import("react").RefAttributes<import("../views/SkiaPictureView.web").SkiaPictureViewHandle>>;
|
9
8
|
export default SkiaPictureViewNativeComponent;
|
@@ -1,9 +1,13 @@
|
|
1
|
-
import
|
1
|
+
import React from "react";
|
2
|
+
import type { SkRect, SkPicture, SkImage } from "../skia/types";
|
2
3
|
import type { SkiaPictureViewNativeProps } from "./types";
|
3
|
-
|
4
|
-
export declare class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {
|
5
|
-
private picture;
|
6
|
-
constructor(props: SkiaPictureViewNativeProps);
|
4
|
+
export interface SkiaPictureViewHandle {
|
7
5
|
setPicture(picture: SkPicture): void;
|
8
|
-
|
6
|
+
getSize(): {
|
7
|
+
width: number;
|
8
|
+
height: number;
|
9
|
+
};
|
10
|
+
redraw(): void;
|
11
|
+
makeImageSnapshot(rect?: SkRect): SkImage | null;
|
9
12
|
}
|
13
|
+
export declare const SkiaPictureView: React.ForwardRefExoticComponent<SkiaPictureViewNativeProps & React.RefAttributes<SkiaPictureViewHandle>>;
|
@@ -4,33 +4,266 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.SkiaPictureView = void 0;
|
7
|
-
var
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
8
|
+
var _JsiSkSurface = require("../skia/web/JsiSkSurface");
|
9
|
+
var _Platform = require("../Platform");
|
10
|
+
var _SkiaViewNativeId = require("./SkiaViewNativeId");
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
13
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
8
14
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
9
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
10
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
11
|
-
class
|
12
|
-
constructor(
|
13
|
-
|
14
|
-
|
16
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* global HTMLCanvasElement */
|
17
|
+
class WebGLRenderer {
|
18
|
+
constructor(canvas, pd) {
|
19
|
+
this.canvas = canvas;
|
20
|
+
this.pd = pd;
|
21
|
+
_defineProperty(this, "surface", null);
|
22
|
+
this.onResize();
|
23
|
+
}
|
24
|
+
makeImageSnapshot(picture, rect) {
|
25
|
+
if (!this.surface) {
|
26
|
+
return null;
|
27
|
+
}
|
28
|
+
const canvas = this.surface.getCanvas();
|
29
|
+
canvas.clear(CanvasKit.TRANSPARENT);
|
30
|
+
this.draw(picture);
|
31
|
+
this.surface.ref.flush();
|
32
|
+
return this.surface.makeImageSnapshot(rect);
|
33
|
+
}
|
34
|
+
onResize() {
|
15
35
|
const {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
36
|
+
canvas,
|
37
|
+
pd
|
38
|
+
} = this;
|
39
|
+
canvas.width = canvas.clientWidth * pd;
|
40
|
+
canvas.height = canvas.clientHeight * pd;
|
41
|
+
const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);
|
42
|
+
const ctx = canvas.getContext("webgl2");
|
43
|
+
if (ctx) {
|
44
|
+
ctx.drawingBufferColorSpace = "display-p3";
|
45
|
+
}
|
46
|
+
if (!surface) {
|
47
|
+
throw new Error("Could not create surface");
|
20
48
|
}
|
21
|
-
|
49
|
+
this.surface = new _JsiSkSurface.JsiSkSurface(CanvasKit, surface);
|
22
50
|
}
|
23
|
-
|
24
|
-
this.
|
25
|
-
|
51
|
+
draw(picture) {
|
52
|
+
if (this.surface) {
|
53
|
+
const canvas = this.surface.getCanvas();
|
54
|
+
canvas.clear(Float32Array.of(0, 0, 0, 0));
|
55
|
+
canvas.save();
|
56
|
+
canvas.scale(pd, pd);
|
57
|
+
canvas.drawPicture(picture);
|
58
|
+
canvas.restore();
|
59
|
+
this.surface.ref.flush();
|
60
|
+
}
|
26
61
|
}
|
27
|
-
|
28
|
-
if (this.
|
29
|
-
canvas
|
30
|
-
|
31
|
-
|
62
|
+
dispose() {
|
63
|
+
if (this.surface) {
|
64
|
+
var _this$canvas;
|
65
|
+
(_this$canvas = this.canvas) === null || _this$canvas === void 0 || (_this$canvas = _this$canvas.getContext("webgl2")) === null || _this$canvas === void 0 || (_this$canvas = _this$canvas.getExtension("WEBGL_lose_context")) === null || _this$canvas === void 0 || _this$canvas.loseContext();
|
66
|
+
this.surface.ref.delete();
|
67
|
+
this.surface = null;
|
32
68
|
}
|
33
69
|
}
|
34
70
|
}
|
35
|
-
|
71
|
+
class StaticWebGLRenderer {
|
72
|
+
constructor(canvas, pd) {
|
73
|
+
this.canvas = canvas;
|
74
|
+
this.pd = pd;
|
75
|
+
_defineProperty(this, "cachedImage", null);
|
76
|
+
}
|
77
|
+
onResize() {
|
78
|
+
this.cachedImage = null;
|
79
|
+
}
|
80
|
+
renderPictureToSurface(picture) {
|
81
|
+
const tempCanvas = new OffscreenCanvas(this.canvas.clientWidth * this.pd, this.canvas.clientHeight * this.pd);
|
82
|
+
let surface = null;
|
83
|
+
try {
|
84
|
+
const webglSurface = CanvasKit.MakeWebGLCanvasSurface(tempCanvas);
|
85
|
+
const ctx = tempCanvas.getContext("webgl2");
|
86
|
+
if (ctx) {
|
87
|
+
ctx.drawingBufferColorSpace = "display-p3";
|
88
|
+
}
|
89
|
+
if (!webglSurface) {
|
90
|
+
throw new Error("Could not create WebGL surface");
|
91
|
+
}
|
92
|
+
surface = new _JsiSkSurface.JsiSkSurface(CanvasKit, webglSurface);
|
93
|
+
const skiaCanvas = surface.getCanvas();
|
94
|
+
skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));
|
95
|
+
skiaCanvas.save();
|
96
|
+
skiaCanvas.scale(this.pd, this.pd);
|
97
|
+
skiaCanvas.drawPicture(picture);
|
98
|
+
skiaCanvas.restore();
|
99
|
+
surface.ref.flush();
|
100
|
+
return {
|
101
|
+
surface,
|
102
|
+
tempCanvas
|
103
|
+
};
|
104
|
+
} catch (error) {
|
105
|
+
if (surface) {
|
106
|
+
surface.ref.delete();
|
107
|
+
}
|
108
|
+
this.cleanupWebGLContext(tempCanvas);
|
109
|
+
return null;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
cleanupWebGLContext(tempCanvas) {
|
113
|
+
const ctx = tempCanvas.getContext("webgl2");
|
114
|
+
if (ctx) {
|
115
|
+
const loseContext = ctx.getExtension("WEBGL_lose_context");
|
116
|
+
if (loseContext) {
|
117
|
+
loseContext.loseContext();
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
draw(picture) {
|
122
|
+
const renderResult = this.renderPictureToSurface(picture);
|
123
|
+
if (!renderResult) {
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
const {
|
127
|
+
tempCanvas
|
128
|
+
} = renderResult;
|
129
|
+
const ctx2d = this.canvas.getContext("2d");
|
130
|
+
if (!ctx2d) {
|
131
|
+
throw new Error("Could not get 2D context");
|
132
|
+
}
|
133
|
+
|
134
|
+
// Set canvas dimensions to match pixel density
|
135
|
+
this.canvas.width = this.canvas.clientWidth * this.pd;
|
136
|
+
this.canvas.height = this.canvas.clientHeight * this.pd;
|
137
|
+
|
138
|
+
// Draw the tempCanvas scaled down to the display size
|
139
|
+
ctx2d.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, 0, 0, this.canvas.clientWidth * this.pd, this.canvas.clientHeight * this.pd);
|
140
|
+
this.cleanupWebGLContext(tempCanvas);
|
141
|
+
}
|
142
|
+
makeImageSnapshot(picture, rect) {
|
143
|
+
if (!this.cachedImage) {
|
144
|
+
const renderResult = this.renderPictureToSurface(picture);
|
145
|
+
if (!renderResult) {
|
146
|
+
return null;
|
147
|
+
}
|
148
|
+
const {
|
149
|
+
surface,
|
150
|
+
tempCanvas
|
151
|
+
} = renderResult;
|
152
|
+
try {
|
153
|
+
this.cachedImage = surface.makeImageSnapshot(rect);
|
154
|
+
} catch (error) {
|
155
|
+
console.error("Error creating image snapshot:", error);
|
156
|
+
} finally {
|
157
|
+
surface.ref.delete();
|
158
|
+
this.cleanupWebGLContext(tempCanvas);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
return this.cachedImage;
|
162
|
+
}
|
163
|
+
dispose() {
|
164
|
+
var _this$cachedImage;
|
165
|
+
(_this$cachedImage = this.cachedImage) === null || _this$cachedImage === void 0 || _this$cachedImage.dispose();
|
166
|
+
this.cachedImage = null;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
const pd = _Platform.Platform.PixelRatio;
|
170
|
+
const SkiaPictureView = exports.SkiaPictureView = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
171
|
+
const canvasRef = (0, _react.useRef)(null);
|
172
|
+
const renderer = (0, _react.useRef)(null);
|
173
|
+
const redrawRequestsRef = (0, _react.useRef)(0);
|
174
|
+
const requestIdRef = (0, _react.useRef)(0);
|
175
|
+
const pictureRef = (0, _react.useRef)(null);
|
176
|
+
const {
|
177
|
+
picture,
|
178
|
+
onLayout
|
179
|
+
} = props;
|
180
|
+
const redraw = (0, _react.useCallback)(() => {
|
181
|
+
redrawRequestsRef.current++;
|
182
|
+
}, []);
|
183
|
+
const getSize = (0, _react.useCallback)(() => {
|
184
|
+
var _canvasRef$current, _canvasRef$current2;
|
185
|
+
return {
|
186
|
+
width: ((_canvasRef$current = canvasRef.current) === null || _canvasRef$current === void 0 ? void 0 : _canvasRef$current.clientWidth) || 0,
|
187
|
+
height: ((_canvasRef$current2 = canvasRef.current) === null || _canvasRef$current2 === void 0 ? void 0 : _canvasRef$current2.clientHeight) || 0
|
188
|
+
};
|
189
|
+
}, []);
|
190
|
+
const setPicture = (0, _react.useCallback)(newPicture => {
|
191
|
+
pictureRef.current = newPicture;
|
192
|
+
redraw();
|
193
|
+
}, [redraw]);
|
194
|
+
const makeImageSnapshot = (0, _react.useCallback)(rect => {
|
195
|
+
if (renderer.current && pictureRef.current) {
|
196
|
+
return renderer.current.makeImageSnapshot(pictureRef.current, rect);
|
197
|
+
}
|
198
|
+
return null;
|
199
|
+
}, []);
|
200
|
+
const tick = (0, _react.useCallback)(() => {
|
201
|
+
if (redrawRequestsRef.current > 0) {
|
202
|
+
redrawRequestsRef.current = 0;
|
203
|
+
if (renderer.current && pictureRef.current) {
|
204
|
+
renderer.current.draw(pictureRef.current);
|
205
|
+
}
|
206
|
+
}
|
207
|
+
requestIdRef.current = requestAnimationFrame(tick);
|
208
|
+
}, []);
|
209
|
+
const onLayoutEvent = (0, _react.useCallback)(evt => {
|
210
|
+
const canvas = canvasRef.current;
|
211
|
+
if (canvas) {
|
212
|
+
renderer.current = props.__destroyWebGLContextAfterRender === true ? new StaticWebGLRenderer(canvas, pd) : new WebGLRenderer(canvas, pd);
|
213
|
+
if (pictureRef.current) {
|
214
|
+
renderer.current.draw(pictureRef.current);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
if (onLayout) {
|
218
|
+
onLayout(evt);
|
219
|
+
}
|
220
|
+
}, [onLayout, props.__destroyWebGLContextAfterRender]);
|
221
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
222
|
+
setPicture,
|
223
|
+
getSize,
|
224
|
+
redraw,
|
225
|
+
makeImageSnapshot
|
226
|
+
}), [setPicture, getSize, redraw, makeImageSnapshot]);
|
227
|
+
(0, _react.useEffect)(() => {
|
228
|
+
var _props$nativeID;
|
229
|
+
const nativeID = (_props$nativeID = props.nativeID) !== null && _props$nativeID !== void 0 ? _props$nativeID : `${_SkiaViewNativeId.SkiaViewNativeId.current++}`;
|
230
|
+
global.SkiaViewApi.registerView(nativeID, {
|
231
|
+
setPicture,
|
232
|
+
getSize,
|
233
|
+
redraw,
|
234
|
+
makeImageSnapshot
|
235
|
+
});
|
236
|
+
if (props.picture) {
|
237
|
+
setPicture(props.picture);
|
238
|
+
}
|
239
|
+
}, [setPicture, getSize, redraw, makeImageSnapshot, props]);
|
240
|
+
(0, _react.useEffect)(() => {
|
241
|
+
tick();
|
242
|
+
return () => {
|
243
|
+
cancelAnimationFrame(requestIdRef.current);
|
244
|
+
if (renderer.current) {
|
245
|
+
renderer.current.dispose();
|
246
|
+
renderer.current = null;
|
247
|
+
}
|
248
|
+
};
|
249
|
+
}, [tick]);
|
250
|
+
(0, _react.useEffect)(() => {
|
251
|
+
if (renderer.current && pictureRef.current) {
|
252
|
+
renderer.current.draw(pictureRef.current);
|
253
|
+
}
|
254
|
+
}, [picture, redraw]);
|
255
|
+
const {
|
256
|
+
debug = false,
|
257
|
+
...viewProps
|
258
|
+
} = props;
|
259
|
+
return /*#__PURE__*/_react.default.createElement(_Platform.Platform.View, _extends({}, viewProps, {
|
260
|
+
onLayout: onLayoutEvent
|
261
|
+
}), /*#__PURE__*/_react.default.createElement("canvas", {
|
262
|
+
ref: canvasRef,
|
263
|
+
style: {
|
264
|
+
display: "flex",
|
265
|
+
flex: 1
|
266
|
+
}
|
267
|
+
}));
|
268
|
+
});
|
36
269
|
//# sourceMappingURL=SkiaPictureView.web.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_SkiaBaseWebView","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SkiaPictureView","SkiaBaseWebView","constructor","props","nativeID","Error","global","SkiaViewApi","registerView","setPicture","picture","redraw","renderInCanvas","canvas","drawPicture","exports"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["import type { SkCanvas, SkPicture } from \"../skia/types\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nexport class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {\n private picture: SkPicture | null = null;\n\n constructor(props: SkiaPictureViewNativeProps) {\n super(props);\n const { nativeID } = props;\n if (!nativeID) {\n throw new Error(\"SkiaPictureView requires a nativeID prop\");\n }\n (global.SkiaViewApi as ISkiaViewApiWeb).registerView(nativeID, this);\n }\n\n public setPicture(picture: SkPicture) {\n this.picture = picture;\n this.redraw();\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.picture) {\n canvas.drawPicture(this.props.picture);\n } else if (this.picture) {\n canvas.drawPicture(this.picture);\n }\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,gBAAA,GAAAC,OAAA;AAAoD,SAAAC,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAE7C,MAAMgB,eAAe,SAASC,gCAAe,CAA6B;EAG/EC,WAAWA,CAACC,KAAiC,EAAE;IAC7C,KAAK,CAACA,KAAK,CAAC;IAACtB,eAAA,kBAHqB,IAAI;IAItC,MAAM;MAAEuB;IAAS,CAAC,GAAGD,KAAK;IAC1B,IAAI,CAACC,QAAQ,EAAE;MACb,MAAM,IAAIC,KAAK,CAAC,0CAA0C,CAAC;IAC7D;IACCC,MAAM,CAACC,WAAW,CAAqBC,YAAY,CAACJ,QAAQ,EAAE,IAAI,CAAC;EACtE;EAEOK,UAAUA,CAACC,OAAkB,EAAE;IACpC,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;EAEUC,cAAcA,CAACC,MAAgB,EAAQ;IAC/C,IAAI,IAAI,CAACV,KAAK,CAACO,OAAO,EAAE;MACtBG,MAAM,CAACC,WAAW,CAAC,IAAI,CAACX,KAAK,CAACO,OAAO,CAAC;IACxC,CAAC,MAAM,IAAI,IAAI,CAACA,OAAO,EAAE;MACvBG,MAAM,CAACC,WAAW,CAAC,IAAI,CAACJ,OAAO,CAAC;IAClC;EACF;AACF;AAACK,OAAA,CAAAf,eAAA,GAAAA,eAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_JsiSkSurface","_Platform","_SkiaViewNativeId","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","WebGLRenderer","constructor","canvas","pd","onResize","makeImageSnapshot","picture","rect","surface","getCanvas","clear","CanvasKit","TRANSPARENT","draw","ref","flush","width","clientWidth","height","clientHeight","MakeWebGLCanvasSurface","ctx","getContext","drawingBufferColorSpace","Error","JsiSkSurface","Float32Array","of","save","scale","drawPicture","restore","dispose","_this$canvas","getExtension","loseContext","delete","StaticWebGLRenderer","cachedImage","renderPictureToSurface","tempCanvas","OffscreenCanvas","webglSurface","skiaCanvas","error","cleanupWebGLContext","renderResult","ctx2d","drawImage","console","_this$cachedImage","Platform","PixelRatio","SkiaPictureView","exports","forwardRef","props","canvasRef","useRef","renderer","redrawRequestsRef","requestIdRef","pictureRef","onLayout","redraw","useCallback","current","getSize","_canvasRef$current","_canvasRef$current2","setPicture","newPicture","tick","requestAnimationFrame","onLayoutEvent","evt","__destroyWebGLContextAfterRender","useImperativeHandle","useEffect","_props$nativeID","nativeID","SkiaViewNativeId","global","SkiaViewApi","registerView","cancelAnimationFrame","debug","viewProps","createElement","View","style","display","flex"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useImperativeHandle,\n forwardRef,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\ninterface Renderer {\n onResize(): void;\n draw(picture: SkPicture): void;\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\nclass WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n\n constructor(private canvas: HTMLCanvasElement, private pd: number) {\n this.onResize();\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.surface) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(picture);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(rect);\n }\n\n onResize() {\n const { canvas, pd } = this;\n canvas.width = canvas.clientWidth * pd;\n canvas.height = canvas.clientHeight * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n const ctx = canvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(picture: SkPicture) {\n if (this.surface) {\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n canvas.drawPicture(picture);\n canvas.restore();\n this.surface.ref.flush();\n }\n }\n\n dispose(): void {\n if (this.surface) {\n this.canvas\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n this.surface.ref.delete();\n this.surface = null;\n }\n }\n}\n\nclass StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n\n constructor(private canvas: HTMLCanvasElement, private pd: number) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderPictureToSurface(\n picture: SkPicture\n ): { surface: JsiSkSurface; tempCanvas: OffscreenCanvas } | null {\n const tempCanvas = new OffscreenCanvas(\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n let surface: JsiSkSurface | null = null;\n\n try {\n const webglSurface = CanvasKit.MakeWebGLCanvasSurface(tempCanvas);\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n\n if (!webglSurface) {\n throw new Error(\"Could not create WebGL surface\");\n }\n\n surface = new JsiSkSurface(CanvasKit, webglSurface);\n\n const skiaCanvas = surface.getCanvas();\n skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));\n skiaCanvas.save();\n skiaCanvas.scale(this.pd, this.pd);\n skiaCanvas.drawPicture(picture);\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas };\n } catch (error) {\n if (surface) {\n surface.ref.delete();\n }\n this.cleanupWebGLContext(tempCanvas);\n return null;\n }\n }\n\n private cleanupWebGLContext(tempCanvas: OffscreenCanvas): void {\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n const loseContext = ctx.getExtension(\"WEBGL_lose_context\");\n if (loseContext) {\n loseContext.loseContext();\n }\n }\n }\n\n draw(picture: SkPicture): void {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n throw new Error(\"Could not get 2D context\");\n }\n\n // Set canvas dimensions to match pixel density\n this.canvas.width = this.canvas.clientWidth * this.pd;\n this.canvas.height = this.canvas.clientHeight * this.pd;\n\n // Draw the tempCanvas scaled down to the display size\n ctx2d.drawImage(\n tempCanvas,\n 0,\n 0,\n tempCanvas.width,\n tempCanvas.height,\n 0,\n 0,\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n this.cleanupWebGLContext(tempCanvas);\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return null;\n }\n\n const { surface, tempCanvas } = renderResult;\n\n try {\n this.cachedImage = surface.makeImageSnapshot(rect);\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n surface.ref.delete();\n this.cleanupWebGLContext(tempCanvas);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\nconst pd = Platform.PixelRatio;\n\nexport interface SkiaPictureViewHandle {\n setPicture(picture: SkPicture): void;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n}\n\nexport const SkiaPictureView = forwardRef<\n SkiaPictureViewHandle,\n SkiaPictureViewNativeProps\n>((props, ref) => {\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const renderer = useRef<Renderer | null>(null);\n const redrawRequestsRef = useRef(0);\n const requestIdRef = useRef(0);\n const pictureRef = useRef<SkPicture | null>(null);\n\n const { picture, onLayout } = props;\n\n const redraw = useCallback(() => {\n redrawRequestsRef.current++;\n }, []);\n\n const getSize = useCallback(() => {\n return {\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n };\n }, []);\n\n const setPicture = useCallback(\n (newPicture: SkPicture) => {\n pictureRef.current = newPicture;\n redraw();\n },\n [redraw]\n );\n\n const makeImageSnapshot = useCallback((rect?: SkRect) => {\n if (renderer.current && pictureRef.current) {\n return renderer.current.makeImageSnapshot(pictureRef.current, rect);\n }\n return null;\n }, []);\n\n const tick = useCallback(() => {\n if (redrawRequestsRef.current > 0) {\n redrawRequestsRef.current = 0;\n if (renderer.current && pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }\n requestIdRef.current = requestAnimationFrame(tick);\n }, []);\n\n const onLayoutEvent = useCallback(\n (evt: LayoutChangeEvent) => {\n const canvas = canvasRef.current;\n if (canvas) {\n renderer.current =\n props.__destroyWebGLContextAfterRender === true\n ? new StaticWebGLRenderer(canvas, pd)\n : new WebGLRenderer(canvas, pd);\n if (pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }\n if (onLayout) {\n onLayout(evt);\n }\n },\n [onLayout, props.__destroyWebGLContextAfterRender]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n }),\n [setPicture, getSize, redraw, makeImageSnapshot]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n (global.SkiaViewApi as ISkiaViewApiWeb).registerView(nativeID, {\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n } as SkiaPictureViewHandle);\n if (props.picture) {\n setPicture(props.picture);\n }\n }, [setPicture, getSize, redraw, makeImageSnapshot, props]);\n\n useEffect(() => {\n tick();\n return () => {\n cancelAnimationFrame(requestIdRef.current);\n if (renderer.current) {\n renderer.current.dispose();\n renderer.current = null;\n }\n };\n }, [tick]);\n\n useEffect(() => {\n if (renderer.current && pictureRef.current) {\n renderer.current.draw(pictureRef.current);\n }\n }, [picture, redraw]);\n\n const { debug = false, ...viewProps } = props;\n return (\n <Platform.View {...viewProps} onLayout={onLayoutEvent}>\n <canvas ref={canvasRef} style={{ display: \"flex\", flex: 1 }} />\n </Platform.View>\n );\n});\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAUA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAIA,IAAAG,iBAAA,GAAAH,OAAA;AAAsD,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,C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GAAG/B,KAAK;EAC7C,oBACEpG,MAAA,CAAAY,OAAA,CAAAwH,aAAA,CAAChI,SAAA,CAAA2F,QAAQ,CAACsC,IAAI,EAAA3G,QAAA,KAAKyG,SAAS;IAAExB,QAAQ,EAAEW;EAAc,iBACpDtH,MAAA,CAAAY,OAAA,CAAAwH,aAAA;IAAQ1E,GAAG,EAAE2C,SAAU;IAACiC,KAAK,EAAE;MAAEC,OAAO,EAAE,MAAM;MAAEC,IAAI,EAAE;IAAE;EAAE,CAAE,CACjD,CAAC;AAEpB,CAAC,CAAC","ignoreList":[]}
|
@@ -26,6 +26,7 @@ export interface SkiaBaseViewProps extends ViewProps {
|
|
26
26
|
*/
|
27
27
|
onSize?: SharedValue<SkSize>;
|
28
28
|
opaque?: boolean;
|
29
|
+
__destroyWebGLContextAfterRender?: boolean;
|
29
30
|
}
|
30
31
|
export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
|
31
32
|
picture?: SkPicture;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Node } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n debug?: boolean;\n opaque?: boolean;\n};\n\nexport interface ISkiaViewApi {\n web?: boolean;\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n size: (nativeId: number) => SkSize;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SharedValue<SkSize>;\n\n opaque?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewNativeProps extends SkiaBaseViewProps {\n root?: Node<unknown>;\n}\n"],"mappings":"","ignoreList":[]}
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Node } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n debug?: boolean;\n opaque?: boolean;\n};\n\nexport interface ISkiaViewApi {\n web?: boolean;\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n size: (nativeId: number) => SkSize;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SharedValue<SkSize>;\n\n opaque?: boolean;\n\n // On web, only 16 WebGL contextes are allowed. If the drawing is non-animated, set\n // __destroyWebGLContextAfterRender to true to release the context after each draw.\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewNativeProps extends SkiaBaseViewProps {\n root?: Node<unknown>;\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -23,5 +23,6 @@ export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
|
|
23
23
|
onSize?: SharedValue<SkSize>;
|
24
24
|
colorSpace?: "p3" | "srgb";
|
25
25
|
ref?: React.Ref<CanvasRef>;
|
26
|
+
__destroyWebGLContextAfterRender?: boolean;
|
26
27
|
}
|
27
28
|
export declare const Canvas: ({ debug, opaque, children, onSize, colorSpace, ref, onLayout, ...viewProps }: CanvasProps) => React.JSX.Element;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","useCanvasRef","useCanvasSize","userRef","ourRef","ref","size","setSize","width","height","current","measure","_x","_y","isFabric","Boolean","_global","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","root","render","unmount","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(\n () => new SkiaSGRoot(Skia, nativeId, onSize),\n [nativeId, onSize]\n );\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;AACA,OAAOA,KAAK,IACVC,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AASd,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAW9B,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAMN,MAAM,CAAY,IAAI,CAAC;AAEzD,OAAO,MAAMO,aAAa,GAAIC,OAAqC,IAAK;EACtE,MAAMC,MAAM,GAAGH,YAAY,CAAC,CAAC;EAC7B,MAAMI,GAAG,GAAGF,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIC,MAAM;EAC7B,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAGX,QAAQ,CAAS;IAAEY,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EACjEhB,eAAe,CAAC,MAAM;IACpB,IAAIY,GAAG,CAACK,OAAO,EAAE;MACfL,GAAG,CAACK,OAAO,CAACC,OAAO,CAAC,CAACC,EAAE,EAAEC,EAAE,EAAEL,KAAK,EAAEC,MAAM,KAAK;QAC7CF,OAAO,CAAC;UAAEC,KAAK;UAAEC;QAAO,CAAC,CAAC;MAC5B,CAAC,CAAC;IACJ;IACA;EACF,CAAC,EAAE,EAAE,CAAC;EACN,OAAO;IAAEJ,GAAG;IAAEC;EAAK,CAAC;AACtB,CAAC;;AAED;AACA,OAAO,MAAMQ,QAAQ,GAAGC,OAAO,EAAAC,OAAA,GAAEC,MAAM,cAAAD,OAAA,uBAAPA,OAAA,CAAiBE,qBAAqB,CAAC;
|
1
|
+
{"version":3,"names":["React","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","useCanvasRef","useCanvasSize","userRef","ourRef","ref","size","setSize","width","height","current","measure","_x","_y","isFabric","Boolean","_global","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","root","render","unmount","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(\n () => new SkiaSGRoot(Skia, nativeId, onSize),\n [nativeId, onSize]\n );\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;AACA,OAAOA,KAAK,IACVC,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AASd,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAW9B,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAMN,MAAM,CAAY,IAAI,CAAC;AAEzD,OAAO,MAAMO,aAAa,GAAIC,OAAqC,IAAK;EACtE,MAAMC,MAAM,GAAGH,YAAY,CAAC,CAAC;EAC7B,MAAMI,GAAG,GAAGF,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIC,MAAM;EAC7B,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAGX,QAAQ,CAAS;IAAEY,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EACjEhB,eAAe,CAAC,MAAM;IACpB,IAAIY,GAAG,CAACK,OAAO,EAAE;MACfL,GAAG,CAACK,OAAO,CAACC,OAAO,CAAC,CAACC,EAAE,EAAEC,EAAE,EAAEL,KAAK,EAAEC,MAAM,KAAK;QAC7CF,OAAO,CAAC;UAAEC,KAAK;UAAEC;QAAO,CAAC,CAAC;MAC5B,CAAC,CAAC;IACJ;IACA;EACF,CAAC,EAAE,EAAE,CAAC;EACN,OAAO;IAAEJ,GAAG;IAAEC;EAAK,CAAC;AACtB,CAAC;;AAED;AACA,OAAO,MAAMQ,QAAQ,GAAGC,OAAO,EAAAC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AAC;IACDG,MAAM,EAAEA,CAAA,KAAM;MACZF,WAAW,CAACG,aAAa,CAACT,QAAQ,CAAC;IACrC,CAAC;IACDU,WAAW,EAAEA,CAAA,KAAM;MACjB,OAAOV,QAAQ;IACjB,CAAC;IACDnB,OAAO,EAAG8B,QAAQ,IAAK;MAAA,IAAAC,gBAAA;MACrB,CAAAA,gBAAA,GAAAb,OAAO,CAACnB,OAAO,cAAAgC,gBAAA,eAAfA,gBAAA,CAAiB/B,OAAO,CAAC8B,QAAQ,CAAC;IACpC,CAAC;IACDE,eAAe,EAAGF,QAAQ,IAAK;MAAA,IAAAG,iBAAA;MAC7B,CAAAA,iBAAA,GAAAf,OAAO,CAACnB,OAAO,cAAAkC,iBAAA,eAAfA,iBAAA,CAAiBD,eAAe,CAACF,QAAQ,CAAC;IAC5C;EACF,CAAC,CACL,CAAC;EAED,oBACEnD,KAAA,CAAAuD,aAAA,CAAC/C,8BAA8B,EAAAgD,QAAA;IAC7BzC,GAAG,EAAEwB,OAAQ;IACbkB,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGlB,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA;EAAW,GACnBE,SAAS,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { SkPicture } from "../skia/types";
|
2
2
|
import type { ISkiaViewApi } from "../views/types";
|
3
|
-
import type {
|
3
|
+
import type { SkiaPictureViewHandle } from "../views/SkiaPictureView.web";
|
4
4
|
export type ISkiaViewApiWeb = ISkiaViewApi & {
|
5
|
-
views: Record<string,
|
5
|
+
views: Record<string, SkiaPictureViewHandle>;
|
6
6
|
deferedPictures: Record<string, SkPicture>;
|
7
|
-
registerView(nativeId: string, view:
|
7
|
+
registerView(nativeId: string, view: SkiaPictureViewHandle): void;
|
8
8
|
};
|
9
9
|
declare const _default: {};
|
10
10
|
export default _default;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["global","SkiaViewApi","views","deferedPictures","web","registerView","nativeId","view","setPicture","setJsiProperty","name","value","size","getSize","width","height","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result","Error"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type { SkPicture, SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type {
|
1
|
+
{"version":3,"names":["global","SkiaViewApi","views","deferedPictures","web","registerView","nativeId","view","setPicture","setJsiProperty","name","value","size","getSize","width","height","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result","Error"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type { SkPicture, SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type { SkiaPictureViewHandle } from \"../views/SkiaPictureView.web\";\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaPictureViewHandle>;\n deferedPictures: Record<string, SkPicture>;\n registerView(nativeId: string, view: SkiaPictureViewHandle): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n web: true,\n registerView(nativeId: string, view: SkiaPictureViewHandle) {\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId]) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n }\n this.views[nativeId] = view;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n if (!this.views[`${nativeId}`]) {\n this.deferedPictures[`${nativeId}`] = value;\n } else {\n this.views[`${nativeId}`].setPicture(value);\n }\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n this.views[`${nativeId}`].redraw();\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n return this.views[`${nativeId}`].makeImageSnapshot(rect);\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const result = this.views[`${nativeId}`].makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n\n// eslint-disable-next-line import/no-default-export\nexport default {};\n"],"mappings":"AAAA;;AAWAA,MAAM,CAACC,WAAW,GAAG;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,eAAe,EAAE,CAAC,CAAC;EACnBC,GAAG,EAAE,IAAI;EACTC,YAAYA,CAACC,QAAgB,EAAEC,IAA2B,EAAE;IAC1D;IACA,IAAI,IAAI,CAACJ,eAAe,CAACG,QAAQ,CAAC,EAAE;MAClCC,IAAI,CAACC,UAAU,CAAC,IAAI,CAACL,eAAe,CAACG,QAAQ,CAAc,CAAC;IAC9D;IACA,IAAI,CAACJ,KAAK,CAACI,QAAQ,CAAC,GAAGC,IAAI;EAC7B,CAAC;EACD;EACAE,cAAcA,CAACH,QAAgB,EAAEI,IAAY,EAAEC,KAAU,EAAE;IACzD,IAAID,IAAI,KAAK,SAAS,EAAE;MACtB,IAAI,CAAC,IAAI,CAACR,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,EAAE;QAC9B,IAAI,CAACH,eAAe,CAAC,GAAGG,QAAQ,EAAE,CAAC,GAAGK,KAAK;MAC7C,CAAC,MAAM;QACL,IAAI,CAACT,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACE,UAAU,CAACG,KAAK,CAAC;MAC7C;IACF;EACF,CAAC;EACDC,IAAIA,CAACN,QAAgB,EAAE;IACrB,IAAI,IAAI,CAACJ,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,EAAE;MAC7B,OAAO,IAAI,CAACJ,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACO,OAAO,CAAC,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO;QAAEC,KAAK,EAAE,CAAC;QAAEC,MAAM,EAAE;MAAE,CAAC;IAChC;EACF,CAAC;EACDC,aAAaA,CAACV,QAAgB,EAAE;IAC9B,IAAI,CAACJ,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACW,MAAM,CAAC,CAAC;EACpC,CAAC;EACDC,iBAAiBA,CAACZ,QAAgB,EAAEa,IAAa,EAAE;IACjD,OAAO,IAAI,CAACjB,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACY,iBAAiB,CAACC,IAAI,CAAC;EAC1D,CAAC;EACDC,sBAAsBA,CAACd,QAAgB,EAAEa,IAAa,EAAE;IACtD,OAAO,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAMC,MAAM,GAAG,IAAI,CAACtB,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACY,iBAAiB,CAACC,IAAI,CAAC;MAChE,IAAIK,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIE,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;;AAEpB;AACA,eAAe,CAAC,CAAC","ignoreList":[]}
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import type { ViewProps } from "react-native";
|
2
|
-
import { SkiaPictureView } from "../views/SkiaPictureView.web";
|
3
2
|
export interface NativeProps extends ViewProps {
|
4
3
|
debug?: boolean;
|
5
4
|
opaque?: boolean;
|
6
5
|
nativeID: string;
|
7
6
|
}
|
8
|
-
declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").
|
7
|
+
declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("..").SkiaPictureViewNativeProps & import("react").RefAttributes<import("../views/SkiaPictureView.web").SkiaPictureViewHandle>>;
|
9
8
|
export default SkiaPictureViewNativeComponent;
|
@@ -1,9 +1,13 @@
|
|
1
|
-
import
|
1
|
+
import React from "react";
|
2
|
+
import type { SkRect, SkPicture, SkImage } from "../skia/types";
|
2
3
|
import type { SkiaPictureViewNativeProps } from "./types";
|
3
|
-
|
4
|
-
export declare class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {
|
5
|
-
private picture;
|
6
|
-
constructor(props: SkiaPictureViewNativeProps);
|
4
|
+
export interface SkiaPictureViewHandle {
|
7
5
|
setPicture(picture: SkPicture): void;
|
8
|
-
|
6
|
+
getSize(): {
|
7
|
+
width: number;
|
8
|
+
height: number;
|
9
|
+
};
|
10
|
+
redraw(): void;
|
11
|
+
makeImageSnapshot(rect?: SkRect): SkImage | null;
|
9
12
|
}
|
13
|
+
export declare const SkiaPictureView: React.ForwardRefExoticComponent<SkiaPictureViewNativeProps & React.RefAttributes<SkiaPictureViewHandle>>;
|