@shopify/react-native-skia 1.3.6 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +14 -7
  2. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +1 -2
  3. package/cpp/api/JsiSkTypefaceFontProvider.h +14 -4
  4. package/lib/commonjs/dom/nodes/Node.d.ts +2 -3
  5. package/lib/commonjs/dom/nodes/Node.js +1 -2
  6. package/lib/commonjs/dom/nodes/Node.js.map +1 -1
  7. package/lib/commonjs/dom/nodes/PaintNode.js +1 -1
  8. package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
  9. package/lib/commonjs/dom/nodes/drawings/Box.js +1 -1
  10. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  11. package/lib/commonjs/dom/nodes/paint/BlendNode.js +1 -1
  12. package/lib/commonjs/dom/nodes/paint/BlendNode.js.map +1 -1
  13. package/lib/commonjs/dom/nodes/paint/ColorFilters.js +1 -1
  14. package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
  15. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +1 -1
  16. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  17. package/lib/commonjs/dom/nodes/paint/MaskFilters.js +1 -1
  18. package/lib/commonjs/dom/nodes/paint/MaskFilters.js.map +1 -1
  19. package/lib/commonjs/dom/nodes/paint/PathEffects.js +1 -1
  20. package/lib/commonjs/dom/nodes/paint/PathEffects.js.map +1 -1
  21. package/lib/commonjs/dom/nodes/paint/Shaders.js +1 -1
  22. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  23. package/lib/commonjs/dom/types/Node.d.ts +1 -2
  24. package/lib/commonjs/dom/types/Node.js.map +1 -1
  25. package/lib/commonjs/dom/types/NodeType.d.ts +0 -9
  26. package/lib/commonjs/dom/types/NodeType.js +1 -11
  27. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  28. package/lib/commonjs/external/reanimated/useVideo.js +0 -2
  29. package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
  30. package/lib/commonjs/external/reanimated/useVideoLoading.js +6 -4
  31. package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -1
  32. package/lib/commonjs/skia/core/SVG.web.d.ts +2 -0
  33. package/lib/commonjs/skia/core/SVG.web.js +22 -0
  34. package/lib/commonjs/skia/core/SVG.web.js.map +1 -0
  35. package/lib/commonjs/skia/types/Font/FontMgr.d.ts +1 -1
  36. package/lib/commonjs/skia/types/Font/FontMgr.js.map +1 -1
  37. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js +1 -1
  38. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  40. package/lib/commonjs/skia/web/JsiSkCanvas.js +3 -2
  41. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkSVG.d.ts +9 -0
  43. package/lib/commonjs/skia/web/JsiSkSVG.js +28 -0
  44. package/lib/commonjs/skia/web/JsiSkSVG.js.map +1 -0
  45. package/lib/commonjs/skia/web/JsiSkSVGFactory.d.ts +4 -3
  46. package/lib/commonjs/skia/web/JsiSkSVGFactory.js +40 -4
  47. package/lib/commonjs/skia/web/JsiSkSVGFactory.js.map +1 -1
  48. package/lib/module/dom/nodes/Node.d.ts +2 -3
  49. package/lib/module/dom/nodes/Node.js +1 -2
  50. package/lib/module/dom/nodes/Node.js.map +1 -1
  51. package/lib/module/dom/nodes/PaintNode.js +2 -2
  52. package/lib/module/dom/nodes/PaintNode.js.map +1 -1
  53. package/lib/module/dom/nodes/drawings/Box.js +2 -2
  54. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  55. package/lib/module/dom/nodes/paint/BlendNode.js +2 -2
  56. package/lib/module/dom/nodes/paint/BlendNode.js.map +1 -1
  57. package/lib/module/dom/nodes/paint/ColorFilters.js +2 -2
  58. package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
  59. package/lib/module/dom/nodes/paint/ImageFilters.js +2 -2
  60. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  61. package/lib/module/dom/nodes/paint/MaskFilters.js +2 -2
  62. package/lib/module/dom/nodes/paint/MaskFilters.js.map +1 -1
  63. package/lib/module/dom/nodes/paint/PathEffects.js +2 -2
  64. package/lib/module/dom/nodes/paint/PathEffects.js.map +1 -1
  65. package/lib/module/dom/nodes/paint/Shaders.js +2 -2
  66. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  67. package/lib/module/dom/types/Node.d.ts +1 -2
  68. package/lib/module/dom/types/Node.js.map +1 -1
  69. package/lib/module/dom/types/NodeType.d.ts +0 -9
  70. package/lib/module/dom/types/NodeType.js +0 -10
  71. package/lib/module/dom/types/NodeType.js.map +1 -1
  72. package/lib/module/external/reanimated/useVideo.js +0 -2
  73. package/lib/module/external/reanimated/useVideo.js.map +1 -1
  74. package/lib/module/external/reanimated/useVideoLoading.js +7 -5
  75. package/lib/module/external/reanimated/useVideoLoading.js.map +1 -1
  76. package/lib/module/skia/core/SVG.web.d.ts +2 -0
  77. package/lib/module/skia/core/SVG.web.js +15 -0
  78. package/lib/module/skia/core/SVG.web.js.map +1 -0
  79. package/lib/module/skia/types/Font/FontMgr.d.ts +1 -1
  80. package/lib/module/skia/types/Font/FontMgr.js.map +1 -1
  81. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js +1 -1
  82. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  83. package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  84. package/lib/module/skia/web/JsiSkCanvas.js +3 -2
  85. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  86. package/lib/module/skia/web/JsiSkSVG.d.ts +9 -0
  87. package/lib/module/skia/web/JsiSkSVG.js +21 -0
  88. package/lib/module/skia/web/JsiSkSVG.js.map +1 -0
  89. package/lib/module/skia/web/JsiSkSVGFactory.d.ts +4 -3
  90. package/lib/module/skia/web/JsiSkSVGFactory.js +41 -5
  91. package/lib/module/skia/web/JsiSkSVGFactory.js.map +1 -1
  92. package/lib/typescript/src/dom/nodes/Node.d.ts +2 -3
  93. package/lib/typescript/src/dom/types/Node.d.ts +1 -2
  94. package/lib/typescript/src/dom/types/NodeType.d.ts +0 -9
  95. package/lib/typescript/src/skia/core/SVG.web.d.ts +2 -0
  96. package/lib/typescript/src/skia/types/Font/FontMgr.d.ts +1 -1
  97. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
  98. package/lib/typescript/src/skia/web/JsiSkSVG.d.ts +9 -0
  99. package/lib/typescript/src/skia/web/JsiSkSVGFactory.d.ts +4 -3
  100. package/package.json +2 -2
  101. package/src/dom/nodes/Node.ts +2 -12
  102. package/src/dom/nodes/PaintNode.ts +2 -2
  103. package/src/dom/nodes/drawings/Box.ts +2 -2
  104. package/src/dom/nodes/paint/BlendNode.ts +2 -2
  105. package/src/dom/nodes/paint/ColorFilters.ts +2 -2
  106. package/src/dom/nodes/paint/ImageFilters.ts +2 -2
  107. package/src/dom/nodes/paint/MaskFilters.ts +2 -2
  108. package/src/dom/nodes/paint/PathEffects.ts +2 -2
  109. package/src/dom/nodes/paint/Shaders.ts +2 -2
  110. package/src/dom/types/Node.ts +2 -2
  111. package/src/dom/types/NodeType.ts +0 -10
  112. package/src/external/reanimated/useVideo.ts +0 -2
  113. package/src/external/reanimated/useVideoLoading.ts +11 -8
  114. package/src/skia/core/SVG.web.ts +29 -0
  115. package/src/skia/types/Font/FontMgr.ts +1 -1
  116. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +1 -1
  117. package/src/skia/web/JsiSkCanvas.ts +6 -2
  118. package/src/skia/web/JsiSkSVG.ts +27 -0
  119. package/src/skia/web/JsiSkSVGFactory.ts +47 -6
