@shopify/react-native-skia 2.2.14 → 2.2.15
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/apple/MetalContext.h +3 -25
- package/apple/MetalContext.mm +7 -3
- package/apple/MetalWindowContext.mm +1 -1
- package/apple/RNSkMetalCanvasProvider.mm +3 -6
- package/cpp/api/JsiSkImage.h +20 -1
- package/cpp/api/JsiSkSurface.h +20 -1
- package/cpp/api/JsiSkThreadSafeDeletion.h +105 -0
- package/cpp/api/recorder/Drawings.h +7 -7
- package/cpp/jsi/JsiHostObject.cpp +0 -27
- package/cpp/jsi/JsiHostObject.h +5 -5
- package/cpp/jsi/ViewProperty.h +34 -2
- package/cpp/rnskia/RNSkJsiViewApi.h +14 -24
- package/cpp/rnskia/RNSkPictureView.h +25 -2
- package/cpp/rnskia/RNSkView.h +7 -0
- package/lib/commonjs/Platform/Platform.js +2 -1
- package/lib/commonjs/Platform/Platform.js.map +1 -1
- package/lib/commonjs/Platform/Platform.web.js +3 -0
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +35 -1
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.web.js +1 -1
- package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
- package/lib/commonjs/skia/types/Data/Data.d.ts +6 -1
- package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +2 -3
- package/lib/commonjs/sksg/Container.js +1 -1
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.d.ts +3 -5
- package/lib/commonjs/sksg/Container.native.js +8 -15
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/sksg/Container.web.d.ts +2 -3
- package/lib/commonjs/sksg/Container.web.js +1 -1
- package/lib/commonjs/sksg/Container.web.js.map +1 -1
- package/lib/commonjs/sksg/Reconciler.d.ts +2 -3
- package/lib/commonjs/sksg/Reconciler.js +2 -2
- package/lib/commonjs/sksg/Reconciler.js.map +1 -1
- package/lib/module/Platform/Platform.js +2 -1
- package/lib/module/Platform/Platform.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +3 -0
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/renderer/Canvas.js +35 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/core/SVG.web.js +1 -1
- package/lib/module/skia/core/SVG.web.js.map +1 -1
- package/lib/module/skia/types/Data/Data.d.ts +6 -1
- package/lib/module/skia/types/Data/Data.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +2 -3
- package/lib/module/sksg/Container.js +1 -1
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Container.native.d.ts +3 -5
- package/lib/module/sksg/Container.native.js +8 -15
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/sksg/Container.web.d.ts +2 -3
- package/lib/module/sksg/Container.web.js +1 -1
- package/lib/module/sksg/Container.web.js.map +1 -1
- package/lib/module/sksg/Reconciler.d.ts +2 -3
- package/lib/module/sksg/Reconciler.js +2 -2
- package/lib/module/sksg/Reconciler.js.map +1 -1
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +2 -3
- package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Container.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Container.native.d.ts +2 -3
- package/lib/typescript/lib/module/sksg/Container.web.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +1 -1
- package/lib/typescript/src/skia/types/Data/Data.d.ts +6 -1
- package/lib/typescript/src/sksg/Container.d.ts +2 -3
- package/lib/typescript/src/sksg/Container.native.d.ts +3 -5
- package/lib/typescript/src/sksg/Container.web.d.ts +2 -3
- package/lib/typescript/src/sksg/Reconciler.d.ts +2 -3
- package/package.json +1 -1
- package/src/Platform/Platform.ts +3 -0
- package/src/Platform/Platform.web.tsx +3 -0
- package/src/renderer/Canvas.tsx +33 -3
- package/src/skia/core/SVG.web.ts +3 -0
- package/src/skia/types/Data/Data.ts +7 -1
- package/src/sksg/Container.native.ts +10 -27
- package/src/sksg/Container.ts +2 -8
- package/src/sksg/Container.web.ts +2 -8
- package/src/sksg/Reconciler.ts +3 -4
@@ -1,6 +1,7 @@
|
|
1
1
|
var _global;
|
2
2
|
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); }
|
3
3
|
import React, { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
4
|
+
import Rea from "../external/reanimated/ReanimatedProxy";
|
4
5
|
import { SkiaViewNativeId } from "../views/SkiaViewNativeId";
|
5
6
|
import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent";
|
6
7
|
import { SkiaSGRoot } from "../sksg/Reconciler";
|
@@ -58,7 +59,40 @@ export const Canvas = ({
|
|
58
59
|
}, []);
|
59
60
|
|
60
61
|
// Root
|
61
|
-
const root = useMemo(() => new SkiaSGRoot(Skia, nativeId
|
62
|
+
const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);
|
63
|
+
const updateSize = useCallback(value => {
|
64
|
+
if (onSize) {
|
65
|
+
onSize.value = value;
|
66
|
+
}
|
67
|
+
}, [onSize]);
|
68
|
+
useEffect(() => {
|
69
|
+
if (onSize) {
|
70
|
+
const {
|
71
|
+
runOnJS
|
72
|
+
} = Rea;
|
73
|
+
const uiOnSize = Rea.makeMutable({
|
74
|
+
width: 0,
|
75
|
+
height: 0
|
76
|
+
});
|
77
|
+
Rea.runOnUI(() => {
|
78
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
79
|
+
// @ts-expect-error
|
80
|
+
global[`__onSize_${nativeId}`] = uiOnSize;
|
81
|
+
uiOnSize.addListener(nativeId, value => {
|
82
|
+
runOnJS(updateSize)(value);
|
83
|
+
});
|
84
|
+
})();
|
85
|
+
return () => {
|
86
|
+
Rea.runOnUI(() => {
|
87
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
88
|
+
// @ts-expect-error
|
89
|
+
delete global[`__onSize_${nativeId}`];
|
90
|
+
uiOnSize.removeListener(nativeId);
|
91
|
+
})();
|
92
|
+
};
|
93
|
+
}
|
94
|
+
return undefined;
|
95
|
+
}, [onSize, nativeId, updateSize]);
|
62
96
|
|
63
97
|
// Render effects
|
64
98
|
useLayoutEffect(() => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","Platform","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","onLayoutWeb","e","OS","nativeEvent","layout","value","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n LayoutChangeEvent,\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\";\nimport { Platform } from \"../Platform\";\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 const onLayoutWeb = useCallback(\n (e: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(e);\n }\n if (Platform.OS === \"web\" && onSize) {\n const { width, height } = e.nativeEvent.layout;\n onSize.value = { width, height };\n }\n },\n [onLayout, onSize]\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 onLayout={onLayoutWeb}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAUd,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,QAAQ,QAAQ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CAAiBD,eAAe,CAACF,QAAQ,CAAC;IAC5C;EACF,CAAC,CACL,CAAC;EAED,MAAMI,WAAW,GAAGxD,WAAW,CAC5ByD,CAAoB,IAAK;IACxB,IAAIrB,QAAQ,EAAE;MACZA,QAAQ,CAACqB,CAAC,CAAC;IACb;IACA,IAAI9C,QAAQ,CAAC+C,EAAE,KAAK,KAAK,IAAIxB,MAAM,EAAE;MACnC,MAAM;QAAEf,KAAK;QAAEC;MAAO,CAAC,GAAGqC,CAAC,CAACE,WAAW,CAACC,MAAM;MAC9C1B,MAAM,CAAC2B,KAAK,GAAG;QAAE1C,KAAK;QAAEC;MAAO,CAAC;IAClC;EACF,CAAC,EACD,CAACgB,QAAQ,EAAEF,MAAM,CACnB,CAAC;EAED,oBACEnC,KAAA,CAAA+D,aAAA,CAACtD,8BAA8B,EAAAuD,QAAA;IAC7B/C,GAAG,EAAEwB,OAAQ;IACbwB,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGxB,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEoB;EAAY,GAClBnB,SAAS,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","Rea","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","Platform","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","updateSize","value","runOnJS","uiOnSize","makeMutable","runOnUI","addListener","removeListener","undefined","render","unmount","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","onLayoutWeb","e","OS","nativeEvent","layout","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n LayoutChangeEvent,\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\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\";\nimport { Platform } from \"../Platform\";\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(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n const updateSize = useCallback(\n (value: SkSize) => {\n if (onSize) {\n onSize.value = value;\n }\n },\n [onSize]\n );\n useEffect(() => {\n if (onSize) {\n const { runOnJS } = Rea;\n const uiOnSize = Rea.makeMutable({ width: 0, height: 0 });\n Rea.runOnUI(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n global[`__onSize_${nativeId}`] = uiOnSize;\n uiOnSize.addListener(nativeId, (value) => {\n runOnJS(updateSize)(value);\n });\n })();\n return () => {\n Rea.runOnUI(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n delete global[`__onSize_${nativeId}`];\n uiOnSize.removeListener(nativeId);\n })();\n };\n }\n return undefined;\n }, [onSize, nativeId, updateSize]);\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 const onLayoutWeb = useCallback(\n (e: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(e);\n }\n if (Platform.OS === \"web\" && onSize) {\n const { width, height } = e.nativeEvent.layout;\n onSize.value = { width, height };\n }\n },\n [onLayout, onSize]\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 onLayout={onLayoutWeb}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAUd,OAAOC,GAAG,MAAM,wCAAwC;AACxD,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,QAAQ,QAAQ,aAAa;AAWtC,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAMR,MAAM,CAAY,IAAI,CAAC;AAEzD,OAAO,MAAMS,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,GAAGb,QAAQ,CAAS;IAAEc,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EACjElB,eA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AEA,UAAW;IACvBC,QAAQ,EAAE6B;EAAY,GAClB5B,SAAS,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
|
@@ -3,7 +3,7 @@ export const useSVG = (source, onError) => {
|
|
3
3
|
if (source === null || source === undefined) {
|
4
4
|
throw new Error(`Invalid svg data source. Got: ${source}`);
|
5
5
|
}
|
6
|
-
if (typeof source !== "object" || source instanceof Uint8Array || typeof source.default !== "string") {
|
6
|
+
if (typeof source !== "object" || source instanceof Uint8Array || !("uri" in source) || typeof source.uri !== "string" || !("default" in source) || typeof source.default !== "string") {
|
7
7
|
throw new Error(`Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(source, null, 2)}`);
|
8
8
|
}
|
9
9
|
const svg = Skia.SVG.MakeFromString(source.default);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Skia","useSVG","source","onError","undefined","Error","Uint8Array","default","JSON","stringify","svg","SVG","MakeFromString"],"sources":["SVG.web.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n if (\n typeof source !== \"object\" ||\n source instanceof Uint8Array ||\n typeof source.default !== \"string\"\n ) {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(\n source,\n null,\n 2\n )}`\n );\n }\n const svg = Skia.SVG.MakeFromString(source.default);\n if (svg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n return svg;\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAG9B,OAAO,MAAMC,MAAM,GAAGA,CACpBC,MAAuB,EACvBC,OAA8B,KAC3B;EACH,IAAID,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKE,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAC,iCAAiCH,MAAM,EAAE,CAAC;EAC5D;EACA,IACE,OAAOA,MAAM,KAAK,QAAQ,IAC1BA,MAAM,YAAYI,UAAU,IAC5B,
|
1
|
+
{"version":3,"names":["Skia","useSVG","source","onError","undefined","Error","Uint8Array","uri","default","JSON","stringify","svg","SVG","MakeFromString"],"sources":["SVG.web.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n if (\n typeof source !== \"object\" ||\n source instanceof Uint8Array ||\n !(\"uri\" in source) ||\n typeof source.uri !== \"string\" ||\n !(\"default\" in source) ||\n typeof source.default !== \"string\"\n ) {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(\n source,\n null,\n 2\n )}`\n );\n }\n const svg = Skia.SVG.MakeFromString(source.default);\n if (svg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n return svg;\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAG9B,OAAO,MAAMC,MAAM,GAAGA,CACpBC,MAAuB,EACvBC,OAA8B,KAC3B;EACH,IAAID,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKE,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAC,iCAAiCH,MAAM,EAAE,CAAC;EAC5D;EACA,IACE,OAAOA,MAAM,KAAK,QAAQ,IAC1BA,MAAM,YAAYI,UAAU,IAC5B,EAAE,KAAK,IAAIJ,MAAM,CAAC,IAClB,OAAOA,MAAM,CAACK,GAAG,KAAK,QAAQ,IAC9B,EAAE,SAAS,IAAIL,MAAM,CAAC,IACtB,OAAOA,MAAM,CAACM,OAAO,KAAK,QAAQ,EAClC;IACA,MAAM,IAAIH,KAAK,CACb,iFAAiFI,IAAI,CAACC,SAAS,CAC7FR,MAAM,EACN,IAAI,EACJ,CACF,CAAC,EACH,CAAC;EACH;EACA,MAAMS,GAAG,GAAGX,IAAI,CAACY,GAAG,CAACC,cAAc,CAACX,MAAM,CAACM,OAAO,CAAC;EACnD,IAAIG,GAAG,KAAK,IAAI,IAAIR,OAAO,KAAKC,SAAS,EAAE;IACzCD,OAAO,CAAC,IAAIE,KAAK,CAAC,mCAAmC,CAAC,CAAC;EACzD;EACA,OAAOM,GAAG;AACZ,CAAC","ignoreList":[]}
|
@@ -5,7 +5,12 @@ type ESModule = {
|
|
5
5
|
__esModule: true;
|
6
6
|
default: string;
|
7
7
|
};
|
8
|
-
|
8
|
+
type MetroAsset = {
|
9
|
+
uri: string;
|
10
|
+
width: number;
|
11
|
+
height: number;
|
12
|
+
};
|
13
|
+
export type DataModule = RNModule | ESModule | MetroAsset;
|
9
14
|
export type DataSource = DataModule | string | Uint8Array;
|
10
15
|
export type DataSourceParam = DataSource | null | undefined;
|
11
16
|
export declare const isRNModule: (mod: DataModule) => mod is RNModule;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isRNModule","mod"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype ESModule = {\n __esModule: true;\n default: string;\n};\nexport type DataModule = RNModule | ESModule;\nexport type DataSource = DataModule | string | Uint8Array;\nexport type DataSourceParam = DataSource | null | undefined;\n\nexport const isRNModule = (mod: DataModule): mod is RNModule =>\n typeof mod === \"number\";\n"],"mappings":"
|
1
|
+
{"version":3,"names":["isRNModule","mod"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype ESModule = {\n __esModule: true;\n default: string;\n};\ntype MetroAsset = {\n uri: string;\n width: number;\n height: number;\n};\n\nexport type DataModule = RNModule | ESModule | MetroAsset;\nexport type DataSource = DataModule | string | Uint8Array;\nexport type DataSourceParam = DataSource | null | undefined;\n\nexport const isRNModule = (mod: DataModule): mod is RNModule =>\n typeof mod === \"number\";\n"],"mappings":"AAmBA,OAAO,MAAMA,UAAU,GAAIC,GAAe,IACxC,OAAOA,GAAG,KAAK,QAAQ","ignoreList":[]}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Skia, SkSize } from "../skia/types";
|
1
|
+
import type { Skia } from "../skia/types";
|
3
2
|
import { StaticContainer } from "./StaticContainer";
|
4
|
-
export declare const createContainer: (Skia: Skia, nativeId: number
|
3
|
+
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["StaticContainer","createContainer","Skia","nativeId"
|
1
|
+
{"version":3,"names":["StaticContainer","createContainer","Skia","nativeId"],"sources":["Container.ts"],"sourcesContent":["import type { Skia } from \"../skia/types\";\n\nimport { StaticContainer } from \"./StaticContainer\";\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n return new StaticContainer(Skia, nativeId);\n};\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,OAAO,MAAMC,eAAe,GAAGA,CAACC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,OAAO,IAAIH,eAAe,CAACE,IAAI,EAAEC,QAAQ,CAAC;AAC5C,CAAC","ignoreList":[]}
|
@@ -1,14 +1,12 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Skia, SkSize } from "../skia/types";
|
1
|
+
import type { Skia } from "../skia/types";
|
3
2
|
import { Container, StaticContainer } from "./StaticContainer";
|
4
3
|
import "../skia/NativeSetup";
|
5
4
|
import "../views/api";
|
6
5
|
declare class NativeReanimatedContainer extends Container {
|
7
6
|
private nativeId;
|
8
|
-
private onSize?;
|
9
7
|
private mapperId;
|
10
|
-
constructor(Skia: Skia, nativeId: number
|
8
|
+
constructor(Skia: Skia, nativeId: number);
|
11
9
|
redraw(): void;
|
12
10
|
}
|
13
|
-
export declare const createContainer: (Skia: Skia, nativeId: number
|
11
|
+
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | NativeReanimatedContainer;
|
14
12
|
export {};
|
@@ -8,12 +8,9 @@ import { Container, StaticContainer } from "./StaticContainer";
|
|
8
8
|
import { visit } from "./Recorder/Visitor";
|
9
9
|
import "../skia/NativeSetup";
|
10
10
|
import "../views/api";
|
11
|
-
const nativeDrawOnscreen = (nativeId, recorder
|
11
|
+
const nativeDrawOnscreen = (nativeId, recorder) => {
|
12
12
|
"worklet";
|
13
13
|
|
14
|
-
if (onSize) {
|
15
|
-
SkiaViewApi.setJsiProperty(nativeId, "onSize", onSize);
|
16
|
-
}
|
17
14
|
//const start = performance.now();
|
18
15
|
const picture = recorder.play();
|
19
16
|
//const end = performance.now();
|
@@ -21,10 +18,9 @@ const nativeDrawOnscreen = (nativeId, recorder, onSize) => {
|
|
21
18
|
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
|
22
19
|
};
|
23
20
|
class NativeReanimatedContainer extends Container {
|
24
|
-
constructor(Skia, nativeId
|
21
|
+
constructor(Skia, nativeId) {
|
25
22
|
super(Skia);
|
26
23
|
this.nativeId = nativeId;
|
27
|
-
this.onSize = onSize;
|
28
24
|
_defineProperty(this, "mapperId", null);
|
29
25
|
}
|
30
26
|
redraw() {
|
@@ -42,27 +38,24 @@ class NativeReanimatedContainer extends Container {
|
|
42
38
|
visit(recorder, this.root);
|
43
39
|
const sharedValues = recorder.getSharedValues();
|
44
40
|
const sharedRecorder = recorder.getRecorder();
|
45
|
-
Rea.runOnUI(
|
41
|
+
Rea.runOnUI(() => {
|
46
42
|
"worklet";
|
47
43
|
|
48
|
-
nativeDrawOnscreen(nativeId, sharedRecorder
|
49
|
-
})(
|
44
|
+
nativeDrawOnscreen(nativeId, sharedRecorder);
|
45
|
+
})();
|
50
46
|
if (sharedValues.length > 0) {
|
51
|
-
const {
|
52
|
-
onSize
|
53
|
-
} = this;
|
54
47
|
this.mapperId = Rea.startMapper(() => {
|
55
48
|
"worklet";
|
56
49
|
|
57
50
|
sharedRecorder.applyUpdates(sharedValues);
|
58
|
-
nativeDrawOnscreen(nativeId, sharedRecorder
|
51
|
+
nativeDrawOnscreen(nativeId, sharedRecorder);
|
59
52
|
}, sharedValues);
|
60
53
|
}
|
61
54
|
}
|
62
55
|
}
|
63
|
-
export const createContainer = (Skia, nativeId
|
56
|
+
export const createContainer = (Skia, nativeId) => {
|
64
57
|
if (HAS_REANIMATED_3 && nativeId !== -1) {
|
65
|
-
return new NativeReanimatedContainer(Skia, nativeId
|
58
|
+
return new NativeReanimatedContainer(Skia, nativeId);
|
66
59
|
} else {
|
67
60
|
return new StaticContainer(Skia, nativeId);
|
68
61
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","ReanimatedRecorder","Container","StaticContainer","visit","nativeDrawOnscreen","nativeId","recorder","
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","ReanimatedRecorder","Container","StaticContainer","visit","nativeDrawOnscreen","nativeId","recorder","picture","play","SkiaViewApi","setJsiProperty","NativeReanimatedContainer","constructor","Skia","_defineProperty","redraw","mapperId","stopMapper","unmounted","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {\n \"worklet\";\n\n //const start = performance.now();\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, private nativeId: number) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder);\n })();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,SAAS,EAAEC,eAAe,QAAQ,mBAAmB;AAC9D,SAASC,KAAK,QAAQ,oBAAoB;AAE1C,OAAO,qBAAqB;AAC5B,OAAO,cAAc;AAErB,MAAMC,kBAAkB,GAAGA,CAACC,QAAgB,EAAEC,QAAqB,KAAK;EACtE,SAAS;;EAET;EACA,MAAMC,OAAO,GAAGD,QAAQ,CAACE,IAAI,CAAC,CAAC;EAC/B;EACA;EACAC,WAAW,CAACC,cAAc,CAACL,QAAQ,EAAE,SAAS,EAAEE,OAAO,CAAC;AAC1D,CAAC;AAED,MAAMI,yBAAyB,SAASV,SAAS,CAAC;EAGhDW,WAAWA,CAACC,IAAU,EAAUR,QAAgB,EAAE;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AAER,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Skia, SkSize } from "../skia/types";
|
1
|
+
import type { Skia } from "../skia/types";
|
3
2
|
import { Container, StaticContainer } from "./StaticContainer";
|
4
3
|
import "../skia/NativeSetup";
|
5
4
|
import "../views/api";
|
@@ -9,5 +8,5 @@ declare class ReanimatedContainer extends Container {
|
|
9
8
|
constructor(Skia: Skia, nativeId: number);
|
10
9
|
redraw(): void;
|
11
10
|
}
|
12
|
-
export declare const createContainer: (Skia: Skia, nativeId: number
|
11
|
+
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | ReanimatedContainer;
|
13
12
|
export {};
|
@@ -66,7 +66,7 @@ class ReanimatedContainer extends Container {
|
|
66
66
|
})();
|
67
67
|
}
|
68
68
|
}
|
69
|
-
export const createContainer = (Skia, nativeId
|
69
|
+
export const createContainer = (Skia, nativeId) => {
|
70
70
|
if (HAS_REANIMATED_3 && nativeId !== -1) {
|
71
71
|
return new ReanimatedContainer(Skia, nativeId);
|
72
72
|
} else {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","ReanimatedContainer","constructor","_defineProperty","redraw","mapperId","stopMapper","unmounted","recorder","root","record","getRecording","animationValues","size","startMapper","Array","from","runOnUI","createContainer"
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","ReanimatedContainer","constructor","_defineProperty","redraw","mapperId","stopMapper","unmounted","recorder","root","record","getRecording","animationValues","size","startMapper","Array","from","runOnUI","createContainer"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, private nativeId: number) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n }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import type { SkCanvas, Skia } from "../skia/types";
|
4
3
|
import { NodeType } from "../dom/types";
|
5
4
|
import "./Elements";
|
6
5
|
export declare class SkiaSGRoot {
|
7
6
|
Skia: Skia;
|
8
7
|
private root;
|
9
8
|
private container;
|
10
|
-
constructor(Skia: Skia, nativeId?: number
|
9
|
+
constructor(Skia: Skia, nativeId?: number);
|
11
10
|
get sg(): {
|
12
11
|
type: NodeType;
|
13
12
|
props: {};
|
@@ -13,11 +13,11 @@ skiaReconciler.injectIntoDevTools({
|
|
13
13
|
rendererPackageName: "react-native-skia"
|
14
14
|
});
|
15
15
|
export class SkiaSGRoot {
|
16
|
-
constructor(Skia, nativeId = -1
|
16
|
+
constructor(Skia, nativeId = -1) {
|
17
17
|
this.Skia = Skia;
|
18
18
|
_defineProperty(this, "root", void 0);
|
19
19
|
_defineProperty(this, "container", void 0);
|
20
|
-
this.container = createContainer(Skia, nativeId
|
20
|
+
this.container = createContainer(Skia, nativeId);
|
21
21
|
this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
|
22
22
|
}
|
23
23
|
get sg() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","
|
1
|
+
{"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","console","error","sg","children","type","Group","props","isDeclaration","updateContainer","element","Promise","resolve","render","mount","redraw","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./StaticContainer\";\nimport { createContainer } from \"./Container\";\n\nimport \"./Elements\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = createContainer(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n private updateContainer(element: ReactNode) {\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n debug(\"updateContainer\");\n resolve(true);\n });\n });\n }\n\n async render(element: ReactNode) {\n this.container.mount();\n await this.updateContainer(element);\n this.container.redraw();\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n this.container.unmount();\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n resolve(true);\n });\n });\n }\n}\n"],"mappings":";;;AAEA,OAAOA,eAAe,MAAM,kBAAkB;AAG9C,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,EAAEC,cAAc,QAAQ,cAAc;AAEpD,SAASC,eAAe,QAAQ,aAAa;AAE7C,OAAO,YAAY;AAEnB,MAAMC,cAAc,GAAGL,eAAe,CAACG,cAAc,CAAC;AAEtDE,cAAc,CAACC,kBAAkB,CAAC;EAChCC,UAAU,EAAE,CAAC;EACbC,OAAO,EA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AAM,CAAC;EACrC;EAEAC,UAAUA,CAAA,EAAG;IACX,MAAMC,QAAQ,GAAG,IAAI,CAACvB,IAAI,CAACwB,eAAe,CAAC,CAAC;IAC5C,MAAMH,MAAM,GAAGE,QAAQ,CAACE,cAAc,CAAC,CAAC;IACxC,IAAI,CAACL,YAAY,CAACC,MAAM,CAAC;IACzB,OAAOE,QAAQ,CAACG,wBAAwB,CAAC,CAAC;EAC5C;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAACxB,SAAS,CAACwB,OAAO,CAAC,CAAC;IACxB,OAAO,IAAIZ,OAAO,CAAEC,OAAO,IAAK;MAC9BvB,cAAc,CAACoB,eAAe,CAAC,IAAI,EAAE,IAAI,CAACT,IAAI,EAAE,IAAI,EAAE,MAAM;QAC1Dd,KAAK,CAAC,kBAAkB,CAAC;QACzB0B,OAAO,CAAC,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
export const __esModule: boolean;
|
2
|
-
export function createContainer(Skia: any, nativeId: any
|
2
|
+
export function createContainer(Skia: any, nativeId: any): _StaticContainer.StaticContainer;
|
3
3
|
import _StaticContainer = require("./StaticContainer");
|
@@ -1,10 +1,9 @@
|
|
1
1
|
export const __esModule: boolean;
|
2
|
-
export function createContainer(Skia: any, nativeId: any
|
2
|
+
export function createContainer(Skia: any, nativeId: any): _StaticContainer.StaticContainer | NativeReanimatedContainer;
|
3
3
|
import _StaticContainer = require("./StaticContainer");
|
4
4
|
declare class NativeReanimatedContainer extends _StaticContainer.Container {
|
5
|
-
constructor(Skia: any, nativeId: any
|
5
|
+
constructor(Skia: any, nativeId: any);
|
6
6
|
nativeId: any;
|
7
|
-
onSize: any;
|
8
7
|
redraw(): void;
|
9
8
|
mapperId: any;
|
10
9
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export const __esModule: boolean;
|
2
|
-
export function createContainer(Skia: any, nativeId: any
|
2
|
+
export function createContainer(Skia: any, nativeId: any): _StaticContainer.StaticContainer | ReanimatedContainer;
|
3
3
|
import _StaticContainer = require("./StaticContainer");
|
4
4
|
declare class ReanimatedContainer extends _StaticContainer.Container {
|
5
5
|
constructor(Skia: any, nativeId: any);
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export function createContainer(Skia: any, nativeId: any
|
1
|
+
export function createContainer(Skia: any, nativeId: any): StaticContainer;
|
2
2
|
import { StaticContainer } from "./StaticContainer";
|
@@ -1,9 +1,8 @@
|
|
1
|
-
export function createContainer(Skia: any, nativeId: any
|
1
|
+
export function createContainer(Skia: any, nativeId: any): StaticContainer | NativeReanimatedContainer;
|
2
2
|
import { StaticContainer } from "./StaticContainer";
|
3
3
|
declare class NativeReanimatedContainer extends Container {
|
4
|
-
constructor(Skia: any, nativeId: any
|
4
|
+
constructor(Skia: any, nativeId: any);
|
5
5
|
nativeId: any;
|
6
|
-
onSize: any;
|
7
6
|
redraw(): void;
|
8
7
|
mapperId: any;
|
9
8
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export function createContainer(Skia: any, nativeId: any
|
1
|
+
export function createContainer(Skia: any, nativeId: any): StaticContainer | ReanimatedContainer;
|
2
2
|
import { StaticContainer } from "./StaticContainer";
|
3
3
|
declare class ReanimatedContainer extends Container {
|
4
4
|
constructor(Skia: any, nativeId: any);
|
@@ -5,7 +5,12 @@ type ESModule = {
|
|
5
5
|
__esModule: true;
|
6
6
|
default: string;
|
7
7
|
};
|
8
|
-
|
8
|
+
type MetroAsset = {
|
9
|
+
uri: string;
|
10
|
+
width: number;
|
11
|
+
height: number;
|
12
|
+
};
|
13
|
+
export type DataModule = RNModule | ESModule | MetroAsset;
|
9
14
|
export type DataSource = DataModule | string | Uint8Array;
|
10
15
|
export type DataSourceParam = DataSource | null | undefined;
|
11
16
|
export declare const isRNModule: (mod: DataModule) => mod is RNModule;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Skia, SkSize } from "../skia/types";
|
1
|
+
import type { Skia } from "../skia/types";
|
3
2
|
import { StaticContainer } from "./StaticContainer";
|
4
|
-
export declare const createContainer: (Skia: Skia, nativeId: number
|
3
|
+
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer;
|
@@ -1,14 +1,12 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Skia, SkSize } from "../skia/types";
|
1
|
+
import type { Skia } from "../skia/types";
|
3
2
|
import { Container, StaticContainer } from "./StaticContainer";
|
4
3
|
import "../skia/NativeSetup";
|
5
4
|
import "../views/api";
|
6
5
|
declare class NativeReanimatedContainer extends Container {
|
7
6
|
private nativeId;
|
8
|
-
private onSize?;
|
9
7
|
private mapperId;
|
10
|
-
constructor(Skia: Skia, nativeId: number
|
8
|
+
constructor(Skia: Skia, nativeId: number);
|
11
9
|
redraw(): void;
|
12
10
|
}
|
13
|
-
export declare const createContainer: (Skia: Skia, nativeId: number
|
11
|
+
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | NativeReanimatedContainer;
|
14
12
|
export {};
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Skia, SkSize } from "../skia/types";
|
1
|
+
import type { Skia } from "../skia/types";
|
3
2
|
import { Container, StaticContainer } from "./StaticContainer";
|
4
3
|
import "../skia/NativeSetup";
|
5
4
|
import "../views/api";
|
@@ -9,5 +8,5 @@ declare class ReanimatedContainer extends Container {
|
|
9
8
|
constructor(Skia: Skia, nativeId: number);
|
10
9
|
redraw(): void;
|
11
10
|
}
|
12
|
-
export declare const createContainer: (Skia: Skia, nativeId: number
|
11
|
+
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | ReanimatedContainer;
|
13
12
|
export {};
|
@@ -1,13 +1,12 @@
|
|
1
1
|
import type { ReactNode } from "react";
|
2
|
-
import type {
|
3
|
-
import type { SkCanvas, Skia, SkSize } from "../skia/types";
|
2
|
+
import type { SkCanvas, Skia } from "../skia/types";
|
4
3
|
import { NodeType } from "../dom/types";
|
5
4
|
import "./Elements";
|
6
5
|
export declare class SkiaSGRoot {
|
7
6
|
Skia: Skia;
|
8
7
|
private root;
|
9
8
|
private container;
|
10
|
-
constructor(Skia: Skia, nativeId?: number
|
9
|
+
constructor(Skia: Skia, nativeId?: number);
|
11
10
|
get sg(): {
|
12
11
|
type: NodeType;
|
13
12
|
props: {};
|
package/package.json
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
"setup-skia-web": "scripts/setup-canvaskit.js"
|
9
9
|
},
|
10
10
|
"title": "React Native Skia",
|
11
|
-
"version": "2.2.
|
11
|
+
"version": "2.2.15",
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
13
13
|
"main": "lib/module/index.js",
|
14
14
|
"react-native": "src/index.ts",
|
package/src/Platform/Platform.ts
CHANGED
@@ -15,8 +15,11 @@ export const Platform: IPlatform = {
|
|
15
15
|
OS: RNPlatform.OS,
|
16
16
|
PixelRatio: PixelRatio.get(),
|
17
17
|
resolveAsset: (source: DataModule) => {
|
18
|
+
// eslint-disable-next-line no-nested-ternary
|
18
19
|
return isRNModule(source)
|
19
20
|
? Image.resolveAssetSource(source).uri
|
21
|
+
: "uri" in source
|
22
|
+
? source.uri
|
20
23
|
: source.default;
|
21
24
|
},
|
22
25
|
findNodeHandle,
|