@shopify/react-native-skia 0.1.180 → 0.1.182
Sign up to get free protection for your applications and to get access to all the features.
- package/android/build.gradle +6 -1
- package/cpp/api/JsiSkData.h +7 -0
- package/cpp/api/JsiSkImage.h +7 -1
- package/cpp/api/JsiSkSVG.h +7 -0
- package/cpp/api/JsiSkTypeface.h +7 -0
- package/cpp/jsi/RuntimeAwareCache.cpp +0 -2
- package/cpp/rnskia/RNSkDomView.cpp +2 -2
- package/cpp/rnskia/RNSkPlatformContext.h +2 -2
- package/cpp/rnskia/dom/base/DerivedNodeProp.h +1 -1
- package/cpp/rnskia/dom/base/JsiDependencyManager.h +10 -6
- package/cpp/rnskia/dom/base/JsiDomNode.h +133 -78
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +17 -5
- package/cpp/rnskia/dom/base/NodeProp.h +5 -5
- package/cpp/rnskia/dom/base/NodePropsContainer.h +8 -2
- package/cpp/rnskia/dom/props/ClipProp.h +13 -20
- package/cpp/rnskia/dom/props/PathProp.h +16 -14
- package/cpp/rnskia/dom/props/PointProp.h +1 -1
- package/cpp/rnskia/dom/props/RRectProp.h +39 -61
- package/cpp/rnskia/dom/props/RectProp.h +27 -25
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +0 -2
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +56 -54
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +30 -9
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.d.ts +1 -0
- package/lib/commonjs/renderer/HostComponents.js +6 -1
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/Reconciler.js +3 -1
- package/lib/commonjs/renderer/Reconciler.js.map +1 -1
- package/lib/commonjs/skia/core/Data.d.ts +2 -2
- package/lib/commonjs/skia/core/Data.js +5 -0
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Data/Data.d.ts +2 -2
- package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Image/Image.d.ts +2 -2
- package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/JsiInstance.d.ts +3 -0
- package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
- package/lib/commonjs/skia/types/SVG/SVG.d.ts +2 -2
- package/lib/commonjs/skia/types/SVG/SVG.js.map +1 -1
- package/lib/commonjs/skia/types/Typeface/Typeface.d.ts +2 -2
- package/lib/commonjs/skia/types/Typeface/Typeface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkData.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkData.js +3 -0
- package/lib/commonjs/skia/web/JsiSkData.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImage.js +4 -0
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTypeface.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkTypeface.js +4 -0
- package/lib/commonjs/skia/web/JsiSkTypeface.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.js +5 -1
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +55 -54
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/renderer/Canvas.js +29 -10
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/HostComponents.d.ts +1 -0
- package/lib/module/renderer/HostComponents.js +3 -0
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/Reconciler.js +2 -1
- package/lib/module/renderer/Reconciler.js.map +1 -1
- package/lib/module/skia/core/Data.d.ts +2 -2
- package/lib/module/skia/core/Data.js +5 -0
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/types/Data/Data.d.ts +2 -2
- package/lib/module/skia/types/Data/Data.js.map +1 -1
- package/lib/module/skia/types/Image/Image.d.ts +2 -2
- package/lib/module/skia/types/Image/Image.js.map +1 -1
- package/lib/module/skia/types/JsiInstance.d.ts +3 -0
- package/lib/module/skia/types/JsiInstance.js.map +1 -1
- package/lib/module/skia/types/SVG/SVG.d.ts +2 -2
- package/lib/module/skia/types/SVG/SVG.js.map +1 -1
- package/lib/module/skia/types/Typeface/Typeface.d.ts +2 -2
- package/lib/module/skia/types/Typeface/Typeface.js.map +1 -1
- package/lib/module/skia/web/JsiSkData.d.ts +1 -0
- package/lib/module/skia/web/JsiSkData.js +3 -0
- package/lib/module/skia/web/JsiSkData.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImage.js +4 -0
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypeface.d.ts +1 -0
- package/lib/module/skia/web/JsiSkTypeface.js +4 -0
- package/lib/module/skia/web/JsiSkTypeface.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +5 -1
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/typescript/src/renderer/HostComponents.d.ts +1 -0
- package/lib/typescript/src/skia/core/Data.d.ts +2 -2
- package/lib/typescript/src/skia/types/Data/Data.d.ts +2 -2
- package/lib/typescript/src/skia/types/Image/Image.d.ts +2 -2
- package/lib/typescript/src/skia/types/JsiInstance.d.ts +3 -0
- package/lib/typescript/src/skia/types/SVG/SVG.d.ts +2 -2
- package/lib/typescript/src/skia/types/Typeface/Typeface.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkData.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkTypeface.d.ts +1 -0
- package/package.json +1 -1
- package/src/dom/nodes/JsiSkDOM.ts +55 -54
- package/src/renderer/Canvas.tsx +34 -14
- package/src/renderer/HostComponents.ts +4 -0
- package/src/renderer/Reconciler.tsx +2 -1
- package/src/skia/core/Data.ts +14 -6
- package/src/skia/types/Data/Data.ts +2 -2
- package/src/skia/types/Image/Image.ts +2 -2
- package/src/skia/types/JsiInstance.ts +4 -0
- package/src/skia/types/SVG/SVG.ts +2 -2
- package/src/skia/types/Typeface/Typeface.ts +2 -2
- package/src/skia/web/JsiSkData.ts +4 -0
- package/src/skia/web/JsiSkImage.ts +4 -0
- package/src/skia/web/JsiSkTypeface.ts +4 -0
- package/src/views/SkiaBaseWebView.tsx +5 -0
@@ -1,9 +1,11 @@
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
2
|
|
3
3
|
import React, { useEffect, useCallback, useMemo, forwardRef, useRef } from "react";
|
4
|
-
import { SkiaDomView } from "../views";
|
4
|
+
import { SkiaDomView, SkiaView } from "../views";
|
5
5
|
import { Skia } from "../skia/Skia";
|
6
|
+
import { JsiDrawingContext } from "../dom/types";
|
6
7
|
import { SkiaRoot } from "./Reconciler";
|
8
|
+
import { NATIVE_DOM } from "./HostComponents";
|
7
9
|
export const useCanvasRef = () => useRef(null);
|
8
10
|
export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
9
11
|
let {
|
@@ -45,15 +47,32 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
45
47
|
root.unmount();
|
46
48
|
};
|
47
49
|
}, [root]);
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
|
51
|
+
if (NATIVE_DOM) {
|
52
|
+
return /*#__PURE__*/React.createElement(SkiaDomView, _extends({
|
53
|
+
ref: ref,
|
54
|
+
style: style,
|
55
|
+
root: root.dom,
|
56
|
+
onTouch: onTouch,
|
57
|
+
onSize: onSize,
|
58
|
+
mode: mode,
|
59
|
+
debug: debug
|
60
|
+
}, props));
|
61
|
+
} else {
|
62
|
+
return /*#__PURE__*/React.createElement(SkiaView // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
63
|
+
, _extends({
|
64
|
+
ref: ref,
|
65
|
+
style: style,
|
66
|
+
mode: mode,
|
67
|
+
debug: debug,
|
68
|
+
onSize: onSize,
|
69
|
+
onDraw: (canvas, info) => {
|
70
|
+
onTouch && onTouch(info.touches);
|
71
|
+
const ctx = new JsiDrawingContext(Skia, canvas);
|
72
|
+
root.dom.render(ctx);
|
73
|
+
}
|
74
|
+
}, props));
|
75
|
+
}
|
57
76
|
});
|
58
77
|
/**
|
59
78
|
* Combines a list of refs into a single ref. This can be used to provide
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaRoot","useCanvasRef","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","current","getNativeId","id","nativeId","registerValues","values","root","render","unmount","dom","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n
|
1
|
+
{"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","SkiaView","Skia","JsiDrawingContext","SkiaRoot","NATIVE_DOM","useCanvasRef","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","current","getNativeId","id","nativeId","registerValues","values","root","render","unmount","dom","canvas","info","touches","ctx","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\n\nimport { SkiaDomView, SkiaView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n onSize={onSize}\n onDraw={(canvas, info) => {\n onTouch && onTouch(info.touches);\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n }}\n {...props}\n />\n );\n }\n }\n) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";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ACA;AACA;AACA;AACA;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAgB,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGzC,KAAK,CAACK,MAAN,CAAgB,IAAhB,CAAlB;EACAL,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpBuC,IAAI,CAACE,OAAL,CAAcnB,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACkB,SAAS,CAACf,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAce,SAAS,CAACf,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACc,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
|
@@ -8,6 +8,7 @@ import type { SkiaValue } from "../values";
|
|
8
8
|
import type { Container } from "./Container";
|
9
9
|
import type { SkiaProps } from "./processors";
|
10
10
|
import type { DependencyManager } from "./DependencyManager";
|
11
|
+
export declare const NATIVE_DOM: boolean;
|
11
12
|
declare global {
|
12
13
|
var SkiaDomApi: {
|
13
14
|
DependencyManager: (registerValues: (values: Array<SkiaValue<unknown>>) => () => void) => DependencyManager;
|
@@ -1,5 +1,8 @@
|
|
1
1
|
import { NodeType } from "../dom/types";
|
2
2
|
import { exhaustiveCheck } from "./typeddash";
|
3
|
+
// This flag should only be turned on for debugging/testing
|
4
|
+
const shouldUseJSDomOnNative = false;
|
5
|
+
export const NATIVE_DOM = shouldUseJSDomOnNative ? false : !!global.SkiaDomApi;
|
3
6
|
export const createNode = (container, type, props) => {
|
4
7
|
const {
|
5
8
|
Sk
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NodeType","exhaustiveCheck","createNode","container","type","props","Sk","Layer","Group","Paint","Fill","Image","Circle","Path","Drawing","CustomDrawing","Line","Oval","Patch","Points","Rect","RRect","Vertices","Text","TextPath","TextBlob","Glyphs","DiffRect","Picture","ImageSVG","BlurMaskFilter","BlendImageFilter","BlurImageFilter","OffsetImageFilter","DropShadowImageFilter","DisplacementMapImageFilter","MorphologyImageFilter","RuntimeShaderImageFilter","MatrixColorFilter","BlendColorFilter","LerpColorFilter","LumaColorFilter","LinearToSRGBGammaColorFilter","SRGBToLinearGammaColorFilter","Shader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","CornerPathEffect","DiscretePathEffect","DashPathEffect","Path1DPathEffect","Path2DPathEffect","SumPathEffect","Line2DPathEffect","Blend","BackdropFilter","Box","BoxShadow"],"sources":["HostComponents.ts"],"sourcesContent":["import { NodeType } from \"../dom/types\";\nimport type {\n DeclarationNode,\n FractalNoiseProps,\n RenderNode,\n CircleProps,\n DrawingNodeProps,\n ImageProps,\n PaintProps,\n PathProps,\n CustomDrawingNodeProps,\n LineProps,\n OvalProps,\n DiffRectProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextProps,\n VerticesProps,\n BlurMaskFilterProps,\n BlendImageFilterProps,\n BlurImageFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n MatrixColorFilterProps,\n ShaderProps,\n ImageShaderProps,\n LinearGradientProps,\n GroupProps,\n PatchProps,\n BlendColorFilterProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n CornerPathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n TwoPointConicalGradientProps,\n TurbulenceProps,\n SweepGradientProps,\n RadialGradientProps,\n ColorProps,\n PictureProps,\n ImageSVGProps,\n LerpColorFilterProps,\n BoxProps,\n BoxShadowProps,\n} from \"../dom/types\";\nimport type { ChildrenProps } from \"../dom/types/Common\";\nimport type {\n BlendProps,\n MorphologyImageFilterProps,\n} from \"../dom/types/ImageFilters\";\nimport type { SkRect, SkRRect } from \"../skia/types\";\nimport type { JsiDrawingNode } from \"../dom/nodes/DrawingNode\";\nimport type { SkiaValue } from \"../values\";\n\nimport type { Container } from \"./Container\";\nimport { exhaustiveCheck } from \"./typeddash\";\nimport type { SkiaProps } from \"./processors\";\nimport type { DependencyManager } from \"./DependencyManager\";\n\ndeclare global {\n var SkiaDomApi: {\n DependencyManager: (\n registerValues: (values: Array<SkiaValue<unknown>>) => () => void\n ) => DependencyManager;\n\n // FIXME: We need a better type for this\n RectNode: (props: RectProps) => JsiDrawingNode<RectProps, SkRect>;\n RRectNode: (\n props: RoundedRectProps\n ) => JsiDrawingNode<RoundedRectProps, SkRRect>;\n GroupNode: (props: GroupProps) => RenderNode<GroupProps>;\n PaintNode: (props: PaintProps) => DeclarationNode<PaintProps>;\n FillNode: (props: PaintProps) => RenderNode<PaintProps>;\n CircleNode: (props: CircleProps) => RenderNode<CircleProps>;\n PathNode: (props: PathProps) => RenderNode<PathProps>;\n CustomDrawingNode: (\n props: CustomDrawingNodeProps\n ) => RenderNode<CustomDrawingNodeProps>;\n LineNode: (props: LineProps) => RenderNode<LineProps>;\n ImageNode: (props: ImageProps) => RenderNode<ImageProps>;\n OvalNode: (props: OvalProps) => RenderNode<OvalProps>;\n PatchNode: (props: PatchProps) => RenderNode<PatchProps>;\n PointsNode: (props: PointsProps) => RenderNode<PointsProps>;\n DiffRectNode: (props: DiffRectProps) => RenderNode<DiffRectProps>;\n // Mask filters\n BlurMaskFilterNode: (\n props: BlurMaskFilterProps\n ) => DeclarationNode<BlurMaskFilterProps>;\n\n // Path effects\n DashPathEffectNode: (\n props: DashPathEffectProps\n ) => DeclarationNode<DashPathEffectProps>;\n DiscretePathEffectNode: (\n props: DiscretePathEffectProps\n ) => DeclarationNode<DiscretePathEffectProps>;\n CornerPathEffectNode: (\n props: CornerPathEffectProps\n ) => DeclarationNode<CornerPathEffectProps>;\n Path1DPathEffectNode: (\n props: Path1DPathEffectProps\n ) => DeclarationNode<Path1DPathEffectProps>;\n Path2DPathEffectNode: (\n props: Path2DPathEffectProps\n ) => DeclarationNode<Path2DPathEffectProps>;\n Line2DPathEffectNode: (\n props: Line2DPathEffectProps\n ) => DeclarationNode<Line2DPathEffectProps>;\n SumPathEffectNode: () => DeclarationNode<null>;\n\n // Image filters\n BlendImageFilterNode: (\n props: BlendImageFilterProps\n ) => DeclarationNode<BlendImageFilterProps>;\n DropShadowImageFilterNode: (\n props: DropShadowImageFilterProps\n ) => DeclarationNode<DropShadowImageFilterProps>;\n DisplacementMapImageFilterNode: (\n props: DisplacementMapImageFilterProps\n ) => DeclarationNode<DisplacementMapImageFilterProps>;\n BlurImageFilterNode: (\n props: BlurImageFilterProps\n ) => DeclarationNode<BlurImageFilterProps>;\n OffsetImageFilterNode: (\n props: OffsetImageFilterProps\n ) => DeclarationNode<OffsetImageFilterProps>;\n MorphologyImageFilterNode: (\n props: MorphologyImageFilterProps\n ) => DeclarationNode<MorphologyImageFilterProps>;\n RuntimeShaderImageFilterNode: (\n props: RuntimeShaderImageFilterProps\n ) => DeclarationNode<RuntimeShaderImageFilterProps>;\n\n // Color filters\n MatrixColorFilterNode: (\n props: MatrixColorFilterProps\n ) => DeclarationNode<MatrixColorFilterProps>;\n BlendColorFilterNode: (\n props: BlendColorFilterProps\n ) => DeclarationNode<BlendColorFilterProps>;\n LinearToSRGBGammaColorFilterNode: () => DeclarationNode<null>;\n SRGBToLinearGammaColorFilterNode: () => DeclarationNode<null>;\n LumaColorFilterNode: () => DeclarationNode<null>;\n LerpColorFilterNode: (\n props: LerpColorFilterProps\n ) => DeclarationNode<LerpColorFilterProps>;\n\n // Shaders\n ShaderNode: (props: ShaderProps) => DeclarationNode<ShaderProps>;\n ImageShaderNode: (\n props: ImageShaderProps\n ) => DeclarationNode<ImageShaderProps>;\n ColorShaderNode: (props: ColorProps) => DeclarationNode<ColorProps>;\n TurbulenceNode: (\n props: TurbulenceProps\n ) => DeclarationNode<TurbulenceProps>;\n FractalNoiseNode: (\n props: FractalNoiseProps\n ) => DeclarationNode<FractalNoiseProps>;\n LinearGradientNode: (\n props: LinearGradientProps\n ) => DeclarationNode<LinearGradientProps>;\n RadialGradientNode: (\n props: RadialGradientProps\n ) => DeclarationNode<RadialGradientProps>;\n SweepGradientNode: (\n props: SweepGradientProps\n ) => DeclarationNode<SweepGradientProps>;\n TwoPointConicalGradientNode: (\n props: TwoPointConicalGradientProps\n ) => DeclarationNode<TwoPointConicalGradientProps>;\n PictureNode: (props: PictureProps) => RenderNode<PictureProps>;\n ImageSVGNode: (props: ImageSVGProps) => RenderNode<ImageSVGProps>;\n VerticesNode: (props: VerticesProps) => RenderNode<VerticesProps>;\n TextNode: (prop: TextProps) => RenderNode<TextProps>;\n TextPathNode: (prop: TextPathProps) => RenderNode<TextPathProps>;\n TextBlobNode: (prop: TextBlobProps) => RenderNode<TextBlobProps>;\n GlyphsNode: (prop: GlyphsProps) => RenderNode<GlyphsProps>;\n BlendNode: (prop: BlendProps) => DeclarationNode<BlendProps>;\n BackdropFilterNode: (prop: ChildrenProps) => RenderNode<ChildrenProps>;\n BoxNode: (prop: BoxProps) => RenderNode<BoxProps>;\n BoxShadowNode: (prop: BoxShadowProps) => DeclarationNode<BoxShadowProps>;\n LayerNode: (prop: ChildrenProps) => RenderNode<ChildrenProps>;\n };\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n skGroup: SkiaProps<GroupProps>;\n skLayer: SkiaProps<ChildrenProps>;\n skPaint: SkiaProps<PaintProps>;\n\n // Drawings\n skFill: SkiaProps<DrawingNodeProps>;\n skImage: SkiaProps<ImageProps>;\n skCircle: SkiaProps<CircleProps>;\n skPath: SkiaProps<PathProps>;\n skDrawing: SkiaProps<CustomDrawingNodeProps>;\n skLine: SkiaProps<LineProps>;\n skOval: SkiaProps<OvalProps>;\n skPatch: SkiaProps<PatchProps>;\n skPoints: SkiaProps<PointsProps>;\n skRect: SkiaProps<RectProps>;\n skRRect: SkiaProps<RoundedRectProps>;\n skVertices: SkiaProps<VerticesProps>;\n skText: SkiaProps<TextProps>;\n skTextPath: SkiaProps<TextPathProps>;\n skTextBlob: SkiaProps<TextBlobProps>;\n skGlyphs: SkiaProps<GlyphsProps>;\n skDiffRect: SkiaProps<DiffRectProps>;\n skPicture: SkiaProps<PictureProps>;\n skImageSVG: SkiaProps<ImageSVGProps>;\n\n // BlurMaskFilters\n skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;\n\n // ImageFilters\n skBlendImageFilter: SkiaProps<BlendImageFilterProps>;\n skBlurImageFilter: SkiaProps<BlurImageFilterProps>;\n skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;\n skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;\n skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;\n skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;\n skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;\n\n // ColorFilters\n skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;\n skBlendColorFilter: SkiaProps<BlendColorFilterProps>;\n skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;\n skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;\n skLumaColorFilter: SkiaProps<ChildrenProps>;\n skLerpColorFilter: SkiaProps<LerpColorFilterProps>;\n\n // Shaders\n skShader: SkiaProps<ShaderProps>;\n skImageShader: SkiaProps<ImageShaderProps>;\n skColorShader: SkiaProps<ColorProps>;\n skTurbulence: SkiaProps<TurbulenceProps>;\n skFractalNoise: SkiaProps<FractalNoiseProps>;\n skLinearGradient: SkiaProps<LinearGradientProps>;\n skRadialGradient: SkiaProps<RadialGradientProps>;\n skSweepGradient: SkiaProps<SweepGradientProps>;\n skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;\n\n // Path Effects\n skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;\n skDashPathEffect: SkiaProps<DashPathEffectProps>;\n skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;\n skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;\n skCornerPathEffect: SkiaProps<CornerPathEffectProps>;\n skSumPathEffect: ChildrenProps;\n skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;\n\n // Mixed declarations/drawings\n skBlend: SkiaProps<BlendProps>;\n skBackdropFilter: SkiaProps<ChildrenProps>;\n skBox: SkiaProps<BoxProps>;\n skBoxShadow: SkiaProps<BoxShadowProps>;\n }\n }\n}\n\nexport const createNode = (\n container: Container,\n type: NodeType,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: any\n) => {\n const { Sk } = container;\n switch (type) {\n case NodeType.Layer:\n return Sk.Layer(props);\n case NodeType.Group:\n return Sk.Group(props);\n case NodeType.Paint:\n return Sk.Paint(props);\n // Drawings\n case NodeType.Fill:\n return Sk.Fill(props);\n case NodeType.Image:\n return Sk.Image(props);\n case NodeType.Circle:\n return Sk.Circle(props);\n case NodeType.Path:\n return Sk.Path(props);\n case NodeType.Drawing:\n return Sk.CustomDrawing(props);\n case NodeType.Line:\n return Sk.Line(props);\n case NodeType.Oval:\n return Sk.Oval(props);\n case NodeType.Patch:\n return Sk.Patch(props);\n case NodeType.Points:\n return Sk.Points(props);\n case NodeType.Rect:\n return Sk.Rect(props);\n case NodeType.RRect:\n return Sk.RRect(props);\n case NodeType.Vertices:\n return Sk.Vertices(props);\n case NodeType.Text:\n return Sk.Text(props);\n case NodeType.TextPath:\n return Sk.TextPath(props);\n case NodeType.TextBlob:\n return Sk.TextBlob(props);\n case NodeType.Glyphs:\n return Sk.Glyphs(props);\n case NodeType.DiffRect:\n return Sk.DiffRect(props);\n case NodeType.Picture:\n return Sk.Picture(props);\n case NodeType.ImageSVG:\n return Sk.ImageSVG(props);\n // Mask Filter\n case NodeType.BlurMaskFilter:\n return Sk.BlurMaskFilter(props);\n // Image Filter\n case NodeType.BlendImageFilter:\n return Sk.BlendImageFilter(props);\n case NodeType.BlurImageFilter:\n return Sk.BlurImageFilter(props);\n case NodeType.OffsetImageFilter:\n return Sk.OffsetImageFilter(props);\n case NodeType.DropShadowImageFilter:\n return Sk.DropShadowImageFilter(props);\n case NodeType.DisplacementMapImageFilter:\n return Sk.DisplacementMapImageFilter(props);\n case NodeType.MorphologyImageFilter:\n return Sk.MorphologyImageFilter(props);\n case NodeType.RuntimeShaderImageFilter:\n return Sk.RuntimeShaderImageFilter(props);\n // Color Filter\n case NodeType.MatrixColorFilter:\n return Sk.MatrixColorFilter(props);\n case NodeType.BlendColorFilter:\n return Sk.BlendColorFilter(props);\n case NodeType.LerpColorFilter:\n return Sk.LerpColorFilter(props);\n case NodeType.LumaColorFilter:\n return Sk.LumaColorFilter();\n case NodeType.LinearToSRGBGammaColorFilter:\n return Sk.LinearToSRGBGammaColorFilter();\n case NodeType.SRGBToLinearGammaColorFilter:\n return Sk.SRGBToLinearGammaColorFilter();\n // Shader\n case NodeType.Shader:\n return Sk.Shader(props);\n case NodeType.ImageShader:\n return Sk.ImageShader(props);\n case NodeType.ColorShader:\n return Sk.ColorShader(props);\n case NodeType.Turbulence:\n return Sk.Turbulence(props);\n case NodeType.FractalNoise:\n return Sk.FractalNoise(props);\n case NodeType.LinearGradient:\n return Sk.LinearGradient(props);\n case NodeType.RadialGradient:\n return Sk.RadialGradient(props);\n case NodeType.SweepGradient:\n return Sk.SweepGradient(props);\n case NodeType.TwoPointConicalGradient:\n return Sk.TwoPointConicalGradient(props);\n // Path Effect\n case NodeType.CornerPathEffect:\n return Sk.CornerPathEffect(props);\n case NodeType.DiscretePathEffect:\n return Sk.DiscretePathEffect(props);\n case NodeType.DashPathEffect:\n return Sk.DashPathEffect(props);\n case NodeType.Path1DPathEffect:\n return Sk.Path1DPathEffect(props);\n case NodeType.Path2DPathEffect:\n return Sk.Path2DPathEffect(props);\n case NodeType.SumPathEffect:\n return Sk.SumPathEffect();\n case NodeType.Line2DPathEffect:\n return Sk.Line2DPathEffect(props);\n // Mixed\n case NodeType.Blend:\n return Sk.Blend(props);\n case NodeType.BackdropFilter:\n return Sk.BackdropFilter(props);\n case NodeType.Box:\n return Sk.Box(props);\n case NodeType.BoxShadow:\n return Sk.BoxShadow(props);\n default:\n return exhaustiveCheck(type);\n }\n};\n"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AA+DA,SAASC,eAAT,QAAgC,aAAhC;AA+MA,OAAO,MAAMC,UAAU,GAAG,CACxBC,SADwB,EAExBC,IAFwB,EAIxBC,KAJwB,KAKrB;EACH,MAAM;IAAEC;EAAF,IAASH,SAAf;;EACA,QAAQC,IAAR;IACE,KAAKJ,QAAQ,CAACO,KAAd;MACE,OAAOD,EAAE,CAACC,KAAH,CAASF,KAAT,CAAP;;IACF,KAAKL,QAAQ,CAACQ,KAAd;MACE,OAAOF,EAAE,CAACE,KAAH,CAASH,KAAT,CAAP;;IACF,KAAKL,QAAQ,CAACS,KAAd;MACE,OAAOH,EAAE,CAACG,KAAH,CAASJ,KAAT,CAAP;IACF;;IACA,KAAKL,QAAQ,CAACU,IAAd;MACE,OAAOJ,EAAE,CAACI,IAAH,CAAQL,KAAR,CAAP;;IACF,KAAKL,QAAQ,CAACW,KAAd;MACE,OAAOL,EAAE,CAACK,KAAH,CAASN,KAAT,CAAP;;IACF,KAAKL,QAAQ,CAACY,MAAd;MACE,OAAON,EAAE,CAACM,MAAH,CAAUP,KAAV,CAAP;;IACF,KAAKL,QAAQ,CAACa,IAAd;MACE,OAAOP,EAAE,CAACO,IAAH,CAAQR,KAAR,CAAP;;IACF,KAAKL,QAAQ,CAACc,OAAd;MACE,OAAOR,EAAE,CAACS,aAAH,CAAiBV,KAAjB,CAAP;;IACF,KAAKL,QAAQ,CAACgB,IAAd;MACE,OAAOV,EAAE,CAACU,IAAH,CAAQX,KAAR,CAAP;;IACF,KAAKL,QAAQ,CAACiB,IAAd;MACE,OAAOX,EAAE,CAACW,IAAH,CAAQZ,KAAR,CAAP;;IACF,KAAKL,QAAQ,CAACkB,KAAd;MACE,OAAO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AC4D,KAAd;MACE,OAAOtD,EAAE,CAACsD,KAAH,CAASvD,KAAT,CAAP;;IACF,KAAKL,QAAQ,CAAC6D,cAAd;MACE,OAAOvD,EAAE,CAACuD,cAAH,CAAkBxD,KAAlB,CAAP;;IACF,KAAKL,QAAQ,CAAC8D,GAAd;MACE,OAAOxD,EAAE,CAACwD,GAAH,CAAOzD,KAAP,CAAP;;IACF,KAAKL,QAAQ,CAAC+D,SAAd;MACE,OAAOzD,EAAE,CAACyD,SAAH,CAAa1D,KAAb,CAAP;;IACF;MACE,OAAOJ,eAAe,CAACG,IAAD,CAAtB;EAzHJ;AA2HD,CAlIM"}
|
1
|
+
{"version":3,"names":["NodeType","exhaustiveCheck","shouldUseJSDomOnNative","NATIVE_DOM","global","SkiaDomApi","createNode","container","type","props","Sk","Layer","Group","Paint","Fill","Image","Circle","Path","Drawing","CustomDrawing","Line","Oval","Patch","Points","Rect","RRect","Vertices","Text","TextPath","TextBlob","Glyphs","DiffRect","Picture","ImageSVG","BlurMaskFilter","BlendImageFilter","BlurImageFilter","OffsetImageFilter","DropShadowImageFilter","DisplacementMapImageFilter","MorphologyImageFilter","RuntimeShaderImageFilter","MatrixColorFilter","BlendColorFilter","LerpColorFilter","LumaColorFilter","LinearToSRGBGammaColorFilter","SRGBToLinearGammaColorFilter","Shader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","CornerPathEffect","DiscretePathEffect","DashPathEffect","Path1DPathEffect","Path2DPathEffect","SumPathEffect","Line2DPathEffect","Blend","BackdropFilter","Box","BoxShadow"],"sources":["HostComponents.ts"],"sourcesContent":["import { NodeType } from \"../dom/types\";\nimport type {\n DeclarationNode,\n FractalNoiseProps,\n RenderNode,\n CircleProps,\n DrawingNodeProps,\n ImageProps,\n PaintProps,\n PathProps,\n CustomDrawingNodeProps,\n LineProps,\n OvalProps,\n DiffRectProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextProps,\n VerticesProps,\n BlurMaskFilterProps,\n BlendImageFilterProps,\n BlurImageFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n MatrixColorFilterProps,\n ShaderProps,\n ImageShaderProps,\n LinearGradientProps,\n GroupProps,\n PatchProps,\n BlendColorFilterProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n CornerPathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n TwoPointConicalGradientProps,\n TurbulenceProps,\n SweepGradientProps,\n RadialGradientProps,\n ColorProps,\n PictureProps,\n ImageSVGProps,\n LerpColorFilterProps,\n BoxProps,\n BoxShadowProps,\n} from \"../dom/types\";\nimport type { ChildrenProps } from \"../dom/types/Common\";\nimport type {\n BlendProps,\n MorphologyImageFilterProps,\n} from \"../dom/types/ImageFilters\";\nimport type { SkRect, SkRRect } from \"../skia/types\";\nimport type { JsiDrawingNode } from \"../dom/nodes/DrawingNode\";\nimport type { SkiaValue } from \"../values\";\n\nimport type { Container } from \"./Container\";\nimport { exhaustiveCheck } from \"./typeddash\";\nimport type { SkiaProps } from \"./processors\";\nimport type { DependencyManager } from \"./DependencyManager\";\n\n// This flag should only be turned on for debugging/testing\nconst shouldUseJSDomOnNative = false;\nexport const NATIVE_DOM = shouldUseJSDomOnNative ? false : !!global.SkiaDomApi;\n\ndeclare global {\n var SkiaDomApi: {\n DependencyManager: (\n registerValues: (values: Array<SkiaValue<unknown>>) => () => void\n ) => DependencyManager;\n\n // FIXME: We need a better type for this\n RectNode: (props: RectProps) => JsiDrawingNode<RectProps, SkRect>;\n RRectNode: (\n props: RoundedRectProps\n ) => JsiDrawingNode<RoundedRectProps, SkRRect>;\n GroupNode: (props: GroupProps) => RenderNode<GroupProps>;\n PaintNode: (props: PaintProps) => DeclarationNode<PaintProps>;\n FillNode: (props: PaintProps) => RenderNode<PaintProps>;\n CircleNode: (props: CircleProps) => RenderNode<CircleProps>;\n PathNode: (props: PathProps) => RenderNode<PathProps>;\n CustomDrawingNode: (\n props: CustomDrawingNodeProps\n ) => RenderNode<CustomDrawingNodeProps>;\n LineNode: (props: LineProps) => RenderNode<LineProps>;\n ImageNode: (props: ImageProps) => RenderNode<ImageProps>;\n OvalNode: (props: OvalProps) => RenderNode<OvalProps>;\n PatchNode: (props: PatchProps) => RenderNode<PatchProps>;\n PointsNode: (props: PointsProps) => RenderNode<PointsProps>;\n DiffRectNode: (props: DiffRectProps) => RenderNode<DiffRectProps>;\n // Mask filters\n BlurMaskFilterNode: (\n props: BlurMaskFilterProps\n ) => DeclarationNode<BlurMaskFilterProps>;\n\n // Path effects\n DashPathEffectNode: (\n props: DashPathEffectProps\n ) => DeclarationNode<DashPathEffectProps>;\n DiscretePathEffectNode: (\n props: DiscretePathEffectProps\n ) => DeclarationNode<DiscretePathEffectProps>;\n CornerPathEffectNode: (\n props: CornerPathEffectProps\n ) => DeclarationNode<CornerPathEffectProps>;\n Path1DPathEffectNode: (\n props: Path1DPathEffectProps\n ) => DeclarationNode<Path1DPathEffectProps>;\n Path2DPathEffectNode: (\n props: Path2DPathEffectProps\n ) => DeclarationNode<Path2DPathEffectProps>;\n Line2DPathEffectNode: (\n props: Line2DPathEffectProps\n ) => DeclarationNode<Line2DPathEffectProps>;\n SumPathEffectNode: () => DeclarationNode<null>;\n\n // Image filters\n BlendImageFilterNode: (\n props: BlendImageFilterProps\n ) => DeclarationNode<BlendImageFilterProps>;\n DropShadowImageFilterNode: (\n props: DropShadowImageFilterProps\n ) => DeclarationNode<DropShadowImageFilterProps>;\n DisplacementMapImageFilterNode: (\n props: DisplacementMapImageFilterProps\n ) => DeclarationNode<DisplacementMapImageFilterProps>;\n BlurImageFilterNode: (\n props: BlurImageFilterProps\n ) => DeclarationNode<BlurImageFilterProps>;\n OffsetImageFilterNode: (\n props: OffsetImageFilterProps\n ) => DeclarationNode<OffsetImageFilterProps>;\n MorphologyImageFilterNode: (\n props: MorphologyImageFilterProps\n ) => DeclarationNode<MorphologyImageFilterProps>;\n RuntimeShaderImageFilterNode: (\n props: RuntimeShaderImageFilterProps\n ) => DeclarationNode<RuntimeShaderImageFilterProps>;\n\n // Color filters\n MatrixColorFilterNode: (\n props: MatrixColorFilterProps\n ) => DeclarationNode<MatrixColorFilterProps>;\n BlendColorFilterNode: (\n props: BlendColorFilterProps\n ) => DeclarationNode<BlendColorFilterProps>;\n LinearToSRGBGammaColorFilterNode: () => DeclarationNode<null>;\n SRGBToLinearGammaColorFilterNode: () => DeclarationNode<null>;\n LumaColorFilterNode: () => DeclarationNode<null>;\n LerpColorFilterNode: (\n props: LerpColorFilterProps\n ) => DeclarationNode<LerpColorFilterProps>;\n\n // Shaders\n ShaderNode: (props: ShaderProps) => DeclarationNode<ShaderProps>;\n ImageShaderNode: (\n props: ImageShaderProps\n ) => DeclarationNode<ImageShaderProps>;\n ColorShaderNode: (props: ColorProps) => DeclarationNode<ColorProps>;\n TurbulenceNode: (\n props: TurbulenceProps\n ) => DeclarationNode<TurbulenceProps>;\n FractalNoiseNode: (\n props: FractalNoiseProps\n ) => DeclarationNode<FractalNoiseProps>;\n LinearGradientNode: (\n props: LinearGradientProps\n ) => DeclarationNode<LinearGradientProps>;\n RadialGradientNode: (\n props: RadialGradientProps\n ) => DeclarationNode<RadialGradientProps>;\n SweepGradientNode: (\n props: SweepGradientProps\n ) => DeclarationNode<SweepGradientProps>;\n TwoPointConicalGradientNode: (\n props: TwoPointConicalGradientProps\n ) => DeclarationNode<TwoPointConicalGradientProps>;\n PictureNode: (props: PictureProps) => RenderNode<PictureProps>;\n ImageSVGNode: (props: ImageSVGProps) => RenderNode<ImageSVGProps>;\n VerticesNode: (props: VerticesProps) => RenderNode<VerticesProps>;\n TextNode: (prop: TextProps) => RenderNode<TextProps>;\n TextPathNode: (prop: TextPathProps) => RenderNode<TextPathProps>;\n TextBlobNode: (prop: TextBlobProps) => RenderNode<TextBlobProps>;\n GlyphsNode: (prop: GlyphsProps) => RenderNode<GlyphsProps>;\n BlendNode: (prop: BlendProps) => DeclarationNode<BlendProps>;\n BackdropFilterNode: (prop: ChildrenProps) => RenderNode<ChildrenProps>;\n BoxNode: (prop: BoxProps) => RenderNode<BoxProps>;\n BoxShadowNode: (prop: BoxShadowProps) => DeclarationNode<BoxShadowProps>;\n LayerNode: (prop: ChildrenProps) => RenderNode<ChildrenProps>;\n };\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n skGroup: SkiaProps<GroupProps>;\n skLayer: SkiaProps<ChildrenProps>;\n skPaint: SkiaProps<PaintProps>;\n\n // Drawings\n skFill: SkiaProps<DrawingNodeProps>;\n skImage: SkiaProps<ImageProps>;\n skCircle: SkiaProps<CircleProps>;\n skPath: SkiaProps<PathProps>;\n skDrawing: SkiaProps<CustomDrawingNodeProps>;\n skLine: SkiaProps<LineProps>;\n skOval: SkiaProps<OvalProps>;\n skPatch: SkiaProps<PatchProps>;\n skPoints: SkiaProps<PointsProps>;\n skRect: SkiaProps<RectProps>;\n skRRect: SkiaProps<RoundedRectProps>;\n skVertices: SkiaProps<VerticesProps>;\n skText: SkiaProps<TextProps>;\n skTextPath: SkiaProps<TextPathProps>;\n skTextBlob: SkiaProps<TextBlobProps>;\n skGlyphs: SkiaProps<GlyphsProps>;\n skDiffRect: SkiaProps<DiffRectProps>;\n skPicture: SkiaProps<PictureProps>;\n skImageSVG: SkiaProps<ImageSVGProps>;\n\n // BlurMaskFilters\n skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;\n\n // ImageFilters\n skBlendImageFilter: SkiaProps<BlendImageFilterProps>;\n skBlurImageFilter: SkiaProps<BlurImageFilterProps>;\n skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;\n skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;\n skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;\n skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;\n skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;\n\n // ColorFilters\n skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;\n skBlendColorFilter: SkiaProps<BlendColorFilterProps>;\n skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;\n skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;\n skLumaColorFilter: SkiaProps<ChildrenProps>;\n skLerpColorFilter: SkiaProps<LerpColorFilterProps>;\n\n // Shaders\n skShader: SkiaProps<ShaderProps>;\n skImageShader: SkiaProps<ImageShaderProps>;\n skColorShader: SkiaProps<ColorProps>;\n skTurbulence: SkiaProps<TurbulenceProps>;\n skFractalNoise: SkiaProps<FractalNoiseProps>;\n skLinearGradient: SkiaProps<LinearGradientProps>;\n skRadialGradient: SkiaProps<RadialGradientProps>;\n skSweepGradient: SkiaProps<SweepGradientProps>;\n skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;\n\n // Path Effects\n skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;\n skDashPathEffect: SkiaProps<DashPathEffectProps>;\n skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;\n skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;\n skCornerPathEffect: SkiaProps<CornerPathEffectProps>;\n skSumPathEffect: ChildrenProps;\n skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;\n\n // Mixed declarations/drawings\n skBlend: SkiaProps<BlendProps>;\n skBackdropFilter: SkiaProps<ChildrenProps>;\n skBox: SkiaProps<BoxProps>;\n skBoxShadow: SkiaProps<BoxShadowProps>;\n }\n }\n}\n\nexport const createNode = (\n container: Container,\n type: NodeType,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: any\n) => {\n const { Sk } = container;\n switch (type) {\n case NodeType.Layer:\n return Sk.Layer(props);\n case NodeType.Group:\n return Sk.Group(props);\n case NodeType.Paint:\n return Sk.Paint(props);\n // Drawings\n case NodeType.Fill:\n return Sk.Fill(props);\n case NodeType.Image:\n return Sk.Image(props);\n case NodeType.Circle:\n return Sk.Circle(props);\n case NodeType.Path:\n return Sk.Path(props);\n case NodeType.Drawing:\n return Sk.CustomDrawing(props);\n case NodeType.Line:\n return Sk.Line(props);\n case NodeType.Oval:\n return Sk.Oval(props);\n case NodeType.Patch:\n return Sk.Patch(props);\n case NodeType.Points:\n return Sk.Points(props);\n case NodeType.Rect:\n return Sk.Rect(props);\n case NodeType.RRect:\n return Sk.RRect(props);\n case NodeType.Vertices:\n return Sk.Vertices(props);\n case NodeType.Text:\n return Sk.Text(props);\n case NodeType.TextPath:\n return Sk.TextPath(props);\n case NodeType.TextBlob:\n return Sk.TextBlob(props);\n case NodeType.Glyphs:\n return Sk.Glyphs(props);\n case NodeType.DiffRect:\n return Sk.DiffRect(props);\n case NodeType.Picture:\n return Sk.Picture(props);\n case NodeType.ImageSVG:\n return Sk.ImageSVG(props);\n // Mask Filter\n case NodeType.BlurMaskFilter:\n return Sk.BlurMaskFilter(props);\n // Image Filter\n case NodeType.BlendImageFilter:\n return Sk.BlendImageFilter(props);\n case NodeType.BlurImageFilter:\n return Sk.BlurImageFilter(props);\n case NodeType.OffsetImageFilter:\n return Sk.OffsetImageFilter(props);\n case NodeType.DropShadowImageFilter:\n return Sk.DropShadowImageFilter(props);\n case NodeType.DisplacementMapImageFilter:\n return Sk.DisplacementMapImageFilter(props);\n case NodeType.MorphologyImageFilter:\n return Sk.MorphologyImageFilter(props);\n case NodeType.RuntimeShaderImageFilter:\n return Sk.RuntimeShaderImageFilter(props);\n // Color Filter\n case NodeType.MatrixColorFilter:\n return Sk.MatrixColorFilter(props);\n case NodeType.BlendColorFilter:\n return Sk.BlendColorFilter(props);\n case NodeType.LerpColorFilter:\n return Sk.LerpColorFilter(props);\n case NodeType.LumaColorFilter:\n return Sk.LumaColorFilter();\n case NodeType.LinearToSRGBGammaColorFilter:\n return Sk.LinearToSRGBGammaColorFilter();\n case NodeType.SRGBToLinearGammaColorFilter:\n return Sk.SRGBToLinearGammaColorFilter();\n // Shader\n case NodeType.Shader:\n return Sk.Shader(props);\n case NodeType.ImageShader:\n return Sk.ImageShader(props);\n case NodeType.ColorShader:\n return Sk.ColorShader(props);\n case NodeType.Turbulence:\n return Sk.Turbulence(props);\n case NodeType.FractalNoise:\n return Sk.FractalNoise(props);\n case NodeType.LinearGradient:\n return Sk.LinearGradient(props);\n case NodeType.RadialGradient:\n return Sk.RadialGradient(props);\n case NodeType.SweepGradient:\n return Sk.SweepGradient(props);\n case NodeType.TwoPointConicalGradient:\n return Sk.TwoPointConicalGradient(props);\n // Path Effect\n case NodeType.CornerPathEffect:\n return Sk.CornerPathEffect(props);\n case NodeType.DiscretePathEffect:\n return Sk.DiscretePathEffect(props);\n case NodeType.DashPathEffect:\n return Sk.DashPathEffect(props);\n case NodeType.Path1DPathEffect:\n return Sk.Path1DPathEffect(props);\n case NodeType.Path2DPathEffect:\n return Sk.Path2DPathEffect(props);\n case NodeType.SumPathEffect:\n return Sk.SumPathEffect();\n case NodeType.Line2DPathEffect:\n return Sk.Line2DPathEffect(props);\n // Mixed\n case NodeType.Blend:\n return Sk.Blend(props);\n case NodeType.BackdropFilter:\n return Sk.BackdropFilter(props);\n case NodeType.Box:\n return Sk.Box(props);\n case NodeType.BoxShadow:\n return Sk.BoxShadow(props);\n default:\n return exhaustiveCheck(type);\n }\n};\n"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AA+DA,SAASC,eAAT,QAAgC,aAAhC;AAIA;AACA,MAAMC,sBAAsB,GAAG,KAA/B;AACA,OAAO,MAAMC,UAAU,GAAGD,sBAAsB,GAAG,KAAH,GAAW,CAAC,CAACE,MAAM,CAACC,UAA7D;AA6MP,OAAO,MAAMC,UAAU,GAAG,CACxBC,SADwB,EAExBC,IAFwB,EAIxBC,KAJwB,KAKrB;EACH,MAAM;IAAEC;EAAF,IAASH,SAAf;;EACA,QAAQC,IAAR;IACE,KAAKR,QAAQ,CAACW,KAAd;M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M"}
|
@@ -4,9 +4,10 @@ import ReactReconciler from "react-reconciler";
|
|
4
4
|
import { DependencyManager } from "./DependencyManager";
|
5
5
|
import { skHostConfig, debug as hostDebug } from "./HostConfig";
|
6
6
|
import { Container } from "./Container";
|
7
|
+
import { NATIVE_DOM } from "./HostComponents";
|
7
8
|
const skiaReconciler = ReactReconciler(skHostConfig);
|
8
9
|
|
9
|
-
const createDependencyManager = registerValues =>
|
10
|
+
const createDependencyManager = registerValues => NATIVE_DOM ? global.SkiaDomApi.DependencyManager(registerValues) : new DependencyManager(registerValues);
|
10
11
|
|
11
12
|
skiaReconciler.injectIntoDevTools({
|
12
13
|
bundleType: 1,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ReactReconciler","DependencyManager","skHostConfig","debug","hostDebug","Container","skiaReconciler","createDependencyManager","registerValues","global","SkiaDomApi","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","getNativeId","depMgr","container","root","createContainer","console","error","render","element","updateContainer","unmount","remove","dom"],"sources":["Reconciler.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { Skia } from \"../skia/types\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { DependencyManager } from \"./DependencyManager\";\nimport { skHostConfig, debug as hostDebug } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(skHostConfig);\n\ntype RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;\n\nconst createDependencyManager = (registerValues: RegisterValues) =>\n
|
1
|
+
{"version":3,"names":["ReactReconciler","DependencyManager","skHostConfig","debug","hostDebug","Container","NATIVE_DOM","skiaReconciler","createDependencyManager","registerValues","global","SkiaDomApi","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","getNativeId","depMgr","container","root","createContainer","console","error","render","element","updateContainer","unmount","remove","dom"],"sources":["Reconciler.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { Skia } from \"../skia/types\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { DependencyManager } from \"./DependencyManager\";\nimport { skHostConfig, debug as hostDebug } from \"./HostConfig\";\nimport { Container } from \"./Container\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nconst skiaReconciler = ReactReconciler(skHostConfig);\n\ntype RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;\n\nconst createDependencyManager = (registerValues: RegisterValues) =>\n NATIVE_DOM\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(\n Skia: Skia,\n registerValues: RegisterValues = () => () => {},\n redraw: () => void = () => {},\n getNativeId: () => number = () => 0\n ) {\n const depMgr = createDependencyManager(registerValues);\n this.container = new Container(Skia, depMgr, redraw, getNativeId);\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 render(element: ReactNode) {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n hostDebug(\"updateContainer\");\n });\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n this.container.depMgr.remove();\n });\n }\n\n get dom() {\n return this.container.root;\n }\n}\n"],"mappings":";;AAEA,OAAOA,eAAP,MAA4B,kBAA5B;AAKA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,YAAT,EAAuBC,KAAK,IAAIC,SAAhC,QAAiD,cAAjD;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,UAAT,QAA2B,kBAA3B;AAEA,MAAMC,cAAc,GAAGP,eAAe,CAACE,YAAD,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AL,CAAeC,IAAtB;EACD;;AAtCmB"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import type { SkData, DataSourceParam } from "../types";
|
2
|
-
export declare const useRawData: <T>(source: DataSourceParam, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined) => T | null;
|
1
|
+
import type { SkData, DataSourceParam, JsiDisposable } from "../types";
|
2
|
+
export declare const useRawData: <T extends JsiDisposable>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: ((err: Error) => void) | undefined) => T | null;
|
3
3
|
export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
|
@@ -32,14 +32,19 @@ const loadData = (source, factory, onError) => {
|
|
32
32
|
const useLoading = (source, loader) => {
|
33
33
|
const mounted = useRef(false);
|
34
34
|
const [data, setData] = useState(null);
|
35
|
+
const dataRef = useRef(null);
|
35
36
|
useEffect(() => {
|
36
37
|
mounted.current = true;
|
37
38
|
loader().then(value => {
|
38
39
|
if (mounted.current) {
|
39
40
|
setData(value);
|
41
|
+
dataRef.current = value;
|
40
42
|
}
|
41
43
|
});
|
42
44
|
return () => {
|
45
|
+
var _dataRef$current;
|
46
|
+
|
47
|
+
(_dataRef$current = dataRef.current) === null || _dataRef$current === void 0 ? void 0 : _dataRef$current.dispose();
|
43
48
|
mounted.current = false;
|
44
49
|
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
45
50
|
}, [source]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useState","Image","Skia","isRNModule","resolveAsset","source","resolveAssetSource","uri","default","factoryWrapper","data2","factory","onError","factoryResult","Error","loadData","undefined","Promise","resolve","Uint8Array","Data","fromBytes","fromURI","then","d","useLoading","loader","mounted","data","setData","current","value","useRawData","identity","useData"],"sources":["Data.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { Image } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport { isRNModule } from \"../types\";\nimport type {
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","Image","Skia","isRNModule","resolveAsset","source","resolveAssetSource","uri","default","factoryWrapper","data2","factory","onError","factoryResult","Error","loadData","undefined","Promise","resolve","Uint8Array","Data","fromBytes","fromURI","then","d","useLoading","loader","mounted","data","setData","dataRef","current","value","dispose","useRawData","identity","useData"],"sources":["Data.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { Image } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport { isRNModule } from \"../types\";\nimport type {\n SkData,\n DataModule,\n DataSourceParam,\n JsiDisposable,\n} from \"../types\";\n\nconst resolveAsset = (source: DataModule) => {\n return isRNModule(source)\n ? Image.resolveAssetSource(source).uri\n : source.default;\n};\n\nconst factoryWrapper = <T>(\n data2: SkData,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n) => {\n const factoryResult = factory(data2);\n if (factoryResult === null) {\n onError && onError(new Error(\"Could not load data\"));\n return null;\n } else {\n return factoryResult;\n }\n};\n\nconst loadData = <T>(\n source: DataSourceParam,\n factory: (data: SkData) => T | null,\n onError?: (err: Error) => void\n): Promise<T | null> => {\n if (source === null || source === undefined) {\n return new Promise((resolve) => resolve(null));\n } else if (source instanceof Uint8Array) {\n return new Promise((resolve) =>\n resolve(factoryWrapper(Skia.Data.fromBytes(source), factory, onError))\n );\n } else {\n const uri = typeof source === \"string\" ? source : resolveAsset(source);\n return Skia.Data.fromURI(uri).then((d) =>\n factoryWrapper(d, factory, onError)\n );\n }\n};\nconst useLoading = <T extends JsiDisposable>(\n source: DataSourceParam,\n loader: () => Promise<T | null>\n) => {\n const mounted = useRef(false);\n const [data, setData] = useState<T | null>(null);\n const dataRef = useRef<T | null>(null);\n useEffect(() => {\n mounted.current = true;\n loader().then((value) => {\n if (mounted.current) {\n setData(value);\n dataRef.current = value;\n }\n });\n return () => {\n dataRef.current?.dispose();\n mounted.current = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [source]);\n return data;\n};\n\nexport const useRawData = <T extends JsiDisposable>(\n source: DataSourceParam,\n factory: (data: SkData) => T | null,\n onError?: (err: Error) => void\n) => useLoading(source, () => loadData<T>(source, factory, onError));\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, identity, onError);\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,QAA4C,OAA5C;AACA,SAASC,KAAT,QAAsB,cAAtB;AAEA,SAASC,IAAT,QAAqB,SAArB;AACA,SAASC,UAAT,QAA2B,UAA3B;;AAQA,MAAMC,YAAY,GAAIC,MAAD,IAAwB;EAC3C,OAAOF,UAAU,CAACE,MAAD,CAAV,GACHJ,KAAK,CAACK,kBAAN,CAAyBD,MAAzB,EAAiCE,GAD9B,GAEHF,MAAM,CAACG,OAFX;AAGD,CAJD;;AAMA,MAAMC,cAAc,GAAG,CACrBC,KADqB,EAErBC,OAFqB,EAGrBC,OAHqB,KAIlB;EACH,MAAMC,aAAa,GAAGF,OAAO,CAACD,KAAD,CAA7B;;EACA,IAAIG,aAAa,KAAK,IAAtB,EAA4B;IAC1BD,OAAO,IAAIA,OAAO,CAAC,IAAIE,KAAJ,CAAU,qBAAV,CAAD,CAAlB;IACA,OAAO,IAAP;EACD,CAHD,MAGO;IACL,OAAOD,aAAP;EACD;AACF,CAZD;;AAcA,MAAME,QAAQ,GAAG,CACfV,MADe,EAEfM,OAFe,EAGfC,OAHe,KAIO;EACtB,IAAIP,MAAM,KAAK,IAAX,IAAmBA,MAAM,KAAKW,SAAlC,EAA6C;IAC3C,OAAO,IAAIC,OAAJ,CAAaC,OAAD,IAAaA,OAAO,CAAC,IAAD,CAAhC,CAAP;EACD,CAFD,MAEO,IAAIb,MAAM,YAAYc,UAAtB,EAAkC;IACvC,OAAO,IAAIF,OAAJ,CAAaC,OAAD,IACjBA,OAAO,CAACT,cAAc,CAACP,IAAI,CAACkB,IAAL,CAAUC,SAAV,CAAoBhB,MAApB,C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AAQ,GAAIP,IAAD,IAAkBA,IAAnC;;AAEA,OAAO,MAAMQ,OAAO,GAAG,CACrB/B,MADqB,EAErBO,OAFqB,KAGlBsB,UAAU,CAAC7B,MAAD,EAAS8B,QAAT,EAAmBvB,OAAnB,CAHR"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { SkJSIInstance } from "../JsiInstance";
|
2
|
-
export declare type SkData = SkJSIInstance<"Data"
|
1
|
+
import type { JsiDisposable, SkJSIInstance } from "../JsiInstance";
|
2
|
+
export declare type SkData = SkJSIInstance<"Data"> & JsiDisposable;
|
3
3
|
declare type RNModule = number;
|
4
4
|
declare type ESModule = {
|
5
5
|
__esModule: true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isRNModule","mod"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\"
|
1
|
+
{"version":3,"names":["isRNModule","mod"],"sources":["Data.ts"],"sourcesContent":["import type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\"> & JsiDisposable;\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":"AAaA,OAAO,MAAMA,UAAU,GAAIC,GAAD,IACxB,OAAOA,GAAP,KAAe,QADV"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { SkMatrix } from "../Matrix";
|
2
|
-
import type { SkJSIInstance } from "../JsiInstance";
|
2
|
+
import type { JsiDisposable, SkJSIInstance } from "../JsiInstance";
|
3
3
|
import type { TileMode } from "../ImageFilter";
|
4
4
|
import type { SkShader } from "../Shader";
|
5
5
|
export declare enum FilterMode {
|
@@ -16,7 +16,7 @@ export declare enum ImageFormat {
|
|
16
16
|
PNG = 4,
|
17
17
|
WEBP = 6
|
18
18
|
}
|
19
|
-
export interface SkImage extends SkJSIInstance<"Image"
|
19
|
+
export interface SkImage extends SkJSIInstance<"Image">, JsiDisposable {
|
20
20
|
/**
|
21
21
|
* Returns the possibly scaled height of the image.
|
22
22
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["FilterMode","MipmapMode","ImageFormat"],"sources":["Image.ts"],"sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nexport enum FilterMode {\n Nearest,\n Linear,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n JPEG = 3,\n PNG = 4,\n WEBP = 6,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\"
|
1
|
+
{"version":3,"names":["FilterMode","MipmapMode","ImageFormat"],"sources":["Image.ts"],"sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nexport enum FilterMode {\n Nearest,\n Linear,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n JPEG = 3,\n PNG = 4,\n WEBP = 6,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\">, JsiDisposable {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n}\n"],"mappings":"AAKA,WAAYA,UAAZ;;WAAYA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAKZ,WAAYC,UAAZ;;WAAYA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAMZ,WAAYC,WAAZ;;WAAYA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["JsiInstance.ts"],"sourcesContent":["export interface SkJSIInstance<T extends string> {\n __typename__: T;\n}\n"],"mappings":""}
|
1
|
+
{"version":3,"names":[],"sources":["JsiInstance.ts"],"sourcesContent":["export interface SkJSIInstance<T extends string> {\n __typename__: T;\n}\n\nexport interface JsiDisposable {\n dispose: () => void;\n}\n"],"mappings":""}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type { SkJSIInstance } from "../JsiInstance";
|
2
|
-
export declare type SkSVG = SkJSIInstance<"SVG"
|
1
|
+
import type { JsiDisposable, SkJSIInstance } from "../JsiInstance";
|
2
|
+
export declare type SkSVG = SkJSIInstance<"SVG"> & JsiDisposable;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["SVG.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkSVG = SkJSIInstance<\"SVG\"
|
1
|
+
{"version":3,"names":[],"sources":["SVG.ts"],"sourcesContent":["import type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkSVG = SkJSIInstance<\"SVG\"> & JsiDisposable;\n"],"mappings":""}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type { SkJSIInstance } from "../JsiInstance";
|
2
|
-
export declare type SkTypeface = SkJSIInstance<"Typeface"
|
1
|
+
import type { JsiDisposable, SkJSIInstance } from "../JsiInstance";
|
2
|
+
export declare type SkTypeface = SkJSIInstance<"Typeface"> & JsiDisposable;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Typeface.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkTypeface = SkJSIInstance<\"Typeface\"
|
1
|
+
{"version":3,"names":[],"sources":["Typeface.ts"],"sourcesContent":["import type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkTypeface = SkJSIInstance<\"Typeface\"> & JsiDisposable;\n"],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["HostObject","JsiSkData","constructor","CanvasKit","ref"],"sources":["JsiSkData.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\ntype Data = ArrayBuffer;\n\nexport class JsiSkData extends HostObject<Data, \"Data\"> implements SkData {\n constructor(CanvasKit: CanvasKit, ref: Data) {\n super(CanvasKit, ref, \"Data\");\n }\n}\n"],"mappings":"AAIA,SAASA,UAAT,QAA2B,QAA3B;AAIA,OAAO,MAAMC,SAAN,SAAwBD,UAAxB,CAAmE;EACxEE,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;IAC3C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;EACD;;
|
1
|
+
{"version":3,"names":["HostObject","JsiSkData","constructor","CanvasKit","ref","dispose"],"sources":["JsiSkData.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\ntype Data = ArrayBuffer;\n\nexport class JsiSkData extends HostObject<Data, \"Data\"> implements SkData {\n constructor(CanvasKit: CanvasKit, ref: Data) {\n super(CanvasKit, ref, \"Data\");\n }\n\n dispose() {\n // Not implemented in data\n }\n}\n"],"mappings":"AAIA,SAASA,UAAT,QAA2B,QAA3B;AAIA,OAAO,MAAMC,SAAN,SAAwBD,UAAxB,CAAmE;EACxEE,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;IAC3C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;EACD;;EAEDC,OAAO,GAAG,CACR;EACD;;AAPuE"}
|
@@ -10,4 +10,5 @@ export declare class JsiSkImage extends HostObject<Image, "Image"> implements Sk
|
|
10
10
|
makeShaderCubic(tx: TileMode, ty: TileMode, B: number, C: number, localMatrix?: SkMatrix): SkShader;
|
11
11
|
encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;
|
12
12
|
encodeToBase64(fmt?: ImageFormat, quality?: number): string;
|
13
|
+
dispose(): void;
|
13
14
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ckEnum","HostObject","JsiSkMatrix","JsiSkShader","toBase64String","bytes","Buffer","from","toString","CHUNK_SIZE","index","length","result","slice","Math","min","String","fromCharCode","apply","btoa","JsiSkImage","constructor","CanvasKit","ref","height","width","makeShaderOptions","tx","ty","fm","mm","localMatrix","fromValue","undefined","makeShaderCubic","B","C","encodeToBytes","fmt","quality","Error","encodeToBase64"],"sources":["JsiSkImage.ts"],"sourcesContent":["import type { CanvasKit, Image } from \"canvaskit-wasm\";\n\nimport type {\n ImageFormat,\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { ckEnum, HostObject } from \"./Host\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/modules/canvaskit/htmlcanvas/util.js\nexport const toBase64String = (bytes: Uint8Array) => {\n if (typeof Buffer !== \"undefined\") {\n // Are we on node?\n return Buffer.from(bytes).toString(\"base64\");\n } else {\n // From https://stackoverflow.com/a/25644409\n // because the naive solution of\n // btoa(String.fromCharCode.apply(null, bytes));\n // would occasionally throw \"Maximum call stack size exceeded\"\n var CHUNK_SIZE = 0x8000; //arbitrary number\n var index = 0;\n var { length } = bytes;\n var result = \"\";\n var slice;\n while (index < length) {\n slice = bytes.slice(index, Math.min(index + CHUNK_SIZE, length));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result += String.fromCharCode.apply(null, slice as any);\n index += CHUNK_SIZE;\n }\n return btoa(result);\n }\n};\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderOptions(\n ckEnum(tx),\n ckEnum(ty),\n ckEnum(fm),\n ckEnum(mm),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderCubic(\n ckEnum(tx),\n ckEnum(ty),\n B,\n C,\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number) {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(fmt?: ImageFormat, quality?: number) {\n const bytes = this.encodeToBytes(fmt, quality);\n return toBase64String(bytes);\n }\n}\n"],"mappings":"AAYA,SAASA,MAAT,EAAiBC,UAAjB,QAAmC,QAAnC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,WAAT,QAA4B,eAA5B,C,CAEA;;AACA,OAAO,MAAMC,cAAc,GAAIC,KAAD,IAAuB;EACnD,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;IACjC;IACA,OAAOA,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,QAAnB,CAA4B,QAA5B,CAAP;EACD,CAHD,MAGO;IACL;IACA;IACA;IACA;IACA,IAAIC,UAAU,GAAG,MAAjB,CALK,CAKoB;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,EAKbL,WALa,EAMH;IACV,OAAO,IAAI5B,WAAJ,CACL,KAAKmB,SADA,EAEL,KAAKC,GAAL,CAASW,eAAT,CACElC,MAAM,CAAC2B,EAAD,CADR,EAEE3B,MAAM,CAAC4B,EAAD,CAFR,EAGEO,CAHF,EAIEC,CAJF,EAKEL,WAAW,GAAG7B,WAAW,CAAC8B,SAAZ,CAAsBD,WAAtB,CAAH,GAAwCE,SALrD,CAFK,CAAP;EAUD;;EAEDI,aAAa,CAACC,GAAD,EAAoBC,OAApB,EAAsC;IACjD,IAAI3B,MAAJ;;IACA,IAAI0B,GAAG,IAAIC,OAAX,EAAoB;MAClB3B,MAAM,GAAG,KAAKW,GAAL,CAASc,aAAT,CAAuBrC,MAAM,CAACsC,GAAD,CAA7B,EAAoCC,OAApC,CAAT;IACD,CAFD,MAEO,IAAID,GAAJ,EAAS;MACd1B,MAAM,GAAG,KAAKW,GAAL,CAASc,aAAT,CAAuBrC,MAAM,CAACsC,GAAD,CAA7B,CAAT;IACD,CAFM,MAEA;MACL1B,MAAM,GAAG,KAAKW,GAAL,CAASc,aAAT,EAAT;IACD;;IACD,IAAI,CAACzB,MAAL,EAAa;MACX,MAAM,IAAI4B,KAAJ,CAAU,sBAAV,CAAN;IACD;;IACD,OAAO5B,MAAP;EACD;;EAED6B,cAAc,CAACH,GAAD,EAAoBC,OAApB,EAAsC;IAClD,MAAMlC,KAAK,GAAG,KAAKgC,aAAL,CAAmBC,GAAnB,EAAwBC,OAAxB,CAAd;IACA,OAAOnC,cAAc,CAACC,KAAD,CAArB;EACD;;
|
1
|
+
{"version":3,"names":["ckEnum","HostObject","JsiSkMatrix","JsiSkShader","toBase64String","bytes","Buffer","from","toString","CHUNK_SIZE","index","length","result","slice","Math","min","String","fromCharCode","apply","btoa","JsiSkImage","constructor","CanvasKit","ref","height","width","makeShaderOptions","tx","ty","fm","mm","localMatrix","fromValue","undefined","makeShaderCubic","B","C","encodeToBytes","fmt","quality","Error","encodeToBase64","dispose","delete"],"sources":["JsiSkImage.ts"],"sourcesContent":["import type { CanvasKit, Image } from \"canvaskit-wasm\";\n\nimport type {\n ImageFormat,\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { ckEnum, HostObject } from \"./Host\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/modules/canvaskit/htmlcanvas/util.js\nexport const toBase64String = (bytes: Uint8Array) => {\n if (typeof Buffer !== \"undefined\") {\n // Are we on node?\n return Buffer.from(bytes).toString(\"base64\");\n } else {\n // From https://stackoverflow.com/a/25644409\n // because the naive solution of\n // btoa(String.fromCharCode.apply(null, bytes));\n // would occasionally throw \"Maximum call stack size exceeded\"\n var CHUNK_SIZE = 0x8000; //arbitrary number\n var index = 0;\n var { length } = bytes;\n var result = \"\";\n var slice;\n while (index < length) {\n slice = bytes.slice(index, Math.min(index + CHUNK_SIZE, length));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result += String.fromCharCode.apply(null, slice as any);\n index += CHUNK_SIZE;\n }\n return btoa(result);\n }\n};\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderOptions(\n ckEnum(tx),\n ckEnum(ty),\n ckEnum(fm),\n ckEnum(mm),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderCubic(\n ckEnum(tx),\n ckEnum(ty),\n B,\n C,\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number) {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(fmt?: ImageFormat, quality?: number) {\n const bytes = this.encodeToBytes(fmt, quality);\n return toBase64String(bytes);\n }\n\n dispose() {\n this.ref.delete();\n }\n}\n"],"mappings":"AAYA,SAASA,MAAT,EAAiBC,UAAjB,QAAmC,QAAnC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,WAAT,QAA4B,eAA5B,C,CAEA;;AACA,OAAO,MAAMC,cAAc,GAAIC,KAAD,IAAuB;EACnD,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;IACjC;IACA,OAAOA,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,QAAnB,CAA4B,QAA5B,CAAP;EACD,CAHD,MAGO;IACL;IACA;IACA;IACA;IACA,IAAIC,UAAU,GAAG,MAAjB,CALK,CAKoB;;IACzB,IAAIC,KAAK,GAAG,CAAZ;IACA,IAAI;MAAEC;IAAF,IAAaN,KAAjB;IACA,IAAIO,MAAM,GAAG,EAAb;IACA,IAAIC,KAAJ;;IACA,OAAOH,KAAK,GAAGC,MAAf,EAAuB;MACrBE,KAAK,GAAGR,KAAK,CAACQ,KAAN,CAAYH,KAAZ,EAAmBI,IAAI,CAACC,GAAL,CAASL,KAAK,GAAGD,UAAjB,EAA6BE,MAA7B,CAAnB,CAAR,CADqB,CAErB;;MACAC,MAAM,IAAII,MAAM,CAACC,YAAP,CAAoBC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;;IACA,IAAI0B,GAAG,IAAIC,OAAX,EAAoB;MAClB3B,MAAM,GAAG,KAAKW,GAAL,CAASc,aAAT,CAAuBrC,MAAM,CAACsC,GAAD,CAA7B,EAAoCC,OAApC,CAAT;IACD,CAFD,MAEO,IAAID,GAAJ,EAAS;MACd1B,MAAM,GAAG,KAAKW,GAAL,CAASc,aAAT,CAAuBrC,MAAM,CAACsC,GAAD,CAA7B,CAAT;IACD,CAFM,MAEA;MACL1B,MAAM,GAAG,KAAKW,GAAL,CAASc,aAAT,EAAT;IACD;;IACD,IAAI,CAACzB,MAAL,EAAa;MACX,MAAM,IAAI4B,KAAJ,CAAU,sBAAV,CAAN;IACD;;IACD,OAAO5B,MAAP;EACD;;EAED6B,cAAc,CAACH,GAAD,EAAoBC,OAApB,EAAsC;IAClD,MAAMlC,KAAK,GAAG,KAAKgC,aAAL,CAAmBC,GAAnB,EAAwBC,OAAxB,CAAd;IACA,OAAOnC,cAAc,CAACC,KAAD,CAArB;EACD;;EAEDqC,OAAO,GAAG;IACR,KAAKnB,GAAL,CAASoB,MAAT;EACD;;AAzE2E"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["HostObject","JsiSkTypeface","constructor","CanvasKit","ref","bold","console","warn","italic"],"sources":["JsiSkTypeface.ts"],"sourcesContent":["import type { CanvasKit, Typeface } from \"canvaskit-wasm\";\n\nimport type { SkTypeface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkTypeface\n extends HostObject<Typeface, \"Typeface\">\n implements SkTypeface\n{\n constructor(CanvasKit: CanvasKit, ref: Typeface) {\n super(CanvasKit, ref, \"Typeface\");\n }\n\n get bold(): boolean {\n console.warn(\n \"Typeface.bold is deprecated and will be removed in a future release. The property will return false.\"\n );\n return false;\n }\n\n get italic(): boolean {\n console.warn(\n \"Typeface.italic is deprecated and will be removed in a future release. The property will return false.\"\n );\n return false;\n }\n}\n"],"mappings":"AAIA,SAASA,UAAT,QAA2B,QAA3B;AAEA,OAAO,MAAMC,aAAN,SACGD,UADH,CAGP;EACEE,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAsC;IAC/C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,UAAtB;EACD;;EAEO,IAAJC,IAAI,GAAY;IAClBC,OAAO,CAACC,IAAR,CACE,sGADF;IAGA,OAAO,KAAP;EACD;;EAES,IAANC,MAAM,GAAY;IACpBF,OAAO,CAACC,IAAR,CACE,wGADF;IAGA,OAAO,KAAP;EACD;;
|
1
|
+
{"version":3,"names":["HostObject","JsiSkTypeface","constructor","CanvasKit","ref","bold","console","warn","italic","dispose","delete"],"sources":["JsiSkTypeface.ts"],"sourcesContent":["import type { CanvasKit, Typeface } from \"canvaskit-wasm\";\n\nimport type { SkTypeface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkTypeface\n extends HostObject<Typeface, \"Typeface\">\n implements SkTypeface\n{\n constructor(CanvasKit: CanvasKit, ref: Typeface) {\n super(CanvasKit, ref, \"Typeface\");\n }\n\n get bold(): boolean {\n console.warn(\n \"Typeface.bold is deprecated and will be removed in a future release. The property will return false.\"\n );\n return false;\n }\n\n get italic(): boolean {\n console.warn(\n \"Typeface.italic is deprecated and will be removed in a future release. The property will return false.\"\n );\n return false;\n }\n\n dispose() {\n this.ref.delete();\n }\n}\n"],"mappings":"AAIA,SAASA,UAAT,QAA2B,QAA3B;AAEA,OAAO,MAAMC,aAAN,SACGD,UADH,CAGP;EACEE,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAsC;IAC/C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,UAAtB;EACD;;EAEO,IAAJC,IAAI,GAAY;IAClBC,OAAO,CAACC,IAAR,CACE,sGADF;IAGA,OAAO,KAAP;EACD;;EAES,IAANC,MAAM,GAAY;IACpBF,OAAO,CAACC,IAAR,CACE,wGADF;IAGA,OAAO,KAAP;EACD;;EAEDE,OAAO,GAAG;IACR,KAAKL,GAAL,CAASM,MAAT;EACD;;AArBH"}
|
@@ -92,8 +92,12 @@ export class SkiaBaseWebView extends React.Component {
|
|
92
92
|
}
|
93
93
|
|
94
94
|
componentWillUnmount() {
|
95
|
+
var _this$_canvasRef$curr, _this$_canvasRef$curr2, _this$_canvasRef$curr3;
|
96
|
+
|
95
97
|
this.unsubscribeAll();
|
96
|
-
cancelAnimationFrame(this.requestId);
|
98
|
+
cancelAnimationFrame(this.requestId); // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context
|
99
|
+
|
100
|
+
(_this$_canvasRef$curr = this._canvasRef.current) === null || _this$_canvasRef$curr === void 0 ? void 0 : (_this$_canvasRef$curr2 = _this$_canvasRef$curr.getContext("webgl2")) === null || _this$_canvasRef$curr2 === void 0 ? void 0 : (_this$_canvasRef$curr3 = _this$_canvasRef$curr2.getExtension("WEBGL_lose_context")) === null || _this$_canvasRef$curr3 === void 0 ? void 0 : _this$_canvasRef$curr3.loseContext();
|
97
101
|
}
|
98
102
|
/**
|
99
103
|
* Creates a snapshot from the canvas in the surface
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","PixelRatio","View","JsiSkSurface","TouchType","pd","get","SkiaBaseWebView","Component","constructor","props","createRef","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","CanvasKit","global","width","height","nativeEvent","layout","_canvasRef","current","canvas","surface","MakeWebGLCanvasSurface","Error","_surface","_canvas","getCanvas","redraw","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","makeImageSnapshot","rect","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","touches","_touches","Float32Array","of","save","scale","restore","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","timestamp","Date","now","createTouchHandler","render","debug","viewProps","display","flex","Start","Active","End","Cancelled"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { PixelRatio, View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawMode, SkiaBaseViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst pd = PixelRatio.get();\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n const { width, height } = evt.nativeEvent.layout;\n this.width = width;\n this.height = height;\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n const canvas = this._canvasRef.current;\n canvas.width = width * pd;\n canvas.height = height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!, []);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(\n canvas: SkCanvas,\n touches: TouchInfo[]\n ): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const touches = [...this._touches];\n this._touches = [];\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas, touches);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.tick();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.redraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.redraw();\n }\n\n createTouchHandler(touchType: TouchType) {\n return (evt: PointerEvent) => this.handleTouchEvent(evt, touchType);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n <canvas\n ref={this._canvasRef}\n style={{ display: \"flex\", flex: 1 }}\n onPointerDown={this.createTouchHandler(TouchType.Start)}\n onPointerMove={this.createTouchHandler(TouchType.Active)}\n onPointerUp={this.createTouchHandler(TouchType.End)}\n onPointerCancel={this.createTouchHandler(TouchType.Cancelled)}\n onPointerLeave={this.createTouchHandler(TouchType.End)}\n onPointerOut={this.createTouchHandler(TouchType.End)}\n />\n </View>\n );\n }\n}\n"],"mappings":";;;;AAAA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAIA,SAASC,YAAT,QAA6B,0BAA7B;AAGA,SAASC,SAAT,QAA0B,SAA1B;AAEA,MAAMC,EAAE,GAAGJ,UAAU,CAACK,GAAX,EAAX;AAEA,OAAO,MAAeC,eAAf,SAEGP,KAAK,CAACQ,SAFT,CAE2B;EAChCC,WAAW,CAACC,KAAD,EAAgB;IAAA;;IACzB,MAAMA,KAAN;;IADyB,kCAKa,IALb;;IAAA,0CAMmB,EANnB;;IAAA,kCAOU,EAPV;;IAAA,iCAQQ,IARR;;IAAA,iDASNV,KAAK,CAACW,SAAN,EATM;;IAAA;;IAAA,yCAWD,CAXC;;IAAA,mCAYP,CAZO;;IAAA,+BAcT,CAdS;;IAAA,gCAeR,CAfQ;;IAEzB,KAAKC,KAAL,kBAAaF,KAAK,CAACG,IAAnB,qDAA2B,SAA3B;EACD;;EAcOC,cAAc,GAAG;IACvB,KAAKC,gBAAL,CAAsBC,OAAtB,CAA+BC,CAAD,IAAOA,CAAC,EAAtC;;IACA,KAAKF,gBAAL,GAAwB,EAAxB;EACD;;EAEOG,QAAQ,CAACC,GAAD,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B,CAFT;MAGE,aAAa,EAAE,KAAKL,kBAAL,CAAwBhF,SAAS,CAACsF,KAAlC,CAHjB;MAIE,aAAa,EAAE,KAAKN,kBAAL,CAAwBhF,SAAS,CAACuF,MAAlC,CAJjB;MAKE,WAAW,EAAE,KAAKP,kBAAL,CAAwBhF,SAAS,CAACwF,GAAlC,CALf;MAME,eAAe,EAAE,KAAKR,kBAAL,CAAwBhF,SAAS,CAACyF,SAAlC,CANnB;MAOE,cAAc,EAAE,KAAKT,kBAAL,CAAwBhF,SAAS,CAACwF,GAAlC,CAPlB;MAQE,YAAY,EAAE,KAAKR,kBAAL,CAAwBhF,SAAS,CAACwF,GAAlC;IARhB,EADF,CADF;EAcD;;AA9K+B"}
|
1
|
+
{"version":3,"names":["React","PixelRatio","View","JsiSkSurface","TouchType","pd","get","SkiaBaseWebView","Component","constructor","props","createRef","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","CanvasKit","global","width","height","nativeEvent","layout","_canvasRef","current","canvas","surface","MakeWebGLCanvasSurface","Error","_surface","_canvas","getCanvas","redraw","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","getContext","getExtension","loseContext","makeImageSnapshot","rect","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","touches","_touches","Float32Array","of","save","scale","restore","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","timestamp","Date","now","createTouchHandler","render","debug","viewProps","display","flex","Start","Active","End","Cancelled"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { PixelRatio, View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawMode, SkiaBaseViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst pd = PixelRatio.get();\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n const { width, height } = evt.nativeEvent.layout;\n this.width = width;\n this.height = height;\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n const canvas = this._canvasRef.current;\n canvas.width = width * pd;\n canvas.height = height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context\n this._canvasRef.current\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!, []);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(\n canvas: SkCanvas,\n touches: TouchInfo[]\n ): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const touches = [...this._touches];\n this._touches = [];\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas, touches);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.tick();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.redraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.redraw();\n }\n\n createTouchHandler(touchType: TouchType) {\n return (evt: PointerEvent) => this.handleTouchEvent(evt, touchType);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n <canvas\n ref={this._canvasRef}\n style={{ display: \"flex\", flex: 1 }}\n onPointerDown={this.createTouchHandler(TouchType.Start)}\n onPointerMove={this.createTouchHandler(TouchType.Active)}\n onPointerUp={this.createTouchHandler(TouchType.End)}\n onPointerCancel={this.createTouchHandler(TouchType.Cancelled)}\n onPointerLeave={this.createTouchHandler(TouchType.End)}\n onPointerOut={this.createTouchHandler(TouchType.End)}\n />\n </View>\n );\n }\n}\n"],"mappings":";;;;AAAA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAIA,SAASC,YAAT,QAA6B,0BAA7B;AAGA,SAASC,SAAT,QAA0B,SAA1B;AAEA,MAAMC,EAAE,GAAGJ,UAAU,CAACK,GAAX,EAAX;AAEA,OAAO,MAAeC,eAAf,SAEGP,KAAK,CAACQ,SAFT,CAE2B;EAChCC,WAAW,CAACC,KAAD,EAAgB;IAAA;;IACzB,MAAMA,KAAN;;IADyB,kCAKa,IALb;;IAAA,0CAMmB,EANnB;;IAAA,kCAOU,EAPV;;IAAA,iCAQQ,IARR;;IAAA,iDASNV,KAAK,CAACW,SAAN,EATM;;IAAA;;IAAA,yCAWD,CAXC;;IAAA,mCAYP,CAZO;;IAAA,+BAcT,CAdS;;IAAA,gCAeR,CAfQ;;IAEzB,KAAKC,KAAL,kBAAaF,KAAK,CAACG,IAAnB,qDAA2B,SAA3B;EACD;;EAcOC,cAAc,GAAG;IACvB,KAAKC,gBAAL,CAAsBC,OAAtB,CAA+BC,CAAD,IAAOA,CAAC,EAAtC;;IACA,KAAKF,gBAAL,GAAwB,EAAxB;EACD;;EAEOG,QAAQ,CAACC,GAAD,EAAyB;IACvC,MAAM;MAAEC;IAAF,IAAgBC,MAAtB;IACA,MAAM;MAAEC,KAAF;M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EAAE;QAAEiE,OAAO,EAAE,MAAX;QAAmBC,IAAI,EAAE;MAAzB,CAFT;MAGE,aAAa,EAAE,KAAKL,kBAAL,CAAwBnF,SAAS,CAACyF,KAAlC,CAHjB;MAIE,aAAa,EAAE,KAAKN,kBAAL,CAAwBnF,SAAS,CAAC0F,MAAlC,CAJjB;MAKE,WAAW,EAAE,KAAKP,kBAAL,CAAwBnF,SAAS,CAAC2F,GAAlC,CALf;MAME,eAAe,EAAE,KAAKR,kBAAL,CAAwBnF,SAAS,CAAC4F,SAAlC,CANnB;MAOE,cAAc,EAAE,KAAKT,kBAAL,CAAwBnF,SAAS,CAAC2F,GAAlC,CAPlB;MAQE,YAAY,EAAE,KAAKR,kBAAL,CAAwBnF,SAAS,CAAC2F,GAAlC;IARhB,EADF,CADF;EAcD;;AAnL+B"}
|
@@ -8,6 +8,7 @@ import type { SkiaValue } from "../values";
|
|
8
8
|
import type { Container } from "./Container";
|
9
9
|
import type { SkiaProps } from "./processors";
|
10
10
|
import type { DependencyManager } from "./DependencyManager";
|
11
|
+
export declare const NATIVE_DOM: boolean;
|
11
12
|
declare global {
|
12
13
|
var SkiaDomApi: {
|
13
14
|
DependencyManager: (registerValues: (values: Array<SkiaValue<unknown>>) => () => void) => DependencyManager;
|