@pixodesk/svg-animator-rn 1.0.39 → 1.0.40

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.
@@ -4,14 +4,19 @@
4
4
  *---------------------------------------------------------------------------------------*/
5
5
 
6
6
  import { Component, type ErrorInfo, type ReactNode } from 'react';
7
- import { createDiagnostics, PxDiagnosticKind, type PxDiagnostics } from '@pixodesk/svg-animator-core';
7
+ import { PxDiagnosticKind, type PxDiagnostics } from '@pixodesk/svg-animator-core';
8
+ import { createDiagnostics } from '@pixodesk/svg-animator-core/internal';
8
9
 
10
+ /** @public @advanced */
9
11
  export interface PxRnErrorBoundaryProps {
10
12
  children: ReactNode;
11
13
  /** Rendered instead of the children once something has thrown. */
12
14
  fallback?: (error: Error) => ReactNode;
13
- onError?: (error: Error, info?: string) => void;
14
- /** Where to report the failure (API review §5). Defaults to the console. */
15
+ /**
16
+ * Where the failure is reported (API review §5, §25.1): `error(internal, …)` with
17
+ * `{ componentStack }` as the detail — so it reaches `onError` like every other failure.
18
+ * Defaults to the console.
19
+ */
15
20
  diag?: PxDiagnostics;
16
21
  }
17
22
 
