relottie plugin to add support for serializing LAST
npm install @lottiefiles/relottie-stringifyCompiler for [unified]. Serializes [last] syntax trees to LottieJSON
``sh`
yarn add @lottiefiles/relottie-stringify
`ts
import { unified } from 'unified';
import { visit } from 'unist-util-visit';
import type { Attribute } from '@lottiefiles/last';
import relottieParse from '@lottiefiles/relottie-parse';
import relottieStringify from '@lottiefiles/relottie-stringify';
const processor = unified().use(relottieParse).use(relottieStringify);
const tree = processor.parse('{"v":"5.5.7"}');
visit(tree, 'attribute', (node: Attribute) => {
node.key = 'new_v';
});
const output = processor.stringify(tree);
`
output will equal
`json`
{"new_v":"5.5.7"}
You can use [dotLottie.js] for converting a LottieJSON into .lottie` format
As last properties can have [expressions][], and improper use of last can open you up to cross-site scripting [cross-site scripting (XSS)][XSS]. Carefully assess each plugin and the risks involved in using them.
Any contributions are welcome.
* [unified][]
* [momoa][]
* [lottie-docs][lottie-docs]
License © [LottieFiles][lottiefiles]
[last]: https://github.com/LottieFiles/relottie/tree/main/packages/last
[momoa]: https://github.com/humanwhocodes/momoa
[LottieFiles]: https://github.com/LottieFiles
[lottie-docs]: https://lottiefiles.github.io/lottie-docs/
[unified]: https://github.com/unifiedjs/unified
[dotLottie.js]: https://github.com/dotlottie/dotlottie-js
[expressions]: https://lottiefiles.github.io/lottie-docs/expressions/#expressions
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting