@tarojs/runtime 4.0.0-beta.5 → 4.0.0-beta.50

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.
@@ -1 +1 @@
1
- {"version":3,"file":"window.js","sources":["../../src/bom/window.ts"],"sourcesContent":["import { isString } from '@tarojs/shared'\n\nimport { CONTEXT_ACTIONS } from '../constants'\nimport { Events } from '../emitter/emitter'\nimport env from '../env'\nimport { getComputedStyle } from './getComputedStyle'\nimport { History } from './history'\nimport { Location } from './location'\nimport { nav as navigator } from './navigator'\nimport { caf, raf } from './raf'\n\nimport type { TaroHistory } from './history'\nimport type { TaroLocation } from './location'\n\nclass TaroWindow extends Events {\n navigator = navigator\n requestAnimationFrame = raf\n cancelAnimationFrame = caf\n getComputedStyle = getComputedStyle\n Date: DateConstructor\n\n location: TaroLocation\n history: TaroHistory\n XMLHttpRequest?: Partial<XMLHttpRequest>\n\n constructor () {\n super()\n\n const globalProperties = [\n ...Object.getOwnPropertyNames(global || {}),\n ...Object.getOwnPropertySymbols(global || {})\n ]\n\n globalProperties.forEach(property => {\n if (property === 'atob' || property === 'document') return\n if (!Object.prototype.hasOwnProperty.call(this, property)) {\n // 防止小程序环境下,window 上的某些 get 属性在赋值时报错\n try {\n this[property] = global[property]\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`)\n }\n }\n }\n })\n\n this.Date ||= Date\n\n // 应用启动时,提供给需要读取历史信息的库使用\n this.location = new Location({ window: this }) as any\n // @ts-ignore\n this.history = new History(this.location, { window: this })\n\n this.initEvent()\n }\n\n initEvent () {\n const _location = this.location\n const _history = this.history\n\n this.on(CONTEXT_ACTIONS.INIT, (pageId: string) => {\n // 页面onload,为该页面建立新的上下文信息\n _location.trigger(CONTEXT_ACTIONS.INIT, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RECOVER, (pageId: string) => {\n // 页面onshow,恢复当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n _history.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RESTORE, (pageId: string) => {\n // 页面onhide,缓存当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n _history.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.DESTORY, (pageId: string) => {\n // 页面onunload,清除当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n _history.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n }, null)\n }\n\n get document () {\n return env.document\n }\n\n addEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.on(event, callback, null)\n }\n\n removeEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.off(event, callback, null)\n }\n\n setTimeout (...args: Parameters<typeof setTimeout>) {\n return setTimeout(...args)\n }\n\n clearTimeout (...args: Parameters<typeof clearTimeout>) {\n return clearTimeout(...args)\n }\n}\n\nexport type { TaroWindow }\nexport const window: TaroWindow = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow())\n\nexport const location = window.location\nexport const history = window.history\n\n"],"names":["navigator","raf","caf"],"mappings":";;;;;;;;;;AAcA,MAAM,UAAW,SAAQ,MAAM,CAAA;AAW7B,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE,CAAA;QAXT,IAAS,CAAA,SAAA,GAAGA,GAAS,CAAA;QACrB,IAAqB,CAAA,qBAAA,GAAGC,IAAG,CAAA;QAC3B,IAAoB,CAAA,oBAAA,GAAGC,IAAG,CAAA;QAC1B,IAAgB,CAAA,gBAAA,GAAG,gBAAgB,CAAA;AAUjC,QAAA,MAAM,gBAAgB,GAAG;AACvB,YAAA,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,IAAI,EAAE,CAAC;AAC3C,YAAA,GAAG,MAAM,CA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EAAE,IAAI,CAAC,CAAA;KAChC;IAED,UAAU,CAAE,GAAG,IAAmC,EAAA;AAChD,QAAA,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC,CAAA;KAC3B;IAED,YAAY,CAAE,GAAG,IAAqC,EAAA;AACpD,QAAA,OAAO,YAAY,CAAC,GAAG,IAAI,CAAC,CAAA;KAC7B;AACF,CAAA;AAGM,MAAM,MAAM,GAAe,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,KAAK,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,UAAU,EAAE,EAAC;AAEvG,MAAA,QAAQ,GAAG,MAAM,CAAC,SAAQ;AAC1B,MAAA,OAAO,GAAG,MAAM,CAAC;;;;"}
1
+ {"version":3,"file":"window.js","sources":["../../src/bom/window.ts"],"sourcesContent":["import { isString } from '@tarojs/shared'\n\nimport { CONTEXT_ACTIONS } from '../constants'\nimport { Events } from '../emitter/emitter'\nimport env from '../env'\nimport { getComputedStyle } from './getComputedStyle'\nimport { History } from './history'\nimport { Location } from './location'\nimport { nav as navigator } from './navigator'\nimport { caf, raf } from './raf'\n\nimport type { TaroHistory } from './history'\nimport type { TaroLocation } from './location'\n\nclass TaroWindow extends Events {\n navigator = navigator\n requestAnimationFrame = raf\n cancelAnimationFrame = caf\n getComputedStyle = getComputedStyle\n Date: DateConstructor\n\n location: TaroLocation\n history: TaroHistory\n XMLHttpRequest?: Partial<XMLHttpRequest>\n\n constructor () {\n super()\n\n const globalProperties = [\n ...Object.getOwnPropertyNames(global || {}),\n ...Object.getOwnPropertySymbols(global || {})\n ]\n\n globalProperties.forEach(property => {\n if (property === 'atob' || property === 'document') return\n if (!Object.prototype.hasOwnProperty.call(this, property)) {\n // 防止小程序环境下,window 上的某些 get 属性在赋值时报错\n try {\n this[property] = global[property]\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`)\n }\n }\n }\n })\n\n this.Date ||= Date\n\n // 应用启动时,提供给需要读取历史信息的库使用\n this.location = new Location({ window: this }) as any\n // @ts-ignore\n this.history = new History(this.location, { window: this })\n\n this.initEvent()\n }\n\n initEvent () {\n const _location = this.location\n const _history = this.history\n\n this.on(CONTEXT_ACTIONS.INIT, (pageId: string) => {\n // 页面onload,为该页面建立新的上下文信息\n _location.trigger(CONTEXT_ACTIONS.INIT, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RECOVER, (pageId: string) => {\n // 页面onshow,恢复当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n _history.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RESTORE, (pageId: string) => {\n // 页面onhide,缓存当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n _history.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.DESTORY, (pageId: string) => {\n // 页面onunload,清除当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n _history.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n }, null)\n }\n\n get document () {\n return env.document\n }\n\n addEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.on(event, callback, null)\n }\n\n removeEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.off(event, callback, null)\n }\n\n setTimeout (...args: Parameters<typeof setTimeout>) {\n return setTimeout(...args)\n }\n\n clearTimeout (...args: Parameters<typeof clearTimeout>) {\n return clearTimeout(...args)\n }\n}\n\nexport type { TaroWindow }\nexport const window: TaroWindow = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow())\n\nexport const location = window.location\nexport const history = window.history\n"],"names":["navigator","raf","caf"],"mappings":";;;;;;;;;;AAcA,MAAM,UAAW,SAAQ,MAAM,CAAA;AAW7B,IAAA,WAAA,GAAA;AACE,QAAA,K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AE,KAAa,EAAE,QAA4B,EAAA;AAC3D,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAM;QAC5B,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;KAC/B;IAED,mBAAmB,CAAE,KAAa,EAAE,QAA4B,EAAA;AAC9D,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAM;QAC5B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;KAChC;IAED,UAAU,CAAE,GAAG,IAAmC,EAAA;AAChD,QAAA,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC,CAAA;KAC3B;IAED,YAAY,CAAE,GAAG,IAAqC,EAAA;AACpD,QAAA,OAAO,YAAY,CAAC,GAAG,IAAI,CAAC,CAAA;KAC7B;AACF,CAAA;AAGM,MAAM,MAAM,GAAe,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,KAAK,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,UAAU,EAAE,EAAC;AAEvG,MAAA,QAAQ,GAAG,MAAM,CAAC,SAAQ;AAC1B,MAAA,OAAO,GAAG,MAAM,CAAC;;;;"}
@@ -722,6 +722,7 @@ interface AppInstance extends Show {
722
722
  onPageNotFound?(res: any): void;
723
723
  onUnhandledRejection?(error: any): void;
724
724
  onShow?(options?: Record<string, unknown>): void;
725
+ onHide?(options?: Record<string, unknown>): void;
725
726
  unmount?(id: string, cb?: () => void): void;
726
727
  taroGlobalData?: Record<any, any>;
727
728
  config?: Record<any, any>;
@@ -769,6 +770,14 @@ declare function createRecursiveComponentConfig(componentName?: string): any;
769
770
  declare function hydrate(node: TaroElement | TaroText): MiniData;
770
771
  declare const nextTick: (cb: TFunc, ctx?: Record<string, any>) => void;
771
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;
772
781
  declare const incrementId: () => () => string;
773
782
  declare function isElement(node: TaroNode): node is TaroElement;
774
783
  declare function isText(node: TaroNode): node is TaroText;
@@ -789,6 +798,7 @@ declare function extend(ctor: Ctor, methodName: string, options: TFunc | Record<
789
798
  declare function getComponentsAlias(): any;
790
799
  declare function convertNumber2PX(value: number): string;
791
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;
792
802
  // export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
793
803
  // export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
794
804
  declare const addLeadingSlash: (url?: string) => string;
@@ -800,4 +810,4 @@ declare const getHomePage: (path?: string, basename?: string, customRoutes?: Rec
800
810
  declare const getCurrentPage: (routerMode?: string, basename?: string) => string;
801
811
  declare function handlePolyfill(): void;
802
812
  export { hooks } from '@tarojs/shared';
803
- 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;