@tarojs/runtime 4.0.1-alpha.1 → 4.0.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.
Files changed (83) hide show
  1. package/LICENSE +8 -8
  2. package/dist/bom/URL.d.ts +2 -2
  3. package/dist/bom/URL.js +2 -3
  4. package/dist/bom/URL.js.map +1 -1
  5. package/dist/bom/URLSearchParams.js.map +1 -1
  6. package/dist/bom/document.d.ts +2 -2
  7. package/dist/bom/document.js +2 -3
  8. package/dist/bom/document.js.map +1 -1
  9. package/dist/bom/getComputedStyle.d.ts +2 -2
  10. package/dist/bom/getComputedStyle.js +2 -3
  11. package/dist/bom/getComputedStyle.js.map +1 -1
  12. package/dist/bom/history.js.map +1 -1
  13. package/dist/bom/location.js +3 -3
  14. package/dist/bom/location.js.map +1 -1
  15. package/dist/bom/raf.d.ts +0 -1
  16. package/dist/bom/raf.js +2 -2
  17. package/dist/bom/raf.js.map +1 -1
  18. package/dist/bom/window.d.ts +4 -5
  19. package/dist/bom/window.js +6 -7
  20. package/dist/bom/window.js.map +1 -1
  21. package/dist/current.d.ts +1 -1
  22. package/dist/dom/anchor-element.js.map +1 -1
  23. package/dist/dom/class-list.js.map +1 -1
  24. package/dist/dom/document.js.map +1 -1
  25. package/dist/dom/element.js +3 -0
  26. package/dist/dom/element.js.map +1 -1
  27. package/dist/dom/event-target.js.map +1 -1
  28. package/dist/dom/event.js.map +1 -1
  29. package/dist/dom/form.js +1 -1
  30. package/dist/dom/form.js.map +1 -1
  31. package/dist/dom/node.js +2 -2
  32. package/dist/dom/node.js.map +1 -1
  33. package/dist/dom/root.js.map +1 -1
  34. package/dist/dom/style.js.map +1 -1
  35. package/dist/dom/style_properties.js.map +1 -1
  36. package/dist/dom/tree.js.map +1 -1
  37. package/dist/dom-external/element.js.map +1 -1
  38. package/dist/dom-external/index.js +1 -1
  39. package/dist/dom-external/index.js.map +1 -1
  40. package/dist/dom-external/inner-html/html.js.map +1 -1
  41. package/dist/dom-external/inner-html/parser.js.map +1 -1
  42. package/dist/dom-external/inner-html/scaner.js.map +1 -1
  43. package/dist/dom-external/inner-html/style.js.map +1 -1
  44. package/dist/dom-external/inner-html/tags.js +4 -4
  45. package/dist/dom-external/inner-html/tags.js.map +1 -1
  46. package/dist/dom-external/inner-html/utils.js.map +1 -1
  47. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  48. package/dist/dom-external/mutation-observer/index.js.map +1 -1
  49. package/dist/dom-external/node.js.map +1 -1
  50. package/dist/dsl/common.d.ts +1 -2
  51. package/dist/dsl/common.js +5 -5
  52. package/dist/dsl/common.js.map +1 -1
  53. package/dist/hydrate.js.map +1 -1
  54. package/dist/index.cjs.d.ts +22 -44
  55. package/dist/index.cjs.js +3321 -3363
  56. package/dist/index.cjs.js.map +1 -1
  57. package/dist/index.d.ts +7 -7
  58. package/dist/index.js +6 -8
  59. package/dist/index.js.map +1 -1
  60. package/dist/{instance-4c64b022.d.ts → instance-0f017c6e.d.ts} +14 -4
  61. package/dist/next-tick.js.map +1 -1
  62. package/dist/perf.d.ts +1 -3
  63. package/dist/perf.js +3 -24
  64. package/dist/perf.js.map +1 -1
  65. package/dist/polyfill/array.js.map +1 -1
  66. package/dist/polyfill/index.js.map +1 -1
  67. package/dist/polyfill/intersection-observer.js +3 -4
  68. package/dist/polyfill/intersection-observer.js.map +1 -1
  69. package/dist/polyfill/object.js.map +1 -1
  70. package/dist/runtime.esm.d.ts +22 -44
  71. package/dist/runtime.esm.js +3316 -3346
  72. package/dist/runtime.esm.js.map +1 -1
  73. package/dist/utils/cache.js.map +1 -1
  74. package/dist/utils/index.d.ts +1 -3
  75. package/dist/utils/index.js +1 -5
  76. package/dist/utils/index.js.map +1 -1
  77. package/dist/utils/lodash.d.ts +1 -2
  78. package/dist/utils/lodash.js +1 -11
  79. package/dist/utils/lodash.js.map +1 -1
  80. package/dist/utils/router.js +3 -3
  81. package/dist/utils/router.js.map +1 -1
  82. package/package.json +24 -16
  83. /package/dist/{options-4c64b022.d.ts → options-0f017c6e.d.ts} +0 -0
