File tree Expand file tree Collapse file tree 4 files changed +24
-9
lines changed
Expand file tree Collapse file tree 4 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @xstate/machine-extractor ' : minor
3+ ---
4+
5+ Capture any string field from meta instead of just description
Original file line number Diff line number Diff line change 1+ import { createMachine } from 'xstate' ;
2+
3+ export const machine = createMachine ( {
4+ meta : {
5+ description : 'description' ,
6+ someOtherField : 'hello there' ,
7+ } ,
8+ } ) ;
Original file line number Diff line number Diff line change 11import { StringLiteral , TemplateLiteral } from './scalars' ;
22import { unionType } from './unionType' ;
3- import { objectTypeWithKnownKeys } from './utils' ;
3+ import { objectOf } from './utils' ;
44
5- export const MetaDescription = unionType ( [ StringLiteral , TemplateLiteral ] ) ;
5+ export const MetaValues = unionType ( [ StringLiteral , TemplateLiteral ] ) ;
66
7- export const StateMeta = objectTypeWithKnownKeys ( {
8- description : MetaDescription ,
9- } ) ;
7+ export const StateMeta = objectOf ( MetaValues ) ;
Original file line number Diff line number Diff line change @@ -101,10 +101,14 @@ const parseStateNode = (
101101 config . always = getTransitions ( astResult . always , opts ) ;
102102 }
103103
104- if ( astResult . meta ?. description ) {
105- config . meta = {
106- description : astResult . meta . description . value ,
107- } ;
104+ if ( astResult . meta ) {
105+ config . meta = astResult . meta . properties . reduce (
106+ ( meta , props ) => ( {
107+ ...meta ,
108+ [ props . key ] : props . result . value ,
109+ } ) ,
110+ { } ,
111+ ) ;
108112 }
109113
110114 if ( astResult . onDone ) {
You can’t perform that action at this time.
0 commit comments