diff --git a/build/build.node.ts b/build/build.node.ts index 5773489ddd9..e0b3cfc67a1 100644 --- a/build/build.node.ts +++ b/build/build.node.ts @@ -589,7 +589,8 @@ namespace $ { if( mod !== this.root() ) this.modEnsure( parent.path() ) var mapping = mod === this.root() - ? this.$.$mol_tree2_from_string( `pack ${ mod.name() } git \\https://github.com/hyoo-ru/mam.git\n` ) + ? this.$.$mol_tree2_from_string( `pack ${ mod.name() } git \\https://github.com/hyoo-ru/mam.git +` ) : this.modMeta( parent.path() ) if( mod.exists() ) { diff --git a/state/shared/shared.ts b/state/shared/shared.ts index 38ca6e4e70b..cf786100e9a 100644 --- a/state/shared/shared.ts +++ b/state/shared/shared.ts @@ -336,7 +336,7 @@ namespace $ { send( key: string, next?: readonly $hyoo_crowd_chunk[] ) { const socket = this.socket() - $mol_wire_sync( this ).wait_connection()/* */ + $mol_wire_sync( this ).wait_connection() if( socket.readyState !== socket.OPEN ) return diff --git a/tree2/js/to/text/text.ts b/tree2/js/to/text/text.ts index 505243c19b4..cbffd92ea79 100644 --- a/tree2/js/to/text/text.ts +++ b/tree2/js/to/text/text.ts @@ -225,7 +225,7 @@ namespace $ { ] // number - if( input.type.match(/[+\-]?NaN/) || !Number.isNaN( Number( input.type ) ) ) return [ + if( $mol_view_tree2_value_number(input.type) ) return [ input.data( input.type ) ] diff --git a/view/tree2/to/dts/dts.ts b/view/tree2/to/dts/dts.ts index 2eceb6871e9..36ec4c49c49 100644 --- a/view/tree2/to/dts/dts.ts +++ b/view/tree2/to/dts/dts.ts @@ -15,10 +15,10 @@ namespace $ { return prop.data(name) } - function params_of( this: $, prop: $mol_tree2, ... val: $mol_tree2[] ) { + function channel_signature( this: $, prop: $mol_tree2, ... val: $mol_tree2[] ) { const { name, key, next } = this.$mol_view_tree2_prop_parts(prop) - if (next && (! val.length || ! val[0].value) ) { + if (next && ! val[0]?.value ) { this.$mol_fail( err`Type empty for next value at ${prop.span}` ) @@ -28,13 +28,16 @@ namespace $ { prop.data(name), prop.data('( '), ... key ? [ - prop.data( 'id: any' + (next ? ', ' : '') ), + prop.data('id'), + prop.data( ': any' + ( next ? ', ' : '' ) ), ] : [], ... next ? [ - prop.data( 'next?: ' ), + prop.data('next'), + prop.data( '?: ' ), ... val, + prop.data(' '), ] : [], - prop.data(' )'), + prop.data(')'), ] ) } @@ -61,24 +64,17 @@ namespace $ { function primitive_type(input: $mol_tree2) { let type = 'string' - if (input.type && ( - input.type.match(/[\+\-]*NaN/) - || !Number.isNaN( Number( input.type ) ) - )) type = 'number' + if (input.type && $mol_view_tree2_value_number(input.type)) type = 'number' if (input.type === 'true' || input.type === 'false') type = 'boolean' return input.data(type) } - function readonly_arr(this: $, input: $mol_tree2, infered: readonly $mol_tree2[]) { - return infered.length === 1 ? [ - input.data('readonly( '), - infered[0], - input.data(' )[]'), - ] : [ + function readonly_arr(input: $mol_tree2, infered: readonly $mol_tree2[]) { + return [ input.data('readonly('), - input.struct( 'indent', infered), + infered.length === 1 ? infered[0] : input.struct( 'indent', infered), input.data(')[]'), ] } @@ -121,10 +117,9 @@ namespace $ { 'null': val => { const kid = val.kids[0] - const kid_data = kid?.type ? kid.data(kid.type) : undefined - return kid_data - ? [ kid_data, val.data( ' | null' ) ] + return kid?.type + ? [ kid.data(kid.type), val.data( ' | null' ) ] : [ val.data( 'any' ) ] }, @@ -219,7 +214,7 @@ namespace $ { return kid.struct( 'line', kid.type.match(/(?:\*|\?)/) ? [ - params_of.call(this, kid, ...ret), + channel_signature.call(this, kid, ...ret), kid.data(': '), ...ret, kid.data( ',' ), @@ -261,7 +256,7 @@ namespace $ { ] if (array_type[0].value === 'any') { - return readonly_arr.call(this, input, array_type) + return readonly_arr(input, array_type) } for (const kid of input.kids) { @@ -288,7 +283,7 @@ namespace $ { ) } - return readonly_arr.call(this, input, array_type) + return readonly_arr(input, array_type) } if( $mol_view_tree2_class_match( input ) ) { @@ -355,7 +350,7 @@ namespace $ { return prop.struct( 'indent', [ prop.struct( 'line', [ - params_of.call(this, prop, ... val ), // Parameter, not Return + channel_signature.call(this, prop, ... val ), // Parameter, not Return prop.data(': '), ... val, ] ) diff --git a/view/tree2/to/js/js.ts b/view/tree2/to/js/js.ts index d706768f3c2..354c7d36828 100644 --- a/view/tree2/to/js/js.ts +++ b/view/tree2/to/js/js.ts @@ -143,7 +143,7 @@ namespace $ { if( input.type[0] === '/' ) return [ input.struct( '[,]', input.hack( belt ) ), ] - if( input.type && (input.type.match(/[\+\-]*NaN/) || !Number.isNaN( Number( input.type ) ) ) ) return [ + if( input.type && $mol_view_tree2_value_number(input.type) ) return [ input ] @@ -154,7 +154,7 @@ namespace $ { for( const over of input.kids ) { - if( over.type?.[0] === '/' ) continue + if( over.type[0] === '/' ) continue const bind = over.kids[0] if( bind.type === '=>' ) continue diff --git a/view/tree2/value/number.ts b/view/tree2/value/number.ts new file mode 100644 index 00000000000..b7358f49d79 --- /dev/null +++ b/view/tree2/value/number.ts @@ -0,0 +1,5 @@ +namespace $ { + export function $mol_view_tree2_value_number(type: string) { + return type.match(/[\+\-]*NaN/) || !Number.isNaN( Number( type ) ) + } +}