add debug files
This commit is contained in:
parent
0fa35d3464
commit
8a1e55168e
@ -1,67 +1,40 @@
|
|||||||
import { ViewHolder, VMPanel, ViewModel, Gravity, Text, VLayout, Group } from "doric"
|
import { Panel, Group, vlayout, layoutConfig, Gravity, IVLayout, text, Text, Color } from "doric";
|
||||||
|
|
||||||
|
|
||||||
interface CountModel {
|
|
||||||
count: number
|
|
||||||
}
|
|
||||||
|
|
||||||
class CounterView extends ViewHolder {
|
|
||||||
number = new Text
|
|
||||||
counter = new Text
|
|
||||||
build(root: Group) {
|
|
||||||
const vlayout = new VLayout
|
|
||||||
vlayout.width = 200
|
|
||||||
vlayout.height = 200
|
|
||||||
vlayout.gravity = new Gravity().center()
|
|
||||||
this.number.textSize = 40
|
|
||||||
this.number.layoutConfig = {
|
|
||||||
alignment: new Gravity().center()
|
|
||||||
}
|
|
||||||
this.counter = new Text
|
|
||||||
this.counter.text = "Click to count"
|
|
||||||
this.counter.textSize = 20
|
|
||||||
vlayout.space = 20
|
|
||||||
vlayout.layoutConfig = {
|
|
||||||
alignment: new Gravity().center()
|
|
||||||
}
|
|
||||||
vlayout.addChild(this.number)
|
|
||||||
vlayout.addChild(this.counter)
|
|
||||||
root.addChild(vlayout)
|
|
||||||
}
|
|
||||||
|
|
||||||
setNumber(n: number) {
|
|
||||||
this.number.text = n.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
setCounter(v: Function) {
|
|
||||||
this.counter.onClick = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CounterVM extends ViewModel<CountModel, CounterView> {
|
|
||||||
|
|
||||||
binding(v: CounterView, model: CountModel): void {
|
|
||||||
v.setNumber(model.count)
|
|
||||||
v.setCounter(() => {
|
|
||||||
this.getModel().count++
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
class __$__ extends VMPanel<CountModel, CounterView>{
|
class __$__ extends Panel {
|
||||||
|
build(rootView: Group): void {
|
||||||
getVMClass() {
|
let number: Text
|
||||||
return CounterVM
|
let count = 0
|
||||||
|
vlayout([
|
||||||
|
number = text({
|
||||||
|
textSize: 40,
|
||||||
|
text: '0',
|
||||||
|
}),
|
||||||
|
text({
|
||||||
|
text: "Click to count",
|
||||||
|
textSize: 20,
|
||||||
|
bgColor: Color.parse('#70a1ff'),
|
||||||
|
textColor: Color.WHITE,
|
||||||
|
onClick: () => {
|
||||||
|
number.text = `${++count}`
|
||||||
|
},
|
||||||
|
layoutConfig: layoutConfig().exactly(),
|
||||||
|
width: 100,
|
||||||
|
height: 50,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
.apply({
|
||||||
|
layoutConfig: layoutConfig().exactly().a(Gravity.Center),
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
space: 20,
|
||||||
|
border: {
|
||||||
|
color: Color.BLUE,
|
||||||
|
width: 1,
|
||||||
|
},
|
||||||
|
gravity: Gravity.Center,
|
||||||
|
} as IVLayout)
|
||||||
|
.in(rootView)
|
||||||
}
|
}
|
||||||
|
|
||||||
getModel() {
|
|
||||||
return {
|
|
||||||
count: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getViewHolder() {
|
|
||||||
return new CounterView
|
|
||||||
}
|
|
||||||
}
|
}
|
24
doric-cli/contents/_launch.json
Normal file
24
doric-cli/contents/_launch.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug TS",
|
||||||
|
"program": "${workspaceFolder}/${relativeFile}",
|
||||||
|
"preLaunchTask": "Doric Build",
|
||||||
|
"sourceMaps": true,
|
||||||
|
"serverReadyAction": {
|
||||||
|
"pattern": "listening on port ([0-9]+)",
|
||||||
|
"uriFormat": "http://localhost:%s",
|
||||||
|
"action": "openExternally"
|
||||||
|
},
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/bundle/**/*.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"doric": "file:../js-framework",
|
"doric": "0.1.0",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rollup": "^1.17.0",
|
"rollup": "^1.17.0",
|
||||||
"rollup-plugin-commonjs": "^10.0.1",
|
"rollup-plugin-commonjs": "^10.0.1",
|
||||||
|
28
doric-cli/contents/_tasks.json
Normal file
28
doric-cli/contents/_tasks.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Doric Build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "doric build",
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Doric Clean",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "doric clean",
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Doric Dev",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "doric dev",
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
"lib": [], /* Specify library files to be included in the compilation. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "doric-cli",
|
"name": "doric-cli",
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"description": "Doric tools",
|
"description": "Doric command line tools",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"doric": "index.js"
|
"doric": "index.js"
|
||||||
@ -31,4 +31,4 @@
|
|||||||
"source-map-merger": "^0.2.0",
|
"source-map-merger": "^0.2.0",
|
||||||
"typescript": "^3.7.2"
|
"typescript": "^3.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,9 @@ module.exports = function (name) {
|
|||||||
fs.writeFileSync(`${name}/tsconfig.json`, fs.readFileSync(`${__dirname}/../contents/_tsconfig.json`))
|
fs.writeFileSync(`${name}/tsconfig.json`, fs.readFileSync(`${__dirname}/../contents/_tsconfig.json`))
|
||||||
fs.writeFileSync(`${name}/rollup.config.js`, fs.readFileSync(`${__dirname}/../contents/_rollup.config.js`))
|
fs.writeFileSync(`${name}/rollup.config.js`, fs.readFileSync(`${__dirname}/../contents/_rollup.config.js`))
|
||||||
fs.writeFileSync(`${name}/.gitignore`, fs.readFileSync(`${__dirname}/../contents/_gitignore`))
|
fs.writeFileSync(`${name}/.gitignore`, fs.readFileSync(`${__dirname}/../contents/_gitignore`))
|
||||||
|
fs.mkdirSync(`${name}/.vscode`)
|
||||||
|
fs.writeFileSync(`${name}/.vscode/launch.json`, fs.readFileSync(`${__dirname}/../contents/_launch.json`).toString().replace(/__\$__/g, name))
|
||||||
|
fs.writeFileSync(`${name}/.vscode/tasks.json`, fs.readFileSync(`${__dirname}/../contents/_tasks.json`).toString().replace(/__\$__/g, name))
|
||||||
fs.mkdirSync(`${name}/src`)
|
fs.mkdirSync(`${name}/src`)
|
||||||
fs.writeFileSync(`${name}/src/${name}.ts`, fs.readFileSync(`${__dirname}/../contents/$.ts`).toString().replace(/__\$__/g, name))
|
fs.writeFileSync(`${name}/src/${name}.ts`, fs.readFileSync(`${__dirname}/../contents/$.ts`).toString().replace(/__\$__/g, name))
|
||||||
fs.writeFileSync(`${name}/index.ts`, `export default ['src/${name}']`)
|
fs.writeFileSync(`${name}/index.ts`, `export default ['src/${name}']`)
|
||||||
|
Reference in New Issue
Block a user