@cloudbase/framework-plugin-low-code 0.6.30 → 0.6.33

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 (82) hide show
  1. package/lib/builder/config/index.js +2 -5
  2. package/lib/builder/core/copy.d.ts.map +1 -1
  3. package/lib/builder/mp/materials.d.ts.map +1 -1
  4. package/lib/builder/mp/materials.js +21 -5
  5. package/package.json +5 -3
  6. package/template/src/handlers/FieldMiddleware/renderer.jsx +11 -6
  7. package/template/src/handlers/actionHandler/utils.js +41 -17
  8. package/template/webpack/web.prod.js +65 -85
  9. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/cookie.js +0 -286
  10. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/history.js +0 -133
  11. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/local-storage.js +0 -103
  12. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/location.js +0 -588
  13. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/miniprogram.js +0 -101
  14. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/navigator.js +0 -80
  15. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/performance.js +0 -28
  16. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/screen.js +0 -31
  17. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/session-storage.js +0 -96
  18. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/xml-http-request.js +0 -290
  19. package/template/dist/mp/miniprogram_npm/miniprogram-render/document.js +0 -396
  20. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/custom-event.js +0 -12
  21. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event-target.js +0 -389
  22. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event.js +0 -186
  23. package/template/dist/mp/miniprogram_npm/miniprogram-render/index.js +0 -41
  24. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/attribute.js +0 -226
  25. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/class-list.js +0 -153
  26. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/comment.js +0 -80
  27. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/a.js +0 -165
  28. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/canvas.js +0 -138
  29. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/image.js +0 -177
  30. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/input.js +0 -181
  31. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/not-support.js +0 -60
  32. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/option.js +0 -126
  33. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/select.js +0 -155
  34. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/textarea.js +0 -178
  35. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/video.js +0 -165
  36. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-component.js +0 -84
  37. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-custom-component.js +0 -64
  38. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element.js +0 -970
  39. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/node.js +0 -140
  40. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style-list.js +0 -28
  41. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style.js +0 -158
  42. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/text-node.js +0 -127
  43. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/parser.js +0 -269
  44. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/query-selector.js +0 -420
  45. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/tree.js +0 -130
  46. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/cache.js +0 -95
  47. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/pool.js +0 -24
  48. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/tool.js +0 -131
  49. package/template/dist/mp/miniprogram_npm/miniprogram-render/window.js +0 -651
  50. package/template/generator/app/common.js +0 -17
  51. package/template/generator/app/global-api.js +0 -163
  52. package/template/generator/app/handlers.js +0 -13
  53. package/template/generator/datasources/config.js.tpl +0 -21
  54. package/template/generator/datasources/dataset-profiles.js.tpl +0 -5
  55. package/template/generator/datasources/datasource-profiles.js.tpl +0 -4
  56. package/template/generator/datasources/index.js.tpl +0 -14
  57. package/template/generator/handlers/NodeRenderer.jsx +0 -471
  58. package/template/generator/handlers/RenderWrapper.jsx +0 -145
  59. package/template/generator/index.jsx +0 -116
  60. package/template/generator/index.less +0 -120
  61. package/template/generator/pages/app.tpl +0 -181
  62. package/template/generator/pages/composite.tpl +0 -267
  63. package/template/generator/router/index.tpl +0 -49
  64. package/template/generator/store/computed.js +0 -11
  65. package/template/generator/store/index.js +0 -5
  66. package/template/generator/utils/ScanCodeComponent.js +0 -345
  67. package/template/generator/utils/actionHandler.js +0 -119
  68. package/template/generator/utils/common.js +0 -225
  69. package/template/generator/utils/computed.js +0 -9
  70. package/template/generator/utils/date.js +0 -324
  71. package/template/generator/utils/error.jsx +0 -14
  72. package/template/generator/utils/eventProxy.js +0 -64
  73. package/template/generator/utils/history.js +0 -35
  74. package/template/generator/utils/hooks.js +0 -10
  75. package/template/generator/utils/index.js +0 -41
  76. package/template/generator/utils/initGlobalVar.js +0 -14
  77. package/template/generator/utils/lifecycle.js +0 -158
  78. package/template/generator/utils/monitor-jssdk.min.js +0 -881
  79. package/template/generator/utils/page.js +0 -10
  80. package/template/generator/utils/scan-code-action.js +0 -27
  81. package/template/generator/utils/style.js +0 -81
  82. package/template/generator/utils/widgets.js +0 -343
