@shopify/react-native-skia 1.8.2 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/android/cpp/rnskia-android/MainThreadDispatcher.h +1 -1
  2. package/android/cpp/rnskia-android/OpenGLContext.h +4 -4
  3. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +3 -3
  4. package/cpp/api/JsiSkCanvas.h +27 -25
  5. package/cpp/api/JsiSkImage.h +24 -0
  6. package/cpp/api/JsiSkPaint.h +1 -1
  7. package/cpp/rnskia/dom/nodes/JsiAtlasNode.h +5 -1
  8. package/cpp/rnskia/dom/nodes/JsiImageNode.h +8 -4
  9. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +9 -38
  10. package/cpp/rnskia/dom/props/SamplingProp.h +54 -0
  11. package/ios/RNSkia-iOS/SkiaManager.mm +2 -4
  12. package/lib/commonjs/dom/types/Drawings.d.ts +3 -1
  13. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  14. package/lib/commonjs/dom/types/Shaders.d.ts +2 -3
  15. package/lib/commonjs/dom/types/Shaders.js.map +1 -1
  16. package/lib/commonjs/renderer/components/image/ImageShader.d.ts +1 -1
  17. package/lib/commonjs/renderer/components/image/ImageShader.js +0 -4
  18. package/lib/commonjs/renderer/components/image/ImageShader.js.map +1 -1
  19. package/lib/commonjs/skia/types/Canvas.d.ts +2 -2
  20. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  21. package/lib/commonjs/skia/types/Image/Image.d.ts +18 -0
  22. package/lib/commonjs/skia/types/Image/Image.js +24 -1
  23. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  24. package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +2 -1
  25. package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
  26. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +2 -2
  27. package/lib/commonjs/skia/web/JsiSkCanvas.js +15 -2
  28. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  29. package/lib/commonjs/sksg/Container.d.ts +17 -14
  30. package/lib/commonjs/sksg/Container.js +59 -62
  31. package/lib/commonjs/sksg/Container.js.map +1 -1
  32. package/lib/commonjs/sksg/HostConfig.js +4 -9
  33. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  34. package/lib/commonjs/sksg/Reconciler.js +1 -2
  35. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  36. package/lib/commonjs/sksg/Recorder/Core.d.ts +42 -37
  37. package/lib/commonjs/sksg/Recorder/Core.js +45 -38
  38. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
  39. package/lib/commonjs/sksg/Recorder/Player.js +4 -0
  40. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  41. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +15 -0
  42. package/lib/commonjs/sksg/Recorder/Recorder.js +23 -1
  43. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  44. package/lib/commonjs/sksg/Recorder/Visitor.js +6 -0
  45. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  46. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +11 -4
  47. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  48. package/lib/commonjs/sksg/Recorder/commands/Shaders.js +8 -3
  49. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  50. package/lib/module/dom/types/Drawings.d.ts +3 -1
  51. package/lib/module/dom/types/Drawings.js.map +1 -1
  52. package/lib/module/dom/types/Shaders.d.ts +2 -3
  53. package/lib/module/dom/types/Shaders.js.map +1 -1
  54. package/lib/module/renderer/components/image/ImageShader.d.ts +1 -1
  55. package/lib/module/renderer/components/image/ImageShader.js +0 -4
  56. package/lib/module/renderer/components/image/ImageShader.js.map +1 -1
  57. package/lib/module/skia/types/Canvas.d.ts +2 -2
  58. package/lib/module/skia/types/Canvas.js.map +1 -1
  59. package/lib/module/skia/types/Image/Image.d.ts +18 -0
  60. package/lib/module/skia/types/Image/Image.js +21 -0
  61. package/lib/module/skia/types/Image/Image.js.map +1 -1
  62. package/lib/module/skia/types/Picture/PictureRecorder.d.ts +2 -1
  63. package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
  64. package/lib/module/skia/web/JsiSkCanvas.d.ts +2 -2
  65. package/lib/module/skia/web/JsiSkCanvas.js +15 -2
  66. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  67. package/lib/module/sksg/Container.d.ts +17 -14
  68. package/lib/module/sksg/Container.js +56 -60
  69. package/lib/module/sksg/Container.js.map +1 -1
  70. package/lib/module/sksg/HostConfig.js +4 -9
  71. package/lib/module/sksg/HostConfig.js.map +1 -1
  72. package/lib/module/sksg/Reconciler.js +2 -3
  73. package/lib/module/sksg/Reconciler.js.map +1 -1
  74. package/lib/module/sksg/Recorder/Core.d.ts +42 -37
  75. package/lib/module/sksg/Recorder/Core.js +43 -37
  76. package/lib/module/sksg/Recorder/Core.js.map +1 -1
  77. package/lib/module/sksg/Recorder/Player.js +5 -1
  78. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  79. package/lib/module/sksg/Recorder/Recorder.d.ts +15 -0
  80. package/lib/module/sksg/Recorder/Recorder.js +23 -1
  81. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  82. package/lib/module/sksg/Recorder/Visitor.js +6 -0
  83. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  84. package/lib/module/sksg/Recorder/commands/Drawing.js +12 -5
  85. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  86. package/lib/module/sksg/Recorder/commands/Shaders.js +9 -4
  87. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  88. package/lib/typescript/lib/commonjs/renderer/components/image/ImageShader.d.ts +1 -3
  89. package/lib/typescript/lib/commonjs/skia/types/Image/Image.d.ts +21 -0
  90. package/lib/typescript/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  91. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +15 -10
  92. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +4 -4
  93. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +21 -2
  94. package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +1 -0
  95. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +7 -0
  96. package/lib/typescript/lib/module/mock/index.d.ts +18 -3
  97. package/lib/typescript/lib/module/renderer/components/image/ImageShader.d.ts +1 -3
  98. package/lib/typescript/lib/module/skia/types/Image/Image.d.ts +21 -0
  99. package/lib/typescript/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  100. package/lib/typescript/lib/module/sksg/Container.d.ts +15 -10
  101. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +4 -4
  102. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +21 -2
  103. package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +1 -0
  104. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +7 -0
  105. package/lib/typescript/src/dom/types/Drawings.d.ts +3 -1
  106. package/lib/typescript/src/dom/types/Shaders.d.ts +2 -3
  107. package/lib/typescript/src/renderer/components/image/ImageShader.d.ts +1 -1
  108. package/lib/typescript/src/skia/types/Canvas.d.ts +2 -2
  109. package/lib/typescript/src/skia/types/Image/Image.d.ts +18 -0
  110. package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +2 -1
  111. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +2 -2
  112. package/lib/typescript/src/sksg/Container.d.ts +17 -14
  113. package/lib/typescript/src/sksg/Recorder/Core.d.ts +42 -37
  114. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +15 -0
  115. package/libs/apple/libskia.xcframework/Info.plist +35 -2
  116. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  117. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  118. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  119. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  120. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  121. package/libs/apple/libskottie.xcframework/Info.plist +36 -3
  122. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  123. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  124. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  125. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  126. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  127. package/libs/apple/libskparagraph.xcframework/Info.plist +40 -7
  128. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  129. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  130. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  131. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  132. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  133. package/libs/apple/libsksg.xcframework/Info.plist +35 -2
  134. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  135. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  136. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  137. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  138. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  139. package/libs/apple/libskshaper.xcframework/Info.plist +33 -0
  140. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  141. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  142. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  143. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  144. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  145. package/libs/apple/libskunicode_core.xcframework/Info.plist +36 -3
  146. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  147. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  148. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  149. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
  150. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  151. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +35 -2
  152. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  153. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  154. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  155. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  156. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  157. package/libs/apple/libsvg.xcframework/Info.plist +36 -3
  158. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  159. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  160. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  161. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  162. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  163. package/package.json +3 -2
  164. package/react-native-skia.podspec +2 -2
  165. package/src/__tests__/snapshots/animated-images/bird.png +0 -0
  166. package/src/__tests__/snapshots/demos/product.png +0 -0
  167. package/src/__tests__/snapshots/demos/product2.png +0 -0
  168. package/src/__tests__/snapshots/images/bundle-android.png +0 -0
  169. package/src/__tests__/snapshots/images/bundle-ios.png +0 -0
  170. package/src/__tests__/snapshots/images/bundle-node.png +0 -0
  171. package/src/__tests__/snapshots/images/filter.png +0 -0
  172. package/src/dom/types/Drawings.ts +3 -0
  173. package/src/dom/types/Shaders.ts +2 -4
  174. package/src/renderer/__tests__/e2e/Text.spec.tsx +1 -1
  175. package/src/renderer/components/image/ImageShader.tsx +2 -15
  176. package/src/skia/types/Canvas.ts +2 -3
  177. package/src/skia/types/Image/Image.ts +14 -0
  178. package/src/skia/types/Picture/PictureRecorder.ts +2 -1
  179. package/src/skia/web/JsiSkCanvas.ts +50 -29
  180. package/src/sksg/Container.ts +64 -68
  181. package/src/sksg/HostConfig.ts +4 -9
  182. package/src/sksg/Reconciler.ts +3 -3
  183. package/src/sksg/Recorder/Core.ts +10 -0
  184. package/src/sksg/Recorder/Player.ts +5 -1
  185. package/src/sksg/Recorder/Recorder.ts +36 -1
  186. package/src/sksg/Recorder/Visitor.ts +6 -0
  187. package/src/sksg/Recorder/commands/Drawing.ts +33 -4
  188. package/src/sksg/Recorder/commands/Shaders.ts +21 -8
  189. package/lib/commonjs/sksg/Recorder/Recording.d.ts +0 -7
  190. package/lib/commonjs/sksg/Recorder/Recording.js +0 -12
  191. package/lib/commonjs/sksg/Recorder/Recording.js.map +0 -1
  192. package/lib/module/sksg/Recorder/Recording.d.ts +0 -7
  193. package/lib/module/sksg/Recorder/Recording.js +0 -5
  194. package/lib/module/sksg/Recorder/Recording.js.map +0 -1
  195. package/lib/typescript/lib/commonjs/sksg/Recorder/Recording.d.ts +0 -5
  196. package/lib/typescript/lib/module/sksg/Recorder/Recording.d.ts +0 -4
  197. package/lib/typescript/src/sksg/Recorder/Recording.d.ts +0 -7
  198. package/src/sksg/Recorder/Recording.ts +0 -13
