@shopify/react-native-skia 0.1.118 → 0.1.119

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/lib/commonjs/renderer/HostConfig.js +1 -1
  2. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  3. package/lib/commonjs/renderer/components/Group.js +6 -3
  4. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  5. package/lib/commonjs/renderer/components/Paint.js +1 -21
  6. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  7. package/lib/commonjs/renderer/components/index.js +0 -13
  8. package/lib/commonjs/renderer/components/index.js.map +1 -1
  9. package/lib/commonjs/renderer/nodes/Declaration.js +5 -1
  10. package/lib/commonjs/renderer/nodes/Declaration.js.map +1 -1
  11. package/lib/commonjs/renderer/nodes/Drawing.js +4 -16
  12. package/lib/commonjs/renderer/nodes/Drawing.js.map +1 -1
  13. package/lib/commonjs/renderer/nodes/Node.js +9 -16
  14. package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
  15. package/lib/commonjs/renderer/processors/Paint.js +24 -26
  16. package/lib/commonjs/renderer/processors/Paint.js.map +1 -1
  17. package/lib/module/renderer/HostConfig.js +1 -1
  18. package/lib/module/renderer/HostConfig.js.map +1 -1
  19. package/lib/module/renderer/components/Group.js +7 -5
  20. package/lib/module/renderer/components/Group.js.map +1 -1
  21. package/lib/module/renderer/components/Paint.js +2 -22
  22. package/lib/module/renderer/components/Paint.js.map +1 -1
  23. package/lib/module/renderer/components/index.js +0 -1
  24. package/lib/module/renderer/components/index.js.map +1 -1
  25. package/lib/module/renderer/nodes/Declaration.js +1 -0
  26. package/lib/module/renderer/nodes/Declaration.js.map +1 -1
  27. package/lib/module/renderer/nodes/Drawing.js +5 -17
  28. package/lib/module/renderer/nodes/Drawing.js.map +1 -1
  29. package/lib/module/renderer/nodes/Node.js +9 -15
  30. package/lib/module/renderer/nodes/Node.js.map +1 -1
  31. package/lib/module/renderer/processors/Paint.js +22 -21
  32. package/lib/module/renderer/processors/Paint.js.map +1 -1
  33. package/lib/typescript/src/renderer/Canvas.d.ts +1 -1
  34. package/lib/typescript/src/renderer/components/index.d.ts +0 -1
  35. package/lib/typescript/src/renderer/nodes/Declaration.d.ts +1 -0
  36. package/lib/typescript/src/renderer/nodes/Node.d.ts +2 -2
  37. package/lib/typescript/src/renderer/processors/Paint.d.ts +2 -2
  38. package/package.json +1 -1
  39. package/src/renderer/HostConfig.ts +1 -1
  40. package/src/renderer/components/Group.tsx +24 -14
  41. package/src/renderer/components/Paint.tsx +5 -35
  42. package/src/renderer/components/index.ts +0 -1
  43. package/src/renderer/nodes/Declaration.tsx +4 -0
  44. package/src/renderer/nodes/Drawing.tsx +10 -20
  45. package/src/renderer/nodes/Node.ts +9 -12
  46. package/src/renderer/processors/Paint.ts +34 -31
  47. package/lib/commonjs/renderer/components/Defs.js +0 -30
  48. package/lib/commonjs/renderer/components/Defs.js.map +0 -1
  49. package/lib/module/renderer/components/Defs.js +0 -16
  50. package/lib/module/renderer/components/Defs.js.map +0 -1
  51. package/lib/typescript/src/renderer/components/Defs.d.ts +0 -5
  52. package/src/renderer/components/Defs.tsx +0 -19
@@ -2,8 +2,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React from "react";
4
4
  import { ClipOp } from "../../skia";
5
- import { processTransform, selectPaint, processPaint, processClip } from "../processors";
6
- import { createDrawing } from "../nodes";
5
+ import { processTransform, processPaint, processClip } from "../processors";
6
+ import { createDrawing, DrawingNode } from "../nodes";
7
+ import { isDeclarationNode } from "../nodes/Declaration";
7
8
 
8
9
  const isSkPaint = obj => "__typename__" in obj && obj.__typename__ === "Paint";
9
10
 
