@shopify/react-native-skia 0.1.149 → 0.1.150

Sign up to get free protection for your applications and to get access to all the features.
@@ -73,6 +73,7 @@ const Mock = {
73
73
  useImage: Noop,
74
74
  useSVG: Noop,
75
75
  usePicture: Noop,
76
+ createPicture: Noop,
76
77
  // 3. Point/Rect/Transform utilities
77
78
  vec,
78
79
  rect: (x, y, width, height) => ({
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","usePicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","useSharedValueEffect","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAlBA;AAoBA,MAAMA,IAAN,CAAW;AACTC,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;AACzBC,MAAAA,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;AAEzBI,MAAAA,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;AAGzBK,MAAAA,GAAG,EAAE,MAAM;AAHc,KAApB,CAAP;AAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;;;AAEA,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAaC,CAAb;AAAA;;AAAA,SAA6B;AAAED,IAAAA,CAAC,EAAEA,CAAF,aAAEA,CAAF,cAAE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EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA1DD;AA2DJC,EAAAA,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA3D7C;AA4DJK,EAAAA,SAAS,EAATA,oBA5DI;AA6DJC,EAAAA,aAAa,EAAE7D,IA7DX;AA8DJ8D,EAAAA,iBAAiB,EAAE9D;AA9Df,CAPC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ExternalExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n usePicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","usePicture","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","useSharedValueEffect","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAlBA;AAoBA,MAAMA,IAAN,CAAW;AACTC,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;AACzBC,MAAAA,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;AAEzBI,MAAAA,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;AAGzBK,MAAAA,GAAG,EAAE,MAAM;AAHc,KAApB,CAAP;AAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;;;AAEA,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAaC,CAAb;AAAA;;AAAA,SAA6B;AAAED,IAAAA,CAAC,EAAEA,CAAF,aAAEA,CAAF,cAAEA,CAAF,GAAO,CAAV;AAAaC,IAAAA,CAAC,UAAEA,CAAF,aAAEA,CAAF,cAAEA,CAAF,GAAOD,CAAP,uCAAY;AAA1B,GAA7B;AAAA,CAAZ;;;AAEA,MAAME,IAOV,GAAG;AACJ;AACA;AACAJ,EAAAA,IAHI;AAIJ,KAAGK,QAJC;AAKJ;AACAC,EAAAA,UAAU,EAAEP,IANR;AAOJQ,EAAAA,OAAO,EAAER,IAPL;AAQJS,EAAAA,OAAO,EAAET,IARL;AASJU,EAAAA,WAAW,EAAEV,IATT;AAUJW,EAAAA,QAAQ,EAAEX,IAVN;AAWJY,EAAAA,MAAM,EAAEZ,IAXJ;AAYJa,EAAAA,UAAU,EAAEb,IAZR;AAaJc,EAAAA,aAAa,EAAEd,IAbX;AAcJ;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,WACT,CAAC;AAAE4B,MAAAA,UAAU,EAAE7B;AAAd,KAAD,EAAoB;AAAE8B,MAAAA,UAAU,EAAE7B;AAAd,KAApB,CADS;AAAA,GAhCP;AAmCJ8B,EAAAA,MAAM,EAAElC,IAnCJ;AAoCJmC,EAAAA,OAAO,EAAEnC,IApCL;AAqCJoC,EAAAA,QAAQ,EAAEpC,IArCN;AAsCJqC,EAAAA,UAAU,EAAErC,IAtCR;AAuCJsC,EAAAA,WAAW,EAAEtC,IAvCT;AAwCJuC,EAAAA,MAAM,EAAEvC,IAxCJ;AAyCJwC,EAAAA,kBAAkB,EAAExC,IAzChB;AA0CJ;AACAyC,EAAAA,oBAAoB,EAApBA,0CA3CI;AA4CJ;AACA,KAAGC,MA7CC;AA8CJ,KAAGC,WA9CC;AA+CJC,EAAAA,QAAQ,EAARA,kBA/CI;AAgDJ;AACA,KAAGC,eAjDC;AAkDJ,KAAGC,eAlDC;AAmDJ,KAAGC,cAnDC;AAoDJ,KAAGC,aApDC;AAqDJ,KAAGC,iBArDC;AAsDJ,KAAGC,mBAtDC;AAuDJC,EAAAA,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA3DD;AA4DJC,EAAAA,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA5D7C;AA6DJK,EAAAA,SAAS,EAATA,oBA7DI;AA8DJC,EAAAA,aAAa,EAAE9D,IA9DX;AA+DJ+D,EAAAA,iBAAiB,EAAE/D;AA/Df,CAPC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ExternalExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n usePicture: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.usePicture = void 0;
6
+ exports.usePicture = exports.createPicture = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
@@ -17,14 +17,32 @@ var _Skia = require("../Skia");
17
17
  */
18
18
  const usePicture = function (rect, cb) {
19
19
  let deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
20
+ console.warn("usePicture() is deprecated. Use createPicture() instead.");
20
21
  return (0, _react.useMemo)(() => {
21
22
  const recorder = _Skia.Skia.PictureRecorder();
22
23
 
23
24
  const canvas = recorder.beginRecording(rect);
24
25
  cb(canvas);
25
26
  return recorder.finishRecordingAsPicture(); // eslint-disable-next-line react-hooks/exhaustive-deps
26
- }, [cb, rect, deps]);
27
+ }, deps);
27
28
  };
29
+ /**
30
+ * Memoizes and returns an SkPicture that can be drawn to another canvas.
31
+ * @param rect Picture bounds
32
+ * @param cb Callback for drawing to the canvas
33
+ * @returns SkPicture
34
+ */
35
+
28
36
 
29
37
  exports.usePicture = usePicture;
38
+
39
+ const createPicture = (rect, cb) => {
40
+ const recorder = _Skia.Skia.PictureRecorder();
41
+
42
+ const canvas = recorder.beginRecording(rect);
43
+ cb(canvas);
44
+ return recorder.finishRecordingAsPicture();
45
+ };
46
+
47
+ exports.createPicture = createPicture;
30
48
  //# sourceMappingURL=Picture.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Picture.ts"],"names":["usePicture","rect","cb","deps","recorder","Skia","PictureRecorder","canvas","beginRecording","finishRecordingAsPicture"],"mappings":";;;;;;;AACA;;AAEA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,UACxBC,IADwB,EAExBC,EAFwB,EAIV;AAAA,MADdC,IACc,uEADS,EACT;AACd,SAAO,oBAAQ,MAAM;AACnB,UAAMC,QAAQ,GAAGC,WAAKC,eAAL,EAAjB;;AACA,UAAMC,MAAM,GAAGH,QAAQ,CAACI,cAAT,CAAwBP,IAAxB,CAAf;AACAC,IAAAA,EAAE,CAACK,MAAD,CAAF;AACA,WAAOH,QAAQ,CAACK,wBAAT,EAAP,CAJmB,CAKnB;AACD,GANM,EAMJ,CAACP,EAAD,EAAKD,IAAL,EAAWE,IAAX,CANI,CAAP;AAOD,CAZM","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkCanvas, SkPicture, SkRect } from \"../types\";\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const usePicture = (\n rect: SkRect,\n cb: (canvas: SkCanvas) => void,\n deps: DependencyList = []\n): SkPicture => {\n return useMemo(() => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [cb, rect, deps]);\n};\n"]}
1
+ {"version":3,"sources":["Picture.ts"],"names":["usePicture","rect","cb","deps","console","warn","recorder","Skia","PictureRecorder","canvas","beginRecording","finishRecordingAsPicture","createPicture"],"mappings":";;;;;;;AACA;;AAEA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,UACxBC,IADwB,EAExBC,EAFwB,EAIrB;AAAA,MADHC,IACG,uEADoB,EACpB;AACHC,EAAAA,OAAO,CAACC,IAAR,CAAa,0DAAb;AACA,SAAO,oBAAQ,MAAM;AACnB,UAAMC,QAAQ,GAAGC,WAAKC,eAAL,EAAjB;;AACA,UAAMC,MAAM,GAAGH,QAAQ,CAACI,cAAT,CAAwBT,IAAxB,CAAf;AACAC,IAAAA,EAAE,CAACO,MAAD,CAAF;AACA,WAAOH,QAAQ,CAACK,wBAAT,EAAP,CAJmB,CAKnB;AACD,GANM,EAMJR,IANI,CAAP;AAOD,CAbM;AAeP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMS,aAAa,GAAG,CAACX,IAAD,EAAeC,EAAf,KAAkD;AAC7E,QAAMI,QAAQ,GAAGC,WAAKC,eAAL,EAAjB;;AACA,QAAMC,MAAM,GAAGH,QAAQ,CAACI,cAAT,CAAwBT,IAAxB,CAAf;AACAC,EAAAA,EAAE,CAACO,MAAD,CAAF;AACA,SAAOH,QAAQ,CAACK,wBAAT,EAAP;AACD,CALM","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkCanvas, SkRect } from \"../types\";\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const usePicture = (\n rect: SkRect,\n cb: (canvas: SkCanvas) => void,\n deps: DependencyList = []\n) => {\n console.warn(\"usePicture() is deprecated. Use createPicture() instead.\");\n return useMemo(() => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const createPicture = (rect: SkRect, cb: (canvas: SkCanvas) => void) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n};\n"]}
@@ -47,6 +47,7 @@ export const Mock = {
47
47
  useImage: Noop,
48
48
  useSVG: Noop,
49
49
  usePicture: Noop,
50
+ createPicture: Noop,
50
51
  // 3. Point/Rect/Transform utilities
51
52
  vec,
52
53
  rect: (x, y, width, height) => ({
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["Values","ValuesHooks","Selector","BaseSkia","useSharedValueEffect","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","useRawData","useData","useFont","useTypeface","useImage","useSVG","usePicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","createDrawing","createDeclaration"],"mappings":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAKA,SAASC,oBAAT,QAAqC,6CAArC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO,KAAKC,aAAZ,MAA+B,oCAA/B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,yCAAnC;AAC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nCL;AAoCJkC,EAAAA,QAAQ,EAAElC,IApCN;AAqCJmC,EAAAA,UAAU,EAAEnC,IArCR;AAsCJoC,EAAAA,WAAW,EAAEpC,IAtCT;AAuCJqC,EAAAA,MAAM,EAAErC,IAvCJ;AAwCJsC,EAAAA,kBAAkB,EAAEtC,IAxChB;AAyCJ;AACAd,EAAAA,oBA1CI;AA2CJ;AACA,KAAGJ,MA5CC;AA6CJ,KAAGC,WA7CC;AA8CJC,EAAAA,QA9CI;AA+CJ;AACA,KAAGG,eAhDC;AAiDJ,KAAGC,eAjDC;AAkDJ,KAAGC,cAlDC;AAmDJ,KAAGC,aAnDC;AAoDJ,KAAGC,iBApDC;AAqDJ,KAAGC,mBArDC;AAsDJ+C,EAAAA,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA1DD;AA2DJC,EAAAA,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA3D7C;AA4DJnD,EAAAA,SA5DI;AA6DJwD,EAAAA,aAAa,EAAEjD,IA7DX;AA8DJkD,EAAAA,iBAAiB,EAAElD;AA9Df,CAPC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ExternalExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n usePicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["Values","ValuesHooks","Selector","BaseSkia","useSharedValueEffect","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","useRawData","useData","useFont","useTypeface","useImage","useSVG","usePicture","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","createDrawing","createDeclaration"],"mappings":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAKA,SAASC,oBAAT,QAAqC,6CAArC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO,KAAKC,aAAZ,MAA+B,oCAA/B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,yCAAnC;AACA,OAAO,KAAKC,mBAAZ,MAAqC,0CAArC;AACA,SAASC,SAAT,QAA0B,0CAA1B;;AAEA,MAAMC,IAAN,CAAW;AACTC,EAAAA,WAAW,GAAG;AACZ,WAAO,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WAAW,EAAErC,IAvCT;AAwCJsC,EAAAA,MAAM,EAAEtC,IAxCJ;AAyCJuC,EAAAA,kBAAkB,EAAEvC,IAzChB;AA0CJ;AACAd,EAAAA,oBA3CI;AA4CJ;AACA,KAAGJ,MA7CC;AA8CJ,KAAGC,WA9CC;AA+CJC,EAAAA,QA/CI;AAgDJ;AACA,KAAGG,eAjDC;AAkDJ,KAAGC,eAlDC;AAmDJ,KAAGC,cAnDC;AAoDJ,KAAGC,aApDC;AAqDJ,KAAGC,iBArDC;AAsDJ,KAAGC,mBAtDC;AAuDJgD,EAAAA,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA3DD;AA4DJC,EAAAA,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA5D7C;AA6DJpD,EAAAA,SA7DI;AA8DJyD,EAAAA,aAAa,EAAElD,IA9DX;AA+DJmD,EAAAA,iBAAiB,EAAEnD;AA/Df,CAPC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ExternalExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n usePicture: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"]}
@@ -9,11 +9,25 @@ import { Skia } from "../Skia";
9
9
  */
10
10
  export const usePicture = function (rect, cb) {
11
11
  let deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
12
+ console.warn("usePicture() is deprecated. Use createPicture() instead.");
12
13
  return useMemo(() => {
13
14
  const recorder = Skia.PictureRecorder();
14
15
  const canvas = recorder.beginRecording(rect);
15
16
  cb(canvas);
16
17
  return recorder.finishRecordingAsPicture(); // eslint-disable-next-line react-hooks/exhaustive-deps
17
- }, [cb, rect, deps]);
18
+ }, deps);
19
+ };
20
+ /**
21
+ * Memoizes and returns an SkPicture that can be drawn to another canvas.
22
+ * @param rect Picture bounds
23
+ * @param cb Callback for drawing to the canvas
24
+ * @returns SkPicture
25
+ */
26
+
27
+ export const createPicture = (rect, cb) => {
28
+ const recorder = Skia.PictureRecorder();
29
+ const canvas = recorder.beginRecording(rect);
30
+ cb(canvas);
31
+ return recorder.finishRecordingAsPicture();
18
32
  };
19
33
  //# sourceMappingURL=Picture.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Picture.ts"],"names":["useMemo","Skia","usePicture","rect","cb","deps","recorder","PictureRecorder","canvas","beginRecording","finishRecordingAsPicture"],"mappings":"AACA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,IAAT,QAAqB,SAArB;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,UACxBC,IADwB,EAExBC,EAFwB,EAIV;AAAA,MADdC,IACc,uEADS,EACT;AACd,SAAOL,OAAO,CAAC,MAAM;AACnB,UAAMM,QAAQ,GAAGL,IAAI,CAACM,eAAL,EAAjB;AACA,UAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAT,CAAwBN,IAAxB,CAAf;AACAC,IAAAA,EAAE,CAACI,MAAD,CAAF;AACA,WAAOF,QAAQ,CAACI,wBAAT,EAAP,CAJmB,CAKnB;AACD,GANa,EAMX,CAACN,EAAD,EAAKD,IAAL,EAAWE,IAAX,CANW,CAAd;AAOD,CAZM","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkCanvas, SkPicture, SkRect } from \"../types\";\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const usePicture = (\n rect: SkRect,\n cb: (canvas: SkCanvas) => void,\n deps: DependencyList = []\n): SkPicture => {\n return useMemo(() => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [cb, rect, deps]);\n};\n"]}
1
+ {"version":3,"sources":["Picture.ts"],"names":["useMemo","Skia","usePicture","rect","cb","deps","console","warn","recorder","PictureRecorder","canvas","beginRecording","finishRecordingAsPicture","createPicture"],"mappings":"AACA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,IAAT,QAAqB,SAArB;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,UACxBC,IADwB,EAExBC,EAFwB,EAIrB;AAAA,MADHC,IACG,uEADoB,EACpB;AACHC,EAAAA,OAAO,CAACC,IAAR,CAAa,0DAAb;AACA,SAAOP,OAAO,CAAC,MAAM;AACnB,UAAMQ,QAAQ,GAAGP,IAAI,CAACQ,eAAL,EAAjB;AACA,UAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAT,CAAwBR,IAAxB,CAAf;AACAC,IAAAA,EAAE,CAACM,MAAD,CAAF;AACA,WAAOF,QAAQ,CAACI,wBAAT,EAAP,CAJmB,CAKnB;AACD,GANa,EAMXP,IANW,CAAd;AAOD,CAbM;AAeP;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMQ,aAAa,GAAG,CAACV,IAAD,EAAeC,EAAf,KAAkD;AAC7E,QAAMI,QAAQ,GAAGP,IAAI,CAACQ,eAAL,EAAjB;AACA,QAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAT,CAAwBR,IAAxB,CAAf;AACAC,EAAAA,EAAE,CAACM,MAAD,CAAF;AACA,SAAOF,QAAQ,CAACI,wBAAT,EAAP;AACD,CALM","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkCanvas, SkRect } from \"../types\";\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const usePicture = (\n rect: SkRect,\n cb: (canvas: SkCanvas) => void,\n deps: DependencyList = []\n) => {\n console.warn(\"usePicture() is deprecated. Use createPicture() instead.\");\n return useMemo(() => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const createPicture = (rect: SkRect, cb: (canvas: SkCanvas) => void) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n};\n"]}
@@ -1,9 +1,16 @@
1
1
  import type { DependencyList } from "react";
