Skip to content

Commit ba6324a

Browse files
committed
refactor(parse): rename parentTitle to resultTitle
1 parent 96f457b commit ba6324a

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

Diff for: packages/relottie-parse/src/entities.ts

+40-40
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface DependentBase {
8282
/**
8383
* parentTitle dependent info for the parent node's title
8484
*/
85-
parentTitle: ParentTitle | ParentTitleConstant;
85+
resultTitle: ParentTitle | ParentTitleConstant;
8686
/**
8787
* Dependent node's title
8888
*/
@@ -94,12 +94,12 @@ export interface DependentBase {
9494
}
9595

9696
export interface DependentPrimitive extends DependentBase {
97-
parentTitle: ParentTitle;
97+
resultTitle: ParentTitle;
9898
type: MomoaPrimitive['type'] | MomoaObject['type'];
9999
}
100100

101101
export interface DependentObject extends DependentBase {
102-
parentTitle: ParentTitle;
102+
resultTitle: ParentTitle;
103103
type: MomoaObject['type'];
104104
}
105105

@@ -108,12 +108,12 @@ export interface DependentArray extends DependentBase {
108108
* if present the "childType" will be checked as well
109109
*/
110110
childType?: MomoaValueNode['type'];
111-
parentTitle: ParentTitle;
111+
resultTitle: ParentTitle;
112112
type: MomoaArray['type'];
113113
}
114114

115115
export interface DependentConstant extends DependentBase {
116-
parentTitle: ParentTitleConstant;
116+
resultTitle: ParentTitleConstant;
117117
type: 'Constant';
118118
}
119119

@@ -148,13 +148,13 @@ const animatedPropEntity = (parentTitle: AnimatedPropertyTitle, kTitle: AnyTitle
148148
type: 'Array',
149149
title: kTitle,
150150
childType: 'Object',
151-
parentTitle,
151+
resultTitle: parentTitle,
152152
},
153153
{
154154
key: 'a',
155155
type: 'Constant',
156156
title: IBT.animated,
157-
parentTitle: {
157+
resultTitle: {
158158
defaultValue: 0,
159159
values: {
160160
0: `${parentTitle}-static`,
@@ -194,7 +194,7 @@ export const objectEntity: NoKeyEntityMap = {
194194
key: 'ty',
195195
type: 'Constant',
196196
title: NT.layerType,
197-
parentTitle: {
197+
resultTitle: {
198198
prefix: 'layer',
199199
defaultValue: 0,
200200
values: {
@@ -226,7 +226,7 @@ export const objectEntity: NoKeyEntityMap = {
226226
key: 'ty',
227227
type: 'Constant',
228228
title: ST.shapeType,
229-
parentTitle: {
229+
resultTitle: {
230230
prefix: 'shape',
231231
defaultValue: 'rc',
232232
values: {
@@ -257,7 +257,7 @@ export const objectEntity: NoKeyEntityMap = {
257257
key: 'sy',
258258
type: 'Constant',
259259
title: NT.shapePolygonStarType,
260-
parentTitle: {
260+
resultTitle: {
261261
prefix: 'shape',
262262
defaultValue: 1,
263263
values: {
@@ -272,13 +272,13 @@ export const objectEntity: NoKeyEntityMap = {
272272
[CT.assets]: {
273273
defaultTitle: OT.assetPrecomposition,
274274
dependents: [
275-
{ key: 'w', type: 'Number', title: NT.width, parentTitle: OT.assetImage },
276-
{ key: 'h', type: 'Number', title: NT.height, parentTitle: OT.assetImage },
275+
{ key: 'w', type: 'Number', title: NT.width, resultTitle: OT.assetImage },
276+
{ key: 'h', type: 'Number', title: NT.height, resultTitle: OT.assetImage },
277277
{
278278
key: 't',
279279
type: 'Constant',
280280
title: ST.assetType,
281-
parentTitle: {
281+
resultTitle: {
282282
prefix: 'asset',
283283
defaultValue: 'seq',
284284
values: {
@@ -287,19 +287,19 @@ export const objectEntity: NoKeyEntityMap = {
287287
},
288288
},
289289
},
290-
{ key: 'layers', type: 'Array', title: CT.composition, parentTitle: OT.assetPrecomposition },
291-
{ key: 'mn', type: 'String', title: ST.matchName, parentTitle: OT.assetPrecomposition },
292-
{ key: 'fr', type: 'Number', title: NT.framerate, parentTitle: OT.assetPrecomposition },
290+
{ key: 'layers', type: 'Array', title: CT.composition, resultTitle: OT.assetPrecomposition },
291+
{ key: 'mn', type: 'String', title: ST.matchName, resultTitle: OT.assetPrecomposition },
292+
{ key: 'fr', type: 'Number', title: NT.framerate, resultTitle: OT.assetPrecomposition },
293293
{
294294
key: 'xt',
295295
// integer-boolean
296296
type: 'Number',
297297
title: IBT.extraComposition,
298-
parentTitle: OT.assetPrecomposition,
298+
resultTitle: OT.assetPrecomposition,
299299
},
300-
{ key: 'p', type: 'String', title: ST.filename, parentTitle: OT.assetFile },
301-
{ key: 'u', type: 'String', title: ST.path, parentTitle: OT.assetFile },
302-
{ key: 'e', type: 'Number', title: IBT.embedded, parentTitle: OT.assetFile },
300+
{ key: 'p', type: 'String', title: ST.filename, resultTitle: OT.assetFile },
301+
{ key: 'u', type: 'String', title: ST.path, resultTitle: OT.assetFile },
302+
{ key: 'e', type: 'Number', title: IBT.embedded, resultTitle: OT.assetFile },
303303
],
304304
},
305305
[CT.effectList]: {
@@ -309,7 +309,7 @@ export const objectEntity: NoKeyEntityMap = {
309309
key: 'ty',
310310
type: 'Constant',
311311
title: NT.effectType,
312-
parentTitle: {
312+
resultTitle: {
313313
prefix: 'effect',
314314
defaultValue: 5,
315315
values: {
@@ -341,7 +341,7 @@ export const objectEntity: NoKeyEntityMap = {
341341
key: 'ty',
342342
type: 'Constant',
343343
title: NT.effectValueType,
344-
parentTitle: {
344+
resultTitle: {
345345
defaultValue: 0,
346346
prefix: 'effect-param',
347347
values: {
@@ -365,7 +365,7 @@ export const objectEntity: NoKeyEntityMap = {
365365
key: 'ty',
366366
type: 'Constant',
367367
title: NT.layerStyleType,
368-
parentTitle: {
368+
resultTitle: {
369369
prefix: CT.layerStyle,
370370
defaultValue: 0,
371371
values: {
@@ -463,13 +463,13 @@ export const objectEntity: NoKeyEntityMap = {
463463
type: 'Array',
464464
title: CT.positionKeyframeList,
465465
childType: 'Object',
466-
parentTitle: OT.animatedPosition,
466+
resultTitle: OT.animatedPosition,
467467
},
468468
{
469469
key: 'a',
470470
type: 'Constant',
471471
title: IBT.animated,
472-
parentTitle: {
472+
resultTitle: {
473473
defaultValue: 0,
474474
values: {
475475
0: OT.animatedPositionStatic,
@@ -481,11 +481,11 @@ export const objectEntity: NoKeyEntityMap = {
481481
key: 's',
482482
type: 'Boolean',
483483
title: BT.splitEnabled,
484-
parentTitle: OT.splitVector,
484+
resultTitle: OT.splitVector,
485485
},
486-
{ key: 'x', type: 'Object', title: ET.animatedValueProp, parentTitle: OT.splitVector },
487-
{ key: 'y', type: 'Object', title: ET.animatedValueProp, parentTitle: OT.splitVector },
488-
{ key: 'z', type: 'Object', title: ET.animatedValueProp, parentTitle: OT.splitVector },
486+
{ key: 'x', type: 'Object', title: ET.animatedValueProp, resultTitle: OT.splitVector },
487+
{ key: 'y', type: 'Object', title: ET.animatedValueProp, resultTitle: OT.splitVector },
488+
{ key: 'z', type: 'Object', title: ET.animatedValueProp, resultTitle: OT.splitVector },
489489
],
490490
},
491491
[ET.layerTransformScale]: {
@@ -909,7 +909,7 @@ export const objectEntity: NoKeyEntityMap = {
909909
key: 'n',
910910
type: 'Constant',
911911
title: ST.strokeDashType,
912-
parentTitle: {
912+
resultTitle: {
913913
prefix: 'stroke-dash',
914914
defaultValue: 'd',
915915
values: {
@@ -930,13 +930,13 @@ export const objectEntity: NoKeyEntityMap = {
930930
[ET.textCharacterData]: {
931931
defaultTitle: OT.characterShapes,
932932
dependents: [
933-
{ key: 'shapes', type: 'Array', title: CT.shapeList, parentTitle: OT.characterShapes },
934-
{ key: 'refId', type: 'String', title: ST.idReference, parentTitle: OT.characterPrecomp },
935-
{ key: 'ks', type: 'Object', title: ET.layerTransform, parentTitle: OT.characterPrecomp },
936-
{ key: 'ip', type: 'Number', title: NT.inPoint, parentTitle: OT.characterPrecomp },
937-
{ key: 'op', type: 'Number', title: NT.outPoint, parentTitle: OT.characterPrecomp },
938-
{ key: 'sr', type: 'Number', title: NT.timeStretch, parentTitle: OT.characterPrecomp },
939-
{ key: 'st', type: 'Number', title: NT.timeStart, parentTitle: OT.characterPrecomp },
933+
{ key: 'shapes', type: 'Array', title: CT.shapeList, resultTitle: OT.characterShapes },
934+
{ key: 'refId', type: 'String', title: ST.idReference, resultTitle: OT.characterPrecomp },
935+
{ key: 'ks', type: 'Object', title: ET.layerTransform, resultTitle: OT.characterPrecomp },
936+
{ key: 'ip', type: 'Number', title: NT.inPoint, resultTitle: OT.characterPrecomp },
937+
{ key: 'op', type: 'Number', title: NT.outPoint, resultTitle: OT.characterPrecomp },
938+
{ key: 'sr', type: 'Number', title: NT.timeStretch, resultTitle: OT.characterPrecomp },
939+
{ key: 'st', type: 'Number', title: NT.timeStart, resultTitle: OT.characterPrecomp },
940940
],
941941
},
942942
[CT.textDocumentKeyframes]: {
@@ -960,11 +960,11 @@ const createDependentTitles = (
960960
): Record<string, AnyTitle> => {
961961
const entityMap = objectEntity[parentTitle];
962962
const dependents = entityMap?.dependents;
963-
const node = dependents?.find((item) => item.key === dependentKey);
963+
const dependent = dependents?.find((item) => item.key === dependentKey);
964964

965-
if (node?.type !== 'Constant') return {};
965+
if (dependent?.type !== 'Constant') return {};
966966

967-
const { prefix, values } = node.parentTitle;
967+
const { prefix, values } = dependent.resultTitle;
968968

969969
const prefixTitle = prefix ? `${prefix}-` : '';
970970

Diff for: packages/relottie-parse/src/helpers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const getTitleFromMemberValue = (
189189
dependent: Dependent,
190190
file: VFile,
191191
): AnyTitle | undefined => {
192-
const { key, parentTitle, type } = dependent;
192+
const { key, resultTitle: parentTitle, type } = dependent;
193193

194194
switch (type) {
195195
case 'Constant':
@@ -256,11 +256,11 @@ const getDependentTitle = (
256256

257257
for (const dependent of dependents) {
258258
const { key } = dependent;
259-
const node = memberKeyValue[key];
259+
const keyValue = memberKeyValue[key];
260260

261-
if (!node) continue;
261+
if (!keyValue) continue;
262262

263-
const title = getTitleFromMemberValue(node, parentTitle, dependent, file);
263+
const title = getTitleFromMemberValue(keyValue, parentTitle, dependent, file);
264264

265265
if (title) return title;
266266
}

0 commit comments

Comments
 (0)