@tarojs/runtime 3.7.0-alpha.2 → 3.7.0-alpha.22

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 (67) hide show
  1. package/dist/runtime.cjs.d.ts +780 -0
  2. package/dist/runtime.cjs.js +4585 -0
  3. package/dist/runtime.esm.d.ts +153 -76
  4. package/dist/runtime.esm.js +200 -75
  5. package/dist/runtime.esm.js.map +1 -1
  6. package/dist/runtime.h5.d.ts +780 -0
  7. package/dist/runtime.h5.js +3350 -0
  8. package/package.json +11 -6
  9. package/dist/bom/URL.d.ts +0 -61
  10. package/dist/bom/URLSearchParams.d.ts +0 -14
  11. package/dist/bom/document.d.ts +0 -2
  12. package/dist/bom/getComputedStyle.d.ts +0 -3
  13. package/dist/bom/history.d.ts +0 -29
  14. package/dist/bom/location.d.ts +0 -36
  15. package/dist/bom/navigator.d.ts +0 -1
  16. package/dist/bom/raf.d.ts +0 -5
  17. package/dist/bom/window.d.ts +0 -4
  18. package/dist/constants/index.d.ts +0 -58
  19. package/dist/current.d.ts +0 -19
  20. package/dist/dom/anchor-element.d.ts +0 -13
  21. package/dist/dom/class-list.d.ts +0 -14
  22. package/dist/dom/custom-wrapper.d.ts +0 -4
  23. package/dist/dom/document.d.ts +0 -20
  24. package/dist/dom/element.d.ts +0 -38
  25. package/dist/dom/event-source.d.ts +0 -7
  26. package/dist/dom/event-target.d.ts +0 -7
  27. package/dist/dom/event.d.ts +0 -23
  28. package/dist/dom/form.d.ts +0 -7
  29. package/dist/dom/node.d.ts +0 -75
  30. package/dist/dom/node_types.d.ts +0 -10
  31. package/dist/dom/root.d.ts +0 -15
  32. package/dist/dom/style.d.ts +0 -14
  33. package/dist/dom/style_properties.d.ts +0 -3
  34. package/dist/dom/svg.d.ts +0 -3
  35. package/dist/dom/text.d.ts +0 -14
  36. package/dist/dom/tree.d.ts +0 -4
  37. package/dist/dom-external/element.d.ts +0 -3
  38. package/dist/dom-external/index.d.ts +0 -1
  39. package/dist/dom-external/inner-html/html.d.ts +0 -2
  40. package/dist/dom-external/inner-html/parser.d.ts +0 -25
  41. package/dist/dom-external/inner-html/scaner.d.ts +0 -30
  42. package/dist/dom-external/inner-html/style.d.ts +0 -27
  43. package/dist/dom-external/inner-html/tags.d.ts +0 -8
  44. package/dist/dom-external/inner-html/utils.d.ts +0 -1
  45. package/dist/dom-external/mutation-observer/implements.d.ts +0 -52
  46. package/dist/dom-external/mutation-observer/index.d.ts +0 -13
  47. package/dist/dom-external/mutation-observer/record.d.ts +0 -24
  48. package/dist/dom-external/node.d.ts +0 -11
  49. package/dist/dsl/common.d.ts +0 -16
  50. package/dist/dsl/instance.d.ts +0 -87
  51. package/dist/emitter/emitter.d.ts +0 -4
  52. package/dist/env.d.ts +0 -7
  53. package/dist/hydrate.d.ts +0 -10
  54. package/dist/index.d.ts +0 -30
  55. package/dist/interface/element.d.ts +0 -4
  56. package/dist/interface/event-target.d.ts +0 -10
  57. package/dist/interface/event.d.ts +0 -15
  58. package/dist/interface/hydrate.d.ts +0 -30
  59. package/dist/interface/index.d.ts +0 -7
  60. package/dist/interface/node.d.ts +0 -7
  61. package/dist/interface/options.d.ts +0 -16
  62. package/dist/interface/utils.d.ts +0 -2
  63. package/dist/next-tick.d.ts +0 -2
  64. package/dist/options.d.ts +0 -2
  65. package/dist/perf.d.ts +0 -7
  66. package/dist/utils/cache.d.ts +0 -12
  67. package/dist/utils/index.d.ts +0 -23
@@ -5,18 +5,19 @@ import { ComponentOptions, VNode } from "vue";
5
5
  import { Component as Vue3Component } from "@vue/runtime-core";
6
6
  import { Component, ComponentClass } from "react";
7
7
  import { CombinedVueInstance } from "vue/types/vue";
