@shopify/react-native-skia 2.2.12 → 2.2.14

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.
@@ -337,7 +337,6 @@ public:
337
337
  }
338
338
  };
339
339
 
340
- // Add to Drawings.h after existing command structures
341
340
  struct BoxShadowCmdProps {
342
341
  float dx = 0;
343
342
  float dy = 0;
@@ -386,16 +385,17 @@ public:
386
385
  for (size_t i = 0; i < shadowCount; i++) {
387
386
  auto shadowObj =
388
387
  shadowsArray.getValueAtIndex(runtime, i).asObject(runtime);
389
- BoxShadowCmdProps shadow;
390
-
391
- convertProperty(runtime, shadowObj, "dx", shadow.dx, variables);
392
- convertProperty(runtime, shadowObj, "dy", shadow.dy, variables);
393
- convertProperty(runtime, shadowObj, "spread", shadow.spread, variables);
394
- convertProperty(runtime, shadowObj, "blur", shadow.blur, variables);
395
- convertProperty(runtime, shadowObj, "color", shadow.color, variables);
396
- convertProperty(runtime, shadowObj, "inner", shadow.inner, variables);
397
-
398
- shadows.push_back(shadow);
388
+
389
+ // Create shadow directly in vector to avoid copy
390
+ shadows.emplace_back();
391
+ BoxShadowCmdProps &shadow = shadows.back();
392
+
393
+ convertProperty(runtime, shadowObj, "dx", shadow.dx, variables);
394
+ convertProperty(runtime, shadowObj, "dy", shadow.dy, variables);
395
+ convertProperty(runtime, shadowObj, "spread", shadow.spread, variables);
396
+ convertProperty(runtime, shadowObj, "blur", shadow.blur, variables);
397
+ convertProperty(runtime, shadowObj, "color", shadow.color, variables);
398
+ convertProperty(runtime, shadowObj, "inner", shadow.inner, variables);
399
399
  }
400
400
  }
401
401
 
@@ -47,7 +47,7 @@
47
47
  * Creates a JSI export function declaration
48
48
  */
49
49
  #define JSI_EXPORT_FUNC(CLASS, FUNCTION) \
50
- {#FUNCTION, (jsi::Value(JsiHostObject::*)( \
50
+ {#FUNCTION, (jsi::Value (JsiHostObject::*)( \
51
51
  jsi::Runtime & runtime, const jsi::Value &thisValue, \
52
52
  const jsi::Value *arguments, size_t)) & \
53
53
  CLASS::FUNCTION}
@@ -65,7 +65,7 @@
65
65
  * Creates a JSI export getter declaration
66
66
  */
67
67
  #define JSI_EXPORT_PROP_GET(CLASS, FUNCTION) \
68
- {#FUNCTION, (jsi::Value(JsiHostObject::*)(jsi::Runtime & runtime)) & \
68
+ {#FUNCTION, (jsi::Value (JsiHostObject::*)(jsi::Runtime & runtime)) & \
69
69
  CLASS::STR_CAT(STR_GET, FUNCTION)}
70
70
 
71
71
  /**
@@ -83,7 +83,7 @@
83
83
  */
84
84
  #define JSI_EXPORT_PROP_SET(CLASS, FUNCTION) \
85
85
  {#FUNCTION, \
86
- (void(JsiHostObject::*)(jsi::Runtime & runtime, const jsi::Value &)) & \
86
+ (void (JsiHostObject::*)(jsi::Runtime & runtime, const jsi::Value &)) & \
87
87
  CLASS::STR_CAT(STR_SET, FUNCTION)}
88
88
 
89
89
  /**
@@ -105,10 +105,15 @@ public:
105
105
  if (name == "onSize" && isSharedValue(runtime, arguments[2])) {
106
106
  jsi::Object size(runtime);
107
107
  auto pd = _platformContext->getPixelDensity();
108
- size.setProperty(runtime, "width",
109
- info->view->getScaledWidth() / pd);
110
- size.setProperty(runtime, "height",
111
- info->view->getScaledHeight() / pd);
108
+ auto w = info->view != nullptr
109
+ ? std::max(info->view->getScaledWidth(), 0)
110
+ : 0;
111
+ auto h = info->view != nullptr
112
+ ? std::max(info->view->getScaledHeight(), 0)
113
+ : 0;
114
+
115
+ size.setProperty(runtime, "width", w / pd);
116
+ size.setProperty(runtime, "height", h / pd);
112
117
  arguments[2].asObject(runtime).setProperty(runtime, "value", size);
113
118
  } else {
114
119
  info->props.insert_or_assign(
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "setup-skia-web": "scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "2.2.12",
11
+ "version": "2.2.14",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",