@shopify/react-native-skia 1.11.9 → 2.0.0-next.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 (116) hide show
  1. package/android/build.gradle +1 -1
  2. package/lib/commonjs/Platform/Platform.web.js +1 -0
  3. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  4. package/lib/commonjs/external/reanimated/textures.js +4 -3
  5. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  6. package/lib/commonjs/headless/index.d.ts +1 -1
  7. package/lib/commonjs/headless/index.js +2 -2
  8. package/lib/commonjs/headless/index.js.map +1 -1
  9. package/lib/commonjs/renderer/Canvas.d.ts +3 -3
  10. package/lib/commonjs/renderer/Canvas.js +12 -31
  11. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  12. package/lib/commonjs/renderer/Offscreen.d.ts +2 -2
  13. package/lib/commonjs/renderer/Offscreen.js +4 -4
  14. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  15. package/lib/commonjs/renderer/__tests__/setup.d.ts +6 -5
  16. package/lib/commonjs/sksg/Container.d.ts +3 -1
  17. package/lib/commonjs/sksg/Container.js +7 -1
  18. package/lib/commonjs/sksg/Container.js.map +1 -1
  19. package/lib/commonjs/sksg/Elements.d.ts +1 -1
  20. package/lib/commonjs/sksg/Elements.js.map +1 -1
  21. package/lib/commonjs/sksg/HostConfig.d.ts +2 -2
  22. package/lib/commonjs/sksg/HostConfig.js +36 -6
  23. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  24. package/lib/commonjs/sksg/Reconciler.d.ts +3 -2
  25. package/lib/commonjs/sksg/Reconciler.js +15 -6
  26. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  27. package/lib/module/Platform/Platform.web.js +1 -0
  28. package/lib/module/Platform/Platform.web.js.map +1 -1
  29. package/lib/module/external/reanimated/textures.js +5 -4
  30. package/lib/module/external/reanimated/textures.js.map +1 -1
  31. package/lib/module/headless/index.d.ts +1 -1
  32. package/lib/module/headless/index.js +2 -2
  33. package/lib/module/headless/index.js.map +1 -1
  34. package/lib/module/renderer/Canvas.d.ts +3 -3
  35. package/lib/module/renderer/Canvas.js +11 -31
  36. package/lib/module/renderer/Canvas.js.map +1 -1
  37. package/lib/module/renderer/Offscreen.d.ts +2 -2
  38. package/lib/module/renderer/Offscreen.js +4 -4
  39. package/lib/module/renderer/Offscreen.js.map +1 -1
  40. package/lib/module/renderer/__tests__/setup.d.ts +6 -5
  41. package/lib/module/sksg/Container.d.ts +3 -1
  42. package/lib/module/sksg/Container.js +7 -1
  43. package/lib/module/sksg/Container.js.map +1 -1
  44. package/lib/module/sksg/Elements.d.ts +1 -1
  45. package/lib/module/sksg/Elements.js.map +1 -1
  46. package/lib/module/sksg/HostConfig.d.ts +2 -2
  47. package/lib/module/sksg/HostConfig.js +36 -7
  48. package/lib/module/sksg/HostConfig.js.map +1 -1
  49. package/lib/module/sksg/Reconciler.d.ts +3 -2
  50. package/lib/module/sksg/Reconciler.js +15 -6
  51. package/lib/module/sksg/Reconciler.js.map +1 -1
  52. package/lib/typescript/lib/commonjs/headless/index.d.ts +1 -1
  53. package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +9 -1
  54. package/lib/typescript/lib/commonjs/renderer/Offscreen.d.ts +2 -2
  55. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +3 -0
  56. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +21 -4
  57. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +9 -2
  58. package/lib/typescript/lib/module/Platform/Platform.web.d.ts +1 -1
  59. package/lib/typescript/lib/module/headless/index.d.ts +1 -1
  60. package/lib/typescript/lib/module/mock/index.d.ts +22 -11
  61. package/lib/typescript/lib/module/renderer/Canvas.d.ts +10 -2
  62. package/lib/typescript/lib/module/renderer/Offscreen.d.ts +2 -2
  63. package/lib/typescript/lib/module/sksg/Container.d.ts +3 -0
  64. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +20 -4
  65. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +9 -2
  66. package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +1 -1
  67. package/lib/typescript/src/headless/index.d.ts +1 -1
  68. package/lib/typescript/src/renderer/Canvas.d.ts +3 -3
  69. package/lib/typescript/src/renderer/Offscreen.d.ts +2 -2
  70. package/lib/typescript/src/renderer/__tests__/setup.d.ts +6 -5
  71. package/lib/typescript/src/sksg/Container.d.ts +3 -1
  72. package/lib/typescript/src/sksg/Elements.d.ts +1 -1
  73. package/lib/typescript/src/sksg/HostConfig.d.ts +2 -2
  74. package/lib/typescript/src/sksg/Reconciler.d.ts +3 -2
  75. package/package.json +11 -10
  76. package/src/Platform/Platform.web.tsx +2 -1
  77. package/src/__tests__/snapshots/screens/snapshot2-android-ci.png +0 -0
  78. package/src/__tests__/snapshots/screens/snapshot3-android-ci.png +0 -0
  79. package/src/external/reanimated/textures.tsx +5 -4
  80. package/src/headless/index.ts +2 -2
  81. package/src/renderer/Canvas.tsx +57 -80
  82. package/src/renderer/Offscreen.tsx +4 -4
  83. package/src/renderer/__tests__/Data.spec.tsx +9 -10
  84. package/src/renderer/__tests__/Drawings.spec.tsx +11 -11
  85. package/src/renderer/__tests__/FitBox.spec.tsx +10 -10
  86. package/src/renderer/__tests__/Glyphs.spec.tsx +2 -2
  87. package/src/renderer/__tests__/Image.spec.tsx +2 -2
  88. package/src/renderer/__tests__/Paths.spec.tsx +8 -8
  89. package/src/renderer/__tests__/Picture.spec.tsx +10 -12
  90. package/src/renderer/__tests__/Simple.spec.tsx +6 -6
  91. package/src/renderer/__tests__/Surfaces.spec.tsx +2 -2
  92. package/src/renderer/__tests__/Text.spec.tsx +12 -12
  93. package/src/renderer/__tests__/Transform.spec.tsx +8 -8
  94. package/src/renderer/__tests__/documentation/Group.spec.tsx +12 -12
  95. package/src/renderer/__tests__/documentation/getting-started/HelloWorld.spec.tsx +2 -2
  96. package/src/renderer/__tests__/documentation/paint/Overview.spec.tsx +8 -8
  97. package/src/renderer/__tests__/documentation/shapes/Box.spec.tsx +4 -4
  98. package/src/renderer/__tests__/e2e/Atlas.spec.tsx +3 -3
  99. package/src/renderer/__tests__/e2e/Offscreen.spec.tsx +1 -1
  100. package/src/renderer/__tests__/examples/BlendModes.spec.tsx +4 -4
  101. package/src/renderer/__tests__/setup.tsx +17 -13
  102. package/src/sksg/Container.ts +9 -1
  103. package/src/sksg/Elements.tsx +1 -1
  104. package/src/sksg/HostConfig.ts +37 -7
  105. package/src/sksg/Reconciler.ts +16 -6
  106. package/src/sksg/__tests__/Simple.spec.tsx +8 -8
  107. package/lib/commonjs/sksg/HostConfig2.d.ts +0 -19
  108. package/lib/commonjs/sksg/HostConfig2.js +0 -159
  109. package/lib/commonjs/sksg/HostConfig2.js.map +0 -1
  110. package/lib/module/sksg/HostConfig2.d.ts +0 -19
  111. package/lib/module/sksg/HostConfig2.js +0 -152
  112. package/lib/module/sksg/HostConfig2.js.map +0 -1
  113. package/lib/typescript/lib/commonjs/sksg/HostConfig2.d.ts +0 -44
  114. package/lib/typescript/lib/module/sksg/HostConfig2.d.ts +0 -43
  115. package/lib/typescript/src/sksg/HostConfig2.d.ts +0 -19
  116. package/src/sksg/HostConfig2.ts +0 -247
