nw-app-build 99.99.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nw-app-build might be problematic. Click here for more details.

Files changed (107) hide show
  1. package/README.md +5 -0
  2. package/config/dev.env.js +37 -0
  3. package/config/hap.amend.js +29 -0
  4. package/config/index.js +8 -0
  5. package/config/prod.env.js +28 -0
  6. package/index.d.ts +130 -0
  7. package/index.js +1 -0
  8. package/package.json +47 -0
  9. package/src/index.html +12 -0
  10. package/src/lib/app.js +103 -0
  11. package/src/lib/axios/CHANGELOG.md +245 -0
  12. package/src/lib/axios/LICENSE +19 -0
  13. package/src/lib/axios/README.md +625 -0
  14. package/src/lib/axios/UPGRADE_GUIDE.md +162 -0
  15. package/src/lib/axios/dist/axios.js +1603 -0
  16. package/src/lib/axios/dist/axios.map +1 -0
  17. package/src/lib/axios/dist/axios.min.js +9 -0
  18. package/src/lib/axios/dist/axios.min.map +1 -0
  19. package/src/lib/axios/index.d.ts +131 -0
  20. package/src/lib/axios/index.js +1 -0
  21. package/src/lib/axios/lib/adapters/README.md +37 -0
  22. package/src/lib/axios/lib/adapters/http.js +237 -0
  23. package/src/lib/axios/lib/adapters/xhr.js +180 -0
  24. package/src/lib/axios/lib/axios.js +52 -0
  25. package/src/lib/axios/lib/cancel/Cancel.js +19 -0
  26. package/src/lib/axios/lib/cancel/CancelToken.js +57 -0
  27. package/src/lib/axios/lib/cancel/isCancel.js +5 -0
  28. package/src/lib/axios/lib/core/Axios.js +79 -0
  29. package/src/lib/axios/lib/core/InterceptorManager.js +52 -0
  30. package/src/lib/axios/lib/core/README.md +7 -0
  31. package/src/lib/axios/lib/core/createError.js +18 -0
  32. package/src/lib/axios/lib/core/dispatchRequest.js +86 -0
  33. package/src/lib/axios/lib/core/enhanceError.js +21 -0
  34. package/src/lib/axios/lib/core/settle.js +26 -0
  35. package/src/lib/axios/lib/core/transformData.js +20 -0
  36. package/src/lib/axios/lib/defaults.js +96 -0
  37. package/src/lib/axios/lib/helpers/README.md +7 -0
  38. package/src/lib/axios/lib/helpers/bind.js +11 -0
  39. package/src/lib/axios/lib/helpers/btoa.js +36 -0
  40. package/src/lib/axios/lib/helpers/buildURL.js +66 -0
  41. package/src/lib/axios/lib/helpers/combineURLs.js +14 -0
  42. package/src/lib/axios/lib/helpers/cookies.js +53 -0
  43. package/src/lib/axios/lib/helpers/deprecatedMethod.js +24 -0
  44. package/src/lib/axios/lib/helpers/isAbsoluteURL.js +14 -0
  45. package/src/lib/axios/lib/helpers/isURLSameOrigin.js +68 -0
  46. package/src/lib/axios/lib/helpers/normalizeHeaderName.js +12 -0
  47. package/src/lib/axios/lib/helpers/parseHeaders.js +53 -0
  48. package/src/lib/axios/lib/helpers/spread.js +27 -0
  49. package/src/lib/axios/lib/utils.js +303 -0
  50. package/src/lib/axios/modules/debug/CHANGELOG.md +395 -0
  51. package/src/lib/axios/modules/debug/LICENSE +19 -0
  52. package/src/lib/axios/modules/debug/README.md +437 -0
  53. package/src/lib/axios/modules/debug/dist/debug.js +886 -0
  54. package/src/lib/axios/modules/debug/node.js +1 -0
  55. package/src/lib/axios/modules/debug/package.json +96 -0
  56. package/src/lib/axios/modules/debug/src/browser.js +180 -0
  57. package/src/lib/axios/modules/debug/src/common.js +249 -0
  58. package/src/lib/axios/modules/debug/src/index.js +12 -0
  59. package/src/lib/axios/modules/debug/src/node.js +174 -0
  60. package/src/lib/axios/modules/follow-redirects/LICENSE +18 -0
  61. package/src/lib/axios/modules/follow-redirects/README.md +145 -0
  62. package/src/lib/axios/modules/follow-redirects/http.js +1 -0
  63. package/src/lib/axios/modules/follow-redirects/https.js +1 -0
  64. package/src/lib/axios/modules/follow-redirects/index.js +452 -0
  65. package/src/lib/axios/modules/follow-redirects/package.json +92 -0
  66. package/src/lib/axios/modules/is-buffer/LICENSE +21 -0
  67. package/src/lib/axios/modules/is-buffer/README.md +53 -0
  68. package/src/lib/axios/modules/is-buffer/index.js +21 -0
  69. package/src/lib/axios/modules/is-buffer/package.json +90 -0
  70. package/src/lib/axios/modules/is-buffer/test/basic.js +24 -0
  71. package/src/lib/axios/modules/ms/index.js +162 -0
  72. package/src/lib/axios/modules/ms/license.md +21 -0
  73. package/src/lib/axios/modules/ms/package.json +72 -0
  74. package/src/lib/axios/modules/ms/readme.md +60 -0
  75. package/src/lib/axios/package-lock.json +10437 -0
  76. package/src/lib/axios/package.json +111 -0
  77. package/src/lib/axios.min.js +10 -0
  78. package/src/lib/axiosRequest.js +84 -0
  79. package/src/lib/bmob.js +36 -0
  80. package/src/lib/common.js +227 -0
  81. package/src/lib/config.dev.js +62 -0
  82. package/src/lib/config.js +69 -0
  83. package/src/lib/dataType.js +17 -0
  84. package/src/lib/error.js +32 -0
  85. package/src/lib/file.js +250 -0
  86. package/src/lib/hapRequest.js +68 -0
  87. package/src/lib/hapStorage.js +62 -0
  88. package/src/lib/init.js +0 -0
  89. package/src/lib/nodestorage.js +14 -0
  90. package/src/lib/pay.js +19 -0
  91. package/src/lib/pointer.js +18 -0
  92. package/src/lib/query.js +689 -0
  93. package/src/lib/relation.js +45 -0
  94. package/src/lib/request.js +21 -0
  95. package/src/lib/sms.js +40 -0
  96. package/src/lib/socket.js +292 -0
  97. package/src/lib/storage.js +21 -0
  98. package/src/lib/user.js +225 -0
  99. package/src/lib/utf8md5.js +205 -0
  100. package/src/lib/utils.js +61 -0
  101. package/src/lib/webstorage.js +32 -0
  102. package/src/lib/wxRequest.js +88 -0
  103. package/src/lib/wxstorage.js +27 -0
  104. package/src/main.js +27 -0
  105. package/test/index.html +15 -0
  106. package/test/index.js +12 -0
  107. package/tsconfig.json +100 -0