@@ -1,286 +0,0 @@
1
- const Location = require('./location')
2
- const cache = require('../util/cache')
3
-
4
- class Cookie {
5
- constructor(pageName) {
6
- const config = cache.getConfig()
7
- const runtime = config.runtime || {}
8
- this.cookieStore = runtime.cookieStore
9
- this.$_pageName = pageName
10
-
11
- if (this.cookieStore !== 'storage' && this.cookieStore !== 'memory') {
12
- // 需要全局共享
13
- this.$_map = cache.getCookie()
14
- } else {
15
- this.$_map = {} // 三维数组,domain - path - key
16
- }
17
- }
18
-
19
- static parse(cookieStr) {
20
- if (!cookieStr && typeof cookieStr !== 'string') return null
21
-
22
- cookieStr = cookieStr.trim().split(';')
23
-
24
- // key-value
25
- const parseKeyValue = /^([^=;\x00-\x1F]+)=([^;\n\r\0\x00-\x1F]*).*/.exec(cookieStr.shift())
26
- if (!parseKeyValue) return null
27
-
28
- const key = (parseKeyValue[1] || '').trim()
29
- const value = (parseKeyValue[2] || '').trim()
30
-
31
- // 其他字段
32
- let path = null
33
- let domain = null
34
- let expires = null
35
- let maxAge = null
36
- let secure = false
37
- let httpOnly = false
38
-
39
- for (let item of cookieStr) {
40
- item = item.trim()
41
- if (!item) continue
42
-
43
- let [key, value] = item.split('=')
44
- key = (key || '').trim().toLowerCase()
45
- value = (value || '').trim()
46
-
47
- if (!key) continue
48
-
49
- switch (key) {
50
- case 'path':
51
- if (value[0] === '/') path = value
52
- break
53
- case 'domain':
54
- value = value.replace(/^\./, '').toLowerCase()
55
- if (value) domain = value
56
- break
57
- case 'expires':
58
- if (value) {
59
- const timeStamp = Date.parse(value)
60
- if (timeStamp) expires = timeStamp
61
- }
62
- break
63
- case 'max-age':
64
- if (/^-?[0-9]+$/.test(value)) maxAge = +value * 1000
65
- break
66
- case 'secure':
67
- secure = true
68
- break
69
- case 'httponly':
70
- httpOnly = true
71
- break
72
- default:
73
- // ignore
74
- break
75
- }
76
- }
77
-
78
- return {
79
- key, value, path, domain, expires, maxAge, secure, httpOnly
80
- }
81
- }
82
-
83
- /**
84
- * 判断 domain
85
- */
86
- $_checkDomain(host, cookieDomain) {
87
- if (host === cookieDomain) return true
88
-
89
- const index = host.indexOf(`.${cookieDomain}`)
90
-
91
- return index > 0 && cookieDomain.length + index + 1 === host.length
92
- }
93
-
94
- /**
95
- * 判断 path
96
- */
97
- $_checkPath(path, cookiePath) {
98
- if (path === cookiePath) return true
99
-
100
- cookiePath = cookiePath === '/' ? '' : cookiePath
101
- return path.indexOf(`${cookiePath}/`) === 0
102
- }
103
-
104
- /**
105
- * 判断过期
106
- */
107
- $_checkExpires(cookie) {
108
- const now = Date.now()
109
-
110
- // maxAge 优先
111
- if (cookie.maxAge !== null) return cookie.createTime + cookie.maxAge > now
112
-
113
- // 判断 expires
114
- if (cookie.expires !== null) return cookie.expires > now
115
-
116
- return true
117
- }
118
-
119
- /**
120
- * 设置 cookie
121
- */
122
- setCookie(cookie, url) {
123
- cookie = Cookie.parse(cookie)
124
-
125
- if (!cookie) return
126
-
127
- const {hostname, port, pathname} = Location.$$parse(url)
128
- const host = ((hostname || '') + (port ? ':' + port : '')) || ''
129
- const path = (pathname || '')[0] === '/' ? pathname : '/'
130
-
131
- if (cookie.domain) {
132
- // 判断 domain
133
- if (!this.$_checkDomain(host, cookie.domain)) return
134
- } else {
135
- // 使用 host 作为默认的 domain
136
- cookie.domain = host
137
- }
138
-
139
- // 需要设置 path 字段的情况,取 url 中除去最后一节的 path
140
- if (!cookie.path || cookie.path[0] !== '/') {
141
- const lastIndex = path.lastIndexOf('/')
142
-
143
- cookie.path = lastIndex === 0 ? path : path.substr(0, lastIndex)
144
- }
145
-
146
- // 存入 cookie
147
- const map = this.$_map
148
- const cookieDomain = cookie.domain
149
- const cookiePath = cookie.path
150
- const cookieKey = cookie.key
151
-
152
- if (!map[cookieDomain]) map[cookieDomain] = {}
153
- if (!map[cookieDomain][cookiePath]) map[cookieDomain][cookiePath] = {}
154
-
155
- const oldCookie = map[cookieDomain][cookiePath][cookieKey]
156
- cookie.createTime = oldCookie && oldCookie.createTime || Date.now()
157
-
158
- if (this.$_checkExpires(cookie)) {
159
- // 未过期
160
- map[cookieDomain][cookiePath][cookieKey] = cookie
161
- } else if (oldCookie) {
162
- // 存在旧 cookie,且被设置为已过期
163
- delete map[cookieDomain][cookiePath][cookieKey]
164
- }
165
-
166
- // 持久化 cookie
167
- if (this.cookieStore !== 'memory' && this.cookieStore !== 'globalmemory') {
168
- const key = this.cookieStore === 'storage' ? `PAGE_COOKIE_${this.$_pageName}` : 'PAGE_COOKIE'
169
- wx.setStorage({
170
- key,
171
- data: this.serialize(),
172
- })
173
- }
174
- }
175
-
176
- /**
177
- * 拉取 cookie
178
- */
179
- getCookie(url, includeHttpOnly) {
180
- const {
181
- protocol, hostname, port, pathname
182
- } = Location.$$parse(url)
183
- const host = ((hostname || '') + (port ? ':' + port : '')) || ''
184
- const path = (pathname || '')[0] === '/' ? pathname : '/'
185
- const res = []
186
-
187
- const map = this.$_map
188
- const domainList = Object.keys(map)
189
-
190
- for (const domainItem of domainList) {
191
- // 判断 domain
192
- if (this.$_checkDomain(host, domainItem)) {
193
- const domainMap = map[domainItem] || {}
194
- const pathList = Object.keys(domainMap)
195
-
196
- for (const pathItem of pathList) {
197
- // 判断 path
198
- if (this.$_checkPath(path, pathItem)) {
199
- const pathMap = map[domainItem][pathItem] || {}
200
-
201
- Object.keys(pathMap).forEach(key => {
202
- const cookie = pathMap[key]
203
-
204
- if (!cookie) return
205
-
206
- // 判断协议
207
- if (cookie.secure && protocol !== 'https:' && protocol !== 'wss:') return
208
- if (!includeHttpOnly && cookie.httpOnly && protocol && protocol !== 'http:') return
209
-
210
- // 判断过期
211
- if (this.$_checkExpires(cookie)) {
212
- res.push(cookie)
213
- } else {
214
- // 过期,删掉
215
- delete map[domainItem][pathItem][key]
216
- }
217
- })
218
- }
219
- }
220
- }
221
- }
222
-
223
- return res
224
- .sort((a, b) => {
225
- const gap = a.createTime - b.createTime
226
-
227
- if (!gap) {
228
- return a.key < b.key ? -1 : 1
229
- } else {
230
- return gap
231
- }
232
- })
233
- .map(cookie => `${cookie.key}=${cookie.value}`)
234
- .join('; ')
235
- }
236
-
237
- /**
238
- * 序列化
239
- */
240
- serialize() {
241
- try {
242
- return JSON.stringify(this.$_map)
243
- } catch (err) {
244
- console.log('cannot serialize the cookie')
245
- return ''
246
- }
247
- }
248
-
249
- /**
250
- * 反序列化
251
- */
252
- deserialize(str) {
253
- let map = {}
254
- try {
255
- map = JSON.parse(str)
256
- } catch (err) {
257
- console.log('cannot deserialize the cookie')
258
- map = {}
259
- }
260
-
261
- // 合并 cookie
262
- const domainList = Object.keys(map)
263
-
264
- for (const domainItem of domainList) {
265
- const domainMap = map[domainItem] || {}
266
- const pathList = Object.keys(domainMap)
267
-
268
- for (const pathItem of pathList) {
269
- const pathMap = map[domainItem][pathItem] || {}
270
-
271
- Object.keys(pathMap).forEach(key => {
272
- const cookie = pathMap[key]
273
-
274
- if (!cookie) return
275
-
276
- // 已存在则不覆盖
277
- if (!this.$_map[domainItem]) this.$_map[domainItem] = {}
278
- if (!this.$_map[domainItem][pathItem]) this.$_map[domainItem][pathItem] = {}
279
- if (!this.$_map[domainItem][pathItem][key]) this.$_map[domainItem][pathItem][key] = cookie
280
- })
281
- }
282
- }
283
- }
284
- }
285
-
286
- module.exports = Cookie
@@ -1,133 +0,0 @@
1
- /**
2
- * 暂不维护跳转后页面的历史,不做页面刷新的操作
3
- */
4
- const Location = require('./location')
5
- const EventTarget = require('../event/event-target')
6
-
7
- class History extends EventTarget {
8
- constructor(location) {
9
- super()
10
-
11
- this.$_location = location
12
- this.$_stack = [{
13
- state: null,
14
- title: '',
15
- url: location.href,
16
- }]
17
- this.$_currentIndex = 0
18
-
19
- this.$_location.addEventListener('$_addToHistory', evt => {
20
- this.$_currentIndex++
21
- this.$_stack = this.$_stack.slice(0, this.$_currentIndex)
22
- this.$_stack.push({
23
- state: null,
24
- title: '',
25
- url: evt.href
26
- })
27
- })
28
- }
29
-
30
- /**
31
- * 检查是否同源
32
- */
33
- $_checkOrigin(url) {
34
- const {protocol, hostname, port} = Location.$$parse(url)
35
-
36
- return (!protocol || this.$_location.protocol === protocol) && (!hostname || this.$_location.hostname === hostname) && ((!hostname && !port) || this.$_location.port === port)
37
- }
38
-
39
- /**
40
- * 重置实例
41
- */
42
- $$reset() {
43
- this.$_stack = [{
44
- state: null,
45
- title: '',
46
- url: this.$_location.href,
47
- }]
48
- this.$_currentIndex = 0
49
- }
50
-
51
- /**
52
- * 对外属性和方法
53
- */
54
- get state() {
55
- const current = this.$_stack[this.$_currentIndex]
56
- return current && current.state || null
57
- }
58
-
59
- get length() {
60
- return this.$_stack.length
61
- }
62
-
63
- back() {
64
- this.go(-1)
65
- }
66
-
67
- forward() {
68
- this.go(1)
69
- }
70
-
71
- go(delta) {
72
- if (typeof delta === 'number') {
73
- const next = this.$_currentIndex + delta
74
-
75
- if (next >= 0 && next < this.$_stack.length && this.$_currentIndex !== next) {
76
- this.$_currentIndex = next
77
- // 替换 href,但不做跳转(理论上此处应该做跳转,但是在小程序环境里不适合)
78
- this.$_location.$$startCheckHash()
79
- this.$_location.$$setHrefWithoutCheck(this.$_stack[this.$_currentIndex].url)
80
- this.$_location.$$endCheckHash(true) // 因为不跳转,所以要强制触发 hashchange 检测
81
-
82
- this.$$trigger('popstate', {
83
- event: {
84
- state: this.state
85
- }
86
- })
87
- }
88
- } else {
89
- // 刷新当前页面
90
- this.$_location.reload()
91
- }
92
- }
93
-
94
- pushState(state = null, title, url) {
95
- if (!url || typeof url !== 'string') return
96
-
97
- if (this.$_checkOrigin(url)) {
98
- // 同源才允许操作
99
- if (title && typeof title === 'string') {
100
- // 设置标题
101
- wx.setNavigationBarTitle({title})
102
- }
103
-
104
-
105
- this.$_currentIndex++
106
- this.$_stack = this.$_stack.slice(0, this.$_currentIndex)
107
-
108
- // 替换 href,但不做跳转
109
- this.$_location.$$setHrefWithoutCheck(url)
110
-
111
- this.$_stack.push({state, title, url: this.$_location.href})
112
- }
113
- }
114
-
115
- replaceState(state = null, title, url) {
116
- if (!url || typeof url !== 'string') return
117
-
118
- if (this.$_checkOrigin(url)) {
119
- // 同源才允许操作
120
- if (title && typeof title === 'string') {
121
- // 设置标题
122
- wx.setNavigationBarTitle({title})
123
- }
124
-
125
- // 替换 href,但不做跳转
126
- this.$_location.$$setHrefWithoutCheck(url)
127
-
128
- this.$_stack.splice(this.$_currentIndex, 1, {state, title, url: this.$_location.href})
129
- }
130
- }
131
- }
132
-
133
- module.exports = History
@@ -1,103 +0,0 @@
1
- const Event = require('../event/event')
2
-
3
- class LocalStorage {
4
- constructor(window) {
5
- this.$_keys = []
6
- this.$_window = window
7
- }
8
-
9
- /**
10
- * 更新 storage 信息
11
- */
12
- $_updateInfo() {
13
- try {
14
- const info = wx.getStorageInfoSync()
15
- const pages = getCurrentPages() || []
16
- pages.forEach(page => {
17
- if (page && page.window) {
18
- page.window.localStorage.$$keys = info.keys
19
- }
20
- })
21
- } catch (err) {
22
- console.warn('getStorageInfoSync fail')
23
- }
24
- }
25
-
26
- /**
27
- * 触发 window 的 storage 事件
28
- */
29
- $_triggerStorage(key, newValue, oldValue, force) {
30
- if (!force && newValue === oldValue) return
31
-
32
- const pages = getCurrentPages() || []
33
- pages.forEach(page => {
34
- if (page && page.window && page.window !== this.$_window) {
35
- page.window.$$trigger('storage', {
36
- event: new Event({
37
- name: 'storage',
38
- target: page.window,
39
- $$extra: {
40
- key,
41
- newValue,
42
- oldValue,
43
- storageArea: this,
44
- url: this.$_window.location.href,
45
- }
46
- })
47
- })
48
- }
49
- })
50
- }
51
-
52
- set $$keys(keys) {
53
- this.$_keys = keys
54
- }
55
-
56
- /**
57
- * 对外属性和方法
58
- */
59
- get length() {
60
- return this.$_keys && this.$_keys.length || 0
61
- }
62
-
63
- key(num) {
64
- if (typeof num !== 'number' || !isFinite(num) || num < 0) return null
65
-
66
- return this.$_keys[num] || null
67
- }
68
-
69
- getItem(key) {
70
- if (!key || typeof key !== 'string') return null
71
-
72
- return wx.getStorageSync(key) || null
73
- }
74
-
75
- setItem(key, data) {
76
- if (!key || typeof key !== 'string') return
77
- data = '' + data
78
-
79
- const oldValue = wx.getStorageSync(key) || null
80
-
81
- wx.setStorageSync(key, data)
82
- this.$_updateInfo()
83
- this.$_triggerStorage(key, data, oldValue)
84
- }
85
-
86
- removeItem(key) {
87
- if (!key || typeof key !== 'string') return
88
-
89
- const oldValue = wx.getStorageSync(key) || null
90
-
91
- wx.removeStorageSync(key)
92
- this.$_updateInfo()
93
- this.$_triggerStorage(key, null, oldValue)
94
- }
95
-
96
- clear() {
97
- wx.clearStorageSync()
98
- this.$_updateInfo()
99
- this.$_triggerStorage(null, null, null, true)
100
- }
101
- }
102
-
103
- module.exports = LocalStorage