8
- declare let document: any;
9
- declare class ClassList extends Set<string> {
8
+ declare class ClassList {
10
9
  private el;
10
+ private tokenList;
11
11
  constructor(className: string, el: TaroElement);
12
12
  get value(): string;
13
- add(s: string): this;
14
13
  get length(): number;
15
- remove(s: string): void;
16
- toggle(s: string): void;
17
- replace(s1: string, s2: string): void;
18
- contains(s: string): boolean;
14
+ add(): void;
15
+ remove(): void;
16
+ contains(token: string): boolean;
17
+ toggle(token: string, force: boolean): boolean;
18
+ replace(token: string, replacement_token: string): void;
19
19
  toString(): string;
20
+ private checkTokenIsValid;
20
21
  private _update;
21
22
  }
22
23
  interface Attributes {
@@ -102,68 +103,6 @@ declare class TaroText extends TaroNode {
102
103
  set data(text: string);
103
104
  get data(): string;
104
105
  }
105
- // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
106
- declare class TaroEvent {
107
- private cacheTarget;
108
- private cacheCurrentTarget;
109
- type: string;
110
- bubbles: boolean;
111
- cancelable: boolean;
112
- _stop: boolean;
113
- _end: boolean;
114
- defaultPrevented: boolean;
115
- // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
116
- button: number;
117
- // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
118
- // here use hi-res timestamp
119
- timeStamp: number;
120
- mpEvent: MpEvent | undefined;
121
- constructor(type: string, opts: EventOptions, event?: MpEvent);
122
- stopPropagation(): void;
123
- stopImmediatePropagation(): void;
124
- preventDefault(): void;
125
- get target(): any;
126
- get currentTarget(): any;
127
- }
128
- declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroEvent;
129
- // 小程序的事件代理回调函数
130
- declare function eventHandler(event: MpEvent): any;
131
- declare class FormElement extends TaroElement {
132
- get value(): string | boolean | number | any[];
133
- set value(val: string | boolean | number | any[]);
134
- dispatchEvent(event: TaroEvent): boolean;
135
- }
136
- declare class TaroRootElement extends TaroElement {
137
- private updatePayloads;
138
- private updateCallbacks;
139
- pendingUpdate: boolean;
140
- ctx: null | MpInstance;
141
- constructor();
142
- get _path(): string;
143
- get _root(): TaroRootElement;
144
- enqueueUpdate(payload: UpdatePayload): void;
145
- performUpdate(initRender?: boolean, prerender?: Func): void;
146
- enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
147
- flushUpdateCallback(): void;
148
- }
149
- declare class TaroDocument extends TaroElement {
150
- documentElement: TaroElement;
151
- head: TaroElement;
152
- body: TaroElement;
153
- createEvent: typeof createEvent;
154
- constructor();
155
- createElement(type: string): TaroElement | TaroRootElement | FormElement;
156
- // an ugly fake createElementNS to deal with @vue/runtime-dom's
157
- // support mounting app to svg container since vue@3.0.8
158
- createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
159
- createTextNode(text: string): TaroText;
160
- getElementById<T extends TaroElement>(id: string | undefined | null): T | null;
161
- querySelector<T extends TaroElement>(query: string): T | null;
162
- querySelectorAll(): never[];
163
- // @TODO: @PERF: 在 hydrate 移除掉空的 node
164
- createComment(): TaroText;
165
- get defaultView(): any;
166
- }
167
106
  interface Node {
168
107
  type: string;
169
108
  }
@@ -203,6 +142,19 @@ declare class TaroEventTarget {
203
142
  removeEventListener(type: string, handler: EventHandler): void;
204
143
  isAnyEventBinded(): boolean;
205
144
  }
145
+ declare class TaroRootElement extends TaroElement {
146
+ private updatePayloads;
147
+ private updateCallbacks;
148
+ pendingUpdate: boolean;
149
+ ctx: null | MpInstance;
150
+ constructor();
151
+ get _path(): string;
152
+ get _root(): TaroRootElement;
153
+ enqueueUpdate(payload: UpdatePayload): void;
154
+ performUpdate(initRender?: boolean, prerender?: Func): void;
155
+ enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
156
+ flushUpdateCallback(): void;
157
+ }
206
158
  interface RemoveChildOptions {
207
159
  cleanRef?: boolean;
208
160
  doUpdate?: boolean;
@@ -217,6 +169,7 @@ declare class TaroNode extends TaroEventTarget {
217
169
  constructor();
218
170
  private hydrate;
219
171
  private updateChildNodes;
172
+ private updateSingleChild;
220
173
  get _root(): TaroRootElement | null;
221
174
  protected findIndex(refChild: TaroNode): number;
222
175
  get _path(): string;
@@ -285,7 +238,34 @@ declare class Style {
285
238
  removeProperty(propertyName: string): string;
286
239
  getPropertyValue(propertyName: string): any;
287
240
  }
241
+ // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
242
+ declare class TaroEvent {
243
+ private cacheTarget;
244
+ private cacheCurrentTarget;
245
+ type: string;
246
+ bubbles: boolean;
247
+ cancelable: boolean;
248
+ _stop: boolean;
249
+ _end: boolean;
250
+ defaultPrevented: boolean;
251
+ // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
252
+ button: number;
253
+ // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
254
+ // here use hi-res timestamp
255
+ timeStamp: number;
256
+ mpEvent: MpEvent | undefined;
257
+ constructor(type: string, opts: EventOptions, event?: MpEvent);
258
+ stopPropagation(): void;
259
+ stopImmediatePropagation(): void;
260
+ preventDefault(): void;
261
+ get target(): any;
262
+ get currentTarget(): any;
263
+ }
264
+ declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroEvent;
265
+ // 小程序的事件代理回调函数
266
+ declare function eventHandler(event: MpEvent): any;
288
267
  declare class TaroElement extends TaroNode {
268
+ ctx?: any;
289
269
  tagName: string;
290
270
  props: Record<string, any>;
291
271
  style: Style;
@@ -319,6 +299,37 @@ declare class TaroElement extends TaroNode {
319
299
  removeEventListener(type: any, handler: any, sideEffect?: boolean): void;
320
300
  static extend(methodName: string, options: Func | Record<string, any>): void;
321
301
  }
302
+ declare class FormElement extends TaroElement {
303
+ get type(): string;
304
+ set type(val: string);
305
+ get value(): string | boolean | number | any[];
306
+ set value(val: string | boolean | number | any[]);
307
+ dispatchEvent(event: TaroEvent): boolean;
308
+ }
309
+ declare class TaroDocument extends TaroElement {
310
+ documentElement: TaroElement;
311
+ head: TaroElement;
312
+ body: TaroElement;
313
+ createEvent: typeof createEvent;
314
+ constructor();
315
+ createElement(type: string): TaroElement | TaroRootElement | FormElement;
316
+ // an ugly fake createElementNS to deal with @vue/runtime-dom's
317
+ // support mounting app to svg container since vue@3.0.8
318
+ createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
319
+ createTextNode(text: string): TaroText;
320
+ getElementById<T extends TaroElement>(id: string | undefined | null): T | null;
321
+ querySelector<T extends TaroElement>(query: string): T | null;
322
+ querySelectorAll(): never[];
323
+ // @TODO: @PERF: 在 hydrate 移除掉空的 node
324
+ createComment(): TaroText;
325
+ get defaultView(): any;
326
+ }
327
+ interface Env {
328
+ window: any;
329
+ document: TaroDocument;
330
+ }
331
+ declare const env: Env;
332
+ declare let document: any;
322
333
  declare function getComputedStyle(element: TaroElement): Style;
323
334
  declare const eventCenter: Events;
324
335
  type EventsType = typeof Events;
@@ -405,7 +416,7 @@ declare class History extends Events {
405
416
  constructor(location: LocationType.Location, options: Options$0);
406
417
  /* public property */
407
418
  get length(): number;
408
- get state(): HistoryState;
419
+ get state(): Record<string, any> | null;
409
420
  /* public method */
410
421
  go(delta: number): void;
411
422
  back(): void;
@@ -578,8 +589,67 @@ declare class MutationObserver {
578
589
  takeRecords(): MutationRecord[];
579
590
  static record(record: MutationRecord): void;
580
591
  }
581
- interface Instance<T> extends Component<T>, Show, PageInstance {
592
+ declare const PROPERTY_THRESHOLD = 2046;
593
+ declare const TARO_RUNTIME = "Taro runtime";
594
+ declare const HOOKS_APP_ID = "taro-app";
595
+ declare const SET_DATA = "\u5C0F\u7A0B\u5E8F setData";
596
+ declare const PAGE_INIT = "\u9875\u9762\u521D\u59CB\u5316";
597
+ declare const ROOT_STR = "root";
598
+ declare const HTML = "html";
599
+ declare const HEAD = "head";
600
+ declare const BODY = "body";
601
+ declare const APP = "app";
602
+ declare const CONTAINER = "container";
603
+ declare const DOCUMENT_ELEMENT_NAME = "#document";
604
+ declare const DOCUMENT_FRAGMENT = "document-fragment";
605
+ declare const ID = "id";
606
+ declare const UID = "uid";
607
+ declare const CLASS = "class";
608
+ declare const STYLE = "style";
609
+ declare const FOCUS = "focus";
610
+ declare const VIEW = "view";
611
+ declare const STATIC_VIEW = "static-view";
612
+ declare const PURE_VIEW = "pure-view";
613
+ declare const PROPS = "props";
614
+ declare const DATASET = "dataset";
615
+ declare const OBJECT = "object";
616
+ declare const VALUE = "value";
617
+ declare const INPUT = "input";
618
+ declare const CHANGE = "change";
619
+ declare const CUSTOM_WRAPPER = "custom-wrapper";
620
+ declare const TARGET = "target";
621
+ declare const CURRENT_TARGET = "currentTarget";
622
+ declare const TYPE = "type";
623
+ declare const CONFIRM = "confirm";
624
+ declare const TIME_STAMP = "timeStamp";
625
+ declare const KEY_CODE = "keyCode";
626
+ declare const TOUCHMOVE = "touchmove";
627
+ declare const DATE = "Date";
628
+ declare const SET_TIMEOUT = "setTimeout";
629
+ declare const CATCHMOVE = "catchMove";
630
+ declare const CATCH_VIEW = "catch-view";
631
+ declare const COMMENT = "comment";
632
+ declare const ON_LOAD = "onLoad";
633
+ declare const ON_READY = "onReady";
634
+ declare const ON_SHOW = "onShow";
635
+ declare const ON_HIDE = "onHide";
636
+ declare const OPTIONS = "options";
637
+ declare const EXTERNAL_CLASSES = "externalClasses";
638
+ declare const EVENT_CALLBACK_RESULT = "e_result";
639
+ declare const BEHAVIORS = "behaviors";
640
+ declare const A = "a";
641
+ /**
642
+ * 页面上下文切换时的行为
643
+ */
644
+ declare enum CONTEXT_ACTIONS {
645
+ INIT = "0",
646
+ RESTORE = "1",
647
+ RECOVER = "2",
648
+ DESTORY = "3"
649
+ }
650
+ interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInstance {
582
651
  tid?: string;
652
+ node?: TaroElement;
583
653
  $forceUpdate?(): void;
584
654
  $nextTick?(cb: () => void): void;
585
655
  $options: Instance;
@@ -587,7 +657,7 @@ interface Instance<T> extends Component<T>, Show, PageInstance {
587
657
  interface VueAppInstance extends ComponentOptions<VueCtor> {
588
658
  $options: AppInstance;
589
659
  }
590
- type VueInstance<M, P> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
660
+ type VueInstance<M = Record<string, any>, P = Record<string, any>> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
591
661
  interface VueInternal {
592
662
  _render(): VNode;
593
663
  _update(vnode: VNode, hyrate: boolean): void;
@@ -595,13 +665,13 @@ interface VueInternal {
595
665
  interface PageProps {
596
666
  tid?: string;
597
667
  }
598
- interface ReactPageComponent<T> extends ComponentClass<T>, PageInstance {
668
+ interface ReactPageComponent<T = PageProps> extends ComponentClass<T>, PageInstance {
599
669
  }
600
- interface ReactPageInstance<T> extends Component<T>, PageInstance {
670
+ interface ReactPageInstance<T = PageProps> extends Component<T>, PageInstance {
601
671
  componentDidShow?(): void;
602
672
  componentDidHide?(): void;
603
673
  }
604
- interface ReactAppInstance<T> extends Component<T>, AppInstance {
674
+ interface ReactAppInstance<T = AppInstance> extends Component<T>, AppInstance {
605
675
  }
606
676
  interface PageLifeCycle extends Show {
607
677
  eh?(event: MpEvent): void;
@@ -639,6 +709,8 @@ interface PageInstance extends PageLifeCycle {
639
709
  path?: string;
640
710
  /** 页面的组件选项 */
641
711
  options?: Record<string, unknown>;
712
+ /** 页面渲染引擎类型 */
713
+ renderer?: "webview" | "skyline";
642
714
  }
643
715
  interface Show {
644
716
  componentDidShow?(): void;
@@ -649,6 +721,7 @@ interface Show {
649
721
  interface AppInstance extends Show {
650
722
  componentDidShow?(options?: Record<string, unknown>): void;
651
723
  mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
724
+ mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, getCtx: (...args: any[]) => void, cb: (...args: any[]) => void): void;
652
725
  onError?(error: string): void;
653
726
  onLaunch?(options?: Record<string, unknown>): void;
654
727
  onPageNotFound?(res: any): void;
@@ -686,6 +759,10 @@ declare function removePageInstance(id: string): void;
686
759
  declare function addLeadingSlash(path?: string): string;
687
760
  declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
688
761
  declare function stringify(obj?: Record<string, unknown>): string;
762
+ declare function getPath(id: string, options?: Record<string, unknown>): string;
763
+ declare function getOnReadyEventKey(path: string): string;
764
+ declare function getOnShowEventKey(path: string): string;
765
+ declare function getOnHideEventKey(path: string): string;
689
766
  declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
690
767
  declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
691
768
  declare function createRecursiveComponentConfig(componentName?: string): any;
@@ -700,4 +777,4 @@ declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
700
777
  declare const options: Options;
701
778
  declare const incrementId: () => () => string;
702
779
  export { hooks } from '@tarojs/shared';
703
- 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, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
780
+ 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, 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, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };