hylid-bridge 4.0.0-alpha.22 → 4.0.0-alpha.24
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.
- package/lib/clients/web/h5/index.d.ts +14 -1
- package/lib/common/apis/custom/web/h5/removeStorage.js +5 -6
- package/lib/common/apis/custom/web/h5/removeStorageSync.js +1 -2
- package/lib/common/apis/custom/web/h5/request.d.ts +15 -2
- package/lib/common/apis/custom/web/h5/request.js +230 -4
- package/lib/umd/index.js +1 -1
- package/lib/umd/web_h5.js +1 -1
- package/lib/whichCanIUse/compatibilities.json +1664 -0
- package/lib/whichCanIUse/index.d.ts +41 -2
- package/lib/whichCanIUse/index.js +97 -12
- package/lib/whichCanIUse/web.js +1 -1
- package/package.json +7 -6
|
@@ -68,7 +68,20 @@ declare const _default: {
|
|
|
68
68
|
removeStorageSync: (args: {
|
|
69
69
|
key: string;
|
|
70
70
|
}) => void;
|
|
71
|
-
request:
|
|
71
|
+
request: (args: {
|
|
72
|
+
url: string;
|
|
73
|
+
headers?: {
|
|
74
|
+
[key: string]: string;
|
|
75
|
+
} | undefined;
|
|
76
|
+
method?: "POST" | "GET" | undefined;
|
|
77
|
+
data?: any;
|
|
78
|
+
timeout?: number | undefined;
|
|
79
|
+
dataType?: "json" | "text" | "base64" | "arraybuffer" | undefined;
|
|
80
|
+
} & import("@hylid/types").AsyncCallback<{
|
|
81
|
+
data: any;
|
|
82
|
+
status: number;
|
|
83
|
+
headers: any;
|
|
84
|
+
}>) => void;
|
|
72
85
|
rpc: typeof rpc;
|
|
73
86
|
setClipboard: typeof setClipboard;
|
|
74
87
|
setNavigationBar: typeof setNavigationBar;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import StorageImpl from "../../../../utils/storage";
|
|
2
1
|
export default (function (opt) {
|
|
3
|
-
var
|
|
4
|
-
success =
|
|
5
|
-
fail =
|
|
6
|
-
complete =
|
|
2
|
+
var _a = opt || {},
|
|
3
|
+
success = _a.success,
|
|
4
|
+
fail = _a.fail,
|
|
5
|
+
complete = _a.complete;
|
|
7
6
|
try {
|
|
8
|
-
|
|
7
|
+
localStorage.removeItem(opt.key || '');
|
|
9
8
|
success === null || success === void 0 ? void 0 : success();
|
|
10
9
|
} catch (e) {
|
|
11
10
|
fail === null || fail === void 0 ? void 0 : fail(e);
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const _default: (args: {
|
|
2
|
+
url: string;
|
|
3
|
+
headers?: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
} | undefined;
|
|
6
|
+
method?: "POST" | "GET" | undefined;
|
|
7
|
+
data?: any;
|
|
8
|
+
timeout?: number | undefined;
|
|
9
|
+
dataType?: "json" | "text" | "base64" | "arraybuffer" | undefined;
|
|
10
|
+
} & import("@hylid/types").AsyncCallback<{
|
|
11
|
+
data: any;
|
|
12
|
+
status: number;
|
|
13
|
+
headers: any;
|
|
14
|
+
}>) => void;
|
|
15
|
+
export default _default;
|
|
@@ -1,4 +1,230 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
return __assign.apply(this, arguments);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) {
|
|
13
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
14
|
+
resolve(value);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) {
|
|
19
|
+
try {
|
|
20
|
+
step(generator.next(value));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
reject(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function rejected(value) {
|
|
26
|
+
try {
|
|
27
|
+
step(generator["throw"](value));
|
|
28
|
+
} catch (e) {
|
|
29
|
+
reject(e);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function step(result) {
|
|
33
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
34
|
+
}
|
|
35
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
39
|
+
var _ = {
|
|
40
|
+
label: 0,
|
|
41
|
+
sent: function sent() {
|
|
42
|
+
if (t[0] & 1) throw t[1];
|
|
43
|
+
return t[1];
|
|
44
|
+
},
|
|
45
|
+
trys: [],
|
|
46
|
+
ops: []
|
|
47
|
+
},
|
|
48
|
+
f,
|
|
49
|
+
y,
|
|
50
|
+
t,
|
|
51
|
+
g;
|
|
52
|
+
return g = {
|
|
53
|
+
next: verb(0),
|
|
54
|
+
"throw": verb(1),
|
|
55
|
+
"return": verb(2)
|
|
56
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
57
|
+
return this;
|
|
58
|
+
}), g;
|
|
59
|
+
function verb(n) {
|
|
60
|
+
return function (v) {
|
|
61
|
+
return step([n, v]);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function step(op) {
|
|
65
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
66
|
+
while (_) try {
|
|
67
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
68
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
+
switch (op[0]) {
|
|
70
|
+
case 0:
|
|
71
|
+
case 1:
|
|
72
|
+
t = op;
|
|
73
|
+
break;
|
|
74
|
+
case 4:
|
|
75
|
+
_.label++;
|
|
76
|
+
return {
|
|
77
|
+
value: op[1],
|
|
78
|
+
done: false
|
|
79
|
+
};
|
|
80
|
+
case 5:
|
|
81
|
+
_.label++;
|
|
82
|
+
y = op[1];
|
|
83
|
+
op = [0];
|
|
84
|
+
continue;
|
|
85
|
+
case 7:
|
|
86
|
+
op = _.ops.pop();
|
|
87
|
+
_.trys.pop();
|
|
88
|
+
continue;
|
|
89
|
+
default:
|
|
90
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
91
|
+
_ = 0;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
95
|
+
_.label = op[1];
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
99
|
+
_.label = t[1];
|
|
100
|
+
t = op;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
if (t && _.label < t[2]) {
|
|
104
|
+
_.label = t[2];
|
|
105
|
+
_.ops.push(op);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
if (t[2]) _.ops.pop();
|
|
109
|
+
_.trys.pop();
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
op = body.call(thisArg, _);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
op = [6, e];
|
|
115
|
+
y = 0;
|
|
116
|
+
} finally {
|
|
117
|
+
f = t = 0;
|
|
118
|
+
}
|
|
119
|
+
if (op[0] & 5) throw op[1];
|
|
120
|
+
return {
|
|
121
|
+
value: op[0] ? op[1] : void 0,
|
|
122
|
+
done: true
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
127
|
+
var t = {};
|
|
128
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
129
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
130
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
131
|
+
}
|
|
132
|
+
return t;
|
|
133
|
+
};
|
|
134
|
+
import { stringify } from 'qs-es5';
|
|
135
|
+
export default (function (options) {
|
|
136
|
+
var success = options.success,
|
|
137
|
+
fail = options.fail,
|
|
138
|
+
_options = __rest(options, ["success", "fail"]);
|
|
139
|
+
if (!_options) {
|
|
140
|
+
fail === null || fail === void 0 ? void 0 : fail({
|
|
141
|
+
error: -103,
|
|
142
|
+
errorMessage: "[request]: Wrong Param"
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
var convertAcceptType = function convertAcceptType() {
|
|
147
|
+
if (options.dataType === 'text') {
|
|
148
|
+
return 'text/plain';
|
|
149
|
+
}
|
|
150
|
+
return 'application/json';
|
|
151
|
+
};
|
|
152
|
+
var convertResponse = function convertResponse(response) {
|
|
153
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0:
|
|
157
|
+
if (!(options.dataType === 'text')) return [3 /*break*/, 2];
|
|
158
|
+
return [4 /*yield*/, response.text()];
|
|
159
|
+
case 1:
|
|
160
|
+
return [2 /*return*/, _a.sent()];
|
|
161
|
+
case 2:
|
|
162
|
+
return [4 /*yield*/, response.json()];
|
|
163
|
+
case 3:
|
|
164
|
+
return [2 /*return*/, _a.sent()];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
var method = options.method || 'GET';
|
|
170
|
+
var requestOptions = {
|
|
171
|
+
method: method,
|
|
172
|
+
mode: 'cors',
|
|
173
|
+
cache: 'no-cache',
|
|
174
|
+
credentials: 'include',
|
|
175
|
+
referrerPolicy: 'no-referrer',
|
|
176
|
+
headers: __assign(__assign({}, options.headers), {
|
|
177
|
+
Accept: convertAcceptType()
|
|
178
|
+
})
|
|
179
|
+
// fetch 暂不支持 timeout
|
|
180
|
+
// timeout: options.timeout,
|
|
181
|
+
};
|
|
182
|
+
var url = options.url;
|
|
183
|
+
if (method === 'GET') {
|
|
184
|
+
if (options.data) {
|
|
185
|
+
var queryStr = typeof options.data === 'string' ? options.data : stringify(options.data);
|
|
186
|
+
if (url.indexOf('?') !== -1) {
|
|
187
|
+
url = url + queryStr;
|
|
188
|
+
} else {
|
|
189
|
+
url = url + '?' + queryStr;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
requestOptions.body = typeof options.data === 'string' ? options.data : JSON.stringify(options.data);
|
|
194
|
+
}
|
|
195
|
+
fetch(url, requestOptions).then(function (response) {
|
|
196
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
var responseHeaders, _a, _b;
|
|
198
|
+
var _c;
|
|
199
|
+
return __generator(this, function (_d) {
|
|
200
|
+
switch (_d.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
responseHeaders = {};
|
|
203
|
+
response.headers.forEach(function (value, key) {
|
|
204
|
+
responseHeaders[key.toLocaleLowerCase()] = value;
|
|
205
|
+
});
|
|
206
|
+
if (!(success === null || success === void 0)) return [3 /*break*/, 1];
|
|
207
|
+
_a = void 0;
|
|
208
|
+
return [3 /*break*/, 3];
|
|
209
|
+
case 1:
|
|
210
|
+
_b = success;
|
|
211
|
+
_c = {
|
|
212
|
+
status: response.status
|
|
213
|
+
};
|
|
214
|
+
return [4 /*yield*/, convertResponse(response)];
|
|
215
|
+
case 2:
|
|
216
|
+
_a = _b.apply(void 0, [(_c.data = _d.sent(), _c.headers = responseHeaders, _c)]);
|
|
217
|
+
_d.label = 3;
|
|
218
|
+
case 3:
|
|
219
|
+
_a;
|
|
220
|
+
return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}).catch(function (e) {
|
|
225
|
+
fail === null || fail === void 0 ? void 0 : fail({
|
|
226
|
+
error: 19,
|
|
227
|
+
errorMessage: 'HTTP error.' + (e === null || e === void 0 ? void 0 : e.message)
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|