@shopify/react-native-skia 2.2.6 → 2.2.8

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 (93) hide show
  1. package/cpp/api/recorder/DrawingCtx.h +15 -0
  2. package/cpp/api/recorder/JsiRecorder.h +2 -1
  3. package/cpp/api/recorder/RNRecorder.h +2 -2
  4. package/cpp/api/recorder/Shaders.h +6 -5
  5. package/lib/commonjs/skia/types/Recorder.d.ts +1 -1
  6. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  7. package/lib/commonjs/sksg/Container.d.ts +3 -39
  8. package/lib/commonjs/sksg/Container.js +3 -195
  9. package/lib/commonjs/sksg/Container.js.map +1 -1
  10. package/lib/commonjs/sksg/Container.native.d.ts +14 -0
  11. package/lib/commonjs/sksg/Container.native.js +81 -0
  12. package/lib/commonjs/sksg/Container.native.js.map +1 -0
  13. package/lib/commonjs/sksg/Container.web.d.ts +14 -0
  14. package/lib/commonjs/sksg/Container.web.js +91 -0
  15. package/lib/commonjs/sksg/Container.web.js.map +1 -0
  16. package/lib/commonjs/sksg/HostConfig.d.ts +1 -1
  17. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  18. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  19. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  20. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +2 -2
  21. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  22. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
  23. package/lib/commonjs/sksg/Recorder/Recorder.js +3 -2
  24. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  25. package/lib/commonjs/sksg/Recorder/Visitor.js +2 -2
  26. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  27. package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
  28. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  29. package/lib/commonjs/sksg/StaticContainer.d.ts +24 -0
  30. package/lib/commonjs/sksg/StaticContainer.js +70 -0
  31. package/lib/commonjs/sksg/StaticContainer.js.map +1 -0
  32. package/lib/module/skia/types/Recorder.d.ts +1 -1
  33. package/lib/module/skia/types/Recorder.js.map +1 -1
  34. package/lib/module/sksg/Container.d.ts +3 -39
  35. package/lib/module/sksg/Container.js +2 -192
  36. package/lib/module/sksg/Container.js.map +1 -1
  37. package/lib/module/sksg/Container.native.d.ts +14 -0
  38. package/lib/module/sksg/Container.native.js +73 -0
  39. package/lib/module/sksg/Container.native.js.map +1 -0
  40. package/lib/module/sksg/Container.web.d.ts +14 -0
  41. package/lib/module/sksg/Container.web.js +83 -0
  42. package/lib/module/sksg/Container.web.js.map +1 -0
  43. package/lib/module/sksg/HostConfig.d.ts +1 -1
  44. package/lib/module/sksg/HostConfig.js.map +1 -1
  45. package/lib/module/sksg/Reconciler.js.map +1 -1
  46. package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  47. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +2 -2
  48. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  49. package/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
  50. package/lib/module/sksg/Recorder/Recorder.js +3 -2
  51. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  52. package/lib/module/sksg/Recorder/Visitor.js +2 -2
  53. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  54. package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
  55. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  56. package/lib/module/sksg/StaticContainer.d.ts +24 -0
  57. package/lib/module/sksg/StaticContainer.js +62 -0
  58. package/lib/module/sksg/StaticContainer.js.map +1 -0
  59. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +2 -42
  60. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +11 -0
  61. package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +15 -0
  62. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +1 -45
  63. package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  64. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
  65. package/lib/typescript/lib/commonjs/sksg/StaticContainer.d.ts +23 -0
  66. package/lib/typescript/lib/module/sksg/Container.d.ts +2 -42
  67. package/lib/typescript/lib/module/sksg/Container.native.d.ts +11 -0
  68. package/lib/typescript/lib/module/sksg/Container.web.d.ts +15 -0
  69. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +1 -45
  70. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  71. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
  72. package/lib/typescript/lib/module/sksg/StaticContainer.d.ts +22 -0
  73. package/lib/typescript/src/skia/types/Recorder.d.ts +1 -1
  74. package/lib/typescript/src/sksg/Container.d.ts +3 -39
  75. package/lib/typescript/src/sksg/Container.native.d.ts +14 -0
  76. package/lib/typescript/src/sksg/Container.web.d.ts +14 -0
  77. package/lib/typescript/src/sksg/HostConfig.d.ts +1 -1
  78. package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  79. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +1 -1
  80. package/lib/typescript/src/sksg/StaticContainer.d.ts +24 -0
  81. package/package.json +1 -1
  82. package/src/renderer/__tests__/e2e/Shader.spec.tsx +93 -0
  83. package/src/skia/types/Recorder.ts +5 -1
  84. package/src/sksg/Container.native.ts +86 -0
  85. package/src/sksg/Container.ts +3 -223
  86. package/src/sksg/Container.web.ts +95 -0
  87. package/src/sksg/HostConfig.ts +1 -1
  88. package/src/sksg/Reconciler.ts +1 -1
  89. package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -2
  90. package/src/sksg/Recorder/Recorder.ts +6 -2
  91. package/src/sksg/Recorder/Visitor.ts +2 -2
  92. package/src/sksg/Recorder/commands/Shaders.ts +8 -3
  93. package/src/sksg/StaticContainer.ts +83 -0
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StaticContainer = exports.Container = void 0;
7
+ var _Recorder = require("./Recorder/Recorder");
8
+ var _Visitor = require("./Recorder/Visitor");
9
+ var _Player = require("./Recorder/Player");
10
+ var _DrawingContext = require("./Recorder/DrawingContext");
11
+ require("../views/api");
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ class Container {
16
+ constructor(Skia) {
17
+ this.Skia = Skia;
18
+ _defineProperty(this, "_root", []);
19
+ _defineProperty(this, "recording", null);
20
+ _defineProperty(this, "unmounted", false);
21
+ }
22
+ get root() {
23
+ return this._root;
24
+ }
25
+ set root(value) {
26
+ this._root = value;
27
+ }
28
+ mount() {
29
+ this.unmounted = false;
30
+ }
31
+ unmount() {
32
+ this.unmounted = true;
33
+ }
34
+ drawOnCanvas(canvas) {
35
+ if (!this.recording) {
36
+ throw new Error("No recording to draw");
37
+ }
38
+ const ctx = (0, _DrawingContext.createDrawingContext)(this.Skia, this.recording.paintPool, canvas);
39
+ (0, _Player.replay)(ctx, this.recording.commands);
40
+ }
41
+ }
42
+ exports.Container = Container;
43
+ class StaticContainer extends Container {
44
+ constructor(Skia, nativeId, onSize) {
45
+ super(Skia);
46
+ this.nativeId = nativeId;
47
+ this.onSize = onSize;
48
+ }
49
+ redraw() {
50
+ const recorder = new _Recorder.Recorder();
51
+ (0, _Visitor.visit)(recorder, this.root);
52
+ this.recording = recorder.getRecording();
53
+ const isOnScreen = this.nativeId !== -1;
54
+ if (isOnScreen) {
55
+ if (this.onSize) {
56
+ const size = SkiaViewApi.size(this.nativeId);
57
+ if (size.width !== this.onSize.value.width || size.height !== this.onSize.value.height) {
58
+ this.onSize.value = size;
59
+ }
60
+ }
61
+ const rec = this.Skia.PictureRecorder();
62
+ const canvas = rec.beginRecording();
63
+ this.drawOnCanvas(canvas);
64
+ const picture = rec.finishRecordingAsPicture();
65
+ SkiaViewApi.setJsiProperty(this.nativeId, "picture", picture);
66
+ }
67
+ }
68
+ }
69
+ exports.StaticContainer = StaticContainer;
70
+ //# sourceMappingURL=StaticContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Recorder","require","_Visitor","_Player","_DrawingContext","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Container","constructor","Skia","root","_root","mount","unmounted","unmount","drawOnCanvas","canvas","recording","Error","ctx","createDrawingContext","paintPool","replay","commands","exports","StaticContainer","nativeId","onSize","redraw","recorder","Recorder","visit","getRecording","isOnScreen","size","SkiaViewApi","width","height","rec","PictureRecorder","beginRecording","picture","finishRecordingAsPicture","setJsiProperty"],"sources":["StaticContainer.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Skia, SkCanvas, SkSize } from \"../skia/types\";\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\";\n\nimport \"../views/api\";\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) {}\n\n get root() {\n return this._root;\n }\n\n set root(value: Node[]) {\n this._root = value;\n }\n\n mount() {\n this.unmounted = false;\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\nexport class StaticContainer extends Container {\n constructor(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\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 if (this.onSize) {\n const size = SkiaViewApi.size(this.nativeId);\n if (\n size.width !== this.onSize.value.width ||\n size.height !== this.onSize.value.height\n ) {\n this.onSize.value = size;\n }\n }\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"],"mappings":";;;;;;AAMA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEAA,OAAA;AAAsB,SAAAI,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAA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order {
12
12
  pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;