@@ -25,12 +30,13 @@ interface State {
25
30
  * A throw anywhere in the rendered SVG tree — an unsupported prop shape, a
26
31
  * react-native-svg internal, a reanimated attachment failure — otherwise
27
32
  * unmounts the whole React tree above it. Here it is contained to this one
28
- * animation, reported through `onError`, and replaced by `fallback`.
33
+ * animation, reported through the diagnostics channel, and replaced by `fallback`.
29
34
  *
30
35
  * NOTE the limit: this catches JavaScript errors only. A crash INSIDE the
31
36
  * native renderer (see `openClosedTextPathTargets` for a real example) never
32
37
  * reaches JavaScript and cannot be caught here — those have to be avoided
33
38
  * rather than handled.
39
+ * @public @advanced
34
40
  */
35
41
  export class PxRnErrorBoundary extends Component<PxRnErrorBoundaryProps, State> {
36
42
  override state: State = { error: null };
@@ -40,9 +46,8 @@ export class PxRnErrorBoundary extends Component<PxRnErrorBoundaryProps, State>
40
46
  }
41
47
 
42
48
  override componentDidCatch(error: Error, info: ErrorInfo): void {
43
- this.props.onError?.(error, info?.componentStack ?? undefined);
44
49
  (this.props.diag ?? createDiagnostics(undefined, '[PixodeskSvgAnimator]'))
45
- .warn(PxDiagnosticKind.internal, 'render failed: ' + (error?.message ?? String(error)));
50
+ .error(PxDiagnosticKind.internal, error, { componentStack: info?.componentStack ?? undefined });
46
51
  }
47
52
 
48
53
  override componentDidUpdate(prev: PxRnErrorBoundaryProps): void {
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License. See the LICENSE file in the project root for details.
4
4
  *---------------------------------------------------------------------------------------*/
5
5
 
6
- import { kebabToCamelCaseWord } from '@pixodesk/svg-animator-core';
6
+ import { kebabToCamelCaseWord } from '@pixodesk/svg-animator-core/internal';
7
7
  import { svgTransformToMatrix } from './PxRnMatrix';
8
8
 
9
9
  /** Attribute names with a react-native-svg prop equivalent under a
@@ -22,6 +22,7 @@ const DROPPED_ATTRS = new Set(['class', 'className', 'style', 'xmlns', 'xmlns:xl
22
22
  *
23
23
  * Pure (no react-native-svg import) so the track compiler and its tests
24
24
  * don't need a React Native environment.
25
+ * @internal
25
26
  */
26
27
  export function toRnPropName(attrName: string): string | undefined {
27
28
  if (DROPPED_ATTRS.has(attrName)) return undefined;
@@ -3,19 +3,13 @@
3
3
  * Licensed under the MIT License. See the LICENSE file in the project root for details.
4
4
  *---------------------------------------------------------------------------------------*/
5
5
 
6
- import {
7
- getNormalizedProps,
8
- resolveStyle,
9
- sanitizeAttributeValue,
10
- DISALLOWED_SVG_TAGS_LOWER,
11
- TEXT_CONTENT_ATTR,
12
- type PxDefs,
13
- type PxNode,
14
- } from '@pixodesk/svg-animator-core';
6
+ import { getNormalizedProps, type PxDefs, type PxNode } from '@pixodesk/svg-animator-core';
7
+ import { sanitizeAttributeValue, DISALLOWED_SVG_TAGS_LOWER, TEXT_CONTENT_ATTR } from '@pixodesk/svg-animator-core/internal';
15
8
  import { createElement, type ComponentType, type ReactElement, type ReactNode } from 'react';
16
9
  import { RN_SVG_COMPONENTS } from './PxRnTypeMap';
17
10
  import { toRnPropName, toRnPropValue } from './PxRnPropNames';
18
11
 
12
+ /** @internal */
19
13
  export interface RenderRnNodeOptions {
20
14
  /** Collects non-fatal issues (unsupported tags, dropped attrs). */
21
15
  warnings?: Array<string>;
@@ -44,6 +38,7 @@ export interface RenderRnNodeOptions {
44
38
  * Converts core-normalized wire props into react-native-svg props: RN prop
45
39
  * naming, sanitization (same security rules as the web renderer), numeric
46
40
  * coercion where possible.
41
+ * @internal
47
42
  */
48
43
  export function toRnProps(props: Record<string, any>, warnings?: Array<string>, tag?: string): Record<string, any> {
49
44
  const normalized = getNormalizedProps(props);
@@ -62,6 +57,7 @@ export function toRnProps(props: Record<string, any>, warnings?: Array<string>,
62
57
  * Renders a (materialized) PxNode tree to react-native-svg elements.
63
58
  * Mirrors the web `renderNode` contract: unsupported/dangerous tags are
64
59
  * skipped with a warning, never a crash.
60
+ * @internal
65
61
  */
66
62
  export function renderRnNode(node: PxNode, opts: RenderRnNodeOptions = {}, key?: string | number): ReactElement | null {
67
63
  if (!node) return null;
@@ -91,11 +87,10 @@ export function renderRnNode(node: PxNode, opts: RenderRnNodeOptions = {}, key?:
91
87
  const rnProps = toRnProps(props, opts.warnings, tag);
92
88
  if (domType !== undefined) rnProps.type = domType;
93
89
 
94
- // `node.style` — a named preset from `definitions.styles`, or an inline
95
- // record. react-native-svg has no CSS, so the resolved declarations are
96
- // applied as ordinary props (the same names, e.g. `fill`, `strokeWidth`).
90
+ // `node.style` — an inline record of declarations. react-native-svg has no CSS, so
91
+ // they are applied as ordinary props (the same names, e.g. `fill`, `strokeWidth`).
97
92
  // Explicit attributes on the node win over the style block.
98
- const resolved = resolveStyle(style, opts.defs);
93
+ const resolved = style;
99
94
  if (resolved) {
100
95
  for (const [k, v] of Object.entries(resolved)) {
101
96
  const rnKey = toRnPropName(k);
package/src/PxRnSafety.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  * Licensed under the MIT License. See the LICENSE file in the project root for details.
4
4
  *---------------------------------------------------------------------------------------*/
5
5
 
6
- import { deepClone, generateUniqueId, type PxNode } from '@pixodesk/svg-animator-core';
6
+ import { type PxNode } from '@pixodesk/svg-animator-core';
7
+ import { deepClone, generateUniqueId } from '@pixodesk/svg-animator-core/internal';
7
8
 
8
9
  /**
9
10
  * Workarounds for defects in react-native-svg's NATIVE renderer that would
@@ -57,6 +58,7 @@ function forEachNode(node: PxNode | undefined, visit: (n: PxNode, parent?: PxNod
57
58
  * has zero length and nothing changes visually at all.
58
59
  *
59
60
  * Returns the document unchanged — the same object — when nothing matches.
61
+ * @internal
60
62
  */
61
63
  export function openClosedTextPathTargets(doc: PxNode, warnings?: Array<string>): PxNode {
62
64
  // Cheap pre-check: the overwhelming majority of documents have no textPath.
package/src/PxRnTracks.ts CHANGED
@@ -3,15 +3,8 @@
3
3
  * Licensed under the MIT License. See the LICENSE file in the project root for details.
4
4
  *---------------------------------------------------------------------------------------*/
5
5
 
6
- import {
7
- calcAnimationValues,
8
- getAnimatorConfig,
9
- getNormalizedBindings,
10
- DEFAULT_DURATION_MS,
11
- PxTimelineEngine,
12
- type PxAnimatedSvgDocument,
13
- type PxAnimationDefinition,
14
- } from '@pixodesk/svg-animator-core';
6
+ import { calcAnimationValues, getAnimatorConfig, getNormalizedBindings, PxTimelineEngine, type PxAnimatedSvgDocument, type PxAnimationDefinition } from '@pixodesk/svg-animator-core';
7
+ import { DEFAULT_DURATION_MS } from '@pixodesk/svg-animator-core/internal';
15
8
  import { toRnPropName, toRnPropValue } from './PxRnPropNames';
16
9
 
17
10
  /**
@@ -22,6 +15,7 @@ import { toRnPropName, toRnPropValue } from './PxRnPropNames';
22
15
  * with — so RN playback is value-identical to the web player. Easing, loops,
23
16
  * transform composition, color interpolation and path morphing are all baked
24
17
  * into the samples at compile time; the UI-thread worklet only indexes arrays.
18
+ * @internal
25
19
  */
26
20
  export interface PxElementTracks {
27
21
  /** Element id (after id regeneration). */
@@ -30,6 +24,7 @@ export interface PxElementTracks {
30
24
  props: Record<string, Array<string | number | Array<number>>>;
31
25
  }
32
26
 
27
+ /** @internal */
33
28
  export interface PxCompiledTracks {
34
29
  /** Per-iteration duration, ms. */
35
30
  duration: number;
@@ -51,6 +46,7 @@ export interface PxCompiledTracks {
51
46
  elements: Array<PxElementTracks>;
52
47
  }
53
48
 
49
+ /** @internal */
54
50
  export interface CompileTracksOptions {
55
51
  /** Target sample rate, samples/second. Default 60 (one per frame). */
56
52
  sampleRate?: number;
@@ -72,6 +68,7 @@ export interface CompileTracksOptions {
72
68
  /**
73
69
  * Compiles a MATERIALIZED document (run `materializeAllInTree(doc, 'frames')`
74
70
  * + `generateNewIds` first) into densely sampled per-element tracks.
71
+ * @internal
75
72
  */
76
73
  export function compileTracks(doc: PxAnimatedSvgDocument, opts?: CompileTracksOptions): PxCompiledTracks {
77
74
  const config = getAnimatorConfig(doc) || {};
@@ -173,6 +170,7 @@ export const NATIVE_PROP_NAME: Record<string, string> = {
173
170
  * reanimated animated-props path of a real device. Props that are applied by
174
171
  * re-rendering through React (and therefore still pass through react-native-svg's
175
172
  * JS layer), and every value on the web, must keep the wire name.
173
+ * @internal
176
174
  */
177
175
  export function sampleProps(
178
176
  tracks: PxElementTracks,
@@ -63,6 +63,7 @@ import type { ComponentType } from 'react';
63
63
  *
64
64
  * Keys are the wire-format `node.type` values, which follow SVG's own casing
65
65
  * (`clipPath`, `feGaussianBlur`, `linearGradient`, …).
66
+ * @internal
66
67
  */
67
68
  export const RN_SVG_COMPONENTS: Record<string, ComponentType<any>> = {
68
69
  // Root & containers
package/src/index.ts CHANGED
@@ -6,12 +6,3 @@
6
6
  export { PixodeskSvgAnimator, default } from './PixodeskSvgAnimator';
7
7
  export type { PixodeskSvgAnimatorProps, RnAnimatorApi } from './PixodeskSvgAnimator';
8
8
 
9
- export { renderRnNode, toRnProps } from './PxRnRender';
10
- export { PxRnErrorBoundary, type PxRnErrorBoundaryProps } from './PxRnErrorBoundary';
11
- export { openClosedTextPathTargets } from './PxRnSafety';
12
- export type { RenderRnNodeOptions } from './PxRnRender';
13
-
14
- export { compileTracks, sampleProps } from './PxRnTracks';
15
- export type { CompileTracksOptions, PxCompiledTracks, PxElementTracks } from './PxRnTracks';
16
-
17
- export { RN_SVG_COMPONENTS, toRnPropName } from './PxRnTypeMap';