@@ -1 +1 @@
1
- {"version":3,"names":["processUniforms","FilterMode","MipmapMode","TileMode","JsiDeclarationNode","DeclarationType","NodeType","enumKey","fitRects","getRect","processGradientProps","processTransformProps","rect2rect","ShaderDeclaration","constructor","ctx","type","props","Shader","ShaderNode","decorate","decorateChildren","source","uniforms","transform","m3","Skia","Matrix","shader","makeShaderWithChildren","shaders","popAll","push","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","rects","x","y","width","height","sx","sy","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n DeclarationContext,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.popAll(),\n m3\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n if (!image) {\n return;\n }\n\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { color } = this.props;\n const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));\n ctx.shaders.push(shader);\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,UAAU,EACVC,UAAU,EACVC,QAAQ,QACH,qBAAqB;AAE5B,SAASC,kBAAkB,QAAQ,SAAS;AAa5C,SAASC,eAAe,EAAEC,QAAQ,QAAQ,aAAa;AACvD,SACEC,OAAO,EACPC,QAAQ,EACRC,OAAO,EACPC,oBAAoB,EACpBC,qBAAqB,EACrBC,SAAS,QACJ,cAAc;AAErB,OAAO,MAAeC,iBAAiB,SAAYT,kBAAkB,CAAI;EACvEU,WAAWA,CAACC,GAAgB,EAAEC,IAAc,EAAEC,KAAQ,EAAE;IACtD,KAAK,CAACF,GAAG,EAAEV,eAAe,CAACa,MAAM,EAAEF,IAAI,EAAEC,KAAK,CAAC;EACjD;AACF;AAEA,OAAO,MAAME,UAAU,SAASN,iBAAiB,CAAc;EAC7DC,WAAWA,CAACC,GAAgB,EAAEE,KAAkB,EAAE;IAChD,KAAK,CAACF,GAAG,EAAET,QAAQ,CAACY,MAAM,EAAED,KAAK,CAAC;EACpC;EAEAG,QAAQA,CAACL,GAAuB,EAAE;IAChC,IAAI,CAACM,gBAAgB,CAACN,GAAG,CAAC;IAC1B,MAAM;MAAEO,MAAM;MAAEC,QAAQ;MAAE,GAAGC;IAAU,CAAC,GAAG,IAAI,CAACP,KAAK;IACrD,MAAMQ,EAAE,GAAG,IAAI,CAACC,IAAI,CAACC,MAAM,C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ACkF,2BAA2B,CACzDpB,KAAK,EACLkB,MAAM,EACNjB,GAAG,EACHkB,IAAI,EACJjB,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,KACF,CAAC;IACDvE,GAAG,CAACe,OAAO,CAACE,IAAI,CAACJ,MAAM,CAAC;EAC1B;AACF"}
1
+ {"version":3,"names":["processUniforms","FilterMode","MipmapMode","TileMode","JsiDeclarationNode","NodeType","enumKey","fitRects","getRect","processGradientProps","processTransformProps","rect2rect","ShaderDeclaration","constructor","ctx","type","props","ShaderNode","Shader","decorate","decorateChildren","source","uniforms","transform","m3","Skia","Matrix","shader","makeShaderWithChildren","shaders","popAll","push","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","rects","x","y","width","height","sx","sy","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n DeclarationContext,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.popAll(),\n m3\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n if (!image) {\n return;\n }\n\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { color } = this.props;\n const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));\n ctx.shaders.push(shader);\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,UAAU,EACVC,UAAU,EACVC,QAAQ,QACH,qBAAqB;AAE5B,SAASC,kBAAkB,QAAQ,SAAS;AAa5C,SAASC,QAAQ,QAAQ,aAAa;AACtC,SACEC,OAAO,EACPC,QAAQ,EACRC,OAAO,EACPC,oBAAoB,EACpBC,qBAAqB,EACrBC,SAAS,QACJ,cAAc;AAErB,OAAO,MAAeC,iBAAiB,SAAYR,kBAAkB,CAAI;EACvES,WAAWA,CAACC,GAAgB,EAAEC,IAAc,EAAEC,KAAQ,EAAE;IACtD,KAAK,CAACF,GAAG,EAAEC,IAAI,EAAEC,KAAK,CAAC;EACzB;AACF;AAEA,OAAO,MAAMC,UAAU,SAASL,iBAAiB,CAAc;EAC7DC,WAAWA,CAACC,GAAgB,EAAEE,KAAkB,EAAE;IAChD,KAAK,CAACF,GAAG,EAAET,QAAQ,CAACa,MAAM,EAAEF,KAAK,CAAC;EACpC;EAEAG,QAAQA,CAACL,GAAuB,EAAE;IAChC,IAAI,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S;MAAEC,IAAI;MAAEC,WAAW;MAAEC;IAAM,CAAC,GACnD5E,oBAAoB,CAAC,IAAI,CAACgB,IAAI,EAAE,IAAI,CAACT,KAAK,CAAC;IAC7C,MAAMW,MAAM,GAAG,IAAI,CAACF,IAAI,CAACP,MAAM,CAACiF,2BAA2B,CACzDpB,KAAK,EACLkB,MAAM,EACNjB,GAAG,EACHkB,IAAI,EACJjB,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,KACF,CAAC;IACDvE,GAAG,CAACe,OAAO,CAACE,IAAI,CAACJ,MAAM,CAAC;EAC1B;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { GroupProps } from "./Common";
2
- import type { DeclarationType, NodeType } from "./NodeType";
2
+ import type { NodeType } from "./NodeType";
3
3
  import type { DeclarationContext } from "./DeclarationContext";
4
4
  import type { DrawingContext } from "./DrawingContext";
5
5
  export interface Node<P> {
@@ -14,7 +14,6 @@ export interface Node<P> {
14
14
  }
15
15
  export type Invalidate = () => void;
16
16
  export interface DeclarationNode<P> extends Node<P> {
17
- declarationType: DeclarationType;
18
17
  decorate(ctx: DeclarationContext): void;
19
18
  setInvalidate(invalidate: Invalidate): void;
20
19
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Node.ts"],"sourcesContent":["import type { GroupProps } from \"./Common\";\nimport type { DeclarationType, NodeType } from \"./NodeType\";\nimport type { DeclarationContext } from \"./DeclarationContext\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nexport interface Node<P> {\n type: NodeType;\n\n setProps(props: P): void;\n setProp<K extends keyof P>(name: K, v: P[K]): boolean;\n getProps(): P;\n\n children(): Node<unknown>[];\n addChild(child: Node<unknown>): void;\n removeChild(child: Node<unknown>): void;\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;\n}\n\nexport type Invalidate = () => void;\n\nexport interface DeclarationNode<P> extends Node<P> {\n declarationType: DeclarationType;\n decorate(ctx: DeclarationContext): void;\n\n setInvalidate(invalidate: Invalidate): void;\n}\n\nexport interface RenderNode<P extends GroupProps> extends Node<P> {\n render(ctx: DrawingContext): void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Node.ts"],"sourcesContent":["import type { GroupProps } from \"./Common\";\nimport type { NodeType } from \"./NodeType\";\nimport type { DeclarationContext } from \"./DeclarationContext\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nexport interface Node<P> {\n type: NodeType;\n\n setProps(props: P): void;\n setProp<K extends keyof P>(name: K, v: P[K]): boolean;\n getProps(): P;\n\n children(): Node<unknown>[];\n addChild(child: Node<unknown>): void;\n removeChild(child: Node<unknown>): void;\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;\n}\n\nexport type Invalidate = () => void;\n\nexport interface DeclarationNode<P> extends Node<P> {\n //declarationType: DeclarationType;\n decorate(ctx: DeclarationContext): void;\n\n setInvalidate(invalidate: Invalidate): void;\n}\n\nexport interface RenderNode<P extends GroupProps> extends Node<P> {\n render(ctx: DrawingContext): void;\n}\n"],"mappings":""}
@@ -57,12 +57,3 @@ export declare const enum NodeType {
57
57
  Atlas = "skAtlas",
58
58
  Paragraph = "skParagraph"
59
59
  }
60
- export declare const enum DeclarationType {
61
- Paint = 0,
62
- Shader = 1,
63
- ImageFilter = 2,
64
- ColorFilter = 3,
65
- PathEffect = 4,
66
- MaskFilter = 5,
67
- Unknown = 6
68
- }
@@ -58,14 +58,4 @@ export let NodeType = /*#__PURE__*/function (NodeType) {
58
58
  NodeType["Paragraph"] = "skParagraph";
59
59
  return NodeType;
60
60
  }({});
61
- export let DeclarationType = /*#__PURE__*/function (DeclarationType) {
62
- DeclarationType[DeclarationType["Paint"] = 0] = "Paint";
63
- DeclarationType[DeclarationType["Shader"] = 1] = "Shader";
64
- DeclarationType[DeclarationType["ImageFilter"] = 2] = "ImageFilter";
65
- DeclarationType[DeclarationType["ColorFilter"] = 3] = "ColorFilter";
66
- DeclarationType[DeclarationType["PathEffect"] = 4] = "PathEffect";
67
- DeclarationType[DeclarationType["MaskFilter"] = 5] = "MaskFilter";
68
- DeclarationType[DeclarationType["Unknown"] = 6] = "Unknown";
69
- return DeclarationType;
70
- }({});
71
61
  //# sourceMappingURL=NodeType.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NodeType","DeclarationType"],"sources":["NodeType.ts"],"sourcesContent":["export const enum NodeType {\n // Shaders\n Layer = \"skLayer\",\n Shader = \"skShader\",\n ImageShader = \"skImageShader\",\n ColorShader = \"skColorShader\",\n Turbulence = \"skTurbulence\",\n FractalNoise = \"skFractalNoise\",\n LinearGradient = \"skLinearGradient\",\n RadialGradient = \"skRadialGradient\",\n SweepGradient = \"skSweepGradient\",\n TwoPointConicalGradient = \"skTwoPointConicalGradient\",\n\n // Mask Filters\n BlurMaskFilter = \"skBlurMaskFilter\",\n\n // Path Effects\n DiscretePathEffect = \"skDiscretePathEffect\",\n DashPathEffect = \"skDashPathEffect\",\n Path1DPathEffect = \"skPath1DPathEffect\",\n Path2DPathEffect = \"skPath2DPathEffect\",\n CornerPathEffect = \"skCornerPathEffect\",\n SumPathEffect = \"skSumPathEffect\",\n Line2DPathEffect = \"skLine2DPathEffect\",\n\n // Color Filters\n MatrixColorFilter = \"skMatrixColorFilter\",\n BlendColorFilter = \"skBlendColorFilter\",\n LinearToSRGBGammaColorFilter = \"skLinearToSRGBGammaColorFilter\",\n SRGBToLinearGammaColorFilter = \"skSRGBToLinearGammaColorFilter\",\n LumaColorFilter = \"skLumaColorFilter\",\n LerpColorFilter = \"skLerpColorFilter\",\n\n // Image Filters\n OffsetImageFilter = \"skOffsetImageFilter\",\n DisplacementMapImageFilter = \"skDisplacementMapImageFilter\",\n BlurImageFilter = \"skBlurImageFilter\",\n DropShadowImageFilter = \"skDropShadowImageFilter\",\n MorphologyImageFilter = \"skMorphologyImageFilter\",\n BlendImageFilter = \"skBlendImageFilter\",\n RuntimeShaderImageFilter = \"skRuntimeShaderImageFilter\",\n\n // Mixed\n Blend = \"skBlend\",\n BackdropFilter = \"skBackdropFilter\",\n Box = \"skBox\",\n BoxShadow = \"skBoxShadow\",\n\n // Drawings\n Group = \"skGroup\",\n Paint = \"skPaint\",\n Circle = \"skCircle\",\n Fill = \"skFill\",\n Image = \"skImage\",\n Points = \"skPoints\",\n Path = \"skPath\",\n Rect = \"skRect\",\n RRect = \"skRRect\",\n Oval = \"skOval\",\n Line = \"skLine\",\n Patch = \"skPatch\",\n Vertices = \"skVertices\",\n DiffRect = \"skDiffRect\",\n Text = \"skText\",\n TextPath = \"skTextPath\",\n TextBlob = \"skTextBlob\",\n Glyphs = \"skGlyphs\",\n Picture = \"skPicture\",\n ImageSVG = \"skImageSVG\",\n Atlas = \"skAtlas\",\n\n // Paragraph\n Paragraph = \"skParagraph\",\n}\n\nexport const enum DeclarationType {\n Paint,\n Shader,\n ImageFilter,\n ColorFilter,\n PathEffect,\n MaskFilter,\n Unknown,\n}\n"],"mappings":"AAAA,WAAkBA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AA2E1B,WAAkBC,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA"}
1
+ {"version":3,"names":["NodeType"],"sources":["NodeType.ts"],"sourcesContent":["export const enum NodeType {\n // Shaders\n Layer = \"skLayer\",\n Shader = \"skShader\",\n ImageShader = \"skImageShader\",\n ColorShader = \"skColorShader\",\n Turbulence = \"skTurbulence\",\n FractalNoise = \"skFractalNoise\",\n LinearGradient = \"skLinearGradient\",\n RadialGradient = \"skRadialGradient\",\n SweepGradient = \"skSweepGradient\",\n TwoPointConicalGradient = \"skTwoPointConicalGradient\",\n\n // Mask Filters\n BlurMaskFilter = \"skBlurMaskFilter\",\n\n // Path Effects\n DiscretePathEffect = \"skDiscretePathEffect\",\n DashPathEffect = \"skDashPathEffect\",\n Path1DPathEffect = \"skPath1DPathEffect\",\n Path2DPathEffect = \"skPath2DPathEffect\",\n CornerPathEffect = \"skCornerPathEffect\",\n SumPathEffect = \"skSumPathEffect\",\n Line2DPathEffect = \"skLine2DPathEffect\",\n\n // Color Filters\n MatrixColorFilter = \"skMatrixColorFilter\",\n BlendColorFilter = \"skBlendColorFilter\",\n LinearToSRGBGammaColorFilter = \"skLinearToSRGBGammaColorFilter\",\n SRGBToLinearGammaColorFilter = \"skSRGBToLinearGammaColorFilter\",\n LumaColorFilter = \"skLumaColorFilter\",\n LerpColorFilter = \"skLerpColorFilter\",\n\n // Image Filters\n OffsetImageFilter = \"skOffsetImageFilter\",\n DisplacementMapImageFilter = \"skDisplacementMapImageFilter\",\n BlurImageFilter = \"skBlurImageFilter\",\n DropShadowImageFilter = \"skDropShadowImageFilter\",\n MorphologyImageFilter = \"skMorphologyImageFilter\",\n BlendImageFilter = \"skBlendImageFilter\",\n RuntimeShaderImageFilter = \"skRuntimeShaderImageFilter\",\n\n // Mixed\n Blend = \"skBlend\",\n BackdropFilter = \"skBackdropFilter\",\n Box = \"skBox\",\n BoxShadow = \"skBoxShadow\",\n\n // Drawings\n Group = \"skGroup\",\n Paint = \"skPaint\",\n Circle = \"skCircle\",\n Fill = \"skFill\",\n Image = \"skImage\",\n Points = \"skPoints\",\n Path = \"skPath\",\n Rect = \"skRect\",\n RRect = \"skRRect\",\n Oval = \"skOval\",\n Line = \"skLine\",\n Patch = \"skPatch\",\n Vertices = \"skVertices\",\n DiffRect = \"skDiffRect\",\n Text = \"skText\",\n TextPath = \"skTextPath\",\n TextBlob = \"skTextBlob\",\n Glyphs = \"skGlyphs\",\n Picture = \"skPicture\",\n ImageSVG = \"skImageSVG\",\n Atlas = \"skAtlas\",\n\n // Paragraph\n Paragraph = \"skParagraph\",\n}\n"],"mappings":"AAAA,WAAkBA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA"}
@@ -23,7 +23,6 @@ const setFrame = (video, currentFrame) => {
23
23
  currentFrame.value.dispose();
24
24
  }
25
25
  currentFrame.value = img;
26
- } else {
27
26
  copyFrameOnAndroid(currentFrame);
28
27
  }
29
28
  };
@@ -87,7 +86,6 @@ export const useVideo = (source, userOptions) => {
87
86
  });
