@cloudbase/framework-plugin-low-code 0.6.31 → 0.6.34
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.
- package/lib/builder/config/index.js +2 -5
- package/lib/builder/core/copy.d.ts.map +1 -1
- package/lib/builder/mp/materials.d.ts.map +1 -1
- package/lib/builder/mp/materials.js +21 -5
- package/lib/generator/template.d.ts +1 -101
- package/lib/generator/template.d.ts.map +1 -1
- package/lib/generator/template.js +1 -101
- package/package.json +5 -3
- package/template/webpack/web.prod.js +66 -85
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/cookie.js +0 -286
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/history.js +0 -133
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/local-storage.js +0 -103
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/location.js +0 -588
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/miniprogram.js +0 -101
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/navigator.js +0 -80
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/performance.js +0 -28
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/screen.js +0 -31
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/session-storage.js +0 -96
- package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/xml-http-request.js +0 -290
- package/template/dist/mp/miniprogram_npm/miniprogram-render/document.js +0 -396
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/custom-event.js +0 -12
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event-target.js +0 -389
- package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event.js +0 -186
- package/template/dist/mp/miniprogram_npm/miniprogram-render/index.js +0 -41
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/attribute.js +0 -226
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/class-list.js +0 -153
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/comment.js +0 -80
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/a.js +0 -165
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/canvas.js +0 -138
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/image.js +0 -177
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/input.js +0 -181
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/not-support.js +0 -60
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/option.js +0 -126
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/select.js +0 -155
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/textarea.js +0 -178
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/video.js +0 -165
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-component.js +0 -84
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-custom-component.js +0 -64
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element.js +0 -970
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/node.js +0 -140
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style-list.js +0 -28
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style.js +0 -158
- package/template/dist/mp/miniprogram_npm/miniprogram-render/node/text-node.js +0 -127
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/parser.js +0 -269
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/query-selector.js +0 -420
- package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/tree.js +0 -130
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/cache.js +0 -95
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/pool.js +0 -24
- package/template/dist/mp/miniprogram_npm/miniprogram-render/util/tool.js +0 -131
- package/template/dist/mp/miniprogram_npm/miniprogram-render/window.js +0 -651
- package/template/generator/app/common.js +0 -17
- package/template/generator/app/global-api.js +0 -163
- package/template/generator/app/handlers.js +0 -13
- package/template/generator/datasources/config.js.tpl +0 -21
- package/template/generator/datasources/dataset-profiles.js.tpl +0 -5
- package/template/generator/datasources/datasource-profiles.js.tpl +0 -4
- package/template/generator/datasources/index.js.tpl +0 -14
- package/template/generator/handlers/NodeRenderer.jsx +0 -471
- package/template/generator/handlers/RenderWrapper.jsx +0 -145
- package/template/generator/index.jsx +0 -116
- package/template/generator/index.less +0 -120
- package/template/generator/pages/app.tpl +0 -181
- package/template/generator/pages/composite.tpl +0 -267
- package/template/generator/router/index.tpl +0 -49
- package/template/generator/store/computed.js +0 -11
- package/template/generator/store/index.js +0 -5
- package/template/generator/utils/ScanCodeComponent.js +0 -345
- package/template/generator/utils/actionHandler.js +0 -119
- package/template/generator/utils/common.js +0 -225
- package/template/generator/utils/computed.js +0 -9
- package/template/generator/utils/date.js +0 -324
- package/template/generator/utils/error.jsx +0 -14
- package/template/generator/utils/eventProxy.js +0 -64
- package/template/generator/utils/history.js +0 -35
- package/template/generator/utils/hooks.js +0 -10
- package/template/generator/utils/index.js +0 -41
- package/template/generator/utils/initGlobalVar.js +0 -14
- package/template/generator/utils/lifecycle.js +0 -158
- package/template/generator/utils/monitor-jssdk.min.js +0 -881
- package/template/generator/utils/page.js +0 -10
- package/template/generator/utils/scan-code-action.js +0 -27
- package/template/generator/utils/style.js +0 -81
- package/template/generator/utils/widgets.js +0 -343
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
const QuerySelector = require('./query-selector')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 遍历 dom 树,收集类和标签对应的节点列表
|
|
5
|
-
*/
|
|
6
|
-
function walkDomTree(node, cache) {
|
|
7
|
-
const tagMap = cache.tagMap = cache.tagMap || {}
|
|
8
|
-
const classMap = cache.classMap = cache.classMap || {}
|
|
9
|
-
const {tagName, classList} = node
|
|
10
|
-
|
|
11
|
-
// 标签
|
|
12
|
-
tagMap[tagName] = tagMap[tagName] || []
|
|
13
|
-
tagMap[tagName].push(node)
|
|
14
|
-
|
|
15
|
-
// 类
|
|
16
|
-
for (const className of classList) {
|
|
17
|
-
classMap[className] = classMap[className] || []
|
|
18
|
-
classMap[className].push(node)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const children = node.children || []
|
|
22
|
-
|
|
23
|
-
for (const child of children) {
|
|
24
|
-
// 递归遍历
|
|
25
|
-
walkDomTree(child, cache)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
class Tree {
|
|
30
|
-
constructor(pageId, root, nodeIdMap, document) {
|
|
31
|
-
this.pageId = pageId
|
|
32
|
-
this.root = document.$$createElement(root, this)
|
|
33
|
-
this.nodeIdMap = nodeIdMap
|
|
34
|
-
this.idMap = {}
|
|
35
|
-
this.document = document
|
|
36
|
-
|
|
37
|
-
this.querySelector = new QuerySelector()
|
|
38
|
-
if (nodeIdMap) nodeIdMap[root.nodeId] = this.root
|
|
39
|
-
|
|
40
|
-
this.walk(root, this.root)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 遍历 ast
|
|
45
|
-
*/
|
|
46
|
-
walk(ast, parentNode) {
|
|
47
|
-
const children = ast.children
|
|
48
|
-
const idMap = this.idMap
|
|
49
|
-
const nodeIdMap = this.nodeIdMap
|
|
50
|
-
const document = this.document
|
|
51
|
-
|
|
52
|
-
if (!children || !children.length) return
|
|
53
|
-
|
|
54
|
-
// 遍历子节点
|
|
55
|
-
for (const child of children) {
|
|
56
|
-
let childNode
|
|
57
|
-
|
|
58
|
-
if (child.type === 'element') {
|
|
59
|
-
childNode = document.$$createElement(child, this)
|
|
60
|
-
} else if (child.type === 'text') {
|
|
61
|
-
childNode = document.$$createTextNode(child, this)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 处理 id 缓存
|
|
65
|
-
const id = childNode.id
|
|
66
|
-
if (id && !idMap[id]) {
|
|
67
|
-
idMap[id] = childNode
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 处理 nodeId 缓存
|
|
71
|
-
if (nodeIdMap) nodeIdMap[child.nodeId] = childNode
|
|
72
|
-
|
|
73
|
-
// 插入子节点
|
|
74
|
-
parentNode.appendChild(childNode)
|
|
75
|
-
|
|
76
|
-
// 遍历子节点的 ast
|
|
77
|
-
this.walk(child, childNode)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 更新 idMap
|
|
83
|
-
*/
|
|
84
|
-
updateIdMap(id, node) {
|
|
85
|
-
this.idMap[id] = node
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 根据 id 获取节点
|
|
90
|
-
*/
|
|
91
|
-
getById(id) {
|
|
92
|
-
return this.idMap[id]
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 根据标签名获取节点列表
|
|
97
|
-
*/
|
|
98
|
-
getByTagName(tagName, node) {
|
|
99
|
-
const cache = {}
|
|
100
|
-
walkDomTree(node || this.root, cache)
|
|
101
|
-
|
|
102
|
-
return cache.tagMap[tagName.toUpperCase()] || []
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 根据类名获取节点列表
|
|
107
|
-
*/
|
|
108
|
-
getByClassName(className, node) {
|
|
109
|
-
const cache = {}
|
|
110
|
-
walkDomTree(node || this.root, cache)
|
|
111
|
-
|
|
112
|
-
return cache.classMap[className] || []
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 查询符合条件的节点
|
|
117
|
-
*/
|
|
118
|
-
query(selector, node) {
|
|
119
|
-
const cache = {}
|
|
120
|
-
walkDomTree(node || this.root, cache)
|
|
121
|
-
|
|
122
|
-
return this.querySelector.exec(selector, {
|
|
123
|
-
idMap: this.idMap,
|
|
124
|
-
tagMap: cache.tagMap,
|
|
125
|
-
classMap: cache.classMap,
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
module.exports = Tree
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const pageMap = {}
|
|
2
|
-
let configCache = {}
|
|
3
|
-
const cookieCache = {}
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 初始化
|
|
7
|
-
*/
|
|
8
|
-
function init(pageId, options) {
|
|
9
|
-
pageMap[pageId] = {
|
|
10
|
-
window: options.window,
|
|
11
|
-
document: options.document,
|
|
12
|
-
nodeIdMap: options.nodeIdMap,
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 销毁
|
|
18
|
-
*/
|
|
19
|
-
function destroy(pageId) {
|
|
20
|
-
delete pageMap[pageId]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 获取 document
|
|
25
|
-
*/
|
|
26
|
-
function getDocument(pageId) {
|
|
27
|
-
return pageMap[pageId] && pageMap[pageId].document
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 获取 window
|
|
32
|
-
*/
|
|
33
|
-
function getWindow(pageId) {
|
|
34
|
-
return pageMap[pageId] && pageMap[pageId].window
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 存储 domNode 映射
|
|
39
|
-
*/
|
|
40
|
-
function setNode(pageId, nodeId, domNode = null) {
|
|
41
|
-
const document = pageMap[pageId] && pageMap[pageId].document
|
|
42
|
-
|
|
43
|
-
// 运行前调用,不做任何操作
|
|
44
|
-
if (!document) return
|
|
45
|
-
// 相当于删除映射
|
|
46
|
-
if (!domNode) return pageMap[pageId].nodeIdMap[nodeId] = domNode
|
|
47
|
-
|
|
48
|
-
let parentNode = domNode.parentNode
|
|
49
|
-
|
|
50
|
-
while (parentNode && parentNode !== document.body) {
|
|
51
|
-
parentNode = parentNode.parentNode
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
pageMap[pageId].nodeIdMap[nodeId] = parentNode === document.body ? domNode : null
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 根据 nodeId 获取 domNode
|
|
59
|
-
*/
|
|
60
|
-
function getNode(pageId, nodeId) {
|
|
61
|
-
return pageMap[pageId] && pageMap[pageId].nodeIdMap[nodeId]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 存储全局 config
|
|
66
|
-
*/
|
|
67
|
-
function setConfig(config) {
|
|
68
|
-
configCache = config
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 获取全局 config
|
|
73
|
-
*/
|
|
74
|
-
function getConfig() {
|
|
75
|
-
return configCache
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 获取全局 cookie
|
|
80
|
-
*/
|
|
81
|
-
function getCookie() {
|
|
82
|
-
return cookieCache
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
module.exports = {
|
|
86
|
-
init,
|
|
87
|
-
destroy,
|
|
88
|
-
getDocument,
|
|
89
|
-
getWindow,
|
|
90
|
-
setNode,
|
|
91
|
-
getNode,
|
|
92
|
-
setConfig,
|
|
93
|
-
getConfig,
|
|
94
|
-
getCookie,
|
|
95
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
class Pool {
|
|
2
|
-
constructor(size) {
|
|
3
|
-
this.$_size = size || 3000
|
|
4
|
-
this.$_cache = []
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 添加一个对象
|
|
9
|
-
*/
|
|
10
|
-
add(object) {
|
|
11
|
-
if (this.$_cache.length >= this.$_size) return
|
|
12
|
-
|
|
13
|
-
this.$_cache.push(object)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 取出一个对象
|
|
18
|
-
*/
|
|
19
|
-
get() {
|
|
20
|
-
return this.$_cache.pop()
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = Pool
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const cache = require('./cache')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 驼峰转连字符
|
|
5
|
-
*/
|
|
6
|
-
function toDash(str) {
|
|
7
|
-
return str.replace(/[A-Z]/g, all => `-${all.toLowerCase()}`)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 连字符转驼峰
|
|
12
|
-
*/
|
|
13
|
-
function toCamel(str) {
|
|
14
|
-
return str.replace(/-([a-zA-Z])/g, (all, $1) => $1.toUpperCase())
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 获取唯一 id
|
|
19
|
-
*/
|
|
20
|
-
let seed = +new Date()
|
|
21
|
-
function getId() {
|
|
22
|
-
return seed++
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 从 pageId 中获取小程序页面 route
|
|
27
|
-
*/
|
|
28
|
-
function getPageRoute(pageId) {
|
|
29
|
-
return pageId.split('-')[2]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 从 pageRoute 中获取小程序页面名称
|
|
34
|
-
*/
|
|
35
|
-
function getPageName(pageRoute) {
|
|
36
|
-
const splitPageRoute = pageRoute.split('/')
|
|
37
|
-
return splitPageRoute[1] === 'pages' ? splitPageRoute[2] : splitPageRoute[1]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 节流,一个同步流中只调用一次该函数
|
|
42
|
-
*/
|
|
43
|
-
const waitFuncSet = new Set()
|
|
44
|
-
function throttle(func) {
|
|
45
|
-
return () => {
|
|
46
|
-
if (waitFuncSet.has(func)) return
|
|
47
|
-
|
|
48
|
-
waitFuncSet.add(func)
|
|
49
|
-
|
|
50
|
-
Promise.resolve().then(() => {
|
|
51
|
-
if (waitFuncSet.has(func)) {
|
|
52
|
-
waitFuncSet.delete(func)
|
|
53
|
-
func()
|
|
54
|
-
}
|
|
55
|
-
}).catch(() => {
|
|
56
|
-
// ignore
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 清空节流缓存
|
|
63
|
-
*/
|
|
64
|
-
function flushThrottleCache() {
|
|
65
|
-
waitFuncSet.forEach(waitFunc => waitFunc && waitFunc())
|
|
66
|
-
waitFuncSet.clear()
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 补全 url
|
|
71
|
-
*/
|
|
72
|
-
function completeURL(url, defaultOrigin, notTransHttps) {
|
|
73
|
-
const config = cache.getConfig()
|
|
74
|
-
|
|
75
|
-
// 处理 url 前缀
|
|
76
|
-
if (url.indexOf('//') === 0) {
|
|
77
|
-
url = 'https:' + url
|
|
78
|
-
} else if (url[0] === '/') {
|
|
79
|
-
url = (config.origin || defaultOrigin) + url
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!notTransHttps && url.indexOf('http:') === 0) {
|
|
83
|
-
url = url.replace(/^http:/ig, 'https:')
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return url
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 解码特殊字符
|
|
91
|
-
*/
|
|
92
|
-
function decodeContent(content) {
|
|
93
|
-
return content
|
|
94
|
-
.replace(/ /g, '\u00A0')
|
|
95
|
-
.replace(/ /g, '\u2002')
|
|
96
|
-
.replace(/ /g, '\u2003')
|
|
97
|
-
.replace(/</g, '<')
|
|
98
|
-
.replace(/>/g, '>')
|
|
99
|
-
.replace(/"/g, '"')
|
|
100
|
-
.replace(/'/g, '\'')
|
|
101
|
-
.replace(/&/g, '&')
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 判断该标签在小程序中是否支持
|
|
106
|
-
*/
|
|
107
|
-
const NOT_SUPPORT_TAG_NAME_LIST = ['IFRAME']
|
|
108
|
-
function isTagNameSupport(tagName) {
|
|
109
|
-
return NOT_SUPPORT_TAG_NAME_LIST.indexOf(tagName) === -1
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 处理 innerHTML/outerHTML 的属性值过滤
|
|
114
|
-
*/
|
|
115
|
-
function escapeForHtmlGeneration(value) {
|
|
116
|
-
return value.replace(/"/g, '"')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = {
|
|
120
|
-
toDash,
|
|
121
|
-
toCamel,
|
|
122
|
-
getId,
|
|
123
|
-
getPageRoute,
|
|
124
|
-
getPageName,
|
|
125
|
-
throttle,
|
|
126
|
-
flushThrottleCache,
|
|
127
|
-
completeURL,
|
|
128
|
-
decodeContent,
|
|
129
|
-
isTagNameSupport,
|
|
130
|
-
escapeForHtmlGeneration,
|
|
131
|
-
}
|