@shopify/react-native-skia 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ README
2
+ ======
3
+
4
+ If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
5
+
6
+ 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
7
+ 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
8
+ ```
9
+ ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
10
+ sdk.dir=/Users/{username}/Library/Android/sdk
11
+ ```
12
+ 3. Delete the `maven` folder
13
+ 4. Run `./gradlew installArchives`
14
+ 5. Verify that latest set of generated files is in the maven folder with the correct version number
@@ -0,0 +1,4 @@
1
+ Files in "base" are used by many parts of Skia, but are not part of the public Skia API.
2
+ See also src/base for other files that are part of base, but not needed by the public API.
3
+
4
+ Files here should not depend on anything other than system headers or other files in base.
@@ -0,0 +1,29 @@
1
+ // Copyright (c) 2018 Google Inc. All rights reserved.
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without
4
+ // modification, are permitted provided that the following conditions are
5
+ // met:
6
+ //
7
+ // * Redistributions of source code must retain the above copyright
8
+ // notice, this list of conditions and the following disclaimer.
9
+ // * Redistributions in binary form must reproduce the above
10
+ // copyright notice, this list of conditions and the following disclaimer
11
+ // in the documentation and/or other materials provided with the
12
+ // distribution.
13
+ // * Neither the name of Google Inc. nor the names of its
14
+ // contributors may be used to endorse or promote products derived from
15
+ // this software without specific prior written permission.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ --------------------------------------------------------------------------------
@@ -0,0 +1,6 @@
1
+ Name: skcms
2
+ URL: https://skia.org/
3
+ Version: unknown
4
+ Security Critical: yes
5
+ Shipped: yes
6
+ License: BSD
@@ -0,0 +1 @@
1
+ Placeholder for the Skia include files.
@@ -8,18 +8,18 @@ var _react = require("react");
8
8
  var _skia = require("../../skia");
9
9
  var _moduleWrapper = require("./moduleWrapper");
10
10
  var _interpolators = require("./interpolators");
