From 274b90a4efe8f90febaf2b5ea213d871699b10c9 Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Tue, 28 Nov 2023 02:24:40 +0300 Subject: [PATCH] $mol_view_tree2 misc fixes while build hyoo --- style/func/func.ts | 32 ++++++++++++------------- style/properties/properties.ts | 4 ++-- style/unit/unit.ts | 4 +++- text/text/text.view.tree | 1 + view/tree2/class/match.ts | 4 ++-- view/tree2/class/props.test.ts | 4 ++++ view/tree2/class/props.ts | 2 +- view/tree2/prop/parts.test.ts | 7 ++++++ view/tree2/prop/parts.ts | 2 +- view/tree2/to/dts/dts.ts | 2 -- view/tree2/to/js/test/js.simple.test.ts | 9 +++++++ 11 files changed, 46 insertions(+), 25 deletions(-) diff --git a/style/func/func.ts b/style/func/func.ts index f1ee5544104..54dcde118ab 100644 --- a/style/func/func.ts +++ b/style/func/func.ts @@ -70,9 +70,9 @@ namespace $ { } static clamp( - min: $mol_style_unit< any >, - mid: $mol_style_unit< any >, - max: $mol_style_unit< any >, + min: $mol_style_unit2, + mid: $mol_style_unit2, + max: $mol_style_unit2, ) { return new $mol_style_func( 'clamp', @@ -99,7 +99,7 @@ namespace $ { } static linear( - ...breakpoints : Array]> + ...breakpoints : Array]> ){ return new $mol_style_func( "linear", @@ -126,23 +126,23 @@ namespace $ { return new $mol_style_func( 'steps', [ value, step_position ] ) } - static blur(value?: $mol_style_unit<$mol_style_unit_length>){ + static blur(value?: $mol_style_unit2<$mol_style_unit_length>){ return new $mol_style_func( 'blur', value ?? "" ); } - static brightness(value?: number | $mol_style_unit<'%'>){ + static brightness(value?: number | $mol_style_unit2<'%'>){ return new $mol_style_func( 'brightness', value ?? "" ); } - static contrast(value?: number | $mol_style_unit<'%'>){ + static contrast(value?: number | $mol_style_unit2<'%'>){ return new $mol_style_func( 'contrast', value ?? "" ); } static drop_shadow( color: $mol_style_properties_color, - x_offset: $mol_style_unit<$mol_style_unit_length>, - y_offset: $mol_style_unit<$mol_style_unit_length>, - blur_radius?: $mol_style_unit<$mol_style_unit_length> + x_offset: $mol_style_unit2<$mol_style_unit_length>, + y_offset: $mol_style_unit2<$mol_style_unit_length>, + blur_radius?: $mol_style_unit2<$mol_style_unit_length> ) { return new $mol_style_func( "drop-shadow", @@ -152,27 +152,27 @@ namespace $ { ); } - static grayscale(value?: number | $mol_style_unit<'%'>){ + static grayscale(value?: number | $mol_style_unit2<'%'>){ return new $mol_style_func( 'grayscale', value ?? "" ); } - static hue_rotate(value?: 0 | $mol_style_unit<$mol_style_unit_angle>){ + static hue_rotate(value?: 0 | $mol_style_unit2<$mol_style_unit_angle>){ return new $mol_style_func( 'hue-rotate', value ?? "") } - static invert(value?: number | $mol_style_unit<'%'>){ + static invert(value?: number | $mol_style_unit2<'%'>){ return new $mol_style_func( 'invert', value ?? "" ); } - static opacity(value?: number | $mol_style_unit<'%'>){ + static opacity(value?: number | $mol_style_unit2<'%'>){ return new $mol_style_func( 'opacity', value ?? "" ); } - static sepia(value?: number | $mol_style_unit<'%'>){ + static sepia(value?: number | $mol_style_unit2<'%'>){ return new $mol_style_func( 'sepia', value ?? "" ); } - static saturate(value?: number | $mol_style_unit<'%'>){ + static saturate(value?: number | $mol_style_unit2<'%'>){ return new $mol_style_func( 'saturate', value ?? "" ); } diff --git a/style/properties/properties.ts b/style/properties/properties.ts index 9c690bb1cfa..4aa4e226081 100644 --- a/style/properties/properties.ts +++ b/style/properties/properties.ts @@ -163,7 +163,7 @@ namespace $ { * The animation can start later, immediately from its beginning, or immediately and partway through the animation. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/animation-delay */ - delay? : $mol_style_unit<$mol_style_unit_time> | $mol_style_unit<$mol_style_unit_time>[][] | Common + delay? : $mol_style_unit2<$mol_style_unit_time> | $mol_style_unit2<$mol_style_unit_time>[][] | Common /** * Sets whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward and backward. @@ -175,7 +175,7 @@ namespace $ { * Sets the length of time that an animation takes to complete one cycle. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/animation-duration */ - duration? : $mol_style_unit<$mol_style_unit_time> | $mol_style_unit<$mol_style_unit_time>[][] | Common + duration? : $mol_style_unit2<$mol_style_unit_time> | $mol_style_unit2<$mol_style_unit_time>[][] | Common /** * Sets how a CSS animation applies styles to its target before and after its execution. diff --git a/style/unit/unit.ts b/style/unit/unit.ts index fb9ae6f6cc0..124bb657281 100644 --- a/style/unit/unit.ts +++ b/style/unit/unit.ts @@ -11,7 +11,9 @@ namespace $ { export type $mol_style_unit_time = 's' | 'ms' export type $mol_style_unit_any = $mol_style_unit_length | $mol_style_unit_angle | $mol_style_unit_time - + + export type $mol_style_unit2< Quanity extends $mol_style_unit_any = $mol_style_unit_any> = `${number}${Quanity}` + /** * CSS Units * @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg diff --git a/text/text/text.view.tree b/text/text/text.view.tree index a0f0f368f90..fc8212147a4 100644 --- a/text/text/text.view.tree +++ b/text/text/text.view.tree @@ -3,6 +3,7 @@ $mol_text $mol_list text \ param \ flow_tokens / + block_text* \ auto / <= auto_scroll null - \Blocks diff --git a/view/tree2/class/match.ts b/view/tree2/class/match.ts index 79b8ac7c829..2308dd909ae 100644 --- a/view/tree2/class/match.ts +++ b/view/tree2/class/match.ts @@ -1,8 +1,8 @@ namespace $ { const class_regex = /^[$A-Z][$\w<>]+$/ - export function $mol_view_tree2_class_match(klass: $mol_tree2) { - if (! klass.type) return false + export function $mol_view_tree2_class_match(klass?: $mol_tree2) { + if (! klass?.type) return false if (klass.type === 'NaN' || klass.type === 'Infinity') return false return class_regex.test(klass.type) diff --git a/view/tree2/class/props.test.ts b/view/tree2/class/props.test.ts index 89273efd811..418d7fa3f42 100644 --- a/view/tree2/class/props.test.ts +++ b/view/tree2/class/props.test.ts @@ -3,6 +3,8 @@ namespace $.$$ { const src = ` ${d}my_test ${d}my_super title @ \\title + sub2 / + <= Сlose_icon ${d}mol_icon_cross sub / <= Title ${d}mol_view sub / @@ -32,6 +34,7 @@ namespace $.$$ { const dest = $$.$mol_tree2_from_string(` title @ \\title + sub2 / <= Сlose_icon sub / <= Title <= Close @@ -39,6 +42,7 @@ namespace $.$$ { Text => f g => h plugins / <= Speech + Сlose_icon ${d}mol_icon_cross Title ${d}mol_view sub / <= title close?event null Close ${d}mol_button diff --git a/view/tree2/class/props.ts b/view/tree2/class/props.ts index fa3fdd8d030..47cef231bd6 100644 --- a/view/tree2/class/props.ts +++ b/view/tree2/class/props.ts @@ -51,7 +51,7 @@ namespace $ { let right const operator = left.kids[0] - if (operator?.type === '=>') { + if (operator?.type === '=>' && context.factory) { right = operator.kids[0] if (! right) this.$mol_fail(err`Need a child ${operator.span}`) if (! context.factory) this.$mol_fail(err`Need a parent ${left.span}`) diff --git a/view/tree2/prop/parts.test.ts b/view/tree2/prop/parts.test.ts index 13606dba460..d4a5df5b7a6 100644 --- a/view/tree2/prop/parts.test.ts +++ b/view/tree2/prop/parts.test.ts @@ -16,6 +16,13 @@ namespace $ { }) }, + 'prop in upper case'($) { + const parts = get_parts('Close_icon') + $mol_assert_equal(parts.name, 'Close_icon') + $mol_assert_equal(parts.key, '') + $mol_assert_equal(parts.next, '') + }, + 'prop with index'($) { const parts = get_parts('some_bla*') $mol_assert_equal(parts.name, 'some_bla') diff --git a/view/tree2/prop/parts.ts b/view/tree2/prop/parts.ts index 7470cbca767..3d421fda640 100644 --- a/view/tree2/prop/parts.ts +++ b/view/tree2/prop/parts.ts @@ -4,7 +4,7 @@ namespace $ { if (! groups) { this.$mol_fail( - $mol_view_tree2_error_str`Required prop like some*? at ${prop.span}` + $mol_view_tree2_error_str`${prop.type ? `Cyrillic symbol in ${prop.type}? ` : ''}Required prop like some*? at ${prop.span}` ) } diff --git a/view/tree2/to/dts/dts.ts b/view/tree2/to/dts/dts.ts index efb4daf9824..ebce3f2c4d6 100644 --- a/view/tree2/to/dts/dts.ts +++ b/view/tree2/to/dts/dts.ts @@ -16,7 +16,6 @@ namespace $ { } function params_of( 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) ) { @@ -309,7 +308,6 @@ namespace $ { ) ) } - return [ input.data( input.type ), ] diff --git a/view/tree2/to/js/test/js.simple.test.ts b/view/tree2/to/js/test/js.simple.test.ts index ae390fb9968..27746a2be00 100644 --- a/view/tree2/to/js/test/js.simple.test.ts +++ b/view/tree2/to/js/test/js.simple.test.ts @@ -66,6 +66,15 @@ namespace $ { ) }, + 'simple throw if cyrillic name'( $ ) { + $mol_assert_fail(() => { + $mol_view_tree2_to_js_test_run(` + Foo $mol_object + sub / <= Сlose_icon $mol_object + `) + }) + }, + 'simple empty legacy indexed channel throws error'( $ ) { $mol_assert_fail(() => { $mol_view_tree2_to_js_test_run(`