2
- import type { SkCanvas, SkPicture, SkRect } from "../types";
2
+ import type { SkCanvas, SkRect } from "../types";
3
3
  /**
4
4
  * Memoizes and returns an SkPicture that can be drawn to another canvas.
5
5
  * @param rect Picture bounds
6
6
  * @param cb Callback for drawing to the canvas
7
7
  * @returns SkPicture
8
8
  */
9
- export declare const usePicture: (rect: SkRect, cb: (canvas: SkCanvas) => void, deps?: DependencyList) => SkPicture;
9
+ export declare const usePicture: (rect: SkRect, cb: (canvas: SkCanvas) => void, deps?: DependencyList) => import("../types").SkPicture;
10
+ /**
11
+ * Memoizes and returns an SkPicture that can be drawn to another canvas.
12
+ * @param rect Picture bounds
13
+ * @param cb Callback for drawing to the canvas
14
+ * @returns SkPicture
15
+ */
16
+ export declare const createPicture: (rect: SkRect, cb: (canvas: SkCanvas) => void) => import("../types").SkPicture;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.149",
10
+ "version": "0.1.150",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
package/src/mock/index.ts CHANGED
@@ -54,6 +54,7 @@ export const Mock: typeof SkiaExports &
54
54
  useImage: Noop,
