@shopify/react-native-skia 0.1.131 → 0.1.134

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/android/CMakeLists.txt +1 -1
  2. package/android/build.gradle +17 -2
  3. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +5 -0
  4. package/cpp/api/JsiSkFont.h +6 -2
  5. package/cpp/api/JsiSkImage.h +2 -19
  6. package/cpp/api/JsiSkPaint.h +5 -32
  7. package/cpp/api/JsiSkPath.h +4 -4
  8. package/cpp/rnskia/RNSkValueApi.h +6 -6
  9. package/cpp/rnskia/values/{RNSkDerivedValue.h → RNSkComputedValue.h} +7 -7
  10. package/cpp/utils/RNSkLog.h +5 -0
  11. package/ios/RNSkia-iOS/SkiaManager.mm +1 -1
  12. package/lib/commonjs/mock/index.js +190 -0
  13. package/lib/commonjs/mock/index.js.map +1 -0
  14. package/lib/commonjs/skia/core/Data.js +33 -43
  15. package/lib/commonjs/skia/core/Data.js.map +1 -1
  16. package/lib/commonjs/skia/core/Typeface.js +1 -1
  17. package/lib/commonjs/skia/core/Typeface.js.map +1 -1
  18. package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
  19. package/lib/commonjs/skia/types/Image/Image.js +5 -5
  20. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  21. package/lib/commonjs/skia/types/Paint/Paint.js +3 -3
  22. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  23. package/lib/commonjs/skia/types/Path/Path.js +0 -1
  24. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  25. package/lib/commonjs/skia/types/Shader/Shader.js +1 -7
  26. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  27. package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -1
  28. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  29. package/lib/commonjs/skia/web/JsiSkFont.js +4 -2
  30. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkFontMgr.js +0 -2
  32. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkImage.js +10 -6
  34. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  35. package/lib/commonjs/skia/web/{JsiImageFilterFactory.js → JsiSkImageFilterFactory.js} +1 -1
  36. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -0
  37. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkPath.js +65 -52
  39. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +1 -1
  41. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +23 -1
  43. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkia.js +2 -2
  45. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  46. package/lib/commonjs/values/api.js +3 -3
  47. package/lib/commonjs/values/api.js.map +1 -1
  48. package/lib/commonjs/values/api.web.js +3 -3
  49. package/lib/commonjs/values/api.web.js.map +1 -1
  50. package/lib/commonjs/values/hooks/index.js +4 -4
  51. package/lib/commonjs/values/hooks/index.js.map +1 -1
  52. package/lib/commonjs/values/hooks/useComputedValue.js +32 -0
  53. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -0
  54. package/lib/commonjs/values/web/{RNSkDerivedValue.js → RNSkComputedValue.js} +4 -4
  55. package/lib/commonjs/values/web/RNSkComputedValue.js.map +1 -0
  56. package/lib/commonjs/values/web/api.js +3 -3
  57. package/lib/commonjs/values/web/api.js.map +1 -1
  58. package/lib/commonjs/views/SkiaView.web.js +4 -4
  59. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  60. package/lib/commonjs/web/index.js +4 -2
  61. package/lib/commonjs/web/index.js.map +1 -1
  62. package/lib/module/mock/index.js +152 -0
  63. package/lib/module/mock/index.js.map +1 -0
  64. package/lib/module/skia/core/Data.js +32 -41
  65. package/lib/module/skia/core/Data.js.map +1 -1
  66. package/lib/module/skia/core/Typeface.js +1 -1
  67. package/lib/module/skia/core/Typeface.js.map +1 -1
  68. package/lib/module/skia/types/Font/Font.js.map +1 -1
  69. package/lib/module/skia/types/Image/Image.js +5 -5
  70. package/lib/module/skia/types/Image/Image.js.map +1 -1
  71. package/lib/module/skia/types/Paint/Paint.js +3 -3
  72. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  73. package/lib/module/skia/types/Path/Path.js +0 -1
  74. package/lib/module/skia/types/Path/Path.js.map +1 -1
  75. package/lib/module/skia/types/Shader/Shader.js +1 -7
  76. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  77. package/lib/module/skia/web/JsiSkCanvas.js +1 -1
  78. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  79. package/lib/module/skia/web/JsiSkFont.js +5 -3
  80. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  81. package/lib/module/skia/web/JsiSkFontMgr.js +0 -2
  82. package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -1
  83. package/lib/module/skia/web/JsiSkImage.js +10 -7
  84. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  85. package/lib/module/skia/web/{JsiImageFilterFactory.js → JsiSkImageFilterFactory.js} +1 -1
  86. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -0
  87. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkPath.js +65 -52
  89. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkShaderFactory.js +1 -1
  91. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  92. package/lib/module/skia/web/JsiSkVerticesFactory.js +24 -1
  93. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  94. package/lib/module/skia/web/JsiSkia.js +1 -1
  95. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  96. package/lib/module/values/api.js +1 -1
  97. package/lib/module/values/api.js.map +1 -1
  98. package/lib/module/values/api.web.js +1 -1
  99. package/lib/module/values/api.web.js.map +1 -1
  100. package/lib/module/values/hooks/index.js +1 -1
  101. package/lib/module/values/hooks/index.js.map +1 -1
  102. package/lib/module/values/hooks/useComputedValue.js +18 -0
  103. package/lib/module/values/hooks/useComputedValue.js.map +1 -0
  104. package/lib/module/values/web/{RNSkDerivedValue.js → RNSkComputedValue.js} +2 -2
  105. package/lib/module/values/web/RNSkComputedValue.js.map +1 -0
  106. package/lib/module/values/web/api.js +3 -3
  107. package/lib/module/values/web/api.js.map +1 -1
  108. package/lib/module/views/SkiaView.web.js +4 -4
  109. package/lib/module/views/SkiaView.web.js.map +1 -1
  110. package/lib/module/web/index.js +3 -1
  111. package/lib/module/web/index.js.map +1 -1
  112. package/lib/typescript/src/mock/index.d.ts +47 -0
  113. package/lib/typescript/src/skia/core/Data.d.ts +3 -3
  114. package/lib/typescript/src/skia/types/Font/Font.d.ts +8 -9
  115. package/lib/typescript/src/skia/types/Image/Image.d.ts +5 -5
  116. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +3 -3
  117. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -2
  118. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +1 -0
  119. package/lib/typescript/src/skia/types/Skia.d.ts +1 -1
  120. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -1
  121. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +3 -3
  122. package/lib/typescript/src/skia/web/{JsiImageFilterFactory.d.ts → JsiSkImageFilterFactory.d.ts} +0 -0
  123. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -1
  124. package/lib/typescript/src/values/api.d.ts +1 -1
  125. package/lib/typescript/src/values/api.web.d.ts +1 -1
  126. package/lib/typescript/src/values/hooks/index.d.ts +1 -1
  127. package/lib/typescript/src/values/hooks/{useDerivedValue.d.ts → useComputedValue.d.ts} +2 -1
  128. package/lib/typescript/src/values/types.d.ts +2 -2
  129. package/lib/typescript/src/values/web/{RNSkDerivedValue.d.ts → RNSkComputedValue.d.ts} +1 -1
  130. package/package.json +2 -1
  131. package/src/mock/index.ts +156 -0
  132. package/src/skia/core/Data.ts +67 -50
  133. package/src/skia/core/Typeface.ts +6 -1
  134. package/src/skia/types/Font/Font.ts +9 -14
  135. package/src/skia/types/Image/Image.ts +4 -4
  136. package/src/skia/types/Paint/Paint.ts +1 -1
  137. package/src/skia/types/Path/Path.ts +0 -1
  138. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -0
  139. package/src/skia/types/Shader/Shader.ts +3 -5
  140. package/src/skia/types/Skia.ts +1 -1
  141. package/src/skia/web/JsiSkCanvas.ts +2 -2
  142. package/src/skia/web/JsiSkFont.ts +7 -3
  143. package/src/skia/web/JsiSkFontMgr.ts +0 -4
  144. package/src/skia/web/JsiSkImage.ts +37 -16
  145. package/src/skia/web/{JsiImageFilterFactory.ts → JsiSkImageFilterFactory.ts} +0 -0
  146. package/src/skia/web/JsiSkPaint.ts +1 -1
  147. package/src/skia/web/JsiSkPath.ts +64 -47
  148. package/src/skia/web/JsiSkShaderFactory.ts +4 -1
  149. package/src/skia/web/JsiSkVerticesFactory.ts +15 -1
  150. package/src/skia/web/JsiSkia.ts +2 -2
  151. package/src/values/api.ts +1 -1
  152. package/src/values/api.web.ts +1 -1
  153. package/src/values/hooks/index.ts +1 -1
  154. package/src/values/hooks/{useDerivedValue.ts → useComputedValue.ts} +8 -3
  155. package/src/values/types.ts +2 -2
  156. package/src/values/web/{RNSkDerivedValue.ts → RNSkComputedValue.ts} +1 -1
  157. package/src/values/web/api.ts +3 -3
  158. package/src/views/SkiaView.web.tsx +9 -11
  159. package/src/web/index.ts +3 -1
  160. package/lib/commonjs/skia/web/JsiImageFilterFactory.js.map +0 -1
  161. package/lib/commonjs/values/hooks/useDerivedValue.js +0 -25
  162. package/lib/commonjs/values/hooks/useDerivedValue.js.map +0 -1
  163. package/lib/commonjs/values/web/RNSkDerivedValue.js.map +0 -1
  164. package/lib/module/skia/web/JsiImageFilterFactory.js.map +0 -1
  165. package/lib/module/values/hooks/useDerivedValue.js +0 -14
  166. package/lib/module/values/hooks/useDerivedValue.js.map +0 -1
  167. package/lib/module/values/web/RNSkDerivedValue.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ /*global btoa, atob*/