@@ -5,10 +5,12 @@ import "../views/api";
5
5
  export declare abstract class Container {
6
6
  protected Skia: Skia;
7
7
  protected nativeId: number;
8
- root: Node[];
8
+ private _root;
9
9
  protected recording: Recording | null;
10
10
  protected unmounted: boolean;
11
11
  constructor(Skia: Skia, nativeId: number);
12
+ get root(): Node[];
13
+ set root(value: Node[]);
12
14
  unmount(): void;
13
15
  drawOnCanvas(canvas: SkCanvas): void;
14
16
  abstract redraw(): void;
@@ -36,10 +36,16 @@ export class Container {
36
36
  constructor(Skia, nativeId) {
37
37
  this.Skia = Skia;
38
38
  this.nativeId = nativeId;
39
- _defineProperty(this, "root", []);
39
+ _defineProperty(this, "_root", []);
40
40
  _defineProperty(this, "recording", null);
41
41
  _defineProperty(this, "unmounted", false);
42
42
  }
43
+ get root() {
44
+ return this._root;
45
+ }
46
+ set root(value) {
47
+ this._root = value;
48
+ }
43
49
  unmount() {
44
50
  this.unmounted = true;
45
51
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","ReanimatedRecorder","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","nativeDrawOnscreen","recorder","play","Container","constructor","_defineProperty","unmount","unmounted","drawOnCanvas","Error","StaticContainer","redraw","root","getRecording","isOnScreen","ReanimatedContainer","mapperId","stopMapper","record","animationValues","size","startMapper","Array","from","runOnUI","NativeReanimatedContainer","sharedValues","getSharedValues","sharedRecorder","getRecorder","length","applyUpdates","createContainer","web","global"],"sources":["Container.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport type { Node } from \"./Node\";\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\n\nimport \"../views/api\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nconst nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {\n \"worklet\";\n\n //const start = performance.now();\n\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nexport abstract class Container {\n public root: Node[] = [];\n protected recording: Recording | null = null;\n protected unmounted = false;\n\n constructor(protected Skia: Skia, protected nativeId: number) {}\n\n unmount() {\n this.unmounted = true;\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n replay(ctx, this.recording.commands);\n }\n\n abstract redraw(): void;\n}\n\nclass StaticContainer extends Container {\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n }\n }\n}\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder);\n })();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n const web = global.SkiaViewApi && global.SkiaViewApi.web;\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n if (!web) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new ReanimatedContainer(Skia, nativeId);\n }\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAKvE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,OAAO,cAAc;AAErB,MAAMC,YAAY,GAAGA,CAACC,IAAU,EAAEC,QAAgB,EAAEC,SAAoB,KAAK;EAC3E,SAAS;;EAET,MAAMC,GAAG,GAAGH,IAAI,CAACI,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;;EAEA,MAAMC,GAAG,GAAGV,oBAAoB,CAACG,IAAI,EAAEE,S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,CAAC,CAAC;IAC7CnD,GAAG,CAAC8C,OAAO,CAAC,MAAM;MAChB,SAAS;;MACTxB,kBAAkB,CAACb,QAAQ,EAAEyC,cAAc,CAAC;IAC9C,CAAC,CAAC,CAAC,CAAC;IACJ,IAAIF,YAAY,CAACI,MAAM,GAAG,CAAC,EAAE;MAC3B,IAAI,CAACd,QAAQ,GAAGtC,GAAG,CAAC2C,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTO,cAAc,CAACG,YAAY,CAACL,YAAY,CAAC;QACzC1B,kBAAkB,CAACb,QAAQ,EAAEyC,cAAc,CAAC;MAC9C,CAAC,EAAEF,YAAY,CAAC;IAClB;EACF;AACF;AAEA,OAAO,MAAMM,eAAe,GAAGA,CAAC9C,IAAU,EAAEC,QAAgB,KAAK;EAC/D,MAAM8C,GAAG,GAAGC,MAAM,CAACpC,WAAW,IAAIoC,MAAM,CAACpC,WAAW,CAACmC,GAAG;EACxD,IAAItD,gBAAgB,IAAIQ,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,IAAI,CAAC8C,GAAG,EAAE;MACR,OAAO,IAAIR,yBAAyB,CAACvC,IAAI,EAAEC,QAAQ,CAAC;IACtD,CAAC,MAAM;MACL,OAAO,IAAI4B,mBAAmB,CAAC7B,IAAI,EAAEC,QAAQ,CAAC;IAChD;EACF,CAAC,MAAM;IACL,OAAO,IAAIuB,eAAe,CAACxB,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","ReanimatedRecorder","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","nativeDrawOnscreen","recorder","play","Container","constructor","_defineProperty","root","_root","value","unmount","unmounted","drawOnCanvas","Error","StaticContainer","redraw","getRecording","isOnScreen","ReanimatedContainer","mapperId","stopMapper","record","animationValues","size","startMapper","Array","from","runOnUI","NativeReanimatedContainer","sharedValues","getSharedValues","sharedRecorder","getRecorder","length","applyUpdates","createContainer","web","global"],"sources":["Container.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport type { Node } from \"./Node\";\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\n\nimport \"../views/api\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nconst nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {\n \"worklet\";\n\n //const start = performance.now();\n\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nexport abstract class Container {\n private _root: Node[] = [];\n protected recording: Recording | null = null;\n protected unmounted = false;\n\n constructor(protected Skia: Skia, protected nativeId: number) {}\n\n get root() {\n return this._root;\n }\n\n set root(value: Node[]) {\n this._root = value;\n }\n\n unmount() {\n this.unmounted = true;\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n replay(ctx, this.recording.commands);\n }\n\n abstract redraw(): void;\n}\n\nclass StaticContainer extends Container {\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n }\n }\n}\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder);\n })();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n const web = global.SkiaViewApi && global.SkiaViewApi.web;\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n if (!web) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new ReanimatedContainer(Skia, nativeId);\n }\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAKvE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,OAAO,cAAc;AAErB,MAAMC,YAAY,GAAGA,CAACC,IAAU,EAAEC,QAAgB,EAAEC,SAAoB,KAAK;EAC3E,SAAS;;EAET,MAAMC,GAAG,GAAGH,IAAI,CAACI,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;;EAEA,MAAMC,GAAG,GAAGV,oBAAoB,CAACG,IAAI,EAAEE,SAAS,CAACM,SAAS,EAAEH,MAAM,CAAC;EACnET,MAAM,CAACW,GAAG,EAAEL,SAAS,CAACO,QAAQ,CAAC;EAC/B,MAAMC,OAAO,GAAGP,GAAG,CAACQ,wBAAwB,CAAC,CAAC;EAC9C;EACA;EACAC,WAAW,CAACC,cAAc,CAACZ,QAAQ,EAAE,SAAS,EAAES,OAAO,CAAC;AAC1D,CAAC;AAED,MAAMI,kBAAkB,GAAGA,CAACb,QAAgB,EAAEc,QAAqB,KAAK;EACtE,SAAS;;EAET;EAEA,MAAML,OAAO,GAAGK,QAAQ,CAACC,IAAI,CAAC,CAAC;E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,CAAC6C,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTO,cAAc,CAACG,YAAY,CAACL,YAAY,CAAC;QACzC5B,kBAAkB,CAACb,QAAQ,EAAE2C,cAAc,CAAC;MAC9C,CAAC,EAAEF,YAAY,CAAC;IAClB;EACF;AACF;AAEA,OAAO,MAAMM,eAAe,GAAGA,CAAChD,IAAU,EAAEC,QAAgB,KAAK;EAC/D,MAAMgD,GAAG,GAAGC,MAAM,CAACtC,WAAW,IAAIsC,MAAM,CAACtC,WAAW,CAACqC,GAAG;EACxD,IAAIxD,gBAAgB,IAAIQ,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,IAAI,CAACgD,GAAG,EAAE;MACR,OAAO,IAAIR,yBAAyB,CAACzC,IAAI,EAAEC,QAAQ,CAAC;IACtD,CAAC,MAAM;MACL,OAAO,IAAI8B,mBAAmB,CAAC/B,IAAI,EAAEC,QAAQ,CAAC;IAChD;EACF,CAAC,MAAM;IACL,OAAO,IAAI0B,eAAe,CAAC3B,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { FractalNoiseProps, CircleProps, DrawingNodeProps, ImageProps, PaintProps, PathProps, LineProps, OvalProps, DiffRectProps, PointsProps, RectProps, RoundedRectProps, TextProps, VerticesProps, BlurMaskFilterProps, BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, MatrixColorFilterProps, ShaderProps, ImageShaderProps, LinearGradientProps, GroupProps, PatchProps, BlendColorFilterProps, DashPathEffectProps, DiscretePathEffectProps, CornerPathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, BoxProps, BoxShadowProps, ParagraphProps, AtlasProps, ChildrenProps, MorphologyImageFilterProps, BlendProps } from "../dom/types";
2
2
  import type { SkiaProps } from "../renderer";
3
- declare global {
3
+ declare module "react" {
4
4
  namespace JSX {
5
5
  interface IntrinsicElements {
6
6
  skGroup: SkiaProps<GroupProps>;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Elements.tsx"],"sourcesContent":["import type {\n FractalNoiseProps,\n CircleProps,\n DrawingNodeProps,\n ImageProps,\n PaintProps,\n PathProps,\n LineProps,\n OvalProps,\n DiffRectProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextProps,\n VerticesProps,\n BlurMaskFilterProps,\n BlendImageFilterProps,\n BlurImageFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n MatrixColorFilterProps,\n ShaderProps,\n ImageShaderProps,\n LinearGradientProps,\n GroupProps,\n PatchProps,\n BlendColorFilterProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n CornerPathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n TwoPointConicalGradientProps,\n TurbulenceProps,\n SweepGradientProps,\n RadialGradientProps,\n ColorProps,\n PictureProps,\n ImageSVGProps,\n LerpColorFilterProps,\n BoxProps,\n BoxShadowProps,\n ParagraphProps,\n AtlasProps,\n ChildrenProps,\n MorphologyImageFilterProps,\n BlendProps,\n} from \"../dom/types\";\nimport type { SkiaProps } from \"../renderer\";\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n skGroup: SkiaProps<GroupProps>;\n skLayer: SkiaProps<ChildrenProps>;\n skPaint: SkiaProps<PaintProps>;\n\n // Drawings\n skFill: SkiaProps<DrawingNodeProps>;\n skImage: SkiaProps<ImageProps>;\n skCircle: SkiaProps<CircleProps>;\n skPath: SkiaProps<PathProps>;\n skLine: SkiaProps<LineProps>;\n skOval: SkiaProps<OvalProps>;\n skPatch: SkiaProps<PatchProps>;\n skPoints: SkiaProps<PointsProps>;\n skRect: SkiaProps<RectProps>;\n skRRect: SkiaProps<RoundedRectProps>;\n skAtlas: SkiaProps<AtlasProps>;\n skVertices: SkiaProps<VerticesProps>;\n skText: SkiaProps<TextProps>;\n skTextPath: SkiaProps<TextPathProps>;\n skTextBlob: SkiaProps<TextBlobProps>;\n skGlyphs: SkiaProps<GlyphsProps>;\n skDiffRect: SkiaProps<DiffRectProps>;\n skPicture: SkiaProps<PictureProps>;\n skImageSVG: SkiaProps<ImageSVGProps>;\n\n // BlurMaskFilters\n skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;\n\n // ImageFilters\n skBlendImageFilter: SkiaProps<BlendImageFilterProps>;\n skBlurImageFilter: SkiaProps<BlurImageFilterProps>;\n skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;\n skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;\n skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;\n skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;\n skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;\n\n // ColorFilters\n skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;\n skBlendColorFilter: SkiaProps<BlendColorFilterProps>;\n skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;\n skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;\n skLumaColorFilter: SkiaProps<ChildrenProps>;\n skLerpColorFilter: SkiaProps<LerpColorFilterProps>;\n\n // Shaders\n skShader: SkiaProps<ShaderProps>;\n skImageShader: SkiaProps<ImageShaderProps>;\n skColorShader: SkiaProps<ColorProps>;\n skTurbulence: SkiaProps<TurbulenceProps>;\n skFractalNoise: SkiaProps<FractalNoiseProps>;\n skLinearGradient: SkiaProps<LinearGradientProps>;\n skRadialGradient: SkiaProps<RadialGradientProps>;\n skSweepGradient: SkiaProps<SweepGradientProps>;\n skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;\n\n // Path Effects\n skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;\n skDashPathEffect: SkiaProps<DashPathEffectProps>;\n skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;\n skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;\n skCornerPathEffect: SkiaProps<CornerPathEffectProps>;\n skSumPathEffect: ChildrenProps;\n skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;\n\n // Mixed declarations/drawings\n skBlend: SkiaProps<BlendProps>;\n skBackdropFilter: SkiaProps<ChildrenProps>;\n skBox: SkiaProps<BoxProps>;\n skBoxShadow: SkiaProps<BoxShadowProps>;\n\n // Paragraph\n skParagraph: SkiaProps<ParagraphProps>;\n }\n }\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["Elements.tsx"],"sourcesContent":["import type {\n FractalNoiseProps,\n CircleProps,\n DrawingNodeProps,\n ImageProps,\n PaintProps,\n PathProps,\n LineProps,\n OvalProps,\n DiffRectProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextProps,\n VerticesProps,\n BlurMaskFilterProps,\n BlendImageFilterProps,\n BlurImageFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n MatrixColorFilterProps,\n ShaderProps,\n ImageShaderProps,\n LinearGradientProps,\n GroupProps,\n PatchProps,\n BlendColorFilterProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n CornerPathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n TwoPointConicalGradientProps,\n TurbulenceProps,\n SweepGradientProps,\n RadialGradientProps,\n ColorProps,\n PictureProps,\n ImageSVGProps,\n LerpColorFilterProps,\n BoxProps,\n BoxShadowProps,\n ParagraphProps,\n AtlasProps,\n ChildrenProps,\n MorphologyImageFilterProps,\n BlendProps,\n} from \"../dom/types\";\nimport type { SkiaProps } from \"../renderer\";\n\ndeclare module \"react\" {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n skGroup: SkiaProps<GroupProps>;\n skLayer: SkiaProps<ChildrenProps>;\n skPaint: SkiaProps<PaintProps>;\n\n // Drawings\n skFill: SkiaProps<DrawingNodeProps>;\n skImage: SkiaProps<ImageProps>;\n skCircle: SkiaProps<CircleProps>;\n skPath: SkiaProps<PathProps>;\n skLine: SkiaProps<LineProps>;\n skOval: SkiaProps<OvalProps>;\n skPatch: SkiaProps<PatchProps>;\n skPoints: SkiaProps<PointsProps>;\n skRect: SkiaProps<RectProps>;\n skRRect: SkiaProps<RoundedRectProps>;\n skAtlas: SkiaProps<AtlasProps>;\n skVertices: SkiaProps<VerticesProps>;\n skText: SkiaProps<TextProps>;\n skTextPath: SkiaProps<TextPathProps>;\n skTextBlob: SkiaProps<TextBlobProps>;\n skGlyphs: SkiaProps<GlyphsProps>;\n skDiffRect: SkiaProps<DiffRectProps>;\n skPicture: SkiaProps<PictureProps>;\n skImageSVG: SkiaProps<ImageSVGProps>;\n\n // BlurMaskFilters\n skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;\n\n // ImageFilters\n skBlendImageFilter: SkiaProps<BlendImageFilterProps>;\n skBlurImageFilter: SkiaProps<BlurImageFilterProps>;\n skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;\n skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;\n skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;\n skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;\n skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;\n\n // ColorFilters\n skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;\n skBlendColorFilter: SkiaProps<BlendColorFilterProps>;\n skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;\n skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;\n skLumaColorFilter: SkiaProps<ChildrenProps>;\n skLerpColorFilter: SkiaProps<LerpColorFilterProps>;\n\n // Shaders\n skShader: SkiaProps<ShaderProps>;\n skImageShader: SkiaProps<ImageShaderProps>;\n skColorShader: SkiaProps<ColorProps>;\n skTurbulence: SkiaProps<TurbulenceProps>;\n skFractalNoise: SkiaProps<FractalNoiseProps>;\n skLinearGradient: SkiaProps<LinearGradientProps>;\n skRadialGradient: SkiaProps<RadialGradientProps>;\n skSweepGradient: SkiaProps<SweepGradientProps>;\n skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;\n\n // Path Effects\n skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;\n skDashPathEffect: SkiaProps<DashPathEffectProps>;\n skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;\n skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;\n skCornerPathEffect: SkiaProps<CornerPathEffectProps>;\n skSumPathEffect: ChildrenProps;\n skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;\n\n // Mixed declarations/drawings\n skBlend: SkiaProps<BlendProps>;\n skBackdropFilter: SkiaProps<ChildrenProps>;\n skBox: SkiaProps<BoxProps>;\n skBoxShadow: SkiaProps<BoxShadowProps>;\n\n // Paragraph\n skParagraph: SkiaProps<ParagraphProps>;\n }\n }\n}\n"],"mappings":"","ignoreList":[]}
@@ -2,14 +2,14 @@ import type { HostConfig } from "react-reconciler";
2
2
  import type { NodeType } from "../dom/types";
3
3
  import type { Node } from "./Node";
4
4
  import type { Container } from "./Container";
5
- export declare const debug: (message?: any, ...optionalParams: any[]) => void;
5
+ export declare const debug: (...args: Parameters<typeof console.log>) => void;
6
6
  type Instance = Node;
7
7
  type Props = object;
8
8
  type TextInstance = Node;
9
9
  type SuspenseInstance = Instance;
10
10
  type HydratableInstance = Instance;
11
11
  type PublicInstance = Instance;
12
- type HostContext = null;
12
+ type HostContext = object;
13
13
  type UpdatePayload = Container;
14
14
  type ChildSet = Node[];
15
15
  type TimeoutHandle = NodeJS.Timeout;
@@ -1,13 +1,15 @@
1
1
  /*global NodeJS*/
2
-
2
+ import { createContext } from "react";
3
3
  import { DefaultEventPriority } from "react-reconciler/constants";
4
4
  import { shallowEq } from "../renderer/typeddash";
5
+ const NoEventPriority = 0;
5
6
  const DEBUG = false;
6
7
  export const debug = (...args) => {
7
8
  if (DEBUG) {
8
9
  console.log(...args);
9
10
  }
10
11
  };
12
+ let currentUpdatePriority = NoEventPriority;
11
13
  export const sksgHostConfig = {
12
14
  /**
13
15
  * This function is used by the reconciler in order to calculate current time for prioritising work.
@@ -22,11 +24,11 @@ export const sksgHostConfig = {
22
24
  noTimeout: -1,
23
25
  getRootHostContext: _rootContainerInstance => {
24
26
  debug("getRootHostContext");
25
- return null;
27
+ return {};
26
28
  },
27
29
  getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {
28
30
  debug("getChildHostContext");
29
- return null;
31
+ return {};
30
32
  },
31
33
  shouldSetTextContent(_type, _props) {
32
34
  return false;
@@ -65,9 +67,8 @@ export const sksgHostConfig = {
65
67
  debug("prepareForCommit");
66
68
  return null;
67
69
  },
68
- resetAfterCommit(container) {
70
+ resetAfterCommit(_container) {
69
71
  debug("resetAfterCommit");
70
- container.redraw();
71
72
  },
72
73
  getPublicInstance(node) {
73
74
  debug("getPublicInstance");
@@ -90,7 +91,7 @@ export const sksgHostConfig = {
90
91
  preparePortalMount: () => {
91
92
  debug("preparePortalMount");
92
93
  },
93
- cloneInstance(instance, _updatePayload, _type, _oldProps, newProps, _internalInstanceHandle, keepChildren, _recyclableInstance) {
94
+ cloneInstance(instance, _type, _oldProps, newProps, _updatePayload, _internalInstanceHandle, keepChildren, _recyclableInstance) {
94
95
  debug("cloneInstance");
95
96
  return {
96
97
  type: instance.type,
@@ -133,6 +134,34 @@ export const sksgHostConfig = {
133
134
  },
134
135
  getInstanceFromScope: function (_scopeInstance) {
135
136
  throw new Error("Function not implemented.");
136
- }
137
+ },
138
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
139
+ // @ts-expect-error
140
+ shouldAttemptEagerTransition: () => false,
141
+ trackSchedulerEvent: () => {},
142
+ resolveEventType: () => null,
143
+ resolveEventTimeStamp: () => -1.1,
144
+ requestPostPaintCallback() {},
145
+ maySuspendCommit: () => false,
146
+ preloadInstance: () => true,
147
+ // true indicates already loaded
148
+ startSuspendingCommit() {},
149
+ suspendInstance() {},
150
+ waitForCommitToBeReady: () => null,
151
+ NotPendingTransition: null,
152
+ HostTransitionContext: /*#__PURE__*/createContext(null),
153
+ setCurrentUpdatePriority(newPriority) {
154
+ currentUpdatePriority = newPriority;
155
+ },
156
+ getCurrentUpdatePriority() {
157
+ return currentUpdatePriority;
158
+ },
159
+ resolveUpdatePriority() {
160
+ if (currentUpdatePriority !== NoEventPriority) {
161
+ return currentUpdatePriority;
162
+ }
163
+ return DefaultEventPriority;
164
+ },
165
+ resetFormInstance() {}
137
166
  };
138
167
  //# sourceMappingURL=HostConfig.js.map
@@ -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","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 (_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;EAE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":[]}
1
+ {"version":3,"names":["createContext","DefaultEventPriority","shallowEq","NoEventPriority","DEBUG","debug","args","console","log","currentUpdatePriority","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","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","container","propsAreEqual","preparePortalMount","cloneInstance","_oldProps","_updatePayload","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope","shouldAttemptEagerTransition","trackSchedulerEvent","resolveEventType","resolveEventTimeStamp","requestPostPaintCallback","maySuspendCommit","preloadInstance","startSuspendingCommit","suspendInstance","waitForCommitToBeReady","NotPendingTransition","HostTransitionContext","setCurrentUpdatePriority","newPriority","getCurrentUpdatePriority","resolveUpdatePriority","resetFormInstance"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport { createContext } from \"react\";\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\ntype EventPriority = number;\nconst NoEventPriority = 0;\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 = object;\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>;\nlet currentUpdatePriority: EventPriority = NoEventPriority;\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 {};\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return {};\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 },\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 _type,\n _oldProps,\n newProps,\n _updatePayload,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\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 (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n shouldAttemptEagerTransition: () => false,\n trackSchedulerEvent: () => {},\n resolveEventType: () => null,\n resolveEventTimeStamp: () => -1.1,\n requestPostPaintCallback() {},\n maySuspendCommit: () => false,\n preloadInstance: () => true, // true indicates already loaded\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady: () => null,\n NotPendingTransition: null,\n HostTransitionContext: createContext(null),\n setCurrentUpdatePriority(newPriority: number) {\n currentUpdatePriority = newPriority;\n },\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority;\n }\n return DefaultEventPriority;\n },\n resetFormInstance() {},\n};\n"],"mappings":"AAAA;AACA,SAASA,aAAa,QAAQ,OAAO;AAErC,SAASC,oBAAoB,QAAQ,4BAA4B;AAGjE,SAASC,SAAS,QAAQ,uBAAuB;AAMjD,MAAMC,eAAe,GAAG,CAAC;AAEzB,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;AA8BD,IAAIG,qBAAoC,GAAGN,eAAe;AAE1D,OAAO,MAAMO,cAA8B,GAAG;EAC5C;AACF;AACA;EACEC,gBAAgB,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,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDoD,oBAAoB,EAAE,SAAAA,CAAUD,cAAc,EAAmB;IAC/D,MAAM,IAAInD,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACD;EACA;EACAqD,4BAA4B,EAAEA,CAAA,KAAM,KAAK;EACzCC,mBAAmB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC7BC,gBAAgB,EAAEA,CAAA,KAAM,IAAI;EAC5BC,qBAAqB,EAAEA,CAAA,KAAM,CAAC,GAAG;EACjCC,wBAAwBA,CAAA,EAAG,CAAC,CAAC;EAC7BC,gBAAgB,EAAEA,CAAA,KAAM,KAAK;EAC7BC,eAAe,EAAEA,CAAA,KAAM,IAAI;EAAE;EAC7BC,qBAAqBA,CAAA,EAAG,CAAC,CAAC;EAC1BC,eAAeA,CAAA,EAAG,CAAC,CAAC;EACpBC,sBAAsB,EAAEA,CAAA,KAAM,IAAI;EAClCC,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,eAAE/F,aAAa,CAAC,IAAI,CAAC;EAC1CgG,wBAAwBA,CAACC,WAAmB,EAAE;IAC5CxF,qBAAqB,GAAGwF,WAAW;EACrC,CAAC;EACDC,wBAAwBA,CAAA,EAAG;IACzB,OAAOzF,qBAAqB;EAC9B,CAAC;EACD0F,qBAAqBA,CAAA,EAAG;IACtB,IAAI1F,qBAAqB,KAAKN,eAAe,EAAE;MAC7C,OAAOM,qBAAqB;IAC9B;IACA,OAAOR,oBAAoB;EAC7B,CAAC;EACDmG,iBAAiBA,CAAA,EAAG,CAAC;AACvB,CAAC","ignoreList":[]}
@@ -13,8 +13,9 @@ export declare class SkiaSGRoot {
13
13
  children: import("./Node").Node<unknown>[];
14
14
  isDeclaration: boolean;
15
15
  };
16
- render(element: ReactNode): void;
16
+ private updateContainer;
17
+ render(element: ReactNode): Promise<void>;
17
18
  drawOnCanvas(canvas: SkCanvas): void;
18
19
  getPicture(): import("../skia/types").SkPicture;
19
- unmount(): void;
20
+ unmount(): Promise<unknown>;
20
21
  }
@@ -29,12 +29,18 @@ export class SkiaSGRoot {
29
29
  isDeclaration: false
30
30
  };
31
31
  }
32
- render(element) {
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- skiaReconciler.updateContainer(element, this.root, null, () => {
35
- debug("updateContainer");
32
+ updateContainer(element) {
33
+ return new Promise(resolve => {
34
+ skiaReconciler.updateContainer(element, this.root, null, () => {
35
+ debug("updateContainer");
36
+ resolve(true);
37
+ });
36
38
  });
37
39
  }
40
+ async render(element) {
41
+ await this.updateContainer(element);
42
+ this.container.redraw();
43
+ }
38
44
  drawOnCanvas(canvas) {
39
45
  this.container.drawOnCanvas(canvas);
40
46
  }
@@ -46,8 +52,11 @@ export class SkiaSGRoot {
46
52
  }
47
53
  unmount() {
48
54
  this.container.unmount();
49
- skiaReconciler.updateContainer(null, this.root, null, () => {
50
- debug("unmountContainer");
55
+ return new Promise(resolve => {
56
+ skiaReconciler.updateContainer(null, this.root, null, () => {
57
+ debug("unmountContainer");
58
+ resolve(true);
59
+ });
51
60
  });
52
61
  }
53
62
  }
@@ -1 +1 @@
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\";\nimport \"./Elements\";\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 this.container.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;AAC7C,OAAO,YAAY;AAEnB,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,CA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","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","console","error","sg","children","type","Group","props","isDeclaration","updateContainer","element","Promise","resolve","render","redraw","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\";\nimport \"./Elements\";\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 private updateContainer(element: ReactNode) {\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n debug(\"updateContainer\");\n resolve(true);\n });\n });\n }\n\n async render(element: ReactNode) {\n await this.updateContainer(element);\n this.container.redraw();\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.unmount();\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(null, this.root,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,CAAC;QACxB0B,OAAO,CAAC,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,MAAMC,MAAMA,CAACH,OAAkB,EAAE;IAC/B,MAAM,IAAI,CAACD,eAAe,CAACC,OAAO,CAAC;IACnC,IAAI,CAACX,SAAS,CAACe,MAAM,CAAC,CAAC;EACzB;EAEAC,YAAYA,CAACC,MAAgB,EAAE;IAC7B,IAAI,CAACjB,SAAS,CAACgB,YAAY,CAACC,MAAM,CAAC;EACrC;EAEAC,UAAUA,CAAA,EAAG;IACX,MAAMC,QAAQ,GAAG,IAAI,CAACtB,IAAI,CAACuB,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,CAACvB,SAAS,CAACuB,OAAO,CAAC,CAAC;IACxB,OAAO,IAAIX,OAAO,CAAEC,OAAO,IAAK;MAC9BvB,cAAc,CAACoB,eAAe,CAAC,IAAI,EAAE,IAAI,CAACT,IAAI,EAAE,IAAI,EAAE,MAAM;QAC1Dd,KAAK,CAAC,kBAAkB,CAAC;QACzB0B,OAAO,CAAC,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -3,4 +3,4 @@ export function makeOffscreenSurface(width: any, height: any): any;
3
3
  export function getSkiaExports(): {
4
4
  Skia: any;
5
5
  };
6
- export function drawOffscreen(surface: any, element: any): any;
6
+ export function drawOffscreen(surface: any, element: any): Promise<any>;
@@ -1,3 +1,11 @@
1
1
  export const __esModule: boolean;
2
- export const Canvas: any;
3
2
  export function useCanvasRef(): any;
3
+ export function Canvas({ debug, opaque, children, onSize, onLayout: _onLayout, ref, ...viewProps }: {
4
+ [x: string]: any;
5
+ debug: any;
6
+ opaque: any;
7
+ children: any;
8
+ onSize: any;
9
+ onLayout: any;
10
+ ref: any;
11
+ }): any;
@@ -1,5 +1,5 @@
1
1
  export const __esModule: boolean;
2
2
  export function isOnMainThread(): boolean;
3
- export function drawAsPicture(element: any, bounds: any): import("../../..").SkPicture;
4
- export function drawAsImage(element: any, size: any): import("../../..").SkImage;
3
+ export function drawAsPicture(element: any, bounds: any): Promise<import("../../..").SkPicture>;
4
+ export function drawAsImage(element: any, size: any): Promise<import("../../..").SkImage>;
5
5
  export function drawAsImageFromPicture(picture: any, size: any): import("../../..").SkImage;
@@ -3,6 +3,9 @@ export class Container {
3
3
  constructor(Skia: any, nativeId: any);
4
4
  Skia: any;
5
5
  nativeId: any;
6
+ set root(value: any);
7
+ get root(): any;
8
+ _root: any;
6
9
  unmount(): void;
7
10
  unmounted: boolean | undefined;
8
11
  drawOnCanvas(canvas: any): void;
@@ -7,8 +7,8 @@ export namespace sksgHostConfig {
7
7
  let scheduleTimeout: typeof setTimeout;
8
8
  let cancelTimeout: typeof clearTimeout;
9
9
  let noTimeout: number;
10
- function getRootHostContext(_rootContainerInstance: any): null;
11
- function getChildHostContext(_parentHostContext: any, _type: any, _rootContainerInstance: any): null;
10
+ function getRootHostContext(_rootContainerInstance: any): {};
11
+ function getChildHostContext(_parentHostContext: any, _type: any, _rootContainerInstance: any): {};
12
12
  function shouldSetTextContent(_type: any, _props: any): boolean;
13
13
  function createTextInstance(_text: any, _rootContainerInstance: any, _hostContext: any, _internalInstanceHandle: any): never;
14
14
  function createInstance(type: any, propsWithChildren: any, _container: any, _hostContext: any, _internalInstanceHandle: any): {
@@ -20,13 +20,13 @@ export namespace sksgHostConfig {
20
20
  function finalizeInitialChildren(parentInstance: any, _type: any, _props: any, _rootContainerInstance: any, _hostContext: any): boolean;
21
21
  function commitMount(): void;
22
22
  function prepareForCommit(_container: any): null;
23
- function resetAfterCommit(container: any): void;
23
+ function resetAfterCommit(_container: any): void;
24
24
  function getPublicInstance(node: any): any;
25
25
  function commitTextUpdate(_textInstance: any, _oldText: any, _newText: any): void;
26
26
  function clearContainer(_container: any): void;
27
27
  function prepareUpdate(_instance: any, _type: any, oldProps: any, newProps: any, container: any, _hostContext: any): any;
28
28
  function preparePortalMount(): void;
29
- function cloneInstance(instance: any, _updatePayload: any, _type: any, _oldProps: any, newProps: any, _internalInstanceHandle: any, keepChildren: any, _recyclableInstance: any): {
29
+ function cloneInstance(instance: any, _type: any, _oldProps: any, newProps: any, _updatePayload: any, _internalInstanceHandle: any, keepChildren: any, _recyclableInstance: any): {
30
30
  type: any;
31
31
  props: any;
32
32
  children: any[];
@@ -44,5 +44,22 @@ export namespace sksgHostConfig {
44
44
  function getInstanceFromNode(_node: any): never;
45
45
  function prepareScopeUpdate(_scopeInstance: any, _instance: any): never;
46
46
  function getInstanceFromScope(_scopeInstance: any): never;
47
+ function shouldAttemptEagerTransition(): boolean;
48
+ function trackSchedulerEvent(): void;
49
+ function resolveEventType(): null;
50
+ function resolveEventTimeStamp(): number;
51
+ function requestPostPaintCallback(): void;
52
+ function maySuspendCommit(): boolean;
53
+ function preloadInstance(): boolean;
54
+ function startSuspendingCommit(): void;
55
+ function suspendInstance(): void;
56
+ function waitForCommitToBeReady(): null;
57
+ let NotPendingTransition: null;
58
+ let HostTransitionContext: _react.Context<null>;
59
+ function setCurrentUpdatePriority(newPriority: any): void;
60
+ function getCurrentUpdatePriority(): number;
61
+ function resolveUpdatePriority(): number;
62
+ function resetFormInstance(): void;
47
63
  }
48
64
  export function debug(...args: any[]): void;
65
+ import _react = require("react");
@@ -7,6 +7,8 @@ export class SkiaSGRoot {
7
7
  mapperId: any;
8
8
  Skia: any;
9
9
  nativeId: any;
10
+ root: any;
11
+ _root: any;
10
12
  unmount(): void;
11
13
  unmounted: boolean | undefined;
12
14
  drawOnCanvas(canvas: any): void;
@@ -19,6 +21,8 @@ export class SkiaSGRoot {
19
21
  mapperId: any;
20
22
  Skia: any;
21
23
  nativeId: any;
24
+ root: any;
25
+ _root: any;
22
26
  unmount(): void;
23
27
  unmounted: boolean | undefined;
24
28
  drawOnCanvas(canvas: any): void;
@@ -31,6 +35,8 @@ export class SkiaSGRoot {
31
35
  } | undefined;
32
36
  Skia: any;
33
37
  nativeId: any;
38
+ root: any;
39
+ _root: any;
34
40
  unmount(): void;
35
41
  unmounted: boolean | undefined;
36
42
  drawOnCanvas(canvas: any): void;
@@ -42,8 +48,9 @@ export class SkiaSGRoot {
42
48
  children: any;
43
49
  isDeclaration: boolean;
44
50
  };
45
- render(element: any): void;
51
+ updateContainer(element: any): Promise<any>;
52
+ render(element: any): Promise<void>;
46
53
  drawOnCanvas(canvas: any): void;
47
54
  getPicture(): any;
48
- unmount(): void;
55
+ unmount(): Promise<any>;
49
56
  }
@@ -10,7 +10,7 @@ declare function View({ children, onLayout, style: rawStyle }: {
10
10
  onLayout: any;
11
11
  style: any;
12
12
  }): React.DetailedReactHTMLElement<{
13
- ref: React.MutableRefObject<null>;
13
+ ref: React.RefObject<null>;
14
14
  style: any;
15
15
  }, HTMLElement>;
16
16
  import React from "react";
@@ -3,4 +3,4 @@ export function makeOffscreenSurface(width: any, height: any): any;
3
3
  export function getSkiaExports(): {
4
4
  Skia: any;
5
5
  };
6
- export function drawOffscreen(surface: any, element: any): any;
6
+ export function drawOffscreen(surface: any, element: any): Promise<any>;
@@ -154,12 +154,14 @@ export function Mock(CanvasKit: any): {
154
154
  matchFont: (inputStyle?: {}, fontMgr?: import("../../..").SkFontMgr) => import("../../..").SkFont;
155
155
  listFontFamilies: (fontMgr?: import("../../..").SkFontMgr) => string[];
156
156
  makeImageFromView: (viewRef: any, callback?: null) => any;
157
- useAnimatedImage: (source: any, onError: any) => null;
157
+ useAnimatedImage: (source: any, // eslint-disable-next-line @typescript-eslint/ban-ts-comment
158
+ onError: any) => null;
158
159
  createPicture: (cb: any, rect: any) => import("../../..").SkPicture;
159
160
  vec: (x: number | undefined, y: any) => import("../../..").SkPoint;
160
161
  point: (x: number | undefined, y: any) => import("../../..").SkPoint;
161
162
  neg: (a: any) => import("../../..").SkPoint;
162
- add: (a: any, b: any) => import("../../..").SkPoint;
163
+ add: (a: any, // eslint-disable-next-line @typescript-eslint/ban-ts-comment
164
+ b: any) => import("../../..").SkPoint;
163
165
  sub: (a: any, b: any) => import("../../..").SkPoint;
164
166
  dist: (a: any, b: any) => number;
165
167
  rect: (x: any, y: any, width: any, height: any) => import("../../..").SkHostRect;
@@ -191,7 +193,8 @@ export function Mock(CanvasKit: any): {
191
193
  B: number;
192
194
  C: number;
193
195
  };
194
- MakeCubic: (B: any, C: any) => {
196
+ MakeCubic: (B: any, // Reanimated hooks
197
+ C: any) => {
195
198
  B: any;
196
199
  C: any;
197
200
  };
@@ -281,13 +284,15 @@ export function Mock(CanvasKit: any): {
281
284
  RoundedRect: (props: any) => import("react").DOMElement<any, Element>;
282
285
  DiffRect: (props: any) => import("react").DOMElement<any, Element>;
283
286
  Line: (props: any) => import("react").DOMElement<any, Element>;
284
- Path: ({ start, end, ...props }: {
287
+ Path: (// @ts-ignore
288
+ { start, end, ...props }: {
285
289
  [x: string]: any;
286
290
  start?: number | undefined;
287
291
  end?: number | undefined;
288
292
  }) => import("react").DOMElement<any, Element>;
289
293
  Oval: (props: any) => import("react").DOMElement<any, Element>;
290
- Points: ({ mode, ...props }: {
294
+ Points: (// @ts-ignore
295
+ { mode, ...props }: {
291
296
  [x: string]: any;
292
297
  mode?: string | undefined;
293
298
  }) => import("react").DOMElement<any, Element>;
@@ -347,7 +352,8 @@ export function Mock(CanvasKit: any): {
347
352
  filter: any;
348
353
  children: any;
349
354
  }>;
350
- Image: ({ fit, ...props }: {
355
+ Image: (// @ts-ignore
356
+ { fit, ...props }: {
351
357
  [x: string]: any;
352
358
  fit?: string | undefined;
353
359
  }) => import("react").DOMElement<any, Element>;
@@ -376,7 +382,8 @@ export function Mock(CanvasKit: any): {
376
382
  tileWidth?: number | undefined;
377
383
  tileHeight?: number | undefined;
378
384
  }) => import("react").DOMElement<any, Element>;
379
- Shader: ({ uniforms, ...props }: {
385
+ Shader: (// @ts-ignore
386
+ { uniforms, ...props }: {
380
387
  [x: string]: any;
381
388
  uniforms?: {} | undefined;
382
389
  }) => import("react").DOMElement<any, Element>;
@@ -384,12 +391,14 @@ export function Mock(CanvasKit: any): {
384
391
  Math: string;
385
392
  Colors: string;
386
393
  };
387
- Text: ({ x, y, ...props }: {
394
+ Text: (// @ts-ignore
395
+ { x, y, ...props }: {
388
396
  [x: string]: any;
389
397
  x?: number | undefined;
390
398
  y?: number | undefined;
391
399
  }) => import("react").DOMElement<any, Element>;
392
- Glyphs: ({ x, y, ...props }: {
400
+ Glyphs: (// @ts-ignore
401
+ { x, y, ...props }: {
393
402
  [x: string]: any;
394
403
  x?: number | undefined;
395
404
  y?: number | undefined;
@@ -415,11 +424,13 @@ export function Mock(CanvasKit: any): {
415
424
  style?: string | undefined;
416
425
  respectCTM?: boolean | undefined;
417
426
  }) => import("react").DOMElement<any, Element>;
418
- Blur: ({ mode, ...props }: {
427
+ Blur: (// @ts-ignore
428
+ { mode, ...props }: {
419
429
  [x: string]: any;
420
430
  mode?: string | undefined;
421
431
  }) => import("react").DOMElement<any, Element>;
422
- Offset: ({ x, y, ...props }: {
432
+ Offset: (// @ts-ignore
433
+ { x, y, ...props }: {
423
434
  [x: string]: any;
424
435
  x?: number | undefined;
425
436
  y?: number | undefined;
@@ -1,3 +1,11 @@
1
- export function useCanvasRef(): React.MutableRefObject<null>;
2
- export const Canvas: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
1
+ export function useCanvasRef(): React.RefObject<null>;
2
+ export function Canvas({ debug, opaque, children, onSize, onLayout: _onLayout, ref, ...viewProps }: {
3
+ [x: string]: any;
4
+ debug: any;
5
+ opaque: any;
6
+ children: any;
7
+ onSize: any;
8
+ onLayout: any;
9
+ ref: any;
10
+ }): React.CElement<object, React.Component<object, {}, any> & import("react-native").NativeMethods>;
3
11
  import React from "react";