@shopify/react-native-skia 0.1.162 → 0.1.163
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +2 -0
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +2 -2
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +5 -5
- package/cpp/api/JsiSkCanvas.h +8 -8
- package/cpp/api/JsiSkColor.h +1 -1
- package/cpp/api/JsiSkColorFilter.h +1 -1
- package/cpp/api/JsiSkColorFilterFactory.h +2 -2
- package/cpp/api/JsiSkContourMeasure.h +1 -1
- package/cpp/api/JsiSkContourMeasureIter.h +2 -2
- package/cpp/api/JsiSkData.h +2 -2
- package/cpp/api/JsiSkDataFactory.h +1 -1
- package/cpp/api/JsiSkFont.h +2 -2
- package/cpp/api/JsiSkImage.h +3 -3
- package/cpp/api/JsiSkImageFilter.h +1 -1
- package/cpp/api/JsiSkImageFilterFactory.h +1 -1
- package/cpp/api/JsiSkImageInfo.h +1 -1
- package/cpp/api/JsiSkMaskFilter.h +1 -1
- package/cpp/api/JsiSkMaskFilterFactory.h +1 -1
- package/cpp/api/JsiSkMatrix.h +1 -1
- package/cpp/api/JsiSkPaint.h +1 -1
- package/cpp/api/JsiSkPath.h +15 -15
- package/cpp/api/JsiSkPathEffect.h +1 -1
- package/cpp/api/JsiSkPathEffectFactory.h +4 -4
- package/cpp/api/JsiSkPathFactory.h +2 -2
- package/cpp/api/JsiSkPicture.h +1 -1
- package/cpp/api/JsiSkPictureFactory.h +2 -2
- package/cpp/api/JsiSkPictureRecorder.h +2 -2
- package/cpp/api/JsiSkPoint.h +1 -1
- package/cpp/api/JsiSkRRect.h +1 -1
- package/cpp/api/JsiSkRSXform.h +1 -1
- package/cpp/api/JsiSkRect.h +1 -1
- package/cpp/api/JsiSkRuntimeEffect.h +1 -1
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +1 -1
- package/cpp/api/JsiSkSVGFactory.h +1 -1
- package/cpp/api/JsiSkShader.h +2 -2
- package/cpp/api/JsiSkShaderFactory.h +3 -3
- package/cpp/api/JsiSkSurface.h +1 -1
- package/cpp/api/JsiSkSurfaceFactory.h +2 -2
- package/cpp/api/JsiSkTextBlob.h +1 -1
- package/cpp/api/JsiSkTextBlobFactory.h +1 -1
- package/cpp/api/JsiSkTypeface.h +2 -2
- package/cpp/api/JsiSkVertices.h +1 -1
- package/cpp/rnskia/RNSkJsView.h +3 -3
- package/cpp/rnskia/RNSkPictureView.h +3 -3
- package/cpp/rnskia/RNSkPlatformContext.h +5 -3
- package/cpp/rnskia/RNSkView.h +2 -2
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +6 -7
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +10 -8
- package/cpp/rnskia/dom/props/BlendModeProp.h +2 -2
- package/cpp/rnskia/dom/props/PaintProps.h +5 -1
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +8 -7
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -1
- package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +4 -4
- package/ios/RNSkia-iOS/SkiaManager.mm +5 -5
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +3 -3
- package/ios/RNSkia-iOS/SkiaUIView.mm +10 -10
- package/lib/commonjs/renderer/Canvas.js +2 -11
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/Container.js +2 -1
- package/lib/commonjs/renderer/Container.js.map +1 -1
- package/lib/commonjs/renderer/components/Mask.js +11 -25
- package/lib/commonjs/renderer/components/Mask.js.map +1 -1
- package/lib/commonjs/renderer/index.js +0 -13
- package/lib/commonjs/renderer/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +3 -10
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/Container.js +2 -1
- package/lib/module/renderer/Container.js.map +1 -1
- package/lib/module/renderer/components/Mask.js +9 -21
- package/lib/module/renderer/components/Mask.js.map +1 -1
- package/lib/module/renderer/index.js +0 -1
- package/lib/module/renderer/index.js.map +1 -1
- package/lib/typescript/src/renderer/Container.d.ts +1 -1
- package/lib/typescript/src/renderer/index.d.ts +0 -1
- package/package.json +1 -1
- package/src/renderer/Canvas.tsx +2 -12
- package/src/renderer/Container.tsx +1 -1
- package/src/renderer/components/Mask.tsx +11 -20
- package/src/renderer/index.ts +0 -1
- package/lib/commonjs/renderer/useCanvas.js +0 -32
- package/lib/commonjs/renderer/useCanvas.js.map +0 -1
- package/lib/module/renderer/useCanvas.js +0 -15
- package/lib/module/renderer/useCanvas.js.map +0 -1
- package/lib/typescript/src/renderer/useCanvas.d.ts +0 -9
- package/src/renderer/useCanvas.ts +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,
|
|
1
|
+
{"version":3,"names":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void = () => {}\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAIT;IAAA,IADOC,MACP,uEAD4B,MAAM,CAAE,CACpC;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIN,QAAJ,CAAa;MAAEG,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKG,KAAL,GAAa,KAAKD,EAAL,CAAQE,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { BlendMode } from "../../skia/types";
|
|
3
|
-
import { useSkiaPrivate } from "../useCanvas";
|
|
1
|
+
import React from "react";
|
|
4
2
|
import { Group } from "./Group";
|
|
3
|
+
import { LumaColorFilter } from "./colorFilters/LumaColorFilter";
|
|
4
|
+
import { Paint } from "./Paint";
|
|
5
5
|
export const Mask = _ref => {
|
|
6
6
|
let {
|
|
7
7
|
children,
|
|
@@ -9,28 +9,16 @@ export const Mask = _ref => {
|
|
|
9
9
|
mode,
|
|
10
10
|
clip
|
|
11
11
|
} = _ref;
|
|
12
|
-
const Skia = useSkiaPrivate();
|
|
13
|
-
const maskPaint = useMemo(() => {
|
|
14
|
-
const paint = Skia.Paint();
|
|
15
|
-
paint.setBlendMode(BlendMode.Src);
|
|
16
|
-
|
|
17
|
-
if (mode === "luminance") {
|
|
18
|
-
paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return paint;
|
|
22
|
-
}, [Skia, mode]);
|
|
23
|
-
const clippingPaint = useMemo(() => {
|
|
24
|
-
const paint = Skia.Paint();
|
|
25
|
-
paint.setBlendMode(BlendMode.DstIn);
|
|
26
|
-
return paint;
|
|
27
|
-
}, [Skia]);
|
|
28
12
|
return /*#__PURE__*/React.createElement(Group, {
|
|
29
13
|
layer: true
|
|
30
14
|
}, /*#__PURE__*/React.createElement(Group, {
|
|
31
|
-
layer:
|
|
15
|
+
layer: /*#__PURE__*/React.createElement(Paint, {
|
|
16
|
+
blendMode: "src"
|
|
17
|
+
}, mode === "luminance" && /*#__PURE__*/React.createElement(LumaColorFilter, null))
|
|
32
18
|
}, mask, clip && /*#__PURE__*/React.createElement(Group, {
|
|
33
|
-
layer:
|
|
19
|
+
layer: /*#__PURE__*/React.createElement(Paint, {
|
|
20
|
+
blendMode: "dstIn"
|
|
21
|
+
})
|
|
34
22
|
}, children)), /*#__PURE__*/React.createElement(Group, {
|
|
35
23
|
blendMode: "srcIn"
|
|
36
24
|
}, children));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","Group","LumaColorFilter","Paint","Mask","children","mask","mode","clip","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\n\nimport { Group } from \"./Group\";\nimport { LumaColorFilter } from \"./colorFilters/LumaColorFilter\";\nimport { Paint } from \"./Paint\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n return (\n <Group layer>\n <Group\n layer={\n <Paint blendMode=\"src\">\n {mode === \"luminance\" && <LumaColorFilter />}\n </Paint>\n }\n >\n {mask}\n {clip && <Group layer={<Paint blendMode=\"dstIn\" />}>{children}</Group>}\n </Group>\n <Group blendMode=\"srcIn\">{children}</Group>\n </Group>\n );\n};\n\nMask.defaultProps = {\n mode: \"alpha\",\n clip: true,\n};\n"],"mappings":"AACA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,KAAT,QAAsB,SAAtB;AASA,OAAO,MAAMC,IAAI,GAAG,QAA+C;EAAA,IAA9C;IAAEC,QAAF;IAAYC,IAAZ;IAAkBC,IAAlB;IAAwBC;EAAxB,CAA8C;EACjE,oBACE,oBAAC,KAAD;IAAO,KAAK;EAAZ,gBACE,oBAAC,KAAD;IACE,KAAK,eACH,oBAAC,KAAD;MAAO,SAAS,EAAC;IAAjB,GACGD,IAAI,KAAK,WAAT,iBAAwB,oBAAC,eAAD,OAD3B;EAFJ,GAOGD,IAPH,EAQGE,IAAI,iBAAI,oBAAC,KAAD;IAAO,KAAK,eAAE,oBAAC,KAAD;MAAO,SAAS,EAAC;IAAjB;EAAd,GAA4CH,QAA5C,CARX,CADF,eAWE,oBAAC,KAAD;IAAO,SAAS,EAAC;EAAjB,GAA0BA,QAA1B,CAXF,CADF;AAeD,CAhBM;AAkBPD,IAAI,CAACK,YAAL,GAAoB;EAClBF,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\n"],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,oBAAd;AACA,cAAc,qBAAd"}
|
|
@@ -6,7 +6,7 @@ export declare class Container {
|
|
|
6
6
|
redraw: () => void;
|
|
7
7
|
private _root;
|
|
8
8
|
Sk: SkDOM;
|
|
9
|
-
constructor(Skia: Skia, depMgr: DependencyManager, redraw
|
|
9
|
+
constructor(Skia: Skia, depMgr: DependencyManager, redraw?: () => void);
|
|
10
10
|
draw(ctx: DrawingContext): void;
|
|
11
11
|
get root(): RenderNode<GroupProps>;
|
|
12
12
|
}
|
package/package.json
CHANGED
package/src/renderer/Canvas.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import React, {
|
|
|
4
4
|
useMemo,
|
|
5
5
|
forwardRef,
|
|
6
6
|
useRef,
|
|
7
|
-
useState,
|
|
8
7
|
} from "react";
|
|
9
8
|
import type {
|
|
10
9
|
RefObject,
|
|
@@ -15,7 +14,6 @@ import type {
|
|
|
15
14
|
} from "react";
|
|
16
15
|
import type { OpaqueRoot } from "react-reconciler";
|
|
17
16
|
import ReactReconciler from "react-reconciler";
|
|
18
|
-
import { Platform } from "react-native";
|
|
19
17
|
|
|
20
18
|
import { SkiaDomView } from "../views";
|
|
21
19
|
import type { TouchHandler } from "../views";
|
|
@@ -26,7 +24,6 @@ import { debug as hostDebug, skHostConfig } from "./HostConfig";
|
|
|
26
24
|
// import { debugTree } from "./nodes";
|
|
27
25
|
import { Container } from "./Container";
|
|
28
26
|
import { DependencyManager } from "./DependencyManager";
|
|
29
|
-
import { CanvasProvider } from "./useCanvas";
|
|
30
27
|
|
|
31
28
|
export const skiaReconciler = ReactReconciler(skHostConfig);
|
|
32
29
|
|
|
@@ -65,11 +62,8 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
|
65
62
|
) => {
|
|
66
63
|
const innerRef = useCanvasRef();
|
|
67
64
|
const ref = useCombinedRefs(forwardedRef, innerRef);
|
|
68
|
-
const [, setTick] = useState(0);
|
|
69
65
|
const redraw = useCallback(() => {
|
|
70
|
-
|
|
71
|
-
? setTick((tick) => tick + 1)
|
|
72
|
-
: innerRef.current?.redraw();
|
|
66
|
+
innerRef.current?.redraw();
|
|
73
67
|
}, [innerRef]);
|
|
74
68
|
|
|
75
69
|
const registerValues = useCallback(
|
|
@@ -107,11 +101,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
|
107
101
|
|
|
108
102
|
// Render effect
|
|
109
103
|
useEffect(() => {
|
|
110
|
-
render(
|
|
111
|
-
<CanvasProvider value={{ Skia }}>{children}</CanvasProvider>,
|
|
112
|
-
root,
|
|
113
|
-
container
|
|
114
|
-
);
|
|
104
|
+
render(children, root, container);
|
|
115
105
|
}, [children, root, redraw, container]);
|
|
116
106
|
|
|
117
107
|
useEffect(() => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import React
|
|
3
|
-
|
|
4
|
-
import { BlendMode } from "../../skia/types";
|
|
5
|
-
import { useSkiaPrivate } from "../useCanvas";
|
|
2
|
+
import React from "react";
|
|
6
3
|
|
|
7
4
|
import { Group } from "./Group";
|
|
5
|
+
import { LumaColorFilter } from "./colorFilters/LumaColorFilter";
|
|
6
|
+
import { Paint } from "./Paint";
|
|
8
7
|
|
|
9
8
|
interface MaskProps {
|
|
10
9
|
mode: "luminance" | "alpha";
|
|
@@ -14,25 +13,17 @@ interface MaskProps {
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export const Mask = ({ children, mask, mode, clip }: MaskProps) => {
|
|
17
|
-
const Skia = useSkiaPrivate();
|
|
18
|
-
const maskPaint = useMemo(() => {
|
|
19
|
-
const paint = Skia.Paint();
|
|
20
|
-
paint.setBlendMode(BlendMode.Src);
|
|
21
|
-
if (mode === "luminance") {
|
|
22
|
-
paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
|
|
23
|
-
}
|
|
24
|
-
return paint;
|
|
25
|
-
}, [Skia, mode]);
|
|
26
|
-
const clippingPaint = useMemo(() => {
|
|
27
|
-
const paint = Skia.Paint();
|
|
28
|
-
paint.setBlendMode(BlendMode.DstIn);
|
|
29
|
-
return paint;
|
|
30
|
-
}, [Skia]);
|
|
31
16
|
return (
|
|
32
17
|
<Group layer>
|
|
33
|
-
<Group
|
|
18
|
+
<Group
|
|
19
|
+
layer={
|
|
20
|
+
<Paint blendMode="src">
|
|
21
|
+
{mode === "luminance" && <LumaColorFilter />}
|
|
22
|
+
</Paint>
|
|
23
|
+
}
|
|
24
|
+
>
|
|
34
25
|
{mask}
|
|
35
|
-
{clip && <Group layer={
|
|
26
|
+
{clip && <Group layer={<Paint blendMode="dstIn" />}>{children}</Group>}
|
|
36
27
|
</Group>
|
|
37
28
|
<Group blendMode="srcIn">{children}</Group>
|
|
38
29
|
</Group>
|
package/src/renderer/index.ts
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useSkiaPrivate = exports.CanvasProvider = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
|
|
14
|
-
const CanvasContext = /*#__PURE__*/_react.default.createContext(null);
|
|
15
|
-
|
|
16
|
-
const CanvasProvider = CanvasContext.Provider; // This private function will be removed once we remove the useCanvas hook and
|
|
17
|
-
// implement the Mask component as a node (will be faster too)
|
|
18
|
-
|
|
19
|
-
exports.CanvasProvider = CanvasProvider;
|
|
20
|
-
|
|
21
|
-
const useSkiaPrivate = () => {
|
|
22
|
-
const ctx = (0, _react.useContext)(CanvasContext);
|
|
23
|
-
|
|
24
|
-
if (!ctx) {
|
|
25
|
-
throw new Error("Skia Canvas context is not available");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return ctx.Skia;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
exports.useSkiaPrivate = useSkiaPrivate;
|
|
32
|
-
//# sourceMappingURL=useCanvas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CanvasContext","React","createContext","CanvasProvider","Provider","useSkiaPrivate","ctx","useContext","Error","Skia"],"sources":["useCanvas.ts"],"sourcesContent":["import React, { useContext } from \"react\";\n\nimport type { Skia } from \"../skia/types\";\n\ninterface CanvasContext {\n Skia: Skia;\n}\n\nconst CanvasContext = React.createContext<CanvasContext | null>(null);\n\nexport const CanvasProvider = CanvasContext.Provider;\n\n// This private function will be removed once we remove the useCanvas hook and\n// implement the Mask component as a node (will be faster too)\nexport const useSkiaPrivate = () => {\n const ctx = useContext(CanvasContext);\n if (!ctx) {\n throw new Error(\"Skia Canvas context is not available\");\n }\n return ctx.Skia;\n};\n"],"mappings":";;;;;;;AAAA;;;;;;AAQA,MAAMA,aAAa,gBAAGC,cAAA,CAAMC,aAAN,CAA0C,IAA1C,CAAtB;;AAEO,MAAMC,cAAc,GAAGH,aAAa,CAACI,QAArC,C,CAEP;AACA;;;;AACO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAMC,GAAG,GAAG,IAAAC,iBAAA,EAAWP,aAAX,CAAZ;;EACA,IAAI,CAACM,GAAL,EAAU;IACR,MAAM,IAAIE,KAAJ,CAAU,sCAAV,CAAN;EACD;;EACD,OAAOF,GAAG,CAACG,IAAX;AACD,CANM"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
const CanvasContext = /*#__PURE__*/React.createContext(null);
|
|
3
|
-
export const CanvasProvider = CanvasContext.Provider; // This private function will be removed once we remove the useCanvas hook and
|
|
4
|
-
// implement the Mask component as a node (will be faster too)
|
|
5
|
-
|
|
6
|
-
export const useSkiaPrivate = () => {
|
|
7
|
-
const ctx = useContext(CanvasContext);
|
|
8
|
-
|
|
9
|
-
if (!ctx) {
|
|
10
|
-
throw new Error("Skia Canvas context is not available");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return ctx.Skia;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=useCanvas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useContext","CanvasContext","createContext","CanvasProvider","Provider","useSkiaPrivate","ctx","Error","Skia"],"sources":["useCanvas.ts"],"sourcesContent":["import React, { useContext } from \"react\";\n\nimport type { Skia } from \"../skia/types\";\n\ninterface CanvasContext {\n Skia: Skia;\n}\n\nconst CanvasContext = React.createContext<CanvasContext | null>(null);\n\nexport const CanvasProvider = CanvasContext.Provider;\n\n// This private function will be removed once we remove the useCanvas hook and\n// implement the Mask component as a node (will be faster too)\nexport const useSkiaPrivate = () => {\n const ctx = useContext(CanvasContext);\n if (!ctx) {\n throw new Error(\"Skia Canvas context is not available\");\n }\n return ctx.Skia;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AAQA,MAAMC,aAAa,gBAAGF,KAAK,CAACG,aAAN,CAA0C,IAA1C,CAAtB;AAEA,OAAO,MAAMC,cAAc,GAAGF,aAAa,CAACG,QAArC,C,CAEP;AACA;;AACA,OAAO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAMC,GAAG,GAAGN,UAAU,CAACC,aAAD,CAAtB;;EACA,IAAI,CAACK,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;EACD;;EACD,OAAOD,GAAG,CAACE,IAAX;AACD,CANM"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { Skia } from "../skia/types";
|
|
3
|
-
interface CanvasContext {
|
|
4
|
-
Skia: Skia;
|
|
5
|
-
}
|
|
6
|
-
declare const CanvasContext: React.Context<CanvasContext | null>;
|
|
7
|
-
export declare const CanvasProvider: React.Provider<CanvasContext | null>;
|
|
8
|
-
export declare const useSkiaPrivate: () => Skia;
|
|
9
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import type { Skia } from "../skia/types";
|
|
4
|
-
|
|
5
|
-
interface CanvasContext {
|
|
6
|
-
Skia: Skia;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const CanvasContext = React.createContext<CanvasContext | null>(null);
|
|
10
|
-
|
|
11
|
-
export const CanvasProvider = CanvasContext.Provider;
|
|
12
|
-
|
|
13
|
-
// This private function will be removed once we remove the useCanvas hook and
|
|
14
|
-
// implement the Mask component as a node (will be faster too)
|
|
15
|
-
export const useSkiaPrivate = () => {
|
|
16
|
-
const ctx = useContext(CanvasContext);
|
|
17
|
-
if (!ctx) {
|
|
18
|
-
throw new Error("Skia Canvas context is not available");
|
|
19
|
-
}
|
|
20
|
-
return ctx.Skia;
|
|
21
|
-
};
|