1
2
  import type { CanvasKit, Image } from "canvaskit-wasm";
2
3
 
3
4
  import type {
@@ -10,7 +11,8 @@ import type {
10
11
  TileMode,
11
12
  } from "../types";
12
13
 
13
- import { ckEnum, HostObject } from "./Host";
14
+ import { ckEnum, HostObject, toValue } from "./Host";
15
+ import { JsiSkShader } from "./JsiSkShader";
14
16
 
15
17
  export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
16
18
  constructor(CanvasKit: CanvasKit, ref: Image) {
@@ -26,26 +28,44 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
26
28
  }
27
29
 
28
30
  makeShaderOptions(
29
- _tx: TileMode,
30
- _ty: TileMode,
31
- _fm: FilterMode,
32
- _mm: MipmapMode,
33
- _localMatrix?: SkMatrix
31
+ tx: TileMode,
32
+ ty: TileMode,
33
+ fm: FilterMode,
34
+ mm: MipmapMode,
35
+ localMatrix?: SkMatrix
34
36
  ): SkShader {
35
- throw new Error("Not implemented yet");
37
+ return new JsiSkShader(
38
+ this.CanvasKit,
39
+ this.ref.makeShaderOptions(
40
+ ckEnum(tx),
41
+ ckEnum(ty),
42
+ ckEnum(fm),
43
+ ckEnum(mm),
44
+ localMatrix ? toValue(localMatrix) : undefined
45
+ )
46
+ );
36
47
  }
37
48
 
38
49
  makeShaderCubic(
39
- _tx: TileMode,
40
- _ty: TileMode,
41
- _B: number,
42
- _C: number,
43
- _localMatrix?: SkMatrix
50
+ tx: TileMode,
51
+ ty: TileMode,
52
+ B: number,
53
+ C: number,
54
+ localMatrix?: SkMatrix
44
55
  ): SkShader {
45
- throw new Error("Not implemented yet");
56
+ return new JsiSkShader(
57
+ this.CanvasKit,
58
+ this.ref.makeShaderCubic(
59
+ ckEnum(tx),
60
+ ckEnum(ty),
61
+ B,
62
+ C,
63
+ localMatrix ? toValue(localMatrix) : undefined
64
+ )
65
+ );
46
66
  }
47
67
 
48
- encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array {
68
+ encodeToBytes(fmt?: ImageFormat, quality?: number) {
49
69
  let result: Uint8Array | null;
50
70
  if (fmt && quality) {
51
71
  result = this.ref.encodeToBytes(ckEnum(fmt), quality);
@@ -60,7 +80,8 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
60
80
  return result;
61
81
  }
62
82
 
63
- encodeToBase64(_fmt?: ImageFormat, _quality?: number): string {
64
- throw new Error("Not implemented yet");
83
+ encodeToBase64(fmt?: ImageFormat, quality?: number) {
84
+ const bytes = this.encodeToBytes(fmt, quality);
85
+ return btoa(String.fromCharCode(...bytes));
65
86
  }
66
87
  }
@@ -1,6 +1,7 @@
1
1
  import type { CanvasKit, Paint } from "canvaskit-wasm";
2
2
 
3
3
  import type {
4
+ StrokeJoin,
4
5
  BlendMode,
5
6
  SkColor,
6
7
  SkColorFilter,
@@ -8,7 +9,6 @@ import type {
8
9
  SkPaint,
9
10
  SkShader,
10
11
  StrokeCap,
11
- StrokeJoin,
12
12
  PaintStyle,
13
13
  SkMaskFilter,
14
14
  SkPathEffect,
@@ -17,6 +17,29 @@ import { ckEnum, HostObject, optEnum, toValue } from "./Host";
17
17
  import { JsiSkPoint } from "./JsiSkPoint";
18
18
  import { JsiSkRect } from "./JsiSkRect";
19
19
 
20
+ const CommandCount = {
21
+ [PathVerb.Move]: 3,
22
+ [PathVerb.Line]: 3,
23
+ [PathVerb.Quad]: 5,
24
+ [PathVerb.Conic]: 6,
25
+ [PathVerb.Cubic]: 7,
26
+ [PathVerb.Close]: 1,
27
+ };
28
+
29
+ const areCmdsInterpolatable = (cmd1: PathCommand[], cmd2: PathCommand[]) => {
30
+ if (cmd1.length !== cmd2.length) {
31
+ return false;
32
+ }
33
+ for (let i = 0; i < cmd1.length; i++) {
34
+ if (cmd1[i][0] !== cmd2[i][0]) {
35
+ return false;
36
+ } else if (cmd1[i][0] === PathVerb.Conic && cmd1[i][5] !== cmd2[i][5]) {
37
+ return false;
38
+ }
39
+ }
40
+ return true;
41
+ };
42
+
20
43
  export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
21
44
  constructor(CanvasKit: CanvasKit, ref: Path) {
22
45
  super(CanvasKit, ref, "Path");
@@ -300,20 +323,25 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
300
323
  // throw new NotImplementedOnRNWeb();
301
324
  const cmd1 = this.toCmds();
302
325
  const cmd2 = end.toCmds();
303
- if (cmd1.length !== cmd2.length) {
326
+ if (!areCmdsInterpolatable(cmd1, cmd2)) {
304
327
  return null;
305
328
  }
306
329
  const interpolated: PathCommand[] = [];
307
- for (let i = 0; i < cmd1.length; i++) {
308
- if (cmd1[i][0] !== cmd2[i][0]) {
309
- return null;
310
- }
311
- const cmd: PathCommand = [cmd1[i][0]];
312
- for (let j = 1; j < cmd1[i].length; j++) {
313
- cmd.push(cmd2[i][j] + (cmd1[i][j] - cmd2[i][j]) * t);
314
- }
315
- interpolated.push(cmd);
316
- }
330
+ cmd1.forEach((cmd, i) => {
331
+ const interpolatedCmd = [cmd[0]];
332
+ interpolated.push(interpolatedCmd);
333
+ cmd.forEach((c, j) => {
334
+ if (j === 0) {
335
+ return;
336
+ }
337
+ if (interpolatedCmd[0] === PathVerb.Conic && j === 5) {
338
+ interpolatedCmd.push(c);
339
+ } else {
340
+ const c2 = cmd2[i][j];
341
+ interpolatedCmd.push(c2 + (c - c2) * t);
342
+ }
343
+ });
344
+ });
317
345
  const path = this.CanvasKit.Path.MakeFromCmds(interpolated.flat());
318
346
  if (path === null) {
319
347
  return null;
@@ -326,44 +354,33 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
326
354
  // throw new NotImplementedOnRNWeb();
327
355
  const cmd1 = this.toCmds();
328
356
  const cmd2 = path2.toCmds();
329
- if (cmd1.length !== cmd2.length) {
330
- return false;
331
- }
332
- for (let i = 0; i < cmd1.length; i++) {
333
- if (cmd1[i][0] !== cmd2[i][0]) {
334
- return false;
335
- }
336
- }
337
- return true;
338
- }
339
-
340
- toCmds(): PathCommand[] {
341
- const cmds: PathCommand[] = [];
342
- let cmd = [];
343
- const flatCmds = this.ref.toCmds();
344
- const CmdCount = {
345
- [PathVerb.Move]: 3,
346
- [PathVerb.Line]: 3,
347
- [PathVerb.Quad]: 5,
348
- [PathVerb.Conic]: 6,
349
- [PathVerb.Cubic]: 7,
350
- [PathVerb.Close]: 0,
351
- [PathVerb.Done]: 0,
352
- };
353
- for (let i = 0; i < flatCmds.length; i++) {
354
- if (cmd.length === 0 && flatCmds[i] === PathVerb.Done) {
355
- break;
357
+ return areCmdsInterpolatable(cmd1, cmd2);
358
+ }
359
+
360
+ toCmds() {
361
+ const cmds = this.ref.toCmds();
362
+ const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {
363
+ if (i === 0) {
364
+ acc.push([]);
356
365
  }
357
- const c = flatCmds[i];
358
- cmd.push(c);
359
- if (cmd.length > 1) {
360
- const length = CmdCount[cmd[0] as PathVerb];
361
- if (cmd.length === length) {
362
- cmds.push(cmd);
363
- cmd = [];
366
+ const current = acc[acc.length - 1];
367
+ if (current.length === 0) {
368
+ current.push(cmd);
369
+ const length = CommandCount[current[0] as PathVerb];
370
+ if (current.length === length && i !== cmds.length - 1) {
371
+ acc.push([]);
372
+ }
373
+ } else {
374
+ const length = CommandCount[current[0] as PathVerb];
375
+ if (current.length < length) {
376
+ current.push(cmd);
377
+ }
378
+ if (current.length === length && i !== cmds.length - 1) {
379
+ acc.push([]);
364
380
  }
365
381
  }
366
- }
367
- return cmds.concat(cmd);
382
+ return acc;
383
+ }, []);
384
+ return result;
368
385
  }
369
386
  }
@@ -172,7 +172,10 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
172
172
  MakeColor(color: SkColor) {
173
173
  return new JsiSkShader(
174
174
  this.CanvasKit,
175
- this.CanvasKit.Shader.MakeColor(toValue(color))
175
+ this.CanvasKit.Shader.MakeColor(
176
+ toValue(color),
177
+ this.CanvasKit.ColorSpace.SRGB
178
+ )
176
179
  );
177
180
  }
178
181
  }
@@ -5,6 +5,20 @@ import type { SkColor, SkPoint, VertexMode } from "../types";
5
5
  import { ckEnum } from "./Host";
6
6
  import { JsiSkVertices } from "./JsiSkVertices";
7
7
 
8
+ const concat = (...arrays: Float32Array[]) => {
9
+ let totalLength = 0;
10
+ for (const arr of arrays) {
11
+ totalLength += arr.length;
12
+ }
13
+ const result = new Float32Array(totalLength);
14
+ let offset = 0;
15
+ for (const arr of arrays) {
16
+ result.set(arr, offset);
17
+ offset += arr.length;
18
+ }
19
+ return result;
20
+ };
21
+
8
22
  export const MakeVertices = (
9
23
  CanvasKit: CanvasKit,
10
24
  mode: VertexMode,
@@ -20,7 +34,7 @@ export const MakeVertices = (
20
34
  ckEnum(mode),
21
35
  positions.map(({ x, y }) => [x, y]).flat(),
22
36
  (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),
23
- colors,
37
+ !colors ? null : colors.reduce((a, c) => concat(a, c)),
24
38
  indices,
25
39
  isVolatile
26
40
  )
@@ -27,7 +27,7 @@ import { JsiSkColorFilterFactory } from "./JsiSkColorFilterFactory";
27
27
  import { JsiSkTypefaceFactory } from "./JsiSkTypefaceFactory";
28
28
  import { JsiSkMaskFilterFactory } from "./JsiSkMaskFilterFactory";
29
29
  import { JsiSkRuntimeEffectFactory } from "./JsiSkRuntimeEffectFactory";
30
- import { JsiSkImageFilterFactory } from "./JsiImageFilterFactory";
30
+ import { JsiSkImageFilterFactory } from "./JsiSkImageFilterFactory";
31
31
  import { JsiSkShaderFactory } from "./JsiSkShaderFactory";
32
32
  import { JsiSkPathEffectFactory } from "./JsiSkPathEffectFactory";
33
33
  import { JsiSkDataFactory } from "./JsiSkDataFactory";
@@ -63,7 +63,7 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
63
63
  new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),
64
64
  Picture: new JsiSkPictureFactory(CanvasKit),
65
65
  Path: new JsiSkPathFactory(CanvasKit),
66
- Matrix: (matrix?: number[]) =>
66
+ Matrix: (matrix?: readonly number[]) =>
67
67
  new JsiSkMatrix(
68
68
  CanvasKit,
69
69
  matrix
package/src/values/api.ts CHANGED
@@ -7,4 +7,4 @@ declare global {
7
7
  const { SkiaValueApi } = global;
8
8
  export const ValueApi = SkiaValueApi;
9
9
 
10
- export const { createValue, createDerivedValue } = ValueApi;
10
+ export const { createValue, createComputedValue } = ValueApi;
@@ -2,4 +2,4 @@ import { ValueApi as ValueApiWeb } from "./web";
2
2
 
3
3
  export const ValueApi = ValueApiWeb;
4
4
 
5
- export const { createValue, createDerivedValue } = ValueApi;
5
+ export const { createValue, createComputedValue } = ValueApi;
@@ -1,4 +1,4 @@
1
1
  export * from "./useClockValue";
2
- export * from "./useDerivedValue";
2
+ export * from "./useComputedValue";
3
3
  export * from "./useValue";
4
4
  export * from "./useValueEffect";
@@ -4,15 +4,20 @@ import { ValueApi } from "../api";
4
4
  import { isValue } from "../../renderer/processors";
5
5
 
6
6
  /**
7
- * Creates a new derived value - a value that will calculate its value depending
7
+ * Creates a new computed value - a value that will calculate its value depending
8
8
  * on other values.
9
9
  * @param cb Callback to calculate new value
10
10
  * @param values Dependant values
11
11
  * @returns A readonly value
12
12
  */
13
- export const useDerivedValue = <R>(cb: () => R, values: unknown[]) =>
13
+ export const useComputedValue = <R>(cb: () => R, values: unknown[]) =>
14
14
  useMemo(
15
- () => ValueApi.createDerivedValue<R>(cb, values.filter(isValue)),
15
+ () => ValueApi.createComputedValue<R>(cb, values.filter(isValue)),
16
16
  // eslint-disable-next-line react-hooks/exhaustive-deps
17
17
  values
18
18
  );
19
+
20
+ export const useDerivedValue = <R>(cb: () => R, values: unknown[]) => {
21
+ console.warn("useDerivedValue is deprecated. Use useComputedValue instead.");
22
+ return useComputedValue(cb, values);
23
+ };
@@ -46,10 +46,10 @@ export interface ISkiaValueApi {
46
46
  */
47
47
  createValue: <T>(initialValue: T) => SkiaMutableValue<T>;
48
48
  /**
49
- * Creates a derived value. This is a calculated value that returns the result of
49
+ * Creates a computed value. This is a calculated value that returns the result of
50
50
  * a function that is called with the values of the dependencies.
51
51
  */
52
- createDerivedValue: <R>(
52
+ createComputedValue: <R>(
53
53
  cb: () => R,
54
54
  values: Array<SkiaValue<unknown>>
55
55
  ) => SkiaValue<R>;
@@ -2,7 +2,7 @@ import type { DependencyList } from "react";
2
2
 
3
3
  import { RNSkReadonlyValue } from "./RNSkReadonlyValue";
4
4
 
5
- export class RNSkDerivedValue<T> extends RNSkReadonlyValue<T> {
5
+ export class RNSkComputedValue<T> extends RNSkReadonlyValue<T> {
6
6
  constructor(callback: () => T, dependencies: DependencyList) {
7
7
  // Initialize dependencies - we can't call this yet, since
8
8
  // super if not called and it requires a start value to be set.
@@ -9,18 +9,18 @@ import type {
9
9
 
10
10
  import { RNSkAnimation } from "./RNSkAnimation";
11
11
  import { RNSkClockValue } from "./RNSkClockValue";
12
- import { RNSkDerivedValue } from "./RNSkDerivedValue";
12
+ import { RNSkComputedValue } from "./RNSkComputedValue";
13
13
  import { RNSkValue } from "./RNSkValue";
14
14
 
15
15
  export const ValueApi: ISkiaValueApi = {
16
16
  createValue: function <T>(initialValue: T): SkiaMutableValue<T> {
17
17
  return new RNSkValue(initialValue);
18
18
  },
19
- createDerivedValue: function <R>(
19
+ createComputedValue: function <R>(
20
20
  cb: () => R,
21
21
  values: SkiaValue<unknown>[]
22
22
  ): SkiaValue<R> {
23
- return new RNSkDerivedValue(cb, values);
23
+ return new RNSkComputedValue(cb, values);
24
24
  },
25
25
  createClockValue: function (): SkiaClockValue {
26
26
  return new RNSkClockValue(requestAnimationFrame.bind(window));
@@ -175,17 +175,15 @@ export class SkiaView extends React.Component<
175
175
  const { mode, debug = false, ...viewProps } = this.props;
176
176
  return (
177
177
  <View {...viewProps} onLayout={this.onLayout.bind(this)}>
178
- {this.state.width > -1 ? (
179
- <canvas
180
- ref={this._canvasRef}
181
- width={`${this.state.width}px`}
182
- height={`${this.state.height}px`}
183
- onPointerDown={this.handleTouchStart.bind(this)}
184
- onPointerMove={this.handleTouchMove.bind(this)}
185
- onPointerUp={this.handleTouchEnd.bind(this)}
186
- onPointerCancel={this.handleTouchCancel.bind(this)}
187
- />
188
- ) : null}
178
+ <canvas
179
+ ref={this._canvasRef}
180
+ width={this.state.width}
181
+ height={this.state.height}
182
+ onPointerDown={this.handleTouchStart.bind(this)}
183
+ onPointerMove={this.handleTouchMove.bind(this)}
184
+ onPointerUp={this.handleTouchEnd.bind(this)}
185
+ onPointerCancel={this.handleTouchCancel.bind(this)}
186
+ />
189
187
  </View>
190
188
  );
191
189
  }
package/src/web/index.ts CHANGED
@@ -1,4 +1,6 @@
1
- import CanvasKitInit from "canvaskit-wasm";
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-expect-error
3
+ import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
2
4
  import type { CanvasKit as CanvasKitType } from "canvaskit-wasm";
3
5
 
4
6
  declare global {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["JsiImageFilterFactory.ts"],"names":["JsiSkImageFilterFactory","Host","constructor","CanvasKit","MakeOffset","_dx","_dy","_input","NotImplementedOnRNWeb","MakeDisplacementMap","_channelX","_channelY","_scale","_in1","MakeShader","_shader","MakeBlur","sigmaX","sigmaY","mode","input","JsiSkImageFilter","ImageFilter","MakeColorFilter","cf","MakeCompose","outer","inner","MakeDropShadow","_sigmaX","_sigmaY","_color","_cropRect","MakeDropShadowOnly","MakeErode","_rx","_ry","MakeDilate","MakeBlend","_mode","_background","_foreground","MakeRuntimeShader","_builder","_childShaderName"],"mappings":";;;;;;;AAeA;;AACA;;AAEO,MAAMA,uBAAN,SACGC,UADH,CAGP;AACEC,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChC,UAAMA,SAAN;AACD;;AAEDC,EAAAA,UAAU,CACRC,GADQ,EAERC,GAFQ,EAGRC,MAHQ,EAIO;AACf,UAAM,IAAIC,2BAAJ,EAAN;AACD;;AAEDC,EAAAA,mBAAmB,CACjBC,SADiB,EAEjBC,SAFiB,EAGjBC,MAHiB,EAIjBC,IAJiB,EAKjBN,MALiB,EAMF;AACf,UAAM,IAAIC,2BAAJ,EAAN;AACD;;AAEDM,EAAAA,UAAU,CAACC,OAAD,EAAoBR,MAApB,EAAiE;AACzE,UAAM,IAAIC,2BAAJ,EAAN;AACD;;AAEDQ,EAAAA,QAAQ,CACNC,MADM,EAENC,MAFM,EAGNC,IAHM,EAINC,KAJM,EAKN;AACA,WAAO,IAAIC,kCAAJ,CACL,KAAKlB,SADA,EAEL,KAAKA,SAAL,CAAemB,WAAf,CAA2BN,QAA3B,CACEC,MADF,EAEEC,MAFF,EAGE,kBAAOC,IAAP,CAHF,EAIEC,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwB,mBAAQA,KAAR,CAJ1B,CAFK,CAAP;AASD;;AAEDG,EAAAA,eAAe,CAACC,EAAD,EAAoBJ,KAApB,EAAiD;AAC9D,WAAO,IAAIC,kCAAJ,CACL,KAAKlB,SADA,EAEL,KAAKA,SAAL,CAAemB,WAAf,CAA2BC,eAA3B,CACE,mBAAQC,EAAR,CADF,EAEEJ,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwB,mBAAQA,KAAR,CAF1B,CAFK,CAAP;AAOD;;AAEDK,EAAAA,WAAW,CAACC,KAAD,EAA8BC,KAA9B,EAA2D;AACpE,WAAO,IAAIN,kCAAJ,CACL,KAAKlB,SADA,EAEL,KAAKA,SAAL,CAAemB,WAAf,CAA2BG,WAA3B,CACEC,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwB,mBAAQA,KAAR,CAD1B,EAEEC,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwB,mBAAQA,KAAR,CAF1B,CAFK,CAAP;AAOD;;AAEDC,EAAAA,cAAc,CACZvB,GADY,EAEZC,GAFY,EAGZuB,OAHY,EAIZC,OAJY,EAKZC,MALY,EAMZxB,MANY,EAOZyB,SAPY,EAQG;AACf,UAAM,IAAIxB,2BAAJ,EAAN;AACD;;AAEDyB,EAAAA,kBAAkB,CAChB5B,GADgB,EAEhBC,GAFgB,EAGhBuB,OAHgB,EAIhBC,OAJgB,EAKhBC,MALgB,EAMhBxB,MANgB,EAOhByB,SAPgB,EAQD;AACf,UAAM,IAAIxB,2BAAJ,EAAN;AACD;;AAED0B,EAAAA,SAAS,CACPC,GADO,EAEPC,GAFO,EAGP7B,MAHO,EAIPyB,SAJO,EAKQ;AACf,UAAM,IAAIxB,2BAAJ,EAAN;AACD;;AAED6B,EAAAA,UAAU,CACRF,GADQ,EAERC,GAFQ,EAGR7B,MAHQ,EAIRyB,SAJQ,EAKO;AACf,UAAM,IAAIxB,2BAAJ,EAAN;AACD;;AAED8B,EAAAA,SAAS,CACPC,KADO,EAEPC,WAFO,EAGPC,WAHO,EAIPT,SAJO,EAKQ;AACf,UAAM,IAAIxB,2BAAJ,EAAN;AACD;;AAEDkC,EAAAA,iBAAiB,CACfC,QADe,EAEfC,gBAFe,EAGfrC,MAHe,EAIA;AACf,UAAM,IAAIC,2BAAJ,EAAN;AACD;;AAzHH","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n ColorChannel,\n ImageFilterFactory,\n SkColor,\n SkColorFilter,\n SkImageFilter,\n BlendMode,\n SkRect,\n SkRuntimeShaderBuilder,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { Host, NotImplementedOnRNWeb, ckEnum, toValue } from \"./Host\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\n\nexport class JsiSkImageFilterFactory\n extends Host\n implements ImageFilterFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeOffset(\n _dx: number,\n _dy: number,\n _input: SkImageFilter | null\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeDisplacementMap(\n _channelX: ColorChannel,\n _channelY: ColorChannel,\n _scale: number,\n _in1: SkImageFilter,\n _input: SkImageFilter | null\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeShader(_shader: SkShader, _input: SkImageFilter | null): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeBlur(\n sigmaX: number,\n sigmaY: number,\n mode: TileMode,\n input: SkImageFilter | null\n ) {\n return new JsiSkImageFilter(\n this.CanvasKit,\n this.CanvasKit.ImageFilter.MakeBlur(\n sigmaX,\n sigmaY,\n ckEnum(mode),\n input === null ? null : toValue(input)\n )\n );\n }\n\n MakeColorFilter(cf: SkColorFilter, input: SkImageFilter | null) {\n return new JsiSkImageFilter(\n this.CanvasKit,\n this.CanvasKit.ImageFilter.MakeColorFilter(\n toValue(cf),\n input === null ? null : toValue(input)\n )\n );\n }\n\n MakeCompose(outer: SkImageFilter | null, inner: SkImageFilter | null) {\n return new JsiSkImageFilter(\n this.CanvasKit,\n this.CanvasKit.ImageFilter.MakeCompose(\n outer === null ? null : toValue(outer),\n inner === null ? null : toValue(inner)\n )\n );\n }\n\n MakeDropShadow(\n _dx: number,\n _dy: number,\n _sigmaX: number,\n _sigmaY: number,\n _color: SkColor,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeDropShadowOnly(\n _dx: number,\n _dy: number,\n _sigmaX: number,\n _sigmaY: number,\n _color: SkColor,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeErode(\n _rx: number,\n _ry: number,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeDilate(\n _rx: number,\n _ry: number,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeBlend(\n _mode: BlendMode,\n _background: SkImageFilter,\n _foreground: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeRuntimeShader(\n _builder: SkRuntimeShaderBuilder,\n _childShaderName: string | null,\n _input: SkImageFilter | null\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n}\n"]}
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDerivedValue = void 0;
7
-
8
- var _react = require("react");
9
-
10
- var _api = require("../api");
11
-
12
- var _processors = require("../../renderer/processors");
13
-
14
- /**
15
- * Creates a new derived value - a value that will calculate its value depending
16
- * on other values.
17
- * @param cb Callback to calculate new value
18
- * @param values Dependant values
19
- * @returns A readonly value
20
- */
21
- const useDerivedValue = (cb, values) => (0, _react.useMemo)(() => _api.ValueApi.createDerivedValue(cb, values.filter(_processors.isValue)), // eslint-disable-next-line react-hooks/exhaustive-deps
22
- values);
23
-
24
- exports.useDerivedValue = useDerivedValue;
25
- //# sourceMappingURL=useDerivedValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["useDerivedValue.ts"],"names":["useDerivedValue","cb","values","ValueApi","createDerivedValue","filter","isValue"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC7B,oBACE,MAAMC,cAASC,kBAAT,CAA+BH,EAA/B,EAAmCC,MAAM,CAACG,MAAP,CAAcC,mBAAd,CAAnC,CADR,EAEE;AACAJ,MAHF,CADK","sourcesContent":["import { useMemo } from \"react\";\n\nimport { ValueApi } from \"../api\";\nimport { isValue } from \"../../renderer/processors\";\n\n/**\n * Creates a new derived value - a value that will calculate its value depending\n * on other values.\n * @param cb Callback to calculate new value\n * @param values Dependant values\n * @returns A readonly value\n */\nexport const useDerivedValue = <R>(cb: () => R, values: unknown[]) =>\n useMemo(\n () => ValueApi.createDerivedValue<R>(cb, values.filter(isValue)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n values\n );\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["RNSkDerivedValue.ts"],"names":["RNSkDerivedValue","RNSkReadonlyValue","constructor","callback","dependencies","unsubscribers","notifyUpdateRef","current","undefined","forEach","dep","push","addListener","_unsubscribers","dependecyUpdated","bind","_callback","update","unsubscribe"],"mappings":";;;;;;;AAEA;;;;AAEO,MAAMA,gBAAN,SAAkCC,oCAAlC,CAAuD;AAC5DC,EAAAA,WAAW,CAACC,QAAD,EAAoBC,YAApB,EAAkD;AAC3D;AACA;AACA,UAAMC,aAAgC,GAAG,EAAzC;AACA,UAAMC,eAAsD,GAAG;AAC7DC,MAAAA,OAAO,EAAEC;AADoD,KAA/D;AAGAJ,IAAAA,YAAY,CAACK,OAAb,CAAsBC,GAAD,IAAS;AAC5B,UAAI,kBAAkBA,GAAlB,IAAyB,iBAAiBA,GAA9C,EAAmD;AACjDL,QAAAA,aAAa,CAACM,IAAd,CACGD,GAAD,CAAoCE,WAApC,CAAgD;AAAA;;AAAA,0CAC9CN,eAAe,CAACC,OAD8B,0DAC9C,2BAAAD,eAAe,CAD+B;AAAA,SAAhD,CADF;AAKD;AACF,KARD;AASA,UAAMH,QAAQ,EAAd;;AAhB2D;;AAAA;;AAiB3D,SAAKU,cAAL,GAAsBR,aAAtB;AACAC,IAAAA,eAAe,CAACC,OAAhB,GAA0B,KAAKO,gBAAL,CAAsBC,IAAtB,CAA2B,IAA3B,CAA1B;AACA,SAAKC,SAAL,GAAiBb,QAAjB;AACD;;AAEOW,EAAAA,gBAAgB,GAAG;AACzB,SAAKG,MAAL,CAAY,KAAKD,SAAL,EAAZ;AACD;;AAKME,EAAAA,WAAW,GAAG;AACnB,SAAKL,cAAL,CAAoBJ,OAApB,CAA6BS,WAAD,IAAiBA,WAAW,EAAxD;AACD;;AAhC2D","sourcesContent":["import type { DependencyList } from \"react\";\n\nimport { RNSkReadonlyValue } from \"./RNSkReadonlyValue\";\n\nexport class RNSkDerivedValue<T> extends RNSkReadonlyValue<T> {\n constructor(callback: () => T, dependencies: DependencyList) {\n // Initialize dependencies - we can't call this yet, since\n // super if not called and it requires a start value to be set.\n const unsubscribers: Array<() => void> = [];\n const notifyUpdateRef: { current: (() => void) | undefined } = {\n current: undefined,\n };\n dependencies.forEach((dep) => {\n if (\"__typename__\" in dep && \"addListener\" in dep) {\n unsubscribers.push(\n (dep as RNSkReadonlyValue<unknown>).addListener(() =>\n notifyUpdateRef.current?.()\n )\n );\n }\n });\n super(callback());\n this._unsubscribers = unsubscribers;\n notifyUpdateRef.current = this.dependecyUpdated.bind(this);\n this._callback = callback;\n }\n\n private dependecyUpdated() {\n this.update(this._callback());\n }\n\n private _callback: () => T;\n private _unsubscribers: Array<() => void>;\n\n public unsubscribe() {\n this._unsubscribers.forEach((unsubscribe) => unsubscribe());\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["JsiImageFilterFactory.ts"],"names":["Host","NotImplementedOnRNWeb","ckEnum","toValue","JsiSkImageFilter","JsiSkImageFilterFactory","constructor","CanvasKit","MakeOffset","_dx","_dy","_input","MakeDisplacementMap","_channelX","_channelY","_scale","_in1","MakeShader","_shader","MakeBlur","sigmaX","sigmaY","mode","input","ImageFilter","MakeColorFilter","cf","MakeCompose","outer","inner","MakeDropShadow","_sigmaX","_sigmaY","_color","_cropRect","MakeDropShadowOnly","MakeErode","_rx","_ry","MakeDilate","MakeBlend","_mode","_background","_foreground","MakeRuntimeShader","_builder","_childShaderName"],"mappings":"AAeA,SAASA,IAAT,EAAeC,qBAAf,EAAsCC,MAAtC,EAA8CC,OAA9C,QAA6D,QAA7D;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA,OAAO,MAAMC,uBAAN,SACGL,IADH,CAGP;AACEM,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChC,UAAMA,SAAN;AACD;;AAEDC,EAAAA,UAAU,CACRC,GADQ,EAERC,GAFQ,EAGRC,MAHQ,EAIO;AACf,UAAM,IAAIV,qBAAJ,EAAN;AACD;;AAEDW,EAAAA,mBAAmB,CACjBC,SADiB,EAEjBC,SAFiB,EAGjBC,MAHiB,EAIjBC,IAJiB,EAKjBL,MALiB,EAMF;AACf,UAAM,IAAIV,qBAAJ,EAAN;AACD;;AAEDgB,EAAAA,UAAU,CAACC,OAAD,EAAoBP,MAApB,EAAiE;AACzE,UAAM,IAAIV,qBAAJ,EAAN;AACD;;AAEDkB,EAAAA,QAAQ,CACNC,MADM,EAENC,MAFM,EAGNC,IAHM,EAINC,KAJM,EAKN;AACA,WAAO,IAAInB,gBAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeiB,WAAf,CAA2BL,QAA3B,CACEC,MADF,EAEEC,MAFF,EAGEnB,MAAM,CAACoB,IAAD,CAHR,EAIEC,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwBpB,OAAO,CAACoB,KAAD,CAJjC,CAFK,CAAP;AASD;;AAEDE,EAAAA,eAAe,CAACC,EAAD,EAAoBH,KAApB,EAAiD;AAC9D,WAAO,IAAInB,gBAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeiB,WAAf,CAA2BC,eAA3B,CACEtB,OAAO,CAACuB,EAAD,CADT,EAEEH,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwBpB,OAAO,CAACoB,KAAD,CAFjC,CAFK,CAAP;AAOD;;AAEDI,EAAAA,WAAW,CAACC,KAAD,EAA8BC,KAA9B,EAA2D;AACpE,WAAO,IAAIzB,gBAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeiB,WAAf,CAA2BG,WAA3B,CACEC,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwBzB,OAAO,CAACyB,KAAD,CADjC,EAEEC,KAAK,KAAK,IAAV,GAAiB,IAAjB,GAAwB1B,OAAO,CAAC0B,KAAD,CAFjC,CAFK,CAAP;AAOD;;AAEDC,EAAAA,cAAc,CACZrB,GADY,EAEZC,GAFY,EAGZqB,OAHY,EAIZC,OAJY,EAKZC,MALY,EAMZtB,MANY,EAOZuB,SAPY,EAQG;AACf,UAAM,IAAIjC,qBAAJ,EAAN;AACD;;AAEDkC,EAAAA,kBAAkB,CAChB1B,GADgB,EAEhBC,GAFgB,EAGhBqB,OAHgB,EAIhBC,OAJgB,EAKhBC,MALgB,EAMhBtB,MANgB,EAOhBuB,SAPgB,EAQD;AACf,UAAM,IAAIjC,qBAAJ,EAAN;AACD;;AAEDmC,EAAAA,SAAS,CACPC,GADO,EAEPC,GAFO,EAGP3B,MAHO,EAIPuB,SAJO,EAKQ;AACf,UAAM,IAAIjC,qBAAJ,EAAN;AACD;;AAEDsC,EAAAA,UAAU,CACRF,GADQ,EAERC,GAFQ,EAGR3B,MAHQ,EAIRuB,SAJQ,EAKO;AACf,UAAM,IAAIjC,qBAAJ,EAAN;AACD;;AAEDuC,EAAAA,SAAS,CACPC,KADO,EAEPC,WAFO,EAGPC,WAHO,EAIPT,SAJO,EAKQ;AACf,UAAM,IAAIjC,qBAAJ,EAAN;AACD;;AAED2C,EAAAA,iBAAiB,CACfC,QADe,EAEfC,gBAFe,EAGfnC,MAHe,EAIA;AACf,UAAM,IAAIV,qBAAJ,EAAN;AACD;;AAzHH","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n ColorChannel,\n ImageFilterFactory,\n SkColor,\n SkColorFilter,\n SkImageFilter,\n BlendMode,\n SkRect,\n SkRuntimeShaderBuilder,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { Host, NotImplementedOnRNWeb, ckEnum, toValue } from \"./Host\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\n\nexport class JsiSkImageFilterFactory\n extends Host\n implements ImageFilterFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeOffset(\n _dx: number,\n _dy: number,\n _input: SkImageFilter | null\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeDisplacementMap(\n _channelX: ColorChannel,\n _channelY: ColorChannel,\n _scale: number,\n _in1: SkImageFilter,\n _input: SkImageFilter | null\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeShader(_shader: SkShader, _input: SkImageFilter | null): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeBlur(\n sigmaX: number,\n sigmaY: number,\n mode: TileMode,\n input: SkImageFilter | null\n ) {\n return new JsiSkImageFilter(\n this.CanvasKit,\n this.CanvasKit.ImageFilter.MakeBlur(\n sigmaX,\n sigmaY,\n ckEnum(mode),\n input === null ? null : toValue(input)\n )\n );\n }\n\n MakeColorFilter(cf: SkColorFilter, input: SkImageFilter | null) {\n return new JsiSkImageFilter(\n this.CanvasKit,\n this.CanvasKit.ImageFilter.MakeColorFilter(\n toValue(cf),\n input === null ? null : toValue(input)\n )\n );\n }\n\n MakeCompose(outer: SkImageFilter | null, inner: SkImageFilter | null) {\n return new JsiSkImageFilter(\n this.CanvasKit,\n this.CanvasKit.ImageFilter.MakeCompose(\n outer === null ? null : toValue(outer),\n inner === null ? null : toValue(inner)\n )\n );\n }\n\n MakeDropShadow(\n _dx: number,\n _dy: number,\n _sigmaX: number,\n _sigmaY: number,\n _color: SkColor,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeDropShadowOnly(\n _dx: number,\n _dy: number,\n _sigmaX: number,\n _sigmaY: number,\n _color: SkColor,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeErode(\n _rx: number,\n _ry: number,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeDilate(\n _rx: number,\n _ry: number,\n _input: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeBlend(\n _mode: BlendMode,\n _background: SkImageFilter,\n _foreground: SkImageFilter | null,\n _cropRect?: SkRect\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n\n MakeRuntimeShader(\n _builder: SkRuntimeShaderBuilder,\n _childShaderName: string | null,\n _input: SkImageFilter | null\n ): SkImageFilter {\n throw new NotImplementedOnRNWeb();\n }\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { useMemo } from "react";
2
- import { ValueApi } from "../api";
3
- import { isValue } from "../../renderer/processors";
4
- /**
5
- * Creates a new derived value - a value that will calculate its value depending
6
- * on other values.
7
- * @param cb Callback to calculate new value
8
- * @param values Dependant values
9
- * @returns A readonly value
10
- */
11
-
12
- export const useDerivedValue = (cb, values) => useMemo(() => ValueApi.createDerivedValue(cb, values.filter(isValue)), // eslint-disable-next-line react-hooks/exhaustive-deps
13
- values);
14
- //# sourceMappingURL=useDerivedValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["useDerivedValue.ts"],"names":["useMemo","ValueApi","isValue","useDerivedValue","cb","values","createDerivedValue","filter"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,QAAT,QAAyB,QAAzB;AACA,SAASC,OAAT,QAAwB,2BAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC7BL,OAAO,CACL,MAAMC,QAAQ,CAACK,kBAAT,CAA+BF,EAA/B,EAAmCC,MAAM,CAACE,MAAP,CAAcL,OAAd,CAAnC,CADD,EAEL;AACAG,MAHK,CADF","sourcesContent":["import { useMemo } from \"react\";\n\nimport { ValueApi } from \"../api\";\nimport { isValue } from \"../../renderer/processors\";\n\n/**\n * Creates a new derived value - a value that will calculate its value depending\n * on other values.\n * @param cb Callback to calculate new value\n * @param values Dependant values\n * @returns A readonly value\n */\nexport const useDerivedValue = <R>(cb: () => R, values: unknown[]) =>\n useMemo(\n () => ValueApi.createDerivedValue<R>(cb, values.filter(isValue)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n values\n );\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["RNSkDerivedValue.ts"],"names":["RNSkReadonlyValue","RNSkDerivedValue","constructor","callback","dependencies","unsubscribers","notifyUpdateRef","current","undefined","forEach","dep","push","addListener","_unsubscribers","dependecyUpdated","bind","_callback","update","unsubscribe"],"mappings":";;AAEA,SAASA,iBAAT,QAAkC,qBAAlC;AAEA,OAAO,MAAMC,gBAAN,SAAkCD,iBAAlC,CAAuD;AAC5DE,EAAAA,WAAW,CAACC,QAAD,EAAoBC,YAApB,EAAkD;AAC3D;AACA;AACA,UAAMC,aAAgC,GAAG,EAAzC;AACA,UAAMC,eAAsD,GAAG;AAC7DC,MAAAA,OAAO,EAAEC;AADoD,KAA/D;AAGAJ,IAAAA,YAAY,CAACK,OAAb,CAAsBC,GAAD,IAAS;AAC5B,UAAI,kBAAkBA,GAAlB,IAAyB,iBAAiBA,GAA9C,EAAmD;AACjDL,QAAAA,aAAa,CAACM,IAAd,CACGD,GAAD,CAAoCE,WAApC,CAAgD;AAAA;;AAAA,0CAC9CN,eAAe,CAACC,OAD8B,0DAC9C,2BAAAD,eAAe,CAD+B;AAAA,SAAhD,CADF;AAKD;AACF,KARD;AASA,UAAMH,QAAQ,EAAd;;AAhB2D;;AAAA;;AAiB3D,SAAKU,cAAL,GAAsBR,aAAtB;AACAC,IAAAA,eAAe,CAACC,OAAhB,GAA0B,KAAKO,gBAAL,CAAsBC,IAAtB,CAA2B,IAA3B,CAA1B;AACA,SAAKC,SAAL,GAAiBb,QAAjB;AACD;;AAEOW,EAAAA,gBAAgB,GAAG;AACzB,SAAKG,MAAL,CAAY,KAAKD,SAAL,EAAZ;AACD;;AAKME,EAAAA,WAAW,GAAG;AACnB,SAAKL,cAAL,CAAoBJ,OAApB,CAA6BS,WAAD,IAAiBA,WAAW,EAAxD;AACD;;AAhC2D","sourcesContent":["import type { DependencyList } from \"react\";\n\nimport { RNSkReadonlyValue } from \"./RNSkReadonlyValue\";\n\nexport class RNSkDerivedValue<T> extends RNSkReadonlyValue<T> {\n constructor(callback: () => T, dependencies: DependencyList) {\n // Initialize dependencies - we can't call this yet, since\n // super if not called and it requires a start value to be set.\n const unsubscribers: Array<() => void> = [];\n const notifyUpdateRef: { current: (() => void) | undefined } = {\n current: undefined,\n };\n dependencies.forEach((dep) => {\n if (\"__typename__\" in dep && \"addListener\" in dep) {\n unsubscribers.push(\n (dep as RNSkReadonlyValue<unknown>).addListener(() =>\n notifyUpdateRef.current?.()\n )\n );\n }\n });\n super(callback());\n this._unsubscribers = unsubscribers;\n notifyUpdateRef.current = this.dependecyUpdated.bind(this);\n this._callback = callback;\n }\n\n private dependecyUpdated() {\n this.update(this._callback());\n }\n\n private _callback: () => T;\n private _unsubscribers: Array<() => void>;\n\n public unsubscribe() {\n this._unsubscribers.forEach((unsubscribe) => unsubscribe());\n }\n}\n"]}