13
13
  pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>): void;
14
14
  pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>): void;
15
- pushShader(shaderType: NodeType, props: AnimatedProps<unknown>): void;
15
+ pushShader(shaderType: NodeType, props: AnimatedProps<unknown>, children: number): void;
16
16
  pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;
17
17
  composePathEffect(): void;
18
18
  composeColorFilter(): void;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Recorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n TextProps,\n AtlasProps,\n BlurMaskFilterProps,\n BoxProps,\n BoxShadowProps,\n CircleProps,\n CTMProps,\n DiffRectProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n NodeType,\n OvalProps,\n PaintProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextBlobProps,\n TextPathProps,\n VerticesProps,\n SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer/processors/Animations/Animations\";\n\nimport type { SkPicture } from \"./Picture\";\n\nexport interface BaseRecorder {\n saveGroup(): void;\n restoreGroup(): void;\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;\n restorePaint(): void;\n restorePaintDeclaration(): void;\n materializePaint(): void;\n pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushShader(shaderType: NodeType, props: AnimatedProps<unknown>): void;\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;\n composePathEffect(): void;\n composeColorFilter(): void;\n composeImageFilter(): void;\n saveCTM(props: AnimatedProps<CTMProps>): void;\n restoreCTM(): void;\n drawPaint(): void;\n saveLayer(): void;\n saveBackdropFilter(): void;\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n animatedProps?: Record<string, SharedValue<unknown>>;\n }[]\n ): void;\n drawImage(props: AnimatedProps<ImageProps>): void;\n drawCircle(props: AnimatedProps<CircleProps>): void;\n drawPoints(props: AnimatedProps<PointsProps>): void;\n drawPath(props: AnimatedProps<PathProps>): void;\n drawRect(props: AnimatedProps<RectProps>): void;\n drawRRect(props: AnimatedProps<RoundedRectProps>): void;\n drawOval(props: AnimatedProps<OvalProps>): void;\n drawLine(props: AnimatedProps<LineProps>): void;\n drawPatch(props: AnimatedProps<PatchProps>): void;\n drawVertices(props: AnimatedProps<VerticesProps>): void;\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void;\n drawText(props: AnimatedProps<TextProps>): void;\n drawTextPath(props: AnimatedProps<TextPathProps>): void;\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void;\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void;\n drawPicture(props: AnimatedProps<PictureProps>): void;\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void;\n drawParagraph(props: AnimatedProps<ParagraphProps>): void;\n drawSkottie(props: AnimatedProps<SkottieProps>): void;\n drawAtlas(props: AnimatedProps<AtlasProps>): void;\n}\n\nexport interface JsiRecorder extends BaseRecorder {\n play(): SkPicture;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["Recorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n TextProps,\n AtlasProps,\n BlurMaskFilterProps,\n BoxProps,\n BoxShadowProps,\n CircleProps,\n CTMProps,\n DiffRectProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n NodeType,\n OvalProps,\n PaintProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextBlobProps,\n TextPathProps,\n VerticesProps,\n SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer/processors/Animations/Animations\";\n\nimport type { SkPicture } from \"./Picture\";\n\nexport interface BaseRecorder {\n saveGroup(): void;\n restoreGroup(): void;\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;\n restorePaint(): void;\n restorePaintDeclaration(): void;\n materializePaint(): void;\n pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushShader(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): void;\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;\n composePathEffect(): void;\n composeColorFilter(): void;\n composeImageFilter(): void;\n saveCTM(props: AnimatedProps<CTMProps>): void;\n restoreCTM(): void;\n drawPaint(): void;\n saveLayer(): void;\n saveBackdropFilter(): void;\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n animatedProps?: Record<string, SharedValue<unknown>>;\n }[]\n ): void;\n drawImage(props: AnimatedProps<ImageProps>): void;\n drawCircle(props: AnimatedProps<CircleProps>): void;\n drawPoints(props: AnimatedProps<PointsProps>): void;\n drawPath(props: AnimatedProps<PathProps>): void;\n drawRect(props: AnimatedProps<RectProps>): void;\n drawRRect(props: AnimatedProps<RoundedRectProps>): void;\n drawOval(props: AnimatedProps<OvalProps>): void;\n drawLine(props: AnimatedProps<LineProps>): void;\n drawPatch(props: AnimatedProps<PatchProps>): void;\n drawVertices(props: AnimatedProps<VerticesProps>): void;\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void;\n drawText(props: AnimatedProps<TextProps>): void;\n drawTextPath(props: AnimatedProps<TextPathProps>): void;\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void;\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void;\n drawPicture(props: AnimatedProps<PictureProps>): void;\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void;\n drawParagraph(props: AnimatedProps<ParagraphProps>): void;\n drawSkottie(props: AnimatedProps<SkottieProps>): void;\n drawAtlas(props: AnimatedProps<AtlasProps>): void;\n}\n\nexport interface JsiRecorder extends BaseRecorder {\n play(): SkPicture;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,40 +1,4 @@
