@tarojs/taro-h5 3.5.9 → 3.6.0-beta.0
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/interaction/index.js +10 -4
- package/dist/api/ui/interaction/modal.d.ts +1 -0
- package/dist/api/ui/interaction/modal.js +9 -1
- package/dist/api/ui/interaction/toast.d.ts +1 -0
- package/dist/api/ui/interaction/toast.js +9 -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/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 +126 -76
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +2 -2
- package/dist/index.esm.js +126 -76
- 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.d.ts +5 -0
- package/dist/utils/index.js +28 -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.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ interface IProcessOpenApi<TOptions = Record<string, unknown>, TResult extends Ta
|
|
|
29
29
|
formatResult?: (res: TResult) => TResult;
|
|
30
30
|
}
|
|
31
31
|
export declare function processOpenApi<TOptions = Record<string, unknown>, TResult extends TaroGeneral.CallbackResult = any>({ name, defaultOptions, standardMethod, formatOptions, formatResult }: IProcessOpenApi<TOptions, TResult>): (options?: Partial<TOptions>, ...args: any[]) => Promise<TResult>;
|
|
32
|
+
/**
|
|
33
|
+
* 根据url获取应用的启动页面
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export declare function getLaunchPage(): string;
|
|
32
37
|
export * from './animation';
|
|
33
38
|
export * from './lodash';
|
|
34
39
|
export * from './valid';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint-disable prefer-promise-reject-errors */
|
|
2
2
|
import Taro from '@tarojs/api';
|
|
3
|
+
import { addLeadingSlash, getHomePage, stripBasename } from '@tarojs/router/dist/utils';
|
|
3
4
|
import { Current, hooks } from '@tarojs/runtime';
|
|
5
|
+
import { isFunction } from '@tarojs/shared';
|
|
4
6
|
import { MethodHandler } from './handler';
|
|
5
7
|
export const isProd = process.env.NODE_ENV === 'production';
|
|
6
8
|
export function shouldBeObject(target) {
|
|
@@ -137,7 +139,7 @@ export function processOpenApi({ name, defaultOptions, standardMethod, formatOpt
|
|
|
137
139
|
// @ts-ignore
|
|
138
140
|
const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
|
|
139
141
|
const opts = formatOptions(Object.assign({}, defaultOptions, options));
|
|
140
|
-
if (
|
|
142
|
+
if (isFunction(targetApi)) {
|
|
141
143
|
return new Promise((resolve, reject) => {
|
|
142
144
|
['fail', 'success', 'complete'].forEach(k => {
|
|
143
145
|
opts[k] = preRef => {
|
|
@@ -154,7 +156,7 @@ export function processOpenApi({ name, defaultOptions, standardMethod, formatOpt
|
|
|
154
156
|
});
|
|
155
157
|
});
|
|
156
158
|
}
|
|
157
|
-
else if (
|
|
159
|
+
else if (isFunction(standardMethod)) {
|
|
158
160
|
return standardMethod(opts);
|
|
159
161
|
}
|
|
160
162
|
else {
|
|
@@ -162,6 +164,30 @@ export function processOpenApi({ name, defaultOptions, standardMethod, formatOpt
|
|
|
162
164
|
}
|
|
163
165
|
};
|
|
164
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* 根据url获取应用的启动页面
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
export function getLaunchPage() {
|
|
172
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
173
|
+
const appConfig = window.__taroAppConfig || {};
|
|
174
|
+
// createPageConfig时根据stack的长度来设置stamp以保证页面path的唯一,此函数是在createPageConfig之前调用,预先设置stamp=1
|
|
175
|
+
const stamp = '?stamp=1';
|
|
176
|
+
let entryPath = '';
|
|
177
|
+
if (((_a = appConfig.router) === null || _a === void 0 ? void 0 : _a.mode) === 'browser' || ((_b = appConfig.router) === null || _b === void 0 ? void 0 : _b.mode) === 'multi') {
|
|
178
|
+
entryPath = location.pathname;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
entryPath = location.hash.slice(1).split('?')[0];
|
|
182
|
+
}
|
|
183
|
+
const routePath = addLeadingSlash(stripBasename(entryPath, (_c = appConfig.router) === null || _c === void 0 ? void 0 : _c.basename));
|
|
184
|
+
const homePath = addLeadingSlash(getHomePage((_e = (_d = appConfig.routes) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.path, (_f = appConfig.router) === null || _f === void 0 ? void 0 : _f.basename, (_g = appConfig.router) === null || _g === void 0 ? void 0 : _g.customRoutes, appConfig.entryPagePath));
|
|
185
|
+
// url上没有指定应用的启动页面时使用homePath
|
|
186
|
+
if (routePath === '/') {
|
|
187
|
+
return homePath + stamp;
|
|
188
|
+
}
|
|
189
|
+
return routePath + stamp;
|
|
190
|
+
}
|
|
165
191
|
export * from './animation';
|
|
166
192
|
export * from './lodash';
|
|
167
193
|
export * from './valid';
|
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.0",
|
|
4
4
|
"description": "Taro h5 framework",
|
|
5
5
|
"browser": "dist/index.esm.js",
|
|
6
6
|
"main:h5": "dist/index.js",
|
|
@@ -27,11 +27,16 @@
|
|
|
27
27
|
"jsonp-retry": "^1.0.3",
|
|
28
28
|
"query-string": "^7.1.1",
|
|
29
29
|
"whatwg-fetch": "^3.4.0",
|
|
30
|
-
"@tarojs/api": "3.
|
|
31
|
-
"@tarojs/router": "3.
|
|
32
|
-
"@tarojs/runtime": "3.
|
|
30
|
+
"@tarojs/api": "3.6.0-beta.0",
|
|
31
|
+
"@tarojs/router": "3.6.0-beta.0",
|
|
32
|
+
"@tarojs/runtime": "3.6.0-beta.0",
|
|
33
|
+
"@tarojs/shared": "3.6.0-beta.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
36
|
+
"jest": "^29.3.1",
|
|
37
|
+
"jest-fetch-mock": "^3.0.3",
|
|
38
|
+
"jest-localstorage-mock": "^2.4.0",
|
|
39
|
+
"jest-mock-console": "^1.0.0",
|
|
35
40
|
"react": "^18.2.0",
|
|
36
41
|
"react-test-renderer": "^18.2.0"
|
|
37
42
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare type TFunc = (...args: any[]) => any
|