@hap-toolkit/dsl-xvm 2.0.9 → 2.0.10-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/LICENSE +51 -51
  2. package/device-json-template/config-tv.json +14 -14
  3. package/package.json +5 -5
  4. package/readme.md +3 -3
  5. package/templates/app/demo/.eslintignore +6 -6
  6. package/templates/app/demo/.eslintrc.json +66 -66
  7. package/templates/app/demo/.gitignore +25 -25
  8. package/templates/app/demo/.prettierignore +6 -6
  9. package/templates/app/demo/README.md +11 -11
  10. package/templates/app/demo/_gitignore +16 -16
  11. package/templates/app/demo/package.json +54 -54
  12. package/templates/app/demo/scripts/gen/index.js +92 -92
  13. package/templates/app/demo/scripts/gen/template.ux +32 -32
  14. package/templates/app/demo/scripts/selfCloseInputTag.js +41 -41
  15. package/templates/app/demo/src/app.ux +22 -22
  16. package/templates/app/demo/src/assets/styles/mixins.scss +5 -5
  17. package/templates/app/demo/src/assets/styles/style.scss +2 -2
  18. package/templates/app/demo/src/assets/styles/variables.scss +11 -11
  19. package/templates/app/demo/src/global.js +38 -38
  20. package/templates/app/demo/src/helper/ajax.js +67 -67
  21. package/templates/app/demo/src/helper/apis/example.js +25 -25
  22. package/templates/app/demo/src/helper/apis/index.js +16 -16
  23. package/templates/app/demo/src/helper/utils.js +31 -31
  24. package/templates/app/demo/src/manifest.json +70 -70
  25. package/templates/app/demo/src/pages/Demo/index.ux +72 -72
  26. package/templates/app/demo/src/pages/DemoDetail/index.ux +63 -63
  27. package/templates/app/demo/src/sitemap.json +3 -3
  28. package/templates/app/demo/src/widgets/CardDemo/assets/styles.scss +16 -16
  29. package/templates/app/demo/src/widgets/CardDemo/index.ux +83 -83
