@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.
Files changed (83) 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/lib/generator/template.d.ts +1 -101
  6. package/lib/generator/template.d.ts.map +1 -1
  7. package/lib/generator/template.js +1 -101
  8. package/package.json +5 -3
  9. package/template/webpack/web.prod.js +66 -85
  10. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/cookie.js +0 -286
  11. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/history.js +0 -133
  12. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/local-storage.js +0 -103
  13. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/location.js +0 -588
  14. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/miniprogram.js +0 -101
  15. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/navigator.js +0 -80
  16. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/performance.js +0 -28
  17. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/screen.js +0 -31
  18. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/session-storage.js +0 -96
  19. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/xml-http-request.js +0 -290
  20. package/template/dist/mp/miniprogram_npm/miniprogram-render/document.js +0 -396
  21. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/custom-event.js +0 -12
  22. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event-target.js +0 -389
  23. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event.js +0 -186
  24. package/template/dist/mp/miniprogram_npm/miniprogram-render/index.js +0 -41
  25. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/attribute.js +0 -226
  26. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/class-list.js +0 -153
  27. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/comment.js +0 -80
  28. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/a.js +0 -165
  29. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/canvas.js +0 -138
  30. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/image.js +0 -177
  31. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/input.js +0 -181
  32. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/not-support.js +0 -60
  33. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/option.js +0 -126
  34. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/select.js +0 -155
  35. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/textarea.js +0 -178
  36. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/video.js +0 -165
  37. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-component.js +0 -84
  38. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-custom-component.js +0 -64
  39. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element.js +0 -970
  40. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/node.js +0 -140
  41. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style-list.js +0 -28
  42. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style.js +0 -158
  43. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/text-node.js +0 -127
  44. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/parser.js +0 -269
  45. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/query-selector.js +0 -420
  46. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/tree.js +0 -130
  47. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/cache.js +0 -95
  48. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/pool.js +0 -24
  49. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/tool.js +0 -131
  50. package/template/dist/mp/miniprogram_npm/miniprogram-render/window.js +0 -651
  51. package/template/generator/app/common.js +0 -17
  52. package/template/generator/app/global-api.js +0 -163
  53. package/template/generator/app/handlers.js +0 -13
  54. package/template/generator/datasources/config.js.tpl +0 -21
  55. package/template/generator/datasources/dataset-profiles.js.tpl +0 -5
  56. package/template/generator/datasources/datasource-profiles.js.tpl +0 -4
  57. package/template/generator/datasources/index.js.tpl +0 -14
  58. package/template/generator/handlers/NodeRenderer.jsx +0 -471
  59. package/template/generator/handlers/RenderWrapper.jsx +0 -145
  60. package/template/generator/index.jsx +0 -116
  61. package/template/generator/index.less +0 -120
  62. package/template/generator/pages/app.tpl +0 -181
  63. package/template/generator/pages/composite.tpl +0 -267
  64. package/template/generator/router/index.tpl +0 -49
  65. package/template/generator/store/computed.js +0 -11
  66. package/template/generator/store/index.js +0 -5
  67. package/template/generator/utils/ScanCodeComponent.js +0 -345
  68. package/template/generator/utils/actionHandler.js +0 -119
  69. package/template/generator/utils/common.js +0 -225
  70. package/template/generator/utils/computed.js +0 -9
  71. package/template/generator/utils/date.js +0 -324
  72. package/template/generator/utils/error.jsx +0 -14
  73. package/template/generator/utils/eventProxy.js +0 -64
  74. package/template/generator/utils/history.js +0 -35
  75. package/template/generator/utils/hooks.js +0 -10
  76. package/template/generator/utils/index.js +0 -41
  77. package/template/generator/utils/initGlobalVar.js +0 -14
  78. package/template/generator/utils/lifecycle.js +0 -158
  79. package/template/generator/utils/monitor-jssdk.min.js +0 -881
  80. package/template/generator/utils/page.js +0 -10
  81. package/template/generator/utils/scan-code-action.js +0 -27
  82. package/template/generator/utils/style.js +0 -81
  83. package/template/generator/utils/widgets.js +0 -343
@@ -1,396 +0,0 @@
1
- const EventTarget = require('./event/event-target')
2
- const Tree = require('./tree/tree')
3
- const Node = require('./node/node')
4
- const Element = require('./node/element')
5
- const TextNode = require('./node/text-node')
6
- const Comment = require('./node/comment')
7
- const tool = require('./util/tool')
8
- const cache = require('./util/cache')
9
- const A = require('./node/element/a')
10
- const Image = require('./node/element/image')
11
- const Input = require('./node/element/input')
12
- const Textarea = require('./node/element/textarea')
13
- const Video = require('./node/element/video')
14
- const Canvas = require('./node/element/canvas')
15
- const Select = require('./node/element/select')
16
- const Option = require('./node/element/option')
17
- const NotSupport = require('./node/element/not-support')
18
- const WxComponent = require('./node/element/wx-component')
19
- const WxCustomComponent = require('./node/element/wx-custom-component')
20
- const Cookie = require('./bom/cookie')
21
-
22
- const CONSTRUCTOR_MAP = {
23
- A,
24
- IMG: Image,
25
- INPUT: Input,
26
- TEXTAREA: Textarea,
27
- VIDEO: Video,
28
- CANVAS: Canvas,
29
- SELECT: Select,
30
- OPTION: Option,
31
- 'WX-COMPONENT': WxComponent,
32
- }
33
- const WX_COMPONENT_MAP = {}
34
- const WX_COMPONENT_LIST = [
35
- 'movable-view', 'cover-image', 'cover-view', 'movable-area', 'scroll-view', 'swiper', 'swiper-item', 'view',
36
- 'icon', 'progress', 'rich-text', 'text',
37
- 'button', 'checkbox', 'checkbox-group', 'editor', 'form', 'input', 'label', 'picker', 'picker-view', 'picker-view-column', 'radio', 'radio-group', 'slider', 'switch', 'textarea',
38
- 'functional-page-navigator', 'navigator',
39
- 'audio', 'camera', 'image', 'live-player', 'live-pusher', 'video',
40
- 'map',
41
- 'canvas',
42
- 'ad', 'official-account', 'open-data', 'web-view',
43
- // 特殊补充
44
- 'capture', 'catch', 'animation'
45
- ]
46
- WX_COMPONENT_LIST.forEach(name => WX_COMPONENT_MAP[name] = name)
47
- let WX_CUSTOM_COMPONENT_MAP = {}
48
-
49
- /**
50
- * 判断是否是内置组件
51
- */
52
- function checkIsWxComponent(tagName, notNeedPrefix) {
53
- const hasPrefix = tagName.indexOf('wx-') === 0
54
- if (notNeedPrefix) {
55
- return hasPrefix ? WX_COMPONENT_MAP[tagName.slice(3)] : WX_COMPONENT_MAP[tagName]
56
- } else {
57
- return hasPrefix ? WX_COMPONENT_MAP[tagName.slice(3)] : false
58
- }
59
- }
60
-
61
- class Document extends EventTarget {
62
- constructor(pageId, nodeIdMap) {
63
- super()
64
-
65
- const config = cache.getConfig()
66
- const runtime = config.runtime || {}
67
- const cookieStore = runtime.cookieStore
68
- WX_CUSTOM_COMPONENT_MAP = runtime.usingComponents || {}
69
-
70
- this.$_pageId = pageId
71
- const pageRoute = tool.getPageRoute(pageId)
72
- const pageName = tool.getPageName(pageRoute)
73
-
74
- // 用于封装特殊标签和对应构造器
75
- const that = this
76
- this.$_imageConstructor = function HTMLImageElement(width, height) {
77
- return Image.$$create({
78
- tagName: 'img',
79
- nodeId: `b-${tool.getId()}`, // 运行时生成,使用 b- 前缀
80
- attrs: {},
81
- width,
82
- height,
83
- }, that.$_tree)
84
- }
85
-
86
- this.$_pageId = pageId
87
- this.$_tree = new Tree(pageId, {
88
- type: 'element',
89
- tagName: 'body',
90
- attrs: {},
91
- unary: false,
92
- nodeId: 'e-body',
93
- children: [],
94
- }, nodeIdMap, this)
95
- this.$_cookie = new Cookie(pageName)
96
- this.$_config = null
97
-
98
- // documentElement
99
- this.$_node = this.$$createElement({
100
- tagName: 'html',
101
- attrs: {},
102
- nodeId: `a-${tool.getId()}`, // 运行前生成,使用 a- 前缀
103
- type: Node.DOCUMENT_NODE,
104
- })
105
- this.$_node.$$updateParent(this) // documentElement 的 parentNode 是 document
106
-
107
- // head 元素
108
- this.$_head = this.createElement('head')
109
-
110
- // 更新 body 的 parentNode
111
- this.$_tree.root.$$updateParent(this.$_node)
112
-
113
- // 持久化 cookie
114
- if (cookieStore !== 'memory' && cookieStore !== 'globalmemory') {
115
- try {
116
- const key = cookieStore === 'storage' ? `PAGE_COOKIE_${pageName}` : 'PAGE_COOKIE'
117
- const cookie = wx.getStorageSync(key)
118
- if (cookie) this.$$cookieInstance.deserialize(cookie)
119
- } catch (err) {
120
- // ignore
121
- }
122
- }
123
- }
124
-
125
- /**
126
- * Image 构造器
127
- */
128
- get $$imageConstructor() {
129
- return this.$_imageConstructor
130
- }
131
-
132
- get $$pageId() {
133
- return this.$_pageId
134
- }
135
-
136
- /**
137
- * 完整的 cookie,包括 httpOnly 也能获取到
138
- */
139
- get $$cookie() {
140
- return this.$_cookie.getCookie(this.URL, true)
141
- }
142
-
143
- /**
144
- * 获取 cookie 实例
145
- */
146
- get $$cookieInstance() {
147
- return this.$_cookie
148
- }
149
-
150
- /**
151
- * 创建内置组件的时候是否支持不用前缀写法
152
- */
153
- get $$notNeedPrefix() {
154
- if (!this.$_config) this.$_config = cache.getConfig()
155
- return this.$_config && this.$_config.runtime && this.$_config.runtime.wxComponent === 'noprefix'
156
- }
157
-
158
- /**
159
- * 设置页面显示状态
160
- */
161
- set $$visibilityState(value) {
162
- this.$_visibilityState = value
163
- }
164
-
165
- /**
166
- * 触发节点事件
167
- */
168
- $$trigger(eventName, options) {
169
- this.documentElement.$$trigger(eventName, options)
170
- }
171
-
172
- /**
173
- * 内部所有节点创建都走此接口,统一把控
174
- */
175
- $$createElement(options, tree) {
176
- const originTagName = options.tagName
177
- const tagName = originTagName.toUpperCase()
178
- let wxComponentName = null
179
- tree = tree || this.$_tree
180
-
181
- const constructorClass = CONSTRUCTOR_MAP[tagName]
182
- if (constructorClass) {
183
- return constructorClass.$$create(options, tree)
184
- // eslint-disable-next-line no-cond-assign
185
- } else if (wxComponentName = checkIsWxComponent(originTagName, this.$$notNeedPrefix)) {
186
- // 内置组件的特殊写法,转成 wx-component 节点
187
- options.tagName = 'wx-component'
188
- options.attrs = options.attrs || {}
189
- options.attrs.behavior = wxComponentName
190
- return WxComponent.$$create(options, tree)
191
- } else if (WX_CUSTOM_COMPONENT_MAP[originTagName]) {
192
- // 自定义组件的特殊写法,转成 wx-custom-component 节点
193
- options.tagName = 'wx-custom-component'
194
- options.attrs = options.attrs || {}
195
- options.componentName = originTagName
196
- return WxCustomComponent.$$create(options, tree)
197
- } else if (!tool.isTagNameSupport(tagName)) {
198
- return NotSupport.$$create(options, tree)
199
- } else {
200
- return Element.$$create(options, tree)
201
- }
202
- }
203
-
204
- /**
205
- * 内部所有文本节点创建都走此接口,统一把控
206
- */
207
- $$createTextNode(options, tree) {
208
- return TextNode.$$create(options, tree || this.$_tree)
209
- }
210
-
211
- /**
212
- * 内部所有注释节点创建都走此接口,统一把控
213
- */
214
- $$createComment(options, tree) {
215
- return Comment.$$create(options, tree || this.$_tree)
216
- }
217
-
218
- /**
219
- * 处理 Set-Cookie 头串
220
- */
221
- $$setCookie(str) {
222
- if (str && typeof str === 'string') {
223
- let start = 0
224
- let startSplit = 0
225
- let nextSplit = str.indexOf(',', startSplit)
226
- const cookies = []
227
-
228
- while (nextSplit >= 0) {
229
- const lastSplitStr = str.substring(start, nextSplit)
230
- const splitStr = str.substr(nextSplit)
231
-
232
- if (/^,\s*([^,=;\x00-\x1F]+)=([^;\n\r\0\x00-\x1F]*).*/.test(splitStr)) {
233
- // 分割成功,则上一片是完整 cookie
234
- cookies.push(lastSplitStr)
235
- start = nextSplit + 1
236
- }
237
-
238
- startSplit = nextSplit + 1
239
- nextSplit = str.indexOf(',', startSplit)
240
- }
241
-
242
- // 塞入最后一片 cookie
243
- cookies.push(str.substr(start))
244
-
245
- cookies.forEach(cookie => this.cookie = cookie)
246
- }
247
- }
248
-
249
- /**
250
- * 对外属性和方法
251
- */
252
- get nodeType() {
253
- return Node.DOCUMENT_NODE
254
- }
255
-
256
- get documentElement() {
257
- return this.$_node
258
- }
259
-
260
- get body() {
261
- return this.$_tree.root
262
- }
263
-
264
- get nodeName() {
265
- return '#document'
266
- }
267
-
268
- get head() {
269
- return this.$_head
270
- }
271
-
272
- get defaultView() {
273
- return cache.getWindow(this.$_pageId) || null
274
- }
275
-
276
- get URL() {
277
- if (this.defaultView) return this.defaultView.location.href
278
-
279
- return ''
280
- }
281
-
282
- get cookie() {
283
- return this.$_cookie.getCookie(this.URL)
284
- }
285
-
286
- set cookie(value) {
287
- if (!value || typeof value !== 'string') return
288
-
289
- this.$_cookie.setCookie(value, this.URL)
290
- }
291
-
292
- get visibilityState() {
293
- return this.$_visibilityState
294
- }
295
-
296
- get hidden() {
297
- return this.$_visibilityState === 'visible'
298
- }
299
-
300
- getElementById(id) {
301
- if (typeof id !== 'string') return
302
-
303
- return this.$_tree.getById(id) || null
304
- }
305
-
306
- getElementsByTagName(tagName) {
307
- if (typeof tagName !== 'string') return []
308
-
309
- return this.$_tree.getByTagName(tagName)
310
- }
311
-
312
- getElementsByClassName(className) {
313
- if (typeof className !== 'string') return []
314
-
315
- return this.$_tree.getByClassName(className)
316
- }
317
-
318
- getElementsByName(name) {
319
- if (typeof name !== 'string') return []
320
-
321
- return this.$_tree.query(`*[name=${name}]`)
322
- }
323
-
324
- querySelector(selector) {
325
- if (typeof selector !== 'string') return
326
-
327
- return this.$_tree.query(selector)[0] || null
328
- }
329
-
330
- querySelectorAll(selector) {
331
- if (typeof selector !== 'string') return []
332
-
333
- return this.$_tree.query(selector)
334
- }
335
-
336
- createElement(tagName) {
337
- if (typeof tagName !== 'string') return
338
-
339
- tagName = tagName.trim()
340
- if (!tagName) return
341
-
342
- return this.$$createElement({
343
- tagName,
344
- nodeId: `b-${tool.getId()}`, // 运行时生成,使用 b- 前缀
345
- })
346
- }
347
-
348
- createElementNS(ns, tagName) {
349
- // 不支持真正意义上的 createElementNS,转成调用 createElement
350
- return this.createElement(tagName)
351
- }
352
-
353
- createTextNode(content) {
354
- content = '' + content
355
-
356
- return this.$$createTextNode({
357
- content,
358
- nodeId: `b-${tool.getId()}`, // 运行时生成,使用 b- 前缀
359
- })
360
- }
361
-
362
- createComment() {
363
- // 忽略注释内容的传入
364
- return this.$$createComment({
365
- nodeId: `b-${tool.getId()}`, // 运行时生成,使用 b- 前缀
366
- })
367
- }
368
-
369
- createDocumentFragment() {
370
- return Element.$$create({
371
- tagName: 'documentfragment',
372
- nodeId: `b-${tool.getId()}`, // 运行时生成,使用 b- 前缀
373
- nodeType: Node.DOCUMENT_FRAGMENT_NODE,
374
- }, this.$_tree)
375
- }
376
-
377
- createEvent() {
378
- const window = cache.getWindow(this.$_pageId)
379
-
380
- return new window.CustomEvent()
381
- }
382
-
383
- addEventListener(eventName, handler, options) {
384
- this.documentElement.addEventListener(eventName, handler, options)
385
- }
386
-
387
- removeEventListener(eventName, handler, isCapture) {
388
- this.documentElement.removeEventListener(eventName, handler, isCapture)
389
- }
390
-
391
- dispatchEvent(evt) {
392
- this.documentElement.dispatchEvent(evt)
393
- }
394
- }
395
-
396
- module.exports = Document
@@ -1,12 +0,0 @@
1
- const Event = require('./event')
2
-
3
- class CustomEvent extends Event {
4
- constructor(name = '', options = {}) {
5
- super({
6
- name,
7
- ...options,
8
- })
9
- }
10
- }
11
-
12
- module.exports = CustomEvent