@@ -36,14 +36,13 @@ export const sksgHostConfig = {
36
36
  // return SpanNode({}, text) as SkNode;
37
37
  throw new Error("Text nodes are not supported yet");
38
38
  },
39
- createInstance(type, propsWithChildren, container, _hostContext, _internalInstanceHandle) {
39
+ createInstance(type, propsWithChildren, _container, _hostContext, _internalInstanceHandle) {
40
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
41
  const {
42
42
  children,
43
43
  ...props
44
44
  } = propsWithChildren;
45
45
  debug("createInstance", type);
46
- container.registerValues(props);
47
46
  const instance = {
48
47
  type,
49
48
  props,
@@ -62,7 +61,7 @@ export const sksgHostConfig = {
62
61
  // if finalizeInitialChildren = true
63
62
  debug("commitMount");
64
63
  },
65
- prepareForCommit(_containerInfo) {
64
+ prepareForCommit(_container) {
66
65
  debug("prepareForCommit");
67
66
  return null;
68
67
  },
@@ -77,9 +76,8 @@ export const sksgHostConfig = {
77
76
  commitTextUpdate: (_textInstance, _oldText, _newText) => {
78
77
  // textInstance.instance = newText;
79
78
  },
80
- clearContainer: container => {
79
+ clearContainer: _container => {
81
80
  debug("clearContainer");
82
- container.clear();
83
81
  },
84
82
  prepareUpdate(_instance, _type, oldProps, newProps, container, _hostContext) {
85
83
  debug("prepareUpdate");
@@ -87,8 +85,6 @@ export const sksgHostConfig = {
87
85
  if (propsAreEqual) {
88
86
  return null;
89
87
  }
90
- container.unregisterValues(oldProps);
91
- container.registerValues(newProps);
92
88
  return container;
93
89
  },
94
90
  preparePortalMount: () => {
@@ -114,7 +110,6 @@ export const sksgHostConfig = {
114
110
  container.root = newChildren;
115
111
  },
116
112
  replaceContainerChildren(container, newChildren) {
117
- debug("replaceContainerChildren");
118
113
  container.root = newChildren;
119
114
  },
120
115
  cloneHiddenInstance(_instance, _type, _props) {
@@ -129,7 +124,7 @@ export const sksgHostConfig = {
129
124
  getCurrentEventPriority: () => DefaultEventPriority,
130
125
  beforeActiveInstanceBlur: () => {},
131
126
  afterActiveInstanceBlur: () => {},
132
- detachDeletedInstance: () => {},
127
+ detachDeletedInstance: _node => {},
133
128
  getInstanceFromNode: function (_node) {
134
129
  throw new Error("Function not implemented.");
135
130
  },
@@ -1 +1 @@
1
- {"version":3,"names":["DefaultEventPriority","shallowEq","DEBUG","debug","args","console","log","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","container","children","props","registerValues","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","resetAfterCommit","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","clear","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","unregisterValues","preparePortalMount","cloneInstance","_updatePayload","_oldProps","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","getInstanceFromNode","_node","prepareScopeUpdate","_scopeInstance","getInstanceFromScope"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n container.registerValues(props);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (container) => {\n debug(\"clearContainer\");\n container.clear();\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n container.unregisterValues(oldProps);\n container.registerValues(newProps);\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _updatePayload,\n _type,\n _oldProps,\n newProps,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n\n return {\n type: instance.type,\n props: newProps,\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"replaceContainerChildren\");\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: () => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n};\n"],"mappings":"AAAA;;AAEA,SAASA,oBAAoB,QAAQ,4BAA4B;AAGjE,SAASC,SAAS,QAAQ,uBAAuB;AAKjD,MAAMC,KAAK,GAAG,KAAK;AACnB,OAAO,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,KAAK,EAAE;IACTG,OAAO,CAACC,GAAG,CAAC,GAAGF,IAAI,CAAC;EACtB;AACF,CAAC;AA+BD,OAAO,MAAMG,cAA8B,GAAG;EAC5C;AACF;AACA;EACEC,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,KAAK;EACxBC,mBAAmB,EAAE,IAAI;EACzBC,iBAAiB,EAAE,KAAK;EACxB;EACAC,eAAe,EAAEC,UAAU;EAC3BC,aAAa,EAAEC,YAAY;EAC3BC,SAAS,EAAE,CAAC,CAAC;EAEbC,kBAAkB,EAAGC,sBAAiC,IAAK;IACzDf,KAAK,CAAC,oBAAoB,CAAC;IAC3B,OAAO,IAAI;EACb,CAAC;EAEDgB,mBAAmBA,CAACC,kBAAkB,EAAEC,KAAK,EAAEH,sBAAsB,EAAE;IACrEf,KAAK,CAAC,qBA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EAC9C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DefaultEventPriority","shallowEq","DEBUG","debug","args","console","log","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","_container","children","props","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","resetAfterCommit","container","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","preparePortalMount","cloneInstance","_updatePayload","_oldProps","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n _container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_container: Container) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (_container) => {\n debug(\"clearContainer\");\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _updatePayload,\n _type,\n _oldProps,\n newProps,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n\n return {\n type: instance.type,\n props: newProps,\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: (_node: Instance) => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (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AAsB,CAAC;EACzC,CAAC;EACD;EACA6C,uBAAuB,EAAEA,CAAA,KAAMzE,oBAAoB;EACnD0E,wBAAwB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClCC,uBAAuB,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjCC,qBAAqB,EAAGC,KAAe,IAAK,CAAC,CAAC;EAC9CC,mBAAmB,EAAE,SAAAA,CAAUD,KAAK,EAA4B;IAC9D,MAAM,IAAIjD,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDmD,kBAAkB,EAAE,SAAAA,CAAUC,cAAc,EAAE1B,SAAS,EAAQ;IAC7D,MAAM,IAAI1B,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDqD,oBAAoB,EAAE,SAAAA,CAAUD,cAAc,EAAmB;IAC/D,MAAM,IAAIpD,KAAK,CAAC,2BAA2B,CAAC;EAC9C;AACF,CAAC","ignoreList":[]}
@@ -4,7 +4,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
4
4
  import ReactReconciler from "react-reconciler";
5
5
  import { NodeType } from "../dom/types";
6
6
  import { debug, sksgHostConfig } from "./HostConfig";
7
- import { Container } from "./Container";
7
+ import { createContainer } from "./Container";
8
8
  const skiaReconciler = ReactReconciler(sksgHostConfig);
9
9
  skiaReconciler.injectIntoDevTools({
10
10
  bundleType: 1,
@@ -16,7 +16,7 @@ export class SkiaSGRoot {
16
16
  this.Skia = Skia;
17
17
  _defineProperty(this, "root", void 0);
18
18
  _defineProperty(this, "container", void 0);
19
- this.container = new Container(Skia, nativeId);
19
+ this.container = createContainer(Skia, nativeId);
20
20
  this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
21
21
  }
22
22
  get sg() {
@@ -44,7 +44,6 @@ export class SkiaSGRoot {
44
44
  return recorder.finishRecordingAsPicture();
45
45
  }
46
46
  unmount() {
47
- this.container.unmounted = true;
48
47
  skiaReconciler.updateContainer(null, this.root, null, () => {
49
48
  debug("unmountContainer");
50
49
  });
@@ -1 +1 @@
1
- {"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","Container","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","createContainer","console","error","sg","children","type","Group","props","isDeclaration","render","element","updateContainer","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount","unmounted"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = new Container(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n debug(\"updateContainer\");\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n this.container.unmounted = true;\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n });\n }\n}\n"],"mapp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,CAAC;EACrC;EAEAC,UAAUA,CAAA,EAAG;IACX,MAAMC,QAAQ,GAAG,IAAI,CAACpB,IAAI,CAACqB,eAAe,CAAC,CAAC;IAC5C,MAAMH,MAAM,GAAGE,QAAQ,CAACE,cAAc,CAAC,CAAC;IACxC,IAAI,CAACL,YAAY,CAACC,MAAM,CAAC;IACzB,OAAOE,QAAQ,CAACG,wBAAwB,CAAC,CAAC;EAC5C;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAACrB,SAAS,CAACsB,SAAS,GAAG,IAAI;IAC/BhC,cAAc,CAACuB,eAAe,CAAC,IAAI,EAAE,IAAI,CAACZ,IAAI,EAAE,IAAI,EAAE,MAAM;MAC1Dd,KAAK,CAAC,kBAAkB,CAAC;IAC3B,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
1
+ {"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","console","error","sg","children","type","Group","props","isDeclaration","render","element","updateContainer","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./Container\";\nimport { createContainer } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = createContainer(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n debug(\"updateContainer\");\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n });\n }\n}\n"],"mappings":";;;AAEA,OAAOA,eAAe,MAAM,kBAAkB;AAG9C,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,EAAEC,cAAc,QAAQ,cAAc;AAEpD,SAASC,eAAe,QAAQ,aAAa;AAE7C,MAAMC,cAAc,GAAGL,eAAe,CAACG,cAAc,CAAC;AAEtDE,cAAc,CAACC,kBAAkB,CAAC;EAChCC,UAAU,EAAE,CAAC;EACbC,OAAO,EAAE,OAAO;EAChBC,mBAAmB,EAAE;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,UAAU,CAAC;EAItBC,WAAWA,CAAQC,IAAU,EAAEC,QAAQ,GAAG,CAAC,CAAC,EAAE;IAAA,KAA3BD,IAAU,GAAVA,IAAU;IAAAE,eAAA;IAAAA,eAAA;IAC3B,IAAI,CAACC,SAAS,GAAGX,eAAe,CAACQ,IAAI,EAAEC,QAAQ,CAAC;IAChD,IAAI,CAACG,IAAI,GAAGX,cAAc,CAACD,eAAe,CACxC,IAAI,CAACW,SAAS,EACd,CAAC,EACD,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,EAAE,EACFE,OAAO,CAACC,KAAK,EACb,IACF,CAAC;EACH;EAEA,IAAIC,EAAEA,CAAA,EAAG;IACP,MAAMC,QAAQ,GAAG,IAAI,CAACL,SAAS,CAACC,IAAI;IACpC,OAAO;MAAEK,IAAI,EAAEpB,QAAQ,CAACqB,KAAK;MAAEC,KAAK,EAAE,CAAC,CAAC;MAAEH,QAAQ;MAAEI,aAAa,EAAE;IAAM,CAAC;EAC5E;EAEAC,MAAMA,CAACC,OAAkB,EAAE;IACzB;IACArB,cAAc,CAACsB,eAAe,CAACD,OAAO,EAAS,IAAI,CAACV,IAAI,EAAE,IAAI,EAAE,MAAM;MACpEd,KAAK,CAAC,iBAAiB,CAAC;IAC1B,CAAC,CAAC;EACJ;EAEA0B,YAAYA,CAACC,MAAgB,EAAE;IAC7B,IAAI,CAACd,SAAS,CAACa,YAAY,CAACC,MAAM,CAAC;EACrC;EAEAC,UAAUA,CAAA,EAAG;IACX,MAAMC,QAAQ,GAAG,IAAI,CAACnB,IAAI,CAACoB,eAAe,CAAC,CAAC;IAC5C,MAAMH,MAAM,GAAGE,QAAQ,CAACE,cAAc,CAAC,CAAC;IACxC,IAAI,CAACL,YAAY,CAACC,MAAM,CAAC;IACzB,OAAOE,QAAQ,CAACG,wBAAwB,CAAC,CAAC;EAC5C;EAEAC,OAAOA,CAAA,EAAG;IACR9B,cAAc,CAACsB,eAAe,CAAC,IAAI,EAAE,IAAI,CAACX,IAAI,EAAE,IAAI,EAAE,MAAM;MAC1Dd,KAAK,CAAC,kBAAkB,CAAC;IAC3B,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -1,43 +1,44 @@
1
1
  import type { SharedValue } from "react-native-reanimated";
2
2
  import type { BlurMaskFilterProps, CircleProps, CTMProps, ImageProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, DrawingNodeProps } from "../../dom/types";
3
3
  export declare enum CommandType {
4
- SavePaint = 0,
5
- RestorePaint = 1,
6
- SaveCTM = 2,
7
- RestoreCTM = 3,
8
- PushColorFilter = 4,
9
- PushBlurMaskFilter = 5,
10
- PushImageFilter = 6,
11
- PushPathEffect = 7,
12
- PushShader = 8,
13
- ComposeColorFilter = 9,
14
- ComposeImageFilter = 10,
15
- ComposePathEffect = 11,
16
- MaterializePaint = 12,
17
- SaveBackdropFilter = 13,
18
- SaveLayer = 14,
19
- RestorePaintDeclaration = 15,
20
- DrawBox = 16,
21
- DrawImage = 17,
22
- DrawCircle = 18,
23
- DrawPaint = 19,
24
- DrawPoints = 20,
25
- DrawPath = 21,
26
- DrawRect = 22,
27
- DrawRRect = 23,
28
- DrawOval = 24,
29
- DrawLine = 25,
30
- DrawPatch = 26,
31
- DrawVertices = 27,
32
- DrawDiffRect = 28,
33
- DrawText = 29,
34
- DrawTextPath = 30,
35
- DrawTextBlob = 31,
36
- DrawGlyphs = 32,
37
- DrawPicture = 33,
38
- DrawImageSVG = 34,
39
- DrawParagraph = 35,
40
- DrawAtlas = 36
4
+ Group = 0,
5
+ SavePaint = 1,
6
+ RestorePaint = 2,
7
+ SaveCTM = 3,
8
+ RestoreCTM = 4,
9
+ PushColorFilter = 5,
10
+ PushBlurMaskFilter = 6,
11
+ PushImageFilter = 7,
12
+ PushPathEffect = 8,
13
+ PushShader = 9,
14
+ ComposeColorFilter = 10,
15
+ ComposeImageFilter = 11,
16
+ ComposePathEffect = 12,
17
+ MaterializePaint = 13,
18
+ SaveBackdropFilter = 14,
19
+ SaveLayer = 15,
20
+ RestorePaintDeclaration = 16,
21
+ DrawBox = 17,
22
+ DrawImage = 18,
23
+ DrawCircle = 19,
24
+ DrawPaint = 20,
25
+ DrawPoints = 21,
26
+ DrawPath = 22,
27
+ DrawRect = 23,
28
+ DrawRRect = 24,
29
+ DrawOval = 25,
30
+ DrawLine = 26,
31
+ DrawPatch = 27,
32
+ DrawVertices = 28,
33
+ DrawDiffRect = 29,
34
+ DrawText = 30,
35
+ DrawTextPath = 31,
36
+ DrawTextBlob = 32,
37
+ DrawGlyphs = 33,
38
+ DrawPicture = 34,
39
+ DrawImageSVG = 35,
40
+ DrawParagraph = 36,
41
+ DrawAtlas = 37
41
42
  }
42
43
  export type Command<T extends CommandType = CommandType> = {
43
44
  type: T;
@@ -48,6 +49,10 @@ export declare const materializeProps: (command: {
48
49
  animatedProps?: Record<string, SharedValue<unknown>>;
49
50
  }) => void;
50
51
  export declare const isCommand: <T extends CommandType>(command: Command, type: T) => command is Command<T>;
52
+ interface GroupCommand extends Command<CommandType.Group> {
53
+ children: Command[];
54
+ }
55
+ export declare const isGroup: (command: Command) => command is GroupCommand;
51
56
  interface Props {
52
57
  [CommandType.DrawImage]: ImageProps;
53
58
  [CommandType.DrawCircle]: CircleProps;
@@ -40,43 +40,44 @@
40
40
  // DrawAtlas = "DrawAtlas",
41
41
  // }
42
42
  export let CommandType = /*#__PURE__*/function (CommandType) {
43
- CommandType[CommandType["SavePaint"] = 0] = "SavePaint";
44
- CommandType[CommandType["RestorePaint"] = 1] = "RestorePaint";
45
- CommandType[CommandType["SaveCTM"] = 2] = "SaveCTM";
46
- CommandType[CommandType["RestoreCTM"] = 3] = "RestoreCTM";
47
- CommandType[CommandType["PushColorFilter"] = 4] = "PushColorFilter";
48
- CommandType[CommandType["PushBlurMaskFilter"] = 5] = "PushBlurMaskFilter";
49
- CommandType[CommandType["PushImageFilter"] = 6] = "PushImageFilter";
50
- CommandType[CommandType["PushPathEffect"] = 7] = "PushPathEffect";
51
- CommandType[CommandType["PushShader"] = 8] = "PushShader";
52
- CommandType[CommandType["ComposeColorFilter"] = 9] = "ComposeColorFilter";
53
- CommandType[CommandType["ComposeImageFilter"] = 10] = "ComposeImageFilter";
54
- CommandType[CommandType["ComposePathEffect"] = 11] = "ComposePathEffect";
55
- CommandType[CommandType["MaterializePaint"] = 12] = "MaterializePaint";
56
- CommandType[CommandType["SaveBackdropFilter"] = 13] = "SaveBackdropFilter";
57
- CommandType[CommandType["SaveLayer"] = 14] = "SaveLayer";
58
- CommandType[CommandType["RestorePaintDeclaration"] = 15] = "RestorePaintDeclaration";
59
- CommandType[CommandType["DrawBox"] = 16] = "DrawBox";
60
- CommandType[CommandType["DrawImage"] = 17] = "DrawImage";
61
- CommandType[CommandType["DrawCircle"] = 18] = "DrawCircle";
62
- CommandType[CommandType["DrawPaint"] = 19] = "DrawPaint";
63
- CommandType[CommandType["DrawPoints"] = 20] = "DrawPoints";
64
- CommandType[CommandType["DrawPath"] = 21] = "DrawPath";
65
- CommandType[CommandType["DrawRect"] = 22] = "DrawRect";
66
- CommandType[CommandType["DrawRRect"] = 23] = "DrawRRect";
67
- CommandType[CommandType["DrawOval"] = 24] = "DrawOval";
68
- CommandType[CommandType["DrawLine"] = 25] = "DrawLine";
69
- CommandType[CommandType["DrawPatch"] = 26] = "DrawPatch";
70
- CommandType[CommandType["DrawVertices"] = 27] = "DrawVertices";
71
- CommandType[CommandType["DrawDiffRect"] = 28] = "DrawDiffRect";
72
- CommandType[CommandType["DrawText"] = 29] = "DrawText";
73
- CommandType[CommandType["DrawTextPath"] = 30] = "DrawTextPath";
74
- CommandType[CommandType["DrawTextBlob"] = 31] = "DrawTextBlob";
75
- CommandType[CommandType["DrawGlyphs"] = 32] = "DrawGlyphs";
76
- CommandType[CommandType["DrawPicture"] = 33] = "DrawPicture";
77
- CommandType[CommandType["DrawImageSVG"] = 34] = "DrawImageSVG";
78
- CommandType[CommandType["DrawParagraph"] = 35] = "DrawParagraph";
79
- CommandType[CommandType["DrawAtlas"] = 36] = "DrawAtlas";
43
+ CommandType[CommandType["Group"] = 0] = "Group";
44
+ CommandType[CommandType["SavePaint"] = 1] = "SavePaint";
45
+ CommandType[CommandType["RestorePaint"] = 2] = "RestorePaint";
46
+ CommandType[CommandType["SaveCTM"] = 3] = "SaveCTM";
47
+ CommandType[CommandType["RestoreCTM"] = 4] = "RestoreCTM";
48
+ CommandType[CommandType["PushColorFilter"] = 5] = "PushColorFilter";
49
+ CommandType[CommandType["PushBlurMaskFilter"] = 6] = "PushBlurMaskFilter";
50
+ CommandType[CommandType["PushImageFilter"] = 7] = "PushImageFilter";
51
+ CommandType[CommandType["PushPathEffect"] = 8] = "PushPathEffect";
52
+ CommandType[CommandType["PushShader"] = 9] = "PushShader";
53
+ CommandType[CommandType["ComposeColorFilter"] = 10] = "ComposeColorFilter";
54
+ CommandType[CommandType["ComposeImageFilter"] = 11] = "ComposeImageFilter";
55
+ CommandType[CommandType["ComposePathEffect"] = 12] = "ComposePathEffect";
56
+ CommandType[CommandType["MaterializePaint"] = 13] = "MaterializePaint";
57
+ CommandType[CommandType["SaveBackdropFilter"] = 14] = "SaveBackdropFilter";
58
+ CommandType[CommandType["SaveLayer"] = 15] = "SaveLayer";
59
+ CommandType[CommandType["RestorePaintDeclaration"] = 16] = "RestorePaintDeclaration";
60
+ CommandType[CommandType["DrawBox"] = 17] = "DrawBox";
61
+ CommandType[CommandType["DrawImage"] = 18] = "DrawImage";
62
+ CommandType[CommandType["DrawCircle"] = 19] = "DrawCircle";
63
+ CommandType[CommandType["DrawPaint"] = 20] = "DrawPaint";
64
+ CommandType[CommandType["DrawPoints"] = 21] = "DrawPoints";
65
+ CommandType[CommandType["DrawPath"] = 22] = "DrawPath";
66
+ CommandType[CommandType["DrawRect"] = 23] = "DrawRect";
67
+ CommandType[CommandType["DrawRRect"] = 24] = "DrawRRect";
68
+ CommandType[CommandType["DrawOval"] = 25] = "DrawOval";
69
+ CommandType[CommandType["DrawLine"] = 26] = "DrawLine";
70
+ CommandType[CommandType["DrawPatch"] = 27] = "DrawPatch";
71
+ CommandType[CommandType["DrawVertices"] = 28] = "DrawVertices";
72
+ CommandType[CommandType["DrawDiffRect"] = 29] = "DrawDiffRect";
73
+ CommandType[CommandType["DrawText"] = 30] = "DrawText";
74
+ CommandType[CommandType["DrawTextPath"] = 31] = "DrawTextPath";
75
+ CommandType[CommandType["DrawTextBlob"] = 32] = "DrawTextBlob";
76
+ CommandType[CommandType["DrawGlyphs"] = 33] = "DrawGlyphs";
77
+ CommandType[CommandType["DrawPicture"] = 34] = "DrawPicture";
78
+ CommandType[CommandType["DrawImageSVG"] = 35] = "DrawImageSVG";
79
+ CommandType[CommandType["DrawParagraph"] = 36] = "DrawParagraph";
80
+ CommandType[CommandType["DrawAtlas"] = 37] = "DrawAtlas";
80
81
  return CommandType;
81
82
  }({});
82
83
  export const materializeProps = command => {
@@ -93,6 +94,11 @@ export const isCommand = (command, type) => {
93
94
 
94
95
  return command.type === type;
95
96
  };
97
+ export const isGroup = command => {
98
+ "worklet";
99
+
100
+ return command.type === CommandType.Group;
101
+ };
96
102
  export const isDrawCommand = (command, type) => {
97
103
  "worklet";
98
104
 
@@ -1 +1 @@
1
- {"version":3,"names":["CommandType","materializeProps","command","animatedProps","key","props","value","isCommand","type","isDrawCommand"],"sources":["Core.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n BlurMaskFilterProps,\n CircleProps,\n CTMProps,\n ImageProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n DrawingNodeProps,\n} from \"../../dom/types\";\n\n// export enum CommandType {\n// // Context\n// SavePaint = \"SavePaint\",\n// RestorePaint = \"RestorePaint\",\n// SaveCTM = \"SaveCTM\",\n// RestoreCTM = \"RestoreCTM\",\n// PushColorFilter = \"PushColorFilter\",\n// PushBlurMaskFilter = \"PushBlurMaskFilter\",\n// PushImageFilter = \"PushImageFilter\",\n// PushPathEffect = \"PushPathEffect\",\n// PushShader = \"PushShader\",\n// ComposeColorFilter = \"ComposeColorFilter\",\n// ComposeImageFilter = \"ComposeImageFilter\",\n// ComposePathEffect = \"ComposePathEffect\",\n// MaterializePaint = \"MaterializePaint\",\n// SaveBackdropFilter = \"SaveBackdropFilter\",\n// SaveLayer = \"SaveLayer\",\n// RestorePaintDeclaration = \"RestorePaintDeclaration\",\n// // Drawing\n// DrawBox = \"DrawBox\",\n// DrawImage = \"DrawImage\",\n// DrawCircle = \"DrawCircle\",\n// DrawPaint = \"DrawPaint\",\n// DrawPoints = \"DrawPoints\",\n// DrawPath = \"DrawPath\",\n// DrawRect = \"DrawRect\",\n// DrawRRect = \"DrawRRect\",\n// DrawOval = \"DrawOval\",\n// DrawLine = \"DrawLine\",\n// DrawPatch = \"DrawPatch\",\n// DrawVertices = \"DrawVertices\",\n// DrawDiffRect = \"DrawDiffRect\",\n// DrawText = \"DrawText\",\n// DrawTextPath = \"DrawTextPath\",\n// DrawTextBlob = \"DrawTextBlob\",\n// DrawGlyphs = \"DrawGlyphs\",\n// DrawPicture = \"DrawPicture\",\n// DrawImageSVG = \"DrawImageSVG\",\n// DrawParagraph = \"DrawParagraph\",\n// DrawAtlas = \"DrawAtlas\",\n// }\nexport enum CommandType {\n // Context\n SavePaint,\n RestorePaint,\n SaveCTM,\n RestoreCTM,\n PushColorFilter,\n PushBlurMaskFilter,\n PushImageFilter,\n PushPathEffect,\n PushShader,\n ComposeColorFilter,\n ComposeImageFilter,\n ComposePathEffect,\n MaterializePaint,\n SaveBackdropFilter,\n SaveLayer,\n RestorePaintDeclaration,\n // Drawing\n DrawBox,\n DrawImage,\n DrawCircle,\n DrawPaint,\n DrawPoints,\n DrawPath,\n DrawRect,\n DrawRRect,\n DrawOval,\n DrawLine,\n DrawPatch,\n DrawVertices,\n DrawDiffRect,\n DrawText,\n DrawTextPath,\n DrawTextBlob,\n DrawGlyphs,\n DrawPicture,\n DrawImageSVG,\n DrawParagraph,\n DrawAtlas,\n}\n\nexport type Command<T extends CommandType = CommandType> = {\n type: T;\n [key: string]: unknown;\n};\n\nexport const materializeProps = (command: {\n props: Record<string, unknown>;\n animatedProps?: Record<string, SharedValue<unknown>>;\n}) => {\n \"worklet\";\n if (command.animatedProps) {\n for (const key in command.animatedProps) {\n command.props[key] = command.animatedProps[key].value;\n }\n }\n};\n\nexport const isCommand = <T extends CommandType>(\n command: Command,\n type: T\n): command is Command<T> => {\n \"worklet\";\n return command.type === type;\n};\n\ninterface Props {\n [CommandType.DrawImage]: ImageProps;\n [CommandType.DrawCircle]: CircleProps;\n [CommandType.SaveCTM]: CTMProps;\n [CommandType.SavePaint]: DrawingNodeProps;\n [CommandType.PushBlurMaskFilter]: BlurMaskFilterProps;\n [CommandType.DrawPoints]: PointsProps;\n [CommandType.DrawPath]: PathProps;\n [CommandType.DrawRect]: RectProps;\n [CommandType.DrawRRect]: RoundedRectProps;\n [CommandType.DrawOval]: OvalProps;\n [CommandType.DrawLine]: LineProps;\n [CommandType.DrawPatch]: PatchProps;\n [CommandType.DrawVertices]: VerticesProps;\n [CommandType.DrawDiffRect]: DiffRectProps;\n [CommandType.DrawText]: TextProps;\n [CommandType.DrawTextPath]: TextPathProps;\n [CommandType.DrawTextBlob]: TextBlobProps;\n [CommandType.DrawGlyphs]: GlyphsProps;\n [CommandType.DrawPicture]: PictureProps;\n [CommandType.DrawImageSVG]: ImageSVGProps;\n [CommandType.DrawParagraph]: ParagraphProps;\n [CommandType.DrawAtlas]: AtlasProps;\n}\n\ninterface DrawCommand<T extends CommandType> extends Command<T> {\n props: T extends keyof Props ? Props[T] : never;\n}\n\nexport const isDrawCommand = <T extends keyof Props>(\n command: Command,\n type: T\n): command is DrawCommand<T> => {\n \"worklet\";\n return command.type === type;\n};\n"],"mappings":"AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,WAAW,0BAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EA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KACmB;EAC1B,SAAS;;EACT,OAAON,OAAO,CAACM,IAAI,KAAKA,IAAI;AAC9B,CAAC;AA+BD,OAAO,MAAMC,aAAa,GAAGA,CAC3BP,OAAgB,EAChBM,IAAO,KACuB;EAC9B,SAAS;;EACT,OAAON,OAAO,CAACM,IAAI,KAAKA,IAAI;AAC9B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["CommandType","materializeProps","command","animatedProps","key","props","value","isCommand","type","isGroup","Group","isDrawCommand"],"sources":["Core.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n BlurMaskFilterProps,\n CircleProps,\n CTMProps,\n ImageProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n DrawingNodeProps,\n} from \"../../dom/types\";\n\n// export enum CommandType {\n// // Context\n// SavePaint = \"SavePaint\",\n// RestorePaint = \"RestorePaint\",\n// SaveCTM = \"SaveCTM\",\n// RestoreCTM = \"RestoreCTM\",\n// PushColorFilter = \"PushColorFilter\",\n// PushBlurMaskFilter = \"PushBlurMaskFilter\",\n// PushImageFilter = \"PushImageFilter\",\n// PushPathEffect = \"PushPathEffect\",\n// PushShader = \"PushShader\",\n// ComposeColorFilter = \"ComposeColorFilter\",\n// ComposeImageFilter = \"ComposeImageFilter\",\n// ComposePathEffect = \"ComposePathEffect\",\n// MaterializePaint = \"MaterializePaint\",\n// SaveBackdropFilter = \"SaveBackdropFilter\",\n// SaveLayer = \"SaveLayer\",\n// RestorePaintDeclaration = \"RestorePaintDeclaration\",\n// // Drawing\n// DrawBox = \"DrawBox\",\n// DrawImage = \"DrawImage\",\n// DrawCircle = \"DrawCircle\",\n// DrawPaint = \"DrawPaint\",\n// DrawPoints = \"DrawPoints\",\n// DrawPath = \"DrawPath\",\n// DrawRect = \"DrawRect\",\n// DrawRRect = \"DrawRRect\",\n// DrawOval = \"DrawOval\",\n// DrawLine = \"DrawLine\",\n// DrawPatch = \"DrawPatch\",\n// DrawVertices = \"DrawVertices\",\n// DrawDiffRect = \"DrawDiffRect\",\n// DrawText = \"DrawText\",\n// DrawTextPath = \"DrawTextPath\",\n// DrawTextBlob = \"DrawTextBlob\",\n// DrawGlyphs = \"DrawGlyphs\",\n// DrawPicture = \"DrawPicture\",\n// DrawImageSVG = \"DrawImageSVG\",\n// DrawParagraph = \"DrawParagraph\",\n// DrawAtlas = \"DrawAtlas\",\n// }\nexport enum CommandType {\n // Context\n Group,\n SavePaint,\n RestorePaint,\n SaveCTM,\n RestoreCTM,\n PushColorFilter,\n PushBlurMaskFilter,\n PushImageFilter,\n PushPathEffect,\n PushShader,\n ComposeColorFilter,\n ComposeImageFilter,\n ComposePathEffect,\n MaterializePaint,\n SaveBackdropFilter,\n SaveLayer,\n RestorePaintDeclaration,\n // Drawing\n DrawBox,\n DrawImage,\n DrawCircle,\n DrawPaint,\n DrawPoints,\n DrawPath,\n DrawRect,\n DrawRRect,\n DrawOval,\n DrawLine,\n DrawPatch,\n DrawVertices,\n DrawDiffRect,\n DrawText,\n DrawTextPath,\n DrawTextBlob,\n DrawGlyphs,\n DrawPicture,\n DrawImageSVG,\n DrawParagraph,\n DrawAtlas,\n}\n\nexport type Command<T extends CommandType = CommandType> = {\n type: T;\n [key: string]: unknown;\n};\n\nexport const materializeProps = (command: {\n props: Record<string, unknown>;\n animatedProps?: Record<string, SharedValue<unknown>>;\n}) => {\n \"worklet\";\n if (command.animatedProps) {\n for (const key in command.animatedProps) {\n command.props[key] = command.animatedProps[key].value;\n }\n }\n};\n\nexport const isCommand = <T extends CommandType>(\n command: Command,\n type: T\n): command is Command<T> => {\n \"worklet\";\n return command.type === type;\n};\n\ninterface GroupCommand extends Command<CommandType.Group> {\n children: Command[];\n}\n\nexport const isGroup = (command: Command): command is GroupCommand => {\n \"worklet\";\n return command.type === CommandType.Group;\n};\n\ninterface Props {\n [CommandType.DrawImage]: ImageProps;\n [CommandType.DrawCircle]: CircleProps;\n [CommandType.SaveCTM]: CTMProps;\n [CommandType.SavePaint]: DrawingNodeProps;\n [CommandType.PushBlurMaskFilter]: BlurMaskFilterProps;\n [CommandType.DrawPoints]: PointsProps;\n [CommandType.DrawPath]: PathProps;\n [CommandType.DrawRect]: RectProps;\n [CommandType.DrawRRect]: RoundedRectProps;\n [CommandType.DrawOval]: OvalProps;\n [CommandType.DrawLine]: LineProps;\n [CommandType.DrawPatch]: PatchProps;\n [CommandType.DrawVertices]: VerticesProps;\n [CommandType.DrawDiffRect]: DiffRectProps;\n [CommandType.DrawText]: TextProps;\n [CommandType.DrawTextPath]: TextPathProps;\n [CommandType.DrawTextBlob]: TextBlobProps;\n [CommandType.DrawGlyphs]: GlyphsProps;\n [CommandType.DrawPicture]: PictureProps;\n [CommandType.DrawImageSVG]: ImageSVGProps;\n [CommandType.DrawParagraph]: ParagraphProps;\n [CommandType.DrawAtlas]: AtlasProps;\n}\n\ninterface DrawCommand<T extends CommandType> extends Command<T> {\n props: T extends keyof Props ? Props[T] : never;\n}\n\nexport const isDrawCommand = <T extends keyof Props>(\n command: Command,\n type: T\n): command is DrawCommand<T> => {\n \"worklet\";\n return command.type === type;\n};\n"],"mappings":"AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,WAAW,0BAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,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CAACM,IAAI,KAAKA,IAAI;AAC9B,CAAC;AAMD,OAAO,MAAMC,OAAO,GAAIP,OAAgB,IAA8B;EACpE,SAAS;;EACT,OAAOA,OAAO,CAACM,IAAI,KAAKR,WAAW,CAACU,KAAK;AAC3C,CAAC;AA+BD,OAAO,MAAMC,aAAa,GAAGA,CAC3BT,OAAgB,EAChBM,IAAO,KACuB;EAC9B,SAAS;;EACT,OAAON,OAAO,CAACM,IAAI,KAAKA,IAAI;AAC9B,CAAC","ignoreList":[]}
@@ -6,10 +6,14 @@ import { setBlurMaskFilter, isPushImageFilter, pushImageFilter, composeImageFilt
6
6
  import { setPaintProperties } from "./commands/Paint";
7
7
  import { composePathEffects, isPushPathEffect, pushPathEffect } from "./commands/PathEffects";
8
8
  import { isPushShader, pushShader } from "./commands/Shaders";
9
- import { CommandType, isCommand, isDrawCommand, materializeProps } from "./Core";
9
+ import { CommandType, isCommand, isDrawCommand, isGroup, materializeProps } from "./Core";
10
10
  const play = (ctx, command) => {
11
11
  "worklet";
12
12
 
13
+ if (isGroup(command)) {
14
+ command.children.forEach(child => play(ctx, child));
15
+ return;
16
+ }
13
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
18
  materializeProps(command);
15
19
  if (isCommand(command, CommandType.SaveBackdropFilter)) {
@@ -1 +1 @@
1
- {"version":3,"names":["drawCircle","drawImage","drawOval","drawPath","drawPoints","drawRect","drawRRect","drawLine","drawAtlas","drawParagraph","drawImageSVG","drawPicture","drawGlyphs","drawTextBlob","drawTextPath","drawText","drawDiffRect","drawVertices","drawPatch","drawBox","isBoxCommand","composeColorFilters","isPushColorFilter","pushColorFilter","saveCTM","setBlurMaskFilter","isPushImageFilter","pushImageFilter","composeImageFilters","setPaintProperties","composePathEffects","isPushPathEffect","pushPathEffect","isPushShader","pushShader","CommandType","isCommand","isDrawCommand","materializeProps","play","ctx","command","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","SavePaint","props","paints","push","savePaint","Skia","RestorePaint","restorePaint","ComposeColorFilter","RestorePaintDeclaration","Error","MaterializePaint","ComposePathEffect","ComposeImageFilter","PushBlurMaskFilter","SaveCTM","RestoreCTM","restore","forEach","p","DrawPaint","drawPaint","DrawImage","DrawCircle","DrawPoints","DrawPath","DrawRect","DrawRRect","DrawOval","DrawLine","DrawPatch","DrawVertices","DrawDiffRect","DrawText","DrawTextPath","DrawTextBlob","DrawGlyphs","DrawPicture","DrawImageSVG","DrawParagraph","DrawAtlas","console","warn","type","replay","commands"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n materializeProps,\n type Command,\n} from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nconst play = (ctx: DrawingContext, command: Command) => {\n \"worklet\";\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n materializeProps(command as any);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(ctx.Skia, ctx.paint, command.props);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n const paints = [ctx.paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n};\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC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G,EAAEC,OAAO,CAACW,KAAK,CAAC;MACnC,CAAC,MAAM,IAAIf,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACwD,SAAS,CAAC,EAAE;QACxDnF,SAAS,CAACgC,GAAG,EAAEC,OAAO,CAACW,KAAK,CAAC;MAC/B,CAAC,MAAM;QACLwC,OAAO,CAACC,IAAI,CAAC,oBAAoBpD,OAAO,CAACqD,IAAI,EAAE,CAAC;MAClD;MACAtD,GAAG,CAACa,MAAM,CAACL,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF,CAAC;AAED,OAAO,MAAM+C,MAAM,GAAGA,CAACvD,GAAmB,EAAEwD,QAAmB,KAAK;EAClE,SAAS;;EACTA,QAAQ,CAAC3B,OAAO,CAAE5B,OAAO,IAAK;IAC5BF,IAAI,CAACC,GAAG,EAAEC,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["drawCircle","drawImage","drawOval","drawPath","drawPoints","drawRect","drawRRect","drawLine","drawAtlas","drawParagraph","drawImageSVG","drawPicture","drawGlyphs","drawTextBlob","drawTextPath","drawText","drawDiffRect","drawVertices","drawPatch","drawBox","isBoxCommand","composeColorFilters","isPushColorFilter","pushColorFilter","saveCTM","setBlurMaskFilter","isPushImageFilter","pushImageFilter","composeImageFilters","setPaintProperties","composePathEffects","isPushPathEffect","pushPathEffect","isPushShader","pushShader","CommandType","isCommand","isDrawCommand","isGroup","materializeProps","play","ctx","command","children","forEach","child","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","SavePaint","props","paints","push","savePaint","Skia","RestorePaint","restorePaint","ComposeColorFilter","RestorePaintDeclaration","Error","MaterializePaint","ComposePathEffect","ComposeImageFilter","PushBlurMaskFilter","SaveCTM","RestoreCTM","restore","p","DrawPaint","drawPaint","DrawImage","DrawCircle","DrawPoints","DrawPath","DrawRect","DrawRRect","DrawOval","DrawLine","DrawPatch","DrawVertices","DrawDiffRect","DrawText","DrawTextPath","DrawTextBlob","DrawGlyphs","DrawPicture","DrawImageSVG","DrawParagraph","DrawAtlas","console","warn","type","replay","commands"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeProps,\n type Command,\n} from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nconst play = (ctx: DrawingContext, command: Command) => {\n \"worklet\";\n if (isGroup(command)) {\n command.children.forEach((child) => play(ctx, child));\n return;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n materializeProps(command as any);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(ctx.Skia, ctx.paint, command.props);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n const paints = [ctx.paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n};\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,SAAS,QACJ,oBAAoB;AAC3B,SAASC,OAAO,EAAEC,YAAY,QAAQ,gBAAgB;AACtD,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,eAAe,QACV,yBAAyB;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ACgC,GAAG,EAAEC,OAAO,CAACc,KAAK,CAAC;MACnC,CAAC,MAAM,IAAInB,aAAa,CAACK,OAAO,EAAEP,WAAW,CAAC2D,SAAS,CAAC,EAAE;QACxDtF,SAAS,CAACiC,GAAG,EAAEC,OAAO,CAACc,KAAK,CAAC;MAC/B,CAAC,MAAM;QACLuC,OAAO,CAACC,IAAI,CAAC,oBAAoBtD,OAAO,CAACuD,IAAI,EAAE,CAAC;MAClD;MACAxD,GAAG,CAACgB,MAAM,CAACL,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF,CAAC;AAED,OAAO,MAAM8C,MAAM,GAAGA,CAACzD,GAAmB,EAAE0D,QAAmB,KAAK;EAClE,SAAS;;EACTA,QAAQ,CAACvD,OAAO,CAAEF,OAAO,IAAK;IAC5BF,IAAI,CAACC,GAAG,EAAEC,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -2,11 +2,25 @@ import type { SharedValue } from "react-native-reanimated";
2
2
  import { NodeType } from "../../dom/types";
3
3
  import type { BlurMaskFilterProps, CircleProps, CTMProps, ImageProps, PaintProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, BoxProps, BoxShadowProps } from "../../dom/types";
4
4
  import type { AnimatedProps } from "../../renderer";
5
+ import type { SkPaint } from "../../skia/types";
5
6
  import type { Command } from "./Core";
7
+ export interface Recording {
8
+ commands: Command[];
9
+ paintPool: SkPaint[];
10
+ }
11
+ interface AnimationValues {
12
+ animationValues: Set<SharedValue<unknown>>;
13
+ }
6
14
  export declare class Recorder {
7
15
  commands: Command[];
16
+ cursors: Command[][];
17
+ animationValues: Set<SharedValue<unknown>>;
18
+ constructor();
19
+ getRecording(): Recording & AnimationValues;
8
20
  private processProps;
9
21
  private add;
22
+ saveGroup(): void;
23
+ restoreGroup(): void;
10
24
  savePaint(props: AnimatedProps<PaintProps>): void;
11
25
  restorePaint(): void;
12
26
  restorePaintDeclaration(): void;
@@ -48,3 +62,4 @@ export declare class Recorder {
48
62
  drawParagraph(props: AnimatedProps<ParagraphProps>): void;
49
63
  drawAtlas(props: AnimatedProps<AtlasProps>): void;
50
64
  }
65
+ export {};
@@ -8,6 +8,16 @@ import { CommandType } from "./Core";
8
8
  export class Recorder {
9
9
  constructor() {
10
10
  _defineProperty(this, "commands", []);
11
+ _defineProperty(this, "cursors", []);
12
+ _defineProperty(this, "animationValues", new Set());
13
+ this.cursors.push(this.commands);
14
+ }
15
+ getRecording() {
16
+ return {
17
+ commands: this.commands,
18
+ paintPool: [],
19
+ animationValues: this.animationValues
20
+ };
11
21
  }
12
22
  processProps(props) {
13
23
  const animatedProps = {};
@@ -15,6 +25,7 @@ export class Recorder {
15
25
  for (const key in props) {
16
26
  const prop = props[key];
17
27
  if (isSharedValue(prop)) {
28
+ this.animationValues.add(prop);
18
29
  props[key] = prop.value;
19
30
  animatedProps[key] = prop;
20
31
  hasAnimatedProps = true;
@@ -34,7 +45,18 @@ export class Recorder {
34
45
  command.animatedProps = animatedProps;
35
46
  }
36
47
  }
37
- this.commands.push(command);
48
+ this.cursors[this.cursors.length - 1].push(command);
49
+ }
50
+ saveGroup() {
51
+ const children = [];
52
+ this.add({
53
+ type: CommandType.Group,
54
+ children
55
+ });
56
+ this.cursors.push(children);
57
+ }
58
+ restoreGroup() {
59
+ this.cursors.pop();
38
60
  }
39
61
  savePaint(props) {
40
62
  this.add({