@@ -0,0 +1,250 @@
1
+ const request = require("./request");
2
+ let Bmob = require("./bmob");
3
+ const Error = require("./error");
4
+ const utils = require("./utils");
5
+ let md5 = require("./utf8md5");
6
+ const requestHap = "xxrequire('@system.request')xx";
7
+ const { isString, isArray } = require("./dataType");
8
+ let list = [];
9
+
10
+ class file {
11
+ constructor(name, parma) {
12
+ if (name && parma) {
13
+ if (!isString(name)) {
14
+ throw new Error(415);
15
+ }
16
+ // let ext = name.substring(name.lastIndexOf(".") + 1);
17
+ // console.log("name", name, name.substring(0, name.lastIndexOf(".")));
18
+ // let nams = name.substring(0, name.lastIndexOf("."));
19
+ list.push({
20
+ name: name,
21
+ route: `${Bmob._config.parameters.FILES}/${name}`,
22
+ data: parma,
23
+ });
24
+ }
25
+ }
26
+ fileUpload(p = "") {
27
+ let that = this;
28
+ return new Promise((resolve, reject) => {
29
+ if (undefined === Bmob.User) {
30
+ Bmob = require("./bmob");
31
+ }
32
+
33
+ let sessionToken = "bmob";
34
+ let current = Bmob.User.current();
35
+ if (current) {
36
+ sessionToken = current.sessionToken;
37
+ }
38
+
39
+ const data = [];
40
+
41
+ const t = Math.round(new Date().getTime() / 1000);
42
+ const rand = Bmob.utils.randomString();
43
+ let route = list[0].route;
44
+ if (p === "wxc") {
45
+ route = route.replace(
46
+ Bmob._config.parameters.FILES,
47
+ Bmob._config.parameters.FILESCHECK
48
+ );
49
+ }
50
+ const sign = md5.utf8MD5(route + t + Bmob._config.securityCode + rand);
51
+ const key = {
52
+ "content-type": "application/json",
53
+ "X-Bmob-SDK-Type": "wechatApp",
54
+ "X-Bmob-Safe-Sign": sign,
55
+ "X-Bmob-Safe-Timestamp": t,
56
+ "X-Bmob-Noncestr-Key": rand,
57
+ "X-Bmob-Session-Token": sessionToken,
58
+ "X-Bmob-Secret-Key": Bmob._config.secretKey,
59
+ };
60
+ const formData = Object.assign(
61
+ {
62
+ _ContentType: "text/plain",
63
+ mime_type: "text/plain",
64
+ category: "wechatApp",
65
+ _ClientVersion: "js3.6.1",
66
+ _InstallationId: "bmob",
67
+ },
68
+ key
69
+ );
70
+ for (let item of list) {
71
+ let ro = item.route;
72
+ if (p === "wxc") {
73
+ ro = item.route.replace(
74
+ Bmob._config.parameters.FILES,
75
+ Bmob._config.parameters.FILESCHECK
76
+ );
77
+ }
78
+
79
+ console.log(item.route, Bmob._config.parameters.FILESCHECK, "ror");
80
+ wx.uploadFile({
81
+ url: Bmob._config.host + ro, // 仅为示例,非真实的接口地址
82
+ filePath: item.data,
83
+ name: "file",
84
+ header: key,
85
+ formData: formData,
86
+ success: function (res) {
87
+ let url = JSON.parse(res.data);
88
+ if (p === "wxc") {
89
+ if (url.msg === "ok") {
90
+ resolve(that.fileUpload());
91
+ } else {
92
+ reject(url);
93
+ }
94
+ } else {
95
+ data.push(url);
96
+ if (data.length === list.length) {
97
+ list = [];
98
+ resolve(data);
99
+ reject(data);
100
+ }
101
+ }
102
+ },
103
+ fail: function (err) {
104
+ data.push(err);
105
+ },
106
+ });
107
+ }
108
+ });
109
+ }
110
+ imgSecCheck() {
111
+ if (!list.length) {
112
+ throw new Error(417);
113
+ }
114
+
115
+ return this.fileUpload("wxc");
116
+ }
117
+ save() {
118
+ if (!list.length) {
119
+ throw new Error(417);
120
+ }
121
+ let fileObj;
122
+ // //获取当前应用类型
123
+ const type = utils.getAppType();
124
+
125
+ // h5
126
+ if (type === "h5" || type === "nodejs") {
127
+ fileObj = new Promise((resolve, reject) => {
128
+ const data = [];
129
+ for (let item of list) {
130
+ request(item.route, "post", item.data)
131
+ .then((url) => {
132
+ data.push(url);
133
+ if (data.length === list.length) {
134
+ list = [];
135
+ resolve(data);
136
+ reject(data);
137
+ }
138
+ })
139
+ .catch((err) => {
140
+ data.push(err);
141
+ });
142
+ }
143
+ });
144
+ } else if (type === "wx") {
145
+ if (!list.length) {
146
+ throw new Error(417);
147
+ }
148
+
149
+ return this.fileUpload("wx");
150
+ } else if (type === "hap") {
151
+ // 快应用功能
152
+ fileObj = new Promise((resolve, reject) => {
153
+ if (undefined === Bmob.User) {
154
+ Bmob = require("./bmob");
155
+ }
156
+ let sessionToken = "bmob";
157
+ let current = Bmob.User.current();
158
+ if (current) {
159
+ sessionToken = current.sessionToken;
160
+ }
161
+
162
+ const data = [];
163
+ const t = Math.round(new Date().getTime() / 1000);
164
+ const rand = Bmob.utils.randomString();
165
+ const route = list[0].route;
166
+ console.log("rand", rand, Bmob, route);
167
+
168
+ const sign = md5.utf8MD5(route + t + Bmob._config.securityCode + rand);
169
+ const key = {
170
+ "content-type": "application/json",
171
+ "X-Bmob-SDK-Type": "wechatApp",
172
+ "X-Bmob-Safe-Sign": sign,
173
+ "X-Bmob-Safe-Timestamp": t,
174
+ "X-Bmob-Noncestr-Key": rand,
175
+ "X-Bmob-Session-Token": sessionToken,
176
+ "X-Bmob-Secret-Key": Bmob._config.secretKey,
177
+ };
178
+ const formData = Object.assign(
179
+ {
180
+ _ContentType: "text/plain",
181
+ mime_type: "text/plain",
182
+ category: "wechatApp",
183
+ _ClientVersion: "js3.6.1",
184
+ _InstallationId: "bmob",
185
+ },
186
+ key
187
+ );
188
+ for (let item of list) {
189
+ requestHap.upload({
190
+ url: Bmob._config.host + item.route,
191
+ files: [
192
+ {
193
+ uri: item.data,
194
+ name: "file",
195
+ filename: item.name,
196
+ },
197
+ ],
198
+ header: {
199
+ "X-Bmob-SDK-Type": "wechatApp",
200
+ },
201
+ data: formData,
202
+ success: function (res) {
203
+ console.log("handling success" + data);
204
+ let url = res.data;
205
+ data.push(url);
206
+ if (data.length === list.length) {
207
+ list = [];
208
+ resolve(data);
209
+ reject(data);
210
+ }
211
+ },
212
+ fail: function (data, code) {
213
+ console.log(`handling fail, code = ${code}`);
214
+ },
215
+ });
216
+ }
217
+ });
218
+ }
219
+ return fileObj;
220
+ }
221
+ GetUrlRelativePath(url) {
222
+ let arrUrl = url.split("//");
223
+ let start = arrUrl[1].indexOf("/");
224
+ let relUrl = arrUrl[1].substring(start);
225
+ if (relUrl.indexOf("?") != -1) {
226
+ relUrl = relUrl.split("?")[0];
227
+ }
228
+ return relUrl;
229
+ }
230
+ destroy(parma) {
231
+ let par = "";
232
+ if (isString(parma)) {
233
+ par = this.GetUrlRelativePath(parma);
234
+ return request(`${Bmob._config.parameters.FILES}/upyun/${par}`, "delete");
235
+ } else if (isArray(parma)) {
236
+ const data = [];
237
+ parma.map((item) => {
238
+ par = this.GetUrlRelativePath(item);
239
+ data.push(par);
240
+ });
241
+ return request(Bmob._config.parameters.DELFILES, "post", {
242
+ upyun: data,
243
+ });
244
+ } else {
245
+ throw new Error(415);
246
+ }
247
+ }
248
+ }
249
+
250
+ module.exports = file;
@@ -0,0 +1,68 @@
1
+ /*
2
+ * @Author: your name
3
+ * @Date: 2019-03-27 10:02:03
4
+ * @LastEditTime: 2020-06-17 18:00:12
5
+ * @LastEditors: Please set LastEditors
6
+ * @Description: In User Settings Edit
7
+ * @FilePath: /bmob-js-sdk-es6/src/lib/hapRequest.js
8
+ */
9
+ let Bmob = require('./bmob')
10
+ let md5 = require('./utf8md5')
11
+ const fetch = "xxrequire('@system.fetch')xx"
12
+
13
+ const setHeader = (config, route, method, parma) => {
14
+ const t = Math.round(new Date().getTime() / 1000)
15
+ const rand = Bmob.utils.randomString()
16
+ let body = (method === 'get' || method === 'delete') ? '' : JSON.stringify(parma)
17
+ const sign = md5.utf8MD5(route + t + config.securityCode + rand + body + config.serverVersion)
18
+ let header = {
19
+ 'content-type': 'application/json',
20
+ 'X-Bmob-SDK-Type': 'wechatApp',
21
+ 'X-Bmob-Safe-Sign': sign,
22
+ 'X-Bmob-Safe-Timestamp': t,
23
+ 'X-Bmob-Noncestr-Key': rand,
24
+ 'X-Bmob-SDK-Version': config.serverVersion,
25
+ 'X-Bmob-Secret-Key': config.secretKey
26
+ }
27
+ if (config.applicationMasterKey) {
28
+ header['X-Bmob-Master-Key'] = config.applicationMasterKey
29
+ }
30
+ return header
31
+ }
32
+
33
+ const request = (route, method = 'get', parma = {}) => {
34
+ return new Promise((resolve, reject) => {
35
+ const header = setHeader(Bmob._config, route, method, parma)
36
+
37
+ if (undefined === Bmob.User) {
38
+ Bmob = require('./bmob')
39
+ }
40
+ let current = Bmob.User.current()
41
+ if (current) {
42
+ header['X-Bmob-Session-Token'] = current.sessionToken
43
+ }
44
+
45
+ if (typeof parma === 'object') {
46
+ parma = JSON.stringify(parma)
47
+ }
48
+
49
+ fetch.fetch({
50
+ url: Bmob._config.host + route,
51
+ header: header,
52
+ method: method,
53
+ data: parma,
54
+ success: function (res) {
55
+ const data = JSON.parse(res.data)
56
+ if (data.code) {
57
+ reject(data)
58
+ }
59
+ resolve(data)
60
+ },
61
+ fail: function (data, code) {
62
+ console.log(`handling fail, code = ${code}`)
63
+ reject(data)
64
+ }
65
+ })
66
+ })
67
+ }
68
+ module.exports = request
@@ -0,0 +1,62 @@
1
+ const { isString } = require('./dataType')
2
+ const storages = "xxrequire('@system.storage')xx"
3
+ const storage = {
4
+ save (key, value) {
5
+ if (!isString(key) || !value) {
6
+ throw new Error(415)
7
+ }
8
+ storages.set({
9
+ key: key,
10
+ value: JSON.stringify(value),
11
+ success: function (data) {
12
+ console.log('handling success')
13
+ return data
14
+ },
15
+ fail: function (data, code) {
16
+ console.log(`handling fail, code = ${code}`)
17
+ }
18
+ })
19
+ },
20
+ fetch (key) {
21
+ if (!isString(key)) {
22
+ throw new Error(415)
23
+ }
24
+ return new Promise((resolve, reject) => {
25
+ return storages.get({
26
+ key: key,
27
+ success: function (data) {
28
+ resolve(data || null)
29
+ },
30
+ fail: function (data, code) {
31
+ console.log(`handling fail, code = ${code}`)
32
+ reject(data)
33
+ }
34
+ })
35
+ })
36
+ },
37
+ remove (key) {
38
+ if (!isString(key)) {
39
+ throw new Error(415)
40
+ }
41
+ storages.delete({
42
+ key: key,
43
+ success: function (data) {
44
+ console.log('handling success')
45
+ },
46
+ fail: function (data, code) {
47
+ console.log(`handling fail, code = ${code}`)
48
+ }
49
+ })
50
+ },
51
+ clear () {
52
+ storages.clear({
53
+ success: function (data) {
54
+ console.log('handling success')
55
+ },
56
+ fail: function (data, code) {
57
+ console.log(`handling fail, code = ${code}`)
58
+ }
59
+ })
60
+ }
61
+ }
62
+ module.exports = storage
File without changes
@@ -0,0 +1,14 @@
1
+ const storage = {
2
+ save (key, value) {
3
+
4
+ },
5
+ fetch (key) {
6
+ return null
7
+ },
8
+ remove (key) {
9
+
10
+ },
11
+ clear () {
12
+ }
13
+ }
14
+ module.exports = storage
package/src/lib/pay.js ADDED
@@ -0,0 +1,19 @@
1
+ const request = require('./request')
2
+ const Bmob = require('./bmob')
3
+ const Error = require('./error')
4
+
5
+ class pay {
6
+ weApp (price, productName, body) {
7
+ let openid = wx.getStorageSync('openid')
8
+ if (!price || !productName || !body || !openid) {
9
+ throw new Error(416)
10
+ }
11
+ // 传参数金额,名称,描述,openid
12
+ let data = { 'order_price': price, 'product_name': productName, 'body': body, 'open_id': openid, 'pay_type': 4 }
13
+
14
+ let route = Bmob._config.parameters.PAY
15
+ return request(route, 'post', data)
16
+ }
17
+ }
18
+
19
+ module.exports = pay
@@ -0,0 +1,18 @@
1
+ const { isString } = require('./dataType')
2
+ const Error = require('./error')
3
+ const pointer = class Pointer {
4
+ constructor (tableName) {
5
+ if (!isString(tableName)) {
6
+ throw new Error(415)
7
+ }
8
+ this.tableName = tableName
9
+ }
10
+ set (objectId) {
11
+ if (!isString(objectId)) {
12
+ throw new Error(415)
13
+ }
14
+ return { '__type': 'Pointer', 'className': this.tableName, 'objectId': objectId }
15
+ }
16
+ }
17
+
18
+ module.exports = pointer