Socket
Book a DemoSign in
Socket

react-native-svg

Package Overview
Dependencies
Maintainers
4
Versions
260
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-svg - npm Package Compare versions

Comparing version
15.15.0
to
15.15.1
+0
-18
android/src/main/java/com/horcrux/svg/GroupView.java

@@ -22,3 +22,2 @@ /*

import android.view.View;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Dynamic;

@@ -28,3 +27,2 @@ import com.facebook.react.bridge.ReactContext;

import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableMap;
import java.util.ArrayList;

@@ -347,18 +345,2 @@ import javax.annotation.Nullable;

}
@Override
public void updateShadowNodeMetrics() {
SvgView svgView = this.getSvgView();
if (this.stateWrapper == null || svgView == null) {
return;
}
WritableMap map = Arguments.createMap();
map.putDouble("x", 0);
map.putDouble("y", 0);
map.putDouble("width", svgView.getCanvasWidth() / mScale);
map.putDouble("height", svgView.getCanvasHeight() / mScale);
this.stateWrapper.updateState(map);
}
}
+5
-20

@@ -36,4 +36,4 @@ /*

import com.facebook.react.touch.ReactHitSlopView;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import java.lang.reflect.Field;

@@ -107,4 +107,6 @@ import java.util.ArrayList;

WritableMap event = Arguments.createMap();
ReactContext reactContext = (ReactContext) getContext();
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topSvgLayout", event);
ReactContext reactContext = (ReactContext)getContext();
reactContext
.getJSModule(RCTEventEmitter.class)
.receiveEvent(getId(), "topSvgLayout", event);
}

@@ -503,4 +505,2 @@

}
this.updateShadowNodeMetrics();
}

@@ -829,17 +829,2 @@

}
protected void updateShadowNodeMetrics() {
RectF clientRect = this.getClientRect();
if (this.stateWrapper == null || clientRect == null) {
return;
}
WritableMap map = Arguments.createMap();
map.putDouble("x", clientRect.left / mScale);
map.putDouble("y", clientRect.top / mScale);
map.putDouble("width", clientRect.width() / mScale);
map.putDouble("height", clientRect.height() / mScale);
this.stateWrapper.updateState(map);
}
}

@@ -70,5 +70,2 @@ /*

import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.facebook.react.bridge.Dynamic;

@@ -85,4 +82,2 @@ import com.facebook.react.bridge.JavaOnlyMap;

import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.ThemedReactContext;

@@ -176,8 +171,2 @@ import com.facebook.react.uimanager.TransformHelper;

@Override
public Object updateState(@NonNull VirtualView view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
view.setStateWrapper(stateWrapper);
return super.updateState(view, props, stateWrapper);
}
static class RenderableShadowNode extends LayoutShadowNode {

@@ -184,0 +173,0 @@

+4
-13

@@ -24,3 +24,2 @@ package com.horcrux.svg;

import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.UIManagerHelper;

@@ -30,2 +29,3 @@ import com.facebook.react.uimanager.events.EventDispatcher;

import com.horcrux.svg.events.SvgOnLayoutEvent;
import java.util.ArrayList;

@@ -89,3 +89,2 @@ import javax.annotation.Nullable;

private GlyphContext glyphContext;
protected @Nullable StateWrapper stateWrapper = null;

@@ -113,6 +112,2 @@ Path mPath;

public void setStateWrapper(@Nullable StateWrapper stateWrapper) {
this.stateWrapper = stateWrapper;
}
@Override

@@ -261,3 +256,3 @@ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {

canvas.concat(mCTM);
mCTM.postConcat(ctm);
mCTM.preConcat(ctm);
mCTMInvertible = mCTM.invert(mInvCTM);

@@ -450,5 +445,3 @@ return count;

SvgView svg = getSvgView();
if (length.unit == SVGLength.UnitType.PERCENTAGE
&& svg != null
&& svg.getViewBox().width() != 0) {
if (length.unit == SVGLength.UnitType.PERCENTAGE && svg != null && svg.getViewBox().width() != 0) {
return relativeOn(length, svg.getViewBox().width());

@@ -461,5 +454,3 @@ }

SvgView svg = getSvgView();
if (length.unit == SVGLength.UnitType.PERCENTAGE
&& svg != null
&& svg.getViewBox().height() != 0) {
if (length.unit == SVGLength.UnitType.PERCENTAGE && svg != null && svg.getViewBox().height() != 0) {
return relativeOn(length, svg.getViewBox().height());

@@ -466,0 +457,0 @@ }

@@ -19,3 +19,2 @@ /**

#import "RNSVGFabricConversions.h"
#import "RNSVGRenderUtils.h"
#endif // RCT_NEW_ARCH_ENABLED

@@ -313,12 +312,2 @@

#ifdef RCT_NEW_ARCH_ENABLED
- (void)updateShadowNodeMetrics
{
auto statePtr = [self state];
if (statePtr) {
statePtr->updateState(RNSVGLayoutableState(0, 0, [self getCanvasWidth], [self getCanvasHeight]));
}
}
#endif
@end

@@ -325,0 +314,0 @@

@@ -19,8 +19,2 @@ /**

#ifdef RCT_NEW_ARCH_ENABLED
#import <rnsvg/RNSVGComponentDescriptors.h>
using namespace facebook::react;
#endif
@interface RNSVGRenderable : RNSVGNode

@@ -46,6 +40,2 @@

#ifdef RCT_NEW_ARCH_ENABLED
- (facebook::react::RNSVGRenderableShadowNode::ConcreteState::Shared)state;
#endif
- (void)setColor:(RNSVGColor *)color;

@@ -63,6 +53,2 @@

#ifdef RCT_NEW_ARCH_ENABLED
- (void)updateShadowNodeMetrics;
#endif
@end

@@ -29,6 +29,2 @@ /**

RNSVGRenderable *_caller;
#ifdef RCT_NEW_ARCH_ENABLED
RNSVGRenderableShadowNode::ConcreteState::Shared _state;
#endif
}

@@ -251,7 +247,2 @@

}
- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState
{
_state = std::static_pointer_cast<const RNSVGRenderableShadowNode::ConcreteState>(state);
}
#endif // RCT_NEW_ARCH_ENABLED

@@ -446,5 +437,2 @@

[self renderMarkers:context path:self.path rect:&rect];
#ifdef RCT_NEW_ARCH_ENABLED
[self updateShadowNodeMetrics];
#endif
}

@@ -791,15 +779,2 @@

#ifdef RCT_NEW_ARCH_ENABLED
- (void)updateShadowNodeMetrics
{
if (_state) {
_state->updateState(RNSVGLayoutableState(self.clientRect.origin.x, self.clientRect.origin.y, self.clientRect.size.width, self.clientRect.size.height));
}
}
- (RNSVGRenderableShadowNode::ConcreteState::Shared)state {
return _state;
}
#endif
@end
#pragma once
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include "RNSVGComponentDescriptor.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include "RNSVGShadowNodes.h"

@@ -10,56 +10,56 @@

using RNSVGCircleComponentDescriptor =
RNSVGComponentDescriptor<RNSVGCircleShadowNode>;
ConcreteComponentDescriptor<RNSVGCircleShadowNode>;
using RNSVGClipPathComponentDescriptor =
RNSVGComponentDescriptor<RNSVGClipPathShadowNode>;
ConcreteComponentDescriptor<RNSVGClipPathShadowNode>;
using RNSVGDefsComponentDescriptor =
RNSVGComponentDescriptor<RNSVGDefsShadowNode>;
ConcreteComponentDescriptor<RNSVGDefsShadowNode>;
using RNSVGEllipseComponentDescriptor =
RNSVGComponentDescriptor<RNSVGEllipseShadowNode>;
ConcreteComponentDescriptor<RNSVGEllipseShadowNode>;
using RNSVGFeBlendComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFeBlendShadowNode>;
ConcreteComponentDescriptor<RNSVGFeBlendShadowNode>;
using RNSVGFeColorMatrixComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFeColorMatrixShadowNode>;
ConcreteComponentDescriptor<RNSVGFeColorMatrixShadowNode>;
using RNSVGFeCompositeComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFeCompositeShadowNode>;
ConcreteComponentDescriptor<RNSVGFeCompositeShadowNode>;
using RNSVGFeFloodComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFeFloodShadowNode>;
ConcreteComponentDescriptor<RNSVGFeFloodShadowNode>;
using RNSVGFeGaussianBlurComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFeGaussianBlurShadowNode>;
ConcreteComponentDescriptor<RNSVGFeGaussianBlurShadowNode>;
using RNSVGFeMergeComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFeMergeShadowNode>;
ConcreteComponentDescriptor<RNSVGFeMergeShadowNode>;
using RNSVGFeOffsetComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFeOffsetShadowNode>;
ConcreteComponentDescriptor<RNSVGFeOffsetShadowNode>;
using RNSVGFilterComponentDescriptor =
RNSVGComponentDescriptor<RNSVGFilterShadowNode>;
ConcreteComponentDescriptor<RNSVGFilterShadowNode>;
using RNSVGForeignObjectComponentDescriptor =
RNSVGComponentDescriptor<RNSVGForeignObjectShadowNode>;
ConcreteComponentDescriptor<RNSVGForeignObjectShadowNode>;
using RNSVGGroupComponentDescriptor =
RNSVGComponentDescriptor<RNSVGGroupShadowNode>;
ConcreteComponentDescriptor<RNSVGGroupShadowNode>;
using RNSVGLinearGradientComponentDescriptor =
RNSVGComponentDescriptor<RNSVGLinearGradientShadowNode>;
ConcreteComponentDescriptor<RNSVGLinearGradientShadowNode>;
using RNSVGLineComponentDescriptor =
RNSVGComponentDescriptor<RNSVGLineShadowNode>;
ConcreteComponentDescriptor<RNSVGLineShadowNode>;
using RNSVGMarkerComponentDescriptor =
RNSVGComponentDescriptor<RNSVGMarkerShadowNode>;
ConcreteComponentDescriptor<RNSVGMarkerShadowNode>;
using RNSVGMaskComponentDescriptor =
RNSVGComponentDescriptor<RNSVGMaskShadowNode>;
ConcreteComponentDescriptor<RNSVGMaskShadowNode>;
using RNSVGPathComponentDescriptor =
RNSVGComponentDescriptor<RNSVGPathShadowNode>;
ConcreteComponentDescriptor<RNSVGPathShadowNode>;
using RNSVGPatternComponentDescriptor =
RNSVGComponentDescriptor<RNSVGPatternShadowNode>;
ConcreteComponentDescriptor<RNSVGPatternShadowNode>;
using RNSVGRadialGradientComponentDescriptor =
RNSVGComponentDescriptor<RNSVGRadialGradientShadowNode>;
ConcreteComponentDescriptor<RNSVGRadialGradientShadowNode>;
using RNSVGRectComponentDescriptor =
RNSVGComponentDescriptor<RNSVGRectShadowNode>;
ConcreteComponentDescriptor<RNSVGRectShadowNode>;
using RNSVGSymbolComponentDescriptor =
RNSVGComponentDescriptor<RNSVGSymbolShadowNode>;
ConcreteComponentDescriptor<RNSVGSymbolShadowNode>;
using RNSVGTextComponentDescriptor =
RNSVGComponentDescriptor<RNSVGTextShadowNode>;
ConcreteComponentDescriptor<RNSVGTextShadowNode>;
using RNSVGTextPathComponentDescriptor =
RNSVGComponentDescriptor<RNSVGTextPathShadowNode>;
ConcreteComponentDescriptor<RNSVGTextPathShadowNode>;
using RNSVGTSpanComponentDescriptor =
RNSVGComponentDescriptor<RNSVGTSpanShadowNode>;
ConcreteComponentDescriptor<RNSVGTSpanShadowNode>;
using RNSVGUseComponentDescriptor =
RNSVGComponentDescriptor<RNSVGUseShadowNode>;
ConcreteComponentDescriptor<RNSVGUseShadowNode>;
} // namespace facebook::react

@@ -7,20 +7,19 @@ #pragma once

#include "RNSVGLayoutableShadowNode.h"
#include "RNSVGLayoutableState.h"
namespace facebook::react {
template <const char *concreteComponentName, typename PropsT = ViewProps>
template <const char *concreteComponentName, typename PropsT = ViewProps, typename ShadowNode = RNSVGLayoutableShadowNode>
class RNSVGConcreteShadowNode : public ConcreteShadowNode<
concreteComponentName,
RNSVGLayoutableShadowNode,
ShadowNode,
PropsT,
ViewEventEmitter,
RNSVGLayoutableState> {
StateData> {
public:
using BaseShadowNode = ConcreteShadowNode<
concreteComponentName,
RNSVGLayoutableShadowNode,
ShadowNode,
PropsT,
ViewEventEmitter,
RNSVGLayoutableState>;
StateData>;

@@ -27,0 +26,0 @@ using ConcreteViewProps = PropsT;

@@ -10,3 +10,5 @@ #include "RNSVGLayoutableShadowNode.h"

ShadowNodeTraits traits)
: YogaLayoutableShadowNode(fragment, family, traits) {}
: YogaLayoutableShadowNode(fragment, family, traits) {
updatePosition();
}

@@ -16,11 +18,18 @@ RNSVGLayoutableShadowNode::RNSVGLayoutableShadowNode(

const ShadowNodeFragment &fragment)
: YogaLayoutableShadowNode(sourceShadowNode, fragment) {}
: YogaLayoutableShadowNode(sourceShadowNode, fragment) {
updatePosition();
}
void RNSVGLayoutableShadowNode::setShadowNodePosition(float x, float y) {
void RNSVGLayoutableShadowNode::updatePosition() {
// SVG handles its layout manually on the native side and does not depend on
// the Yoga layout. Setting the dimensions to absolute fill is a hack for measure
// to return "correct" layout metrics when onPress is tested. It also eliminates
// randomly positioned views in the layout inspector when Yoga attempts to interpret
// SVG properties like width when viewBox scale is set. Ideal solution would be to
// return correct bounding box from native side in getLayoutMetrics.
auto style = yogaNode_.style();
style.setPositionType(yoga::PositionType::Absolute);
style.setPosition(yoga::Edge::Left, yoga::StyleLength::points(x));
style.setPosition(yoga::Edge::Top, yoga::StyleLength::points(y));
style.setPosition(yoga::Edge::All, yoga::Style::Length::points(0));
style.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::percent(100));
style.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::percent(100));
yogaNode_.setStyle(style);

@@ -27,0 +36,0 @@ }

#include <react/renderer/components/view/YogaLayoutableShadowNode.h>
#include "RNSVGLayoutableState.h"

@@ -18,5 +17,7 @@ namespace facebook::react {

void layout(LayoutContext layoutContext) override;
void setShadowNodePosition(float x, float y);
private:
void updatePosition();
};
} // namespace facebook::react

@@ -27,3 +27,2 @@ #include <react/renderer/components/rnsvg/ShadowNodes.h>

extern const char RNSVGRectComponentName[] = "RNSVGRect";
extern const char RNSVGRenderableComponentName[] = "RNSVGRenderable";
extern const char RNSVGSymbolComponentName[] = "RNSVGSymbol";

@@ -30,0 +29,0 @@ extern const char RNSVGTextComponentName[] = "RNSVGText";

@@ -6,2 +6,3 @@ #pragma once

#include <react/renderer/components/rnsvg/Props.h>
#include <react/renderer/components/view/YogaLayoutableShadowNode.h>
#include "RNSVGConcreteShadowNode.h"

@@ -118,3 +119,4 @@ #include "RNSVGImageState.h"

RNSVGForeignObjectComponentName,
RNSVGForeignObjectProps>;
RNSVGForeignObjectProps,
YogaLayoutableShadowNode>;

@@ -195,10 +197,2 @@ JSI_EXPORT extern const char RNSVGGroupComponentName[];

JSI_EXPORT extern const char RNSVGRenderableComponentName[];
/*
* `ShadowNode` for RNSVGRenderable base.
*/
using RNSVGRenderableShadowNode =
RNSVGConcreteShadowNode<RNSVGRenderableComponentName>;
JSI_EXPORT extern const char RNSVGSymbolComponentName[];

