Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: default to undefined generator for parsed lotties #51

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

roris
Copy link
Collaborator

@roris roris commented Jul 9, 2024

Pull request checklist

The library currently sets itself as the default generator, even when it is passed a Lottie that does not have a generator. Override behavior of Animation.fromJSON to set metadata fields as undefined when a Lottie without metadata is passed.

The keywords is also changed to be an empty array, instead of array of length 1 in this case.

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (yarn build) was run locally and any changes were pushed
  • Lint (yarn lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix

What is the current behavior?

  • Animation.meta.generator is set to @lottiefiles/lottie-js ${version} when initialized from a JSON object without metadata
  • Animation.meta.keywords is set to an array of length one, with an undefined element, when initialized from a JSON object without metadata

Issue Number: N/A

What is the new behavior?

  • Animation.meta.generator will be undefined when initialized from a JSON object without metadata.
  • Animation.meta.keywords will be an empty array when initialized from a JSON object without metadata.

Does this introduce a breaking change?

  • No

Other information

Copy link

changeset-bot bot commented Jul 9, 2024

🦋 Changeset detected

Latest commit: f450904

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lottiefiles/lottie-js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

github-actions bot commented Jul 9, 2024

Code coverage

Filename Statements Branches Functions Lines
src/shapes/ellipse-shape.ts 100% 100% 100% 100%
src/constants/index.ts 100% 100% 100% 100%
src/constants/asset-type.ts 100% 100% 100% 100%
src/constants/blend-mode.ts 100% 100% 100% 100%
src/constants/fill-rule-type.ts 100% 100% 100% 100%
src/constants/gradient-fill-type.ts 100% 100% 100% 100%
src/constants/gradient-stroke-type.ts 100% 100% 100% 100%
src/constants/layer-type.ts 100% 100% 100% 100%
src/constants/line-cap-type.ts 100% 100% 100% 100%
src/constants/line-join-type.ts 100% 100% 100% 100%
src/constants/mask-mode.ts 100% 100% 100% 100%
src/constants/property-type.ts 100% 100% 100% 100%
src/constants/shape-type.ts 100% 100% 100% 100%
src/constants/trim-mode.ts 100% 100% 100% 100%
src/constants/repeater-composite.ts 100% 100% 100% 100%
src/constants/star-type.ts 100% 100% 100% 100%
src/constants/matte-mode.ts 100% 100% 100% 100%
src/constants/effect-type.ts 100% 100% 100% 100%
src/constants/effect-value-type.ts 100% 100% 100% 100%
src/constants/text-caps.ts 100% 100% 100% 100%
src/constants/text-grouping.ts 100% 100% 100% 100%
src/constants/text-justify.ts 100% 100% 100% 100%
src/constants/text-based.ts 100% 100% 100% 100%
src/constants/text-shape.ts 100% 100% 100% 100%
src/properties/index.ts 100% 100% 100% 100%
src/properties/property.ts 96.97% 91.67% 80% 96.77%
src/timeline/index.ts 100% 100% 100% 100%
src/timeline/key-frame.ts 91.43% 83.78% 100% 91.18%
src/utils/use-registry.ts 100% 100% 100% 100%
src/values/index.ts 100% 100% 100% 100%
src/values/color.ts 60.71% 60% 53.85% 57.69%
src/values/text-document.ts 95.24% 50% 66.67% 95.24%
src/properties/gradient.ts 8.62% 0% 0% 9.8%
src/properties/transform.ts 85.71% 77.27% 100% 85.71%
src/shapes/shape.ts 100% 100% 100% 100%
src/shapes/path-shape.ts 100% 100% 100% 100%
src/animation/animation.ts 59.69% 40.66% 48.98% 60.11%
src/assets/index.ts 100% 100% 100% 100%
src/assets/asset.ts 100% 100% 100% 100%
src/assets/image-asset.ts 22.22% 100% 0% 22.22%
src/assets/precomposition-asset.ts 100% 100% 100% 100%
src/fonts/index.ts 100% 100% 100% 100%
src/fonts/character.ts 8% 0% 0% 8.7%
src/utils/shape.ts 52.63% 47.06% 100% 52.63%
src/shapes/index.ts 100% 100% 100% 100%
src/shapes/fill-shape.ts 100% 50% 100% 100%
src/index.ts 100% 100% 100% 100%
src/animation/index.ts 100% 100% 100% 100%
src/animation/meta.ts 100% 75% 100% 100%
src/layers/index.ts 100% 100% 100% 100%
src/layers/group-layer.ts 50% 100% 0% 50%
src/layers/layer.ts 79.37% 67.65% 42.86% 82.76%
src/effects/index.ts 100% 100% 100% 100%
src/effects/effect-value.ts 80% 25% 66.67% 80%
src/effects/effect.ts 85% 57.14% 60% 88.89%
src/masks/index.ts 100% 100% 100% 100%
src/masks/mask.ts 94.12% 100% 66.67% 94.12%
src/layers/image-layer.ts 33.33% 100% 0% 33.33%
src/layers/precomposition-layer.ts 100% 100% 100% 100%
src/layers/shape-layer.ts 78.26% 0% 87.5% 80.95%
src/layers/solid-layer.ts 85.71% 100% 66.67% 85.71%
src/layers/text-layer.ts 83.33% 50% 66.67% 83.33%
src/text/index.ts 100% 100% 100% 100%
src/text/text-data.ts 88.89% 75% 66.67% 88.24%
src/text/text-animator.ts 90.91% 100% 66.67% 90.91%
src/text/text-selector.ts 93.55% 62.5% 66.67% 93.55%
src/text/text-transform.ts 62.16% 59.38% 50% 62.16%
src/text/text-options.ts 88.89% 100% 66.67% 88.89%
src/markers/index.ts 100% 100% 100% 100%
src/markers/marker.ts 11.11% 100% 0% 11.11%
src/utils/color-spaces.ts 12% 0% 0% 14.29%
src/shapes/gradient-fill-shape.ts 14.29% 0% 0% 14.29%
src/shapes/group-shape.ts 87.88% 50% 83.33% 90.63%
src/shapes/rectangle-shape.ts 100% 100% 100% 100%
src/shapes/stroke-shape.ts 100% 50% 100% 100%
src/shapes/trim-shape.ts 25% 0% 0% 25%
src/shapes/gradient-stroke-shape.ts 12.12% 0% 0% 12.12%
src/shapes/repeater-shape.ts 11.76% 0% 0% 11.76%
src/shapes/star-shape.ts 14.81% 0% 0% 14.81%
src/shapes/rounded-corners-shape.ts 36.36% 100% 0% 36.36%
src/shapes/merge-shape.ts 100% 100% 100% 100%
src/shapes/offset-path-shape.ts 26.67% 100% 0% 26.67%
src/shapes/pucker-bloat-shape.ts 36.36% 100% 0% 36.36%
src/shapes/twist-shape.ts 30.77% 100% 0% 30.77%
src/shapes/zig-zag-shape.ts 26.67% 100% 0% 26.67%
src/fonts/font.ts 94.74% 0% 66.67% 94.74%
src/fonts/font-list.ts 85.71% 100% 75% 83.33%

@jawish jawish merged commit a1bc6c5 into main Jul 10, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants