@tarojs/taro-h5 3.5.11 → 3.6.0-beta.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/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 +81 -75
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +2 -2
- package/dist/index.esm.js +80 -74
- 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 +20 -10
- package/dist/utils/index.js +3 -2
- 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,39 @@
|
|
|
1
|
+
import { isFunction } from '@tarojs/shared';
|
|
2
|
+
import { isProd } from './index';
|
|
1
3
|
export class MethodHandler {
|
|
2
4
|
constructor({ name, success, fail, complete }) {
|
|
5
|
+
this.isHandlerError = false;
|
|
3
6
|
this.methodName = name;
|
|
4
7
|
this.__success = success;
|
|
5
8
|
this.__fail = fail;
|
|
6
9
|
this.__complete = complete;
|
|
10
|
+
this.isHandlerError = isFunction(this.__complete) || isFunction(this.__fail);
|
|
7
11
|
}
|
|
8
|
-
success(res = {},
|
|
12
|
+
success(res = {}, promise = {}) {
|
|
9
13
|
if (!res.errMsg) {
|
|
10
14
|
res.errMsg = `${this.methodName}:ok`;
|
|
11
15
|
}
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
isFunction(this.__success) && this.__success(res);
|
|
17
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
18
|
+
const { resolve = Promise.resolve.bind(Promise) } = promise;
|
|
14
19
|
return resolve(res);
|
|
15
20
|
}
|
|
16
|
-
fail(res = {},
|
|
21
|
+
fail(res = {}, promise = {}) {
|
|
17
22
|
if (!res.errMsg) {
|
|
18
23
|
res.errMsg = `${this.methodName}:fail`;
|
|
19
24
|
}
|
|
20
25
|
else {
|
|
21
26
|
res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
if (!isProd) {
|
|
29
|
+
console.error(res.errMsg);
|
|
30
|
+
}
|
|
31
|
+
isFunction(this.__fail) && this.__fail(res);
|
|
32
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
33
|
+
const { resolve = Promise.resolve.bind(Promise), reject = Promise.reject.bind(Promise) } = promise;
|
|
34
|
+
return this.isHandlerError
|
|
35
|
+
? resolve(res)
|
|
36
|
+
: reject(res);
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
export class CallbackManager {
|
|
@@ -67,12 +77,12 @@ export class CallbackManager {
|
|
|
67
77
|
*/
|
|
68
78
|
this.trigger = (...args) => {
|
|
69
79
|
this.callbacks.forEach(opt => {
|
|
70
|
-
if (
|
|
80
|
+
if (isFunction(opt)) {
|
|
71
81
|
opt(...args);
|
|
72
82
|
}
|
|
73
83
|
else {
|
|
74
84
|
const { callback, ctx } = opt;
|
|
75
|
-
|
|
85
|
+
isFunction(callback) && callback.call(ctx, ...args);
|
|
76
86
|
}
|
|
77
87
|
});
|
|
78
88
|
};
|
package/dist/utils/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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
7
|
export const isProd = process.env.NODE_ENV === 'production';
|
|
7
8
|
export function shouldBeObject(target) {
|
|
@@ -141,7 +142,7 @@ export function processOpenApi({ name, defaultOptions, standardMethod, formatOpt
|
|
|
141
142
|
// @ts-ignore
|
|
142
143
|
const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
|
|
143
144
|
const opts = formatOptions(Object.assign({}, defaultOptions, options));
|
|
144
|
-
if (
|
|
145
|
+
if (isFunction(targetApi)) {
|
|
145
146
|
return new Promise((resolve, reject) => {
|
|
146
147
|
['fail', 'success', 'complete'].forEach(k => {
|
|
147
148
|
opts[k] = preRef => {
|
|
@@ -158,7 +159,7 @@ export function processOpenApi({ name, defaultOptions, standardMethod, formatOpt
|
|
|
158
159
|
});
|
|
159
160
|
});
|
|
160
161
|
}
|
|
161
|
-
else if (
|
|
162
|
+
else if (isFunction(standardMethod)) {
|
|
162
163
|
return standardMethod(opts);
|
|
163
164
|
}
|
|
164
165
|
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-beta.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-beta.1",
|
|
35
|
+
"@tarojs/router": "3.6.0-beta.1",
|
|
36
|
+
"@tarojs/runtime": "3.6.0-beta.1",
|
|
37
|
+
"@tarojs/shared": "3.6.0-beta.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
|