@@ -18,8 +19,9 @@ const onDraw = createDrawing((ctx, _ref, node) => {
18
19
  canvas,
19
20
  opacity
20
21
  } = ctx;
21
- const paint = selectPaint(ctx.paint, groupProps);
22
- processPaint(paint, opacity, groupProps);
22
+ const declarations = node.children.filter(isDeclarationNode).map(child => child.draw(ctx));
23
+ const drawings = node.children.filter(child => child instanceof DrawingNode);
24
+ const paint = processPaint(ctx.paint.copy(), opacity, groupProps, declarations);
23
25
  const hasTransform = !!groupProps.transform || !!groupProps.matrix;
24
26
  const hasClip = !!clip;
25
27
  const shouldSave = hasTransform || hasClip || !!layer;
@@ -50,7 +52,7 @@ const onDraw = createDrawing((ctx, _ref, node) => {
50
52
  node.visit({ ...ctx,
51
53
  paint,
52
54
  opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity
53
- });
55
+ }, drawings);
54
56
 
55
57
  if (shouldSave) {
56
58
  canvas.restore();
@@ -1 +1 @@
1
- {"version":3,"sources":["Group.tsx"],"names":["React","ClipOp","processTransform","selectPaint","processPaint","processClip","createDrawing","isSkPaint","obj","__typename__","onDraw","ctx","node","layer","clip","invertClip","groupProps","canvas","opacity","paint","hasTransform","transform","matrix","hasClip","shouldSave","saveLayer","current","undefined","save","op","Difference","Intersect","visit","restore","Group","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAIA,SAASC,MAAT,QAAuB,YAAvB;AACA,SACEC,gBADF,EAEEC,WAFF,EAGEC,YAHF,EAIEC,WAJF,QAKO,eALP;AAYA,SAASC,aAAT,QAA8B,UAA9B;;AAEA,MAAMC,SAAS,GAAIC,GAAD,IAChB,kBAAkBA,GAAlB,IAAyBA,GAAG,CAACC,YAAJ,KAAqB,OADhD;;AASA,MAAMC,MAAM,GAAGJ,aAAa,CAC1B,CAACK,GAAD,QAAkDC,IAAlD,KAA2D;AAAA,MAArD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA,UAAf;AAA2B,OAAGC;AAA9B,GAAqD;AACzD,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAsBP,GAA5B;AACA,QAAMQ,KAAK,GAAGhB,WAAW,CAACQ,GAAG,CAACQ,KAAL,EAAYH,UAAZ,CAAzB;AACAZ,EAAAA,YAAY,CAACe,KAAD,EAAQD,OAAR,EAAiBF,UAAjB,CAAZ;AACA,QA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/B;AAAsC,IAAA,cAAc;AAApD,KAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { RefObject } from \"react\";\n\nimport type { SkPaint } from \"../../skia\";\nimport { ClipOp } from \"../../skia\";\nimport {\n processTransform,\n selectPaint,\n processPaint,\n processClip,\n} from \"../processors\";\nimport type {\n CustomPaintProps,\n TransformProps,\n AnimatedProps,\n ClipDef,\n} from \"../processors\";\nimport { createDrawing } from \"../nodes\";\n\nconst isSkPaint = (obj: RefObject<SkPaint> | SkPaint): obj is SkPaint =>\n \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nexport interface GroupProps extends CustomPaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: RefObject<SkPaint> | SkPaint | boolean;\n}\n\nconst onDraw = createDrawing<GroupProps>(\n (ctx, { layer, clip, invertClip, ...groupProps }, node) => {\n const { canvas, opacity } = ctx;\n const paint = selectPaint(ctx.paint, groupProps);\n processPaint(paint, opacity, groupProps);\n const hasTransform = !!groupProps.transform || !!groupProps.matrix;\n const hasClip = !!clip;\n const shouldSave = hasTransform || hasClip || !!layer;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else if (isSkPaint(layer)) {\n canvas.saveLayer(layer);\n } else {\n canvas.saveLayer(layer.current ?? undefined);\n }\n } else {\n canvas.save();\n }\n processTransform(ctx, groupProps);\n if (clip) {\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n processClip(canvas, clip, op);\n }\n }\n node.visit({\n ...ctx,\n paint,\n opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity,\n });\n if (shouldSave) {\n canvas.restore();\n }\n }\n);\n\nexport const Group = (props: AnimatedProps<GroupProps>) => {\n return <skDrawing onDraw={onDraw} {...props} skipProcessing />;\n};\n"]}
1
+ {"version":3,"sources":["Group.tsx"],"names":["React","ClipOp","processTransform","processPaint","processClip","createDrawing","DrawingNode","isDeclarationNode","isSkPaint","obj","__typename__","onDraw","ctx","node","layer","clip","invertClip","groupProps","canvas","opacity","declarations","children","filter","map","child","draw","drawings","paint","copy","hasTransform","transform","matrix","hasClip","shouldSave","saveLayer","current","undefined","save","op","Difference","Intersect","visit","restore","Group","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAIA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,gBAAT,EAA2BC,YAA3B,EAAyCC,WAAzC,QAA4D,eAA5D;AAOA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,UAA3C;AACA,SAASC,iBAAT,QAAkC,sBAAlC;;AAEA,MAAMC,SAAS,GAAIC,GAAD,IAChB,kBAAkBA,GAAlB,IAAyBA,GAAG,CAACC,YAAJ,KAAqB,OADhD;;AASA,MAAMC,MAAM,GAAGN,aAAa,CAC1B,CAACO,GAAD,QAAkDC,IAAlD,KAA2D;AAAA,MAArD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA,UAAf;AAA2B,OAAGC;AAA9B,GAAqD;AACzD,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAsBP,GAA5B;AACA,QAAMQ,YAAY,GAAGP,IAAI,CAACQ,QAAL,CAClBC,MADkB,CACXf,iBADW,EAElBgB,GAFkB,CAEbC,KAAD,IAAWA,KAAK,CAACC,IAAN,CAAWb,GAAX,CAFG,CAArB;AAIA,QAAMc,QAAQ,GAAGb,IAAI,CAACQ,QAAL,CAAcC,MAAd,CACdE,KAAD,IAAWA,KAAK,YAAYlB,WADb,CAAjB;AAGA,QAAMqB,KAAK,GAAGxB,YAAY,CACxBS,GAAG,CAACe,KAAJ,CAAUC,IAAV,EADwB,EAExBT,OAFwB,EAGxBF,UAHwB,EAIxBG,YAJwB,CAA1B;AAMA,QAAMS,YAAY,GAAG,CAAC,CAACZ,UAAU,CAACa,SAAb,IAA0B,CAAC,CAACb,UAAU,CAACc,MAA5D;AACA,QAAMC,OAAO,GAAG,CAAC,CAACjB,IAAlB;AACA,QAAMkB,UAAU,GAAGJ,YAAY,IAAIG,OAAhB,IAA2B,CAAC,CAAClB,KAAhD;;AACA,MAAImB,UAAJ,EAAgB;AACd,QAAInB,KAAJ,EAAW;AACT,UAAI,OAAOA,KAAP,KAAiB,SAArB,EAAgC;AAC9BI,QAAAA,MAAM,CAACgB,SAAP;AACD,OAFD,MAEO,IAAI1B,SAAS,CAACM,KAAD,CAAb,EAAsB;AAC3BI,QAAAA,MAAM,CAACgB,SAAP,CAAiBpB,KAAjB;AACD,OAFM,MAEA;AAAA;;AACLI,QAAAA,MAAM,CAACgB,SAAP,mBAAiBpB,KAAK,CAACqB,OAAvB,2DAAkCC,SAAlC;AACD;AACF,KARD,MAQO;AACLlB,MAAAA,MAAM,CAACmB,IAAP;AACD;;AACDnC,IAAAA,gBAAgB,CAACU,GAAD,EAAMK,UAAN,CAAhB;;AACA,QAAIF,IAAJ,EAAU;AACR,YAAMuB,EAAE,GAAGtB,UAAU,GAAGf,MAAM,CAACsC,UAAV,GAAuBtC,MAAM,CAACuC,SAAnD;AACApC,MAAAA,WAAW,CAACc,MAAD,EAASH,IAAT,EAAeuB,EAAf,CAAX;AACD;AACF;;AACDzB,EAAAA,IAAI,CAAC4B,KAAL,CACE,EACE,GAAG7B,GADL;AAEEe,IAAAA,KAFF;AAGER,IAAAA,OAAO,EAAEF,UAAU,CAACE,OAAX,GAAqBF,UAAU,CAACE,OAAX,GAAqBA,OAA1C,GAAoDA;AAH/D,GADF,EAMEO,QANF;;AAQA,MAAIO,UAAJ,EAAgB;AACdf,IAAAA,MAAM,CAACwB,OAAP;AACD;AACF,CAhDyB,CAA5B;AAmDA,OAAO,MAAMC,KAAK,GAAIC,KAAD,IAAsC;AACzD,sBAAO;AAAW,IAAA,MAAM,EAAEjC;AAAnB,KAA+BiC,KAA/B;AAAsC,IAAA,cAAc;AAApD,KAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { RefObject } from \"react\";\n\nimport type { SkPaint } from \"../../skia\";\nimport { ClipOp } from \"../../skia\";\nimport { processTransform, processPaint, processClip } from \"../processors\";\nimport type {\n CustomPaintProps,\n TransformProps,\n AnimatedProps,\n ClipDef,\n} from \"../processors\";\nimport { createDrawing, DrawingNode } from \"../nodes\";\nimport { isDeclarationNode } from \"../nodes/Declaration\";\n\nconst isSkPaint = (obj: RefObject<SkPaint> | SkPaint): obj is SkPaint =>\n \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nexport interface GroupProps extends CustomPaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: RefObject<SkPaint> | SkPaint | boolean;\n}\n\nconst onDraw = createDrawing<GroupProps>(\n (ctx, { layer, clip, invertClip, ...groupProps }, node) => {\n const { canvas, opacity } = ctx;\n const declarations = node.children\n .filter(isDeclarationNode)\n .map((child) => child.draw(ctx));\n\n const drawings = node.children.filter(\n (child) => child instanceof DrawingNode\n );\n const paint = processPaint(\n ctx.paint.copy(),\n opacity,\n groupProps,\n declarations\n );\n const hasTransform = !!groupProps.transform || !!groupProps.matrix;\n const hasClip = !!clip;\n const shouldSave = hasTransform || hasClip || !!layer;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else if (isSkPaint(layer)) {\n canvas.saveLayer(layer);\n } else {\n canvas.saveLayer(layer.current ?? undefined);\n }\n } else {\n canvas.save();\n }\n processTransform(ctx, groupProps);\n if (clip) {\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n processClip(canvas, clip, op);\n }\n }\n node.visit(\n {\n ...ctx,\n paint,\n opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity,\n },\n drawings\n );\n if (shouldSave) {\n canvas.restore();\n }\n }\n);\n\nexport const Group = (props: AnimatedProps<GroupProps>) => {\n return <skDrawing onDraw={onDraw} {...props} skipProcessing />;\n};\n"]}
@@ -1,34 +1,14 @@
1
1
  function _extends() { _extends = Object.assign || 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, { useRef, useMemo, forwardRef, useImperativeHandle } from "react";
4
- import { isShader, isMaskFilter, isColorFilter, Skia, isImageFilter, isPathEffect } from "../../skia";
4
+ import { Skia } from "../../skia";
5
5
  import { processPaint } from "../processors";
6
6
  import { createDeclaration } from "../nodes";
7
7
  export const usePaintRef = () => useRef(null);
8
8
  export const Paint = /*#__PURE__*/forwardRef((props, ref) => {
9
9
  const paint = useMemo(() => Skia.Paint(), []);
10
10
  useImperativeHandle(ref, () => paint, [paint]);
11
- const onDeclare = useMemo(() => createDeclaration((paintProps, children, ctx) => {
12
- processPaint(paint, ctx.opacity, paintProps);
13
- children.forEach(child => {
14
- if (isShader(child)) {
15
- paint.setShader(child);
16
- } else if (isMaskFilter(child)) {
17
- paint.setMaskFilter(child);
18
- } else if (isColorFilter(child)) {
19
- paint.setColorFilter(child);
20
- } else if (isPathEffect(child)) {
21
- paint.setPathEffect(child);
22
- }
23
- });
24
- const filters = children.filter(isImageFilter);
25
-
26
- if (filters.length > 0) {
27
- paint.setImageFilter(filters.reverse().reduce(Skia.ImageFilter.MakeCompose, null));
28
- }
29
-
30
- return paint;
31
- }), [paint]);
11
+ const onDeclare = useMemo(() => createDeclaration((paintProps, children, ctx) => processPaint(paint, ctx.opacity, paintProps, children)), [paint]);
32
12
  return /*#__PURE__*/React.createElement("skDeclaration", _extends({
33
13
  onDeclare: onDeclare
34
14
  }, props));
@@ -1 +1 @@
1
- {"version":3,"sources":["Paint.tsx"],"names":["React","useRef","useMemo","forwardRef","useImperativeHandle","isShader","isMaskFilter","isColorFilter","Skia","isImageFilter","isPathEffect","processPaint","createDeclaration","usePaintRef","Paint","props","ref","paint","onDeclare","paintProps","children","ctx","opacity","forEach","child","setShader","setMaskFilter","setColorFilter","setPathEffect","filters","filter","length","setImageFilter","reverse","reduce","ImageFilter","MakeCompose"],"mapp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AApB;AACD;AACF,KAVD;AAWA,UAAMK,OAAO,GAAGT,QAAQ,CAACU,MAAT,CAAgBrB,aAAhB,CAAhB;;AACA,QAAIoB,OAAO,CAACE,MAAR,GAAiB,CAArB,EAAwB;AACtBd,MAAAA,KAAK,CAACe,cAAN,CACEH,OAAO,CACJI,OADH,GAEGC,MAFH,CAGI1B,IAAI,CAAC2B,WAAL,CAAiBC,WAHrB,EAII,IAJJ,CADF;AAQD;;AACD,WAAOnB,KAAP;AACD,GAzBgB,CAFI,EA4BvB,CAACA,KAAD,CA5BuB,CAAzB;AA8BA,sBAAO;AAAe,IAAA,SAAS,EAAEC;AAA1B,KAAyCH,KAAzC,EAAP;AACD,CAnC4B,CAAxB","sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useRef, useMemo, forwardRef, useImperativeHandle } from \"react\";\n\nimport type { SkPaint, SkImageFilter } from \"../../skia\";\nimport {\n isShader,\n isMaskFilter,\n isColorFilter,\n Skia,\n isImageFilter,\n isPathEffect,\n} from \"../../skia\";\nimport type { CustomPaintProps, AnimatedProps } from \"../processors\";\nimport { processPaint } from \"../processors\";\nimport { createDeclaration } from \"../nodes\";\n\nexport const usePaintRef = () => useRef<SkPaint>(null);\n\nexport interface PaintProps extends Omit<CustomPaintProps, \"paint\"> {\n children?: ReactNode | ReactNode[];\n}\n\nexport const Paint = forwardRef<SkPaint, AnimatedProps<PaintProps>>(\n (props, ref) => {\n const paint = useMemo(() => Skia.Paint(), []);\n useImperativeHandle(ref, () => paint, [paint]);\n const onDeclare = useMemo(\n () =>\n createDeclaration<PaintProps>((paintProps, children, ctx) => {\n processPaint(paint, ctx.opacity, paintProps);\n children.forEach((child) => {\n if (isShader(child)) {\n paint.setShader(child);\n } else if (isMaskFilter(child)) {\n paint.setMaskFilter(child);\n } else if (isColorFilter(child)) {\n paint.setColorFilter(child);\n } else if (isPathEffect(child)) {\n paint.setPathEffect(child);\n }\n });\n const filters = children.filter(isImageFilter);\n if (filters.length > 0) {\n paint.setImageFilter(\n filters\n .reverse()\n .reduce<SkImageFilter | null>(\n Skia.ImageFilter.MakeCompose,\n null\n )\n );\n }\n return paint;\n }),\n [paint]\n );\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n }\n);\n"]}
1
+ {"version":3,"sources":["Paint.tsx"],"names":["React","useRef","useMemo","forwardRef","useImperativeHandle","Skia","processPaint","createDeclaration","usePaintRef","Paint","props","ref","paint","onDeclare","paintProps","children","ctx","opacity"],"mappings":";;AACA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,OAAxB,EAAiCC,UAAjC,EAA6CC,mBAA7C,QAAwE,OAAxE;AAGA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,YAAT,QAA6B,eAA7B;AACA,SAASC,iBAAT,QAAkC,UAAlC;AAEA,OAAO,MAAMC,WAAW,GAAG,MAAMP,MAAM,CAAU,IAAV,CAAhC;AAMP,OAAO,MAAMQ,KAAK,gBAAGN,UAAU,CAC7B,CAACO,KAAD,EAAQC,GAAR,KAAgB;AACd,QAAMC,KAAK,GAAGV,OAAO,CAAC,MAAMG,IAAI,CAACI,KAAL,EAAP,EAAqB,EAArB,CAArB;AACAL,EAAAA,mBAAmB,CAACO,GAAD,EAAM,MAAMC,KAAZ,EAAmB,CAACA,KAAD,CAAnB,CAAnB;AACA,QAAMC,SAAS,GAAGX,OAAO,CACvB,MACEK,iBAAiB,CAAa,CAACO,UAAD,EAAaC,QAAb,EAAuBC,GAAvB,KAC5BV,YAAY,CAACM,KAAD,EAAQI,GAAG,CAACC,OAAZ,EAAqBH,UAArB,EAAiCC,QAAjC,CADG,CAFI,EAKvB,CAACH,KAAD,CALuB,CAAzB;AAOA,sBAAO;AAAe,IAAA,SAAS,EAAEC;AAA1B,KAAyCH,KAAzC,EAAP;AACD,CAZ4B,CAAxB","sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useRef, useMemo, forwardRef, useImperativeHandle } from \"react\";\n\nimport type { SkPaint } from \"../../skia\";\nimport { Skia } from \"../../skia\";\nimport type { CustomPaintProps, AnimatedProps } from \"../processors\";\nimport { processPaint } from \"../processors\";\nimport { createDeclaration } from \"../nodes\";\n\nexport const usePaintRef = () => useRef<SkPaint>(null);\n\nexport interface PaintProps extends Omit<CustomPaintProps, \"paint\"> {\n children?: ReactNode | ReactNode[];\n}\n\nexport const Paint = forwardRef<SkPaint, AnimatedProps<PaintProps>>(\n (props, ref) => {\n const paint = useMemo(() => Skia.Paint(), []);\n useImperativeHandle(ref, () => paint, [paint]);\n const onDeclare = useMemo(\n () =>\n createDeclaration<PaintProps>((paintProps, children, ctx) =>\n processPaint(paint, ctx.opacity, paintProps, children)\n ),\n [paint]\n );\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n }\n);\n"]}
@@ -14,6 +14,5 @@ export * from "./Mask";
14
14
  export * from "./Paint";
15
15
  export * from "./Compose";
16
16
  export * from "./Blend";
17
- export * from "./Defs";
18
17
  export * from "./Drawing";
19
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,QAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,WAAd;AAEA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,WAAd","sourcesContent":["export * from \"./shapes\";\nexport * from \"./backdrop\";\nexport * from \"./image\";\nexport * from \"./shaders\";\nexport * from \"./text\";\nexport * from \"./colorFilters\";\nexport * from \"./maskFilters\";\nexport * from \"./imageFilters\";\nexport * from \"./pathEffects\";\nexport * from \"../processors\";\nexport * from \"./Picture\";\n\nexport * from \"./Group\";\nexport * from \"./Mask\";\nexport * from \"./Paint\";\nexport * from \"./Compose\";\nexport * from \"./Blend\";\nexport * from \"./Defs\";\nexport * from \"./Drawing\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,QAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,WAAd;AAEA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd","sourcesContent":["export * from \"./shapes\";\nexport * from \"./backdrop\";\nexport * from \"./image\";\nexport * from \"./shaders\";\nexport * from \"./text\";\nexport * from \"./colorFilters\";\nexport * from \"./maskFilters\";\nexport * from \"./imageFilters\";\nexport * from \"./pathEffects\";\nexport * from \"../processors\";\nexport * from \"./Picture\";\n\nexport * from \"./Group\";\nexport * from \"./Mask\";\nexport * from \"./Paint\";\nexport * from \"./Compose\";\nexport * from \"./Blend\";\nexport * from \"./Drawing\";\n"]}
@@ -6,6 +6,7 @@ import { Node } from "./Node";
6
6
  export const createDeclaration = cb => cb;
7
7
  export const useDeclaration = (cb, deps) => // eslint-disable-next-line react-hooks/exhaustive-deps
8
8
  useCallback(cb, deps !== null && deps !== void 0 ? deps : []);
9
+ export const isDeclarationNode = node => node instanceof DeclarationNode;
9
10
  export class DeclarationNode extends Node {
10
11
  constructor(depMgr, onDeclare, props) {
11
12
  super(depMgr, props);
@@ -1 +1 @@
1
- {"version":3,"sources":["Declaration.tsx"],"names":["useCallback","isAnimated","materialize","Node","createDeclaration","cb","useDeclaration","deps","DeclarationNode","constructor","depMgr","onDeclare","props","memoizable","_props","draw","ctx","children","visit","obj"],"mappings":";;AACA,SAASA,WAAT,QAA4B,OAA5B;AAKA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,eAAxC;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,iBAAiB,GAC5BC,EAD+B,IAEJA,EAFtB;AAIP,OAAO,MAAMC,cAAc,GAAG,CAC5BD,EAD4B,EAE5BE,IAF4B,KAI5B;AACAP,WAAW,CAACK,EAAD,EAAKE,IAAL,aAAKA,IAAL,cAAKA,IAAL,GAAa,EAAb,CALN;AAWP,OAAO,MAAMC,eAAN,SAAiCL,IAAjC,CAAyC;AAG9CM,EAAAA,WAAW,CACTC,MADS,EAETC,SAFS,EAGTC,KAHS,EAIT;AACA,UAAMF,MAAN,EAAcE,KAAd;;AADA;;AAEA,UAAMC,UAAN,GAAmB,CAACZ,UAAU,CAACW,KAAD,CAA9B;AACA,SAAKD,SAAL,GAAiBA,SAAjB;AACD;;AAEQ,MAALC,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKC,UAAL,GAAkB,CAACZ,UAAU,CAACW,KAAD,CAA7B;AACA,UAAMA,KAAN,GAAcA,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKE,MAAZ;AACD;;AAEDC,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,QAAQ,GAAG,KAAKC,KAAL,CAAWF,GAAX,CAAjB;AACA,UAAMJ,KAAK,GAAGV,WAAW,CAAC,KAAKU,KAAN,CAAzB;AACA,UAAMO,GAAG,GAAG,KAAKR,SAAL,CAAeC,KAAf,EAAsBK,QAAtB,EAAgCD,GAAhC,CAAZ;AACA,WAAOG,GAAP;AACD;;AA3B6C","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useCallback } from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { AnimatedProps } from \"../processors\";\nimport { isAnimated, materialize } from \"../processors\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\nexport type DeclarationResult = SkJSIInstance<string> | null;\n\ntype DeclarationCallback<T> = (\n props: T,\n children: DeclarationResult[],\n ctx: DrawingContext\n) => DeclarationResult;\n\nexport const createDeclaration = <T,>(\n cb: DeclarationCallback<T>\n): DeclarationCallback<T> => cb;\n\nexport const useDeclaration = <P,>(\n cb: DeclarationCallback<P>,\n deps?: DependencyList\n) =>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(cb, deps ?? []);\n\nexport interface DeclarationProps<P> {\n onDeclare: DeclarationCallback<P>;\n}\n\nexport class DeclarationNode<P> extends Node<P> {\n private onDeclare: DeclarationCallback<P>;\n\n constructor(\n depMgr: DependencyManager,\n onDeclare: DeclarationCallback<P>,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n super.memoizable = !isAnimated(props);\n this.onDeclare = onDeclare;\n }\n\n set props(props: AnimatedProps<P>) {\n this.memoizable = !isAnimated(props);\n super.props = props;\n }\n\n get props() {\n return this._props;\n }\n\n draw(ctx: DrawingContext) {\n const children = this.visit(ctx);\n const props = materialize(this.props);\n const obj = this.onDeclare(props, children, ctx);\n return obj;\n }\n}\n"]}
1
+ {"version":3,"sources":["Declaration.tsx"],"names":["useCallback","isAnimated","materialize","Node","createDeclaration","cb","useDeclaration","deps","isDeclarationNode","node","DeclarationNode","constructor","depMgr","onDeclare","props","memoizable","_props","draw","ctx","children","visit","obj"],"mappings":";;AACA,SAASA,WAAT,QAA4B,OAA5B;AAKA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,eAAxC;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,iBAAiB,GAC5BC,EAD+B,IAEJA,EAFtB;AAIP,OAAO,MAAMC,cAAc,GAAG,CAC5BD,EAD4B,EAE5BE,IAF4B,KAI5B;AACAP,WAAW,CAACK,EAAD,EAAKE,IAAL,aAAKA,IAAL,cAAKA,IAAL,GAAa,EAAb,CALN;AAOP,OAAO,MAAMC,iBAAiB,GAC5BC,IAD+B,IAEMA,IAAI,YAAYC,eAFhD;AAQP,OAAO,MAAMA,eAAN,SAAiCP,IAAjC,CAAyC;AAG9CQ,EAAAA,WAAW,CACTC,MADS,EAETC,SAFS,EAGTC,KAHS,EAIT;AACA,UAAMF,MAAN,EAAcE,KAAd;;AADA;;AAEA,UAAMC,UAAN,GAAmB,CAACd,UAAU,CAACa,KAAD,CAA9B;AACA,SAAKD,SAAL,GAAiBA,SAAjB;AACD;;AAEQ,MAALC,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKC,UAAL,GAAkB,CAACd,UAAU,CAACa,KAAD,CAA7B;AACA,UAAMA,KAAN,GAAcA,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKE,MAAZ;AACD;;AAEDC,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,QAAQ,GAAG,KAAKC,KAAL,CAAWF,GAAX,CAAjB;AACA,UAAMJ,KAAK,GAAGZ,WAAW,CAAC,KAAKY,KAAN,CAAzB;AACA,UAAMO,GAAG,GAAG,KAAKR,SAAL,CAAeC,KAAf,EAAsBK,QAAtB,EAAgCD,GAAhC,CAAZ;AACA,WAAOG,GAAP;AACD;;AA3B6C","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useCallback } from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { AnimatedProps } from \"../processors\";\nimport { isAnimated, materialize } from \"../processors\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\nexport type DeclarationResult = SkJSIInstance<string> | null;\n\ntype DeclarationCallback<T> = (\n props: T,\n children: DeclarationResult[],\n ctx: DrawingContext\n) => DeclarationResult;\n\nexport const createDeclaration = <T,>(\n cb: DeclarationCallback<T>\n): DeclarationCallback<T> => cb;\n\nexport const useDeclaration = <P,>(\n cb: DeclarationCallback<P>,\n deps?: DependencyList\n) =>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(cb, deps ?? []);\n\nexport const isDeclarationNode = (\n node: Node\n): node is DeclarationNode<unknown> => node instanceof DeclarationNode;\n\nexport interface DeclarationProps<P> {\n onDeclare: DeclarationCallback<P>;\n}\n\nexport class DeclarationNode<P> extends Node<P> {\n private onDeclare: DeclarationCallback<P>;\n\n constructor(\n depMgr: DependencyManager,\n onDeclare: DeclarationCallback<P>,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n super.memoizable = !isAnimated(props);\n this.onDeclare = onDeclare;\n }\n\n set props(props: AnimatedProps<P>) {\n this.memoizable = !isAnimated(props);\n super.props = props;\n }\n\n get props() {\n return this._props;\n }\n\n draw(ctx: DrawingContext) {\n const children = this.visit(ctx);\n const props = materialize(this.props);\n const obj = this.onDeclare(props, children, ctx);\n return obj;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
3
  import { useCallback } from "react";
4
- import { processPaint, selectPaint } from "../processors";
4
+ import { processPaint } from "../processors";
5
5
  import { materialize } from "../processors/Animations/Animations";
6
6
  import { isPaint } from "../../skia";
7
7
  import { Node } from "./Node";
@@ -26,23 +26,11 @@ export class DrawingNode extends Node {
26
26
  if (this.skipProcessing) {
27
27
  this.onDraw(ctx, drawingProps, this);
28
28
  } else {
29
- const selectedPaint = selectPaint(ctx.paint, drawingProps);
30
- processPaint(selectedPaint, ctx.opacity, drawingProps); // to draw only once:
31
- // onDraw({ ...ctx, paint: selectedPaint }, children);
32
-
33
- [selectedPaint, ...this.children.map(child => {
34
- //if (child.type === NodeType.Declaration) {
35
- const ret = child.draw(ctx);
36
-
37
- if (ret) {
38
- return ret;
39
- } //}
40
-
41
-
42
- return null;
43
- }).filter(isPaint)].forEach(paint => {
29
+ const declarations = this.visit(ctx);
30
+ const paint = processPaint(ctx.paint.copy(), ctx.opacity, drawingProps, declarations);
31
+ [paint, ...declarations.filter(isPaint)].forEach(currentPaint => {
44
32
  this.onDraw({ ...ctx,
45
- paint
33
+ paint: currentPaint
46
34
  }, drawingProps, this);
47
35
  });
48
36
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["Drawing.tsx"],"names":["useCallback","processPaint","selectPaint","materialize","isPaint","Node","createDrawing","cb","useDrawing","deps","DrawingNode","constructor","depMgr","onDraw","skipProcessing","props","draw","ctx","drawingProps","selectedPaint","paint","opacity","children","map","child","ret","filter","forEach"],"mappings":";;AACA,SAASA,WAAT,QAA4B,OAA5B;AAGA,SAASC,YAAT,EAAuBC,WAAvB,QAA0C,eAA1C;AAEA,SAASC,WAAT,QAA4B,qCAA5B;AACA,SAASC,OAAT,QAAwB,YAAxB;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,aAAa,GAAQC,EAAL,IAC3BA,EADK;AAGP,OAAO,MAAMC,UAAU,GAAG,CAAKD,EAAL,EAA4BE,IAA5B,KACxB;AACAT,WAAW,CAACO,EAAD,EAAKE,IAAL,aAAKA,IAAL,cAAKA,IAAL,GAAa,EAAb,CAFN;AAUP,OAAO,MAAMC,WAAN,SAA6BL,IAA7B,CAAqC;AAI1CM,EAAAA,WAAW,CACTC,MADS,EAETC,MAFS,EAGTC,cAHS,EAITC,KAJS,EAKT;AACA,UAAMH,MAAN,EAAcG,KAAd;;AADA;;AAAA;;AAEA,SAAKF,MAAL,GAAcA,MAAd;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACD;;AAEDE,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,YAAY,GAAGf,WAAW,CAAC,KAAKY,KAAN,CAAhC;;AACA,QAAI,KAAKD,cAAT,EAAyB;AACvB,WAAKD,MAAL,CAAYI,GAAZ,EAAiBC,YAAjB,EAA+B,IAA/B;AACD,KAFD,MAEO;AACL,YAAMC,aAAa,GAAGjB,WAAW,CAACe,GAAG,CAACG,KAAL,EAAYF,YAAZ,CAAjC;AACAjB,MAAAA,YAAY,CAACkB,aAAD,EAAgBF,GAAG,CAACI,OAApB,EAA6BH,YAA7B,CAAZ,CAFK,CAGL;AACA;;AACA,OACEC,aADF,EAEE,GAAG,KAAKG,QAAL,CACAC,GADA,CACKC,KAAD,IAAW;AACd;AACA,cAAMC,GAAG,GAAGD,KAAK,CAACR,IAAN,CAAWC,GAAX,CAAZ;;AACA,YAAIQ,GAAJ,EAAS;AACP,iBAAOA,GAAP;AACD,SALa,CAMd;;;AACA,eAAO,IAAP;AACD,OATA,EAUAC,MAVA,CAUOtB,OAVP,CAFL,EAaEuB,OAbF,CAaWP,KAAD,IAAW;AACnB,aAAKP,MAAL,CAAY,EAAE,GAAGI,GAAL;AAAUG,UAAAA;AAAV,SAAZ,EAA+BF,YAA/B,EAA6C,IAA7C;AACD,OAfD;AAgBD;AACF;;AAzCyC","sourcesContent":["import type { DependencyList, ReactNode } from \"react\";\nimport { useCallback } from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport { processPaint, selectPaint } from \"../processors\";\nimport type { AnimatedProps } from \"../processors/Animations/Animations\";\nimport { materialize } from \"../processors/Animations/Animations\";\nimport { isPaint } from \"../../skia\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\ntype DrawingCallback<P> = (\n ctx: DrawingContext,\n props: P,\n node: Node<P>\n) => void;\n\ntype OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;\n\nexport const createDrawing = <P,>(cb: OnDrawCallback<P>): DrawingCallback<P> =>\n cb;\n\nexport const useDrawing = <P,>(cb: OnDrawCallback<P>, deps?: DependencyList) =>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(cb, deps ?? []);\n\nexport type DrawingProps<T> = {\n onDraw: DrawingCallback<T>;\n skipProcessing?: boolean;\n children?: ReactNode | ReactNode[];\n};\n\nexport class DrawingNode<P> extends Node<P> {\n onDraw: DrawingCallback<P>;\n skipProcessing: boolean;\n\n constructor(\n depMgr: DependencyManager,\n onDraw: DrawingCallback<P>,\n skipProcessing: boolean,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n this.onDraw = onDraw;\n this.skipProcessing = skipProcessing;\n }\n\n draw(ctx: DrawingContext) {\n const drawingProps = materialize(this.props);\n if (this.skipProcessing) {\n this.onDraw(ctx, drawingProps, this);\n } else {\n const selectedPaint = selectPaint(ctx.paint, drawingProps);\n processPaint(selectedPaint, ctx.opacity, drawingProps);\n // to draw only once:\n // onDraw({ ...ctx, paint: selectedPaint }, children);\n [\n selectedPaint,\n ...this.children\n .map((child) => {\n //if (child.type === NodeType.Declaration) {\n const ret = child.draw(ctx);\n if (ret) {\n return ret;\n }\n //}\n return null;\n })\n .filter(isPaint),\n ].forEach((paint) => {\n this.onDraw({ ...ctx, paint }, drawingProps, this);\n });\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["Drawing.tsx"],"names":["useCallback","processPaint","materialize","isPaint","Node","createDrawing","cb","useDrawing","deps","DrawingNode","constructor","depMgr","onDraw","skipProcessing","props","draw","ctx","drawingProps","declarations","visit","paint","copy","opacity","filter","forEach","currentPaint"],"mappings":";;AACA,SAASA,WAAT,QAA4B,OAA5B;AAGA,SAASC,YAAT,QAA6B,eAA7B;AAEA,SAASC,WAAT,QAA4B,qCAA5B;AACA,SAASC,OAAT,QAAwB,YAAxB;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,aAAa,GAAQC,EAAL,IAC3BA,EADK;AAGP,OAAO,MAAMC,UAAU,GAAG,CAAKD,EAAL,EAA4BE,IAA5B,KACxB;AACAR,WAAW,CAACM,EAAD,EAAKE,IAAL,aAAKA,IAAL,cAAKA,IAAL,GAAa,EAAb,CAFN;AAUP,OAAO,MAAMC,WAAN,SAA6BL,IAA7B,CAAqC;AAI1CM,EAAAA,WAAW,CACTC,MADS,EAETC,MAFS,EAGTC,cAHS,EAITC,KAJS,EAKT;AACA,UAAMH,MAAN,EAAcG,KAAd;;AADA;;AAAA;;AAEA,SAAKF,MAAL,GAAcA,MAAd;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACD;;AAEDE,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,YAAY,GAAGf,WAAW,CAAC,KAAKY,KAAN,CAAhC;;AACA,QAAI,KAAKD,cAAT,EAAyB;AACvB,WAAKD,MAAL,CAAYI,GAAZ,EAAiBC,YAAjB,EAA+B,IAA/B;AACD,KAFD,MAEO;AACL,YAAMC,YAAY,GAAG,KAAKC,KAAL,CAAWH,GAAX,CAArB;AACA,YAAMI,KAAK,GAAGnB,YAAY,CACxBe,GAAG,CAACI,KAAJ,CAAUC,IAAV,EADwB,EAExBL,GAAG,CAACM,OAFoB,EAGxBL,YAHwB,EAIxBC,YAJwB,CAA1B;AAMA,OAACE,KAAD,EAAQ,GAAGF,YAAY,CAACK,MAAb,CAAoBpB,OAApB,CAAX,EAAyCqB,OAAzC,CAAkDC,YAAD,IAAkB;AACjE,aAAKb,MAAL,CAAY,EAAE,GAAGI,GAAL;AAAUI,UAAAA,KAAK,EAAEK;AAAjB,SAAZ,EAA6CR,YAA7C,EAA2D,IAA3D;AACD,OAFD;AAGD;AACF;;AA/ByC","sourcesContent":["import type { DependencyList, ReactNode } from \"react\";\nimport { useCallback } from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport { processPaint } from \"../processors\";\nimport type { AnimatedProps } from \"../processors/Animations/Animations\";\nimport { materialize } from \"../processors/Animations/Animations\";\nimport { isPaint } from \"../../skia\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\ntype DrawingCallback<P> = (\n ctx: DrawingContext,\n props: P,\n node: Node<P>\n) => void;\n\ntype OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;\n\nexport const createDrawing = <P,>(cb: OnDrawCallback<P>): DrawingCallback<P> =>\n cb;\n\nexport const useDrawing = <P,>(cb: OnDrawCallback<P>, deps?: DependencyList) =>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(cb, deps ?? []);\n\nexport type DrawingProps<T> = {\n onDraw: DrawingCallback<T>;\n skipProcessing?: boolean;\n children?: ReactNode | ReactNode[];\n};\n\nexport class DrawingNode<P> extends Node<P> {\n onDraw: DrawingCallback<P>;\n skipProcessing: boolean;\n\n constructor(\n depMgr: DependencyManager,\n onDraw: DrawingCallback<P>,\n skipProcessing: boolean,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n this.onDraw = onDraw;\n this.skipProcessing = skipProcessing;\n }\n\n draw(ctx: DrawingContext) {\n const drawingProps = materialize(this.props);\n if (this.skipProcessing) {\n this.onDraw(ctx, drawingProps, this);\n } else {\n const declarations = this.visit(ctx);\n const paint = processPaint(\n ctx.paint.copy(),\n ctx.opacity,\n drawingProps,\n declarations\n );\n [paint, ...declarations.filter(isPaint)].forEach((currentPaint) => {\n this.onDraw({ ...ctx, paint: currentPaint }, drawingProps, this);\n });\n }\n }\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
- import { isPaint } from "../../skia";
4
3
  export let NodeType;
5
4
 
6
5
  (function (NodeType) {
@@ -16,7 +15,7 @@ export class Node {
16
15
 
17
16
  _defineProperty(this, "memoizable", false);
18
17
 
19
- _defineProperty(this, "memoized", false);
18
+ _defineProperty(this, "memoized", null);
20
19
 
21
20
  _defineProperty(this, "parent", void 0);
22
21
 
@@ -38,26 +37,21 @@ export class Node {
38
37
  return this._props;
39
38
  }
40
39
 
41
- visit(ctx) {
40
+ visit(ctx, children) {
42
41
  const returnedValues = [];
43
- let currentCtx = ctx;
44
- this.children.forEach(child => {
42
+ (children !== null && children !== void 0 ? children : this.children).forEach(child => {
45
43
  if (!child.memoized) {
46
- const ret = child.draw(currentCtx);
44
+ const ret = child.draw(ctx);
47
45
 
48
46
  if (ret) {
49
- if (isPaint(ret)) {
50
- currentCtx = { ...currentCtx,
51
- paint: ret
52
- };
53
- }
54
-
55
47
  returnedValues.push(ret);
56
- }
57
48
 
58
- if (child.memoizable) {
59
- child.memoized = true;
49
+ if (child.memoizable) {
50
+ child.memoized = ret;
51
+ }
60
52
  }
53
+ } else {
54
+ returnedValues.push(child.memoized);
61
55
  }
62
56
  });
63
57
  return returnedValues;
@@ -1 +1 @@
1
- {"version":3,"sources":["Node.ts"],"names":["isPaint","NodeType","Node","constructor","depMgr","props","_props","unSubscribeNode","subscribeNode","visit","ctx","returnedValues","currentCtx","children","forEach","child","memoized","ret","draw","paint","push","memoizable"],"mappings":";;AAAA,SAASA,OAAT,QAAwB,YAAxB;AAMA,WAAYC,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,KAAAA,Q;;AAOZ,OAAO,MAAeC,IAAf,CAAiC;AAQtCC,EAAAA,WAAW,CAACC,MAAD,EAA4BC,KAA5B,EAAqD;AAAA,sCAPpC,EAOoC;;AAAA;;AAAA,wCALnD,KAKmD;;AAAA,sCAJrD,KAIqD;;AAAA;;AAAA;;AAC9D,SAAKC,MAAL,GAAcD,KAAd;AACA,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKA,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACD;;AAIQ,MAALA,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKD,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACA,SAAKC,MAAL,GAAcD,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKC,MAAZ;AACD;;AAEDG,EAAAA,KAAK,CAACC,GAAD,EAAsB;AACzB,UAAMC,cAAkD,GAAG,EAA3D;AACA,QAAIC,UAAU,GAAGF,GAAjB;AACA,SAAKG,QAAL,CAAcC,OAAd,CAAuBC,KAAD,IAAW;AAC/B,UAAI,CAACA,KAAK,CAACC,QAAX,EAAqB;AACnB,cAAMC,GAAG,GAAGF,KAAK,CAACG,IAAN,CAAWN,UAAX,CAAZ;;AACA,YAAIK,GAAJ,EAAS;AACP,cAAIjB,OAAO,CAACiB,GAAD,CAAX,EAAkB;AAChBL,YAAAA,UAAU,GAAG,EAAE,GAAGA,UAAL;AAAiBO,cAAAA,KAAK,EAAEF;AAAxB,aAAb;AACD;;AACDN,UAAAA,cAAc,CAACS,IAAf,CAAoBH,GAApB;AACD;;AACD,YAAIF,KAAK,CAACM,UAAV,EAAsB;AACpBN,UAAAA,KAAK,CAACC,QAAN,GAAiB,IAAjB;AACD;AACF;AACF,KAbD;AAcA,WAAOL,cAAP;AACD;;AA7CqC","sourcesContent":["import { isPaint } from \"../../skia\";\nimport type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { DependencyManager } from \"../DependencyManager\";\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { AnimatedProps } from \"../processors\";\n\nexport enum NodeType {\n Declaration = \"skDeclaration\",\n Drawing = \"skDrawing\",\n}\n\ntype DeclarationResult = SkJSIInstance<string> | null;\n\nexport abstract class Node<P = unknown> {\n readonly children: Node[] = [];\n _props: AnimatedProps<P>;\n memoizable = false;\n memoized = false;\n parent?: Node;\n depMgr: DependencyManager;\n\n constructor(depMgr: DependencyManager, props: AnimatedProps<P>) {\n this._props = props;\n this.depMgr = depMgr;\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n }\n\n abstract draw(ctx: DrawingContext): void | DeclarationResult;\n\n set props(props: AnimatedProps<P>) {\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n this._props = props;\n }\n\n get props() {\n return this._props;\n }\n\n visit(ctx: DrawingContext) {\n const returnedValues: Exclude<DeclarationResult, null>[] = [];\n let currentCtx = ctx;\n this.children.forEach((child) => {\n if (!child.memoized) {\n const ret = child.draw(currentCtx);\n if (ret) {\n if (isPaint(ret)) {\n currentCtx = { ...currentCtx, paint: ret };\n }\n returnedValues.push(ret);\n }\n if (child.memoizable) {\n child.memoized = true;\n }\n }\n });\n return returnedValues;\n }\n}\n"]}
1
+ {"version":3,"sources":["Node.ts"],"names":["NodeType","Node","constructor","depMgr","props","_props","unSubscribeNode","subscribeNode","visit","ctx","children","returnedValues","forEach","child","memoized","ret","draw","push","memoizable"],"mappings":";;AAKA,WAAYA,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,KAAAA,Q;;AAOZ,OAAO,MAAeC,IAAf,CAAiC;AAQtCC,EAAAA,WAAW,CAACC,MAAD,EAA4BC,KAA5B,EAAqD;AAAA,sCAPpC,EAOoC;;AAAA;;AAAA,wCALnD,KAKmD;;AAAA,sCAJ3B,IAI2B;;AAAA;;AAAA;;AAC9D,SAAKC,MAAL,GAAcD,KAAd;AACA,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKA,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACD;;AAIQ,MAALA,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKD,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACA,SAAKC,MAAL,GAAcD,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKC,MAAZ;AACD;;AAEDG,EAAAA,KAAK,CAACC,GAAD,EAAsBC,QAAtB,EAAyC;AAC5C,UAAMC,cAAkD,GAAG,EAA3D;AACA,KAACD,QAAD,aAACA,QAAD,cAACA,QAAD,GAAa,KAAKA,QAAlB,EAA4BE,OAA5B,CAAqCC,KAAD,IAAW;AAC7C,UAAI,CAACA,KAAK,CAACC,QAAX,EAAqB;AACnB,cAAMC,GAAG,GAAGF,KAAK,CAACG,IAAN,CAAWP,GAAX,CAAZ;;AACA,YAAIM,GAAJ,EAAS;AACPJ,UAAAA,cAAc,CAACM,IAAf,CAAoBF,GAApB;;AACA,cAAIF,KAAK,CAACK,UAAV,EAAsB;AACpBL,YAAAA,KAAK,CAACC,QAAN,GAAiBC,GAAjB;AACD;AACF;AACF,OARD,MAQO;AACLJ,QAAAA,cAAc,CAACM,IAAf,CAAoBJ,KAAK,CAACC,QAA1B;AACD;AACF,KAZD;AAaA,WAAOH,cAAP;AACD;;AA3CqC","sourcesContent":["import type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { DependencyManager } from \"../DependencyManager\";\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { AnimatedProps } from \"../processors\";\n\nexport enum NodeType {\n Declaration = \"skDeclaration\",\n Drawing = \"skDrawing\",\n}\n\ntype DeclarationResult = SkJSIInstance<string> | null;\n\nexport abstract class Node<P = unknown> {\n readonly children: Node[] = [];\n _props: AnimatedProps<P>;\n memoizable = false;\n memoized: DeclarationResult | null = null;\n parent?: Node;\n depMgr: DependencyManager;\n\n constructor(depMgr: DependencyManager, props: AnimatedProps<P>) {\n this._props = props;\n this.depMgr = depMgr;\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n }\n\n abstract draw(ctx: DrawingContext): void | DeclarationResult;\n\n set props(props: AnimatedProps<P>) {\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n this._props = props;\n }\n\n get props() {\n return this._props;\n }\n\n visit(ctx: DrawingContext, children?: Node[]) {\n const returnedValues: Exclude<DeclarationResult, null>[] = [];\n (children ?? this.children).forEach((child) => {\n if (!child.memoized) {\n const ret = child.draw(ctx);\n if (ret) {\n returnedValues.push(ret);\n if (child.memoizable) {\n child.memoized = ret;\n }\n }\n } else {\n returnedValues.push(child.memoized);\n }\n });\n return returnedValues;\n }\n}\n"]}
@@ -1,7 +1,8 @@
1
- import { BlendMode, PaintStyle, StrokeJoin, StrokeCap, processColor } from "../../skia";
1
+ import { BlendMode, PaintStyle, StrokeJoin, StrokeCap, processColor, isShader, isMaskFilter, isColorFilter, isPathEffect, isImageFilter, Skia } from "../../skia";
2
2
  export const enumKey = k => k.charAt(0).toUpperCase() + k.slice(1);
3
- export const processPaint = (paint, currentOpacity, _ref) => {
3
+ export const processPaint = (paint, currentOpacity, _ref, children) => {
4
4
  let {
5
+ paint: paintRef,
5
6
  color,
6
7
  blendMode,
7
8
  style,
@@ -12,6 +13,10 @@ export const processPaint = (paint, currentOpacity, _ref) => {
12
13
  opacity
13
14
  } = _ref;
14
15
 
16
+ if (paintRef && paintRef.current) {
17
+ return paintRef.current;
18
+ }
19
+
15
20
  if (color !== undefined) {
16
21
  const c = processColor(color, currentOpacity);
17
22
  paint.setShader(null);
@@ -48,28 +53,24 @@ export const processPaint = (paint, currentOpacity, _ref) => {
48
53
  if (opacity !== undefined) {
49
54
  paint.setAlphaf(opacity);
50
55
  }
51
- };
52
- export const selectPaint = (currentPaint, _ref2) => {
53
- var _paint$current;
54
56
 
55
- let {
56
- paint,
57
- color: cl,
58
- blendMode,
59
- style: paintStyle,
60
- strokeWidth,
61
- strokeJoin,
62
- strokeCap,
63
- strokeMiter,
64
- opacity
65
- } = _ref2;
66
- const hasCustomPaint = cl !== undefined || blendMode !== undefined || paintStyle !== undefined || strokeWidth !== undefined || strokeJoin !== undefined || opacity !== undefined || strokeCap !== undefined || strokeMiter !== undefined;
67
- const parentPaint = (_paint$current = paint === null || paint === void 0 ? void 0 : paint.current) !== null && _paint$current !== void 0 ? _paint$current : currentPaint;
57
+ children.forEach(child => {
58
+ if (isShader(child)) {
59
+ paint.setShader(child);
60
+ } else if (isMaskFilter(child)) {
61
+ paint.setMaskFilter(child);
62
+ } else if (isColorFilter(child)) {
63
+ paint.setColorFilter(child);
64
+ } else if (isPathEffect(child)) {
65
+ paint.setPathEffect(child);
66
+ }
67
+ });
68
+ const filters = children.filter(isImageFilter);
68
69
 
69
- if (hasCustomPaint) {
70
- return parentPaint.copy();
70
+ if (filters.length > 0) {
71
+ paint.setImageFilter(filters.reverse().reduce(Skia.ImageFilter.MakeCompose, null));
71
72
  }
72
73
 
73
- return parentPaint;
74
+ return paint;
74
75
  };
75
76
  //# sourceMappingURL=Paint.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Paint.ts"],"names":["BlendMode","PaintStyle","StrokeJoin","StrokeCap","processColor","enumKey","k","charAt","toUpperCase","slice","processPaint","paint","currentOpacity","color","blendMode","style","strokeWidth","strokeJoin","strokeCap","strokeMiter","opacity","undefined","c","setShader","setColor","getColor","setBlendMode","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setStrokeWidth","setAlphaf","selectPaint","currentPaint","cl","paintStyle","hasCustomPaint","parentPaint","current","copy"],"mappings":"AAEA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,YALF,QAMO,YANP;AA0BA,OAAO,MAAMC,OAAO,GAAsBC,CAAnB,IACpBA,CAAC,CAACC,MAAF,CAAS,CAAT,EAAYC,WAAZ,KAA4BF,CAAC,CAACG,KAAF,CAAQ,CAAR,CADxB;AAGP,OAAO,MAAMC,YAAY,GAAG,CAC1BC,KAD0B,EAE1BC,cAF0B,WAavB;AAAA,MAVH;AACEC,IAAAA,KADF;AAEEC,IAAAA,SAFF;AAGEC,IAAAA,KAHF;AAIEC,IAAAA,WAJF;AAKEC,IAAAA,UALF;AAMEC,IAAAA,SANF;AAOEC,IAAAA,WAPF;AAQEC,IAAAA;AARF,GAUG;;AACH,MAAIP,KAAK,KAAKQ,SAAd,EAAyB;AACvB,UAAMC,CAAC,GAAGlB,YAAY,CAACS,KAAD,EAAQD,cAAR,CAAtB;AACAD,IAAAA,KAAK,CAACY,SAAN,CAAgB,IAAhB;AACAZ,IAAAA,KAAK,CAACa,QAAN,CAAeF,CAAf;AACD,GAJD,MAIO;AACL,UAAMA,CAAC,GAAGlB,YAAY,CAACO,KAAK,CAACc,QAAN,EAAD,EAAmBb,cAAnB,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d,IAEAe,UAAU,KAAKf,SAFf,IAGAL,WAAW,KAAKK,SAHhB,IAIAJ,UAAU,KAAKI,SAJf,IAKAD,OAAO,KAAKC,SALZ,IAMAH,SAAS,KAAKG,SANd,IAOAF,WAAW,KAAKE,SARlB;AASA,QAAMiB,WAAW,qBAAG3B,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAE4B,OAAV,2DAAqBL,YAAtC;;AACA,MAAIG,cAAJ,EAAoB;AAClB,WAAOC,WAAW,CAACE,IAAZ,EAAP;AACD;;AACD,SAAOF,WAAP;AACD,CA5BM","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\n\nimport {\n BlendMode,\n PaintStyle,\n StrokeJoin,\n StrokeCap,\n processColor,\n} from \"../../skia\";\nimport type { SkPaint, Color } from \"../../skia\";\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\nexport interface CustomPaintProps extends ChildrenProps {\n paint?: RefObject<SkPaint>;\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n}\n\nexport const enumKey = <K extends string>(k: K) =>\n (k.charAt(0).toUpperCase() + k.slice(1)) as Capitalize<K>;\n\nexport const processPaint = (\n paint: SkPaint,\n currentOpacity: number,\n {\n color,\n blendMode,\n style,\n strokeWidth,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n }: CustomPaintProps\n) => {\n if (color !== undefined) {\n const c = processColor(color, currentOpacity);\n paint.setShader(null);\n paint.setColor(c);\n } else {\n const c = processColor(paint.getColor(), currentOpacity);\n paint.setColor(c);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (opacity !== undefined) {\n paint.setAlphaf(opacity);\n }\n};\n\nexport const selectPaint = (\n currentPaint: SkPaint,\n {\n paint,\n color: cl,\n blendMode,\n style: paintStyle,\n strokeWidth,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n }: CustomPaintProps\n) => {\n const hasCustomPaint =\n cl !== undefined ||\n blendMode !== undefined ||\n paintStyle !== undefined ||\n strokeWidth !== undefined ||\n strokeJoin !== undefined ||\n opacity !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined;\n const parentPaint = paint?.current ?? currentPaint;\n if (hasCustomPaint) {\n return parentPaint.copy();\n }\n return parentPaint;\n};\n"]}
1
+ {"version":3,"sources":["Paint.ts"],"names":["BlendMode","PaintStyle","StrokeJoin","StrokeCap","processColor","isShader","isMaskFilter","isColorFilter","isPathEffect","isImageFilter","Skia","enumKey","k","charAt","toUpperCase","slice","processPaint","paint","currentOpacity","children","paintRef","color","blendMode","style","strokeWidth","strokeJoin","strokeCap","strokeMiter","opacity","current","undefined","c","setShader","setColor","getColor","setBlendMode","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setStrokeWidth","setAlphaf","forEach","child","setMaskFilter","setColorFilter","setPathEffect","filters","filter","length","setImageFilter","reverse","reduce","ImageFilter","MakeCompose"],"mappings":"AAEA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,YALF,EAMEC,QANF,EAOEC,YAPF,EAQEC,aARF,EASEC,YATF,EAUEC,aAVF,EAWEC,IAXF,QAYO,YAZP;AAkCA,OAAO,MAAMC,OAAO,GAAsBC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M","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\n\nimport {\n BlendMode,\n PaintStyle,\n StrokeJoin,\n StrokeCap,\n processColor,\n isShader,\n isMaskFilter,\n isColorFilter,\n isPathEffect,\n isImageFilter,\n Skia,\n} from \"../../skia\";\nimport type { SkPaint, Color, SkImageFilter } from \"../../skia\";\nimport type { DeclarationResult } from \"../nodes\";\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\n// TODO: rename to paint props?\nexport interface CustomPaintProps extends ChildrenProps {\n paint?: RefObject<SkPaint>;\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n}\n\nexport const enumKey = <K extends string>(k: K) =>\n (k.charAt(0).toUpperCase() + k.slice(1)) as Capitalize<K>;\n\nexport const processPaint = (\n paint: SkPaint,\n currentOpacity: number,\n {\n paint: paintRef,\n color,\n blendMode,\n style,\n strokeWidth,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n }: CustomPaintProps,\n children: DeclarationResult[]\n) => {\n if (paintRef && paintRef.current) {\n return paintRef.current;\n }\n if (color !== undefined) {\n const c = processColor(color, currentOpacity);\n paint.setShader(null);\n paint.setColor(c);\n } else {\n const c = processColor(paint.getColor(), currentOpacity);\n paint.setColor(c);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (opacity !== undefined) {\n paint.setAlphaf(opacity);\n }\n children.forEach((child) => {\n if (isShader(child)) {\n paint.setShader(child);\n } else if (isMaskFilter(child)) {\n paint.setMaskFilter(child);\n } else if (isColorFilter(child)) {\n paint.setColorFilter(child);\n } else if (isPathEffect(child)) {\n paint.setPathEffect(child);\n }\n });\n const filters = children.filter(isImageFilter);\n if (filters.length > 0) {\n paint.setImageFilter(\n filters\n .reverse()\n .reduce<SkImageFilter | null>(Skia.ImageFilter.MakeCompose, null)\n );\n }\n return paint;\n};\n"]}
@@ -18,4 +18,4 @@ export interface CanvasProps extends ComponentProps<typeof SkiaView> {
18
18
  onTouch?: TouchHandler;
19
19
  fontMgr?: FontMgr;
20
20
  }
21
- export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "style" | "children" | "mode" | "debug" | "onDraw" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "onTouch" | "fontMgr"> & React.RefAttributes<SkiaView>>;
21
+ export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "children" | "style" | "mode" | "debug" | "onDraw" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "onTouch" | "fontMgr"> & React.RefAttributes<SkiaView>>;
@@ -14,5 +14,4 @@ export * from "./Mask";
14
14
  export * from "./Paint";
15
15
  export * from "./Compose";
16
16
  export * from "./Blend";
17
- export * from "./Defs";
18
17
  export * from "./Drawing";
@@ -8,6 +8,7 @@ export declare type DeclarationResult = SkJSIInstance<string> | null;
8
8
  declare type DeclarationCallback<T> = (props: T, children: DeclarationResult[], ctx: DrawingContext) => DeclarationResult;
9
9
  export declare const createDeclaration: <T>(cb: DeclarationCallback<T>) => DeclarationCallback<T>;
10
10
  export declare const useDeclaration: <P>(cb: DeclarationCallback<P>, deps?: DependencyList | undefined) => DeclarationCallback<P>;
11
+ export declare const isDeclarationNode: (node: Node) => node is DeclarationNode<unknown>;
11
12
  export interface DeclarationProps<P> {
12
13
  onDeclare: DeclarationCallback<P>;
13
14
  }
@@ -11,13 +11,13 @@ export declare abstract class Node<P = unknown> {
11
11
  readonly children: Node[];
12
12
  _props: AnimatedProps<P>;
13
13
  memoizable: boolean;
14
- memoized: boolean;
14
+ memoized: DeclarationResult | null;
15
15
  parent?: Node;
16
16
  depMgr: DependencyManager;
17
17
  constructor(depMgr: DependencyManager, props: AnimatedProps<P>);
18
18
  abstract draw(ctx: DrawingContext): void | DeclarationResult;
19
19
  set props(props: AnimatedProps<P>);
20
20
  get props(): AnimatedProps<P>;
21
- visit(ctx: DrawingContext): SkJSIInstance<string>[];
21
+ visit(ctx: DrawingContext, children?: Node[]): SkJSIInstance<string>[];
22
22
  }
23
23
  export {};
@@ -1,6 +1,7 @@
1
1
  import type { ReactNode, RefObject } from "react";
2
2
  import { BlendMode, PaintStyle, StrokeJoin, StrokeCap } from "../../skia";
3
3
  import type { SkPaint, Color } from "../../skia";
4
+ import type { DeclarationResult } from "../nodes";
4
5
  export declare type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;
5
6
  export interface ChildrenProps {
6
7
  children?: ReactNode | ReactNode[];
@@ -17,5 +18,4 @@ export interface CustomPaintProps extends ChildrenProps {
17
18
  opacity?: number;
18
19
  }
19
20
  export declare const enumKey: <K extends string>(k: K) => Capitalize<K>;
20
- export declare const processPaint: (paint: SkPaint, currentOpacity: number, { color, blendMode, style, strokeWidth, strokeJoin, strokeCap, strokeMiter, opacity, }: CustomPaintProps) => void;
21
- export declare const selectPaint: (currentPaint: SkPaint, { paint, color: cl, blendMode, style: paintStyle, strokeWidth, strokeJoin, strokeCap, strokeMiter, opacity, }: CustomPaintProps) => SkPaint;
21
+ export declare const processPaint: (paint: SkPaint, currentOpacity: number, { paint: paintRef, color, blendMode, style, strokeWidth, strokeJoin, strokeCap, strokeMiter, opacity, }: CustomPaintProps, children: DeclarationResult[]) => SkPaint;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "React Native Skia",
7
- "version": "0.1.118",
7
+ "version": "0.1.119",
8
8
  "description": "High-performance React Native Graphics using Skia",
9
9
  "main": "lib/module/index.js",
10
10
  "files": [
@@ -69,7 +69,7 @@ const bustBranchMemoization = (parent: Node) => {
69
69
  if (parent.memoizable) {
70
70
  let ancestor: Node | undefined = parent;
71
71
  while (ancestor) {
72
- ancestor.memoized = false;
72
+ ancestor.memoized = null;
73
73
  ancestor = ancestor.parent;
74
74
  }
75
75
  }
@@ -3,19 +3,15 @@ import type { RefObject } from "react";
3
3
 
4
4
  import type { SkPaint } from "../../skia";
5
5
  import { ClipOp } from "../../skia";
6
- import {
7
- processTransform,
8
- selectPaint,
9
- processPaint,
10
- processClip,
11
- } from "../processors";
6
+ import { processTransform, processPaint, processClip } from "../processors";
12
7
  import type {
13
8
  CustomPaintProps,
14
9
  TransformProps,
15
10
  AnimatedProps,
16
11
  ClipDef,
17
12
  } from "../processors";
18
- import { createDrawing } from "../nodes";
13
+ import { createDrawing, DrawingNode } from "../nodes";
14
+ import { isDeclarationNode } from "../nodes/Declaration";
19
15
 
20
16
  const isSkPaint = (obj: RefObject<SkPaint> | SkPaint): obj is SkPaint =>
21
17
  "__typename__" in obj && obj.__typename__ === "Paint";
@@ -29,8 +25,19 @@ export interface GroupProps extends CustomPaintProps, TransformProps {
29
25
  const onDraw = createDrawing<GroupProps>(
30
26
  (ctx, { layer, clip, invertClip, ...groupProps }, node) => {
31
27
  const { canvas, opacity } = ctx;
32
- const paint = selectPaint(ctx.paint, groupProps);
33
- processPaint(paint, opacity, groupProps);
28
+ const declarations = node.children
29
+ .filter(isDeclarationNode)
30
+ .map((child) => child.draw(ctx));
31
+
32
+ const drawings = node.children.filter(
33
+ (child) => child instanceof DrawingNode
34
+ );
35
+ const paint = processPaint(
36
+ ctx.paint.copy(),
37
+ opacity,
38
+ groupProps,
39
+ declarations
40
+ );
34
41
  const hasTransform = !!groupProps.transform || !!groupProps.matrix;
35
42
  const hasClip = !!clip;
36
43
  const shouldSave = hasTransform || hasClip || !!layer;
@@ -52,11 +59,14 @@ const onDraw = createDrawing<GroupProps>(
52
59
  processClip(canvas, clip, op);
53
60
  }
54
61
  }
55
- node.visit({
56
- ...ctx,
57
- paint,
58
- opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity,
59
- });
62
+ node.visit(
63
+ {
64
+ ...ctx,
65
+ paint,
66
+ opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity,
67
+ },
68
+ drawings
69
+ );
60
70
  if (shouldSave) {
61
71
  canvas.restore();
62
72
  }
@@ -1,15 +1,8 @@
1
1
  import type { ReactNode } from "react";
2
2
  import React, { useRef, useMemo, forwardRef, useImperativeHandle } from "react";
3
3
 
4
- import type { SkPaint, SkImageFilter } from "../../skia";
5
- import {
6
- isShader,
7
- isMaskFilter,
8
- isColorFilter,
9
- Skia,
10
- isImageFilter,
11
- isPathEffect,
12
- } from "../../skia";
4
+ import type { SkPaint } from "../../skia";
5
+ import { Skia } from "../../skia";
13
6
  import type { CustomPaintProps, AnimatedProps } from "../processors";
14
7
  import { processPaint } from "../processors";
15
8
  import { createDeclaration } from "../nodes";
@@ -26,32 +19,9 @@ export const Paint = forwardRef<SkPaint, AnimatedProps<PaintProps>>(
26
19
  useImperativeHandle(ref, () => paint, [paint]);
27
20
  const onDeclare = useMemo(
28
21
  () =>
29
- createDeclaration<PaintProps>((paintProps, children, ctx) => {
30
- processPaint(paint, ctx.opacity, paintProps);
31
- children.forEach((child) => {
32
- if (isShader(child)) {
33
- paint.setShader(child);
34
- } else if (isMaskFilter(child)) {
35
- paint.setMaskFilter(child);
36
- } else if (isColorFilter(child)) {
37
- paint.setColorFilter(child);
38
- } else if (isPathEffect(child)) {
39
- paint.setPathEffect(child);
40
- }
41
- });
42
- const filters = children.filter(isImageFilter);
43
- if (filters.length > 0) {
44
- paint.setImageFilter(
45
- filters
46
- .reverse()
47
- .reduce<SkImageFilter | null>(
48
- Skia.ImageFilter.MakeCompose,
49
- null
50
- )
51
- );
52
- }
53
- return paint;
54
- }),
22
+ createDeclaration<PaintProps>((paintProps, children, ctx) =>
23
+ processPaint(paint, ctx.opacity, paintProps, children)
24
+ ),
55
25
  [paint]
56
26
  );
57
27
  return <skDeclaration onDeclare={onDeclare} {...props} />;
@@ -15,5 +15,4 @@ export * from "./Mask";
15
15
  export * from "./Paint";
16
16
  export * from "./Compose";
17
17
  export * from "./Blend";
18
- export * from "./Defs";
19
18
  export * from "./Drawing";