@tarojs/runtime 4.0.0-beta.29 → 4.0.0-beta.30
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/index.cjs.d.ts +10 -1
- package/dist/index.cjs.js +31 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/perf.d.ts +3 -1
- package/dist/perf.js +22 -3
- package/dist/perf.js.map +1 -1
- package/dist/runtime.esm.d.ts +10 -1
- package/dist/runtime.esm.js +30 -4
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/lodash.d.ts +2 -1
- package/dist/utils/lodash.js +11 -1
- package/dist/utils/lodash.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.d.ts
CHANGED
|
@@ -770,6 +770,14 @@ declare function createRecursiveComponentConfig(componentName?: string): any;
|
|
|
770
770
|
declare function hydrate(node: TaroElement | TaroText): MiniData;
|
|
771
771
|
declare const nextTick: (cb: TFunc, ctx?: Record<string, any>) => void;
|
|
772
772
|
declare const options: Options;
|
|
773
|
+
declare class Performance {
|
|
774
|
+
#private;
|
|
775
|
+
private recorder;
|
|
776
|
+
start(id: string): void;
|
|
777
|
+
stop(id: string, now?: number): void;
|
|
778
|
+
delayStop(id: string, delay?: number): ((...args: any[]) => void) | undefined;
|
|
779
|
+
}
|
|
780
|
+
declare const perf: Performance;
|
|
773
781
|
declare const incrementId: () => () => string;
|
|
774
782
|
declare function isElement(node: TaroNode): node is TaroElement;
|
|
775
783
|
declare function isText(node: TaroNode): node is TaroText;
|
|
@@ -790,6 +798,7 @@ declare function extend(ctor: Ctor, methodName: string, options: TFunc | Record<
|
|
|
790
798
|
declare function getComponentsAlias(): any;
|
|
791
799
|
declare function convertNumber2PX(value: number): string;
|
|
792
800
|
declare function throttle(fn: any, threshold?: number, scope?: any): (...args: any[]) => void;
|
|
801
|
+
declare function debounce(fn: any, ms?: number, scope?: any): (...args: any[]) => void;
|
|
793
802
|
// export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
|
|
794
803
|
// export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
|
|
795
804
|
declare const addLeadingSlash: (url?: string) => string;
|
|
@@ -801,4 +810,4 @@ declare const getHomePage: (path?: string, basename?: string, customRoutes?: Rec
|
|
|
801
810
|
declare const getCurrentPage: (routerMode?: string, basename?: string) => string;
|
|
802
811
|
declare function handlePolyfill(): void;
|
|
803
812
|
export { hooks } from '@tarojs/shared';
|
|
804
|
-
export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, env, PROPERTY_THRESHOLD, TARO_RUNTIME, HOOKS_APP_ID, SET_DATA, PAGE_INIT, ROOT_STR, HTML, HEAD, BODY, APP, CONTAINER, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, ID, UID, CLASS, STYLE, FOCUS, VIEW, STATIC_VIEW, PURE_VIEW, PROPS, DATASET, OBJECT, VALUE, INPUT, CHANGE, CUSTOM_WRAPPER, TARGET, CURRENT_TARGET, TYPE, CONFIRM, TIME_STAMP, KEY_CODE, TOUCHMOVE, DATE, SET_TIMEOUT, COMPILE_MODE, CATCHMOVE, CATCH_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, throttle, addLeadingSlash, hasBasename, stripBasename, stripTrailing, stripSuffix, getHomePage, getCurrentPage, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniTextData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$1 as Options, TFunc, PageConfig, handlePolyfill };
|
|
813
|
+
export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, env, PROPERTY_THRESHOLD, TARO_RUNTIME, HOOKS_APP_ID, SET_DATA, PAGE_INIT, ROOT_STR, HTML, HEAD, BODY, APP, CONTAINER, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, ID, UID, CLASS, STYLE, FOCUS, VIEW, STATIC_VIEW, PURE_VIEW, PROPS, DATASET, OBJECT, VALUE, INPUT, CHANGE, CUSTOM_WRAPPER, TARGET, CURRENT_TARGET, TYPE, CONFIRM, TIME_STAMP, KEY_CODE, TOUCHMOVE, DATE, SET_TIMEOUT, COMPILE_MODE, CATCHMOVE, CATCH_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, perf, incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, throttle, debounce, addLeadingSlash, hasBasename, stripBasename, stripTrailing, stripSuffix, getHomePage, getCurrentPage, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniTextData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$1 as Options, TFunc, PageConfig, handlePolyfill };
|
package/dist/index.cjs.js
CHANGED
|
@@ -219,6 +219,16 @@ function throttle(fn, threshold = 250, scope) {
|
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
|
+
function debounce(fn, ms = 250, scope) {
|
|
223
|
+
let timer;
|
|
224
|
+
return function (...args) {
|
|
225
|
+
const context = scope || this;
|
|
226
|
+
clearTimeout(timer);
|
|
227
|
+
timer = setTimeout(function () {
|
|
228
|
+
fn.apply(context, args);
|
|
229
|
+
}, ms);
|
|
230
|
+
};
|
|
231
|
+
}
|
|
222
232
|
|
|
223
233
|
const eventCenter = shared.hooks.call('getEventCenter', shared.Events);
|
|
224
234
|
|
|
@@ -3503,8 +3513,10 @@ class FormElement extends TaroElement {
|
|
|
3503
3513
|
}
|
|
3504
3514
|
}
|
|
3505
3515
|
|
|
3516
|
+
var _Performance_instances, _Performance_parseTime;
|
|
3506
3517
|
class Performance {
|
|
3507
3518
|
constructor() {
|
|
3519
|
+
_Performance_instances.add(this);
|
|
3508
3520
|
this.recorder = new Map();
|
|
3509
3521
|
}
|
|
3510
3522
|
start(id) {
|
|
@@ -3513,18 +3525,32 @@ class Performance {
|
|
|
3513
3525
|
}
|
|
3514
3526
|
this.recorder.set(id, Date.now());
|
|
3515
3527
|
}
|
|
3516
|
-
stop(id) {
|
|
3528
|
+
stop(id, now = Date.now()) {
|
|
3517
3529
|
if (!options.debug) {
|
|
3518
3530
|
return;
|
|
3519
3531
|
}
|
|
3520
|
-
const now = Date.now();
|
|
3521
3532
|
const prev = this.recorder.get(id);
|
|
3533
|
+
if (!(prev >= 0))
|
|
3534
|
+
return;
|
|
3522
3535
|
this.recorder.delete(id);
|
|
3523
3536
|
const time = now - prev;
|
|
3524
3537
|
// eslint-disable-next-line no-console
|
|
3525
|
-
console.log(`${id} 时长: ${time}ms`);
|
|
3538
|
+
console.log(`${id} 时长: ${time}ms 开始时间:${tslib.__classPrivateFieldGet(this, _Performance_instances, "m", _Performance_parseTime).call(this, prev)} 结束时间:${tslib.__classPrivateFieldGet(this, _Performance_instances, "m", _Performance_parseTime).call(this, now)}`);
|
|
3539
|
+
}
|
|
3540
|
+
delayStop(id, delay = 500) {
|
|
3541
|
+
if (!options.debug) {
|
|
3542
|
+
return;
|
|
3543
|
+
}
|
|
3544
|
+
return debounce((now = Date.now(), cb) => {
|
|
3545
|
+
this.stop(id, now);
|
|
3546
|
+
cb === null || cb === void 0 ? void 0 : cb();
|
|
3547
|
+
}, delay);
|
|
3526
3548
|
}
|
|
3527
3549
|
}
|
|
3550
|
+
_Performance_instances = new WeakSet(), _Performance_parseTime = function _Performance_parseTime(time) {
|
|
3551
|
+
const d = new Date(time);
|
|
3552
|
+
return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, '0')}`;
|
|
3553
|
+
};
|
|
3528
3554
|
const perf = new Performance();
|
|
3529
3555
|
|
|
3530
3556
|
function findCustomWrapper(root, dataPathArr) {
|
|
@@ -5096,6 +5122,7 @@ exports.createEvent = createEvent;
|
|
|
5096
5122
|
exports.createPageConfig = createPageConfig;
|
|
5097
5123
|
exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
|
|
5098
5124
|
exports.customWrapperCache = customWrapperCache;
|
|
5125
|
+
exports.debounce = debounce;
|
|
5099
5126
|
exports.document = document$1;
|
|
5100
5127
|
exports.env = env;
|
|
5101
5128
|
exports.eventCenter = eventCenter;
|
|
@@ -5128,6 +5155,7 @@ exports.navigator = nav;
|
|
|
5128
5155
|
exports.nextTick = nextTick;
|
|
5129
5156
|
exports.options = options;
|
|
5130
5157
|
exports.parseUrl = parseUrl;
|
|
5158
|
+
exports.perf = perf;
|
|
5131
5159
|
exports.removePageInstance = removePageInstance;
|
|
5132
5160
|
exports.requestAnimationFrame = _raf;
|
|
5133
5161
|
exports.safeExecute = safeExecute;
|