react-native-svg
Advanced tools
Comparing version 14.1.0 to 15.0.0
@@ -634,9 +634,16 @@ "use strict"; | ||
xml, | ||
override | ||
override, | ||
fallback, | ||
onError = _reactNativeSvg.err | ||
} = props; | ||
const ast = (0, React.useMemo)(() => xml !== null ? (0, _reactNativeSvg.parse)(xml, inlineStyles) : null, [xml]); | ||
return /*#__PURE__*/React.createElement(_reactNativeSvg.SvgAst, { | ||
ast: ast, | ||
override: override || props | ||
}); | ||
try { | ||
const ast = (0, React.useMemo)(() => xml !== null ? (0, _reactNativeSvg.parse)(xml, inlineStyles) : null, [xml]); | ||
return /*#__PURE__*/React.createElement(_reactNativeSvg.SvgAst, { | ||
ast: ast, | ||
override: override || props | ||
}); | ||
} catch (error) { | ||
onError(error); | ||
return fallback ?? null; | ||
} | ||
} | ||
@@ -666,3 +673,4 @@ function SvgCssUri(props) { | ||
xml: xml, | ||
override: props | ||
override: props, | ||
fallback: fallback | ||
}); | ||
@@ -669,0 +677,0 @@ } |
@@ -37,3 +37,3 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
require('./fabric/NativeSvgRenderableModule').default; | ||
require('../fabric/NativeSvgRenderableModule').default; | ||
return await RNSVGRenderableModule.getRawResource(uri); | ||
@@ -40,0 +40,0 @@ } catch (e) { |
@@ -74,3 +74,2 @@ "use strict"; | ||
} | ||
const extractedProps = Array.isArray(props) ? transformsArrayToProps(props) : props; | ||
const { | ||
@@ -92,3 +91,3 @@ rotation, | ||
y | ||
} = extractedProps; | ||
} = props; | ||
if (rotation == null && translate == null && translateX == null && translateY == null && origin == null && originX == null && originY == null && scale == null && scaleX == null && scaleY == null && skew == null && skewX == null && skewY == null && x == null && y == null) { | ||
@@ -95,0 +94,0 @@ return null; |
@@ -41,11 +41,2 @@ "use strict"; | ||
fetchText: true, | ||
JsxAST: true, | ||
Middleware: true, | ||
Styles: true, | ||
UriProps: true, | ||
UriState: true, | ||
XmlAST: true, | ||
XmlProps: true, | ||
XmlState: true, | ||
AstProps: true, | ||
RNSVGCircle: true, | ||
@@ -82,8 +73,2 @@ RNSVGClipPath: true, | ||
}; | ||
Object.defineProperty(exports, "AstProps", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.AstProps; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Circle", { | ||
@@ -131,8 +116,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "JsxAST", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.JsxAST; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Line", { | ||
@@ -168,8 +147,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "Middleware", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.Middleware; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Path", { | ||
@@ -355,8 +328,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "Styles", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.Styles; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Svg", { | ||
@@ -446,14 +413,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "UriProps", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.UriProps; | ||
} | ||
}); | ||
Object.defineProperty(exports, "UriState", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.UriState; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Use", { | ||
@@ -471,20 +426,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "XmlAST", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.XmlAST; | ||
} | ||
}); | ||
Object.defineProperty(exports, "XmlProps", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.XmlProps; | ||
} | ||
}); | ||
Object.defineProperty(exports, "XmlState", { | ||
enumerable: true, | ||
get: function () { | ||
return _xml.XmlState; | ||
} | ||
}); | ||
Object.defineProperty(exports, "camelCase", { | ||
@@ -491,0 +428,0 @@ enumerable: true, |
@@ -624,9 +624,16 @@ import * as React from 'react'; | ||
xml, | ||
override | ||
override, | ||
fallback, | ||
onError = err | ||
} = props; | ||
const ast = useMemo(() => xml !== null ? parse(xml, inlineStyles) : null, [xml]); | ||
return /*#__PURE__*/React.createElement(SvgAst, { | ||
ast: ast, | ||
override: override || props | ||
}); | ||
try { | ||
const ast = useMemo(() => xml !== null ? parse(xml, inlineStyles) : null, [xml]); | ||
return /*#__PURE__*/React.createElement(SvgAst, { | ||
ast: ast, | ||
override: override || props | ||
}); | ||
} catch (error) { | ||
onError(error); | ||
return fallback ?? null; | ||
} | ||
} | ||
@@ -656,3 +663,4 @@ export function SvgCssUri(props) { | ||
xml: xml, | ||
override: props | ||
override: props, | ||
fallback: fallback | ||
}); | ||
@@ -659,0 +667,0 @@ } |
@@ -23,3 +23,3 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
require('./fabric/NativeSvgRenderableModule').default; | ||
require('../fabric/NativeSvgRenderableModule').default; | ||
return await RNSVGRenderableModule.getRawResource(uri); | ||
@@ -26,0 +26,0 @@ } catch (e) { |
@@ -65,3 +65,2 @@ import { append, appendTransform, identity, reset, toArray } from '../Matrix2D'; | ||
} | ||
const extractedProps = Array.isArray(props) ? transformsArrayToProps(props) : props; | ||
const { | ||
@@ -83,3 +82,3 @@ rotation, | ||
y | ||
} = extractedProps; | ||
} = props; | ||
if (rotation == null && translate == null && translateX == null && translateY == null && origin == null && originX == null && originY == null && scale == null && scaleX == null && scaleY == null && skew == null && skewX == null && skewY == null && x == null && y == null) { | ||
@@ -86,0 +85,0 @@ return null; |
@@ -26,8 +26,8 @@ import Shape from './elements/Shape'; | ||
import ForeignObject from './elements/ForeignObject'; | ||
import { parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml, camelCase, err, fetchText, JsxAST, Middleware, Styles, UriProps, UriState, XmlAST, XmlProps, XmlState, AstProps } from './xml'; | ||
import { parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml, camelCase, err, fetchText } from './xml'; | ||
import { RNSVGCircle, RNSVGClipPath, RNSVGDefs, RNSVGEllipse, RNSVGForeignObject, RNSVGGroup, RNSVGImage, RNSVGLine, RNSVGLinearGradient, RNSVGMarker, RNSVGMask, RNSVGPath, RNSVGPattern, RNSVGRadialGradient, RNSVGRect, RNSVGSvgAndroid, RNSVGSvgIOS, RNSVGSymbol, RNSVGText, RNSVGTextPath, RNSVGTSpan, RNSVGUse } from './fabric'; | ||
export { SvgCss, SvgCssUri, SvgWithCss, SvgWithCssUri, inlineStyles, LocalSvg, WithLocalSvg, loadLocalRawResource } from './deprecated'; | ||
export * from './lib/extract/types'; | ||
export { Svg, Circle, Ellipse, G, Text, TSpan, TextPath, Path, Polygon, Polyline, Line, Rect, Use, Image, Symbol, Defs, LinearGradient, RadialGradient, Stop, ClipPath, Pattern, Mask, Marker, ForeignObject, parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml, camelCase, err, fetchText, JsxAST, Middleware, Styles, UriProps, UriState, XmlAST, XmlProps, XmlState, AstProps, Shape, RNSVGMarker, RNSVGMask, RNSVGPattern, RNSVGClipPath, RNSVGRadialGradient, RNSVGLinearGradient, RNSVGDefs, RNSVGSymbol, RNSVGImage, RNSVGUse, RNSVGTextPath, RNSVGTSpan, RNSVGText, RNSVGGroup, RNSVGPath, RNSVGLine, RNSVGEllipse, RNSVGCircle, RNSVGRect, RNSVGSvgAndroid, RNSVGSvgIOS, RNSVGForeignObject }; | ||
export { Svg, Circle, Ellipse, G, Text, TSpan, TextPath, Path, Polygon, Polyline, Line, Rect, Use, Image, Symbol, Defs, LinearGradient, RadialGradient, Stop, ClipPath, Pattern, Mask, Marker, ForeignObject, parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml, camelCase, err, fetchText, Shape, RNSVGMarker, RNSVGMask, RNSVGPattern, RNSVGClipPath, RNSVGRadialGradient, RNSVGLinearGradient, RNSVGDefs, RNSVGSymbol, RNSVGImage, RNSVGUse, RNSVGTextPath, RNSVGTSpan, RNSVGText, RNSVGGroup, RNSVGPath, RNSVGLine, RNSVGEllipse, RNSVGCircle, RNSVGRect, RNSVGSvgAndroid, RNSVGSvgIOS, RNSVGForeignObject }; | ||
export default Svg; | ||
//# sourceMappingURL=ReactNativeSVG.js.map |
@@ -22,3 +22,3 @@ import * as React from 'react'; | ||
export declare const inlineStyles: Middleware; | ||
export declare function SvgCss(props: XmlProps): React.JSX.Element; | ||
export declare function SvgCss(props: XmlProps): React.JSX.Element | null; | ||
export declare function SvgCssUri(props: UriProps): React.JSX.Element | null; | ||
@@ -25,0 +25,0 @@ export declare class SvgWithCss extends Component<XmlProps, XmlState> { |
import type { TransformsStyle } from 'react-native'; | ||
import type { ColumnMajorTransformMatrix, TransformedProps, TransformProps } from './types'; | ||
export declare function transformsArrayToProps(transformObjectsArray: TransformsStyle['transform']): TransformProps; | ||
type TransformsStyleArray = Exclude<TransformsStyle['transform'], string>; | ||
export declare function transformsArrayToProps(transformObjectsArray: TransformsStyleArray): TransformProps; | ||
export declare function props2transform(props: TransformProps | undefined): TransformedProps | null; | ||
export declare function transformToMatrix(props: TransformedProps | null, transform: TransformProps['transform']): ColumnMajorTransformMatrix | null; | ||
export default function extractTransform(props: TransformProps | TransformProps['transform']): ColumnMajorTransformMatrix | null; | ||
export {}; | ||
//# sourceMappingURL=extractTransform.d.ts.map |
@@ -53,4 +53,5 @@ import Shape from './elements/Shape'; | ||
export * from './lib/extract/types'; | ||
export { Svg, Circle, Ellipse, G, Text, TSpan, TextPath, Path, Polygon, Polyline, Line, Rect, Use, Image, Symbol, Defs, LinearGradient, RadialGradient, Stop, ClipPath, Pattern, Mask, Marker, ForeignObject, parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml, camelCase, err, fetchText, JsxAST, Middleware, Styles, UriProps, UriState, XmlAST, XmlProps, XmlState, AstProps, Shape, RNSVGMarker, RNSVGMask, RNSVGPattern, RNSVGClipPath, RNSVGRadialGradient, RNSVGLinearGradient, RNSVGDefs, RNSVGSymbol, RNSVGImage, RNSVGUse, RNSVGTextPath, RNSVGTSpan, RNSVGText, RNSVGGroup, RNSVGPath, RNSVGLine, RNSVGEllipse, RNSVGCircle, RNSVGRect, RNSVGSvgAndroid, RNSVGSvgIOS, RNSVGForeignObject, }; | ||
export { Svg, Circle, Ellipse, G, Text, TSpan, TextPath, Path, Polygon, Polyline, Line, Rect, Use, Image, Symbol, Defs, LinearGradient, RadialGradient, Stop, ClipPath, Pattern, Mask, Marker, ForeignObject, parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml, camelCase, err, fetchText, Shape, RNSVGMarker, RNSVGMask, RNSVGPattern, RNSVGClipPath, RNSVGRadialGradient, RNSVGLinearGradient, RNSVGDefs, RNSVGSymbol, RNSVGImage, RNSVGUse, RNSVGTextPath, RNSVGTSpan, RNSVGText, RNSVGGroup, RNSVGPath, RNSVGLine, RNSVGEllipse, RNSVGCircle, RNSVGRect, RNSVGSvgAndroid, RNSVGSvgIOS, RNSVGForeignObject, }; | ||
export type { JsxAST, Middleware, Styles, UriProps, UriState, XmlAST, XmlProps, XmlState, AstProps, }; | ||
export default Svg; | ||
//# sourceMappingURL=ReactNativeSVG.d.ts.map |
{ | ||
"version": "14.1.0", | ||
"version": "15.0.0", | ||
"name": "react-native-svg", | ||
@@ -4,0 +4,0 @@ "description": "SVG library for react-native", |
@@ -78,2 +78,3 @@ <img src="https://user-images.githubusercontent.com/39658211/200319759-006c214f-941c-496c-a3c2-7de5b7ce33dc.png" width="100%" alt="React Native SVG at Software Mansion" > | ||
| >=12.3.0 | >=0.64.0 | | ||
| >=15.0.0 | >=0.70.0 | | ||
@@ -80,0 +81,0 @@ ## Support for Fabric |
@@ -11,2 +11,4 @@ import type { TransformsStyle } from 'react-native'; | ||
type TransformsStyleArray = Exclude<TransformsStyle['transform'], string>; | ||
function appendTransformProps(props: TransformedProps) { | ||
@@ -24,3 +26,3 @@ const { x, y, originX, originY, scaleX, scaleY, rotation, skewX, skewY } = | ||
originX, | ||
originY, | ||
originY | ||
); | ||
@@ -33,3 +35,3 @@ } | ||
axisY: NumberProp | void, | ||
defaultValue?: number, | ||
defaultValue?: number | ||
): [number, number] { | ||
@@ -71,3 +73,3 @@ let x; | ||
export function transformsArrayToProps( | ||
transformObjectsArray: TransformsStyle['transform'], | ||
transformObjectsArray: TransformsStyleArray | ||
) { | ||
@@ -79,3 +81,3 @@ const props: TransformProps = {}; | ||
console.error( | ||
'You must specify exactly one property per transform object.', | ||
'You must specify exactly one property per transform object.' | ||
); | ||
@@ -91,3 +93,3 @@ } | ||
export function props2transform( | ||
props: TransformProps | undefined, | ||
props: TransformProps | undefined | ||
): TransformedProps | null { | ||
@@ -97,5 +99,2 @@ if (!props) { | ||
} | ||
const extractedProps = Array.isArray(props) | ||
? transformsArrayToProps(props) | ||
: props; | ||
const { | ||
@@ -117,3 +116,3 @@ rotation, | ||
y, | ||
} = extractedProps; | ||
} = props; | ||
if ( | ||
@@ -141,3 +140,3 @@ rotation == null && | ||
console.warn( | ||
'Passing SvgLengthList to x or y attribute where SvgLength expected', | ||
'Passing SvgLengthList to x or y attribute where SvgLength expected' | ||
); | ||
@@ -148,3 +147,3 @@ } | ||
translateX || (Array.isArray(x) ? x[0] : x), | ||
translateY || (Array.isArray(y) ? y[0] : y), | ||
translateY || (Array.isArray(y) ? y[0] : y) | ||
); | ||
@@ -170,3 +169,3 @@ const or = universal2axis(origin, originX, originY); | ||
props: TransformedProps | null, | ||
transform: TransformProps['transform'], | ||
transform: TransformProps['transform'] | ||
): ColumnMajorTransformMatrix | null { | ||
@@ -189,7 +188,7 @@ if (!props && !transform) { | ||
columnMatrix[4], | ||
columnMatrix[5], | ||
columnMatrix[5] | ||
); | ||
} else { | ||
const transformProps = props2transform( | ||
transformsArrayToProps(transform as TransformsStyle['transform']), | ||
transformsArrayToProps(transform as TransformsStyleArray) | ||
); | ||
@@ -215,3 +214,3 @@ transformProps && appendTransformProps(transformProps); | ||
export default function extractTransform( | ||
props: TransformProps | TransformProps['transform'], | ||
props: TransformProps | TransformProps['transform'] | ||
): ColumnMajorTransformMatrix | null { | ||
@@ -235,4 +234,4 @@ if (Array.isArray(props) && typeof props[0] === 'number') { | ||
props2transform(transformProps), | ||
transformProps?.transform, | ||
transformProps?.transform | ||
); | ||
} |
@@ -144,11 +144,2 @@ import Shape from './elements/Shape'; | ||
fetchText, | ||
JsxAST, | ||
Middleware, | ||
Styles, | ||
UriProps, | ||
UriState, | ||
XmlAST, | ||
XmlProps, | ||
XmlState, | ||
AstProps, | ||
Shape, | ||
@@ -179,2 +170,14 @@ RNSVGMarker, | ||
export type { | ||
JsxAST, | ||
Middleware, | ||
Styles, | ||
UriProps, | ||
UriState, | ||
XmlAST, | ||
XmlProps, | ||
XmlState, | ||
AstProps, | ||
}; | ||
export default Svg; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2902043
938
163
23747