11
+ const useBufferValue = (size, bufferInitializer) => (0, _react.useMemo)(() => (0, _moduleWrapper.makeMutable)(new Array(size).fill(0).map(bufferInitializer)),
12
+ // eslint-disable-next-line react-hooks/exhaustive-deps
13
+ [size]);
11
14
  const useBuffer = (size, bufferInitializer, modifier) => {
12
15
  var _mod$__closure;
13
- const buffer = (0, _react.useMemo)(() => new Array(size).fill(0).map(bufferInitializer),
14
- // eslint-disable-next-line react-hooks/exhaustive-deps
15
- [size]);
16
- const values = (0, _moduleWrapper.useSharedValue)(buffer);
16
+ const values = useBufferValue(size, bufferInitializer);
17
17
  const mod = modifier;
18
- const deps = Object.values((_mod$__closure = mod.__closure) !== null && _mod$__closure !== void 0 ? _mod$__closure : {});
18
+ const deps = [size, ...Object.values((_mod$__closure = mod.__closure) !== null && _mod$__closure !== void 0 ? _mod$__closure : {})];
19
19
  const mapperId = (0, _moduleWrapper.startMapper)(() => {
20
20
  "worklet";
21
21
 
22
- buffer.forEach((val, index) => {
22
+ values.value.forEach((val, index) => {
23
23
  modifier(val, index);
24
24
  });
25
25
  (0, _interpolators.notifyChange)(values);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_skia","_moduleWrapper","_interpolators","useBuffer","size","bufferInitializer","modifier","_mod$__closure","buffer","useMemo","Array","fill","map","values","useSharedValue","mod","deps","Object","__closure","mapperId","startMapper","forEach","val","index","notifyChange","useEffect","stopMapper","useRectBuffer","Skia","XYWHRect","exports","useRSXformBuffer","RSXform","usePointBuffer","Point","useColorBuffer","Color"],"sources":["buffers.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { WorkletFunction } from \"react-native-reanimated/lib/typescript/reanimated2/commonTypes\";\n\nimport type { SkColor, SkHostRect, SkPoint, SkRSXform } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport { startMapper, stopMapper, useSharedValue } from \"./moduleWrapper\";\nimport { notifyChange } from \"./interpolators\";\n\ntype Modifier<T> = (input: T, index: number) => void;\n\nconst useBuffer = <T>(\n size: number,\n bufferInitializer: () => T,\n modifier: Modifier<T>\n) => {\n const buffer = useMemo(\n () => new Array(size).fill(0).map(bufferInitializer),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [size]\n );\n const values = useSharedValue(buffer);\n const mod = modifier as WorkletFunction;\n const deps = Object.values(mod.__closure ?? {});\n const mapperId = startMapper(() => {\n \"worklet\";\n buffer.forEach((val, index) => {\n modifier(val, index);\n });\n notifyChange(values);\n }, deps);\n\n useEffect(() => {\n return () => {\n stopMapper(mapperId);\n };\n }, [mapperId]);\n\n return values;\n};\n\nexport const useRectBuffer = (size: number, modifier: Modifier<SkHostRect>) =>\n useBuffer(size, () => Skia.XYWHRect(0, 0, 0, 0), modifier);\n\n// Usage for RSXform Buffer\nexport const useRSXformBuffer = (size: number, modifier: Modifier<SkRSXform>) =>\n useBuffer(size, () => Skia.RSXform(1, 0, 0, 0), modifier);\n\n// Usage for Point Buffer\nexport const usePointBuffer = (size: number, modifier: Modifier<SkPoint>) =>\n useBuffer(size, () => Skia.Point(0, 0), modifier);\n\n// Usage for Color Buffer\nexport const useColorBuffer = (size: number, modifier: Modifier<SkColor>) =>\n useBuffer(size, () => Skia.Color(\"black\"), modifier);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAIA,MAAMI,SAAS,GAAGA,CAChBC,IAAY,EACZC,iBAA0B,EAC1BC,QAAqB,KAClB;EAAA,IAAAC,cAAA;EACH,MAAMC,MAAM,GAAG,IAAAC,cAAO,EACpB,MAAM,IAAIC,KAAK,CAACN,IAAI,CAAC,CAACO,IAAI,CAAC,CAAC,CAAC,CAACC,GAAG,CAACP,iBAAiB,CAAC;EACpD;EACA,CAACD,IAAI,CACP,CAAC;EACD,MAAMS,MAAM,GAAG,IAAAC,6BAAc,EAACN,MAAM,CAAC;EACrC,MAAMO,GAAG,GAAGT,QAA2B;EACvC,MAAMU,IAAI,GAAGC,MAAM,CAACJ,MAAM,EAAAN,cAAA,GAACQ,GAAG,CAACG,SAAS,cAAAX,cAAA,cAAAA,cAAA,GAAI,CAAC,CAAC,CAAC;EAC/C,MAAMY,QAAQ,GAAG,IAAAC,0BAAW,EAAC,MAAM;IACjC,SAAS;;IACTZ,MAAM,CAACa,OAAO,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK;MAC7BjB,QAAQ,CAACgB,GAAG,EAAEC,KAAK,CAAC;IACtB,CAAC,CAAC;IACF,IAAAC,2BAAY,EAACX,MAAM,CAAC;EACtB,CAAC,EAAEG,IAAI,CAAC;EAER,IAAAS,gBAAS,EAAC,MAAM;IACd,OAAO,MAAM;MACX,IAAAC,yBAAU,EAACP,QAAQ,CAAC;IACtB,CAAC;EACH,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEd,OAAON,MAAM;AACf,CAAC;AAEM,MAAMc,aAAa,GAAGA,CAACvB,IAAY,EAAEE,QAA8B,KACxEH,SAAS,CAACC,IAAI,EAAE,MAAMwB,UAAI,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAEvB,QAAQ,CAAC;;AAE5D;AAAAwB,OAAA,CAAAH,aAAA,GAAAA,aAAA;AACO,MAAMI,gBAAgB,GAAGA,CAAC3B,IAAY,EAAEE,QAA6B,KAC1EH,SAAS,CAACC,IAAI,EAAE,MAAMwB,UAAI,CAACI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE1B,QAAQ,CAAC;;AAE3D;AAAAwB,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AACO,MAAME,cAAc,GAAGA,CAAC7B,IAAY,EAAEE,QAA2B,KACtEH,SAAS,CAACC,IAAI,EAAE,MAAMwB,UAAI,CAACM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE5B,QAAQ,CAAC;;AAEnD;AAAAwB,OAAA,CAAAG,cAAA,GAAAA,cAAA;AACO,MAAME,cAAc,GAAGA,CAAC/B,IAAY,EAAEE,QAA2B,KACtEH,SAAS,CAACC,IAAI,EAAE,MAAMwB,UAAI,CAACQ,KAAK,CAAC,OAAO,CAAC,EAAE9B,QAAQ,CAAC;AAACwB,OAAA,CAAAK,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"names":["_react","require","_skia","_moduleWrapper","_interpolators","useBufferValue","size","bufferInitializer","useMemo","makeMutable","Array","fill","map","useBuffer","modifier","_mod$__closure","values","mod","deps","Object","__closure","mapperId","startMapper","value","forEach","val","index","notifyChange","useEffect","stopMapper","useRectBuffer","Skia","XYWHRect","exports","useRSXformBuffer","RSXform","usePointBuffer","Point","useColorBuffer","Color"],"sources":["buffers.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { WorkletFunction } from \"react-native-reanimated/lib/typescript/reanimated2/commonTypes\";\n\nimport type { SkColor, SkHostRect, SkPoint, SkRSXform } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport { startMapper, stopMapper, makeMutable } from \"./moduleWrapper\";\nimport { notifyChange } from \"./interpolators\";\n\ntype Modifier<T> = (input: T, index: number) => void;\n\nconst useBufferValue = <T>(size: number, bufferInitializer: () => T) =>\n useMemo(\n () => makeMutable(new Array(size).fill(0).map(bufferInitializer)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [size]\n );\n\nconst useBuffer = <T>(\n size: number,\n bufferInitializer: () => T,\n modifier: Modifier<T>\n) => {\n const values = useBufferValue(size, bufferInitializer);\n const mod = modifier as WorkletFunction;\n const deps = [size, ...Object.values(mod.__closure ?? {})];\n const mapperId = startMapper(() => {\n \"worklet\";\n values.value.forEach((val, index) => {\n modifier(val, index);\n });\n notifyChange(values);\n }, deps);\n\n useEffect(() => {\n return () => {\n stopMapper(mapperId);\n };\n }, [mapperId]);\n\n return values;\n};\n\nexport const useRectBuffer = (size: number, modifier: Modifier<SkHostRect>) =>\n useBuffer(size, () => Skia.XYWHRect(0, 0, 0, 0), modifier);\n\n// Usage for RSXform Buffer\nexport const useRSXformBuffer = (size: number, modifier: Modifier<SkRSXform>) =>\n useBuffer(size, () => Skia.RSXform(1, 0, 0, 0), modifier);\n\n// Usage for Point Buffer\nexport const usePointBuffer = (size: number, modifier: Modifier<SkPoint>) =>\n useBuffer(size, () => Skia.Point(0, 0), modifier);\n\n// Usage for Color Buffer\nexport const useColorBuffer = (size: number, modifier: Modifier<SkColor>) =>\n useBuffer(size, () => Skia.Color(\"black\"), modifier);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AA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E5D;AAAAmB,OAAA,CAAAH,aAAA,GAAAA,aAAA;AACO,MAAMI,gBAAgB,GAAGA,CAAC5B,IAAY,EAAEQ,QAA6B,KAC1ED,SAAS,CAACP,IAAI,EAAE,MAAMyB,UAAI,CAACI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAErB,QAAQ,CAAC;;AAE3D;AAAAmB,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AACO,MAAME,cAAc,GAAGA,CAAC9B,IAAY,EAAEQ,QAA2B,KACtED,SAAS,CAACP,IAAI,EAAE,MAAMyB,UAAI,CAACM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAEvB,QAAQ,CAAC;;AAEnD;AAAAmB,OAAA,CAAAG,cAAA,GAAAA,cAAA;AACO,MAAME,cAAc,GAAGA,CAAChC,IAAY,EAAEQ,QAA2B,KACtED,SAAS,CAACP,IAAI,EAAE,MAAMyB,UAAI,CAACQ,KAAK,CAAC,OAAO,CAAC,EAAEzB,QAAQ,CAAC;AAACmB,OAAA,CAAAK,cAAA,GAAAA,cAAA"}
@@ -10,5 +10,6 @@ export declare const startMapper: (worklet: () => void, inputs?: unknown[], outp
10
10
  export declare const stopMapper: (mapperID: number) => void;
11
11
  export declare const runOnJS: any;
12
12
  export declare const runOnUI: any;
13
+ export declare const makeMutable: <T>(val: T) => SharedValue<T>;
13
14
  export declare const useAnimatedReaction: <T>(prepare: () => T, react: (v: T) => void, dependencies?: DependencyList) => void;
14
15
  export declare const isSharedValue: <T>(value: unknown) => value is SharedValue<T>;
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.stopMapper = exports.startMapper = exports.runOnUI = exports.runOnJS = exports.isSharedValue = exports.HAS_REANIMATED3 = exports.HAS_REANIMATED2 = void 0;
6
+ exports.stopMapper = exports.startMapper = exports.runOnUI = exports.runOnJS = exports.makeMutable = exports.isSharedValue = exports.HAS_REANIMATED3 = exports.HAS_REANIMATED2 = void 0;
7
7
  exports.throwOnMissingReanimated = throwOnMissingReanimated;
8
8
  exports.useSharedValue = exports.useFrameCallback = exports.useDerivedValue = exports.useAnimatedReaction = void 0;
9
- var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7, _Reanimated8;
9
+ var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7, _Reanimated8, _Reanimated9;
10
10
  /* eslint-disable @typescript-eslint/no-explicit-any */
11
11
 
12
12
  // This one is needed for the deprecated useSharedValue function
@@ -37,7 +37,8 @@ const startMapper = exports.startMapper = ((_Reanimated4 = Reanimated2) === null
37
37
  const stopMapper = exports.stopMapper = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.stopMapper) || throwOnMissingReanimated;
38
38
  const runOnJS = exports.runOnJS = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.runOnJS) || throwOnMissingReanimated;
39
39
  const runOnUI = exports.runOnUI = ((_Reanimated7 = Reanimated2) === null || _Reanimated7 === void 0 ? void 0 : _Reanimated7.runOnUI) || throwOnMissingReanimated;
40
- const useAnimatedReaction = exports.useAnimatedReaction = ((_Reanimated8 = Reanimated2) === null || _Reanimated8 === void 0 ? void 0 : _Reanimated8.useAnimatedReaction) || throwOnMissingReanimated;
40
+ const makeMutable = exports.makeMutable = ((_Reanimated8 = Reanimated2) === null || _Reanimated8 === void 0 ? void 0 : _Reanimated8.makeMutable) || throwOnMissingReanimated;
41
+ const useAnimatedReaction = exports.useAnimatedReaction = ((_Reanimated9 = Reanimated2) === null || _Reanimated9 === void 0 ? void 0 : _Reanimated9.useAnimatedReaction) || throwOnMissingReanimated;
41
42
  const isSharedValue = value => {
42
43
  return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
43
44
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","exports","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","_Reanimated","useDerivedValue","_Reanimated2","useFrameCallback","_Reanimated3","startMapper","_Reanimated4","stopMapper","_Reanimated5","runOnJS","_Reanimated6","runOnUI","_Reanimated7","useAnimatedReaction","_Reanimated8","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;AASA;AACA;;AAEA,IAAIA,WAAgB;AAEpB,IAAIC,WAAgB;AACpB,IAAIC,iBAAyB;AAE7B,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAyB,CAAC;EAChDD,iBAAiB,GAAGC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EAC3E,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,WAAW,GAAGD,WAAW;EAC3B;AACF,CAAC,CAAC,OAAOM,CAAC,EAAE,CAAC;AAEN,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,CAAC,CAACP,WAAW;AACrC,MAAMS,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,CAAC,CAACR,WAAW;AAErC,SAASS,wBAAwBA,CAAA,EAAG;EACzC,IAAI,CAACH,eAAe,EAAE;IACpB,MAAM,IAAII,KAAK,CACb;AACN,iDACI,CAAC;EACH;AACF;AAEO,MAAMC,cAGM,GAAAJ,OAAA,CAAAI,cAAA,GAAG,EAAAC,WAAA,GAAAb,WAAW,cAAAa,WAAA,uBAAXA,WAAA,CAAaD,cAAc,K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
1
+ {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","exports","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","_Reanimated","useDerivedValue","_Reanimated2","useFrameCallback","_Reanimated3","startMapper","_Reanimated4","stopMapper","_Reanimated5","runOnJS","_Reanimated6","runOnUI","_Reanimated7","makeMutable","_Reanimated8","useAnimatedReaction","_Reanimated9","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;\nexport const makeMutable: <T>(val: T) => SharedValue<T> =\n Reanimated2?.makeMutable || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;AASA;AACA;;AAEA,IAAIA,WAAgB;AAEpB,IAAIC,WAAgB;AACpB,IAAIC,iBAAyB;AAE7B,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAyB,CAAC;EAChDD,iBAAiB,GAAGC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EAC3E,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,WAAW,GAAGD,WAAW;EAC3B;AACF,CAAC,CAAC,OAAOM,CAAC,EAAE,CAAC;AAEN,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,CAAC,CAACP,WAAW;AACrC,MAAMS,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,CAAC,CAACR,WAAW;AAErC,SAASS,wBAAwBA,CAAA,EAAG;EACzC,IAAI,CAACH,eAAe,EAAE;IACpB,MAAM,IAAII,KAAK,CACb;AACN,iDACI,CAAC;EACH;AACF;AAEO,MAAMC,cAGM,GAAAJ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BAAwB;AAEjE,MAAMoB,aAAa,GAAOC,KAAc,IAA8B;EAC3E,OACE,CAAC,CAACA,KAAK,KACN9B,WAAW,GACRA,WAAW,CAAC6B,aAAa,CAACC,KAAK,CAAC,GAC/BA,KAAK,CAASA,KAAK,KAAKC,SAAS,CAAC;AAE3C,CAAC;AAACxB,OAAA,CAAAsB,aAAA,GAAAA,aAAA"}
@@ -1,19 +1,19 @@
1
1
  import { useEffect, useMemo } from "react";
2
2
  import { Skia } from "../../skia";
3
- import { startMapper, stopMapper, useSharedValue } from "./moduleWrapper";
3
+ import { startMapper, stopMapper, makeMutable } from "./moduleWrapper";
4
4
  import { notifyChange } from "./interpolators";
5
+ const useBufferValue = (size, bufferInitializer) => useMemo(() => makeMutable(new Array(size).fill(0).map(bufferInitializer)),
6
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7
+ [size]);
5
8
  const useBuffer = (size, bufferInitializer, modifier) => {
6
9
  var _mod$__closure;
7
- const buffer = useMemo(() => new Array(size).fill(0).map(bufferInitializer),
8
- // eslint-disable-next-line react-hooks/exhaustive-deps
9
- [size]);
10
- const values = useSharedValue(buffer);
10
+ const values = useBufferValue(size, bufferInitializer);
11
11
  const mod = modifier;
12
- const deps = Object.values((_mod$__closure = mod.__closure) !== null && _mod$__closure !== void 0 ? _mod$__closure : {});
12
+ const deps = [size, ...Object.values((_mod$__closure = mod.__closure) !== null && _mod$__closure !== void 0 ? _mod$__closure : {})];
13
13
  const mapperId = startMapper(() => {
14
14
  "worklet";
15
15
 
16
- buffer.forEach((val, index) => {
16
+ values.value.forEach((val, index) => {
17
17
  modifier(val, index);
18
18
  });
19
19
  notifyChange(values);
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useMemo","Skia","startMapper","stopMapper","useSharedValue","notifyChange","useBuffer","size","bufferInitializer","modifier","_mod$__closure","buffer","Array","fill","map","values","mod","deps","Object","__closure","mapperId","forEach","val","index","useRectBuffer","XYWHRect","useRSXformBuffer","RSXform","usePointBuffer","Point","useColorBuffer","Color"],"sources":["buffers.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { WorkletFunction } from \"react-native-reanimated/lib/typescript/reanimated2/commonTypes\";\n\nimport type { SkColor, SkHostRect, SkPoint, SkRSXform } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport { startMapper, stopMapper, useSharedValue } from \"./moduleWrapper\";\nimport { notifyChange } from \"./interpolators\";\n\ntype Modifier<T> = (input: T, index: number) => void;\n\nconst useBuffer = <T>(\n size: number,\n bufferInitializer: () => T,\n modifier: Modifier<T>\n) => {\n const buffer = useMemo(\n () => new Array(size).fill(0).map(bufferInitializer),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [size]\n );\n const values = useSharedValue(buffer);\n const mod = modifier as WorkletFunction;\n const deps = Object.values(mod.__closure ?? {});\n const mapperId = startMapper(() => {\n \"worklet\";\n buffer.forEach((val, index) => {\n modifier(val, index);\n });\n notifyChange(values);\n }, deps);\n\n useEffect(() => {\n return () => {\n stopMapper(mapperId);\n };\n }, [mapperId]);\n\n return values;\n};\n\nexport const useRectBuffer = (size: number, modifier: Modifier<SkHostRect>) =>\n useBuffer(size, () => Skia.XYWHRect(0, 0, 0, 0), modifier);\n\n// Usage for RSXform Buffer\nexport const useRSXformBuffer = (size: number, modifier: Modifier<SkRSXform>) =>\n useBuffer(size, () => Skia.RSXform(1, 0, 0, 0), modifier);\n\n// Usage for Point Buffer\nexport const usePointBuffer = (size: number, modifier: Modifier<SkPoint>) =>\n useBuffer(size, () => Skia.Point(0, 0), modifier);\n\n// Usage for Color Buffer\nexport const useColorBuffer = (size: number, modifier: Modifier<SkColor>) =>\n useBuffer(size, () => Skia.Color(\"black\"), modifier);\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAI1C,SAASC,IAAI,QAAQ,YAAY;AAEjC,SAASC,WAAW,EAAEC,UAAU,EAAEC,cAAc,QAAQ,iBAAiB;AACzE,SAASC,YAAY,QAA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CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAElB,QAAQ,CAAC;;AAE3D;AACA,OAAO,MAAMmB,cAAc,GAAGA,CAACrB,IAAY,EAAEE,QAA2B,KACtEH,SAAS,CAACC,IAAI,EAAE,MAAMN,IAAI,CAAC4B,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAEpB,QAAQ,CAAC;;AAEnD;AACA,OAAO,MAAMqB,cAAc,GAAGA,CAACvB,IAAY,EAAEE,QAA2B,KACtEH,SAAS,CAACC,IAAI,EAAE,MAAMN,IAAI,CAAC8B,KAAK,CAAC,OAAO,CAAC,EAAEtB,QAAQ,CAAC"}
1
+ {"version":3,"names":["useEffect","useMemo","Skia","startMapper","stopMapper","makeMutable","notifyChange","useBufferValue","size","bufferInitializer","Array","fill","map","useBuffer","modifier","_mod$__closure","values","mod","deps","Object","__closure","mapperId","value","forEach","val","index","useRectBuffer","XYWHRect","useRSXformBuffer","RSXform","usePointBuffer","Point","useColorBuffer","Color"],"sources":["buffers.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { WorkletFunction } from \"react-native-reanimated/lib/typescript/reanimated2/commonTypes\";\n\nimport type { SkColor, SkHostRect, SkPoint, SkRSXform } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport { startMapper, stopMapper, makeMutable } from \"./moduleWrapper\";\nimport { notifyChange } from \"./interpolators\";\n\ntype Modifier<T> = (input: T, index: number) => void;\n\nconst useBufferValue = <T>(size: number, bufferInitializer: () => T) =>\n useMemo(\n () => makeMutable(new Array(size).fill(0).map(bufferInitializer)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [size]\n );\n\nconst useBuffer = <T>(\n size: number,\n bufferInitializer: () => T,\n modifier: Modifier<T>\n) => {\n const values = useBufferValue(size, bufferInitializer);\n const mod = modifier as WorkletFunction;\n const deps = [size, ...Object.values(mod.__closure ?? {})];\n const mapperId = startMapper(() => {\n \"worklet\";\n values.value.forEach((val, index) => {\n modifier(val, index);\n });\n notifyChange(values);\n }, deps);\n\n useEffect(() => {\n return () => {\n stopMapper(mapperId);\n };\n }, [mapperId]);\n\n return values;\n};\n\nexport const useRectBuffer = (size: number, modifier: Modifier<SkHostRect>) =>\n useBuffer(size, () => Skia.XYWHRect(0, 0, 0, 0), modifier);\n\n// Usage for RSXform Buffer\nexport const useRSXformBuffer = (size: number, modifier: Modifier<SkRSXform>) =>\n useBuffer(size, () => Skia.RSXform(1, 0, 0, 0), modifier);\n\n// Usage for Point Buffer\nexport const usePointBuffer = (size: number, modifier: Modifier<SkPoint>) =>\n useBuffer(size, () => Skia.Point(0, 0), modifier);\n\n// Usage for Color Buffer\nexport const useColorBuffer = (size: number, modifier: Modifier<SkColor>) =>\n useBuffer(size, () => Skia.Color(\"black\"), modifier);\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAI1C,SAASC,IAAI,QAAQ,YAAY;AAEjC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,QAAQ,iBAAiB;AACtE,SAASC,YAAY,QAAQ,iBAAiB;AAI9C,MAAMC,cAAc,GAAGA,CAAIC,IAAY,EAAEC,iBAA0B,KACjER,OAAO,CACL,MAAMI,WAAW,CAAC,IAAIK,KAAK,CAACF,IAAI,CAAC,CAACG,IAAI,CAAC,CAAC,CAAC,CAACC,GAAG,CAACH,iBAAiB,CAAC,CAAC;AACjE;AACA,CAACD,IAAI,CACP,CAAC;AAEH,MAAMK,SAAS,GAAGA,CAChBL,IAAY,EACZC,iBAA0B,EAC1BK,QAAqB,KAClB;EAAA,IAAAC,cAAA;EACH,MAAMC,MAAM,GAAGT,cAAc,CAACC,IAAI,EAAEC,iBAAiB,CAAC;EACtD,MAAMQ,GAAG,GAAGH,QAA2B;EACvC,MAAMI,IAAI,GAAG,CAACV,IAAI,EAAE,GAAGW,MAAM,CAACH,MAAM,EAAAD,cAAA,GAACE,GAAG,CAACG,SAAS,cAAAL,cAAA,c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per: (worklet: () => void, inputs?: unknown[], outp
10
10
  export declare const stopMapper: (mapperID: number) => void;
11
11
  export declare const runOnJS: any;
12
12
  export declare const runOnUI: any;
13
+ export declare const makeMutable: <T>(val: T) => SharedValue<T>;
13
14
  export declare const useAnimatedReaction: <T>(prepare: () => T, react: (v: T) => void, dependencies?: DependencyList) => void;
14
15
  export declare const isSharedValue: <T>(value: unknown) => value is SharedValue<T>;
@@ -1,4 +1,4 @@
1
- var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7, _Reanimated8;
1
+ var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7, _Reanimated8, _Reanimated9;
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
 
4
4
  // This one is needed for the deprecated useSharedValue function
@@ -29,7 +29,8 @@ export const startMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated
29
29
  export const stopMapper = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.stopMapper) || throwOnMissingReanimated;
30
30
  export const runOnJS = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.runOnJS) || throwOnMissingReanimated;
31
31
  export const runOnUI = ((_Reanimated7 = Reanimated2) === null || _Reanimated7 === void 0 ? void 0 : _Reanimated7.runOnUI) || throwOnMissingReanimated;
32
- export const useAnimatedReaction = ((_Reanimated8 = Reanimated2) === null || _Reanimated8 === void 0 ? void 0 : _Reanimated8.useAnimatedReaction) || throwOnMissingReanimated;
32
+ export const makeMutable = ((_Reanimated8 = Reanimated2) === null || _Reanimated8 === void 0 ? void 0 : _Reanimated8.makeMutable) || throwOnMissingReanimated;
33
+ export const useAnimatedReaction = ((_Reanimated9 = Reanimated2) === null || _Reanimated9 === void 0 ? void 0 : _Reanimated9.useAnimatedReaction) || throwOnMissingReanimated;
33
34
  export const isSharedValue = value => {
34
35
  return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
35
36
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","_Reanimated","useDerivedValue","_Reanimated2","useFrameCallback","_Reanimated3","startMapper","_Reanimated4","stopMapper","_Reanimated5","runOnJS","_Reanimated6","runOnUI","_Reanimated7","useAnimatedReaction","_Reanimated8","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";AAAA;;AASA;AACA;;AAEA,IAAIA,WAAgB;AAEpB,IAAIC,WAAgB;AACpB,IAAIC,iBAAyB;AAE7B,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAyB,CAAC;EAChDD,iBAAiB,GAAGC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EAC3E,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,WAAW,GAAGD,WAAW;EAC3B;AACF,CAAC,CAAC,OAAOM,CAAC,EAAE,CAAC;AAEb,OAAO,MAAMC,eAAe,GAAG,CAAC,CAACP,WAAW;AAC5C,OAAO,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAAW;AAE5C,OAAO,SAASQ,wBAAwBA,CAAA,EAAG;EACzC,IAAI,CAACF,eAAe,EAAE;IACpB,MAAM,IAAIG,KAAK,CACb;AACN,iDACI,CAAC;EACH;AACF;AAEA,OAAO,MAAMC,cAGM,GAAG,EAAAC,WAAA,GAAAZ,WAAW,cAAAY,WAAA,uBAAXA,WAAA,CAAaD,cAAc,KAAIF,wBAAwB;AAE7E,OAAO,MAAMI,eAGO,GAAG,EAAAC,YAAA,GAAAd,WAAW,cAAAc,YAAA,uBAAXA,YAAA,CAAaD,eAAe,KAAIJ,wBAAwB;AAE/E,OAAO,MAAMM,gBAGK,GAAG,EAAAC,YAAA,GAAAhB,WAAW,cAAAgB,YAAA,uBAAXA,YAAA,CAAaD,gBAAgB,KAAIN,wBAAwB;AAE9E,OAAO,MAAMQ,WAIF,GAAG,EAAAC,YAAA,GAAAlB,WAAW,cAAAkB,YAAA,uBAAXA,YAAA,CAAaD,WAAW,KAAIR,wBAAwB;AAElE,OAAO,MAAMU,UAAsC,GACjD,EAAAC,YAAA,GAAApB,WAAW,cAAAoB,YAAA,uBAAXA,YAAA,CAAaD,UAAU,KAAIV,wBAAwB;AAErD,OAAO,MAAMY,OAAO,GAAG,EAAAC,YAAA,GAAAtB,WAAW,cAAAsB,YAAA,uBAAXA,YAAA,CAAaD,OAAO,KAAIZ,wBAAwB;AACvE,OAAO,MAAMc,OAAO,GAAG,EAAAC,YAAA,GAAAxB,WAAW,cAAAwB,YAAA,uBAAXA,YAAA,CAAaD,OAAO,KAAId,wBAAwB;AAEvE,OAAO,MAAMgB,mBAIJ,GAAG,EAAAC,YAAA,GAAA1B,WAAW,cAAA0B,YAAA,uBAAXA,YAAA,CAAaD,mBAAmB,KAAIhB,wBAAwB;AAExE,OAAO,MAAMkB,aAAa,GAAOC,KAAc,IAA8B;EAC3E,OACE,CAAC,CAACA,KAAK,KACN3B,WAAW,GACRA,WAAW,CAAC0B,aAAa,CAACC,KAAK,CAAC,GAC/BA,KAAK,CAASA,KAAK,KAAKC,SAAS,CAAC;AAE3C,CAAC"}
1
+ {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","_Reanimated","useDerivedValue","_Reanimated2","useFrameCallback","_Reanimated3","startMapper","_Reanimated4","stopMapper","_Reanimated5","runOnJS","_Reanimated6","runOnUI","_Reanimated7","makeMutable","_Reanimated8","useAnimatedReaction","_Reanimated9","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;\nexport const makeMutable: <T>(val: T) => SharedValue<T> =\n Reanimated2?.makeMutable || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";AAAA;;AASA;AACA;;AAEA,IAAIA,WAAgB;AAEpB,IAAIC,WAAgB;AACpB,IAAIC,iBAAyB;AAE7B,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAyB,CAAC;EAChDD,iBAAiB,GAAGC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EAC3E,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,WAAW,GAAGD,WAAW;EAC3B;AACF,CAAC,CAAC,OAAOM,CAAC,EAAE,CAAC;AAEb,OAAO,MAAMC,eAAe,GAAG,CAAC,CAACP,WAAW;AAC5C,OAAO,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAAW;AAE5C,OAAO,SAASQ,wBAAwBA,CAAA,EAAG;EACzC,IAAI,CAACF,eAAe,EAAE;IACpB,MAAM,IAAIG,KAAK,CACb;AACN,iDACI,CAAC;EACH;AACF;AAEA,OAAO,MAAMC,cAGM,GAAG,EAAAC,WAAA,GAAAZ,WAAW,cAAAY,WAAA,uBAAXA,WAAA,CAAaD,cAAc,KAAIF,wBAAwB;AAE7E,OAAO,MAAMI,eAGO,GAAG,EAAAC,YAAA,GAAAd,WAAW,cAAAc,YAAA,uBAAXA,YAAA,CAAaD,eAAe,KAAIJ,wBAAwB;AAE/E,OAAO,MAAMM,gBAGK,GAAG,EAAAC,YAAA,GAAAhB,WAAW,cAAAgB,YAAA,uBAAXA,YAAA,CAAaD,gBAAgB,KAAIN,wBAAwB;AAE9E,OAAO,MAAMQ,WAIF,GAAG,EAAAC,YAAA,GAAAlB,WAAW,cAAAkB,YAAA,uBAAXA,YAAA,CAAaD,WAAW,KAAIR,wBAAwB;AAElE,OAAO,MAAMU,UAAsC,GACjD,EAAAC,YAAA,GAAApB,WAAW,cAAAoB,YAAA,uBAAXA,YAAA,CAAaD,UAAU,KAAIV,wBAAwB;AAErD,OAAO,MAAMY,OAAO,GAAG,EAAAC,YAAA,GAAAtB,WAAW,cAAAsB,YAAA,uBAAXA,YAAA,CAAaD,OAAO,KAAIZ,wBAAwB;AACvE,OAAO,MAAMc,OAAO,GAAG,EAAAC,YAAA,GAAAxB,WAAW,cAAAwB,YAAA,uBAAXA,YAAA,CAAaD,OAAO,KAAId,wBAAwB;AACvE,OAAO,MAAMgB,WAA0C,GACrD,EAAAC,YAAA,GAAA1B,WAAW,cAAA0B,YAAA,uBAAXA,YAAA,CAAaD,WAAW,KAAIhB,wBAAwB;AAEtD,OAAO,MAAMkB,mBAIJ,GAAG,EAAAC,YAAA,GAAA5B,WAAW,cAAA4B,YAAA,uBAAXA,YAAA,CAAaD,mBAAmB,KAAIlB,wBAAwB;AAExE,OAAO,MAAMoB,aAAa,GAAOC,KAAc,IAA8B;EAC3E,OACE,CAAC,CAACA,KAAK,KACN7B,WAAW,GACRA,WAAW,CAAC4B,aAAa,CAACC,KAAK,CAAC,GAC/BA,KAAK,CAASA,KAAK,KAAKC,SAAS,CAAC;AAE3C,CAAC"}
@@ -10,5 +10,6 @@ export declare const startMapper: (worklet: () => void, inputs?: unknown[], outp
10
10
  export declare const stopMapper: (mapperID: number) => void;
11
11
  export declare const runOnJS: any;
12
12
  export declare const runOnUI: any;
13
+ export declare const makeMutable: <T>(val: T) => SharedValue<T>;
13
14
  export declare const useAnimatedReaction: <T>(prepare: () => T, react: (v: T) => void, dependencies?: DependencyList) => void;
14
15
  export declare const isSharedValue: <T>(value: unknown) => value is SharedValue<T>;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "1.0.3",
10
+ "version": "1.0.4",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "react-native": "src/index.ts",
@@ -49,7 +49,7 @@
49
49
  "test": "jest",
50
50
  "e2e": "E2E=true yarn test -i e2e",
51
51
  "build": "bob build && merge-dirs lib/typescript/src lib/commonjs && merge-dirs lib/typescript/src lib/module",
52
- "release": "standard-version"
52
+ "release": "semantic-release"
53
53
  },
54
54
  "repository": {
55
55
  "type": "git",
@@ -106,7 +106,6 @@
106
106
  "react-native": "0.72.6",
107
107
  "react-native-builder-bob": "0.18.2",
108
108
  "react-native-reanimated": "3.6.2",
109
- "standard-version": "^9.5.0",
110
109
  "ts-jest": "29.1.1",
111
110
  "typescript": "5.1.6",
112
111
  "ws": "8.11.0"
@@ -28,7 +28,7 @@ Pod::Spec.new do |s|
28
28
  "HEADER_SEARCH_PATHS" => '"$(PODS_TARGET_SRCROOT)/cpp/"/**'
29
29
  }
30
30
 
31
- s.frameworks = 'GLKit', 'MetalKit'
31
+ s.frameworks = 'MetalKit'
32
32
 
33
33
  s.ios.vendored_frameworks = [
34
34
  'libs/ios/libskia.xcframework',
@@ -4,27 +4,29 @@ import type { WorkletFunction } from "react-native-reanimated/lib/typescript/rea
4
4
  import type { SkColor, SkHostRect, SkPoint, SkRSXform } from "../../skia/types";
5
5
  import { Skia } from "../../skia";
6
6
 
7
- import { startMapper, stopMapper, useSharedValue } from "./moduleWrapper";
7
+ import { startMapper, stopMapper, makeMutable } from "./moduleWrapper";
8
8
  import { notifyChange } from "./interpolators";
9
9
 
10
10
  type Modifier<T> = (input: T, index: number) => void;
11
11
 
12
+ const useBufferValue = <T>(size: number, bufferInitializer: () => T) =>
13
+ useMemo(
14
+ () => makeMutable(new Array(size).fill(0).map(bufferInitializer)),
15
+ // eslint-disable-next-line react-hooks/exhaustive-deps
16
+ [size]
17
+ );
18
+
12
19
  const useBuffer = <T>(
13
20
  size: number,
14
21
  bufferInitializer: () => T,
15
22
  modifier: Modifier<T>
16
23
  ) => {
17
- const buffer = useMemo(
18
- () => new Array(size).fill(0).map(bufferInitializer),
19
- // eslint-disable-next-line react-hooks/exhaustive-deps
20
- [size]
21
- );
22
- const values = useSharedValue(buffer);
24
+ const values = useBufferValue(size, bufferInitializer);
23
25
  const mod = modifier as WorkletFunction;
24
- const deps = Object.values(mod.__closure ?? {});
26
+ const deps = [size, ...Object.values(mod.__closure ?? {})];
25
27
  const mapperId = startMapper(() => {
26
28
  "worklet";
27
- buffer.forEach((val, index) => {
29
+ values.value.forEach((val, index) => {
28
30
  modifier(val, index);
29
31
  });
30
32
  notifyChange(values);
@@ -64,6 +64,8 @@ export const stopMapper: (mapperID: number) => void =
64
64
 
65
65
  export const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;
66
66
  export const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;
67
+ export const makeMutable: <T>(val: T) => SharedValue<T> =
68
+ Reanimated2?.makeMutable || throwOnMissingReanimated;
67
69
 
68
70
  export const useAnimatedReaction: <T>(
69
71
  prepare: () => T,