55
55
  useSVG: Noop,
56
56
  usePicture: Noop,
57
+ createPicture: Noop,
57
58
  // 3. Point/Rect/Transform utilities
58
59
  vec,
59
60
  rect: (x: number, y: number, width: number, height: number) => ({
@@ -2,7 +2,7 @@ import type { DependencyList } from "react";
2
2
  import { useMemo } from "react";
3
3
 
4
4
  import { Skia } from "../Skia";
5
- import type { SkCanvas, SkPicture, SkRect } from "../types";
5
+ import type { SkCanvas, SkRect } from "../types";
6
6
 
7
7
  /**
8
8
  * Memoizes and returns an SkPicture that can be drawn to another canvas.
@@ -14,12 +14,26 @@ export const usePicture = (
14
14
  rect: SkRect,
15
15
  cb: (canvas: SkCanvas) => void,
16
16
  deps: DependencyList = []
17
- ): SkPicture => {
17
+ ) => {
18
+ console.warn("usePicture() is deprecated. Use createPicture() instead.");
18
19
  return useMemo(() => {
19
20
  const recorder = Skia.PictureRecorder();
20
21
  const canvas = recorder.beginRecording(rect);
21
22
  cb(canvas);
22
23
  return recorder.finishRecordingAsPicture();
23
24
  // eslint-disable-next-line react-hooks/exhaustive-deps
24
- }, [cb, rect, deps]);
25
+ }, deps);
26
+ };
27
+
28
+ /**
29
+ * Memoizes and returns an SkPicture that can be drawn to another canvas.
30
+ * @param rect Picture bounds
31
+ * @param cb Callback for drawing to the canvas
32
+ * @returns SkPicture
33
+ */
34
+ export const createPicture = (rect: SkRect, cb: (canvas: SkCanvas) => void) => {
35
+ const recorder = Skia.PictureRecorder();
36
+ const canvas = recorder.beginRecording(rect);
37
+ cb(canvas);
38
+ return recorder.finishRecordingAsPicture();
25
39
  };