@tarojs/runtime 3.5.5 → 3.5.6-alpha.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.
@@ -1,8 +1,8 @@
1
- import type { Attributes, Func } from '../interface';
2
1
  import { ClassList } from './class-list';
3
- import type { TaroEvent } from './event';
4
2
  import { TaroNode } from './node';
5
3
  import { Style } from './style';
4
+ import type { Attributes, Func } from '../interface';
5
+ import type { TaroEvent } from './event';
6
6
  export declare class TaroElement extends TaroNode {
7
7
  tagName: string;
8
8
  props: Record<string, any>;
@@ -1,8 +1,8 @@
1
+ import { TaroEventTarget } from './event-target';
2
+ import { NodeType } from './node_types';
1
3
  import type { Func, UpdatePayload } from '../interface';
2
4
  import type { TaroDocument } from './document';
3
5
  import type { TaroElement } from './element';
4
- import { TaroEventTarget } from './event-target';
5
- import { NodeType } from './node_types';
6
6
  import type { TaroRootElement } from './root';
7
7
  interface RemoveChildOptions {
8
8
  cleanRef?: boolean;
@@ -1,5 +1,5 @@
1
- import type { Func, MpInstance, UpdatePayload } from '../interface';
2
1
  import { TaroElement } from './element';
2
+ import type { Func, MpInstance, UpdatePayload } from '../interface';
3
3
  export declare class TaroRootElement extends TaroElement {
4
4
  private updatePayloads;
5
5
  private updateCallbacks;
@@ -1,7 +1,7 @@
1
- import type { TaroNode } from '../../dom/node';
2
- import type { MutationCallback, MutationObserverInit } from './implements';
3
1
  import { MutationObserverImpl } from './implements';
4
2
  import { MutationRecord, MutationRecordType } from './record';
3
+ import type { TaroNode } from '../../dom/node';
4
+ import type { MutationCallback, MutationObserverInit } from './implements';
5
5
  export declare class MutationObserver {
6
6
  core: Pick<MutationObserverImpl, 'observe' | 'disconnect' | 'takeRecords'>;
7
7
  constructor(callback: MutationCallback);
@@ -3,6 +3,7 @@ import type { PageConfig } from '@tarojs/taro';
3
3
  import type { Instance, PageInstance, PageProps } from './instance';
4
4
  export declare function injectPageInstance(inst: Instance<PageProps>, id: string): void;
5
5
  export declare function getPageInstance(id: string): Instance | undefined;
6
+ export declare function removePageInstance(id: string): void;
6
7
  export declare function addLeadingSlash(path?: string): string;
7
8
  export declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
8
9
  export declare function stringify(obj?: Record<string, unknown>): string;
@@ -1,6 +1,6 @@
1
+ import VueCtor, { ComponentOptions, VNode } from 'vue';
1
2
  import type { Component as Vue3Component } from '@vue/runtime-core';
2
3
  import type { Component, ComponentClass } from 'react';
3
- import VueCtor, { ComponentOptions, VNode } from 'vue';
4
4
  import type { CombinedVueInstance } from 'vue/types/vue';
5
5
  import type { TaroElement } from '../dom/element';
6
6
  import type { Func, MpEvent } from '../interface';
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { TaroText } from './dom/text';
16
16
  export { MutationObserver } from './dom-external/mutation-observer';
17
17
  export { Current, getCurrentInstance } from './current';
18
18
  export { eventSource } from './dom/event-source';
19
- export { addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, safeExecute, stringify } from './dsl/common';
19
+ export { addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, removePageInstance, safeExecute, stringify } from './dsl/common';
20
20
  export * from './emitter/emitter';
21
21
  export { hydrate } from './hydrate';
22
22
  export { nextTick } from './next-tick';
@@ -1,11 +1,24 @@
1
1
  import { Shortcuts, Events } from "@tarojs/shared";
2
2
  import { PageConfig } from "@tarojs/taro";
3
- import { Component as Vue3Component } from "@vue/runtime-core";
4
- import { Component, ComponentClass } from "react";
5
3
  import VueCtor from "vue";
6
4
  import { ComponentOptions, VNode } from "vue";
5
+ import { Component as Vue3Component } from "@vue/runtime-core";
6
+ import { Component, ComponentClass } from "react";
7
7
  import { CombinedVueInstance } from "vue/types/vue";
8
8
  declare let document: any;
9
+ declare class ClassList extends Set<string> {
10
+ private el;
11
+ constructor(className: string, el: TaroElement);
12
+ get value(): string;
13
+ add(s: string): this;
14
+ 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;
19
+ toString(): string;
20
+ private _update;
21
+ }
9
22
  interface Attributes {
10
23
  name: string;
11
24
  value: string;
@@ -67,6 +80,28 @@ interface UpdatePayload {
67
80
  path: string;
68
81
  value: UpdatePayloadValue;
69
82
  }
83
+ declare const enum NodeType {
84
+ ELEMENT_NODE = 1,
85
+ ATTRIBUTE_NODE = 2,
86
+ TEXT_NODE = 3,
87
+ CDATA_SECTION_NODE = 4,
88
+ ENTITY_REFERENCE_NODE = 5,
89
+ COMMENT_NODE = 6,
90
+ PROCESSING_INSTRUCTION_NODE = 7,
91
+ DOCUMENT_NODE = 9
92
+ }
93
+ declare class TaroText extends TaroNode {
94
+ _value: string;
95
+ nodeType: NodeType;
96
+ nodeName: string;
97
+ constructor(value: any);
98
+ set textContent(text: string);
99
+ get textContent(): string;
100
+ set nodeValue(text: string);
101
+ get nodeValue(): string;
102
+ set data(text: string);
103
+ get data(): string;
104
+ }
70
105
  // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
71
106
  declare class TaroEvent {
72
107
  private cacheTarget;
@@ -127,22 +162,45 @@ declare class TaroDocument extends TaroElement {
127
162
  createComment(): TaroText;
128
163
  get defaultView(): any;
129
164
  }
165
+ interface Node {
166
+ type: string;
167
+ }
168
+ interface Comment extends Node {
169
+ type: "comment";
170
+ content: string;
171
+ }
172
+ interface Text extends Node {
173
+ type: "text";
174
+ content: string;
175
+ }
176
+ interface Element extends Node {
177
+ type: "element";
178
+ tagName: string;
179
+ children: ChildNode[];
180
+ attributes: string[];
181
+ }
182
+ type ChildNode = Comment | Text | Element;
183
+ interface Options {
184
+ prerender: boolean;
185
+ debug: boolean;
186
+ html?: {
187
+ skipElements: Set<string>;
188
+ voidElements: Set<string>;
189
+ closingElements: Set<string>;
190
+ transformText?: (taroText: TaroText, text: Text) => TaroText;
191
+ transformElement?: (taroElement: TaroElement, element: Element) => TaroElement;
192
+ renderHTMLTag: boolean;
193
+ };
194
+ miniGlobal?: any;
195
+ }
196
+ type Func = (...args: any[]) => any;
197
+ type Ctx = Record<string, any>;
130
198
  declare class TaroEventTarget {
131
199
  __handlers: Record<string, EventHandler[]>;
132
200
  addEventListener(type: string, handler: EventHandler, options?: boolean | AddEventListenerOptions): void;
133
201
  removeEventListener(type: string, handler: EventHandler): void;
134
202
  isAnyEventBinded(): boolean;
135
203
  }
136
- declare const enum NodeType {
137
- ELEMENT_NODE = 1,
138
- ATTRIBUTE_NODE = 2,
139
- TEXT_NODE = 3,
140
- CDATA_SECTION_NODE = 4,
141
- ENTITY_REFERENCE_NODE = 5,
142
- COMMENT_NODE = 6,
143
- PROCESSING_INSTRUCTION_NODE = 7,
144
- DOCUMENT_NODE = 9
145
- }
146
204
  interface RemoveChildOptions {
147
205
  cleanRef?: boolean;
148
206
  doUpdate?: boolean;
@@ -212,64 +270,6 @@ declare class TaroNode extends TaroEventTarget {
212
270
  get ownerDocument(): TaroDocument;
213
271
  static extend(methodName: string, options: Func | Record<string, any>): void;
214
272
  }
215
- declare class TaroText extends TaroNode {
216
- _value: string;
217
- nodeType: NodeType;
218
- nodeName: string;
219
- constructor(value: any);
220
- set textContent(text: string);
221
- get textContent(): string;
222
- set nodeValue(text: string);
223
- get nodeValue(): string;
224
- set data(text: string);
225
- get data(): string;
226
- }
227
- interface Node {
228
- type: string;
229
- }
230
- interface Comment extends Node {
231
- type: "comment";
232
- content: string;
233
- }
234
- interface Text extends Node {
235
- type: "text";
236
- content: string;
237
- }
238
- interface Element extends Node {
239
- type: "element";
240
- tagName: string;
241
- children: ChildNode[];
242
- attributes: string[];
243
- }
244
- type ChildNode = Comment | Text | Element;
245
- interface Options {
246
- prerender: boolean;
247
- debug: boolean;
248
- html?: {
249
- skipElements: Set<string>;
250
- voidElements: Set<string>;
251
- closingElements: Set<string>;
252
- transformText?: (taroText: TaroText, text: Text) => TaroText;
253
- transformElement?: (taroElement: TaroElement, element: Element) => TaroElement;
254
- renderHTMLTag: boolean;
255
- };
256
- miniGlobal?: any;
257
- }
258
- type Func = (...args: any[]) => any;
259
- type Ctx = Record<string, any>;
260
- declare class ClassList extends Set<string> {
261
- private el;
262
- constructor(className: string, el: TaroElement);
263
- get value(): string;
264
- add(s: string): this;
265
- get length(): number;
266
- remove(s: string): void;
267
- toggle(s: string): void;
268
- replace(s1: string, s2: string): void;
269
- contains(s: string): boolean;
270
- toString(): string;
271
- private _update;
272
- }
273
273
  declare class Style {
274
274
  _pending: boolean;
275
275
  _usedStyleProp: Set<string>;
@@ -515,6 +515,7 @@ interface IEventSource extends Map<string | undefined | null, TaroNode> {
515
515
  declare const eventSource: IEventSource;
516
516
  declare function injectPageInstance(inst: Instance<PageProps>, id: string): void;
517
517
  declare function getPageInstance(id: string): Instance | undefined;
518
+ declare function removePageInstance(id: string): void;
518
519
  declare function addLeadingSlash(path?: string): string;
519
520
  declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
520
521
  declare function stringify(obj?: Record<string, unknown>): string;
@@ -534,4 +535,4 @@ declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
534
535
  declare const options: Options;
535
536
  declare const incrementId: () => () => string;
536
537
  export { hooks } from '@tarojs/shared';
537
- export { document, getComputedStyle, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, 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, Func, Ctx };
538
+ export { document, getComputedStyle, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, 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, Func, Ctx };
@@ -2912,6 +2912,9 @@ function injectPageInstance(inst, id) {
2912
2912
  function getPageInstance(id) {
2913
2913
  return instances.get(id);
2914
2914
  }
2915
+ function removePageInstance(id) {
2916
+ instances.delete(id);
2917
+ }
2915
2918
  function addLeadingSlash(path) {
2916
2919
  if (path == null) {
2917
2920
  return '';
@@ -3105,8 +3108,9 @@ function createPageConfig(component, pageName, data, pageConfig) {
3105
3108
  function createComponentConfig(component, componentName, data) {
3106
3109
  const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
3107
3110
  let componentElement = null;
3111
+ const [ATTACHED, DETACHED] = hooks.call('getMiniLifecycleImpl').component;
3108
3112
  const config = {
3109
- attached() {
3113
+ [ATTACHED]() {
3110
3114
  var _a;
3111
3115
  perf.start(PAGE_INIT);
3112
3116
  const path = getPath(id, { id: ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId() });
@@ -3121,7 +3125,7 @@ function createComponentConfig(component, componentName, data) {
3121
3125
  }
3122
3126
  });
3123
3127
  },
3124
- detached() {
3128
+ [DETACHED]() {
3125
3129
  const path = getPath(id, { id: this.getPageId() });
3126
3130
  Current.app.unmount(path, () => {
3127
3131
  instances.delete(path);
@@ -3145,18 +3149,19 @@ function createComponentConfig(component, componentName, data) {
3145
3149
  }
3146
3150
  function createRecursiveComponentConfig(componentName) {
3147
3151
  const isCustomWrapper = componentName === CUSTOM_WRAPPER;
3152
+ const [ATTACHED, DETACHED] = hooks.call('getMiniLifecycleImpl').component;
3148
3153
  const lifeCycles = isCustomWrapper
3149
3154
  ? {
3150
- attached() {
3151
- var _a;
3152
- const componentId = (_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid;
3155
+ [ATTACHED]() {
3156
+ var _a, _b;
3157
+ const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
3153
3158
  if (isString(componentId)) {
3154
3159
  customWrapperCache.set(componentId, this);
3155
3160
  }
3156
3161
  },
3157
- detached() {
3158
- var _a;
3159
- const componentId = (_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid;
3162
+ [DETACHED]() {
3163
+ var _a, _b;
3164
+ const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
3160
3165
  if (isString(componentId)) {
3161
3166
  customWrapperCache.delete(componentId);
3162
3167
  }
@@ -3214,5 +3219,5 @@ const nextTick = (cb, ctx) => {
3214
3219
  }
3215
3220
  };
3216
3221
 
3217
- export { Current, FormElement, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, hydrate, incrementId, injectPageInstance, nav as navigator, nextTick, now, options, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
3222
+ export { Current, FormElement, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, hydrate, incrementId, injectPageInstance, nav as navigator, nextTick, now, options, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
3218
3223
  //# sourceMappingURL=runtime.esm.js.map