Skip to content

Commit

Permalink
$mol_build, switch to new $mol_view_tree2_to_js
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Oct 23, 2023
1 parent d3a18ed commit 77fa062
Show file tree
Hide file tree
Showing 59 changed files with 971 additions and 968 deletions.
29 changes: 28 additions & 1 deletion build/build.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ namespace $ {
return [ script ]

}

viewTreeTranspile( path : string ) {
if (this.$.$mol_env()?.['MOL_BUILD_TREE2']) return this.viewTreeTranspile2(path)

return this.viewTreeTranspile1(path)
}

@ $mol_mem_key
viewTreeTranspile( path : string ) {
viewTreeTranspile1( path : string ) {

const file = $mol_file.absolute( path )
const name = file.name()
Expand All @@ -98,6 +104,27 @@ namespace $ {
return [ script , locale ]
}

@ $mol_mem_key
viewTreeTranspile2( path : string ) {

const file = $mol_file.absolute( path )
const name = file.name()

const script = file.parent().resolve( `-view.tree/${ name }.js` )
const dts = file.parent().resolve( `-view.tree/${ name }.d.ts` )
const locale = file.parent().resolve( `-view.tree/${ name }.locale=en.json` )

const text = file.text()
const tree = this.$.$mol_tree2_from_string( text , name )
const res = this.$.$mol_view_tree2_to_full( tree )

script.text( res.js )
dts.text( res.dts )
locale.text( JSON.stringify( res.locales , null , '\t' ) )

return [ script , locale ]
}

@ $mol_mem_key
cssTranspile( path : string ) {

Expand Down
5 changes: 5 additions & 0 deletions view/tree2/prop/parts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace $ {
export function $mol_view_tree2_prop_signature_parts( prop: $mol_tree2 ) {
return [ ...prop.type.matchAll( $mol_view_tree2_prop_signature ) ][0].groups!
}
}
12 changes: 7 additions & 5 deletions view/tree2/to/dts/dts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace $ {

const prop_parts = $mol_view_tree2_prop_signature_parts

function name_of( prop: $mol_tree2 ) {
return [ ... prop.type.matchAll( $mol_view_tree2_prop_signature ) ][0].groups!.name
return prop_parts(prop).name
}

function params_of( prop: $mol_tree2, ... val: $mol_tree2[] ) {

const { key, next } = [ ... prop.type.matchAll( $mol_view_tree2_prop_signature ) ][0].groups!
const { key, next } = prop_parts(prop)

return prop.struct( 'line', [
prop.data('( '),
Expand All @@ -25,9 +27,9 @@ namespace $ {

}

export function $mol_view_tree2_to_dts(this: $, descr: $mol_tree2) {
export function $mol_view_tree2_to_dts(this: $, tree: $mol_tree2) {

descr = $mol_view_tree2_classes( descr )
const descr = $mol_view_tree2_classes( tree )

const types = [] as $mol_tree2[]

Expand All @@ -48,7 +50,7 @@ namespace $ {
] ),
... props.map( prop => {

const { name, key, next } = [ ... prop.type.matchAll( $mol_view_tree2_prop_signature ) ][0].groups!
const name = name_of(prop)
if (methods.has(name)) return undefined

methods.add(name)
Expand Down
14 changes: 14 additions & 0 deletions view/tree2/to/full/full.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace $ {
export function $mol_view_tree2_to_full(this: $, tree: $mol_tree2) {
const dts_text = this.$mol_view_tree2_to_dts(tree)
const dts_str = this.$mol_tree2_text_to_string_mapped_js(dts_text)

const js_tree = this.$mol_view_tree2_to_js(tree)
const js_text = this.$mol_tree2_js_to_text(js_tree)
const js_str = this.$mol_tree2_text_to_string_mapped_js(js_text)

const locales = this.$mol_view_tree2_to_locale(tree)

return { js: js_str, dts: dts_str, locales }
}
}
113 changes: 0 additions & 113 deletions view/tree2/to/js/js.array.test.ts

This file was deleted.

Loading

0 comments on commit 77fa062

Please sign in to comment.