@pixodesk/svg-animator-rn 1.0.39 → 1.0.41

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.
package/dist/index.js CHANGED
@@ -31,30 +31,8 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
 
33
33
  // src/PixodeskSvgAnimator.tsx
34
- import {
35
- clampSeekMs,
36
- createDiagnostics as createDiagnostics2,
37
- createRunClock,
38
- isValidPlaybackRate,
39
- progressSpanMs,
40
- progressToTimeMs,
41
- PX_RATE_REJECTED,
42
- PxDiagnosticKind as PxDiagnosticKind2,
43
- seekCeilingMs,
44
- timeToProgress,
45
- reportDocumentDiagnostics,
46
- generateNewIds,
47
- getAnimatorConfig as getAnimatorConfig2,
48
- getDefs,
49
- materializeAllInTree,
50
- resolveTrigger,
51
- validateNodeEffects,
52
- PxTimelineEngine as PxTimelineEngine2,
53
- PxControlMode,
54
- resolveControlMode,
55
- applyAnimatorConfig,
56
- foldTimelineOverride
57
- } from "@pixodesk/svg-animator-core";
34
+ import { clampSeekMs, createRunClock, isValidPlaybackRate, progressSpanMs, progressToTimeMs, PX_RATE_REJECTED, PxDiagnosticKind as PxDiagnosticKind2, seekCeilingMs, timeToProgress, generateNewIds, getAnimatorConfig as getAnimatorConfig2, getDefinitions, materializeAllInTree, resolveTrigger, validateNodeEffects, PxTimelineEngine as PxTimelineEngine2, PxControlMode, resolveControlMode, applyAnimatorConfig, foldTimelineOverride } from "@pixodesk/svg-animator-core";
35
+ import { createDiagnostics as createDiagnostics2, reportDocumentDiagnostics } from "@pixodesk/svg-animator-core/internal";
58
36
  import { createElement as createElement2, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
59
37
  import { Dimensions, Platform, Pressable, View } from "react-native";
60
38
  import Animated, {
@@ -70,16 +48,11 @@ import Animated, {
70
48
  } from "react-native-reanimated";
71
49
 
72
50
  // src/PxRnTracks.ts
73
- import {
74
- calcAnimationValues,
75
- getAnimatorConfig,
76
- getNormalizedBindings,
77
- DEFAULT_DURATION_MS,
78
- PxTimelineEngine
79
- } from "@pixodesk/svg-animator-core";
51
+ import { calcAnimationValues, getAnimatorConfig, normalizeBindings, PxTimelineEngine } from "@pixodesk/svg-animator-core";
52
+ import { PX_DEFAULT_DURATION_MS } from "@pixodesk/svg-animator-core/internal";
80
53
 
81
54
  // src/PxRnPropNames.ts
82
- import { kebabToCamelCaseWord } from "@pixodesk/svg-animator-core";
55
+ import { kebabToCamelCaseWord } from "@pixodesk/svg-animator-core/internal";
83
56
 
84
57
  // src/PxRnMatrix.ts
85
58
  var DEG = Math.PI / 180;
@@ -177,7 +150,7 @@ function toRnPropValue(rnPropName, value, tag, native = false) {
177
150
  function compileTracks(doc, opts) {
178
151
  var _a, _b, _c, _d;
179
152
  const config = getAnimatorConfig(doc) || {};
180
- const duration = +(config.duration || DEFAULT_DURATION_MS);
153
+ const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
181
154
  const _iterations = config.iterations;
182
155
  let iterations = 1;
183
156
  if (typeof _iterations === "number") iterations = _iterations || 1;
@@ -196,7 +169,7 @@ function compileTracks(doc, opts) {
196
169
  ((_a2 = n == null ? void 0 : n.children) != null ? _a2 : []).forEach(indexTags);
197
170
  };
198
171
  indexTags(doc);
199
- const bindings = getNormalizedBindings(doc, PxTimelineEngine.js) || [];
172
+ const bindings = normalizeBindings(doc, PxTimelineEngine.js) || [];
200
173
  const elements = [];
201
174
  for (const binding of bindings) {
202
175
  const animDef = binding.animate;
@@ -256,13 +229,8 @@ function sampleProps(tracks, tMs, stepMs, sampleCount, native = false) {
256
229
  }
257
230
 
258
231
  // src/PxRnRender.tsx
259
- import {
260
- getNormalizedProps,
261
- resolveStyle,
262
- sanitizeAttributeValue,
263
- DISALLOWED_SVG_TAGS_LOWER,
264
- TEXT_CONTENT_ATTR
265
- } from "@pixodesk/svg-animator-core";
232
+ import { toDomProps } from "@pixodesk/svg-animator-core";
233
+ import { sanitizeAttributeValue, PX_DISALLOWED_SVG_TAGS_LOWER, PX_TEXT_CONTENT_ATTR } from "@pixodesk/svg-animator-core/internal";
266
234
  import { createElement } from "react";
267
235
 
268
236
  // src/PxRnTypeMap.ts
@@ -379,7 +347,7 @@ var RN_SVG_COMPONENTS = {
379
347
 
380
348
  // src/PxRnRender.tsx
381
349
  function toRnProps(props, warnings, tag) {
382
- const normalized = getNormalizedProps(props);
350
+ const normalized = toDomProps(props);
383
351
  const out = {};
384
352
  for (const key of Object.keys(normalized)) {
385
353
  const sanitized = sanitizeAttributeValue(key, normalized[key]);
@@ -397,7 +365,7 @@ function renderRnNode(node, opts = {}, key) {
397
365
  const tag = String(type || "g");
398
366
  const domType = props.domType;
399
367
  if (domType !== void 0) delete props.domType;
400
- if (DISALLOWED_SVG_TAGS_LOWER.has(tag.toLowerCase())) {
368
+ if (PX_DISALLOWED_SVG_TAGS_LOWER.has(tag.toLowerCase())) {
401
369
  (_b = opts.warnings) == null ? void 0 : _b.push("tag blocked (dangerous): " + tag);
402
370
  return null;
403
371
  }
@@ -408,7 +376,7 @@ function renderRnNode(node, opts = {}, key) {
408
376
  }
409
377
  const rnProps = toRnProps(props, opts.warnings, tag);
410
378
  if (domType !== void 0) rnProps.type = domType;
411
- const resolved = resolveStyle(style, opts.defs);
379
+ const resolved = style;
412
380
  if (resolved) {
413
381
  for (const [k, v] of Object.entries(resolved)) {
414
382
  const rnKey = toRnPropName(k);
@@ -418,7 +386,7 @@ function renderRnNode(node, opts = {}, key) {
418
386
  rnProps[rnKey] = toRnPropValue(rnKey, String(sanitized), tag);
419
387
  }
420
388
  }
421
- const textContent = props[TEXT_CONTENT_ATTR];
389
+ const textContent = props[PX_TEXT_CONTENT_ATTR];
422
390
  let childElements = void 0;
423
391
  if (Array.isArray(children) && children.length > 0) {
424
392
  childElements = children.map((ch, i) => {
@@ -444,7 +412,8 @@ function renderRnNode(node, opts = {}, key) {
444
412
 
445
413
  // src/PxRnErrorBoundary.tsx
446
414
  import { Component } from "react";
447
- import { createDiagnostics, PxDiagnosticKind } from "@pixodesk/svg-animator-core";
415
+ import { PxDiagnosticKind } from "@pixodesk/svg-animator-core";
416
+ import { createDiagnostics } from "@pixodesk/svg-animator-core/internal";
448
417
  var PxRnErrorBoundary = class extends Component {
449
418
  constructor() {
450
419
  super(...arguments);
@@ -454,9 +423,8 @@ var PxRnErrorBoundary = class extends Component {
454
423
  return { error };
455
424
  }
456
425
  componentDidCatch(error, info) {
457
- var _a, _b, _c, _d, _e;
458
- (_c = (_b = this.props).onError) == null ? void 0 : _c.call(_b, error, (_a = info == null ? void 0 : info.componentStack) != null ? _a : void 0);
459
- ((_d = this.props.diag) != null ? _d : createDiagnostics(void 0, "[PixodeskSvgAnimator]")).warn(PxDiagnosticKind.internal, "render failed: " + ((_e = error == null ? void 0 : error.message) != null ? _e : String(error)));
426
+ var _a, _b;
427
+ ((_a = this.props.diag) != null ? _a : createDiagnostics(void 0, "[PixodeskSvgAnimator]")).error(PxDiagnosticKind.internal, error, { componentStack: (_b = info == null ? void 0 : info.componentStack) != null ? _b : void 0 });
460
428
  }
461
429
  componentDidUpdate(prev) {
462
430
  if (this.state.error && prev.children !== this.props.children) {
@@ -471,7 +439,7 @@ var PxRnErrorBoundary = class extends Component {
471
439
  };
472
440
 
473
441
  // src/PxRnSafety.ts
474
- import { deepClone, generateUniqueId } from "@pixodesk/svg-animator-core";
442
+ import { deepClone, generateUniqueId } from "@pixodesk/svg-animator-core/internal";
475
443
  function isClosedPath(d) {
476
444
  return typeof d === "string" && /[zZ]/.test(d);
477
445
  }
@@ -622,7 +590,7 @@ function compileDocument(doc, overrides, diag) {
622
590
  reportDocumentDiagnostics(doc, "[PixodeskSvgAnimator]");
623
591
  const patch = foldTimelineOverride(timeline, { duration, delay, iterations, startOn });
624
592
  if (patch !== void 0 || resetTimeline) {
625
- const applied = applyAnimatorConfig(doc, patch != null ? patch : {}, { resetDefaults: !!resetTimeline });
593
+ const applied = applyAnimatorConfig(doc, patch != null ? patch : {}, { resetTimeline: !!resetTimeline });
626
594
  for (const w of applied.warnings) diag.warn(PxDiagnosticKind2.usage, "timeline override: " + w);
627
595
  doc = applied.doc;
628
596
  }
@@ -658,21 +626,15 @@ function PixodeskSvgAnimator({
658
626
  onError,
659
627
  fallback,
660
628
  onWarn,
661
- silent
629
+ muteWarn,
630
+ muteError
662
631
  }) {
663
632
  var _a, _b;
664
633
  const timelineKey = typeof timeline === "string" ? timeline : JSON.stringify(timeline != null ? timeline : null);
665
- const makeDiag = () => createDiagnostics2({
666
- onWarn,
667
- // This component's public `onError` is richer — `(error, componentStack?)` — and the
668
- // error boundary hands it a component stack. Adapt rather than narrow it; the ternary
669
- // keeps "not given" as undefined, so the console fallback still fires.
670
- onError: onError ? (d) => {
671
- var _a2;
672
- return onError((_a2 = d.error) != null ? _a2 : new Error(d.message));
673
- } : void 0,
674
- silent
675
- }, "[PixodeskSvgAnimator]");
634
+ const makeDiag = () => createDiagnostics2(
635
+ { onWarn, onError, muteWarn, muteError },
636
+ "[PixodeskSvgAnimator]"
637
+ );
676
638
  const compiled = useMemo(() => {
677
639
  try {
678
640
  return compileDocument(
@@ -682,7 +644,7 @@ function PixodeskSvgAnimator({
682
644
  );
683
645
  } catch (e) {
684
646
  const error = e instanceof Error ? e : new Error(String(e));
685
- makeDiag().warn(PxDiagnosticKind2.internal, "could not compile the document: " + error.message);
647
+ makeDiag().error(PxDiagnosticKind2.internal, error, { phase: "compile" });
686
648
  return { doc: null, tracks: EMPTY_TRACKS, error };
687
649
  }
688
650
  }, [doc, timelineKey, resetTimeline, duration, delay, iterations, startOn]);
@@ -878,7 +840,7 @@ function PixodeskSvgAnimator({
878
840
  if (!compiled.doc) return null;
879
841
  const renderOpts = {
880
842
  warnings: warningsRef.current,
881
- defs: getDefs(compiled.doc)
843
+ defs: getDefinitions(compiled.doc)
882
844
  };
883
845
  try {
884
846
  return renderRnNode(compiled.doc, __spreadProps(__spreadValues({}, renderOpts), {
@@ -918,7 +880,7 @@ function PixodeskSvgAnimator({
918
880
  } catch (e) {
919
881
  const error = e instanceof Error ? e : new Error(String(e));
920
882
  renderErrorRef.current = error;
921
- makeDiag().warn(PxDiagnosticKind2.internal, "could not render the document: " + error.message);
883
+ makeDiag().error(PxDiagnosticKind2.internal, error, { phase: "render" });
922
884
  return null;
923
885
  }
924
886
  }, [compiled, trackById]);
@@ -927,9 +889,6 @@ function PixodeskSvgAnimator({
927
889
  for (const w of warningsRef.current) diag.warn(PxDiagnosticKind2.platform, w);
928
890
  }, [root]);
929
891
  const failure = (_b = compiled.error) != null ? _b : renderErrorRef.current;
930
- useEffect(() => {
931
- if (failure) onError == null ? void 0 : onError(failure);
932
- }, [failure]);
933
892
  if (failure) return fallback ? fallback(failure) : null;
934
893
  let content = root;
935
894
  if (autoplay && effectiveStartOn === "scrollIntoView" && root) {
@@ -954,19 +913,11 @@ function PixodeskSvgAnimator({
954
913
  }
955
914
  );
956
915
  }
957
- return /* @__PURE__ */ jsx(PxRnErrorBoundary, { onError, fallback, diag: makeDiag(), children: content });
916
+ return /* @__PURE__ */ jsx(PxRnErrorBoundary, { fallback, diag: makeDiag(), children: content });
958
917
  }
959
918
  var PixodeskSvgAnimator_default = PixodeskSvgAnimator;
960
919
  export {
961
920
  PixodeskSvgAnimator,
962
- PxRnErrorBoundary,
963
- RN_SVG_COMPONENTS,
964
- compileTracks,
965
- PixodeskSvgAnimator_default as default,
966
- openClosedTextPathTargets,
967
- renderRnNode,
968
- sampleProps,
969
- toRnPropName,
970
- toRnProps
921
+ PixodeskSvgAnimator_default as default
971
922
  };
972
923
  //# sourceMappingURL=index.js.map