@@ -205,0 +199,0 @@

{
"version": "15.15.0",
"version": "15.15.1",
"name": "react-native-svg",

@@ -4,0 +4,0 @@ "description": "SVG library for react-native",

// RNSVGComponentDescriptor.h
#pragma once
#include <react/debug/react_native_assert.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include "RNSVGShadowNodes.h"
namespace facebook::react {
template <typename ShadowNodeT>
class RNSVGComponentDescriptor final : public ConcreteComponentDescriptor<ShadowNodeT> {
public:
using ConcreteComponentDescriptor<ShadowNodeT>::ConcreteComponentDescriptor;
void adopt(ShadowNode &shadowNode) const override {
react_native_assert(dynamic_cast<RNSVGLayoutableShadowNode *>(&shadowNode));
auto layoutableShadowNode = dynamic_cast<RNSVGLayoutableShadowNode *>(&shadowNode);
auto state = std::static_pointer_cast<const typename ShadowNodeT::ConcreteState>(shadowNode.getState());
auto stateData = state->getData();
if (stateData.getWidth() != 0 && stateData.getHeight() != 0) {
layoutableShadowNode->setSize(Size{stateData.getWidth(), stateData.getHeight()});
layoutableShadowNode->setShadowNodePosition(stateData.getX(), stateData.getY());
}
ConcreteComponentDescriptor<ShadowNodeT>::adopt(shadowNode);
}
};
} // namespace facebook::react
#include "RNSVGLayoutableState.h"
namespace facebook::react {
float RNSVGLayoutableState::getX() const {
return x_;
}
float RNSVGLayoutableState::getY() const {
return y_;
}
float RNSVGLayoutableState::getWidth() const {
return width_;
}
float RNSVGLayoutableState::getHeight() const {
return height_;
}
} // namespace facebook::react
#pragma once
#ifdef ANDROID
#include <folly/dynamic.h>
#endif
namespace facebook::react {
class RNSVGLayoutableState {
public:
RNSVGLayoutableState()
: x_(0), y_(0), width_(0), height_(0) {}
RNSVGLayoutableState(float x, float y, float width, float height)
: x_(x), y_(y), width_(width), height_(height) {}
#ifdef ANDROID
RNSVGLayoutableState(RNSVGLayoutableState const &previousState, folly::dynamic data)
: x_((float)data["x"].getDouble()),
y_((float)data["y"].getDouble()),
width_((float)data["width"].getDouble()),
height_((float)data["height"].getDouble()){};
folly::dynamic getDynamic() const {
return folly::dynamic::object("x", x_)("y", y_)("width", width_)("height", height_);
};
#endif
float getX() const;
float getY() const;
float getWidth() const;
float getHeight() const;
private:
float x_{};
float y_{};
float width_{};
float height_{};
};
} // namespace facebook::react