@shopify/react-native-skia 0.1.153 → 0.1.154
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkCanvas.h +1 -1
- package/lib/commonjs/dom/nodes/GroupNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.js +3 -7
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js +8 -30
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
- package/lib/module/dom/nodes/GroupNode.js.map +1 -1
- package/lib/module/dom/nodes/RenderNode.js +3 -7
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/external/reanimated/useSharedValueEffect.js +8 -35
- package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
- package/lib/typescript/src/dom/nodes/GroupNode.d.ts +1 -2
- package/package.json +1 -1
- package/src/dom/nodes/GroupNode.ts +1 -5
- package/src/dom/nodes/RenderNode.ts +6 -5
- package/src/external/reanimated/useSharedValueEffect.ts +8 -28
package/cpp/api/JsiSkCanvas.h
CHANGED
@@ -414,7 +414,7 @@ public:
|
|
414
414
|
JSI_HOST_FUNCTION(saveLayer) {
|
415
415
|
SkPaint *paint = (count >= 1 && !arguments[0].isUndefined()) ?
|
416
416
|
JsiSkPaint::fromValue(runtime, arguments[0]).get() : nullptr;
|
417
|
-
SkRect *bounds = count >= 2 && !arguments[1].isNull() && arguments[1].isUndefined() ? JsiSkRect::fromValue(runtime, arguments[1]).get() : nullptr;
|
417
|
+
SkRect *bounds = count >= 2 && !arguments[1].isNull() && !arguments[1].isUndefined() ? JsiSkRect::fromValue(runtime, arguments[1]).get() : nullptr;
|
418
418
|
SkImageFilter *backdrop = count >= 3 && !arguments[2].isNull() && !arguments[2].isUndefined() ? JsiSkImageFilter::fromValue(runtime, arguments[2]).get() : nullptr;
|
419
419
|
SkCanvas::SaveLayerFlags flags = count >= 4 ? arguments[3].asNumber() : 0;
|
420
420
|
return jsi::Value(_canvas->saveLayer(
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["GroupNode","JsiRenderNode","constructor","ctx","props","NodeType","Group","renderNode","children","map","child","render"],"sources":["GroupNode.ts"],"sourcesContent":["import type { DrawingContext, GroupProps } from \"../types\";\nimport { NodeType } from \"../types\";\
|
1
|
+
{"version":3,"names":["GroupNode","JsiRenderNode","constructor","ctx","props","NodeType","Group","renderNode","children","map","child","render"],"sources":["GroupNode.ts"],"sourcesContent":["import type { DrawingContext, GroupProps } from \"../types\";\nimport { NodeType } from \"../types\";\n\nimport { JsiRenderNode } from \"./RenderNode\";\nimport type { NodeContext } from \"./Node\";\n\nexport class GroupNode extends JsiRenderNode<GroupProps> {\n constructor(ctx: NodeContext, props: GroupProps) {\n super(ctx, NodeType.Group, props);\n }\n\n renderNode(ctx: DrawingContext): void {\n this.children().map((child) => {\n if (child instanceof JsiRenderNode) {\n child.render(ctx);\n }\n });\n }\n}\n"],"mappings":";;;;;;;AACA;;AAEA;;AAGO,MAAMA,SAAN,SAAwBC,yBAAxB,CAAkD;EACvDC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWE,eAAA,CAASC,KAApB,EAA2BF,KAA3B;EACD;;EAEDG,UAAU,CAACJ,GAAD,EAA4B;IACpC,KAAKK,QAAL,GAAgBC,GAAhB,CAAqBC,KAAD,IAAW;MAC7B,IAAIA,KAAK,YAAYT,yBAArB,EAAoC;QAClCS,KAAK,CAACC,MAAN,CAAaR,GAAb;MACD;IACF,CAJD;EAKD;;AAXsD"}
|
@@ -211,7 +211,7 @@ class JsiRenderNode extends _Node.JsiNode {
|
|
211
211
|
paint
|
212
212
|
};
|
213
213
|
const hasTransform = matrix !== undefined || transform !== undefined;
|
214
|
-
const hasClip = this.clipRect !== undefined;
|
214
|
+
const hasClip = this.clipRect !== undefined || this.clipPath !== undefined || this.clipRRect !== undefined;
|
215
215
|
const shouldSave = hasTransform || hasClip || !!layer;
|
216
216
|
const op = invertClip ? _types.ClipOp.Difference : _types.ClipOp.Intersect;
|
217
217
|
|
@@ -235,13 +235,9 @@ class JsiRenderNode extends _Node.JsiNode {
|
|
235
235
|
|
236
236
|
if (this.clipRect) {
|
237
237
|
canvas.clipRect(this.clipRect, op, true);
|
238
|
-
}
|
239
|
-
|
240
|
-
if (this.clipRRect) {
|
238
|
+
} else if (this.clipRRect) {
|
241
239
|
canvas.clipRRect(this.clipRRect, op, true);
|
242
|
-
}
|
243
|
-
|
244
|
-
if (this.clipPath) {
|
240
|
+
} else if (this.clipPath) {
|
245
241
|
canvas.clipPath(this.clipPath, op, true);
|
246
242
|
}
|
247
243
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["paintProps","JsiRenderNode","JsiNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","JsiDeclarationNode","setInvalidate","insertChildBefore","before","clip","isPathDef","processPath","isRRect","processTransformProps","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","BlendMode","enumKey","PaintStyle","StrokeJoin","StrokeCap","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","hasTransform","hasClip","shouldSave","op","ClipOp","Difference","Intersect","saveLayer","isSkPaint","current","save","concat","renderNode","restore","obj","__typename__","alpha","copy","setShader","setColor","cl","getColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setAlphaf","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nimport type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n DeclarationNode,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = {};\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n const opacity = this.props.opacity\n ? parentCtx.opacity * this.props.opacity\n : parentCtx.opacity;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint, paintCtx, parentCtx.opacity)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, opacity, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip = this.clipRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n\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(\n layer.current ? layer.current.materialize() : undefined\n );\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n }\n if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n }\n if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nexport const isSkPaint = (\n obj: RefObject<DeclarationNode<unknown, SkPaint>> | SkPaint\n): obj is SkPaint => \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nconst concatPaint = (\n parent: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity: alpha,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext,\n opacity: number\n) => {\n const paint = parent.copy();\n if (color !== undefined) {\n paint.setShader(null);\n color[3] *= opacity;\n paint.setColor(color);\n } else {\n const cl = paint.getColor();\n cl[3] *= opacity;\n paint.setColor(cl);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (alpha !== undefined) {\n paint.setAlphaf(alpha * opacity);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;;;;;;AASA;;AAiBA;;AAEA;;AAEA;;;;AAEA,MAAMA,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB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,EAA6B;IAC3B2D,KAAK,CAACiC,YAAN,CAAmBtE,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKrB,SAAnB,EAA8B;IAC5B2D,KAAK,CAACkC,aAAN,CAAoBxE,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKvB,SAApB,EAA+B;IAC7B2D,KAAK,CAACmC,cAAN,CAAqBvE,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKpB,SAAd,EAAyB;IACvB2D,KAAK,CAACoC,QAAN,CAAe3E,KAAf;EACD;;EACD,OAAOuC,KAAP;AACD,CAtED"}
|
1
|
+
{"version":3,"names":["paintProps","JsiRenderNode","JsiNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","JsiDeclarationNode","setInvalidate","insertChildBefore","before","clip","isPathDef","processPath","isRRect","processTransformProps","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","BlendMode","enumKey","PaintStyle","StrokeJoin","StrokeCap","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","hasTransform","hasClip","shouldSave","op","ClipOp","Difference","Intersect","saveLayer","isSkPaint","current","save","concat","renderNode","restore","obj","__typename__","alpha","copy","setShader","setColor","cl","getColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setAlphaf","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nimport type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n DeclarationNode,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = {};\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n const opacity = this.props.opacity\n ? parentCtx.opacity * this.props.opacity\n : parentCtx.opacity;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint, paintCtx, parentCtx.opacity)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, opacity, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n\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(\n layer.current ? layer.current.materialize() : undefined\n );\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nexport const isSkPaint = (\n obj: RefObject<DeclarationNode<unknown, SkPaint>> | SkPaint\n): obj is SkPaint => \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nconst concatPaint = (\n parent: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity: alpha,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext,\n opacity: number\n) => {\n const paint = parent.copy();\n if (color !== undefined) {\n paint.setShader(null);\n color[3] *= opacity;\n paint.setColor(color);\n } else {\n const cl = paint.getColor();\n cl[3] *= opacity;\n paint.setColor(cl);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (alpha !== undefined) {\n paint.setAlphaf(alpha * opacity);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;;;;;;AASA;;AAiBA;;AAEA;;AAEA;;;;AAEA,MAAMA,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB;;AAiBO,MAAeC,aAAf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AK,GAAGtD,OAAxB;EACD;;EACD,IAAIF,SAAS,KAAKtB,SAAlB,EAA6B;IAC3B2D,KAAK,CAACiC,YAAN,CAAmBtE,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKrB,SAAnB,EAA8B;IAC5B2D,KAAK,CAACkC,aAAN,CAAoBxE,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKvB,SAApB,EAA+B;IAC7B2D,KAAK,CAACmC,cAAN,CAAqBvE,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKpB,SAAd,EAAyB;IACvB2D,KAAK,CAACoC,QAAN,CAAe3E,KAAf;EACD;;EACD,OAAOuC,KAAP;AACD,CAtED"}
|
@@ -9,13 +9,11 @@ var _react = require("react");
|
|
9
9
|
|
10
10
|
var _Reanimated;
|
11
11
|
|
12
|
-
// @
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
13
|
let Reanimated;
|
14
|
-
let Core;
|
15
14
|
|
16
15
|
try {
|
17
16
|
Reanimated = require("react-native-reanimated");
|
18
|
-
Core = require("react-native-reanimated/lib/reanimated2/core");
|
19
17
|
} catch (e) {// Ignore
|
20
18
|
}
|
21
19
|
|
@@ -35,36 +33,16 @@ const useSharedValueEffect = function (cb, value) {
|
|
35
33
|
}
|
36
34
|
|
37
35
|
const input = useSharedValueWrapper(0);
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
} = (0, _react.useMemo)(() => {
|
43
|
-
if (Reanimated && Core) {
|
44
|
-
const {
|
45
|
-
runOnJS
|
46
|
-
} = Reanimated;
|
36
|
+
(0, _react.useEffect)(() => {
|
37
|
+
if (!Reanimated) {
|
38
|
+
console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
|
39
|
+
} else {
|
47
40
|
const {
|
48
|
-
startMapper,
|
49
|
-
stopMapper
|
50
|
-
} = Core;
|
51
|
-
return {
|
52
41
|
runOnJS,
|
53
42
|
startMapper,
|
54
43
|
stopMapper
|
55
|
-
};
|
56
|
-
|
57
|
-
console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
|
58
|
-
return {
|
59
|
-
runOnJS: undefined,
|
60
|
-
startMapper: undefined,
|
61
|
-
stopMapper: undefined
|
62
|
-
};
|
63
|
-
}
|
64
|
-
}, []);
|
65
|
-
(0, _react.useEffect)(() => {
|
66
|
-
if (startMapper !== undefined && runOnJS !== undefined && stopMapper !== undefined) {
|
67
|
-
// Start a mapper in Reanimated
|
44
|
+
} = Reanimated; // Start a mapper in Reanimated
|
45
|
+
|
68
46
|
const mapperId = startMapper(() => {
|
69
47
|
"worklet";
|
70
48
|
|
@@ -79,7 +57,7 @@ const useSharedValueEffect = function (cb, value) {
|
|
79
57
|
}
|
80
58
|
|
81
59
|
return () => {}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
82
|
-
}, [input,
|
60
|
+
}, [input, value, ...values]);
|
83
61
|
};
|
84
62
|
|
85
63
|
exports.useSharedValueEffect = useSharedValueEffect;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Reanimated","
|
1
|
+
{"version":3,"names":["Reanimated","require","e","useSharedValueWrapper","useSharedValue","undefined","value","useMemo","useSharedValueEffect","cb","values","input","useEffect","console","warn","runOnJS","startMapper","stopMapper","mapperId"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet Reanimated: any;\n\ntry {\n Reanimated = require(\"react-native-reanimated\");\n} catch (e) {\n // Ignore\n}\n\ntype SharedValueTypeWrapper<T = number> = {\n value: T;\n};\n\nconst useSharedValueWrapper =\n Reanimated?.useSharedValue === undefined\n ? (value: number) => useMemo(() => ({ value }), [value])\n : Reanimated.useSharedValue;\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueTypeWrapper<T>,\n ...values: SharedValueTypeWrapper<T>[]\n) => {\n const input = useSharedValueWrapper(0);\n\n useEffect(() => {\n if (!Reanimated) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n const { runOnJS, startMapper, stopMapper } = Reanimated;\n\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA,IAAIA,UAAJ;;AAEA,IAAI;EACFA,UAAU,GAAGC,OAAO,CAAC,yBAAD,CAApB;AACD,CAFD,CAEE,OAAOC,CAAP,EAAU,CACV;AACD;;AAMD,MAAMC,qBAAqB,GACzB,gBAAAH,UAAU,UAAV,kDAAYI,cAAZ,MAA+BC,SAA/B,GACKC,KAAD,IAAmB,IAAAC,cAAA,EAAQ,OAAO;EAAED;AAAF,CAAP,CAAR,EAA2B,CAACA,KAAD,CAA3B,CADvB,GAEIN,UAAU,CAACI,cAHjB;AAKA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMI,oBAAoB,GAAG,UAClCC,EADkC,EAElCH,KAFkC,EAI/B;EAAA,kCADAI,MACA;IADAA,MACA;EAAA;;EACH,MAAMC,KAAK,GAAGR,qBAAqB,CAAC,CAAD,CAAnC;EAEA,IAAAS,gBAAA,EAAU,MAAM;IACd,IAAI,CAACZ,UAAL,EAAiB;MACfa,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL,MAAM;QAAEC,OAAF;QAAWC,WAAX;QAAwBC;MAAxB,IAAuCjB,UAA7C,CADK,CAGL;;MACA,MAAMkB,QAAQ,GAAGF,WAAW,CAC1B,MAAM;QACJ;;QACAD,OAAO,CAACN,EAAD,CAAP;MACD,CAJyB,EAK1B,CAACH,KAAD,EAAQ,GAAGI,MAAX,CAL0B,EAM1B,CAACC,KAAD,CAN0B,CAA5B,CAJK,CAYL;;MACA,OAAO,MAAM;QACX,IAAIM,UAAU,IAAIC,QAAQ,KAAKb,SAA/B,EAA0C;UACxCY,UAAU,CAACC,QAAD,CAAV;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAxBc,CAyBd;EACD,CA1BD,EA0BG,CAACP,KAAD,EAAQL,KAAR,EAAe,GAAGI,MAAlB,CA1BH;AA2BD,CAlCM"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NodeType","JsiRenderNode","GroupNode","constructor","ctx","props","Group","renderNode","children","map","child","render"],"sources":["GroupNode.ts"],"sourcesContent":["import type { DrawingContext, GroupProps } from \"../types\";\nimport { NodeType } from \"../types\";\
|
1
|
+
{"version":3,"names":["NodeType","JsiRenderNode","GroupNode","constructor","ctx","props","Group","renderNode","children","map","child","render"],"sources":["GroupNode.ts"],"sourcesContent":["import type { DrawingContext, GroupProps } from \"../types\";\nimport { NodeType } from \"../types\";\n\nimport { JsiRenderNode } from \"./RenderNode\";\nimport type { NodeContext } from \"./Node\";\n\nexport class GroupNode extends JsiRenderNode<GroupProps> {\n constructor(ctx: NodeContext, props: GroupProps) {\n super(ctx, NodeType.Group, props);\n }\n\n renderNode(ctx: DrawingContext): void {\n this.children().map((child) => {\n if (child instanceof JsiRenderNode) {\n child.render(ctx);\n }\n });\n }\n}\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,UAAzB;AAEA,SAASC,aAAT,QAA8B,cAA9B;AAGA,OAAO,MAAMC,SAAN,SAAwBD,aAAxB,CAAkD;EACvDE,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWJ,QAAQ,CAACM,KAApB,EAA2BD,KAA3B;EACD;;EAEDE,UAAU,CAACH,GAAD,EAA4B;IACpC,KAAKI,QAAL,GAAgBC,GAAhB,CAAqBC,KAAD,IAAW;MAC7B,IAAIA,KAAK,YAAYT,aAArB,EAAoC;QAClCS,KAAK,CAACC,MAAN,CAAaP,GAAb;MACD;IACF,CAJD;EAKD;;AAXsD"}
|
@@ -199,7 +199,7 @@ export class JsiRenderNode extends JsiNode {
|
|
199
199
|
paint
|
200
200
|
};
|
201
201
|
const hasTransform = matrix !== undefined || transform !== undefined;
|
202
|
-
const hasClip = this.clipRect !== undefined;
|
202
|
+
const hasClip = this.clipRect !== undefined || this.clipPath !== undefined || this.clipRRect !== undefined;
|
203
203
|
const shouldSave = hasTransform || hasClip || !!layer;
|
204
204
|
const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;
|
205
205
|
|
@@ -223,13 +223,9 @@ export class JsiRenderNode extends JsiNode {
|
|
223
223
|
|
224
224
|
if (this.clipRect) {
|
225
225
|
canvas.clipRect(this.clipRect, op, true);
|
226
|
-
}
|
227
|
-
|
228
|
-
if (this.clipRRect) {
|
226
|
+
} else if (this.clipRRect) {
|
229
227
|
canvas.clipRRect(this.clipRRect, op, true);
|
230
|
-
}
|
231
|
-
|
232
|
-
if (this.clipPath) {
|
228
|
+
} else if (this.clipPath) {
|
233
229
|
canvas.clipPath(this.clipPath, op, true);
|
234
230
|
}
|
235
231
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["StrokeCap","StrokeJoin","PaintStyle","BlendMode","ClipOp","isRRect","isPathDef","processPath","processTransformProps","JsiNode","JsiDeclarationNode","enumKey","paintProps","JsiRenderNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","setInvalidate","insertChildBefore","before","clip","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","hasTransform","hasClip","shouldSave","op","Difference","Intersect","saveLayer","isSkPaint","current","save","concat","renderNode","restore","obj","__typename__","alpha","copy","setShader","setColor","cl","getColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setAlphaf","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nimport type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n DeclarationNode,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = {};\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n const opacity = this.props.opacity\n ? parentCtx.opacity * this.props.opacity\n : parentCtx.opacity;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint, paintCtx, parentCtx.opacity)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, opacity, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip = this.clipRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n\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(\n layer.current ? layer.current.materialize() : undefined\n );\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n }\n if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n }\n if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nexport const isSkPaint = (\n obj: RefObject<DeclarationNode<unknown, SkPaint>> | SkPaint\n): obj is SkPaint => \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nconst concatPaint = (\n parent: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity: alpha,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext,\n opacity: number\n) => {\n const paint = parent.copy();\n if (color !== undefined) {\n paint.setShader(null);\n color[3] *= opacity;\n paint.setColor(color);\n } else {\n const cl = paint.getColor();\n cl[3] *= opacity;\n paint.setColor(cl);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (alpha !== undefined) {\n paint.setAlphaf(alpha * opacity);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;AASA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,MALF,EAMEC,OANF,QAOO,kBAPP;AAiBA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,qBAAjC,QAA8D,aAA9D;AAEA,SAASC,OAAT,EAAkBC,kBAAlB,QAA4C,QAA5C;AAEA,SAASC,OAAT,QAAwB,kBAAxB;AAEA,MAAMC,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB;AAiBA,OAAO,MAAeC,aAAf,SACGJ,OADH,CAGP;EAOEK,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWC,IAAX,EAAiBC,KAAjB;;IADsD,oCANxB,IAMwB;;IAAA;;IAAA;;IAAA;;IAAA;;IAEtD,KAAKC,MAAL,GAAc,KAAKC,IAAL,CAAUC,MAAV,EAAd;IACA,KAAKC,YAAL;EACD;;EAEDC,QAAQ,CAACL,KAAD,EAAW;IACjB,MAAMK,QAAN,CAAeL,KAAf;IACA,KAAKI,YAAL;IACA,KAAKE,UAAL,GAAkB,IAAlB;EACD;;EAEDC,OAAO,CAAoBC,GAApB,EAA4BC,KAA5B,EAAyC;IAC9C,MAAMC,UAAU,GAAG,MAAMH,OAAN,CAAcC,GAAd,EAAmBC,KAAnB,CAAnB;;IACA,IAAIC,UAAJ,EAAgB;MACd,KAAKN,YAAL;;MACA,IAAIT,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AA6B;IAC3BiD,KAAK,CAAC0B,YAAN,CAAmB7D,SAAnB;EACD;;EACD,IAAIa,WAAW,KAAK3B,SAApB,EAA+B;IAC7BiD,KAAK,CAAC2B,cAAN,CAAqBjD,WAArB;EACD;;EACD,IAAIW,WAAW,KAAKtC,SAApB,EAA+B;IAC7BiD,KAAK,CAAC4B,cAAN,CAAqBvC,WAArB;EACD;;EACD,IAAIG,UAAU,KAAKzC,SAAnB,EAA8B;IAC5BiD,KAAK,CAAC6B,aAAN,CAAoBrC,UAApB;EACD;;EACD,IAAIP,UAAU,KAAKlC,SAAnB,EAA8B;IAC5BiD,KAAK,CAAC8B,aAAN,CAAoB7C,UAApB;EACD;;EACD,IAAIiC,KAAK,KAAKnE,SAAd,EAAyB;IACvBiD,KAAK,CAAC+B,SAAN,CAAgBb,KAAK,GAAGhD,OAAxB;EACD;;EACD,IAAIF,SAAS,KAAKjB,SAAlB,EAA6B;IAC3BiD,KAAK,CAACgC,YAAN,CAAmBhE,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKhB,SAAnB,EAA8B;IAC5BiD,KAAK,CAACiC,aAAN,CAAoBlE,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKlB,SAApB,EAA+B;IAC7BiD,KAAK,CAACkC,cAAN,CAAqBjE,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKf,SAAd,EAAyB;IACvBiD,KAAK,CAACmC,QAAN,CAAerE,KAAf;EACD;;EACD,OAAOkC,KAAP;AACD,CAtED"}
|
1
|
+
{"version":3,"names":["StrokeCap","StrokeJoin","PaintStyle","BlendMode","ClipOp","isRRect","isPathDef","processPath","processTransformProps","JsiNode","JsiDeclarationNode","enumKey","paintProps","JsiRenderNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","setInvalidate","insertChildBefore","before","clip","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","hasTransform","hasClip","shouldSave","op","Difference","Intersect","saveLayer","isSkPaint","current","save","concat","renderNode","restore","obj","__typename__","alpha","copy","setShader","setColor","cl","getColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setAlphaf","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nimport type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n DeclarationNode,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = {};\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n const opacity = this.props.opacity\n ? parentCtx.opacity * this.props.opacity\n : parentCtx.opacity;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint, paintCtx, parentCtx.opacity)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, opacity, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n\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(\n layer.current ? layer.current.materialize() : undefined\n );\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nexport const isSkPaint = (\n obj: RefObject<DeclarationNode<unknown, SkPaint>> | SkPaint\n): obj is SkPaint => \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nconst concatPaint = (\n parent: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity: alpha,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext,\n opacity: number\n) => {\n const paint = parent.copy();\n if (color !== undefined) {\n paint.setShader(null);\n color[3] *= opacity;\n paint.setColor(color);\n } else {\n const cl = paint.getColor();\n cl[3] *= opacity;\n paint.setColor(cl);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (alpha !== undefined) {\n paint.setAlphaf(alpha * opacity);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;AASA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,MALF,EAMEC,OANF,QAOO,kBAPP;AAiBA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,qBAAjC,QAA8D,aAA9D;AAEA,SAASC,OAAT,EAAkBC,kBAAlB,QAA4C,QAA5C;AAEA,SAASC,OAAT,QAAwB,kBAAxB;AAEA,MAAMC,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB;AAiBA,OAAO,MAAeC,aAAf,SACGJ,OADH,CAGP;EAOEK,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWC,IAAX,EAAiBC,KAAjB;;IADsD,oCANxB,IAMwB;;IAAA;;IAAA;;IAAA;;IAAA;;IAEtD,KAAKC,MAAL,GAAc,KAAKC,IAAL,CAAUC,MAAV,EAAd;IACA,KAAKC,YAAL;EACD;;EAEDC,QAAQ,CAACL,KAAD,EAAW;IACjB,MAAMK,QAAN,CAAeL,KAAf;IACA,KAAKI,YAAL;IACA,KAAKE,UAAL,GAAkB,IAAlB;EACD;;EAEDC,OAAO,CAAoBC,GAApB,EAA4BC,KAA5B,EAAyC;IAC9C,MAAMC,UAAU,GA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
6
|
-
|
7
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
8
|
-
import { useEffect, useMemo } from "react"; // @ts-ignore
|
3
|
+
import { useEffect, useMemo } from "react"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
9
4
|
|
10
5
|
let Reanimated;
|
11
|
-
let Core;
|
12
6
|
|
13
7
|
try {
|
14
8
|
Reanimated = require("react-native-reanimated");
|
15
|
-
Core = require("react-native-reanimated/lib/reanimated2/core");
|
16
9
|
} catch (e) {// Ignore
|
17
10
|
}
|
18
11
|
|
@@ -32,36 +25,16 @@ export const useSharedValueEffect = function (cb, value) {
|
|
32
25
|
}
|
33
26
|
|
34
27
|
const input = useSharedValueWrapper(0);
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
} = useMemo(() => {
|
40
|
-
if (Reanimated && Core) {
|
41
|
-
const {
|
42
|
-
runOnJS
|
43
|
-
} = Reanimated;
|
28
|
+
useEffect(() => {
|
29
|
+
if (!Reanimated) {
|
30
|
+
console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
|
31
|
+
} else {
|
44
32
|
const {
|
45
|
-
startMapper,
|
46
|
-
stopMapper
|
47
|
-
} = Core;
|
48
|
-
return {
|
49
33
|
runOnJS,
|
50
34
|
startMapper,
|
51
35
|
stopMapper
|
52
|
-
};
|
53
|
-
|
54
|
-
console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
|
55
|
-
return {
|
56
|
-
runOnJS: undefined,
|
57
|
-
startMapper: undefined,
|
58
|
-
stopMapper: undefined
|
59
|
-
};
|
60
|
-
}
|
61
|
-
}, []);
|
62
|
-
useEffect(() => {
|
63
|
-
if (startMapper !== undefined && runOnJS !== undefined && stopMapper !== undefined) {
|
64
|
-
// Start a mapper in Reanimated
|
36
|
+
} = Reanimated; // Start a mapper in Reanimated
|
37
|
+
|
65
38
|
const mapperId = startMapper(() => {
|
66
39
|
"worklet";
|
67
40
|
|
@@ -76,6 +49,6 @@ export const useSharedValueEffect = function (cb, value) {
|
|
76
49
|
}
|
77
50
|
|
78
51
|
return () => {}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
79
|
-
}, [input,
|
52
|
+
}, [input, value, ...values]);
|
80
53
|
};
|
81
54
|
//# sourceMappingURL=useSharedValueEffect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","Reanimated","
|
1
|
+
{"version":3,"names":["useEffect","useMemo","Reanimated","require","e","useSharedValueWrapper","useSharedValue","undefined","value","useSharedValueEffect","cb","values","input","console","warn","runOnJS","startMapper","stopMapper","mapperId"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet Reanimated: any;\n\ntry {\n Reanimated = require(\"react-native-reanimated\");\n} catch (e) {\n // Ignore\n}\n\ntype SharedValueTypeWrapper<T = number> = {\n value: T;\n};\n\nconst useSharedValueWrapper =\n Reanimated?.useSharedValue === undefined\n ? (value: number) => useMemo(() => ({ value }), [value])\n : Reanimated.useSharedValue;\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueTypeWrapper<T>,\n ...values: SharedValueTypeWrapper<T>[]\n) => {\n const input = useSharedValueWrapper(0);\n\n useEffect(() => {\n if (!Reanimated) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n const { runOnJS, startMapper, stopMapper } = Reanimated;\n\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks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1BM,CAAT;AA2BD,CAlCM"}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import type { DrawingContext, GroupProps } from "../types";
|
2
|
-
import type { RenderNode } from "../types/Node";
|
3
2
|
import { JsiRenderNode } from "./RenderNode";
|
4
3
|
import type { NodeContext } from "./Node";
|
5
|
-
export declare class GroupNode extends JsiRenderNode<GroupProps>
|
4
|
+
export declare class GroupNode extends JsiRenderNode<GroupProps> {
|
6
5
|
constructor(ctx: NodeContext, props: GroupProps);
|
7
6
|
renderNode(ctx: DrawingContext): void;
|
8
7
|
}
|
package/package.json
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
import type { DrawingContext, GroupProps } from "../types";
|
2
2
|
import { NodeType } from "../types";
|
3
|
-
import type { RenderNode } from "../types/Node";
|
4
3
|
|
5
4
|
import { JsiRenderNode } from "./RenderNode";
|
6
5
|
import type { NodeContext } from "./Node";
|
7
6
|
|
8
|
-
export class GroupNode
|
9
|
-
extends JsiRenderNode<GroupProps>
|
10
|
-
implements RenderNode<GroupProps>
|
11
|
-
{
|
7
|
+
export class GroupNode extends JsiRenderNode<GroupProps> {
|
12
8
|
constructor(ctx: NodeContext, props: GroupProps) {
|
13
9
|
super(ctx, NodeType.Group, props);
|
14
10
|
}
|
@@ -229,7 +229,10 @@ export abstract class JsiRenderNode<P extends GroupProps>
|
|
229
229
|
// TODO: can we only recreate a new context here if needed?
|
230
230
|
const ctx = { ...parentCtx, opacity, paint };
|
231
231
|
const hasTransform = matrix !== undefined || transform !== undefined;
|
232
|
-
const hasClip =
|
232
|
+
const hasClip =
|
233
|
+
this.clipRect !== undefined ||
|
234
|
+
this.clipPath !== undefined ||
|
235
|
+
this.clipRRect !== undefined;
|
233
236
|
const shouldSave = hasTransform || hasClip || !!layer;
|
234
237
|
const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;
|
235
238
|
|
@@ -254,11 +257,9 @@ export abstract class JsiRenderNode<P extends GroupProps>
|
|
254
257
|
}
|
255
258
|
if (this.clipRect) {
|
256
259
|
canvas.clipRect(this.clipRect, op, true);
|
257
|
-
}
|
258
|
-
if (this.clipRRect) {
|
260
|
+
} else if (this.clipRRect) {
|
259
261
|
canvas.clipRRect(this.clipRRect, op, true);
|
260
|
-
}
|
261
|
-
if (this.clipPath) {
|
262
|
+
} else if (this.clipPath) {
|
262
263
|
canvas.clipPath(this.clipPath, op, true);
|
263
264
|
}
|
264
265
|
|
@@ -1,16 +1,10 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-shadow */
|
2
|
-
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
3
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
4
1
|
import { useEffect, useMemo } from "react";
|
5
2
|
|
6
|
-
// @
|
7
|
-
let Reanimated:
|
8
|
-
let Core: // @ts-ignore
|
9
|
-
typeof import("react-native-reanimated/lib/reanimated2/core") | undefined;
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
4
|
+
let Reanimated: any;
|
10
5
|
|
11
6
|
try {
|
12
7
|
Reanimated = require("react-native-reanimated");
|
13
|
-
Core = require("react-native-reanimated/lib/reanimated2/core");
|
14
8
|
} catch (e) {
|
15
9
|
// Ignore
|
16
10
|
}
|
@@ -36,29 +30,15 @@ export const useSharedValueEffect = <T = number>(
|
|
36
30
|
...values: SharedValueTypeWrapper<T>[]
|
37
31
|
) => {
|
38
32
|
const input = useSharedValueWrapper(0);
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
const { startMapper, stopMapper } = Core;
|
43
|
-
return { runOnJS, startMapper, stopMapper };
|
44
|
-
} else {
|
33
|
+
|
34
|
+
useEffect(() => {
|
35
|
+
if (!Reanimated) {
|
45
36
|
console.warn(
|
46
37
|
"Reanimated was not found and the useSharedValueEffect hook will have no effect."
|
47
38
|
);
|
48
|
-
|
49
|
-
|
50
|
-
startMapper: undefined,
|
51
|
-
stopMapper: undefined,
|
52
|
-
};
|
53
|
-
}
|
54
|
-
}, []);
|
39
|
+
} else {
|
40
|
+
const { runOnJS, startMapper, stopMapper } = Reanimated;
|
55
41
|
|
56
|
-
useEffect(() => {
|
57
|
-
if (
|
58
|
-
startMapper !== undefined &&
|
59
|
-
runOnJS !== undefined &&
|
60
|
-
stopMapper !== undefined
|
61
|
-
) {
|
62
42
|
// Start a mapper in Reanimated
|
63
43
|
const mapperId = startMapper(
|
64
44
|
() => {
|
@@ -77,5 +57,5 @@ export const useSharedValueEffect = <T = number>(
|
|
77
57
|
}
|
78
58
|
return () => {};
|
79
59
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
80
|
-
}, [input,
|
60
|
+
}, [input, value, ...values]);
|
81
61
|
};
|