@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,389 +0,0 @@
1
- const Event = require('./event')
2
- const CustomEvent = require('./custom-event')
3
-
4
- /**
5
- * 比较 touch 列表
6
- */
7
- function compareTouchList(a, b) {
8
- if (a.length !== b.length) return false
9
-
10
- for (let i, len = a.length; i < len; i++) {
11
- const aItem = a[i]
12
- const bItem = b[i]
13
-
14
- if (aItem.identifier !== bItem.identifier) return false
15
- if (aItem.pageX !== bItem.pageX || aItem.pageY !== bItem.pageY || aItem.clientX !== bItem.clientX || aItem.clientY !== bItem.clientY) return false
16
- }
17
-
18
- return true
19
- }
20
-
21
- class EventTarget {
22
- constructor(...args) {
23
- this.$$init(...args)
24
- }
25
-
26
- /**
27
- * 初始化实例
28
- */
29
- $$init() {
30
- // 补充实例的属性,用于 'xxx' in XXX 判断
31
- this.ontouchstart = null
32
- this.ontouchmove = null
33
- this.ontouchend = null
34
- this.ontouchcancel = null
35
- this.oninput = null
36
- this.onfocus = null
37
- this.onblur = null
38
- this.onchange = null
39
-
40
- this.$_miniprogramEvent = null // 记录已触发的小程序事件
41
- this.$_eventHandlerMap = null
42
- }
43
-
44
- /**
45
- * 销毁实例
46
- */
47
- $$destroy() {
48
- Object.keys(this).forEach(key => {
49
- // 处理 on 开头的属性
50
- if (key.indexOf('on') === 0) this[key] = null
51
- // 处理外部挂进来的私有的属性
52
- if (key[0] === '_') this[key] = null
53
- if (key[0] === '$' && (key[1] !== '_' && key[1] !== '$')) this[key] = null
54
- })
55
-
56
- this.$_miniprogramEvent = null
57
- this.$_eventHandlerMap = null
58
- }
59
-
60
- set $_eventHandlerMap(value) {
61
- this.$__eventHandlerMap = value
62
- }
63
-
64
- get $_eventHandlerMap() {
65
- if (!this.$__eventHandlerMap) this.$__eventHandlerMap = Object.create(null)
66
- return this.$__eventHandlerMap
67
- }
68
-
69
- /**
70
- * 触发事件捕获、冒泡流程
71
- */
72
- static $$process(target, eventName, miniprogramEvent, extra, callback) {
73
- let event
74
-
75
- if (eventName instanceof CustomEvent || eventName instanceof Event) {
76
- // 传入的是事件对象
77
- event = eventName
78
- eventName = event.type
79
- }
80
-
81
- eventName = eventName.toLowerCase()
82
-
83
- const path = [target]
84
- let parentNode = target.parentNode
85
-
86
- while (parentNode && parentNode.tagName !== 'HTML') {
87
- path.push(parentNode)
88
- parentNode = parentNode.parentNode
89
- }
90
-
91
- if (path[path.length - 1].tagName === 'BODY') {
92
- // 如果最后一个节点是 document.body,则追加 document.documentElement
93
- path.push(parentNode)
94
- }
95
-
96
- if (!event) {
97
- // 此处特殊处理,不直接返回小程序的 event 对象
98
- event = new Event({
99
- name: eventName,
100
- target,
101
- timeStamp: miniprogramEvent.timeStamp,
102
- touches: miniprogramEvent.touches,
103
- changedTouches: miniprogramEvent.changedTouches,
104
- bubbles: true, // 默认都可以冒泡 TODO
105
- $$extra: extra,
106
- })
107
- }
108
-
109
- // 捕获
110
- for (let i = path.length - 1; i >= 0; i--) {
111
- const currentTarget = path[i]
112
-
113
- if (!event.$$canBubble) break // 判定冒泡是否结束
114
- if (currentTarget === target) continue
115
-
116
- // wx-capture 节点事件单独触发
117
- if (currentTarget.tagName === 'WX-COMPONENT' && currentTarget.behavior === 'capture') continue
118
-
119
- event.$$setCurrentTarget(currentTarget)
120
- event.$$setEventPhase(Event.CAPTURING_PHASE)
121
-
122
- currentTarget.$$trigger(eventName, {
123
- event,
124
- isCapture: true,
125
- })
126
- if (callback) callback(currentTarget, event, true)
127
- }
128
-
129
- // 目标
130
- if (event.$$canBubble) {
131
- event.$$setCurrentTarget(target)
132
- event.$$setEventPhase(Event.AT_TARGET)
133
-
134
- // 捕获和冒泡阶段监听的事件都要触发
135
- target.$$trigger(eventName, {
136
- event,
137
- isCapture: true,
138
- isTarget: true,
139
- })
140
- if (callback) callback(target, event, true)
141
-
142
- target.$$trigger(eventName, {
143
- event,
144
- isCapture: false,
145
- isTarget: true,
146
- })
147
- if (callback) callback(target, event, false)
148
- }
149
-
150
- if (event.bubbles) {
151
- // 冒泡
152
- for (const currentTarget of path) {
153
- if (!event.$$canBubble) break // 判定冒泡是否结束
154
- if (currentTarget === target) continue
155
-
156
- // wx-capture 节点事件单独触发
157
- if (currentTarget.tagName === 'WX-COMPONENT' && currentTarget.behavior === 'capture') continue
158
-
159
- event.$$setCurrentTarget(currentTarget)
160
- event.$$setEventPhase(Event.BUBBLING_PHASE)
161
-
162
- currentTarget.$$trigger(eventName, {
163
- event,
164
- isCapture: false,
165
- })
166
- if (callback) callback(currentTarget, event, false)
167
-
168
- // wx-catch 节点事件要结束冒泡
169
- if (currentTarget.tagName === 'WX-COMPONENT' && currentTarget.behavior === 'catch') event.stopPropagation()
170
- }
171
- }
172
-
173
- // 重置事件
174
- event.$$setCurrentTarget(null)
175
- event.$$setEventPhase(Event.NONE)
176
-
177
- return event
178
- }
179
-
180
- /**
181
- * 获取 handlers
182
- */
183
- $_getHandlers(eventName, isCapture, isInit) {
184
- const handlerMap = this.$_eventHandlerMap
185
-
186
- if (isInit) {
187
- const handlerObj = handlerMap[eventName] = handlerMap[eventName] || {}
188
-
189
- handlerObj.capture = handlerObj.capture || []
190
- handlerObj.bubble = handlerObj.bubble || []
191
-
192
- return isCapture ? handlerObj.capture : handlerObj.bubble
193
- } else {
194
- const handlerObj = handlerMap[eventName]
195
-
196
- if (!handlerObj) return null
197
-
198
- return isCapture ? handlerObj.capture : handlerObj.bubble
199
- }
200
- }
201
-
202
- /**
203
- * 触发节点事件
204
- */
205
- $$trigger(eventName, {
206
- event, args = [], isCapture, isTarget
207
- } = {}) {
208
- eventName = eventName.toLowerCase()
209
- const handlers = this.$_getHandlers(eventName, isCapture)
210
- const onEventName = `on${eventName}`
211
-
212
- if ((!isCapture || !isTarget) && typeof this[onEventName] === 'function') {
213
- // 触发 onXXX 绑定的事件
214
- if (event && event.$$immediateStop) return
215
- try {
216
- this[onEventName].call(this || null, event, ...args)
217
- } catch (err) {
218
- console.error(err)
219
- }
220
- }
221
-
222
- if (!handlers) return
223
-
224
- // 触发 addEventListener 绑定的事件
225
- if (handlers.length) {
226
- handlers.forEach(handler => {
227
- if (event && event.$$immediateStop) return
228
- try {
229
- handler.call(this || null, event, ...args)
230
- } catch (err) {
231
- console.error(err)
232
- }
233
- })
234
- }
235
-
236
- // 触发 addEventListener 绑定到命名空间下的事件
237
- if (handlers._namespace) {
238
- Object.keys(handlers._namespace).forEach(namespace => {
239
- const namespaceHandlers = handlers._namespace[namespace]
240
- if (namespaceHandlers) {
241
- namespaceHandlers.forEach(handler => {
242
- if (event && event.$$immediateStop) return
243
- try {
244
- handler.call(this || null, event, ...args)
245
- } catch (err) {
246
- console.error(err)
247
- }
248
- })
249
- }
250
- })
251
- }
252
- }
253
-
254
- /**
255
- * 检查该事件是否可以触发
256
- */
257
- $$checkEvent(miniprogramEvent) {
258
- const last = this.$_miniprogramEvent
259
- const now = miniprogramEvent
260
-
261
- let flag = false
262
-
263
- if (!last || last.timeStamp !== now.timeStamp) {
264
- // 时间戳不同
265
- flag = true
266
- } else {
267
- if (last.touches && now.touches && !compareTouchList(last.touches, now.touches)) {
268
- // 存在不同的 touches
269
- flag = true
270
- } else if ((!last.touches && now.touches) || (last.touches && !now.touches)) {
271
- // 存在一方没有 touches
272
- flag = true
273
- }
274
-
275
- if (last.changedTouches && now.changedTouches && !compareTouchList(last.changedTouches, now.changedTouches)) {
276
- // 存在不同的 changedTouches
277
- flag = true
278
- } else if ((!last.changedTouches && now.changedTouches) || (last.changedTouches && !now.changedTouches)) {
279
- // 存在一方没有 changedTouches
280
- flag = true
281
- }
282
- }
283
-
284
- if (flag) this.$_miniprogramEvent = now
285
- return flag
286
- }
287
-
288
- /**
289
- * 清空某个事件的所有句柄
290
- */
291
- $$clearEvent(eventName, options) {
292
- if (typeof eventName !== 'string') return
293
-
294
- let isCapture = false
295
- let namespace = null
296
-
297
- if (typeof options === 'boolean') isCapture = options
298
- else if (typeof options === 'object') {
299
- isCapture = !!options.capture
300
- namespace = options.$$namespace
301
- }
302
-
303
- eventName = eventName.toLowerCase()
304
- const handlers = this.$_getHandlers(eventName, isCapture)
305
-
306
- if (!handlers) return
307
-
308
- if (handlers.length) handlers.length = 0
309
- if (handlers._namespace) handlers._namespace[namespace] = null
310
- }
311
-
312
- /**
313
- * 是否存在事件句柄,只考虑通过 addEventListener 绑定的句柄
314
- */
315
- $$hasEventHandler(eventName) {
316
- eventName = eventName.toLowerCase()
317
- const bubbleHandlers = this.$_getHandlers(eventName, false)
318
- const captureHandlers = this.$_getHandlers(eventName, true)
319
- return (bubbleHandlers && bubbleHandlers.length) || (captureHandlers && captureHandlers.length)
320
- }
321
-
322
- /**
323
- * 对外属性和方法
324
- */
325
- addEventListener(eventName, handler, options) {
326
- if (typeof eventName !== 'string' || typeof handler !== 'function') return
327
-
328
- let isCapture = false
329
- let namespace = null
330
-
331
- if (typeof options === 'boolean') isCapture = options
332
- else if (typeof options === 'object') {
333
- isCapture = !!options.capture
334
- namespace = options.$$namespace
335
- }
336
-
337
- eventName = eventName.toLowerCase()
338
- const handlers = this.$_getHandlers(eventName, isCapture, true)
339
-
340
- if (namespace) {
341
- // 存在命名空间
342
- handlers._namespace = handlers._namespace || {}
343
- handlers._namespace[namespace] = handlers._namespace[namespace] || []
344
- handlers._namespace[namespace].push(handler)
345
- } else {
346
- handlers.push(handler)
347
- }
348
- }
349
-
350
- removeEventListener(eventName, handler, options) {
351
- if (typeof eventName !== 'string' || typeof handler !== 'function') return
352
-
353
- let isCapture = false
354
- let namespace = null
355
-
356
- if (typeof options === 'boolean') isCapture = options
357
- else if (typeof options === 'object') {
358
- isCapture = !!options.capture
359
- namespace = options.$$namespace
360
- }
361
-
362
- eventName = eventName.toLowerCase()
363
- const handlers = this.$_getHandlers(eventName, isCapture, false)
364
-
365
- if (!handlers) return
366
-
367
- if (namespace) {
368
- // 存在命名空间
369
- if (!handlers._namespace || !handlers._namespace[namespace]) return
370
-
371
- const index = handlers._namespace[namespace].indexOf(handler)
372
- if (index >= 0) handlers._namespace[namespace].splice(index, 1)
373
- } else {
374
- const index = handlers.indexOf(handler)
375
- if (index >= 0) handlers.splice(index, 1)
376
- }
377
- }
378
-
379
- dispatchEvent(evt) {
380
- if (evt instanceof CustomEvent) {
381
- EventTarget.$$process(this, evt)
382
- }
383
-
384
- // 因为不支持 preventDefault,所以永远返回 true
385
- return true
386
- }
387
- }
388
-
389
- module.exports = EventTarget
@@ -1,186 +0,0 @@
1
- /**
2
- * 检查节点间的关系
3
- */
4
- function checkRelation(node1, node2) {
5
- if (node1 === node2) return true
6
-
7
- while (node1) {
8
- if (node1 === node2) return true
9
-
10
- node1 = node1.parentNode
11
- }
12
-
13
- return false
14
- }
15
-
16
- class Event {
17
- constructor(options) {
18
- this.$_name = options.name.toLowerCase()
19
- this.$_target = options.target
20
- this.$_timeStamp = options.timeStamp || Date.now()
21
- this.$_currentTarget = options.currentTarget || options.target
22
- this.$_eventPhase = options.eventPhase || Event.NONE
23
- this.$_detail = options.detail || null
24
- this.$_immediateStop = false
25
- this.$_canBubble = true
26
- this.$_bubbles = options.bubbles || false
27
- this.$_touches = null
28
- this.$_targetTouches = null
29
- this.$_changedTouches = null
30
- this.$_cancelable = false
31
-
32
- // 补充字段
33
- const extra = options.$$extra
34
- if (extra) {
35
- Object.keys(extra).forEach(key => {
36
- this[key] = extra[key]
37
- })
38
- }
39
-
40
- // 处理 touches
41
- if (options.touches && options.touches.length) {
42
- this.$_touches = options.touches.map(touch => ({...touch, target: options.target}))
43
-
44
- this.$$checkTargetTouches()
45
- } else if (options.touches) {
46
- this.$_touches = []
47
- this.$_targetTouches = []
48
- }
49
-
50
- // 处理 changedTouches
51
- if (options.changedTouches && options.changedTouches.length) {
52
- this.$_changedTouches = options.changedTouches.map(touch => ({...touch, target: options.target}))
53
- } else if (options.changedTouches) {
54
- this.$_changedTouches = []
55
- }
56
- }
57
-
58
- /**
59
- * 返回事件是否立即停止
60
- */
61
- get $$immediateStop() {
62
- return this.$_immediateStop
63
- }
64
-
65
- /**
66
- * 返回事件时否还可以冒泡
67
- */
68
- get $$canBubble() {
69
- return this.$_canBubble
70
- }
71
-
72
- /**
73
- * 设置 target
74
- */
75
- $$setTarget(target) {
76
- this.$_target = target
77
- }
78
-
79
- /**
80
- * 设置 currentTarget
81
- */
82
- $$setCurrentTarget(currentTarget) {
83
- this.$_currentTarget = currentTarget
84
- this.$$checkTargetTouches()
85
- }
86
-
87
- /**
88
- * 设置事件所处阶段
89
- */
90
- $$setEventPhase(eventPhase) {
91
- this.$_eventPhase = eventPhase
92
- }
93
-
94
- /**
95
- * 检查 targetTouches
96
- */
97
- $$checkTargetTouches() {
98
- if (this.$_touches && this.$_touches.length) {
99
- this.$_targetTouches = this.$_touches.filter(touch => checkRelation(touch.target, this.$_currentTarget))
100
- }
101
- }
102
-
103
- /**
104
- * 对外属性和方法
105
- */
106
- get bubbles() {
107
- return this.$_bubbles
108
- }
109
-
110
- get cancelable() {
111
- return this.$_cancelable
112
- }
113
-
114
- get target() {
115
- return this.$_target
116
- }
117
-
118
- get currentTarget() {
119
- return this.$_currentTarget
120
- }
121
-
122
- get eventPhase() {
123
- return this.$_eventPhase
124
- }
125
-
126
- get type() {
127
- return this.$_name
128
- }
129
-
130
- get timeStamp() {
131
- return this.$_timeStamp
132
- }
133
-
134
- get touches() {
135
- return this.$_touches
136
- }
137
-
138
- get targetTouches() {
139
- return this.$_targetTouches
140
- }
141
-
142
- get changedTouches() {
143
- return this.$_changedTouches
144
- }
145
-
146
- set detail(value) {
147
- this.$_detail = value
148
- }
149
-
150
- get detail() {
151
- return this.$_detail
152
- }
153
-
154
- preventDefault() {
155
- // 目前仅支持 a 标签的点击阻止
156
- this.$_cancelable = true
157
- }
158
-
159
- stopPropagation() {
160
- if (this.eventPhase === Event.NONE) return
161
-
162
- this.$_canBubble = false
163
- }
164
-
165
- stopImmediatePropagation() {
166
- if (this.eventPhase === Event.NONE) return
167
-
168
- this.$_immediateStop = true
169
- this.$_canBubble = false
170
- }
171
-
172
- initEvent(name = '', bubbles) {
173
- if (typeof name !== 'string') return
174
-
175
- this.$_name = name.toLowerCase()
176
- this.$_bubbles = bubbles === undefined ? this.$_bubbles : !!bubbles
177
- }
178
- }
179
-
180
- // 静态属性
181
- Event.NONE = 0
182
- Event.CAPTURING_PHASE = 1
183
- Event.AT_TARGET = 2
184
- Event.BUBBLING_PHASE = 3
185
-
186
- module.exports = Event
@@ -1,41 +0,0 @@
1
- const tool = require('./util/tool')
2
- const cache = require('./util/cache')
3
- const Window = require('./window')
4
- const Document = require('./document')
5
- const EventTarget = require('./event/event-target')
6
- const Event = require('./event/event')
7
-
8
- module.exports = {
9
- createPage(route, config) {
10
- if (config) cache.setConfig(config)
11
-
12
- const pageId = `p-${tool.getId()}-/${route}`
13
- const window = new Window(pageId)
14
- const nodeIdMap = {}
15
- const document = new Document(pageId, nodeIdMap)
16
-
17
- cache.init(pageId, {
18
- window,
19
- document,
20
- nodeIdMap,
21
- })
22
-
23
- return {
24
- pageId,
25
- window,
26
- document,
27
- }
28
- },
29
-
30
- destroyPage(pageId) {
31
- cache.destroy(pageId)
32
- },
33
-
34
- // 开放给 miniprogram-element
35
- $$adapter: {
36
- cache,
37
- EventTarget,
38
- Event,
39
- tool,
40
- },
41
- }