@@ -42,21 +42,17 @@ module.exports = (options = {}) => tree => {
4242 options . plugins = options . plugins || [ ] ;
4343 options . strict = typeof options . strict === 'undefined' ? true : options . strict ;
4444 options . attrsParserRules = options . attrsParserRules || { } ;
45-
4645 options . slot = new RegExp ( `^${ options . slot } :` , 'i' ) ;
4746 options . fill = new RegExp ( `^${ options . fill } :` , 'i' ) ;
4847 options . tagPrefix = new RegExp ( `^${ options . tagPrefix } ` , 'i' ) ;
4948 options . matcher = options . matcher || [ { tag : options . tag } , { tag : options . tagPrefix } ] ;
50-
5149 options . roots = Array . isArray ( options . roots ) ? options . roots : [ options . roots ] ;
5250 options . roots . forEach ( ( root , index ) => {
5351 options . roots [ index ] = path . join ( options . root , root ) ;
5452 } ) ;
55-
5653 options . namespaces = Array . isArray ( options . namespaces ) ? options . namespaces : [ options . namespaces ] ;
5754 options . namespaces . forEach ( ( namespace , index ) => {
5855 options . namespaces [ index ] . root = path . resolve ( namespace . root ) ;
59-
6056 if ( namespace . fallback ) {
6157 options . namespaces [ index ] . fallback = path . resolve ( namespace . fallback ) ;
6258 }
@@ -69,11 +65,7 @@ module.exports = (options = {}) => tree => {
6965 options . locals = { ...options . expressions . locals } ;
7066 options . aware = { } ;
7167
72- log ( options , 'options' , 'init' ) ;
73-
74- // Apply expressions to initial tree
7568 tree = expressions ( options . expressions ) ( tree ) ;
76-
7769 tree = processTree ( options ) ( tree ) ;
7870
7971 return tree ;
@@ -111,11 +103,9 @@ function processTree(options) {
111103 return currentNode ;
112104 }
113105
114- // Process <stack > tag
106+ // Process <push > tag
115107 processPushes ( currentNode , pushedContent , options ) ;
116108
117- // log(componentNode, 'componentNode');
118-
119109 log ( `${ ++ processCounter } ${ componentPath } ` , 'Processing component' , 'processTree' ) ;
120110
121111 let nextNode = parser ( readFileSync ( componentPath , 'utf8' ) ) ;
@@ -129,17 +119,11 @@ function processTree(options) {
129119 const { attributes, locals} = processLocals ( currentNode , nextNode , slotContent , options ) ;
130120
131121 options . expressions . locals = attributes ;
132-
133122 options . expressions . locals . $slots = slotContent ;
134-
135123 // const plugins = [...options.plugins, expressions(options.expressions)];
136-
137- log ( { attributes, locals, slotContent} , 'Processed attributes, locals and slots' , 'processTree' ) ;
138-
139124 nextNode = expressions ( options . expressions ) ( nextNode ) ;
140- // process.exit(0);
141125
142- // Process <stack > tag
126+ // Process <push > tag
143127 processPushes ( nextNode , pushedContent , options ) ;
144128
145129 // Process <stack> tag
@@ -192,8 +176,6 @@ function setFilledSlots(currentNode, slots, {slot}) {
192176
193177 const name = fillNode . tag . split ( ':' ) [ 1 ] ;
194178
195- log ( name , 'found filled slot' , 'setFilledSlots' ) ;
196-
197179 /** @var {Object} locals */
198180 const locals = Object . fromEntries ( Object . entries ( fillNode . attrs ) . filter ( ( [ attributeName ] ) => ! [ name , 'type' ] . includes ( attributeName ) ) ) ;
199181
@@ -217,8 +199,6 @@ function setFilledSlots(currentNode, slots, {slot}) {
217199
218200 return fillNode ;
219201 } ) ;
220-
221- log ( slots , 'all filled slots found' , 'setFilledSlots' ) ;
222202}
223203
224204/**
@@ -242,7 +222,7 @@ function processPushes(tree, content, {push}) {
242222 const pushContent = render ( pushNode . content ) ;
243223
244224 if ( typeof pushNode . attrs . once === 'undefined' || ! content [ pushNode . attrs . name ] . includes ( pushContent ) ) {
245- if ( typeof pushNode . attrs . prepend === 'undefined' ) {
225+ if ( typeof pushNode . attrs . prepend === 'undefined' ) {
246226 content [ pushNode . attrs . name ] . push ( pushContent ) ;
247227 } else {
248228 content [ pushNode . attrs . name ] . unshift ( pushContent ) ;
@@ -254,8 +234,6 @@ function processPushes(tree, content, {push}) {
254234
255235 return pushNode ;
256236 } ) ;
257-
258- log ( Object . keys ( content ) , 'Found pushes' , 'processPushes' ) ;
259237}
260238
261239/**
@@ -267,8 +245,6 @@ function processPushes(tree, content, {push}) {
267245 * @return {void }
268246 */
269247function processStacks ( tree , content , { stack} ) {
270- log ( Object . keys ( content ) , 'Process stacks for this push' , 'processStacks' ) ;
271-
272248 match . call ( tree , { tag : stack } , stackNode => {
273249 stackNode . tag = false ;
274250 stackNode . content = content [ stackNode . attrs . name ] ;
@@ -292,8 +268,6 @@ function processSlotContent(tree, content, {slot}) {
292268 content [ name ] = { } ;
293269 }
294270
295- log ( name , 'processing slot' , 'processSlotContent' ) ;
296-
297271 content [ name ] . tag = slotNode . tag ;
298272 content [ name ] . attrs = slotNode . attrs ;
299273 content [ name ] . content = slotNode . content ;
@@ -305,8 +279,6 @@ function processSlotContent(tree, content, {slot}) {
305279
306280 return slotNode ;
307281 } ) ;
308-
309- log ( content , 'Slots processed' , 'processSlotContent' ) ;
310282}
311283
312284/**
@@ -321,8 +293,6 @@ function processFillContent(tree, content, {fill}) {
321293 match . call ( tree , { tag : fill } , fillNode => {
322294 const name = fillNode . tag . split ( ':' ) [ 1 ] ;
323295
324- log ( name , 'Processing fill' , 'processFillContent' ) ;
325-
326296 fillNode . tag = false ;
327297
328298 if ( content [ name ] ?. rendered ) {
@@ -341,8 +311,6 @@ function processFillContent(tree, content, {fill}) {
341311
342312 return fillNode ;
343313 } ) ;
344-
345- log ( content , 'Processed fill' , 'processFillContent' ) ;
346314}
347315
348316/**
@@ -360,6 +328,7 @@ function processLocals(currentNode, nextNode, slotContent, options) {
360328 const merged = [ ] ;
361329 const computed = [ ] ;
362330 const aware = [ ] ;
331+
363332 Object . keys ( attributes ) . forEach ( attributeName => {
364333 const newAttributeName = attributeName
365334 . replace ( 'merge:' , '' )
@@ -368,22 +337,18 @@ function processLocals(currentNode, nextNode, slotContent, options) {
368337
369338 switch ( true ) {
370339 case attributeName . startsWith ( 'merge:' ) :
371- log ( attributeName , 'merge' , 'processLocals' ) ;
372340 attributes [ newAttributeName ] = attributes [ attributeName ] ;
373341 delete attributes [ attributeName ] ;
374342 merged . push ( newAttributeName ) ;
375-
376343 break ;
377344
378345 case attributeName . startsWith ( 'computed:' ) :
379- log ( attributeName , 'computed' , 'processLocals' ) ;
380346 attributes [ newAttributeName ] = attributes [ attributeName ] ;
381347 delete attributes [ attributeName ] ;
382348 computed . push ( newAttributeName ) ;
383349 break ;
384350
385351 case attributeName . startsWith ( 'aware:' ) :
386- log ( attributeName , 'aware' , 'processLocals' ) ;
387352 attributes [ newAttributeName ] = attributes [ attributeName ] ;
388353 delete attributes [ attributeName ] ;
389354 aware . push ( newAttributeName ) ;
@@ -419,8 +384,6 @@ function processLocals(currentNode, nextNode, slotContent, options) {
419384 // Retrieve default locals from <script props> and merge with attributes
420385 const { locals} = scriptDataLocals ( nextNode , { localsAttr : options . localsAttr , removeScriptLocals : true , locals : { ...attributes , $slots : slotContent } } ) ;
421386
422- log ( locals , 'locals parsed in tag ' + currentNode . tag , 'processLocals' ) ;
423-
424387 // Merge default locals and attributes or overrides props with attributes
425388 if ( locals ) {
426389 if ( merged . length > 0 ) {
@@ -448,8 +411,6 @@ function processLocals(currentNode, nextNode, slotContent, options) {
448411 options . aware = Object . fromEntries ( Object . entries ( attributes ) . filter ( ( [ attributeName ] ) => aware . includes ( attributeName ) ) ) ;
449412 }
450413
451- log ( { locals, attributes} , 'locals and attributes processed for tag ' + currentNode . tag , 'processLocals' ) ;
452-
453414 return { attributes, locals} ;
454415}
455416
@@ -472,51 +433,34 @@ function processAttributes(currentNode, attributes, locals, options) {
472433
473434 const nodeAttrs = parseAttrs ( currentNode . content [ index ] . attrs , options . attrsParserRules ) ;
474435
475- log ( nodeAttrs , 'nodeAttrs in processAttributes' , 'processAttributes' ) ;
476- log ( locals , 'locals in processAttributes' , 'processAttributes' ) ;
477- log ( options . aware , 'options aware in processAttributes' , 'processAttributes' ) ;
478-
479436 Object . keys ( attributes ) . forEach ( attr => {
480- log ( attr , 'processing attribute' , 'processAttributes' ) ;
481- log ( typeof locals [ attr ] === 'undefined' , 'not in locals?' , 'processAttributes' ) ;
482-
483437 if ( typeof locals [ attr ] === 'undefined' && ! Object . keys ( options . aware ) . includes ( attr ) ) {
484438 if ( [ 'class' ] . includes ( attr ) ) {
485- // Merge class
486439 if ( typeof nodeAttrs . class === 'undefined' ) {
487440 nodeAttrs . class = [ ] ;
488441 }
489442
490443 nodeAttrs . class . push ( attributes . class ) ;
491-
492444 delete attributes . class ;
493445 } else if ( [ 'override:class' ] . includes ( attr ) ) {
494- // Override class
495446 nodeAttrs . class = attributes [ 'override:class' ] ;
496-
497447 delete attributes [ 'override:class' ] ;
498448 } else if ( [ 'style' ] . includes ( attr ) ) {
499- // Merge style
500449 if ( typeof nodeAttrs . style === 'undefined' ) {
501450 nodeAttrs . style = { } ;
502451 }
503452
504453 nodeAttrs . style = Object . assign ( nodeAttrs . style , styleToObject ( attributes . style ) ) ;
505-
506454 delete attributes . style ;
507455 } else if ( [ 'override:style' ] . includes ( attr ) ) {
508- // Override style
509456 nodeAttrs . style = attributes [ 'override:style' ] ;
510457 delete attributes [ 'override:style' ] ;
511458 } else if ( ! attr . startsWith ( '$' ) && attr !== options . attribute ) {
512- // Everything that doesn't start with '$' else set as attribute name/value
513459 nodeAttrs [ attr ] = attributes [ attr ] ;
514460 delete attributes [ attr ] ;
515461 }
516462 }
517463 } ) ;
518464
519465 currentNode . content [ index ] . attrs = nodeAttrs . compose ( ) ;
520-
521- log ( currentNode . content [ index ] . attrs , 'after processing attributes' , 'processAttributes' ) ;
522466}
0 commit comments