vite-plugin-taro-runtime 0.7.13 → 0.8.0-beta.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.
- package/README.md +2 -0
- package/dist/plugin-framework-react/runtime.js +3 -3
- package/dist/plugin-html/html-elements.d.ts +4 -0
- package/dist/plugin-html/html-elements.js +94 -0
- package/dist/plugin-html/runtime.js +1 -12
- package/dist/react/index.d.ts +3 -1
- package/dist/react/react.esm.js +56 -48
- package/dist/react/renderer-host.d.ts +4 -0
- package/dist/runtime/dom/element.d.ts +21 -3
- package/dist/runtime/dom/element.js +58 -29
- package/dist/runtime/dom/event-source.js +5 -1
- package/dist/runtime/dom/event-target.d.ts +11 -1
- package/dist/runtime/dom/event-target.js +35 -7
- package/dist/runtime/dom/event.d.ts +8 -1
- package/dist/runtime/dom/event.js +45 -14
- package/dist/runtime/dom/nearest-ctx.d.ts +3 -1
- package/dist/runtime/dom/nearest-ctx.js +10 -1
- package/dist/runtime/dom/node.d.ts +15 -7
- package/dist/runtime/dom/node.js +88 -44
- package/dist/runtime/dom/style.d.ts +7 -2
- package/dist/runtime/dom/style.js +19 -5
- package/dist/runtime/dom/text.d.ts +3 -2
- package/dist/runtime/dom/text.js +13 -6
- package/dist/runtime/dom-external/mutation-observer/implements.d.ts +3 -1
- package/dist/runtime/dom-external/mutation-observer/implements.js +5 -1
- package/dist/runtime/dom-external/mutation-observer/index.d.ts +2 -0
- package/dist/runtime/dom-external/mutation-observer/index.js +5 -1
- package/dist/runtime/dom-external/node.js +56 -18
- package/dist/runtime/dsl/common.d.ts +1 -0
- package/dist/runtime/dsl/common.js +22 -74
- package/dist/runtime/dsl/instance.d.ts +2 -3
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/utils/index.js +1 -1
- package/package.json +7 -1
- package/types/tt-document.d.ts +21 -2
|
@@ -51,5 +51,7 @@ declare class MutationObserverImpl {
|
|
|
51
51
|
takeRecords(): MutationRecord[];
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
declare function hasMutationObservers(): boolean;
|
|
55
|
+
|
|
56
|
+
export { MutationObserverImpl, hasMutationObservers };
|
|
55
57
|
export type { MutationCallback, MutationObserverInit };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
const observers = [];
|
|
2
|
+
/** Read observer presence directly from the current registrations. */
|
|
3
|
+
function hasMutationObservers() {
|
|
4
|
+
return observers.length > 0;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* The MutationObserver provides the ability
|
|
4
8
|
* to watch for changes being made to the DOM tree.
|
|
@@ -104,5 +108,5 @@ function recordMutation(record) {
|
|
|
104
108
|
});
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
export { MutationObserverImpl, recordMutation };
|
|
111
|
+
export { MutationObserverImpl, hasMutationObservers, recordMutation };
|
|
108
112
|
//# sourceMappingURL=implements.js.map
|
|
@@ -9,6 +9,8 @@ declare class MutationObserver {
|
|
|
9
9
|
observe(...args: [TaroNode, MutationObserverInit?]): void;
|
|
10
10
|
disconnect(): void;
|
|
11
11
|
takeRecords(): MutationRecord[];
|
|
12
|
+
/** Whether any observers are currently registered. */
|
|
13
|
+
static get hasObservers(): boolean;
|
|
12
14
|
static record(record: MutationRecord): void;
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { noop } from '@tarojs/shared';
|
|
2
|
-
import { MutationObserverImpl, recordMutation } from './implements.js';
|
|
2
|
+
import { MutationObserverImpl, hasMutationObservers, recordMutation } from './implements.js';
|
|
3
3
|
|
|
4
4
|
class MutationObserver {
|
|
5
5
|
constructor(callback) {
|
|
@@ -26,6 +26,10 @@ class MutationObserver {
|
|
|
26
26
|
takeRecords() {
|
|
27
27
|
return this.core.takeRecords();
|
|
28
28
|
}
|
|
29
|
+
/** Check before preparing mutation snapshots, sibling lookups or record objects. */
|
|
30
|
+
static get hasObservers() {
|
|
31
|
+
return ENABLE_MUTATION_OBSERVER && hasMutationObservers();
|
|
32
|
+
}
|
|
29
33
|
static record(record) {
|
|
30
34
|
recordMutation(record);
|
|
31
35
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TaroElement } from '../dom/element.js';
|
|
2
|
+
import { TaroNode } from '../dom/node.js';
|
|
3
|
+
import { Style } from '../dom/style.js';
|
|
2
4
|
import { parser } from './inner-html/parser.js';
|
|
3
5
|
|
|
6
|
+
// Capture the template defaults before hosts replace presentation delegates during startup.
|
|
7
|
+
// Clone construction needs host initialization, not incremental template payloads, even for roots.
|
|
8
|
+
const templateAttributeUpdate = TaroElement.prototype.delegateAttributeUpdate;
|
|
9
|
+
const templateStyleUpdate = Style.prototype.delegateStyleUpdate;
|
|
10
|
+
const templateChildInsertion = TaroNode.prototype.delegateChildInsertion;
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* An implementation of `Element.insertAdjacentHTML()`
|
|
6
14
|
* to support Vue 3 with a version of or greater than `vue@3.1.2`
|
|
@@ -31,31 +39,61 @@ function insertAdjacentHTML(position, html) {
|
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
|
-
function cloneNode(isDeep
|
|
42
|
+
function cloneNode(isDeep) {
|
|
35
43
|
const document = this.ownerDocument;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
if (this.nodeType === 3 /* NodeType.TEXT_NODE */) {
|
|
45
|
+
// Creation supplies both the logical and native initial value in one operation.
|
|
46
|
+
return document.createTextNode(this._value);
|
|
39
47
|
}
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
const newNode = document.createElement(this.nodeName);
|
|
49
|
+
/*
|
|
50
|
+
* A clone owns fresh identity and handler state. Copy attributes directly rather than invoking
|
|
51
|
+
* public setters: cloning must retain the source's ID lookup and produce no mutation records.
|
|
52
|
+
* Notify replaced presentation delegates while copying, so native hosts receive each value
|
|
53
|
+
* during construction. Template clones only need the copied logical state.
|
|
54
|
+
*/
|
|
55
|
+
if (newNode.delegateAttributeUpdate === templateAttributeUpdate) {
|
|
56
|
+
newNode.props = Object.assign({}, this.props);
|
|
42
57
|
}
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
newNode
|
|
58
|
+
else {
|
|
59
|
+
for (const name of Object.keys(this.props)) {
|
|
60
|
+
const value = this.props[name];
|
|
61
|
+
newNode.props[name] = value;
|
|
62
|
+
newNode.delegateAttributeUpdate(name, value, false);
|
|
48
63
|
}
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
}
|
|
65
|
+
newNode.dataset = Object.assign({}, this.dataset);
|
|
66
|
+
// Copy an existing declaration; unstyled sources and clones retain lazy allocation.
|
|
67
|
+
const sourceStyle = this._style;
|
|
68
|
+
if (sourceStyle) {
|
|
69
|
+
const style = newNode.style;
|
|
70
|
+
style._value = Object.assign({}, sourceStyle._value);
|
|
71
|
+
for (const name of sourceStyle._usedStyleProp) {
|
|
72
|
+
style._usedStyleProp.add(name);
|
|
73
|
+
// Dynamic CSS variables and hyphen-prefixed properties keep their original accessors.
|
|
74
|
+
if (name[0] === '-') {
|
|
75
|
+
style.setCssVariables(name);
|
|
76
|
+
}
|
|
51
77
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
newNode.style._usedStyleProp = new Set(Array.from(value._usedStyleProp));
|
|
78
|
+
if (style._usedStyleProp.size > 0 && style.delegateStyleUpdate !== templateStyleUpdate) {
|
|
79
|
+
style.delegateStyleUpdate();
|
|
55
80
|
}
|
|
56
81
|
}
|
|
57
82
|
if (isDeep) {
|
|
58
|
-
|
|
83
|
+
const notifyInsertion = newNode.delegateChildInsertion !== templateChildInsertion;
|
|
84
|
+
for (const child of this.childNodes) {
|
|
85
|
+
const clonedChild = child.cloneNode(true);
|
|
86
|
+
/*
|
|
87
|
+
* Construct the logical relationship before its native insertion. Calling appendChild
|
|
88
|
+
* here would also record observer mutations and search for the preceding sibling.
|
|
89
|
+
* This construction loop visits each edge once and leaves ordinary mutations unchanged.
|
|
90
|
+
*/
|
|
91
|
+
clonedChild.parentNode = newNode;
|
|
92
|
+
newNode.childNodes.push(clonedChild);
|
|
93
|
+
if (notifyInsertion) {
|
|
94
|
+
newNode.delegateChildInsertion(clonedChild, undefined, 0, undefined);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
59
97
|
}
|
|
60
98
|
return newNode;
|
|
61
99
|
}
|
|
@@ -10,6 +10,7 @@ declare function getPath(id: string, options?: Record<string, unknown>): string;
|
|
|
10
10
|
declare function getOnReadyEventKey(path: string): string;
|
|
11
11
|
declare function getOnShowEventKey(path: string): string;
|
|
12
12
|
declare function getOnHideEventKey(path: string): string;
|
|
13
|
+
/** Creates native lifecycles; onLoad reads the receiver's parameters and can delegate mounting with its load callback. */
|
|
13
14
|
declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
|
|
14
15
|
declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
|
|
15
16
|
declare function createRecursiveComponentConfig(componentName?: string, forceCustomWrapper?: boolean): any;
|
|
@@ -4,7 +4,7 @@ import { taroWindowProvider } from '../bom/window.js';
|
|
|
4
4
|
import { PAGE_INIT, OPTIONS, EXTERNAL_CLASSES, BEHAVIORS, CONTEXT_ACTIONS, VIEW, ON_HIDE, ON_READY, ON_SHOW, ON_LOAD, CUSTOM_WRAPPER } from '../constants/index.js';
|
|
5
5
|
import { Current } from '../current.js';
|
|
6
6
|
import { eventHandler } from '../dom/event.js';
|
|
7
|
-
import {
|
|
7
|
+
import { invalidateNearestCtx } from '../dom/nearest-ctx.js';
|
|
8
8
|
import { eventCenter } from '../emitter/emitter.js';
|
|
9
9
|
import env from '../env.js';
|
|
10
10
|
import { perf } from '../perf.js';
|
|
@@ -70,9 +70,8 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
70
70
|
// 小程序 Page 构造器是一个傲娇小公主,不能把复杂的对象挂载到参数上
|
|
71
71
|
const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
|
|
72
72
|
const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES,] = hooks.call('getMiniLifecycleImpl').page;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let prepareMountList = [];
|
|
73
|
+
// Native instances of the same route have independent lifecycle completion.
|
|
74
|
+
const hasLoaded = new WeakMap();
|
|
76
75
|
function setCurrentRouter(page) {
|
|
77
76
|
const router = process.env.TARO_PLATFORM === 'web' ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
|
|
78
77
|
Current.router = {
|
|
@@ -87,91 +86,40 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
87
86
|
Current.router.exitState = page.exitState;
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
|
-
let loadResolver;
|
|
91
|
-
let hasLoaded;
|
|
92
89
|
const config = {
|
|
93
|
-
[ONLOAD](
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
config.__vpt_meta.prerenderIdentity = undefined;
|
|
102
|
-
}
|
|
103
|
-
const uniqueOptions = prerenderIdentity?.params ?? Object.assign({}, options, { $taroTimestamp: Date.now() });
|
|
104
|
-
const $taroPath = this.$taroPath = prerenderIdentity?.path ?? getPath(id, uniqueOptions);
|
|
105
|
-
if (process.env.TARO_PLATFORM === 'web') {
|
|
106
|
-
config.path = $taroPath;
|
|
107
|
-
}
|
|
108
|
-
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
|
|
109
|
-
if (this.$taroParams == null) {
|
|
110
|
-
this.$taroParams = uniqueOptions;
|
|
111
|
-
}
|
|
112
|
-
setCurrentRouter(this);
|
|
113
|
-
// 初始化当前页面的上下文信息
|
|
114
|
-
if (process.env.TARO_PLATFORM !== 'web') {
|
|
115
|
-
taroWindowProvider.trigger(CONTEXT_ACTIONS.INIT, $taroPath);
|
|
116
|
-
}
|
|
117
|
-
const mount = () => {
|
|
118
|
-
Current.app.mount(component, $taroPath, () => {
|
|
119
|
-
if (process.env.TARO_ENV === 'tt' && isEnableTTDom()) {
|
|
120
|
-
pageElement = env.document.getPageDocumentById(this.__webviewId__);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
pageElement = env.document.getElementById($taroPath);
|
|
124
|
-
}
|
|
125
|
-
ensure(pageElement !== null, '没有找到页面实例。');
|
|
126
|
-
safeExecute($taroPath, ON_LOAD, this.$taroParams);
|
|
127
|
-
loadResolver();
|
|
128
|
-
if (process.env.TARO_PLATFORM !== 'web') {
|
|
129
|
-
pageElement.ctx = this;
|
|
130
|
-
bumpNearestCtxEpochForRoot(pageElement);
|
|
131
|
-
if (process.env.TARO_ENV === 'tt' && isEnableTTDom()) {
|
|
132
|
-
pageElement.sync();
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
pageElement.performUpdate(true, cb);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
isFunction(cb) && cb();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
90
|
+
[ONLOAD](_options, mount) {
|
|
91
|
+
// Resolve this instance's lifecycle barrier after its load handlers run.
|
|
92
|
+
let loadResolver;
|
|
93
|
+
hasLoaded.set(this, new Promise(resolve => { loadResolver = resolve; }));
|
|
94
|
+
const dispatch = () => {
|
|
95
|
+
const result = safeExecute(this.$taroPath, ON_LOAD, this.$taroParams);
|
|
96
|
+
loadResolver();
|
|
97
|
+
return result;
|
|
142
98
|
};
|
|
143
|
-
|
|
144
|
-
prepareMountList.push(mount);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
mount();
|
|
148
|
-
}
|
|
99
|
+
return mount ? mount(dispatch) : dispatch();
|
|
149
100
|
},
|
|
150
101
|
[ONUNLOAD]() {
|
|
151
102
|
const $taroPath = this.$taroPath;
|
|
103
|
+
const pageElement = process.env.TARO_ENV === 'tt' && isEnableTTDom()
|
|
104
|
+
? env.document.getPageDocumentById(this.__webviewId__)
|
|
105
|
+
: env.document.getElementById($taroPath);
|
|
152
106
|
// 销毁当前页面的上下文信息
|
|
153
107
|
if (process.env.TARO_PLATFORM !== 'web') {
|
|
154
108
|
taroWindowProvider.trigger(CONTEXT_ACTIONS.DESTROY, $taroPath);
|
|
155
109
|
}
|
|
156
110
|
// 触发onUnload生命周期
|
|
157
111
|
safeExecute($taroPath, ONUNLOAD);
|
|
158
|
-
unmounting = true;
|
|
159
112
|
Current.app.unmount($taroPath, () => {
|
|
160
|
-
|
|
113
|
+
hasLoaded.delete(this);
|
|
161
114
|
instances.delete($taroPath);
|
|
162
115
|
if (pageElement) {
|
|
163
|
-
|
|
116
|
+
invalidateNearestCtx(pageElement);
|
|
164
117
|
pageElement.ctx = null;
|
|
165
|
-
pageElement = null;
|
|
166
|
-
}
|
|
167
|
-
if (prepareMountList.length) {
|
|
168
|
-
prepareMountList.forEach(fn => fn());
|
|
169
|
-
prepareMountList = [];
|
|
170
118
|
}
|
|
171
119
|
});
|
|
172
120
|
},
|
|
173
121
|
[ONREADY]() {
|
|
174
|
-
hasLoaded.then(() => {
|
|
122
|
+
hasLoaded.get(this).then(() => {
|
|
175
123
|
// 触发生命周期
|
|
176
124
|
safeExecute(this.$taroPath, ON_READY);
|
|
177
125
|
// 通过事件触发子组件的生命周期
|
|
@@ -180,7 +128,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
180
128
|
});
|
|
181
129
|
},
|
|
182
130
|
[ONSHOW](options = {}) {
|
|
183
|
-
hasLoaded.then(() => {
|
|
131
|
+
hasLoaded.get(this).then(() => {
|
|
184
132
|
// 设置 Current 的 page 和 router
|
|
185
133
|
Current.page = this;
|
|
186
134
|
setCurrentRouter(this);
|
|
@@ -242,7 +190,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
242
190
|
return exec();
|
|
243
191
|
}
|
|
244
192
|
if (isDefer) {
|
|
245
|
-
hasLoaded.then(exec);
|
|
193
|
+
hasLoaded.get(this).then(exec);
|
|
246
194
|
}
|
|
247
195
|
else {
|
|
248
196
|
return exec();
|
|
@@ -341,7 +289,7 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
|
|
|
341
289
|
const el = env.document.getElementById(componentId);
|
|
342
290
|
if (el) {
|
|
343
291
|
el.ctx = this;
|
|
344
|
-
|
|
292
|
+
invalidateNearestCtx(el);
|
|
345
293
|
}
|
|
346
294
|
}
|
|
347
295
|
},
|
|
@@ -358,7 +306,7 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
|
|
|
358
306
|
const el = env.document.getElementById(componentId);
|
|
359
307
|
if (el) {
|
|
360
308
|
el.ctx = null;
|
|
361
|
-
|
|
309
|
+
invalidateNearestCtx(el);
|
|
362
310
|
}
|
|
363
311
|
}
|
|
364
312
|
}
|
|
@@ -26,7 +26,8 @@ interface ReactAppInstance<T = AppInstance> extends Component$1<T>, AppInstance
|
|
|
26
26
|
interface PageLifeCycle extends Show {
|
|
27
27
|
eh?(event: MpEvent): void;
|
|
28
28
|
onAddToFavorites?(): void;
|
|
29
|
-
|
|
29
|
+
/** Dispatches $taroParams; mount receives the load callback after lifecycle ordering is initialized. */
|
|
30
|
+
onLoad?(options: Record<string, unknown>, mount?: TFunc): void;
|
|
30
31
|
onOptionMenuClick?(): void;
|
|
31
32
|
onKeyboardHeight?(obj: {
|
|
32
33
|
height: number;
|
|
@@ -56,8 +57,6 @@ interface PageLifeCycle extends Show {
|
|
|
56
57
|
onUnload?(): void;
|
|
57
58
|
}
|
|
58
59
|
interface PageInstance extends PageLifeCycle {
|
|
59
|
-
/** @internal VPT metadata; native onLoad consumes the prepared identity once. */
|
|
60
|
-
__vpt_meta?: { prerenderIdentity?: { path: string; params: Record<string, unknown> } };
|
|
61
60
|
/** 页面的初始数据 */
|
|
62
61
|
data?: Record<string, unknown> | (() => Record<string, unknown>);
|
|
63
62
|
/** 页面路径 */
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { taroHistoryProvider as history, taroLocationProvider as location, taroW
|
|
|
12
12
|
export { TaroElement } from './dom/element.js';
|
|
13
13
|
export { TaroEvent, createEvent, eventHandler, eventHandlerTTDom } from './dom/event.js';
|
|
14
14
|
export { FormElement } from './dom/form.js';
|
|
15
|
-
export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv } from './dom/nearest-ctx.js';
|
|
15
|
+
export { bumpNearestCtxEpochForRoot, getNearestCtx, invalidateNearestCtx, isNearestCtxEnv } from './dom/nearest-ctx.js';
|
|
16
16
|
export { TaroNode } from './dom/node.js';
|
|
17
17
|
export { TaroRootElement } from './dom/root.js';
|
|
18
18
|
export { Style } from './dom/style.js';
|
package/dist/runtime/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { taroHistoryProvider as history, taroLocationProvider as location, taroW
|
|
|
13
13
|
export { TaroElement } from './dom/element.js';
|
|
14
14
|
export { TaroEvent, createEvent, eventHandler, eventHandlerTTDom } from './dom/event.js';
|
|
15
15
|
export { FormElement } from './dom/form.js';
|
|
16
|
-
export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv } from './dom/nearest-ctx.js';
|
|
16
|
+
export { bumpNearestCtxEpochForRoot, getNearestCtx, invalidateNearestCtx, isNearestCtxEnv } from './dom/nearest-ctx.js';
|
|
17
17
|
export { TaroNode } from './dom/node.js';
|
|
18
18
|
export { TaroRootElement } from './dom/root.js';
|
|
19
19
|
export { Style } from './dom/style.js';
|
|
@@ -57,7 +57,7 @@ function isParentBound(node, type) {
|
|
|
57
57
|
if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
|
-
else if ((_a = node.
|
|
60
|
+
else if ((_a = node.getEventHandlers(type)) === null || _a === void 0 ? void 0 : _a.length) {
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.0",
|
|
4
4
|
"description": "Taro runtime, React, and platform support for vite-plugin-taro.",
|
|
5
5
|
"author": "sep2",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,6 +72,11 @@
|
|
|
72
72
|
},
|
|
73
73
|
"./plugin-framework-react/runtime": "./dist/plugin-framework-react/runtime.js",
|
|
74
74
|
"./plugin-html/runtime": "./dist/plugin-html/runtime.js",
|
|
75
|
+
"./plugin-html/html-elements": {
|
|
76
|
+
"types": "./dist/plugin-html/html-elements.d.ts",
|
|
77
|
+
"import": "./dist/plugin-html/html-elements.js",
|
|
78
|
+
"default": "./dist/plugin-html/html-elements.js"
|
|
79
|
+
},
|
|
75
80
|
"./plugin-platform-weapp/runtime": "./dist/plugin-platform-weapp/runtime.js",
|
|
76
81
|
"./plugin-platform-weapp/components-react": {
|
|
77
82
|
"types": "./dist/plugin-platform-weapp/types/components-react.d.ts",
|
|
@@ -119,6 +124,7 @@
|
|
|
119
124
|
"README.md"
|
|
120
125
|
],
|
|
121
126
|
"sideEffects": [
|
|
127
|
+
"./dist/runtime/index.js",
|
|
122
128
|
"./dist/runtime/dom-external/index.js",
|
|
123
129
|
"./dist/react/react.esm.js",
|
|
124
130
|
"./dist/plugin-framework-react/runtime.js",
|
package/types/tt-document.d.ts
CHANGED
|
@@ -13,13 +13,30 @@ export interface TTNativeNode {
|
|
|
13
13
|
removeChild(child: TTNativeNode): void
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/** SDK Style exposes dynamic property setters alongside its whole-style and CSS-variable APIs. */
|
|
17
|
+
export interface TTNativeStyle {
|
|
18
|
+
[name: string]: unknown
|
|
19
|
+
cssText: string
|
|
20
|
+
setProperty(name: string, value: string | number): void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 已核对的 TT SDK 4.4.0.3 包装事件在此保留原始平台负载,供 Taro 共享事件流程构造逻辑事件。
|
|
25
|
+
* 这里只声明桥接实际读取的形状;上游提供对应事件类型后可直接复用其声明。
|
|
26
|
+
* Taro 原生事件入口若直接接受 SDK 事件并完成负载转换,host 可移除对 _rawEvent 的依赖。
|
|
27
|
+
*/
|
|
28
|
+
export interface TTNativeEvent {
|
|
29
|
+
readonly _rawEvent: { readonly data: MpEvent }
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
export interface TTNativeElement extends TTNativeNode {
|
|
17
33
|
id: string
|
|
34
|
+
readonly style: TTNativeStyle
|
|
18
35
|
readonly attributes: Readonly<Record<string, unknown>>
|
|
19
36
|
setAttribute(name: string, value: unknown): void
|
|
20
37
|
removeAttribute(name: string): void
|
|
21
|
-
addEventListener(name: string, listener: (event:
|
|
22
|
-
removeEventListener(name: string, listener: (event:
|
|
38
|
+
addEventListener(name: string, listener: (event: TTNativeEvent) => unknown): void
|
|
39
|
+
removeEventListener(name: string, listener: (event: TTNativeEvent) => unknown): void
|
|
23
40
|
}
|
|
24
41
|
|
|
25
42
|
export interface TTNativeComponent extends TTNativeElement {
|
|
@@ -31,6 +48,8 @@ export interface TTNativeComponent extends TTNativeElement {
|
|
|
31
48
|
export interface TTNativeDocument {
|
|
32
49
|
getPageDocumentById(id: number): TTNativeElement | undefined
|
|
33
50
|
createElement(name: string): TTNativeElement
|
|
51
|
+
/** Creates a native component resolved from the owning Page's registration, using Taro's SDK options. */
|
|
52
|
+
createNativeComponent(name: string, options: { __tt__inner__options__: { name: string } }): TTNativeComponent
|
|
34
53
|
createTextNode(text: string): TTNativeNode
|
|
35
54
|
}
|
|
36
55
|
|