Skip to content

Commit

Permalink
feat: adjust extract-features & metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidosmf committed Dec 17, 2024
1 parent 1a5f7c1 commit 31c1996
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .changeset/late-files-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@lottiefiles/relottie-extract-features': major
'@lottiefiles/relottie-metadata': major
---

feat: use v2 relottie packages with required changes
4 changes: 2 additions & 2 deletions packages/relottie-extract-features/src/extract-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2022 Design Barn Inc.
*/

import type { Root, AnyTitle, NodeValue, KeyNode, Primitive } from '@lottiefiles/last';
import type { Root, AnyTitle, NodeValue, KeyNode, PrimitiveNode } from '@lottiefiles/last';
import type { Plugin } from 'unified';
import { visitParents } from 'unist-util-visit-parents';
import type { Data, VFile } from 'vfile';
Expand Down Expand Up @@ -35,7 +35,7 @@ export interface ExtractFeaturesFileData extends Data {
}

type AncestorChildNode = Exclude<NodeValue, KeyNode>;
type AncestorNode = Exclude<AncestorChildNode, Primitive>;
type AncestorNode = Exclude<AncestorChildNode, PrimitiveNode>;

const extractFeatures: Plugin<[Options?], Root> = (_ops: Options = {}) => {
// const options = { ...DEFAULT_OPTIONS, ...ops };
Expand Down
14 changes: 7 additions & 7 deletions packages/relottie-extract-features/src/used-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
Element,
Collection,
ArrayNode,
Primitive,
PrimitiveNode,
Root,
} from '@lottiefiles/last';

Expand Down Expand Up @@ -52,7 +52,7 @@ export const elementNodeChecker: IsFeatureUsedChecker<Element> = (node): boolean
return objectNodeChecker(objectNode);
};

export const primitiveNodeChecker: IsFeatureUsedChecker<Primitive> = (node): boolean => {
export const primitiveNodeChecker = (node: PrimitiveNode): boolean => {
const value = node.value;

switch (typeof value) {
Expand Down Expand Up @@ -176,19 +176,19 @@ export const isFeatureUsed = (feature: AnyTitle, node: NodeWithTitle): boolean =
}

switch (node.type) {
case 'attribute':
case 'Attribute':
return attributeValueChecker(node);

case 'element':
case 'Element':
return elementNodeChecker(node);

case 'collection':
case 'Collection':
return collectionNodeChecker(node);

case 'array':
case 'Array':
return arrayNodeChecker(node);

case 'object':
case 'Object':
return objectNodeChecker(node);

default:
Expand Down
2 changes: 1 addition & 1 deletion packages/relottie-metadata/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const getRgbaFromNode = (node: Collection): number[] => {
if (!valueNode) return [];

const rgbaColor = valueNode.children.reduce((acc, child) => {
if (child.type !== 'primitive') return acc;
if (child.type !== 'Number') return acc;

const childValue = child.value;

Expand Down

0 comments on commit 31c1996

Please sign in to comment.