Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
luckylionheart authored Dec 2, 2024
2 parents cb36af3 + 0698fe5 commit 40c8c57
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 46 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/deploy.yml → .github/workflows/mol.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy
name: $mol

on:
workflow_dispatch:
Expand Down Expand Up @@ -42,12 +42,12 @@ jobs:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
INPUTS_CLIENT_PAYLOAD: '{"repository":${{ toJson(github.event.repository.name) }}}'
INPUTS_EVENT_TYPE: dependency_changed
INPUTS_REPOSITORY: ${{ matrix.repo }}
uses: rekgrpth/github-repository-dispatch-shell-action@v1
- uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GH_PAT }}
repository: ${{ matrix.repo }}
event-type: dependency_changed
client-payload: '{"repository":${{ toJson(github.event.repository.name) }}}'
strategy:
matrix:
repo:
Expand Down
8 changes: 4 additions & 4 deletions build/build.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ namespace $ {

@ $mol_mem
gitVersion() {
return this.$.$mol_run({ command: 'git version', dir: '.' }).stdout.toString().trim().match(/.*\s+([\d\.]+)$/)?.[1] ?? ''
return this.$.$mol_run({ command: 'git version', dir: '.' }).stdout.toString().trim().match(/.*\s+([\d\.]+\d+)/)?.[1] ?? ''
}

gitDeepenSupported() {
Expand All @@ -641,13 +641,13 @@ namespace $ {
gitPull(path: string) {
const args = [] as string[]

if ( ! this.interactive() ) {
if ( ! this.interactive() && this.gitDeepenSupported() ) {
// depth и deepen не годятся для локальной разработки, поэтому оставляем ограничение глубины пула только для CI
// --depth=1 в сочетании с сабмодулями обрезает историю, кроме первого коммита
// --deepen=1 в git-конфиге сабмодуля выставляет bare=true, после этого все команды падают с сообщением
// --deepen=1, если не сделать unset GIT_DIR, в git-конфиге сабмодуля выставляет bare=true, после этого все команды падают с сообщением
// warning: core.bare and core.worktree do not make sense
// fatal: unable to set up work tree using invalid config
args.push( this.gitDeepenSupported() ? '--deepen=1' : '--depth=1' )
args.push( '--deepen=1' )
}
return this.run_safe( { command: ['git', 'pull', ...args], dir: path } )
}
Expand Down
9 changes: 6 additions & 3 deletions format/format.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ namespace $.$$ {
const mask = this.mask( filtered )

if( ( prev?.[0] ?? 0 ) >= from ) return [ from, to ]

const lastAllow = ( value.length - [ ... value ].reverse().findIndex( letter => allow.includes( letter ) ) )%(value.length+1)

const lastAllow = (
value.length - [ ... value ].reverse().findIndex( letter => allow.includes( letter ) )
) % ( value.length + 1 )

if( lastAllow < from ) {
from = to = lastAllow
}
Expand All @@ -29,7 +32,7 @@ namespace $.$$ {
++ from
++ to
}

return [ from, to ]
}

Expand Down
1 change: 0 additions & 1 deletion index.html

This file was deleted.

78 changes: 62 additions & 16 deletions number/number.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ namespace $.$$ {
*/
export class $mol_number extends $.$mol_number {

value_limited( next? : any ) : number {
if ( next === undefined ) return this.value()
if ( next === '' ) return this.value( Number.NaN )
value_limited( val? : number ) : number {
if (Number.isNaN( val )) return this.value( val )
if ( val === undefined ) return this.value()

const min = this.value_min()
const max = this.value_max()

const val = Number( next )

if( val < min ) return this.value( min )
if( val > max ) return this.value( max )

Expand All @@ -28,23 +26,71 @@ namespace $.$$ {
override event_inc( next? : Event ) {
this.value_limited( ( this.value_limited() || 0 ) + this.precision_change() )
}

override value_string( next? : string ) {
const next_num = this.value_limited( next )

const precisionView = this.precision_view()
round(val: number) {
if (Number.isNaN(val)) return ''
if( val === 0 ) return '0'
if( !val ) return ''

const precision_view = this.precision_view()

if( next_num === 0 ) return '0'
if( !next_num ) return ''
if (! precision_view) return val.toFixed()

if( precisionView >= 1 ) {
return ( next_num / precisionView ).toFixed()
if( precision_view >= 1 ) {
return ( val / precision_view ).toFixed()
} else {
const fixedNumber = Math.log10( 1 / precisionView )
return next_num.toFixed( Math.ceil( fixedNumber ) )
const fixed_number = Math.log10( 1 / precision_view )
return val.toFixed( Math.ceil( fixed_number ) )
}
}


@ $mol_mem
override value_string( next? : string ): string {
// Вытягиваем value
// Если кто-то поменяет из вне value, value_string надо обновить
const current = this.round( this.value_limited() )
if (next === undefined) return current

const precision = this.precision_view()

// Точку в конце поставить нельзя, если precision_view целое число > 0
if ( precision - Math.floor(precision) === 0 ) next = next.replace(/[.,]/g, '')

// Запятые меняем на точки, удаляем не-цифры и не-точки и лишние ноли в начале целой части.
// Минус получится ввести только в начале.
next = (this.value_min() < 0 && next.startsWith('-') ? '-' : '')
+ next.replace(/,/g, '.').replace(/[^\d\.]/g, '').replace(/^0{2,}/, '0')

let dot_pos = next.indexOf('.')

if (dot_pos !== -1) {
const prev = $mol_wire_probe(() => this.value_string()) ?? ''
const dot_pos_prev = prev.indexOf('.')
// Определяем где относительно предыдущей точки юзер поставил новую
if (dot_pos_prev === dot_pos) dot_pos = next.lastIndexOf('.')

// Из частей до и после новой точки старую точку удаляем
const frac = next.slice(dot_pos + 1).replace(/\./g, '')

// Если точка идет первой, перед ней пишем 0, что бы форматирование выглядело нормально в mask
next = (next.slice(0, dot_pos) || '0').replace(/\./g, '') + '.' + frac
}

// Оставляем старое значение в value есть сочетание, приводящие к NaN, например -.
if ( Number.isNaN(Number(next)) ) return next

if ( next.endsWith('.') ) return next
if ( next.endsWith('-') ) return next

// Если пустая строка - сетим NaN
// Применяем округления.
this.value_limited(Number(next || Number.NaN))

// Возвращаем все-равно не нормализованное значение
// Иначе нельзя ввести будет 10, если min/max 5..10
return next
}

@ $mol_mem
override dec_enabled() : boolean {
return this.enabled() && (
Expand Down
2 changes: 1 addition & 1 deletion page/page.view.tree
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$mol_page $mol_view
dom_name \article
field *
attr *
^
tabIndex <= tabindex -1
sub /
Expand Down
2 changes: 1 addition & 1 deletion portion/portion.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ $mol_portion_indicator $mol_view
$mol_portion $mol_view
portion 0
sub /
<= indicator $mol_portion_indicator
<= Indicator $mol_portion_indicator
width_style <= indicator_width_style \0
20 changes: 20 additions & 0 deletions state/arg/arg.node.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace $ {

$mol_test_mocks.push( context => {
class $mol_state_arg_mock extends $mol_state_arg {

static $ = context

@ $mol_mem
static href( next? : string ) { return next || '' }

@ $mol_action
static go( next : { [ key : string ] : string | null } ) {
this.href( this.link( next ) )
}

}
context.$mol_state_arg = $mol_state_arg_mock
} )

}
7 changes: 6 additions & 1 deletion state/arg/arg.web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ namespace $ {
@ $mol_mem
static href( next? : string ) { return next || '' }

@ $mol_action
static go( next : { [ key : string ] : string | null } ) {
this.href( this.link( next ) )
}

}
context.$mol_state_arg = $mol_state_arg_mock
} )
Expand All @@ -17,7 +22,7 @@ namespace $ {
'args as dictionary'( $ ) {

$.$mol_state_arg.href( '#!foo=bar/xxx' )
$mol_assert_like( $.$mol_state_arg.dict() , { foo : 'bar' , xxx : '' } )
$mol_assert_equal( $.$mol_state_arg.dict() , { foo : 'bar' , xxx : '' } )

$.$mol_state_arg.dict({ foo : null , yyy : '' , lol : '123' })
$mol_assert_equal( $.$mol_state_arg.href().replace( /.*#/ , '#' ) , '#!yyy/lol=123' )
Expand Down
6 changes: 3 additions & 3 deletions syntax2/md/md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ namespace $ {
'code-docs' : /\/\/\/.*?$/ ,
'code-comment-block' : /(?:\/\*[^]*?\*\/|\/\+[^]*?\+\/|<![^]*?>)/ ,
'code-link' : /(?:\w+:\/\/|#)\S+?(?=\s|\\\\|""|$)/ ,
'code-comment-inline' : /\/\/.*?(?:$|\/\/)/ ,
'code-string' : /(?:".*?"|'.*?'|`.*?`|\/.+?\/[dygimsu]*(?!\p{Letter})|(?:^|[ \t])\\[^\n]*\n)/u ,
'code-comment-inline' : /\/\/.*?(?:$|\/\/)|- \\.*/ ,
'code-string' : /(?:".*?"|'.*?'|`.*?`| ?\\\\.+?\\\\|\/.+?\/[dygimsu]*(?!\p{Letter})|[ \t]*\\[^\n]*)/u ,
'code-number' : /[+-]?(?:\d*\.)?\d+\w*/ ,
'code-call' : /\.?\w+ *(?=\()/ ,
'code-sexpr' : /\((\w+ )/ ,
'code-field' : /(?:(?:\.|::|->)\w+|[\w-]+\??\s*:(?!\/\/|:))/ ,
'code-keyword' : /\b(throw|readonly|unknown|keyof|typeof|never|from|class|struct|interface|type|function|extends|implements|module|namespace|import|export|include|require|var|val|let|const|for|do|while|until|in|out|of|new|if|then|else|switch|case|this|return|async|await|yield|try|catch|break|continue|get|set|public|private|protected|string|boolean|number|null|undefined|true|false|void|int|float|ref)\b/ ,
'code-global' : /[$]+\w*|\b[A-Z][a-z0-9]+[A-Z]\w*/ ,
'code-word' : /\w+/ ,
'code-decorator' : /@\s*\S+/ ,
'code-decorator' : /@.+/ ,
'code-tag' : /<\/?[\w-]+\/?>?|&\w+;/ ,
'code-punctuation' : /[\-\[\]\{\}\(\)<=>~!\?@#%&\*_\+\\\/\|;:\.,\^]+?/ ,
})
Expand Down
4 changes: 2 additions & 2 deletions view/view/view.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace $ {

export type $mol_view_content = $mol_view|Node|string|number|boolean
export type $mol_view_content = $mol_view|Node|string|number|boolean|null

export function $mol_view_visible_width() {
return $mol_window.size().width
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace $ {

/// Raw child views
sub() {
return [] as readonly ($mol_view|Node|string|number|boolean)[]
return [] as readonly $mol_view_content[]
}

/// Visible sub views with defined ambient context
Expand Down
8 changes: 8 additions & 0 deletions wait/rest/rest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace $.$$ {

$mol_test_mocks.push( $ => {
$.$mol_wait_timeout = function $mol_wait_timeout_mock( this: $, timeout: number ) { }
$.$mol_wait_timeout_async = async function $mol_wait_timeout_async_mock( this: $, timeout: number ) {}
} )

}
8 changes: 8 additions & 0 deletions wait/timeout/timeout.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace $.$$ {

$mol_test_mocks.push( $ => {
$.$mol_wait_rest = function $mol_wait_rest_mock( this: $ ) { }
$.$mol_wait_rest_async = async function $mol_wait_rest_async_mock( this: $ ) {}
} )

}
2 changes: 1 addition & 1 deletion wait/timeout/timeout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace $ {

export function $mol_wait_timeout_async( this: $, timeout: number ) {
export function $mol_wait_timeout_async( this: $, timeout: number ): Promise< void > {
const promise = $mol_promise()
const task = new this.$mol_after_timeout( timeout , ()=> promise.done() )
return Object.assign( promise, {
Expand Down
12 changes: 6 additions & 6 deletions wire/async/async.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace $ {

static send( next: string ) {
$mol_wire_sync( this.first ).push( next )
this.$.$mol_wait_timeout(0)
$$.$mol_wait_timeout(0)
this.last.push( next )
}

Expand All @@ -39,8 +39,8 @@ namespace $ {
$.$mol_after_mock_warp()
await promise

$mol_assert_like( NameLogger.first, [ 'john', 'jin' ] )
$mol_assert_like( NameLogger.last, [ 'jin' ] )
$mol_assert_equal( NameLogger.first, [ 'john', 'jin' ] )
$mol_assert_equal( NameLogger.last, [ 'jin' ] )

},

Expand All @@ -51,7 +51,7 @@ namespace $ {

function send_name( next: string ) {
$mol_wire_sync( first ).push( next )
$.$mol_wait_timeout(0)
$$.$mol_wait_timeout(0)
last.push( next )
}

Expand All @@ -63,8 +63,8 @@ namespace $ {
$.$mol_after_mock_warp()
await promise

$mol_assert_like( first, [ 'john', 'jin' ] )
$mol_assert_like( last, [ 'jin' ] )
$mol_assert_equal( first, [ 'john', 'jin' ] )
$mol_assert_equal( last, [ 'jin' ] )

},

Expand Down

0 comments on commit 40c8c57

Please sign in to comment.