@@ -1,8 +1,9 @@
1
- /// <reference types="node" />
2
- /// <reference types="react" />
3
1
  import { Shortcuts, Events } from "@tarojs/shared";
2
+ import VueCtor from "vue";
3
+ import { ComponentOptions, VNode } from "vue";
4
4
  import { Component as Vue3Component } from "@vue/runtime-core";
5
5
  import { Component, ComponentClass } from "react";
6
+ import { CombinedVueInstance } from "vue/types/vue";
6
7
  declare class ClassList {
7
8
  private el;
8
9
  private tokenList;
@@ -43,8 +44,8 @@ interface AddEventListenerOptions extends EventListenerOptions {
43
44
  once?: boolean;
44
45
  passive?: boolean;
45
46
  }
46
- interface EventHandler<T = any, R = void> {
47
- (...args: T[]): R;
47
+ // eslint-disable-next-line @typescript-eslint/ban-types
48
+ interface EventHandler extends Function {
48
49
  _stop?: boolean;
49
50
  }
50
51
  // Note: @tarojs/runtime 不依赖 @tarojs/taro, 所以不能改为从 @tarojs/taro 引入 (可能导致循环依赖)
@@ -330,11 +331,9 @@ interface Env {
330
331
  document: TaroDocument;
331
332
  }
332
333
  declare const env: Env;
333
- // Note: 小程序端 vite 打包成 commonjs,const document = xxx 会报错,所以把 document 改为 taroDocumentProvider
334
- declare const taroDocumentProvider: TaroDocument;
334
+ declare const document: TaroDocument;
335
335
  type TGetComputedStyle = typeof window.getComputedStyle | ((el: TaroElement) => Style);
336
- // Note: 小程序端 vite 打包成 commonjs,const getComputedStyle = xxx 会报错,所以把 GetComputedStyle 改为 taroGetComputedStyleProvider
337
- declare const taroGetComputedStyleProvider: TGetComputedStyle;
336
+ declare const getComputedStyle: TGetComputedStyle;
338
337
  declare const eventCenter: Events;
339
338
  type EventsType = typeof Events;
340
339
  /**
@@ -464,8 +463,7 @@ declare class TaroURL {
464
463
  href: string;
465
464
  };
466
465
  }
467
- // Note: 小程序端 vite 打包成 commonjs,const URL = xxx 会报错,所以把 URL 改为 TaroURLProvider
468
- declare const TaroURLProvider: typeof TaroURL;
466
+ declare const URL: typeof TaroURL;
469
467
  declare function parseUrl(url?: string): {
470
468
  href: string;
471
469
  origin: string;
@@ -495,10 +493,9 @@ declare class TaroWindow extends Events {
495
493
  setTimeout(...args: Parameters<typeof setTimeout>): NodeJS.Timeout;
496
494
  clearTimeout(...args: Parameters<typeof clearTimeout>): void;
497
495
  }
498
- // Note: 小程序端 vite 打包成 commonjs,const window = xxx 会报错,所以把 window 改为 taroWindowProvider,location 和 history 同理
499
- declare const taroWindowProvider: TaroWindow;
500
- declare const taroLocationProvider: TaroLocation;
501
- declare const taroHistoryProvider: TaroHistory;
496
+ declare const window: TaroWindow;
497
+ declare const location: TaroLocation;
498
+ declare const history: TaroHistory;
502
499
  // for Vue3
503
500
  declare class SVGElement extends TaroElement {
504
501
  }
@@ -652,6 +649,14 @@ interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInst
652
649
  $nextTick?(cb: () => void): void;
653
650
  $options: Instance;
654
651
  }
652
+ interface VueAppInstance extends ComponentOptions<VueCtor> {
653
+ $options: AppInstance;
654
+ }
655
+ type VueInstance<M = Record<string, any>, P = Record<string, any>> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
656
+ interface VueInternal {
657
+ _render(): VNode;
658
+ _update(vnode: VNode, hyrate: boolean): void;
659
+ }
655
660
  interface PageProps {
656
661
  tid?: string;
657
662
  }
@@ -712,8 +717,8 @@ interface Show {
712
717
  }
713
718
  interface AppInstance extends Show {
714
719
  componentDidShow?(options?: Record<string, unknown>): void;
715
- mount?(component: React.ComponentClass | Vue3Component, id: string, cb: (...args: any[]) => void): void;
716
- mount?(component: React.ComponentClass | Vue3Component, id: string, getCtx: (...args: any[]) => void, cb: (...args: any[]) => void): void;
720
+ mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
721
+ mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, getCtx: (...args: any[]) => void, cb: (...args: any[]) => void): void;
717
722
  onError?(error: string): void;
718
723
  onLaunch?(options?: Record<string, unknown>): void;
719
724
  onPageNotFound?(res: any): void;
@@ -767,35 +772,8 @@ declare function createRecursiveComponentConfig(componentName?: string): any;
767
772
  declare function hydrate(node: TaroElement | TaroText): MiniData;
768
773
  declare const nextTick: (cb: TFunc, ctx?: Record<string, any>) => void;
769
774
  declare const options: Options;
770
- declare class Performance {
771
- #private;
772
- private recorder;
773
- start(id: string): void;
774
- stop(id: string, now?: number): void;
775
- delayStop(id: string, delay?: number): ((...args: any[]) => void) | undefined;
776
- }
777
- declare const perf: Performance;
778
775
  declare const incrementId: () => () => string;
779
- declare function isElement(node: TaroNode): node is TaroElement;
780
- declare function isText(node: TaroNode): node is TaroText;
781
- declare function isComment(node: TaroNode): boolean;
782
776
  declare function isHasExtractProp(el: TaroElement): boolean;
783
- /**
784
- * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
785
- * @param node 当前组件
786
- * @param type 事件类型
787
- */
788
- declare function isParentBinded(node: TaroElement | null, type: string): boolean;
789
- declare function shortcutAttr(key: string): string;
790
- declare const customWrapperCache: Map<string, Record<string, any>>;
791
- interface Ctor {
792
- new (...args: any[]): any;
793
- }
794
- declare function extend(ctor: Ctor, methodName: string, options: TFunc | Record<string, any>): void;
795
- declare function getComponentsAlias(): any;
796
- declare function convertNumber2PX(value: number): string;
797
- declare function throttle(fn: any, threshold?: number, scope?: any): (...args: any[]) => void;
798
- declare function debounce(fn: any, ms?: number, scope?: any): (...args: any[]) => void;
799
777
  // export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
800
778
  // export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
801
779
  declare const addLeadingSlash: (url?: string) => string;
@@ -807,4 +785,4 @@ declare const getHomePage: (path?: string, basename?: string, customRoutes?: Rec
807
785
  declare const getCurrentPage: (routerMode?: string, basename?: string) => string;
808
786
  declare function handlePolyfill(): void;
809
787
  export { hooks } from '@tarojs/shared';
810
- export { taroDocumentProvider as document, taroGetComputedStyleProvider as getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, TaroURLProvider as URL, URLSearchParams, taroHistoryProvider as history, taroLocationProvider as location, taroWindowProvider as 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, 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 };
788
+ 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, isHasExtractProp, 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 };