@@ -38,6 +38,7 @@ import type { PrimitiveParts } from '@lottiefiles/last-builder';
3838import { is } from 'unist-util-is' ;
3939import type { VFile , Data } from 'vfile' ;
4040
41+ import { fileConstants } from './constants.js' ;
4142import type { Dependent } from './entities.js' ;
4243import { getMemberEntity , getNoKeyEntity } from './entities.js' ;
4344import { Stack } from './helpers.js' ;
@@ -46,21 +47,13 @@ import type { ParseOptions } from './options.js';
4647import type { SettingsOptions } from './unified-relottie-parse.js' ;
4748
4849export interface ParseFileData extends Data {
49- parse : {
50- messages ?: VFile [ 'messages' ] ;
51- } ;
50+ parse ?: object ;
5251}
5352
5453export interface Info {
5554 hasExpressions : Root [ 'hasExpressions' ] ;
5655}
5756
58- const addWarningMessage = ( file : VFile , message : string , options : ParseOptions ) : void => {
59- if ( options . warningMessage ) {
60- file . message ( message ) ;
61- }
62- } ;
63-
6457const createValueType = ( node : Momoa . AstNode , options : ParseOptions ) : PrimitiveParts < PrimitiveValueType > => {
6558 if ( ! options . valueType || node . type === 'Array' || node . type === 'Object' || node . type === 'Document' ) {
6659 return { } ;
@@ -157,7 +150,6 @@ const getTitleFromMemberValue = (
157150 parentNodeTitle : ParentTitle ,
158151 dependent : Dependent ,
159152 file : VFile ,
160- options : ParseOptions ,
161153) : AnyTitle | undefined => {
162154 const { key, parentTitle, type } = dependent ;
163155
@@ -178,7 +170,7 @@ const getTitleFromMemberValue = (
178170 if ( ! constTitle ) {
179171 const message = `[${ parentNodeTitle } ] '${ constantKey } ' is missing in "dependent.parentTitle.values"` ;
180172
181- addWarningMessage ( file , message , options ) ;
173+ file . message ( message , node , fileConstants . sourceId ) ;
182174 }
183175
184176 const title = typeof constTitle === 'undefined' ? defaultConstTitle : constTitle ;
@@ -198,7 +190,7 @@ const getTitleFromMemberValue = (
198190 if ( type !== node . type ) {
199191 const message = `${ parentNodeTitle } 's '${ key } ' type is ${ node . type } but has to be ${ type } ` ;
200192
201- addWarningMessage ( file , message , options ) ;
193+ file . message ( message , node , fileConstants . sourceId ) ;
202194 break ;
203195 }
204196
@@ -213,7 +205,6 @@ const getDependentTitle = (
213205 members : Momoa . Member [ ] ,
214206 dependents : Dependent [ ] ,
215207 file : VFile ,
216- options : ParseOptions ,
217208) : AnyTitle | undefined => {
218209 const memberKeyValue = members . reduce ( ( acc , member ) => {
219210 const key = member . name . value ;
@@ -229,37 +220,27 @@ const getDependentTitle = (
229220
230221 if ( ! node ) continue ;
231222
232- const title = getTitleFromMemberValue ( node , parentTitle , dependent , file , options ) ;
223+ const title = getTitleFromMemberValue ( node , parentTitle , dependent , file ) ;
233224
234225 if ( title ) return title ;
235226 }
236227
237228 return undefined ;
238229} ;
239230
240- const getObjectNodeTitle = (
241- node : Momoa . Obj ,
242- parentNodeTitle : ParentTitle ,
243- file : VFile ,
244- options : ParseOptions ,
245- ) : ObjectTitle => {
231+ const getObjectNodeTitle = ( node : Momoa . Obj , parentNodeTitle : ParentTitle , file : VFile ) : ObjectTitle => {
246232 const entity = getNoKeyEntity ( node , parentNodeTitle ) ;
247233
248234 const { defaultTitle, dependents } = entity ;
249235
250236 if ( ! dependents ) return defaultTitle as ObjectTitle ;
251237
252- const title = getDependentTitle ( parentNodeTitle , node . members , dependents , file , options ) ;
238+ const title = getDependentTitle ( parentNodeTitle , node . members , dependents , file ) ;
253239
254240 return ( title || defaultTitle ) as ObjectTitle ;
255241} ;
256242
257- const getArrayNodeTitle = (
258- node : Momoa . Arr ,
259- parentNodeTitle : ParentTitle ,
260- file : VFile ,
261- options : ParseOptions ,
262- ) : ArrayTitle => {
243+ const getArrayNodeTitle = ( node : Momoa . Arr , parentNodeTitle : ParentTitle , file : VFile ) : ArrayTitle => {
263244 const entity = getNoKeyEntity ( node , parentNodeTitle ) ;
264245
265246 const { defaultTitle, dependents } = entity ;
@@ -268,7 +249,7 @@ const getArrayNodeTitle = (
268249
269250 const members = getMembersFromArrNode ( node ) ;
270251
271- const title = getDependentTitle ( parentNodeTitle , members , dependents , file , options ) ;
252+ const title = getDependentTitle ( parentNodeTitle , members , dependents , file ) ;
272253
273254 return ( title || defaultTitle ) as ArrayTitle ;
274255} ;
@@ -307,7 +288,7 @@ const traverseJsonEnter = (
307288 const element = stack . peek ( ) ;
308289
309290 assertNodeType < Element > ( element , 'element' , file ) ;
310- const elementValueTitle = getObjectNodeTitle ( node , element . title , file , options ) ;
291+ const elementValueTitle = getObjectNodeTitle ( node , element . title , file ) ;
311292
312293 stack . push ( objectNode ( elementValueTitle , [ ] , { ...position } ) ) ;
313294 break ;
@@ -316,7 +297,7 @@ const traverseJsonEnter = (
316297 const array = stack . peek ( ) ;
317298
318299 assertNodeType < ArrayNode > ( array , 'array' , file ) ;
319- const objectTitle = getObjectNodeTitle ( node , array . title , file , options ) ;
300+ const objectTitle = getObjectNodeTitle ( node , array . title , file ) ;
320301
321302 stack . push ( objectNode ( objectTitle , [ ] , { ...position } ) ) ;
322303 break ;
@@ -332,7 +313,7 @@ const traverseJsonEnter = (
332313 const collection = stack . peek ( ) ;
333314
334315 assertNodeType < Collection > ( collection , 'collection' , file ) ;
335- const collectionValueTitle = getArrayNodeTitle ( node , collection . title , file , options ) ;
316+ const collectionValueTitle = getArrayNodeTitle ( node , collection . title , file ) ;
336317
337318 stack . push ( arrayNode ( collectionValueTitle , [ ] , { ...position } ) ) ;
338319 break ;
@@ -341,7 +322,7 @@ const traverseJsonEnter = (
341322 const array = stack . peek ( ) ;
342323
343324 assertNodeType < ArrayNode > ( array , 'array' , file ) ;
344- const arrayTitle = getArrayNodeTitle ( node , array . title , file , options ) ;
325+ const arrayTitle = getArrayNodeTitle ( node , array . title , file ) ;
345326
346327 stack . push ( arrayNode ( arrayTitle , [ ] , { ...position } ) ) ;
347328 break ;
@@ -545,16 +526,6 @@ export function parse(document: string, file: VFile, settings: SettingsOptions =
545526 } ,
546527 } ) ;
547528
548- const dataMessages = options . warningMessage && file . messages . length > 0 ? { messages : file . messages } : { } ;
549-
550- const fileData : ParseFileData = {
551- parse : {
552- ...dataMessages ,
553- } ,
554- } ;
555-
556- Object . assign ( file . data , fileData ) ;
557-
558529 const tree = stack . pop ( ) ;
559530
560531 if ( is < Root > ( tree , 'root' ) ) {
0 commit comments