88
87
  Rea.useAnimatedReaction(() => seek.value, value => {
89
88
  if (value !== null) {
90
- copyFrameOnAndroid(currentFrame);
91
89
  video === null || video === void 0 || video.seek(value);
92
90
  currentTime.value = value;
93
91
  seek.value = null;
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useMemo","Platform","Rea","useVideoLoading","copyFrameOnAndroid","currentFrame","OS","tex","value","makeNonTextureImage","dispose","setFrame","video","img","nextImage","defaultOptions","looping","paused","seek","currentTime","volume","useOption","defaultValue","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$volume","isPaused","lastTimestamp","duration","_video$duration","framerate","_video$framerate","size","_video$size","width","height","rotation","_video$rotation","frameDuration","currentFrameDuration","Math","floor","useAnimatedReaction","pause","play","setVolume","useFrameCallback","frameInfo","currentTimestamp","timestamp","delta","isOver","runOnUI"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype Animated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n volume: Animated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n currentFrame.value = tex.makeNonTextureImage();\n tex.dispose();\n }\n }\n};\n\nconst setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = img;\n } else {\n copyFrameOnAndroid(currentFrame);\n }\n};\n\nconst defaultOptions = {\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n volume: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useVideoLoading(source);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const volume = useOption(userOptions?.volume ?? defaultOptions.volume);\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(\n () => (Platform.OS === \"web\" ? -1 : video?.framerate() ?? 0),\n [video]\n );\n const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);\n const rotation = useMemo(() => video?.rotation() ?? 0, [video]);\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(frameDuration);\n Rea.useAnimatedReaction(\n () => isPaused.value,\n (paused) => {\n if (paused) {\n video?.pause();\n } else {\n lastTimestamp.value = -1;\n video?.play();\n }\n }\n );\n Rea.useAnimatedReaction(\n () => seek.value,\n (value) => {\n if (value !== null) {\n copyFrameOnAndroid(currentFrame);\n video?.seek(value);\n currentTime.value = value;\n seek.value = null;\n }\n }\n );\n Rea.useAnimatedReaction(\n () => volume.value,\n (value) => {\n video?.setVolume(value);\n }\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (isPaused.value) {\n return;\n }\n const currentTimestamp = frameInfo.timestamp;\n if (lastTimestamp.value === -1) {\n lastTimestamp.value = currentTimestamp;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const isOver = currentTime.value + delta > duration;\n if (isOver && looping.value) {\n seek.value = 0;\n currentTime.value = seek.value;\n lastTimestamp.value = currentTimestamp;\n }\n // On Web the framerate is uknown.\n // This could be optimized by using requestVideoFrameCallback (Chrome only)\n if ((delta >= currentFrameDuration && !isOver) || Platform.OS === \"web\") {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return {\n currentFrame,\n currentTime,\n duration,\n framerate,\n rotation,\n size,\n };\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAG1C,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,OAAOC,GAAG,MAAM,mBAAmB;AACnC,SAASC,eAAe,QAAQ,mBAAmB;AAWnD,MAAMC,kBAAkB,GAAIC,YAAyC,IAAK;EACxE,SAAS;;EACT;EACA,IAAIJ,QAAQ,CAACK,EAAE,KAAK,S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;MAC1BvB,aAAa,CAAC1B,KAAK,GAAG+C,gBAAgB;IACxC;EACF,CAAC,CAAC;EAEFxD,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAG,GAAG,CAACyD,OAAO,CAAClC,YAAY,CAAC,CAACb,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAO;IACLP,YAAY;IACZc,WAAW;IACXgB,QAAQ;IACRE,SAAS;IACTM,QAAQ;IACRJ;EACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["useEffect","useMemo","Platform","Rea","useVideoLoading","copyFrameOnAndroid","currentFrame","OS","tex","value","makeNonTextureImage","dispose","setFrame","video","img","nextImage","defaultOptions","looping","paused","seek","currentTime","volume","useOption","defaultValue","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$volume","isPaused","lastTimestamp","duration","_video$duration","framerate","_video$framerate","size","_video$size","width","height","rotation","_video$rotation","frameDuration","currentFrameDuration","Math","floor","useAnimatedReaction","pause","play","setVolume","useFrameCallback","frameInfo","currentTimestamp","timestamp","delta","isOver","runOnUI"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype Animated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n volume: Animated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n currentFrame.value = tex.makeNonTextureImage();\n tex.dispose();\n }\n }\n};\n\nconst setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = img;\n copyFrameOnAndroid(currentFrame);\n }\n};\n\nconst defaultOptions = {\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n volume: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useVideoLoading(source);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const volume = useOption(userOptions?.volume ?? defaultOptions.volume);\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(\n () => (Platform.OS === \"web\" ? -1 : video?.framerate() ?? 0),\n [video]\n );\n const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);\n const rotation = useMemo(() => video?.rotation() ?? 0, [video]);\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(frameDuration);\n Rea.useAnimatedReaction(\n () => isPaused.value,\n (paused) => {\n if (paused) {\n video?.pause();\n } else {\n lastTimestamp.value = -1;\n video?.play();\n }\n }\n );\n Rea.useAnimatedReaction(\n () => seek.value,\n (value) => {\n if (value !== null) {\n video?.seek(value);\n currentTime.value = value;\n seek.value = null;\n }\n }\n );\n Rea.useAnimatedReaction(\n () => volume.value,\n (value) => {\n video?.setVolume(value);\n }\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (isPaused.value) {\n return;\n }\n const currentTimestamp = frameInfo.timestamp;\n if (lastTimestamp.value === -1) {\n lastTimestamp.value = currentTimestamp;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const isOver = currentTime.value + delta > duration;\n if (isOver && looping.value) {\n seek.value = 0;\n currentTime.value = seek.value;\n lastTimestamp.value = currentTimestamp;\n }\n // On Web the framerate is uknown.\n // This could be optimized by using requestVideoFrameCallback (Chrome only)\n if ((delta >= currentFrameDuration && !isOver) || Platform.OS === \"web\") {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return {\n currentFrame,\n currentTime,\n duration,\n framerate,\n rotation,\n size,\n };\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAG1C,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,OAAOC,GAAG,MAAM,mBAAmB;AACnC,SAASC,eAAe,QAAQ,mBAAmB;AAWnD,MAAMC,kBAAkB,GAAIC,YAAyC,IAAK;EACxE,SAAS;;EACT;EACA,IAAIJ,QAAQ,CAACK,EAAE,KAAK,SAAS,EAAE;IAC7B,MAAMC,GAAG,GAAGF,YAAY,CAACG,KAAK;IAC9B,IAAID,GAAG,EAAE;MACPF,YAAY,CAACG,KAAK,GAAGD,GAAG,CAACE,mBAAmB,CAAC,CAAC;MAC9CF,GAAG,CAACG,OAAO,CAAC,CAAC;IACf;EACF;AACF,CAAC;AAED,MAAMC,QAAQ,GAAGA,CAACC,KAAY,EAAEP,YAAyC,KAAK;EAC5E,SAAS;;EACT,MAAMQ,GAAG,GAAGD,KAAK,CAACE,SAAS,CAAC,CAAC;EAC7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allback, useEffect, useState } from "react";
2
2
  import { Skia } from "../../skia";
3
3
  import Rea from "./ReanimatedProxy";
4
4
  const runtime = Rea.createWorkletRuntime("video-metadata-runtime");
5
5
  export const useVideoLoading = source => {
6
- const runOnJS = Rea.runOnJS;
6
+ const {
7
+ runOnJS
8
+ } = Rea;
7
9
  const [video, setVideo] = useState(null);
8
- const cb = src => {
10
+ const cb = useCallback(src => {
9
11
  "worklet";
10
12
 
11
13
  const vid = Skia.Video(src);
12
14
  runOnJS(setVideo)(vid);
13
- };
15
+ }, [runOnJS]);
14
16
  useEffect(() => {
15
17
  if (source) {
16
18
  Rea.runOnRuntime(runtime, cb)(source);
17
19
  }
18
- }, [source]);
20
+ }, [cb, source]);
19
21
  return video;
20
22
  };
21
23
  //# sourceMappingURL=useVideoLoading.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","Skia","Rea","runtime","createWorkletRuntime","useVideoLoading","source","runOnJS","video","setVideo","cb","src","vid","Video","runOnRuntime"],"sources":["useVideoLoading.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport type { Video } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst runtime = Rea.createWorkletRuntime(\"video-metadata-runtime\");\n\ntype VideoSource = string | null;\n\nexport const useVideoLoading = (source: VideoSource) => {\n const runOnJS = Rea.runOnJS;\n const [video, setVideo] = useState<Video | null>(null);\n const cb = (src: string) => {\n \"worklet\";\n const vid = Skia.Video(src) as Video;\n runOnJS(setVideo)(vid);\n };\n useEffect(() => {\n if (source) {\n Rea.runOnRuntime(runtime, cb)(source);\n }\n }, [source]);\n return video;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAG3C,SAASC,IAAI,QAAQ,YAAY;AAEjC,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,MAAMC,OAAO,GAAGD,GAAG,CAACE,oBAAoB,CAAC,wBAAwB,CAAC;AAIlE,OAAO,MAAMC,eAAe,GAAIC,MAAmB,IAAK;EACtD,MAAMC,OAAO,GAAGL,GAAG,CAACK,OAAO;EAC3B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGT,QAAQ,CAAe,IAAI,CAAC;EACtD,MAAMU,EAAE,GAAIC,GAAW,IAAK;IAC1B,SAAS;;IACT,MAAMC,GAAG,GAAGX,IAAI,CAACY,KAAK,CAACF,GAAG,CAAU;IACpCJ,OAAO,CAACE,QAAQ,CAAC,CAACG,GAAG,CAAC;EACxB,CAAC;EACDb,SAAS,CAAC,MAAM;IACd,IAAIO,MAAM,EAAE;MACVJ,GAAG,CAACY,YAAY,CAACX,OAAO,EAAEO,EAAE,CAAC,CAACJ,MAAM,CAAC;IACvC;EACF,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EACZ,OAAOE,KAAK;AACd,CAAC"}
1
+ {"version":3,"names":["useCallback","useEffect","useState","Skia","Rea","runtime","createWorkletRuntime","useVideoLoading","source","runOnJS","video","setVideo","cb","src","vid","Video","runOnRuntime"],"sources":["useVideoLoading.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\n\nimport type { Video } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst runtime = Rea.createWorkletRuntime(\"video-metadata-runtime\");\n\ntype VideoSource = string | null;\n\nexport const useVideoLoading = (source: VideoSource) => {\n const { runOnJS } = Rea;\n const [video, setVideo] = useState<Video | null>(null);\n const cb = useCallback(\n (src: string) => {\n \"worklet\";\n const vid = Skia.Video(src) as Video;\n runOnJS(setVideo)(vid);\n },\n [runOnJS]\n );\n useEffect(() => {\n if (source) {\n Rea.runOnRuntime(runtime, cb)(source);\n }\n }, [cb, source]);\n return video;\n};\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAGxD,SAASC,IAAI,QAAQ,YAAY;AAEjC,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,MAAMC,OAAO,GAAGD,GAAG,CAACE,oBAAoB,CAAC,wBAAwB,CAAC;AAIlE,OAAO,MAAMC,eAAe,GAAIC,MAAmB,IAAK;EACtD,MAAM;IAAEC;EAAQ,CAAC,GAAGL,GAAG;EACvB,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGT,QAAQ,CAAe,IAAI,CAAC;EACtD,MAAMU,EAAE,GAAGZ,WAAW,CACnBa,GAAW,IAAK;IACf,SAAS;;IACT,MAAMC,GAAG,GAAGX,IAAI,CAACY,KAAK,CAACF,GAAG,CAAU;IACpCJ,OAAO,CAACE,QAAQ,CAAC,CAACG,GAAG,CAAC;EACxB,CAAC,EACD,CAACL,OAAO,CACV,CAAC;EACDR,SAAS,CAAC,MAAM;IACd,IAAIO,MAAM,EAAE;MACVJ,GAAG,CAACY,YAAY,CAACX,OAAO,EAAEO,EAAE,CAAC,CAACJ,MAAM,CAAC;IACvC;EACF,CAAC,EAAE,CAACI,EAAE,EAAEJ,MAAM,CAAC,CAAC;EAChB,OAAOE,KAAK;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { DataSourceParam } from "../types";
2
+ export declare const useSVG: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
@@ -0,0 +1,15 @@
1
+ import { Skia } from "../Skia";
2
+ export const useSVG = (source, onError) => {
3
+ if (source === null || source === undefined) {
4
+ throw new Error(`Invalid svg data source. Got: ${source}`);
5
+ }
6
+ if (typeof source !== "object" || source instanceof Uint8Array || typeof source.default !== "string") {
7
+ throw new Error(`Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(source, null, 2)}`);
8
+ }
9
+ const svg = Skia.SVG.MakeFromString(source.default);
10
+ if (svg === null && onError !== undefined) {
11
+ onError(new Error("Failed to create SVG from source."));
12
+ }
13
+ return svg;
14
+ };
15
+ //# sourceMappingURL=SVG.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Skia","useSVG","source","onError","undefined","Error","Uint8Array","default","JSON","stringify","svg","SVG","MakeFromString"],"sources":["SVG.web.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n if (\n typeof source !== \"object\" ||\n source instanceof Uint8Array ||\n typeof source.default !== \"string\"\n ) {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(\n source,\n null,\n 2\n )}`\n );\n }\n const svg = Skia.SVG.MakeFromString(source.default);\n if (svg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n return svg;\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAG9B,OAAO,MAAMC,MAAM,GAAGA,CACpBC,MAAuB,EACvBC,OAA8B,KAC3B;EACH,IAAID,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKE,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAE,iCAAgCH,MAAO,EAAC,CAAC;EAC5D;EACA,IACE,OAAOA,MAAM,KAAK,QAAQ,IAC1BA,MAAM,YAAYI,UAAU,IAC5B,OAAOJ,MAAM,CAACK,OAAO,KAAK,QAAQ,EAClC;IACA,MAAM,IAAIF,KAAK,CACZ,iFAAgFG,IAAI,CAACC,SAAS,CAC7FP,MAAM,EACN,IAAI,EACJ,CACF,CAAE,EACJ,CAAC;EACH;EACA,MAAMQ,GAAG,GAAGV,IAAI,CAACW,GAAG,CAACC,cAAc,CAACV,MAAM,CAACK,OAAO,CAAC;EACnD,IAAIG,GAAG,KAAK,IAAI,IAAIP,OAAO,KAAKC,SAAS,EAAE;IACzCD,OAAO,CAAC,IAAIE,KAAK,CAAC,mCAAmC,CAAC,CAAC;EACzD;EACA,OAAOK,GAAG;AACZ,CAAC"}
@@ -4,5 +4,5 @@ import type { FontStyle } from "./Font";
4
4
  export interface SkFontMgr extends SkJSIInstance<"FontMgr"> {
5
5
  countFamilies(): number;
6
6
  getFamilyName(index: number): string;
7
- matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;
7
+ matchFamilyStyle(name: string, style: FontStyle): SkTypeface;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["FontMgr.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkTypeface } from \"../Typeface\";\n\nimport type { FontStyle } from \"./Font\";\n\nexport interface SkFontMgr extends SkJSIInstance<\"FontMgr\"> {\n countFamilies(): number;\n getFamilyName(index: number): string;\n matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["FontMgr.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkTypeface } from \"../Typeface\";\n\nimport type { FontStyle } from \"./Font\";\n\nexport interface SkFontMgr extends SkJSIInstance<\"FontMgr\"> {\n countFamilies(): number;\n getFamilyName(index: number): string;\n matchFamilyStyle(name: string, style: FontStyle): SkTypeface;\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  export class CanvasKitWebGLBuffer {}
2
2
  export const isNativeBufferAddr = buffer => buffer instanceof BigInt;
3
- export const isNativeBufferWeb = buffer => buffer instanceof HTMLVideoElement || buffer instanceof HTMLCanvasElement || buffer instanceof ImageBitmap || buffer instanceof OffscreenCanvas || buffer instanceof VideoFrame || buffer instanceof HTMLImageElement || buffer instanceof SVGImageElement || buffer instanceof CanvasKitWebGLBuffer;
3
+ export const isNativeBufferWeb = buffer => buffer instanceof HTMLVideoElement || buffer instanceof HTMLCanvasElement || buffer instanceof ImageBitmap || buffer instanceof OffscreenCanvas || typeof VideoFrame !== "undefined" && buffer instanceof VideoFrame || buffer instanceof HTMLImageElement || buffer instanceof SVGImageElement || buffer instanceof CanvasKitWebGLBuffer;
4
4
  export const isNativeBufferNode = buffer => buffer instanceof ArrayBuffer;
5
5
  //# sourceMappingURL=NativeBufferFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CanvasKitWebGLBuffer","isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport abstract class CanvasKitWebGLBuffer {}\n\nexport type NativeBuffer<\n T extends\n | bigint\n | ArrayBuffer\n | CanvasImageSource\n | CanvasKitWebGLBuffer\n | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement ||\n buffer instanceof CanvasKitWebGLBuffer;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":"AAEA,OAAO,MAAeA,oBAAoB,CAAC;AAe3C,OAAO,MAAMC,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AACzD,OAAO,MAAMC,iBAAiB,GAC5BF,MAAoB,IAEpBA,MAAM,YAAYG,gBAAgB,IAClCH,MAAM,YAAYI,iBAAiB,IACnCJ,MAAM,YAAYK,WAAW,IAC7BL,MAAM,YAAYM,eAAe,IACjCN,MAAM,YAAYO,UAAU,IAC5BP,MAAM,YAAYQ,gBAAgB,IAClCR,MAAM,YAAYS,eAAe,IACjCT,MAAM,YAAYF,oBAAoB;AAExC,OAAO,MAAMY,kBAAkB,GAC7BV,MAAoB,IACWA,MAAM,YAAYW,WAAW"}
1
+ {"version":3,"names":["CanvasKitWebGLBuffer","isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport abstract class CanvasKitWebGLBuffer {}\n\nexport type NativeBuffer<\n T extends\n | bigint\n | ArrayBuffer\n | CanvasImageSource\n | CanvasKitWebGLBuffer\n | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n (typeof VideoFrame !== \"undefined\" && buffer instanceof VideoFrame) ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement ||\n buffer instanceof CanvasKitWebGLBuffer;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":"AAEA,OAAO,MAAeA,oBAAoB,CAAC;AAe3C,OAAO,MAAMC,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AACzD,OAAO,MAAMC,iBAAiB,GAC5BF,MAAoB,IAEpBA,MAAM,YAAYG,gBAAgB,IAClCH,MAAM,YAAYI,iBAAiB,IACnCJ,MAAM,YAAYK,WAAW,IAC7BL,MAAM,YAAYM,eAAe,IAChC,OAAOC,UAAU,KAAK,WAAW,IAAIP,MAAM,YAAYO,UAAW,IACnEP,MAAM,YAAYQ,gBAAgB,IAClCR,MAAM,YAAYS,eAAe,IACjCT,MAAM,YAAYF,oBAAoB;AAExC,OAAO,MAAMY,kBAAkB,GAC7BV,MAAoB,IACWA,MAAM,YAAYW,WAAW"}
@@ -27,7 +27,7 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
27
27
  drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont): void;
28
28
  drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;
29
29
  drawGlyphs(glyphs: number[], positions: SkPoint[], x: number, y: number, font: SkFont, paint: SkPaint): void;
30
- drawSvg(_svgDom: SkSVG, _width?: number, _height?: number): void;
30
+ drawSvg(svg: SkSVG, _width?: number, _height?: number): void;
31
31
  save(): number;
32
32
  saveLayer(paint?: SkPaint, bounds?: SkRect | null, backdrop?: SkImageFilter | null, flags?: SaveLayerFlag): number;
33
33
  restore(): void;
@@ -97,8 +97,9 @@ export class JsiSkCanvas extends HostObject {
97
97
  drawGlyphs(glyphs, positions, x, y, font, paint) {
98
98
  this.ref.drawGlyphs(glyphs, positions.map(p => [p.x, p.y]).flat(), x, y, JsiSkFont.fromValue(font), JsiSkPaint.fromValue(paint));
99
99
  }
100
- drawSvg(_svgDom, _width, _height) {
101
- throw new Error("drawSvg is not implemented on React Native Web");
100
+ drawSvg(svg, _width, _height) {
101
+ const image = this.CanvasKit.MakeImageFromCanvasImageSource(svg.ref);
102
+ this.ref.drawImage(image, 0, 0);
102
103
  }
103
104
  save() {
104
105
  return this.ref.save();
@@ -1 +1 @@
1
- {"version":3,"names":["getEnum","HostObject","JsiSkPaint","JsiSkRect","JsiSkRRect","JsiSkImage","JsiSkVertices","JsiSkPath","JsiSkFont","JsiSkTextBlob","JsiSkPicture","JsiSkMatrix","JsiSkImageFilter","JsiSkPoint","JsiSkRSXform","JsiSkCanvas","constructor","CanvasKit","ref","_defineProperty","delete","drawRect","rect","paint","fromValue","drawImage","image","x","y","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","FilterMode","MipmapMode","drawImageNine","center","filter","Array","from","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","BlendMode","drawPatch","cubics","colors","texs","map","flat","flatMap","p","undefined","restoreToCount","saveCount","drawPoints","points","PointMode","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","drawDRRect","outer","inner","drawOval","drawPath","path","drawText","str","font","drawTextBlob","blob","drawGlyphs","glyphs","positions","drawSvg","_svgDom","_width","_height","Error","save","saveLayer","bounds","backdrop","flags","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","clear","clipPath","op","doAntiAlias","PathOp","clipRect","clipRRect","concat","m","isArray","drawPicture","skp","drawAtlas","atlas","srcs","dsts","_sampling","s","dst","cls","Uint32Array","length","i","r","g","b","a","ColorAsInt","DstOver","readPixels","srcX","srcY","imageInfo","pxInfo","width","height","colorSpace","ColorSpace","SRGB","alphaType","AlphaType","colorType","ColorType"],"sources":["JsiSkCanvas.ts"],"sourcesContent":["import type { Canvas, CanvasKit } from \"canvaskit-wasm\";\n\nimport {\n type BlendMode,\n type ClipOp,\n type FilterMode,\n type MipmapMode,\n type PointMode,\n type SaveLayerFlag,\n type ImageInfo,\n type SkCanvas,\n type SkColor,\n type SkFont,\n type SkImage,\n type SkImageFilter,\n type SkMatrix,\n type SkPaint,\n type SkPath,\n type SkPicture,\n type SkPoint,\n type SkRect,\n type InputRRect,\n type SkSVG,\n type SkTextBlob,\n type SkVertices,\n type SkRSXform,\n type CubicResampler,\n type FilterOptions,\n} from \"../types\";\n\nimport { getEnum, HostObject } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\nimport { JsiSkPicture } from \"./JsiSkPicture\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(\n JsiSkImage.fromValue(image),\n x,\n y,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n JsiSkPaint.fromValue(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n JsiSkImage.fromValue(img),\n left,\n top,\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n JsiSkImage.fromValue(img),\n left,\n top,\n getEnum(this.CanvasKit.FilterMode, fm),\n getEnum(this.CanvasKit.MipmapMode, mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n JsiSkImage.fromValue(img),\n Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit.FilterMode, filter),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit.FilterMode, fm),\n getEnum(this.CanvasKit.MipmapMode, mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(JsiSkPaint.fromValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(\n JsiSkVertices.fromValue(verts),\n getEnum(this.CanvasKit.BlendMode, mode),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,\n mode ? getEnum(this.CanvasKit.BlendMode, mode) : null,\n paint ? JsiSkPaint.fromValue(paint) : undefined\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n getEnum(this.CanvasKit.PointMode, mode),\n points.map(({ x, y }) => [x, y]).flat(),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngle,\n sweepAngle,\n useCenter,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawRRect(rrect: InputRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint) {\n this.ref.drawDRRect(\n JsiSkRRect.fromValue(this.CanvasKit, outer),\n JsiSkRRect.fromValue(this.CanvasKit, inner),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(\n str,\n x,\n y,\n JsiSkPaint.fromValue(paint),\n JsiSkFont.fromValue(font)\n );\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(\n JsiSkTextBlob.fromValue(blob),\n x,\n y,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n JsiSkFont.fromValue(font),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawSvg(_svgDom: SkSVG, _width?: number, _height?: number) {\n throw new Error(\"drawSvg is not implemented on React Native Web\");\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n paint ? JsiSkPaint.fromValue(paint) : undefined,\n bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,\n backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(\n color,\n blendMode ? getEnum(this.CanvasKit.BlendMode, blendMode) : undefined\n );\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(\n JsiSkPath.fromValue(path),\n getEnum(this.CanvasKit.PathOp, op),\n doAntiAlias\n );\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n getEnum(this.CanvasKit.PathOp, op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n getEnum(this.CanvasKit.PathOp, op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix | number[]) {\n this.ref.concat(Array.isArray(m) ? m : JsiSkMatrix.fromValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(JsiSkPicture.fromValue(skp));\n }\n\n drawAtlas(\n atlas: SkImage,\n srcs: SkRect[],\n dsts: SkRSXform[],\n paint: SkPaint,\n blendMode?: BlendMode,\n colors?: SkColor[],\n _sampling?: CubicResampler | FilterOptions\n ) {\n const src = srcs.flatMap((s) =>\n Array.from(JsiSkRect.fromValue(this.CanvasKit, s))\n );\n const dst = dsts.flatMap((s) => Array.from(JsiSkRSXform.fromValue(s)));\n let cls: Uint32Array | undefined;\n if (colors) {\n cls = new Uint32Array(colors.length);\n for (let i = 0; i < colors.length; i++) {\n const [r, g, b, a] = colors[i];\n cls[i] = this.CanvasKit.ColorAsInt(r * 255, g * 255, b * 255, a * 255);\n }\n }\n this.ref.drawAtlas(\n JsiSkImage.fromValue(atlas),\n src,\n dst,\n JsiSkPaint.fromValue(paint),\n blendMode\n ? getEnum(this.CanvasKit.BlendMode, blendMode)\n : this.CanvasKit.BlendMode.DstOver,\n cls\n );\n }\n\n readPixels(srcX: number, srcY: number, imageInfo: ImageInfo) {\n const pxInfo = {\n width: imageInfo.width,\n height: imageInfo.height,\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n alphaType: getEnum(this.CanvasKit.AlphaType, imageInfo.alphaType),\n colorType: getEnum(this.CanvasKit.ColorType, imageInfo.colorType),\n };\n return this.ref.readPixels(srcX, srcY, pxInfo);\n }\n}\n"],"mappings":";;;AA8BA,SAASA,OAAO,EAAEC,UAAU,QAAQ,QAAQ;AAC5C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,OAAO,MAAMC,WAAW,SACdd,UAAU,CAEpB;EACEe,WAAWA,CAACC,SAAoB,EAAEC,GAAW,EAAE;IAC7C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,QAAQ,CAAC;IAACC,eAAA,kBAGxB,MAAM;MACd,IAAI,CAACD,GAAG,CAACE,MAAM,CAAC,CAAC;IACnB,CAAC;EAJD;EAMA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AAEC,IAAY,EAAEC,SAAoB,EAAE;IAC3D,MAAMC,MAAM,GAAG;MACbC,KAAK,EAAEF,SAAS,CAACE,KAAK;MACtBC,MAAM,EAAEH,SAAS,CAACG,MAAM;MACxBC,UAAU,EAAE,IAAI,CAAChJ,SAAS,CAACiJ,UAAU,CAACC,IAAI;MAC1CC,SAAS,EAAEpK,OAAO,CAAC,IAAI,CAACiB,SAAS,CAACoJ,SAAS,EAAER,SAAS,CAACO,SAAS,CAAC;MACjEE,SAAS,EAAEtK,OAAO,CAAC,IAAI,CAACiB,SAAS,CAACsJ,SAAS,EAAEV,SAAS,CAACS,SAAS;IAClE,CAAC;IACD,OAAO,IAAI,CAACpJ,GAAG,CAACwI,UAAU,CAACC,IAAI,EAAEC,IAAI,EAAEE,MAAM,CAAC;EAChD;AACF"}
1
+ {"version":3,"names":["getEnum","HostObject","JsiSkPaint","JsiSkRect","JsiSkRRect","JsiSkImage","JsiSkVertices","JsiSkPath","JsiSkFont","JsiSkTextBlob","JsiSkPicture","JsiSkMatrix","JsiSkImageFilter","JsiSkPoint","JsiSkRSXform","JsiSkCanvas","constructor","CanvasKit","ref","_defineProperty","delete","drawRect","rect","paint","fromValue","drawImage","image","x","y","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","FilterMode","MipmapMode","drawImageNine","center","filter","Array","from","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","BlendMode","drawPatch","cubics","colors","texs","map","flat","flatMap","p","undefined","restoreToCount","saveCount","drawPoints","points","PointMode","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","drawDRRect","outer","inner","drawOval","drawPath","path","drawText","str","font","drawTextBlob","blob","drawGlyphs","glyphs","positions","drawSvg","svg","_width","_height","MakeImageFromCanvasImageSource","save","saveLayer","bounds","backdrop","flags","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","clear","clipPath","op","doAntiAlias","PathOp","clipRect","clipRRect","concat","m","isArray","drawPicture","skp","drawAtlas","atlas","srcs","dsts","_sampling","s","dst","cls","Uint32Array","length","i","r","g","b","a","ColorAsInt","DstOver","readPixels","srcX","srcY","imageInfo","pxInfo","width","height","colorSpace","ColorSpace","SRGB","alphaType","AlphaType","colorType","ColorType"],"sources":["JsiSkCanvas.ts"],"sourcesContent":["import type { Canvas, CanvasKit } from \"canvaskit-wasm\";\n\nimport {\n type BlendMode,\n type ClipOp,\n type FilterMode,\n type MipmapMode,\n type PointMode,\n type SaveLayerFlag,\n type ImageInfo,\n type SkCanvas,\n type SkColor,\n type SkFont,\n type SkImage,\n type SkImageFilter,\n type SkMatrix,\n type SkPaint,\n type SkPath,\n type SkPicture,\n type SkPoint,\n type SkRect,\n type InputRRect,\n type SkSVG,\n type SkTextBlob,\n type SkVertices,\n type SkRSXform,\n type CubicResampler,\n type FilterOptions,\n} from \"../types\";\n\nimport { getEnum, HostObject } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\nimport { JsiSkPicture } from \"./JsiSkPicture\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport type { JsiSkSVG } from \"./JsiSkSVG\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(\n JsiSkImage.fromValue(image),\n x,\n y,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n JsiSkPaint.fromValue(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n JsiSkImage.fromValue(img),\n left,\n top,\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n JsiSkImage.fromValue(img),\n left,\n top,\n getEnum(this.CanvasKit.FilterMode, fm),\n getEnum(this.CanvasKit.MipmapMode, mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n JsiSkImage.fromValue(img),\n Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit.FilterMode, filter),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit.FilterMode, fm),\n getEnum(this.CanvasKit.MipmapMode, mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(JsiSkPaint.fromValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(\n JsiSkVertices.fromValue(verts),\n getEnum(this.CanvasKit.BlendMode, mode),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,\n mode ? getEnum(this.CanvasKit.BlendMode, mode) : null,\n paint ? JsiSkPaint.fromValue(paint) : undefined\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n getEnum(this.CanvasKit.PointMode, mode),\n points.map(({ x, y }) => [x, y]).flat(),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngle,\n sweepAngle,\n useCenter,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawRRect(rrect: InputRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint) {\n this.ref.drawDRRect(\n JsiSkRRect.fromValue(this.CanvasKit, outer),\n JsiSkRRect.fromValue(this.CanvasKit, inner),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(\n str,\n x,\n y,\n JsiSkPaint.fromValue(paint),\n JsiSkFont.fromValue(font)\n );\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(\n JsiSkTextBlob.fromValue(blob),\n x,\n y,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n JsiSkFont.fromValue(font),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawSvg(svg: SkSVG, _width?: number, _height?: number) {\n const image = this.CanvasKit.MakeImageFromCanvasImageSource(\n (svg as JsiSkSVG).ref\n );\n this.ref.drawImage(image, 0, 0);\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n paint ? JsiSkPaint.fromValue(paint) : undefined,\n bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,\n backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(\n color,\n blendMode ? getEnum(this.CanvasKit.BlendMode, blendMode) : undefined\n );\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(\n JsiSkPath.fromValue(path),\n getEnum(this.CanvasKit.PathOp, op),\n doAntiAlias\n );\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n getEnum(this.CanvasKit.PathOp, op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n getEnum(this.CanvasKit.PathOp, op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix | number[]) {\n this.ref.concat(Array.isArray(m) ? m : JsiSkMatrix.fromValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(JsiSkPicture.fromValue(skp));\n }\n\n drawAtlas(\n atlas: SkImage,\n srcs: SkRect[],\n dsts: SkRSXform[],\n paint: SkPaint,\n blendMode?: BlendMode,\n colors?: SkColor[],\n _sampling?: CubicResampler | FilterOptions\n ) {\n const src = srcs.flatMap((s) =>\n Array.from(JsiSkRect.fromValue(this.CanvasKit, s))\n );\n const dst = dsts.flatMap((s) => Array.from(JsiSkRSXform.fromValue(s)));\n let cls: Uint32Array | undefined;\n if (colors) {\n cls = new Uint32Array(colors.length);\n for (let i = 0; i < colors.length; i++) {\n const [r, g, b, a] = colors[i];\n cls[i] = this.CanvasKit.ColorAsInt(r * 255, g * 255, b * 255, a * 255);\n }\n }\n this.ref.drawAtlas(\n JsiSkImage.fromValue(atlas),\n src,\n dst,\n JsiSkPaint.fromValue(paint),\n blendMode\n ? getEnum(this.CanvasKit.BlendMode, blendMode)\n : this.CanvasKit.BlendMode.DstOver,\n cls\n );\n }\n\n readPixels(srcX: number, srcY: number, imageInfo: ImageInfo) {\n const pxInfo = {\n width: imageInfo.width,\n height: imageInfo.height,\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n alphaType: getEnum(this.CanvasKit.AlphaType, imageInfo.alphaType),\n colorType: getEnum(this.CanvasKit.ColorType, imageInfo.colorType),\n };\n return this.ref.readPixels(srcX, srcY, pxInfo);\n }\n}\n"],"mappings":";;;AA8BA,SAASA,OAAO,EAAEC,UAAU,QAAQ,QAAQ;AAC5C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,YAAY,QA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AAC,CAAC,GAAG,IAAI,CAAClI,SAAS,CAACuI,UAAU,CAACJ,CAAC,GAAG,GAAG,EAAEC,CAAC,GAAG,GAAG,EAAEC,CAAC,GAAG,GAAG,EAAEC,CAAC,GAAG,GAAG,CAAC;MACxE;IACF;IACA,IAAI,CAACrI,GAAG,CAACuH,SAAS,CAChBpI,UAAU,CAACmB,SAAS,CAACkH,KAAK,CAAC,EAC3B3G,GAAG,EACHgH,GAAG,EACH7I,UAAU,CAACsB,SAAS,CAACD,KAAK,CAAC,EAC3BqG,SAAS,GACL5H,OAAO,CAAC,IAAI,CAACiB,SAAS,CAAC+C,SAAS,EAAE4D,SAAS,CAAC,GAC5C,IAAI,CAAC3G,SAAS,CAAC+C,SAAS,CAACyF,OAAO,EACpCT,GACF,CAAC;EACH;EAEAU,UAAUA,CAACC,IAAY,EAAEC,IAAY,EAAEC,SAAoB,EAAE;IAC3D,MAAMC,MAAM,GAAG;MACbC,KAAK,EAAEF,SAAS,CAACE,KAAK;MACtBC,MAAM,EAAEH,SAAS,CAACG,MAAM;MACxBC,UAAU,EAAE,IAAI,CAAChJ,SAAS,CAACiJ,UAAU,CAACC,IAAI;MAC1CC,SAAS,EAAEpK,OAAO,CAAC,IAAI,CAACiB,SAAS,CAACoJ,SAAS,EAAER,SAAS,CAACO,SAAS,CAAC;MACjEE,SAAS,EAAEtK,OAAO,CAAC,IAAI,CAACiB,SAAS,CAACsJ,SAAS,EAAEV,SAAS,CAACS,SAAS;IAClE,CAAC;IACD,OAAO,IAAI,CAACpJ,GAAG,CAACwI,UAAU,CAACC,IAAI,EAAEC,IAAI,EAAEE,MAAM,CAAC;EAChD;AACF"}
@@ -0,0 +1,9 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+ import type { SkSVG } from "../types";
3
+ import { HostObject } from "./Host";
4
+ export declare class JsiSkSVG extends HostObject<HTMLImageElement, "SVG"> implements SkSVG {
5
+ constructor(CanvasKit: CanvasKit, ref: HTMLImageElement);
6
+ width(): number;
7
+ height(): number;
8
+ dispose: () => void;
9
+ }
@@ -0,0 +1,21 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
+ import { HostObject } from "./Host";
5
+ export class JsiSkSVG extends HostObject {
6
+ constructor(CanvasKit, ref) {
7
+ super(CanvasKit, ref, "SVG");
8
+ _defineProperty(this, "dispose", () => {
9
+ if (this.ref.parentNode) {
10
+ this.ref.parentNode.removeChild(this.ref);
11
+ }
12
+ });
13
+ }
14
+ width() {
15
+ return this.ref.width;
16
+ }
17
+ height() {
18
+ return this.ref.height;
19
+ }
20
+ }
21
+ //# sourceMappingURL=JsiSkSVG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HostObject","JsiSkSVG","constructor","CanvasKit","ref","_defineProperty","parentNode","removeChild","width","height"],"sources":["JsiSkSVG.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkSVG } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkSVG\n extends HostObject<HTMLImageElement, \"SVG\">\n implements SkSVG\n{\n constructor(CanvasKit: CanvasKit, ref: HTMLImageElement) {\n super(CanvasKit, ref, \"SVG\");\n }\n\n width(): number {\n return this.ref.width;\n }\n height(): number {\n return this.ref.height;\n }\n\n dispose = () => {\n if (this.ref.parentNode) {\n this.ref.parentNode.removeChild(this.ref);\n }\n };\n}\n"],"mappings":";;;AAIA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,OAAO,MAAMC,QAAQ,SACXD,UAAU,CAEpB;EACEE,WAAWA,CAACC,SAAoB,EAAEC,GAAqB,EAAE;IACvD,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,KAAK,CAAC;IAACC,eAAA,kBAUrB,MAAM;MACd,IAAI,IAAI,CAACD,GAAG,CAACE,UAAU,EAAE;QACvB,IAAI,CAACF,GAAG,CAACE,UAAU,CAACC,WAAW,CAAC,IAAI,CAACH,GAAG,CAAC;MAC3C;IACF,CAAC;EAbD;EAEAI,KAAKA,CAAA,EAAW;IACd,OAAO,IAAI,CAACJ,GAAG,CAACI,KAAK;EACvB;EACAC,MAAMA,CAAA,EAAW;IACf,OAAO,IAAI,CAACL,GAAG,CAACK,MAAM;EACxB;AAOF"}
@@ -1,9 +1,10 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
- import type { SkData, SkSVG } from "../types";
2
+ import type { SkSVG } from "../types";
3
3
  import type { SVGFactory } from "../types/SVG/SVGFactory";
4
4
  import { Host } from "./Host";
5
+ import type { JsiSkData } from "./JsiSkData";
5
6
  export declare class JsiSkSVGFactory extends Host implements SVGFactory {
6
7
  constructor(CanvasKit: CanvasKit);
7
- MakeFromData(_data: SkData): SkSVG | null;
8
- MakeFromString(_str: string): SkSVG | null;
8
+ MakeFromData(data: JsiSkData): SkSVG | null;
9
+ MakeFromString(str: string): SkSVG | null;
9
10
  }
@@ -1,13 +1,49 @@
1
- import { Host, NotImplementedOnRNWeb } from "./Host";
1
+ import { Host } from "./Host";
2
+ import { JsiSkSVG } from "./JsiSkSVG";
2
3
  export class JsiSkSVGFactory extends Host {
3
4
  constructor(CanvasKit) {
4
5
  super(CanvasKit);
5
6
  }
6
- MakeFromData(_data) {
7
- throw new NotImplementedOnRNWeb();
7
+ MakeFromData(data) {
8
+ const decoder = new TextDecoder("utf-8");
9
+ const str = decoder.decode(data.ref);
10
+ return this.MakeFromString(str);
8
11
  }
9
- MakeFromString(_str) {
10
- throw new NotImplementedOnRNWeb();
12
+ MakeFromString(str) {
13
+ const parser = new DOMParser();
14
+ const svgDoc = parser.parseFromString(str, "image/svg+xml");
15
+ const svgElement = svgDoc.documentElement;
16
+ const attrWidth = svgElement.getAttribute("width");
17
+ const attrHeight = svgElement.getAttribute("height");
18
+ let width = attrWidth ? parseFloat(attrWidth) : null;
19
+ let height = attrHeight ? parseFloat(attrHeight) : null;
20
+ const svgDataUrl = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(str);
21
+ // Create a new HTMLImageElement
22
+ const img = new Image();
23
+ img.src = svgDataUrl;
24
+
25
+ // Optionally set styles or attributes on the image
26
+ img.style.display = "none";
27
+ img.alt = "SVG Image";
28
+ if (!width || !height) {
29
+ const viewBox = svgElement.getAttribute("viewBox");
30
+ if (viewBox) {
31
+ const viewBoxValues = viewBox.split(" ");
32
+ if (viewBoxValues.length === 4) {
33
+ width = width || parseFloat(viewBoxValues[2]);
34
+ height = height || parseFloat(viewBoxValues[3]);
35
+ }
36
+ }
37
+ }
38
+ if (width && height) {
39
+ img.width = width;
40
+ img.height = height;
41
+ }
42
+ img.onerror = e => {
43
+ console.error("SVG failed to load", e);
44
+ };
45
+ document.body.appendChild(img);
46
+ return new JsiSkSVG(this.CanvasKit, img);
11
47
  }
12
48
  }
13
49
  //# sourceMappingURL=JsiSkSVGFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Host","NotImplementedOnRNWeb","JsiSkSVGFactory","constructor","CanvasKit","MakeFromData","_data","MakeFromString","_str"],"sources":["JsiSkSVGFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData, SkSVG } from \"../types\";\nimport type { SVGFactory } from \"../types/SVG/SVGFactory\";\n\nimport { Host, NotImplementedOnRNWeb } from \"./Host\";\n\nexport class JsiSkSVGFactory extends Host implements SVGFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeFromData(_data: SkData): SkSVG | null {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeFromString(_str: string): SkSVG | null {\n throw new NotImplementedOnRNWeb();\n }\n}\n"],"mappings":"AAKA,SAASA,IAAI,EAAEC,qBAAqB,QAAQ,QAAQ;AAEpD,OAAO,MAAMC,eAAe,SAASF,IAAI,CAAuB;EAC9DG,WAAWA,CAACC,SAAoB,EAAE;IAChC,KAAK,CAACA,SAAS,CAAC;EAClB;EAEAC,YAAYA,CAACC,KAAa,EAAgB;IACxC,MAAM,IAAIL,qBAAqB,CAAC,CAAC;EACnC;EAEAM,cAAcA,CAACC,IAAY,EAAgB;IACzC,MAAM,IAAIP,qBAAqB,CAAC,CAAC;EACnC;AACF"}
1
+ {"version":3,"names":["Host","JsiSkSVG","JsiSkSVGFactory","constructor","CanvasKit","MakeFromData","data","decoder","TextDecoder","str","decode","ref","MakeFromString","parser","DOMParser","svgDoc","parseFromString","svgElement","documentElement","attrWidth","getAttribute","attrHeight","width","parseFloat","height","svgDataUrl","encodeURIComponent","img","Image","src","style","display","alt","viewBox","viewBoxValues","split","length","onerror","e","console","error","document","body","appendChild"],"sources":["JsiSkSVGFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkSVG } from \"../types\";\nimport type { SVGFactory } from \"../types/SVG/SVGFactory\";\n\nimport { Host } from \"./Host\";\nimport type { JsiSkData } from \"./JsiSkData\";\nimport { JsiSkSVG } from \"./JsiSkSVG\";\n\nexport class JsiSkSVGFactory extends Host implements SVGFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeFromData(data: JsiSkData): SkSVG | null {\n const decoder = new TextDecoder(\"utf-8\");\n const str = decoder.decode(data.ref);\n return this.MakeFromString(str);\n }\n\n MakeFromString(str: string): SkSVG | null {\n const parser = new DOMParser();\n const svgDoc = parser.parseFromString(str, \"image/svg+xml\");\n const svgElement = svgDoc.documentElement;\n\n const attrWidth = svgElement.getAttribute(\"width\");\n const attrHeight = svgElement.getAttribute(\"height\");\n let width = attrWidth ? parseFloat(attrWidth) : null;\n let height = attrHeight ? parseFloat(attrHeight) : null;\n\n const svgDataUrl =\n \"data:image/svg+xml;charset=utf-8,\" + encodeURIComponent(str);\n // Create a new HTMLImageElement\n const img = new Image();\n img.src = svgDataUrl;\n\n // Optionally set styles or attributes on the image\n img.style.display = \"none\";\n img.alt = \"SVG Image\";\n if (!width || !height) {\n const viewBox = svgElement.getAttribute(\"viewBox\");\n if (viewBox) {\n const viewBoxValues = viewBox.split(\" \");\n if (viewBoxValues.length === 4) {\n width = width || parseFloat(viewBoxValues[2]);\n height = height || parseFloat(viewBoxValues[3]);\n }\n }\n }\n if (width && height) {\n img.width = width;\n img.height = height;\n }\n\n img.onerror = (e) => {\n console.error(\"SVG failed to load\", e);\n };\n document.body.appendChild(img);\n return new JsiSkSVG(this.CanvasKit, img);\n }\n}\n"],"mappings":"AAKA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,QAAQ,QAAQ,YAAY;AAErC,OAAO,MAAMC,eAAe,SAASF,IAAI,CAAuB;EAC9DG,WAAWA,CAACC,SAAoB,EAAE;IAChC,KAAK,CAACA,SAAS,CAAC;EAClB;EAEAC,YAAYA,CAACC,IAAe,EAAgB;IAC1C,MAAMC,OAAO,GAAG,IAAIC,WAAW,CAAC,OAAO,CAAC;IACxC,MAAMC,GAAG,GAAGF,OAAO,CAACG,MAAM,CAACJ,IAAI,CAACK,GAAG,CAAC;IACpC,OAAO,IAAI,CAACC,cAAc,CAACH,GAAG,CAAC;EACjC;EAEAG,cAAcA,CAACH,GAAW,EAAgB;IACxC,MAAMI,MAAM,GAAG,IAAIC,SAAS,CAAC,CAAC;IAC9B,MAAMC,MAAM,GAAGF,MAAM,CAACG,eAAe,CAACP,GAAG,EAAE,eAAe,CAAC;IAC3D,MAAMQ,UAAU,GAAGF,MAAM,CAACG,eAAe;IAEzC,MAAMC,SAAS,GAAGF,UAAU,CAACG,YAAY,CAAC,OAAO,CAAC;IAClD,MAAMC,UAAU,GAAGJ,UAAU,CAACG,YAAY,C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