diff --git a/book2/book2.view.css b/book2/book2.view.css index 955de3e7fb9..20c6b86dc0b 100644 --- a/book2/book2.view.css +++ b/book2/book2.view.css @@ -33,7 +33,7 @@ top: 1.5rem; width: 1px; height: 1rem; - background: var(--mol_theme_special); + background: var(--mol_theme_focus); border-radius: var(--mol_gap_round); opacity: .5; } diff --git a/build/build.node.ts b/build/build.node.ts index f72e04dbde4..533abcf9977 100644 --- a/build/build.node.ts +++ b/build/build.node.ts @@ -696,7 +696,7 @@ namespace $ { try { this.modEnsure( dep.path() ) } catch( error: any ) { - error.message = `${ error.message }\nDependency "${ dep.relate( this.root() ) }" from "${ mod.relate( this.root() ) }" ` + error.message = `${ error.message }\nDependency "${p}" -> "${ dep.relate( this.root() ) }" from "${ mod.relate( this.root() ) }" ` $mol_fail_hidden(error) } @@ -905,7 +905,7 @@ namespace $ { var sources = this.sources_js( { path , exclude } ) if( sources.length === 0 ) return [] - var concater = new $mol_sourcemap_builder( targetJS.parent().path(), ';') + var concater = new $mol_sourcemap_builder( this.root().relate( targetJS.parent() ), ';') concater.add( '"use strict"' ) if( bundle === 'node' ) { @@ -931,7 +931,7 @@ namespace $ { concater.add( `\nvar $node = $node || {}\nvoid function( module ) { var exports = module.${''}exports = this; function require( id ) { return $node[ id.replace( /^.\\// , "` + src.parent().relate( this.root().resolve( 'node_modules' ) ) + `/" ) ] }; \n`, '-' ) } - concater.add( content.text , src.relate( targetJS.parent() ) , content.map ) + concater.add( content.text , '' , content.map ) if( isCommonJs ) { const idFull = src.relate( this.root().resolve( 'node_modules' ) ) @@ -1016,7 +1016,7 @@ namespace $ { var target = pack.resolve( `-/${bundle}.test.js` ) var targetMap = pack.resolve( `-/${bundle}.test.js.map` ) - var concater = new $mol_sourcemap_builder( target.parent().path(), ';') + var concater = new $mol_sourcemap_builder( this.root().relate( target.parent() ), ';') concater.add( '"use strict"' ) var exclude_ext = exclude.filter( ex => ex !== 'test' && ex !== 'dev' ) @@ -1041,7 +1041,7 @@ namespace $ { } try { const content = this.js_content( src.path() ) - concater.add( content.text, src.relate( target.parent() ), content.map) + concater.add( content.text, '', content.map) } catch( error: any ) { errors.push( error ) } diff --git a/compare/deep/deep.ts b/compare/deep/deep.ts index 396a243975b..91830cd72cd 100644 --- a/compare/deep/deep.ts +++ b/compare/deep/deep.ts @@ -21,10 +21,10 @@ namespace $ { if( left_proto !== right_proto ) return false - if( left instanceof Boolean ) return Object.is( left.valueOf(), right['valueOf']() ) - if( left instanceof Number ) return Object.is( left.valueOf(), right['valueOf']() ) - if( left instanceof String ) return Object.is( left.valueOf(), right['valueOf']() ) - if( left instanceof Date ) return Object.is( left.valueOf(), right['valueOf']() ) + if( left instanceof Boolean ) return Object.is( left.valueOf(), ( right as any )['valueOf']() ) + if( left instanceof Number ) return Object.is( left.valueOf(), ( right as any )['valueOf']() ) + if( left instanceof String ) return Object.is( left.valueOf(), ( right as any )['valueOf']() ) + if( left instanceof Date ) return Object.is( left.valueOf(), ( right as any )['valueOf']() ) if( left instanceof RegExp ) return left.source === (right as any).source && left.flags === (right as any).flags if( left instanceof Error ) return left.message === (right as any).message && left.stack === (right as any).stack diff --git a/object2/object2.ts b/object2/object2.ts index 88629a15450..3cd8c4d5457 100644 --- a/object2/object2.ts +++ b/object2/object2.ts @@ -2,7 +2,7 @@ namespace $ { export class $mol_object2 { - static $ = $ as $ + static $ = $ as any as $ [Symbol.toStringTag]!: string @@ -31,7 +31,7 @@ namespace $ { } static toString() { - if( Symbol.toStringTag in this ) return this[ Symbol.toStringTag ] as string + if( Symbol.toStringTag in this ) return ( this as any )[ Symbol.toStringTag ] as string return this.name } diff --git a/range2/range2.test.ts b/range2/range2.test.ts index 7eb0506fae6..6d40adad9d9 100644 --- a/range2/range2.test.ts +++ b/range2/range2.test.ts @@ -11,13 +11,13 @@ namespace $ { $mol_assert_ok( list instanceof Array ) $mol_assert_equal( list.length , 10 ) - $mol_assert_equal( list[-1] , -1 ) + $mol_assert_equal( list[-1] , undefined ) $mol_assert_equal( list[0] , 0 ) $mol_assert_equal( list[9] , 9 ) $mol_assert_equal( list[9.5] , undefined ) - $mol_assert_equal( list[10] , 10 ) + $mol_assert_equal( list[10] , undefined ) - $mol_assert_equal( calls , 4 ) + $mol_assert_equal( calls , 2 ) } , @@ -32,9 +32,9 @@ namespace $ { $mol_assert_equal( list[0] , 0 ) $mol_assert_equal( list[4] , 4 ) $mol_assert_equal( list[Number.MAX_SAFE_INTEGER] , Number.MAX_SAFE_INTEGER ) - $mol_assert_equal( list[Number.POSITIVE_INFINITY] , Number.POSITIVE_INFINITY ) + $mol_assert_equal( list[Number.POSITIVE_INFINITY] , undefined ) - $mol_assert_equal( calls , 4 ) + $mol_assert_equal( calls , 3 ) } , @@ -100,10 +100,10 @@ namespace $ { $mol_assert_equal( list[9] , 4 ) $mol_assert_equal( list[10] , 0 ) $mol_assert_equal( list[14] , 4 ) - $mol_assert_equal( list[15] , 5 ) + $mol_assert_equal( list[15] , undefined ) $mol_assert_equal( calls1 , 2 ) - $mol_assert_equal( calls2 , 3 ) + $mol_assert_equal( calls2 , 2 ) } , @@ -118,7 +118,7 @@ namespace $ { $mol_assert_equal( list[0] , 1 ) $mol_assert_equal( list[2] , 5 ) - $mol_assert_equal( list[3] , 7 ) + $mol_assert_equal( list[3] , undefined ) $mol_assert_equal( calls , 10 ) // $mol_assert_equal( calls , 6 ) // TODO: lazy filter @@ -128,13 +128,14 @@ namespace $ { 'reverse'() { let calls = 0 - const list = $mol_range2( index => ( ++ calls , index ) , ()=> 10 ).reverse().slice(0, 3) + const list = $mol_range2( index => ( ++ calls , index ) , ()=> 10 ).toReversed().slice(0, 3) $mol_assert_ok( list instanceof Array ) $mol_assert_equal( list.length , 3 ) $mol_assert_equal( list[0] , 9 ) - $mol_assert_equal( list[3] , 6 ) + $mol_assert_equal( list[2] , 7 ) + $mol_assert_equal( list[3] , undefined ) $mol_assert_equal( calls , 2 ) } , @@ -170,10 +171,10 @@ namespace $ { $mol_assert_equal( target[0] , 10 ) $mol_assert_equal( target[4] , 14 ) - $mol_assert_equal( target[5] , 15 ) + $mol_assert_equal( target[5] , undefined ) - $mol_assert_equal( calls1 , 3 ) - $mol_assert_equal( calls2 , 3 ) + $mol_assert_equal( calls1 , 2 ) + $mol_assert_equal( calls2 , 2 ) } , @@ -188,9 +189,9 @@ namespace $ { $mol_assert_equal( list[0] , 3 ) $mol_assert_equal( list[3] , 6 ) - $mol_assert_equal( list[4] , 7 ) + $mol_assert_equal( list[4] , undefined ) - $mol_assert_equal( calls , 3 ) + $mol_assert_equal( calls , 2 ) } , @@ -231,9 +232,9 @@ namespace $ { $mol_assert_equal( list[0] , 12 ) $mol_assert_equal( list[3] , 15 ) - $mol_assert_equal( list[4] , Number.NaN ) + $mol_assert_equal( list[4] , undefined ) - $mol_assert_equal( calls , 3 ) + $mol_assert_equal( calls , 2 ) } , @@ -246,9 +247,12 @@ namespace $ { $mol_assert_fail( ()=> list.unshift( 4 ) , TypeError ) $mol_assert_fail( ()=> list.shift() , TypeError ) - + $mol_assert_fail( ()=> list.splice( 1 , 2 ) , TypeError ) $mol_assert_fail( ()=> list[ 1 ] = 2 , TypeError ) + + $mol_assert_fail( ()=> list.reverse() , TypeError ) + $mol_assert_fail( ()=> list.sort() , TypeError ) $mol_assert_equal( list.toString() , '0,1,2,3,4' ) diff --git a/range2/range2.ts b/range2/range2.ts index 0ec565e9e16..7c836b2beb4 100644 --- a/range2/range2.ts +++ b/range2/range2.ts @@ -15,6 +15,8 @@ namespace $ { if( field === 'length' ) return size() const index = Number( field ) + if( index < 0 ) return undefined + if( index >= size() ) return undefined if( index === Math.trunc( index ) ) return item( index ) } @@ -22,7 +24,7 @@ namespace $ { } , set( target , field ) { - return $mol_fail( new TypeError( `Lazy range is read only, ${String(field)}` ) ) + return $mol_fail( new TypeError( `Lazy range is read only (trying to set field ${ JSON.stringify( field ) })` ) ) } , ownKeys( target ) { @@ -53,8 +55,9 @@ namespace $ { } export class $mol_range2_array< Item > extends Array< Item > { - - concat( ... tail : this[] ) : Item[] { + + // Lazy + concat( ... tail : Item[][] ) : Item[] { if( tail.length === 0 ) return this as any if( tail.length > 1 ) { @@ -69,6 +72,7 @@ namespace $ { ) } + // Diligent filter< Context > ( check : ( val : Item , index : number , list : Item[] )=> boolean , context? : Context , @@ -81,6 +85,7 @@ namespace $ { return filtered } + // Diligent forEach< Context > ( proceed : ( this : Context , val : Item , index : number , list : Item[] )=> void , context? : Context, @@ -88,6 +93,7 @@ namespace $ { for( let [ key , value ] of this.entries() ) proceed.call( context as Context , value , key , this ) } + // Lazy map< Item_out , Context > ( proceed : ( this : Context , val : Item , index : number , list : Item[] )=> Item_out , context? : Context , @@ -98,6 +104,7 @@ namespace $ { ) } + // Diligent reduce< Result > ( merge : ( result : Result , val : Item , index : number , list : Item[] )=> Result , result? : Result , @@ -115,24 +122,23 @@ namespace $ { return result } - reverse(): Item[] { + // Lazy + toReversed(): Item[] { return $mol_range2( index => this[ this.length - 1 - index ] , ()=> this.length , ) } - slice( from = 0 , to = this.length ) : Item[] { + // Lazy + slice( from = 0 , to = this.length ) { return $mol_range2( index => this[ from + index ] , ()=> Math.min( to , this.length ) - from , ) } - at(index: number): Item | undefined { - return this[index >= 0 ? index : this.length + index] - } - + // Lazy some< Context > ( check : ( this : Context , val : Item , index : number , list : Item[] )=> boolean , context? : Context , @@ -143,6 +149,7 @@ namespace $ { return false } + // Lazy every< Context = null > ( check : ( this : Context , val : Item , index : number , list : Item[] )=> boolean , context? : Context , @@ -153,6 +160,14 @@ namespace $ { return true } + reverse() { + return $mol_fail( new TypeError( `Mutable reverse is forbidden. Use toReversed instead.` ) ) + } + + sort() { + return $mol_fail( new TypeError( `Mutable sort is forbidden. Use toSorted instead.` ) ) + } + } } diff --git a/range2/readme.md b/range2/readme.md index 0a4ac15db9b..63d8f88c20e 100644 --- a/range2/readme.md +++ b/range2/readme.md @@ -35,6 +35,7 @@ const array = [ ... range ] - concat - map - slice +- toReversed - some - every - entries diff --git a/text/code/code.view.css.ts b/text/code/code.view.css.ts index ed2df4aefc4..e65d1f93948 100644 --- a/text/code/code.view.css.ts +++ b/text/code/code.view.css.ts @@ -5,6 +5,9 @@ namespace $.$$ { $mol_style_define( $mol_text_code, { whiteSpace: 'pre-wrap', + font: { + family: 'monospace', + }, Rows: { padding: $mol_gap.text, diff --git a/wire/atom/atom.ts b/wire/atom/atom.ts index 0ad2d0e60b6..95e185fd24b 100644 --- a/wire/atom/atom.ts +++ b/wire/atom/atom.ts @@ -43,7 +43,7 @@ namespace $ { const field = task.name + '()' let dict = Object.getOwnPropertyDescriptor( host ?? task, field )?.value const prefix = (host as any)?.[ Symbol.toStringTag ] ?? ( host instanceof Function ? $$.$mol_func_name( host ) : host ) - const id = `${ prefix }.${ task.name }(${ $mol_key( key ) })` + const id = `${ prefix }.${ task.name }(${ $mol_key( key ).replace( /^"|"$/g, "'" ) })` if( dict ) { const existen = dict.get( id )