1
1
  import type { SharedValue } from "react-native-reanimated";
2
- import type { Skia, SkCanvas, SkSize } from "../skia/types";
3
- import type { Node } from "./Node";
4
- import type { Recording } from "./Recorder/Recorder";
5
- import "../views/api";
6
- export declare abstract class Container {
7
- protected Skia: Skia;
8
- private _root;
9
- protected recording: Recording | null;
10
- protected unmounted: boolean;
11
- constructor(Skia: Skia);
12
- get root(): Node[];
13
- set root(value: Node[]);
14
- mount(): void;
15
- unmount(): void;
16
- drawOnCanvas(canvas: SkCanvas): void;
17
- abstract redraw(): void;
18
- }
19
- declare class StaticContainer extends Container {
20
- private nativeId;
21
- private onSize?;
22
- constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
23
- redraw(): void;
24
- }
25
- declare class ReanimatedContainer extends Container {
26
- private nativeId;
27
- private onSize?;
28
- private mapperId;
29
- constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
30
- redraw(): void;
31
- }
32
- declare class NativeReanimatedContainer extends Container {
33
- private nativeId;
34
- private onSize?;
35
- private mapperId;
36
- constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
37
- redraw(): void;
38
- }
39
- export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | ReanimatedContainer | NativeReanimatedContainer;
40
- export {};
2
+ import type { Skia, SkSize } from "../skia/types";
3
+ import { StaticContainer } from "./StaticContainer";
4
+ export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer;
@@ -1,195 +1,5 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- import Rea from "../external/reanimated/ReanimatedProxy";
5
- import { HAS_REANIMATED_3 } from "../external/reanimated/renderHelpers";
6
- import { Recorder } from "./Recorder/Recorder";
7
- import { visit } from "./Recorder/Visitor";
8
- import { replay } from "./Recorder/Player";
9
- import { createDrawingContext } from "./Recorder/DrawingContext";
10
- import { ReanimatedRecorder } from "./Recorder/ReanimatedRecorder";
11
- import "../views/api";
12
- const drawOnscreen = (Skia, nativeId, recording, onSize) => {
13
- "worklet";
14
-
15
- if (onSize) {
16
- const size = SkiaViewApi.size(nativeId);
17
- if (size.width !== onSize.value.width || size.height !== onSize.value.height) {
18
- onSize.value = size;
19
- }
20
- }
21
- const rec = Skia.PictureRecorder();
22
- const canvas = rec.beginRecording();
23
- //const start = performance.now();
24
-
25
- const ctx = createDrawingContext(Skia, recording.paintPool, canvas);
26
- replay(ctx, recording.commands);
27
- const picture = rec.finishRecordingAsPicture();
28
- //const end = performance.now();
29
- //console.log("Recording time: ", end - start);
30
- SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
31
- };
32
- const nativeDrawOnscreen = (nativeId, recorder, onSize) => {
33
- "worklet";
34
-
35
- //const start = performance.now();
36
- if (onSize) {
37
- const size = SkiaViewApi.size(nativeId);
38
- if (size.width !== onSize.value.width || size.height !== onSize.value.height) {
39
- onSize.value = size;
40
- }
41
- }
42
- const picture = recorder.play();
43
- //const end = performance.now();
44
- //console.log("Recording time: ", end - start);
45
- SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
46
- };
47
- export class Container {
48
- constructor(Skia) {
49
- this.Skia = Skia;
50
- _defineProperty(this, "_root", []);
51
- _defineProperty(this, "recording", null);
52
- _defineProperty(this, "unmounted", false);
53
- }
54
- get root() {
55
- return this._root;
56
- }
57
- set root(value) {
58
- this._root = value;
59
- }
60
- mount() {
61
- this.unmounted = false;
62
- }
63
- unmount() {
64
- this.unmounted = true;
65
- }
66
- drawOnCanvas(canvas) {
67
- if (!this.recording) {
68
- throw new Error("No recording to draw");
69
- }
70
- const ctx = createDrawingContext(this.Skia, this.recording.paintPool, canvas);
71
- replay(ctx, this.recording.commands);
72
- }
73
- }
74
- class StaticContainer extends Container {
75
- constructor(Skia, nativeId, onSize) {
76
- super(Skia);
77
- this.nativeId = nativeId;
78
- this.onSize = onSize;
79
- }
80
- redraw() {
81
- const recorder = new Recorder();
82
- visit(recorder, this.root);
83
- this.recording = recorder.getRecording();
84
- const isOnScreen = this.nativeId !== -1;
85
- if (isOnScreen) {
86
- if (this.onSize) {
87
- const size = SkiaViewApi.size(this.nativeId);
88
- if (size.width !== this.onSize.value.width || size.height !== this.onSize.value.height) {
89
- this.onSize.value = size;
90
- }
91
- }
92
- const rec = this.Skia.PictureRecorder();
93
- const canvas = rec.beginRecording();
94
- this.drawOnCanvas(canvas);
95
- const picture = rec.finishRecordingAsPicture();
96
- SkiaViewApi.setJsiProperty(this.nativeId, "picture", picture);
97
- }
98
- }
99
- }
100
- class ReanimatedContainer extends Container {
101
- constructor(Skia, nativeId, onSize) {
102
- super(Skia);
103
- this.nativeId = nativeId;
104
- this.onSize = onSize;
105
- _defineProperty(this, "mapperId", null);
106
- }
107
- redraw() {
108
- if (this.mapperId !== null) {
109
- Rea.stopMapper(this.mapperId);
110
- }
111
- if (this.unmounted) {
112
- return;
113
- }
114
- const recorder = new Recorder();
115
- visit(recorder, this.root);
116
- const record = recorder.getRecording();
117
- const {
118
- animationValues
119
- } = record;
120
- this.recording = {
121
- commands: record.commands,
122
- paintPool: record.paintPool
123
- };
124
- const {
125
- nativeId,
126
- Skia,
127
- recording
128
- } = this;
129
- if (animationValues.size > 0) {
130
- this.mapperId = Rea.startMapper(() => {
131
- "worklet";
132
-
133
- drawOnscreen(Skia, nativeId, recording);
134
- }, Array.from(animationValues));
135
- }
136
- Rea.runOnUI(onSize => {
137
- "worklet";
138
-
139
- drawOnscreen(Skia, nativeId, recording, onSize);
140
- })(this.onSize);
141
- }
142
- }
143
- class NativeReanimatedContainer extends Container {
144
- constructor(Skia, nativeId, onSize) {
145
- super(Skia);
146
- this.nativeId = nativeId;
147
- this.onSize = onSize;
148
- _defineProperty(this, "mapperId", null);
149
- }
150
- redraw() {
151
- if (this.mapperId !== null) {
152
- Rea.stopMapper(this.mapperId);
153
- }
154
- if (this.unmounted) {
155
- return;
156
- }
157
- const {
158
- nativeId,
159
- Skia
160
- } = this;
161
- const recorder = new ReanimatedRecorder(Skia);
162
- visit(recorder, this.root);
163
- const sharedValues = recorder.getSharedValues();
164
- const sharedRecorder = recorder.getRecorder();
165
- Rea.runOnUI(onSize => {
166
- "worklet";
167
-
168
- nativeDrawOnscreen(nativeId, sharedRecorder, onSize);
169
- })(this.onSize);
170
- if (sharedValues.length > 0) {
171
- const {
172
- onSize
173
- } = this;
174
- this.mapperId = Rea.startMapper(() => {
175
- "worklet";
176
-
177
- sharedRecorder.applyUpdates(sharedValues);
178
- nativeDrawOnscreen(nativeId, sharedRecorder, onSize);
179
- }, sharedValues);
180
- }
181
- }
182
- }
1
+ import { StaticContainer } from "./StaticContainer";
183
2
  export const createContainer = (Skia, nativeId, onSize) => {
184
- const web = global.SkiaViewApi && global.SkiaViewApi.web;
185
- if (HAS_REANIMATED_3 && nativeId !== -1) {
186
- if (!web) {
187
- return new NativeReanimatedContainer(Skia, nativeId, onSize);
188
- } else {
189
- return new ReanimatedContainer(Skia, nativeId, onSize);
190
- }
191
- } else {
192
- return new StaticContainer(Skia, nativeId);
193
- }
3
+ return new StaticContainer(Skia, nativeId, onSize);
194
4
  };
