@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,101 +0,0 @@
1
- const cache = require('../util/cache')
2
-
3
- let pageUrlRouteMap = null
4
-
5
- class Miniprogram {
6
- constructor(pageId) {
7
- this.$_pageId = pageId
8
- this.$_pageUrl = '' // 页面真实 url
9
- this.$_subpackagesMap = {} // 分包名映射表
10
- }
11
-
12
- get window() {
13
- return cache.getWindow(this.$_pageId) || null
14
- }
15
-
16
- get document() {
17
- return cache.getDocument(this.$_pageId) || null
18
- }
19
-
20
- get config() {
21
- return cache.getConfig()
22
- }
23
-
24
- get subpackagesMap() {
25
- return this.$_subpackagesMap
26
- }
27
-
28
- /**
29
- * 初始化
30
- */
31
- init(url) {
32
- if (typeof url === 'string') this.$_pageUrl = url // 设置真实 url
33
- const {
34
- origin, entry, router, runtime = {}
35
- } = cache.getConfig()
36
- const subpackagesMap = runtime.subpackagesMap || {}
37
-
38
- this.$_pageUrl = this.$_pageUrl || (origin + entry)
39
- this.$_subpackagesMap = subpackagesMap
40
- this.window.location.$$reset(this.$_pageUrl)
41
- this.window.history.$$reset()
42
-
43
- if (!pageUrlRouteMap) {
44
- // 需要初始化页面 url - 小程序页面路由映射表
45
- pageUrlRouteMap = {}
46
-
47
- Object.keys(router).forEach(pageName => {
48
- const regexpList = []
49
-
50
- router[pageName].forEach(pathObj => {
51
- // 构造正则表达式
52
- const regexp = new RegExp(pathObj.regexp, pathObj.options)
53
- regexpList.push(regexp)
54
- })
55
-
56
- // 将每个页面的路由改造成函数,方便后续做匹配用
57
- pageUrlRouteMap[pageName] = pathname => {
58
- for (const regexp of regexpList) {
59
- const parseRes = regexp.exec(pathname)
60
- regexp.lastIndex = 0
61
-
62
- if (parseRes) {
63
- // 匹配成功
64
- const packageName = subpackagesMap[pageName]
65
- return `/${packageName ? packageName + '/' : ''}pages/${pageName}/index`
66
- }
67
- }
68
-
69
- return null
70
- }
71
- })
72
- }
73
- }
74
-
75
- /**
76
- * 需要匹配对应路由的 route
77
- */
78
- getMatchRoute(pathname) {
79
- const keys = Object.keys(pageUrlRouteMap)
80
- for (const key of keys) {
81
- const matchRes = pageUrlRouteMap[key](pathname)
82
-
83
- if (matchRes) return matchRes // 匹配成功
84
- }
85
-
86
- return null
87
- }
88
-
89
- /**
90
- * 判断是否 tabBar 页面
91
- */
92
- isTabBarPage(pageRoute) {
93
- const {
94
- runtime = {}
95
- } = cache.getConfig()
96
- const tabBarMap = runtime.tabBarMap || {}
97
- return !!tabBarMap[pageRoute]
98
- }
99
- }
100
-
101
- module.exports = Miniprogram
@@ -1,80 +0,0 @@
1
- class Navigator {
2
- constructor() {
3
- this.$_language = ''
4
- this.$_wxVersion = ''
5
- this.$_brand = '' // 手机品牌
6
- this.$_model = '' // 手机型号
7
- this.$_platform = ''
8
- this.$_system = '' // 操作系统版本
9
-
10
- this.$_userAgent = ''
11
- }
12
-
13
- /**
14
- * 重置实例
15
- */
16
- $$reset(info) {
17
- this.$_language = info.language
18
- this.$_wxVersion = info.version
19
- this.$_brand = info.brand
20
- this.$_model = info.model
21
- this.$_platform = info.platform
22
- this.$_system = info.system
23
-
24
- // 拼装 userAgent
25
- const appVersion = '5.0'
26
- const appleWebKitVersion = '602.3.12'
27
- let platformContext
28
- if (this.$_platform === 'ios') {
29
- // 拆分系统版本号
30
- let systemVersion = this.$_system.split(' ')
31
- if (systemVersion.length >= 2) {
32
- systemVersion = systemVersion[1].split('.').join('_')
33
- } else {
34
- systemVersion = ''
35
- }
36
-
37
- platformContext = `${this.$_brand}; CPU ${this.$_brand} OS ${systemVersion} like Mac OS X`
38
- } else if (this.$_platform === 'android') {
39
- platformContext = `Linux; ${this.$_system}; ${this.$_model}`
40
- } else {
41
- // 在开发者工具上,默认在 windows x64 上运行
42
- platformContext = 'Windows NT 6.1; win64; x64'
43
- }
44
-
45
- this.$_userAgent = `${this.appCodeName}/${appVersion} (${platformContext}) AppleWebKit/${appleWebKitVersion} (KHTML, like Gecko) Mobile MicroMessenger/${this.$_wxVersion} Language/${this.language}`
46
- }
47
-
48
- /**
49
- * 对外属性和方法
50
- */
51
- get userAgent() {
52
- return this.$_userAgent
53
- }
54
-
55
- get appCodeName() {
56
- return 'Mozilla'
57
- }
58
-
59
- get appName() {
60
- return 'Netscape'
61
- }
62
-
63
- get language() {
64
- return this.$_language
65
- }
66
-
67
- get languages() {
68
- return [this.$_language]
69
- }
70
-
71
- get platform() {
72
- return this.$_platform
73
- }
74
-
75
- get product() {
76
- return 'Gecko'
77
- }
78
- }
79
-
80
- module.exports = Navigator
@@ -1,28 +0,0 @@
1
- class Performance {
2
- constructor(timeOrigin) {
3
- this.$_timeOrigin = timeOrigin
4
- }
5
-
6
- /**
7
- * 对外属性和方法
8
- */
9
- get navigation() {
10
- console.warn('performance.navigation is not supported')
11
- return null
12
- }
13
-
14
- get timing() {
15
- console.warn('performance.timing is not supported')
16
- return null
17
- }
18
-
19
- get timeOrigin() {
20
- return this.$_timeOrigin
21
- }
22
-
23
- now() {
24
- return +new Date() - this.$_timeOrigin
25
- }
26
- }
27
-
28
- module.exports = Performance
@@ -1,31 +0,0 @@
1
- const EventTarget = require('../event/event-target')
2
-
3
- class Screen extends EventTarget {
4
- constructor() {
5
- super()
6
-
7
- this.$_width = 0
8
- this.$_height = 0
9
- }
10
-
11
- /**
12
- * 重置实例
13
- */
14
- $$reset(info) {
15
- this.$_width = info.screenWidth
16
- this.$_height = info.screenHeight
17
- }
18
-
19
- /**
20
- * 对外属性和方法
21
- */
22
- get width() {
23
- return this.$_width
24
- }
25
-
26
- get height() {
27
- return this.$_height
28
- }
29
- }
30
-
31
- module.exports = Screen
@@ -1,96 +0,0 @@
1
- const Event = require('../event/event')
2
-
3
- class SessionStorage {
4
- constructor(window) {
5
- this.$_keys = []
6
- this.$_map = {}
7
- this.$_window = window
8
- }
9
-
10
- /**
11
- * 触发 window 的 storage 事件
12
- */
13
- $_triggerStorage(key, newValue, oldValue, force) {
14
- if (!force && newValue === oldValue) return
15
-
16
- const pages = getCurrentPages() || []
17
- pages.forEach(page => {
18
- if (page && page.window && page.window !== this.$_window) {
19
- page.window.$$trigger('storage', {
20
- event: new Event({
21
- name: 'storage',
22
- target: page.window,
23
- $$extra: {
24
- key,
25
- newValue,
26
- oldValue,
27
- storageArea: this,
28
- url: this.$_window.location.href,
29
- }
30
- })
31
- })
32
- }
33
- })
34
- }
35
-
36
- /**
37
- * 对外属性和方法
38
- */
39
- get length() {
40
- return this.$_keys.length
41
- }
42
-
43
- key(num) {
44
- if (typeof num !== 'number' || !isFinite(num) || num < 0) return null
45
-
46
- return this.$_keys[num] || null
47
- }
48
-
49
- getItem(key) {
50
- if (!key || typeof key !== 'string') return null
51
-
52
- return this.$_map[key] || null
53
- }
54
-
55
- setItem(key, data) {
56
- if (!key || typeof key !== 'string') return
57
- data = '' + data
58
-
59
- const oldValue = this.$_map[key] || null
60
-
61
- this.$_map[key] = data
62
-
63
- // 调整顺序
64
- const index = this.$_keys.indexOf(key)
65
- if (index >= 0) this.$_keys.splice(index, 1)
66
- this.$_keys.push(key)
67
-
68
- this.$_triggerStorage(key, data, oldValue)
69
- }
70
-
71
- removeItem(key) {
72
- if (!key || typeof key !== 'string') return
73
-
74
- const oldValue = this.$_map[key] || null
75
-
76
- delete this.$_map[key]
77
-
78
- // 删除 key
79
- const index = this.$_keys.indexOf(key)
80
- if (index >= 0) this.$_keys.splice(index, 1)
81
-
82
- this.$_triggerStorage(key, null, oldValue)
83
- }
84
-
85
- clear() {
86
- this.$_keys.forEach(key => {
87
- delete this.$_map[key]
88
- })
89
-
90
- this.$_keys.length = 0
91
-
92
- this.$_triggerStorage(null, null, null, true)
93
- }
94
- }
95
-
96
- module.exports = SessionStorage
@@ -1,290 +0,0 @@
1
- const EventTarget = require('../event/event-target')
2
-
3
- const SUPPORT_METHOD = ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT']
4
- const STATUS_TEXT_MAP = {
5
- 100: 'Continue',
6
- 101: 'Switching protocols',
7
-
8
- 200: 'OK',
9
- 201: 'Created',
10
- 202: 'Accepted',
11
- 203: 'Non-Authoritative Information',
12
- 204: 'No Content',
13
- 205: 'Reset Content',
14
- 206: 'Partial Content',
15
-
16
- 300: 'Multiple Choices',
17
- 301: 'Moved Permanently',
18
- 302: 'Found',
19
- 303: 'See Other',
20
- 304: 'Not Modified',
21
- 305: 'Use Proxy',
22
- 307: 'Temporary Redirect',
23
-
24
- 400: 'Bad Request',
25
- 401: 'Unauthorized',
26
- 402: 'Payment Required',
27
- 403: 'Forbidden',
28
- 404: 'Not Found',
29
- 405: 'Method Not Allowed',
30
- 406: 'Not Acceptable',
31
- 407: 'Proxy Authentication Required',
32
- 408: 'Request Timeout',
33
- 409: 'Conflict',
34
- 410: 'Gone',
35
- 411: 'Length Required',
36
- 412: 'Precondition Failed',
37
- 413: 'Request Entity Too Large',
38
- 414: 'Request-URI Too Long',
39
- 415: 'Unsupported Media Type',
40
- 416: 'Requested Range Not Suitable',
41
- 417: 'Expectation Failed',
42
-
43
- 500: 'Internal Server Error',
44
- 501: 'Not Implemented',
45
- 502: 'Bad Gateway',
46
- 503: 'Service Unavailable',
47
- 504: 'Gateway Timeout',
48
- 505: 'HTTP Version Not Supported',
49
- }
50
-
51
- class XMLHttpRequest extends EventTarget {
52
- constructor(window) {
53
- super()
54
-
55
- this.$_window = window
56
- this.$_method = ''
57
- this.$_url = ''
58
- this.$_data = null
59
- this.$_status = 0
60
- this.$_statusText = ''
61
- this.$_readyState = XMLHttpRequest.UNSENT
62
- this.$_header = {
63
- Accept: '*/*'
64
- }
65
- this.$_responseType = ''
66
- this.$_resHeader = null
67
- this.$_response = null
68
- this.$_timeout = 0
69
- this.$_startTime = null
70
-
71
- this.$_requestTask = null
72
- this.$_requestSuccess = this.$_requestSuccess.bind(this)
73
- this.$_requestFail = this.$_requestFail.bind(this)
74
- this.$_requestComplete = this.$_requestComplete.bind(this)
75
- }
76
-
77
- /**
78
- * readyState 变化
79
- */
80
- $_callReadyStateChange(readyState) {
81
- const hasChange = readyState !== this.$_readyState
82
- this.$_readyState = readyState
83
-
84
- if (hasChange) this.$$trigger('readystatechange')
85
- }
86
-
87
- /**
88
- * 执行请求
89
- */
90
- $_callRequest() {
91
- if (this.$_timeout) {
92
- this.$_startTime = +new Date()
93
-
94
- setTimeout(() => {
95
- if (!this.$_status && this.$_readyState !== XMLHttpRequest.DONE) {
96
- // 超时
97
- if (this.$_requestTask) this.$_requestTask.abort()
98
- this.$_callReadyStateChange(XMLHttpRequest.DONE)
99
- this.$$trigger('timeout')
100
- }
101
- }, this.$_timeout)
102
- }
103
-
104
- // 重置各种状态
105
- this.$_status = 0
106
- this.$_statusText = ''
107
- this.$_readyState = XMLHttpRequest.OPENED
108
- this.$_resHeader = null
109
- this.$_response = null
110
-
111
- // 头信息
112
- const header = Object.assign({}, this.$_header)
113
- if (this.$_window) {
114
- header.cookie = this.$_window.document.$$cookie
115
- }
116
-
117
- // 补完 url
118
- let url = this.$_url
119
- url = url.indexOf('//') === -1 ? this.$_window.location.origin + url : url
120
-
121
- this.$_requestTask = wx.request({
122
- url,
123
- data: this.$_data || {},
124
- header,
125
- method: this.$_method,
126
- dataType: this.$_responseType === 'json' ? 'json' : 'text',
127
- responseType: this.$_responseType === 'arraybuffer' ? 'arraybuffer' : 'text',
128
- success: this.$_requestSuccess,
129
- fail: this.$_requestFail,
130
- complete: this.$_requestComplete,
131
- })
132
- }
133
-
134
- /**
135
- * 请求成功
136
- */
137
- $_requestSuccess({data, statusCode, header}) {
138
- this.$_status = statusCode
139
- this.$_resHeader = header
140
-
141
- this.$_callReadyStateChange(XMLHttpRequest.HEADERS_RECEIVED)
142
-
143
- // 处理 set-cookie
144
- if (this.$_window) {
145
- const setCookie = header['Set-Cookie']
146
-
147
- if (setCookie && typeof setCookie === 'string') {
148
- this.$_window.document.$$setCookie(setCookie)
149
- }
150
- }
151
-
152
- // 处理返回数据
153
- if (data) {
154
- this.$_callReadyStateChange(XMLHttpRequest.LOADING)
155
- this.$$trigger('loadstart')
156
- this.$_response = data
157
- this.$$trigger('loadend')
158
- }
159
- }
160
-
161
- /**
162
- * 请求失败
163
- */
164
- $_requestFail({errMsg}) {
165
- this.$_status = 0
166
- this.$_statusText = errMsg
167
-
168
- this.$$trigger('error')
169
- }
170
-
171
- /**
172
- * 请求完成
173
- */
174
- $_requestComplete() {
175
- this.$_startTime = null
176
- this.$_requestTask = null
177
- this.$_callReadyStateChange(XMLHttpRequest.DONE)
178
-
179
- if (this.$_status) {
180
- this.$$trigger('load')
181
- }
182
- }
183
-
184
- /**
185
- * 对外属性和方法
186
- */
187
- get timeout() {
188
- return this.$_timeout
189
- }
190
-
191
- set timeout(timeout) {
192
- if (typeof timeout !== 'number' || !isFinite(timeout) || timeout <= 0) return
193
-
194
- this.$_timeout = timeout
195
- }
196
-
197
- get status() {
198
- return this.$_status
199
- }
200
-
201
- get statusText() {
202
- if (this.$_readyState === XMLHttpRequest.UNSENT || this.$_readyState === XMLHttpRequest.OPENED) return ''
203
-
204
- return STATUS_TEXT_MAP[this.$_status + ''] || this.$_statusText || ''
205
- }
206
-
207
- get readyState() {
208
- return this.$_readyState
209
- }
210
-
211
- get responseType() {
212
- return this.$_responseType
213
- }
214
-
215
- set responseType(value) {
216
- if (typeof value !== 'string') return
217
-
218
- this.$_responseType = value
219
- }
220
-
221
- get responseText() {
222
- if (!this.$_responseType || this.$_responseType === 'text') {
223
- return this.$_response
224
- }
225
-
226
- return null
227
- }
228
-
229
- get response() {
230
- return this.$_response
231
- }
232
-
233
- abort() {
234
- if (this.$_requestTask) {
235
- this.$_requestTask.abort()
236
- this.$$trigger('abort')
237
- }
238
- }
239
-
240
- getAllResponseHeaders() {
241
- if (this.$_readyState === XMLHttpRequest.UNSENT || this.$_readyState === XMLHttpRequest.OPENED || !this.$_resHeader) return ''
242
-
243
- return Object.keys(this.$_resHeader)
244
- .map(key => `${key}: ${this.$_resHeader[key]}`)
245
- .join('\r\n')
246
- }
247
-
248
- getResponseHeader(name) {
249
- if (this.$_readyState === XMLHttpRequest.UNSENT || this.$_readyState === XMLHttpRequest.OPENED || !this.$_resHeader) return null
250
-
251
- // 处理大小写不敏感
252
- const key = Object.keys(this.$_resHeader).find(item => item.toLowerCase() === name.toLowerCase())
253
- const value = key ? this.$_resHeader[key] : null
254
-
255
- return typeof value === 'string' ? value : null
256
- }
257
-
258
- open(method, url) {
259
- if (typeof method === 'string') method = method.toUpperCase()
260
-
261
- if (SUPPORT_METHOD.indexOf(method) < 0) return
262
- if (!url || typeof url !== 'string') return
263
-
264
- this.$_method = method
265
- this.$_url = url
266
-
267
- this.$_callReadyStateChange(XMLHttpRequest.OPENED)
268
- }
269
-
270
- setRequestHeader(header, value) {
271
- if (typeof header === 'string' && typeof value === 'string') {
272
- this.$_header[header] = value
273
- }
274
- }
275
-
276
- send(data) {
277
- if (this.$_readyState !== XMLHttpRequest.OPENED) return
278
-
279
- this.$_data = data
280
- this.$_callRequest()
281
- }
282
- }
283
-
284
- XMLHttpRequest.UNSENT = 0
285
- XMLHttpRequest.OPENED = 1
286
- XMLHttpRequest.HEADERS_RECEIVED = 2
287
- XMLHttpRequest.LOADING = 3
288
- XMLHttpRequest.DONE = 4
289
-
290
- module.exports = XMLHttpRequest