@tarojs/taro-h5 3.5.11 → 3.6.0-alpha.1
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/dist/api/base/system.js +5 -1
- package/dist/api/device/clipboard.js +2 -1
- package/dist/api/location/chooseLocation.js +4 -4
- package/dist/api/location/getLocation.js +2 -2
- package/dist/api/media/image/chooseImage.js +2 -2
- package/dist/api/media/image/getImageInfo.js +2 -2
- package/dist/api/media/image/previewImage.js +2 -1
- package/dist/api/media/video/index.js +2 -2
- package/dist/api/network/request/index.js +9 -8
- package/dist/api/network/websocket/index.d.ts +1 -1
- package/dist/api/network/websocket/index.js +3 -3
- package/dist/api/network/websocket/socketTask.js +7 -6
- package/dist/api/taro.js +2 -1
- package/dist/api/ui/navigation-bar/index.d.ts +1 -1
- package/dist/api/ui/pull-down-refresh.js +4 -4
- package/dist/api/ui/scroll/index.js +3 -3
- package/dist/api/ui/tab-bar.js +16 -16
- package/dist/api/wxml/MediaQueryObserver.js +4 -3
- package/dist/api/wxml/nodesRef.d.ts +1 -0
- package/dist/api/wxml/selectorQuery.js +3 -2
- package/dist/index.cjs.d.ts +2 -2
- package/dist/index.cjs.js +89 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +2 -2
- package/dist/index.esm.js +88 -79
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +2 -2
- package/dist/utils/handler.d.ts +8 -3
- package/dist/utils/handler.js +19 -10
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +6 -6
- package/dist/utils/valid.d.ts +1 -2
- package/dist/utils/valid.js +0 -3
- package/package.json +9 -4
- package/types/global.d.ts +1 -0
package/dist/taroApis.d.ts
CHANGED
|
@@ -544,7 +544,7 @@ declare function onSocketOpen(): void;
|
|
|
544
544
|
declare function onSocketMessage(): void;
|
|
545
545
|
declare function onSocketError(): void;
|
|
546
546
|
declare function onSocketClose(): void;
|
|
547
|
-
declare function connectSocket(options
|
|
547
|
+
declare function connectSocket(options?: Taro.connectSocket.Option): Promise<unknown>;
|
|
548
548
|
declare function closeSocket(): void;
|
|
549
549
|
// 帐号信息
|
|
550
550
|
declare const getAccountInfoSync: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
@@ -679,7 +679,7 @@ declare const disableAlertBeforeUnload: (option?: {}, ...args: any[]) => Promise
|
|
|
679
679
|
declare const getMenuButtonBoundingClientRect: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
680
680
|
// 导航栏
|
|
681
681
|
declare const showNavigationBarLoading: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
682
|
-
declare function setNavigationBarTitle(options
|
|
682
|
+
declare function setNavigationBarTitle(options?: Taro.setNavigationBarTitle.Option): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
683
683
|
/**
|
|
684
684
|
* 设置页面导航条颜色
|
|
685
685
|
*/
|
package/dist/utils/handler.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
declare type TCallback<T = Partial<TaroGeneral.CallbackResult>> = (res: T) => Promise<void> | void;
|
|
2
2
|
interface IMethodParam<T = Partial<TaroGeneral.CallbackResult>> {
|
|
3
3
|
name: string;
|
|
4
|
-
success?: TCallback<T>;
|
|
4
|
+
success?: TCallback<T & TaroGeneral.CallbackResult>;
|
|
5
5
|
fail?: TCallback;
|
|
6
6
|
complete?: TCallback;
|
|
7
7
|
}
|
|
8
|
+
interface IMockPromise {
|
|
9
|
+
resolve?: typeof Promise.resolve | TFunc;
|
|
10
|
+
reject?: typeof Promise.reject | TFunc;
|
|
11
|
+
}
|
|
8
12
|
export declare class MethodHandler<T = Partial<TaroGeneral.CallbackResult>> {
|
|
9
13
|
methodName: string;
|
|
10
14
|
protected __success?: TCallback<T>;
|
|
11
15
|
protected __fail?: TCallback;
|
|
12
16
|
protected __complete?: TCallback;
|
|
17
|
+
protected isHandlerError: boolean;
|
|
13
18
|
constructor({ name, success, fail, complete }: IMethodParam<T>);
|
|
14
|
-
success<U = Record<string, unknown>>(res?: Partial<T> & Partial<TaroGeneral.CallbackResult>,
|
|
15
|
-
fail<U = Record<string, unknown>>(res?: Partial<T> & Partial<TaroGeneral.CallbackResult>,
|
|
19
|
+
success<U = Record<string, unknown>>(res?: Partial<T> & Partial<TaroGeneral.CallbackResult>, promise?: IMockPromise): Promise<T & U & TaroGeneral.CallbackResult>;
|
|
20
|
+
fail<U = Record<string, unknown>>(res?: Partial<T> & Partial<TaroGeneral.CallbackResult>, promise?: IMockPromise): Promise<T & U & TaroGeneral.CallbackResult>;
|
|
16
21
|
}
|
|
17
22
|
declare type TCallbackManagerParam = (...arr: unknown[]) => void;
|
|
18
23
|
interface ICallbackManagerOption {
|
package/dist/utils/handler.js
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
|
+
import { isFunction } from '@tarojs/shared';
|
|
1
2
|
export class MethodHandler {
|
|
2
3
|
constructor({ name, success, fail, complete }) {
|
|
4
|
+
this.isHandlerError = false;
|
|
3
5
|
this.methodName = name;
|
|
4
6
|
this.__success = success;
|
|
5
7
|
this.__fail = fail;
|
|
6
8
|
this.__complete = complete;
|
|
9
|
+
this.isHandlerError = isFunction(this.__complete) || isFunction(this.__fail);
|
|
7
10
|
}
|
|
8
|
-
success(res = {},
|
|
11
|
+
success(res = {}, promise = {}) {
|
|
9
12
|
if (!res.errMsg) {
|
|
10
13
|
res.errMsg = `${this.methodName}:ok`;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
isFunction(this.__success) && this.__success(res);
|
|
16
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
17
|
+
const { resolve = Promise.resolve.bind(Promise) } = promise;
|
|
14
18
|
return resolve(res);
|
|
15
19
|
}
|
|
16
|
-
fail(res = {},
|
|
20
|
+
fail(res = {}, promise = {}) {
|
|
17
21
|
if (!res.errMsg) {
|
|
18
22
|
res.errMsg = `${this.methodName}:fail`;
|
|
19
23
|
}
|
|
20
24
|
else {
|
|
21
25
|
res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
28
|
+
console.error(res.errMsg);
|
|
29
|
+
}
|
|
30
|
+
isFunction(this.__fail) && this.__fail(res);
|
|
31
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
32
|
+
const { resolve = Promise.resolve.bind(Promise), reject = Promise.reject.bind(Promise) } = promise;
|
|
33
|
+
return this.isHandlerError
|
|
34
|
+
? resolve(res)
|
|
35
|
+
: reject(res);
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
export class CallbackManager {
|
|
@@ -67,12 +76,12 @@ export class CallbackManager {
|
|
|
67
76
|
*/
|
|
68
77
|
this.trigger = (...args) => {
|
|
69
78
|
this.callbacks.forEach(opt => {
|
|
70
|
-
if (
|
|
79
|
+
if (isFunction(opt)) {
|
|
71
80
|
opt(...args);
|
|
72
81
|
}
|
|
73
82
|
else {
|
|
74
83
|
const { callback, ctx } = opt;
|
|
75
|
-
|
|
84
|
+
isFunction(callback) && callback.call(ctx, ...args);
|
|
76
85
|
}
|
|
77
86
|
});
|
|
78
87
|
};
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import Taro from '@tarojs/api';
|
|
3
3
|
import { addLeadingSlash, getHomePage, stripBasename } from '@tarojs/router/dist/utils';
|
|
4
4
|
import { Current, hooks } from '@tarojs/runtime';
|
|
5
|
+
import { isFunction } from '@tarojs/shared';
|
|
5
6
|
import { MethodHandler } from './handler';
|
|
6
|
-
export const isProd = process.env.NODE_ENV === 'production';
|
|
7
7
|
export function shouldBeObject(target) {
|
|
8
8
|
if (target && typeof target === 'object')
|
|
9
9
|
return { flag: true };
|
|
@@ -85,7 +85,7 @@ export function temporarilyNotSupport(name = '') {
|
|
|
85
85
|
type: 'method',
|
|
86
86
|
category: 'temporarily',
|
|
87
87
|
});
|
|
88
|
-
if (
|
|
88
|
+
if (process.env.NODE_ENV === 'production') {
|
|
89
89
|
console.warn(errMsg);
|
|
90
90
|
return handle.success({ errMsg });
|
|
91
91
|
}
|
|
@@ -105,7 +105,7 @@ export function weixinCorpSupport(name) {
|
|
|
105
105
|
type: 'method',
|
|
106
106
|
category: 'weixin_corp',
|
|
107
107
|
});
|
|
108
|
-
if (
|
|
108
|
+
if (process.env.NODE_ENV === 'production') {
|
|
109
109
|
console.warn(errMsg);
|
|
110
110
|
return handle.success({ errMsg });
|
|
111
111
|
}
|
|
@@ -125,7 +125,7 @@ export function permanentlyNotSupport(name = '') {
|
|
|
125
125
|
type: 'method',
|
|
126
126
|
category: 'permanently',
|
|
127
127
|
});
|
|
128
|
-
if (
|
|
128
|
+
if (process.env.NODE_ENV === 'production') {
|
|
129
129
|
console.warn(errMsg);
|
|
130
130
|
return handle.success({ errMsg });
|
|
131
131
|
}
|
|
@@ -141,7 +141,7 @@ export function processOpenApi({ name, defaultOptions, standardMethod, formatOpt
|
|
|
141
141
|
// @ts-ignore
|
|
142
142
|
const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
|
|
143
143
|
const opts = formatOptions(Object.assign({}, defaultOptions, options));
|
|
144
|
-
if (
|
|
144
|
+
if (isFunction(targetApi)) {
|
|
145
145
|
return new Promise((resolve, reject) => {
|
|
146
146
|
['fail', 'success', 'complete'].forEach(k => {
|
|
147
147
|
opts[k] = preRef => {
|
|
@@ -158,7 +158,7 @@ export function processOpenApi({ name, defaultOptions, standardMethod, formatOpt
|
|
|
158
158
|
});
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
else if (
|
|
161
|
+
else if (isFunction(standardMethod)) {
|
|
162
162
|
return standardMethod(opts);
|
|
163
163
|
}
|
|
164
164
|
else {
|
package/dist/utils/valid.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare const isValidColor: (color: any) => boolean;
|
|
1
|
+
export declare const isValidColor: (color: string) => boolean;
|
package/dist/utils/valid.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro-h5",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0-alpha.1",
|
|
4
4
|
"description": "Taro h5 framework",
|
|
5
5
|
"browser": "dist/index.esm.js",
|
|
6
6
|
"main:h5": "dist/index.js",
|
|
@@ -31,11 +31,16 @@
|
|
|
31
31
|
"jsonp-retry": "^1.0.3",
|
|
32
32
|
"query-string": "^7.1.1",
|
|
33
33
|
"whatwg-fetch": "^3.4.0",
|
|
34
|
-
"@tarojs/api": "3.
|
|
35
|
-
"@tarojs/router": "3.
|
|
36
|
-
"@tarojs/runtime": "3.
|
|
34
|
+
"@tarojs/api": "3.6.0-alpha.1",
|
|
35
|
+
"@tarojs/router": "3.6.0-alpha.1",
|
|
36
|
+
"@tarojs/runtime": "3.6.0-alpha.1",
|
|
37
|
+
"@tarojs/shared": "3.6.0-alpha.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
40
|
+
"jest": "^29.3.1",
|
|
41
|
+
"jest-fetch-mock": "^3.0.3",
|
|
42
|
+
"jest-localstorage-mock": "^2.4.0",
|
|
43
|
+
"jest-mock-console": "^1.0.0",
|
|
39
44
|
"react": "^18.2.0",
|
|
40
45
|
"react-test-renderer": "^18.2.0"
|
|
41
46
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare type TFunc = (...args: any[]) => any
|