195
5
  //# sourceMappingURL=Container.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","ReanimatedRecorder","drawOnscreen","Skia","nativeId","recording","onSize","size","SkiaViewApi","width","value","height","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","setJsiProperty","nativeDrawOnscreen","recorder","play","Container","constructor","_defineProperty","root","_root","mount","unmounted","unmount","drawOnCanvas","Error","StaticContainer","redraw","getRecording","isOnScreen","ReanimatedContainer","mapperId","stopMapper","record","animationValues","startMapper","Array","from","runOnUI","NativeReanimatedContainer","sharedValues","getSharedValues","sharedRecorder","getRecorder","length","applyUpdates","createContainer","web","global"],"sources":["Container.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas, SkSize } 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 = (\n Skia: Skia,\n nativeId: number,\n recording: Recording,\n onSize?: SharedValue<SkSize>\n) => {\n \"worklet\";\n if (onSize) {\n const size = SkiaViewApi.size(nativeId);\n if (\n size.width !== onSize.value.width ||\n size.height !== onSize.value.height\n ) {\n onSize.value = size;\n }\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 = (\n nativeId: number,\n recorder: JsiRecorder,\n onSize?: SharedValue<SkSize>\n) => {\n \"worklet\";\n\n //const start = performance.now();\n if (onSize) {\n const size = SkiaViewApi.size(nativeId);\n if (\n size.width !== onSize.value.width ||\n size.height !== onSize.value.height\n ) {\n onSize.value = size;\n }\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) {}\n\n get root() {\n return this._root;\n }\n\n set root(value: Node[]) {\n this._root = value;\n }\n\n mount() {\n this.unmounted = false;\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(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\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 if (this.onSize) {\n const size = SkiaViewApi.size(this.nativeId);\n if (\n size.width !== this.onSize.value.width ||\n size.height !== this.onSize.value.height\n ) {\n this.onSize.value = size;\n }\n }\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(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\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((onSize?: SharedValue<SkSize>) => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!, onSize);\n })(this.onSize);\n }\n}\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\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((onSize?: SharedValue<SkSize>) => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, onSize);\n })(this.onSize);\n if (sharedValues.length > 0) {\n const { onSize } = this;\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, onSize);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n onSize?: SharedValue<SkSize>\n) => {\n const web = global.SkiaViewApi && global.SkiaViewApi.web;\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n if (!web) {\n return new NativeReanimatedContainer(Skia, nativeId, onSize);\n } else {\n return new ReanimatedContainer(Skia, nativeId, onSize);\n }\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAEA,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,CACnBC,IAAU,EACVC,QAAgB,EAChBC,SAAoB,EACpBC,MAA4B,KACzB;EACH,SAAS;;EACT,IAAIA,MAAM,EAAE;IACV,MAAMC,IAAI,GAAGC,WAAW,CAACD,IAAI,CAACH,QAAQ,CAAC;IACvC,IACEG,IAAI,CAACE,KAAK,KAAKH,MAAM,CAACI,KAAK,CAACD,KAAK,IACjCF,IAAI,CAACI,MAAM,KAAKL,MAAM,CAACI,KAAK,CAACC,MAAM,EACnC;MACAL,MAAM,CAACI,KAAK,GAAGH,IAAI;IACrB;EACF;EACA,MAAMK,GAAG,GAAGT,IAAI,CAACU,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;;EAEA,MAAMC,GAAG,GAAGhB,oBAAoB,CAACG,IAAI,EAAEE,SAAS,CAACY,SAAS,EAAEH,MAAM,CAAC;EACnEf,MAAM,CAACiB,GAAG,EAAEX,SAAS,CAACa,QAAQ,CAAC;EAC/B,MAAMC,OAAO,GAAGP,GAAG,CAACQ,wBAAwB,CAAC,CAAC;EAC9C;EACA;EACAZ,WAAW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AAS;;QACTO,cAAc,CAACG,YAAY,CAACL,YAAY,CAAC;QACzC3B,kBAAkB,CAAClB,QAAQ,EAAE+C,cAAc,EAAE7C,MAAM,CAAC;MACtD,CAAC,EAAE2C,YAAY,CAAC;IAClB;EACF;AACF;AAEA,OAAO,MAAMM,eAAe,GAAGA,CAC7BpD,IAAU,EACVC,QAAgB,EAChBE,MAA4B,KACzB;EACH,MAAMkD,GAAG,GAAGC,MAAM,CAACjD,WAAW,IAAIiD,MAAM,CAACjD,WAAW,CAACgD,GAAG;EACxD,IAAI5D,gBAAgB,IAAIQ,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,IAAI,CAACoD,GAAG,EAAE;MACR,OAAO,IAAIR,yBAAyB,CAAC7C,IAAI,EAAEC,QAAQ,EAAEE,MAAM,CAAC;IAC9D,CAAC,MAAM;MACL,OAAO,IAAIiC,mBAAmB,CAACpC,IAAI,EAAEC,QAAQ,EAAEE,MAAM,CAAC;IACxD;EACF,CAAC,MAAM;IACL,OAAO,IAAI6B,eAAe,CAAChC,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["StaticContainer","createContainer","Skia","nativeId","onSize"],"sources":["Container.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Skia, SkSize } from \"../skia/types\";\n\nimport { StaticContainer } from \"./StaticContainer\";\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n onSize?: SharedValue<SkSize>\n) => {\n return new StaticContainer(Skia, nativeId, onSize);\n};\n"],"mappings":"AAIA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,IAAU,EACVC,QAAgB,EAChBC,MAA4B,KACzB;EACH,OAAO,IAAIJ,eAAe,CAACE,IAAI,EAAEC,QAAQ,EAAEC,MAAM,CAAC;AACpD,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import type { SharedValue } from "react-native-reanimated";