@@ -1,92 +1,92 @@
1
- /*
2
- * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- /**
7
- * @desc: gen script command,make a new page generated by one click.
8
- * @author: nicejade
9
- */
10
-
11
- const fs = require('fs')
12
- const path = require('path')
13
- const colors = require('colors')
14
-
15
- const newFolderName = process.argv[2]
16
-
17
- String.prototype.firstUpperCase = function () {
18
- return this.replace(/\b(\w)/g, ($1) => {
19
- return $1.toLowerCase()
20
- })
21
- }
22
- const resolve = (dir) => {
23
- return path.join(__dirname, '../..', dir)
24
- }
25
-
26
- const successExecPrint = (msg) => {
27
- console.log(
28
- colors.green(`✓ `) +
29
- colors.cyan(`${msg} `) +
30
- colors.green('task has been successfully executed.')
31
- )
32
- }
33
-
34
- function createNewPage(newFolderPath) {
35
- const mReg = new RegExp('@PAGE_CLASS_NAME', 'g')
36
- const pageContent = fs.readFileSync(`${__dirname}/template.ux`, 'UTF-8')
37
- const rootClassName = newFolderName
38
- .firstUpperCase()
39
- .replace(/([A-Z])/g, '-$1')
40
- .toLowerCase()
41
- const newContent = pageContent.replace(mReg, rootClassName)
42
-
43
- fs.mkdirSync(newFolderPath, 0777)
44
- fs.writeFile(`${newFolderPath}/index.ux`, newContent, (error) => {
45
- if (error) throw `Something went wrong: ${error}`
46
- })
47
- successExecPrint('Create New Page')
48
- }
49
-
50
- function saveRouter2Manifest() {
51
- const manifestPath = resolve('/src/manifest.json')
52
- let manifestConf = fs.readFileSync(manifestPath, 'UTF-8')
53
- manifestConf = JSON.parse(manifestConf)
54
- const routerPages = manifestConf.router.pages
55
- routerPages[`pages/${newFolderName}`] = {
56
- component: 'index',
57
- }
58
- manifestConf = JSON.stringify(manifestConf, null, 2)
59
- fs.writeFile(manifestPath, manifestConf, (error) => {
60
- if (error) throw `Something went wrong[@saveRouter2Manifest]: ${error}`
61
- })
62
- successExecPrint('Save Router Into Manifest')
63
- }
64
-
65
- function main() {
66
- if (!newFolderName) {
67
- return console.warn(
68
- `⚠️ Please enter the name of the page you want to create.`.underline.red
69
- )
70
- }
71
-
72
- const folderNameReg = /^[A-Z][[A-Za-z0-9]+$/
73
- if (!folderNameReg.test(newFolderName)) {
74
- return console.warn(
75
- `⚠️ Please enter the standard Folder name. Eg: XyzAbcde.`.underline.red
76
- )
77
- }
78
-
79
- const newFolderPath = path.join(__dirname, `../../src/pages/${newFolderName}`)
80
- const isExist = fs.existsSync(newFolderPath)
81
-
82
- if (isExist) {
83
- return console.warn(
84
- `⚠️ ${newFolderName} already exists in the /src/pages/ directory.`
85
- .underline.red
86
- )
87
- }
88
- createNewPage(newFolderPath)
89
- saveRouter2Manifest()
90
- }
91
-
92
- main()
1
+ /*
2
+ * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * @desc: gen script command,make a new page generated by one click.
8
+ * @author: nicejade
9
+ */
10
+
11
+ const fs = require('fs')
12
+ const path = require('path')
13
+ const colors = require('colors')
14
+
15
+ const newFolderName = process.argv[2]
16
+
17
+ String.prototype.firstUpperCase = function () {
18
+ return this.replace(/\b(\w)/g, ($1) => {
19
+ return $1.toLowerCase()
20
+ })
21
+ }
22
+ const resolve = (dir) => {
23
+ return path.join(__dirname, '../..', dir)
24
+ }
25
+
26
+ const successExecPrint = (msg) => {
27
+ console.log(
28
+ colors.green(`✓ `) +
29
+ colors.cyan(`${msg} `) +
30
+ colors.green('task has been successfully executed.')
31
+ )
32
+ }
33
+
34
+ function createNewPage(newFolderPath) {
35
+ const mReg = new RegExp('@PAGE_CLASS_NAME', 'g')
36
+ const pageContent = fs.readFileSync(`${__dirname}/template.ux`, 'UTF-8')
37
+ const rootClassName = newFolderName
38
+ .firstUpperCase()
39
+ .replace(/([A-Z])/g, '-$1')
40
+ .toLowerCase()
41
+ const newContent = pageContent.replace(mReg, rootClassName)
42
+
43
+ fs.mkdirSync(newFolderPath, 0777)
44
+ fs.writeFile(`${newFolderPath}/index.ux`, newContent, (error) => {
45
+ if (error) throw `Something went wrong: ${error}`
46
+ })
47
+ successExecPrint('Create New Page')
48
+ }
49
+
50
+ function saveRouter2Manifest() {
51
+ const manifestPath = resolve('/src/manifest.json')
52
+ let manifestConf = fs.readFileSync(manifestPath, 'UTF-8')
53
+ manifestConf = JSON.parse(manifestConf)
54
+ const routerPages = manifestConf.router.pages
55
+ routerPages[`pages/${newFolderName}`] = {
56
+ component: 'index',
57
+ }
58
+ manifestConf = JSON.stringify(manifestConf, null, 2)
59
+ fs.writeFile(manifestPath, manifestConf, (error) => {
60
+ if (error) throw `Something went wrong[@saveRouter2Manifest]: ${error}`
61
+ })
62
+ successExecPrint('Save Router Into Manifest')
63
+ }
64
+
65
+ function main() {
66
+ if (!newFolderName) {
67
+ return console.warn(
68
+ `⚠️ Please enter the name of the page you want to create.`.underline.red
69
+ )
70
+ }
71
+
72
+ const folderNameReg = /^[A-Z][[A-Za-z0-9]+$/
73
+ if (!folderNameReg.test(newFolderName)) {
74
+ return console.warn(
75
+ `⚠️ Please enter the standard Folder name. Eg: XyzAbcde.`.underline.red
76
+ )
77
+ }
78
+
79
+ const newFolderPath = path.join(__dirname, `../../src/pages/${newFolderName}`)
80
+ const isExist = fs.existsSync(newFolderPath)
81
+
82
+ if (isExist) {
83
+ return console.warn(
84
+ `⚠️ ${newFolderName} already exists in the /src/pages/ directory.`
85
+ .underline.red
86
+ )
87
+ }
88
+ createNewPage(newFolderPath)
89
+ saveRouter2Manifest()
90
+ }
91
+
92
+ main()
@@ -1,32 +1,32 @@
1
- <!--
2
- Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
- SPDX-License-Identifier: Apache-2.0
4
- -->
5
-
6
- <template>
7
- <div class="wrapper">
8
- <text class="title">{{ title }}</text>
9
- </div>
10
- </template>
11
-
12
- <script>
13
- export default {
14
- private: {
15
- title: '欢迎体验快应用开发'
16
- },
17
-
18
- onInit() {}
19
- }
20
- </script>
21
-
22
- <style lang="scss">
23
- @import './../../assets/styles/style.scss';
24
- .wrapper {
25
- @include flex-box-mixins(column, center, center);
26
- .title {
27
- font-size: 18 * $size-factor;
28
- text-align: center;
29
- color: $black;
30
- }
31
- }
32
- </style>
1
+ <!--
2
+ Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
+ SPDX-License-Identifier: Apache-2.0
4
+ -->
5
+
6
+ <template>
7
+ <div class="wrapper">
8
+ <text class="title">{{ title }}</text>
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ export default {
14
+ private: {
15
+ title: '欢迎体验快应用开发'
16
+ },
17
+
18
+ onInit() {}
19
+ }
20
+ </script>
21
+
22
+ <style lang="scss">
23
+ @import './../../assets/styles/style.scss';
24
+ .wrapper {
25
+ @include flex-box-mixins(column, center, center);
26
+ .title {
27
+ font-size: 18 * $size-factor;
28
+ text-align: center;
29
+ color: $black;
30
+ }
31
+ }
32
+ </style>
@@ -1,41 +1,41 @@
1
- /*
2
- * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- /**
7
- * @file: selfCloseInputTag.js
8
- * @desc: 遍历指定目录下 .ux 文件,将其中 input 标签由 <input **></input> 转换为 <input ** />
9
- * @date: 2019-01-23
10
- */
11
-
12
- const fs = require('fs')
13
- const path = require('path')
14
-
15
- const quickappCodePath = './src/'
16
-
17
- const main = (codePath) => {
18
- const traversing = (cpath) => {
19
- const files = fs.readdirSync(cpath)
20
- files.forEach((fileName) => {
21
- const fPath = path.join(cpath, fileName)
22
- const stats = fs.statSync(fPath)
23
- stats.isDirectory() && traversing(fPath)
24
- stats.isFile() && fPath.endsWith('.ux') && matchAndReplace(fPath)
25
- })
26
- }
27
- traversing(codePath)
28
- }
29
-
30
- const matchAndReplace = (path) => {
31
- const pageContent = fs.readFileSync(path, 'UTF-8')
32
- const newContent = pageContent.replace(
33
- /(<)([\s]*?)(input\b[^\/]*?)>[\s\S]*?<\/input>/gm,
34
- '$1$3 />'
35
- )
36
- fs.writeFile(path, newContent, (error) => {
37
- if (error) throw `Something went wrong: ${error}`
38
- })
39
- }
40
-
41
- main(quickappCodePath)
1
+ /*
2
+ * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * @file: selfCloseInputTag.js
8
+ * @desc: 遍历指定目录下 .ux 文件,将其中 input 标签由 <input **></input> 转换为 <input ** />
9
+ * @date: 2019-01-23
10
+ */
11
+
12
+ const fs = require('fs')
13
+ const path = require('path')
14
+
15
+ const quickappCodePath = './src/'
16
+
17
+ const main = (codePath) => {
18
+ const traversing = (cpath) => {
19
+ const files = fs.readdirSync(cpath)
20
+ files.forEach((fileName) => {
21
+ const fPath = path.join(cpath, fileName)
22
+ const stats = fs.statSync(fPath)
23
+ stats.isDirectory() && traversing(fPath)
24
+ stats.isFile() && fPath.endsWith('.ux') && matchAndReplace(fPath)
25
+ })
26
+ }
27
+ traversing(codePath)
28
+ }
29
+
30
+ const matchAndReplace = (path) => {
31
+ const pageContent = fs.readFileSync(path, 'UTF-8')
32
+ const newContent = pageContent.replace(
33
+ /(<)([\s]*?)(input\b[^\/]*?)>[\s\S]*?<\/input>/gm,
34
+ '$1$3 />'
35
+ )
36
+ fs.writeFile(path, newContent, (error) => {
37
+ if (error) throw `Something went wrong: ${error}`
38
+ })
39
+ }
40
+
41
+ main(quickappCodePath)
@@ -1,22 +1,22 @@
1
- <!--
2
- Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
- SPDX-License-Identifier: Apache-2.0
4
- -->
5
-
6
- <script>
7
- /**
8
- * 应用级别的配置,供所有页面公用
9
- */
10
-
11
- const $utils = require('./helper/utils').default
12
- const $apis = require('./helper/apis').default
13
-
14
- /* @desc: 注入方法至全局 global,以便页面调用 */
15
- const hook2global = global.__proto__ || global
16
- hook2global.$utils = $utils
17
- hook2global.$apis = $apis
18
-
19
- export default {
20
- onCreate() {}
21
- }
22
- </script>
1
+ <!--
2
+ Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
+ SPDX-License-Identifier: Apache-2.0
4
+ -->
5
+
6
+ <script>
7
+ /**
8
+ * 应用级别的配置,供所有页面公用
9
+ */
10
+
11
+ const $utils = require('./helper/utils').default
12
+ const $apis = require('./helper/apis').default
13
+
14
+ /* @desc: 注入方法至全局 global,以便页面调用 */
15
+ const hook2global = global.__proto__ || global
16
+ hook2global.$utils = $utils
17
+ hook2global.$apis = $apis
18
+
19
+ export default {
20
+ onCreate() {}
21
+ }
22
+ </script>
@@ -1,5 +1,5 @@
1
- @mixin flex-box-mixins($direction: row, $justify: center, $align-items: center) {
2
- flex-direction: $direction;
3
- justify-content: $justify;
4
- align-items: $align-items;
5
- }
1
+ @mixin flex-box-mixins($direction: row, $justify: center, $align-items: center) {
2
+ flex-direction: $direction;
3
+ justify-content: $justify;
4
+ align-items: $align-items;
5
+ }
@@ -1,2 +1,2 @@
1
- @import './variables.scss';
2
- @import './mixins.scss';
1
+ @import './variables.scss';
2
+ @import './mixins.scss';
@@ -1,11 +1,11 @@
1
- $brand: #09ba07;
2
-
3
- $white: #ffffff;
4
- $black: #000000;
5
- $grey: #9393aa;
6
- $red: #fa0101;
7
- $yellow: #ffff00;
8
-
9
- // $size-factor 为 3px,对应的 designWidth 为 1080,长度使用:360的设计稿尺寸数字 * $size-factor
10
- // 如果 designWidth 设置为 360,可修改 $size-factor 为 1px
11
- $size-factor: 3px;
1
+ $brand: #09ba07;
2
+
3
+ $white: #ffffff;
4
+ $black: #000000;
5
+ $grey: #9393aa;
6
+ $red: #fa0101;
7
+ $yellow: #ffff00;
8
+
9
+ // $size-factor 为 3px,对应的 designWidth 为 1080,长度使用:360的设计稿尺寸数字 * $size-factor
10
+ // 如果 designWidth 设置为 360,可修改 $size-factor 为 1px
11
+ $size-factor: 3px;
@@ -1,38 +1,38 @@
1
- /*
2
- * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- /**
6
- * @file 全局能力的配置与获取
7
- * 文档地址:https://doc.quickapp.cn/tutorial/framework/optimization-skills.html#%E4%BD%BF%E7%94%A8-globaljs
8
- */
9
-
10
- function getGlobalRef() {
11
- return Object.getPrototypeOf(global) || global
12
- }
13
-
14
- const quickappGlobal = getGlobalRef()
15
-
16
- /**
17
- * 设置全局(被APP与Page共享)数据;
18
- * @param key {string}
19
- * @param val {*}
20
- */
21
- function setGlobalData(key, val) {
22
- quickappGlobal[key] = val
23
- }
24
-
25
- /**
26
- * 获取全局(被APP与Page共享)数据;
27
- * @param key {string}
28
- * @return {*}
29
- */
30
- function getGlobalData(key) {
31
- return quickappGlobal[key]
32
- }
33
-
34
- // 两个方法默认定义在全局
35
- setGlobalData('setGlobalData', setGlobalData)
36
- setGlobalData('getGlobalData', getGlobalData)
37
-
38
- export { setGlobalData, getGlobalData }
1
+ /*
2
+ * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /**
6
+ * @file 全局能力的配置与获取
7
+ * 文档地址:https://doc.quickapp.cn/tutorial/framework/optimization-skills.html#%E4%BD%BF%E7%94%A8-globaljs
8
+ */
9
+
10
+ function getGlobalRef() {
11
+ return Object.getPrototypeOf(global) || global
12
+ }
13
+
14
+ const quickappGlobal = getGlobalRef()
15
+
16
+ /**
17
+ * 设置全局(被APP与Page共享)数据;
18
+ * @param key {string}
19
+ * @param val {*}
20
+ */
21
+ function setGlobalData(key, val) {
22
+ quickappGlobal[key] = val
23
+ }
24
+
25
+ /**
26
+ * 获取全局(被APP与Page共享)数据;
27
+ * @param key {string}
28
+ * @return {*}
29
+ */
30
+ function getGlobalData(key) {
31
+ return quickappGlobal[key]
32
+ }
33
+
34
+ // 两个方法默认定义在全局
35
+ setGlobalData('setGlobalData', setGlobalData)
36
+ setGlobalData('getGlobalData', getGlobalData)
37
+
38
+ export { setGlobalData, getGlobalData }
@@ -1,67 +1,67 @@
1
- /*
2
- * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- import $fetch from '@system.fetch'
7
- import $utils from './utils'
8
-
9
- Promise.prototype.finally = function (callback) {
10
- const P = this.constructor
11
- return this.then(
12
- (value) => P.resolve(callback()).then(() => value),
13
- (reason) =>
14
- P.resolve(callback()).then(() => {
15
- throw reason
16
- })
17
- )
18
- }
19
-
20
- function requestHandle(params) {
21
- return new Promise((resolve, reject) => {
22
- $fetch
23
- .fetch({
24
- url: params.url,
25
- method: params.method,
26
- data: params.data,
27
- })
28
- .then((response) => {
29
- const result = response.data
30
- const content = JSON.parse(result.data)
31
- /* @desc: 可跟具体不同业务接口数据,返回你所需要的部分,使得使用尽可能便捷 */
32
- content.success ? resolve(content.value) : resolve(content.message)
33
- })
34
- .catch((error, code) => {
35
- console.log(`🐛 request fail, code = ${code}`)
36
- reject(error)
37
- })
38
- .finally(() => {
39
- console.log(`✔️ request @${params.url} has been completed.`)
40
- resolve()
41
- })
42
- })
43
- }
44
-
45
- export default {
46
- post: function (url, params) {
47
- return requestHandle({
48
- method: 'post',
49
- url: url,
50
- data: params,
51
- })
52
- },
53
- get: function (url, params) {
54
- return requestHandle({
55
- method: 'get',
56
- url: $utils.queryString(url, params),
57
- })
58
- },
59
- put: function (url, params) {
60
- return requestHandle({
61
- method: 'put',
62
- url: url,
63
- data: params,
64
- })
65
- },
66
- // 如果,method 您需要更多类型,可自行添加更多方法;
67
- }
1
+ /*
2
+ * Copyright (c) 2021-present, the hapjs-platform Project Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import $fetch from '@system.fetch'
7
+ import $utils from './utils'
8
+
9
+ Promise.prototype.finally = function (callback) {
10
+ const P = this.constructor
11
+ return this.then(
12
+ (value) => P.resolve(callback()).then(() => value),
13
+ (reason) =>
14
+ P.resolve(callback()).then(() => {
15
+ throw reason
16
+ })
17
+ )
18
+ }
19
+
20
+ function requestHandle(params) {
21
+ return new Promise((resolve, reject) => {
22
+ $fetch
23
+ .fetch({
24
+ url: params.url,
25
+ method: params.method,
26
+ data: params.data,
27
+ })
28
+ .then((response) => {
29
+ const result = response.data
30
+ const content = JSON.parse(result.data)
31
+ /* @desc: 可跟具体不同业务接口数据,返回你所需要的部分,使得使用尽可能便捷 */
32
+ content.success ? resolve(content.value) : resolve(content.message)
33
+ })
34
+ .catch((error, code) => {
35
+ console.log(`🐛 request fail, code = ${code}`)
36
+ reject(error)
37
+ })
38
+ .finally(() => {
39
+ console.log(`✔️ request @${params.url} has been completed.`)
40
+ resolve()
41
+ })
42
+ })
43
+ }
44
+
45
+ export default {
46
+ post: function (url, params) {
47
+ return requestHandle({
48
+ method: 'post',
49
+ url: url,
50
+ data: params,
51
+ })
52
+ },
53
+ get: function (url, params) {
54
+ return requestHandle({
55
+ method: 'get',
56
+ url: $utils.queryString(url, params),
57
+ })
58
+ },
59
+ put: function (url, params) {
60
+ return requestHandle({
61
+ method: 'put',
62
+ url: url,
63
+ data: params,
64
+ })
65
+ },
66
+ // 如果,method 您需要更多类型,可自行添加更多方法;
67
+ }