2
+ import type { Skia, SkSize } from "../skia/types";
3
+ import { Container, StaticContainer } from "./StaticContainer";
4
+ import "../skia/NativeSetup";
5
+ import "../views/api";
6
+ declare class NativeReanimatedContainer extends Container {
7
+ private nativeId;
8
+ private onSize?;
9
+ private mapperId;
10
+ constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
11
+ redraw(): void;
12
+ }
13
+ export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | NativeReanimatedContainer;
14
+ export {};
@@ -0,0 +1,73 @@
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
+ import Rea from "../external/reanimated/ReanimatedProxy";
5
+ import { HAS_REANIMATED_3 } from "../external/reanimated/renderHelpers";
6
+ import { ReanimatedRecorder } from "./Recorder/ReanimatedRecorder";
7
+ import { Container, StaticContainer } from "./StaticContainer";
8
+ import { visit } from "./Recorder/Visitor";
9
+ import "../skia/NativeSetup";
10
+ import "../views/api";
11
+ const nativeDrawOnscreen = (nativeId, recorder, onSize) => {
12
+ "worklet";
13
+
14
+ //const start = performance.now();
15
+ if (onSize) {
16
+ const size = SkiaViewApi.size(nativeId);
17
+ if (size.width !== onSize.value.width || size.height !== onSize.value.height) {
18
+ onSize.value = size;
19
+ }
20
+ }
21
+ const picture = recorder.play();
22
+ //const end = performance.now();
23
+ //console.log("Recording time: ", end - start);
24
+ SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
25
+ };
26
+ class NativeReanimatedContainer extends Container {
27
+ constructor(Skia, nativeId, onSize) {
28
+ super(Skia);
29
+ this.nativeId = nativeId;
30
+ this.onSize = onSize;
31
+ _defineProperty(this, "mapperId", null);
32
+ }
33
+ redraw() {
34
+ if (this.mapperId !== null) {
35
+ Rea.stopMapper(this.mapperId);
36
+ }
37
+ if (this.unmounted) {
38
+ return;
39
+ }
40
+ const {
41
+ nativeId,
42
+ Skia
43
+ } = this;
44
+ const recorder = new ReanimatedRecorder(Skia);
45
+ visit(recorder, this.root);
46
+ const sharedValues = recorder.getSharedValues();
47
+ const sharedRecorder = recorder.getRecorder();
48
+ Rea.runOnUI(onSize => {
49
+ "worklet";
50
+
51
+ nativeDrawOnscreen(nativeId, sharedRecorder, onSize);
52
+ })(this.onSize);
53
+ if (sharedValues.length > 0) {
54
+ const {
55
+ onSize
56
+ } = this;
57
+ this.mapperId = Rea.startMapper(() => {
58
+ "worklet";
59
+
60
+ sharedRecorder.applyUpdates(sharedValues);
61
+ nativeDrawOnscreen(nativeId, sharedRecorder, onSize);
62
+ }, sharedValues);
63
+ }
64
+ }
65
+ }
66
+ export const createContainer = (Skia, nativeId, onSize) => {
67
+ if (HAS_REANIMATED_3 && nativeId !== -1) {
68
+ return new NativeReanimatedContainer(Skia, nativeId, onSize);
69
+ } else {
70
+ return new StaticContainer(Skia, nativeId);
71
+ }
72
+ };
73
+ //# sourceMappingURL=Container.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Rea","HAS_REANIMATED_3","ReanimatedRecorder","Container","StaticContainer","visit","nativeDrawOnscreen","nativeId","recorder","onSize","size","SkiaViewApi","width","value","height","picture","play","setJsiProperty","NativeReanimatedContainer","constructor","Skia","_defineProperty","redraw","mapperId","stopMapper","unmounted","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer"],"sources":["Container.native.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkSize } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst nativeDrawOnscreen = (\n nativeId: number,\n recorder: JsiRecorder,\n onSize?: SharedValue<SkSize>\n) => {\n \"worklet\";\n\n //const start = performance.now();\n if (onSize) {\n const size = SkiaViewApi.size(nativeId);\n if (\n size.width !== onSize.value.width ||\n size.height !== onSize.value.height\n ) {\n onSize.value = size;\n }\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\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\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((onSize?: SharedValue<SkSize>) => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, onSize);\n })(this.onSize);\n if (sharedValues.length > 0) {\n const { onSize } = this;\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, onSize);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n onSize?: SharedValue<SkSize>\n) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId, onSize);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAEA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,SAAS,EAAEC,eAAe,QAAQ,mBAAmB;AAC9D,SAASC,KAAK,QAAQ,oBAAoB;AAE1C,OAAO,qBAAqB;AAC5B,OAAO,cAAc;AAErB,MAAMC,kBAAkB,GAAGA,CACzBC,QAAgB,EAChBC,QAAqB,EACrBC,MAA4B,KACzB;EACH,SAAS;;EAET;EACA,IAAIA,MAAM,EAAE;IACV,MAAMC,IAAI,GAAGC,WAAW,CAACD,IAAI,CAACH,QAAQ,CAAC;IACvC,IACEG,IAAI,CAACE,KAAK,KAAKH,MAAM,CAACI,KAAK,CAACD,KAAK,IACjCF,IAAI,CAACI,MAAM,KAAKL,MAAM,CAACI,KAAK,CAACC,MAAM,EACnC;MACAL,MAAM,CAACI,KAAK,GAAGH,IAAI;IACrB;EACF;EACA,MAAMK,OAAO,GAAGP,QAAQ,CAACQ,IAAI,CAAC,CAAC;EAC/B;EACA;EACAL,WAAW,CAACM,cAAc,CAACV,QAAQ,EAAE,SAAS,EAAEQ,OAAO,CAAC;AAC1D,CAAC;AAED,MAAMG,yBAAyB,SAASf,SAAS,CAAC;EAGhDgB,WAAWA,CACTC,IAAU,EACFb,QAAgB,EAChBE,MAA4B,EACpC;IACA,KAAK,CAACW,IAAI,CAAC;IAAC,KAHJb,QAAgB,GAAhBA,QAAgB;IAAA,KAChBE,MAA4B,GAA5BA,MAA4B;IAAAY,eAAA,mBALJ,IAAI;EAQtC;EAEAC,MAAMA,CAAA,EAAG;IACP,IAAI,IAAI,CAACC,QAAQ,KAAK,IAAI,EAAE;MAC1BvB,GAAG,CAACwB,UAAU,CAAC,IAAI,CAACD,QAAQ,CAAC;IAC/B;IACA,IAAI,IAAI,CAACE,SA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3
+ import { Container, StaticContainer } from "./StaticContainer";
4
+ import "../skia/NativeSetup";
5
+ import "../views/api";
6
+ declare class ReanimatedContainer extends Container {
7
+ private nativeId;
8
+ private onSize?;
9
+ private mapperId;
10
+ constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
11
+ redraw(): void;
12
+ }
13
+ export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | ReanimatedContainer;
14
+ export {};
@@ -0,0 +1,83 @@
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
+ import Rea from "../external/reanimated/ReanimatedProxy";
5
+ import { HAS_REANIMATED_3 } from "../external/reanimated/renderHelpers";
6
+ import { Recorder } from "./Recorder/Recorder";
7
+ import { visit } from "./Recorder/Visitor";
8
+ import { replay } from "./Recorder/Player";
9
+ import { createDrawingContext } from "./Recorder/DrawingContext";
10
+ import { Container, StaticContainer } from "./StaticContainer";
11
+ import "../skia/NativeSetup";
12
+ import "../views/api";
13
+ const drawOnscreen = (Skia, nativeId, recording, onSize) => {
14
+ "worklet";
15
+
16
+ if (onSize) {
17
+ const size = SkiaViewApi.size(nativeId);
18
+ if (size.width !== onSize.value.width || size.height !== onSize.value.height) {
19
+ onSize.value = size;
20
+ }
21
+ }
22
+ const rec = Skia.PictureRecorder();
23
+ const canvas = rec.beginRecording();
24
+ //const start = performance.now();
25
+
26
+ const ctx = createDrawingContext(Skia, recording.paintPool, canvas);
27
+ replay(ctx, recording.commands);
28
+ const picture = rec.finishRecordingAsPicture();
29
+ //const end = performance.now();
30
+ //console.log("Recording time: ", end - start);
31
+ SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
32
+ };
33
+ class ReanimatedContainer extends Container {
34
+ constructor(Skia, nativeId, onSize) {
35
+ super(Skia);
36
+ this.nativeId = nativeId;
37
+ this.onSize = onSize;
38
+ _defineProperty(this, "mapperId", null);
39
+ }
40
+ redraw() {
41
+ if (this.mapperId !== null) {
42
+ Rea.stopMapper(this.mapperId);
43
+ }
44
+ if (this.unmounted) {
45
+ return;
46
+ }
47
+ const recorder = new Recorder();
48
+ visit(recorder, this.root);
49
+ const record = recorder.getRecording();
50
+ const {
51
+ animationValues
52
+ } = record;
53
+ this.recording = {
54
+ commands: record.commands,
55
+ paintPool: record.paintPool
56
+ };
57
+ const {
58
+ nativeId,
59
+ Skia,
60
+ recording
61
+ } = this;
62
+ if (animationValues.size > 0) {
63
+ this.mapperId = Rea.startMapper(() => {
64
+ "worklet";
65
+
66
+ drawOnscreen(Skia, nativeId, recording);
67
+ }, Array.from(animationValues));
68
+ }
69
+ Rea.runOnUI(onSize => {
70
+ "worklet";
71
+
72
+ drawOnscreen(Skia, nativeId, recording, onSize);
73
+ })(this.onSize);
74
+ }
75
+ }
76
+ export const createContainer = (Skia, nativeId, onSize) => {
77
+ if (HAS_REANIMATED_3 && nativeId !== -1) {
78
+ return new ReanimatedContainer(Skia, nativeId, onSize);
79
+ } else {
80
+ return new StaticContainer(Skia, nativeId);
81
+ }
82
+ };
83
+ //# sourceMappingURL=Container.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","drawOnscreen","Skia","nativeId","recording","onSize","size","SkiaViewApi","width","value","height","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","setJsiProperty","ReanimatedContainer","constructor","_defineProperty","redraw","mapperId","stopMapper","unmounted","recorder","root","record","getRecording","animationValues","startMapper","Array","from","runOnUI","createContainer"],"sources":["Container.web.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkSize } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\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 { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst drawOnscreen = (\n Skia: Skia,\n nativeId: number,\n recording: Recording,\n onSize?: SharedValue<SkSize>\n) => {\n \"worklet\";\n if (onSize) {\n const size = SkiaViewApi.size(nativeId);\n if (\n size.width !== onSize.value.width ||\n size.height !== onSize.value.height\n ) {\n onSize.value = size;\n }\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\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\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((onSize?: SharedValue<SkSize>) => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!, onSize);\n })(this.onSize);\n }\n}\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n onSize?: SharedValue<SkSize>\n) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId, onSize);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAEA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,SAAS,EAAEC,eAAe,QAAQ,mBAAmB;AAE9D,OAAO,qBAAqB;AAC5B,OAAO,cAAc;AAErB,MAAMC,YAAY,GAAGA,CACnBC,IAAU,EACVC,QAAgB,EAChBC,SAAoB,EACpBC,MAA4B,KACzB;EACH,SAAS;;EACT,IAAIA,MAAM,EAAE;IACV,MAAMC,IAAI,GAAGC,WAAW,CAACD,IAAI,CAACH,QAAQ,CAAC;IACvC,IACEG,IAAI,CAACE,KAAK,KAAKH,MAAM,CAACI,KAAK,CAACD,KAAK,IACjCF,IAAI,CAACI,MAAM,KAAKL,MAAM,CAACI,KAAK,CAACC,MAAM,EACnC;MACAL,MAAM,CAACI,KAAK,GAAGH,IAAI;IACrB;EACF;EACA,MAAMK,GAAG,GAAGT,IAAI,CAACU,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;;EAEA,MAAMC,GAAG,GAAGjB,oBAAoB,CAACI,IAAI,EAAEE,SAAS,CAACY,SAAS,EAAEH,MAAM,CAAC;EACnEhB,MAAM,CAACkB,GAAG,E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KAAK,CAACC,IAAI,CAACH,eAAe,CAAC,CAAC;IACjC;IACAvC,GAAG,CAAC2C,OAAO,CAAE/B,MAA4B,IAAK;MAC5C,SAAS;;MACTJ,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAGC,MAAM,CAAC;IAClD,CAAC,CAAC,CAAC,IAAI,CAACA,MAAM,CAAC;EACjB;AACF;AAEA,OAAO,MAAMgC,eAAe,GAAGA,CAC7BnC,IAAU,EACVC,QAAgB,EAChBE,MAA4B,KACzB;EACH,IAAIX,gBAAgB,IAAIS,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIkB,mBAAmB,CAACnB,IAAI,EAAEC,QAAQ,EAAEE,MAAM,CAAC;EACxD,CAAC,MAAM;IACL,OAAO,IAAIL,eAAe,CAACE,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { HostConfig } from "react-reconciler";
2
2
  import type { NodeType } from "../dom/types";
3
3
  import type { Node } from "./Node";
4
- import type { Container } from "./Container";
4
+ import type { Container } from "./StaticContainer";
5
5
  export declare const debug: (...args: Parameters<typeof console.log>) => void;
6
6
  type Instance = Node;
7
7
  type Props = object;