@wdio/browser-runner 9.0.0-alpha.78 → 9.0.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/build/browser/driver.js +249 -234
- package/build/browser/expect.js +107 -148
- package/build/browser/frameworks/mocha.d.ts.map +1 -1
- package/build/browser/integrations/stencil.js +370 -407
- package/build/browser/mock.d.ts +3 -2
- package/build/browser/mock.d.ts.map +1 -1
- package/build/browser/mock.js +78 -34
- package/build/browser/setup.js +313 -37
- package/build/browser/spy.d.ts.map +1 -1
- package/build/browser/spy.js +29 -40
- package/build/browser/utils.d.ts +7 -0
- package/build/browser/utils.d.ts.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1465 -171
- package/build/types.d.ts +19 -2
- package/build/types.d.ts.map +1 -1
- package/build/utils.d.ts +3 -3
- package/build/utils.d.ts.map +1 -1
- package/build/vite/constants.d.ts +3 -0
- package/build/vite/constants.d.ts.map +1 -1
- package/build/vite/plugins/esbuild.d.ts.map +1 -1
- package/build/vite/plugins/testrunner.d.ts.map +1 -1
- package/build/vite/server.d.ts +0 -1
- package/build/vite/server.d.ts.map +1 -1
- package/build/vite/utils.d.ts.map +1 -1
- package/package.json +57 -26
- package/build/browser/commands/debug.js +0 -6
- package/build/browser/frameworks/mocha.js +0 -320
- package/build/browser/utils.js +0 -61
- package/build/communicator.js +0 -82
- package/build/constants.js +0 -89
- package/build/types.js +0 -1
- package/build/utils.js +0 -86
- package/build/vite/constants.js +0 -55
- package/build/vite/frameworks/index.js +0 -19
- package/build/vite/frameworks/nuxt.js +0 -61
- package/build/vite/frameworks/stencil.js +0 -165
- package/build/vite/frameworks/tailwindcss.js +0 -28
- package/build/vite/mock.js +0 -50
- package/build/vite/plugins/esbuild.js +0 -25
- package/build/vite/plugins/mockHoisting.js +0 -312
- package/build/vite/plugins/testrunner.js +0 -152
- package/build/vite/plugins/worker.js +0 -12
- package/build/vite/server.js +0 -104
- package/build/vite/types.js +0 -1
- package/build/vite/utils.js +0 -223
- /package/{LICENSE-MIT → LICENSE} +0 -0
|
@@ -1,431 +1,394 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// src/browser/integrations/stencil.ts
|
|
2
|
+
import { h } from "@stencil/core";
|
|
3
|
+
import { $ } from "@wdio/globals";
|
|
4
|
+
import {
|
|
5
|
+
bootstrapLazy,
|
|
6
|
+
flushAll,
|
|
7
|
+
insertVdomAnnotations,
|
|
8
|
+
registerComponents,
|
|
9
|
+
registerModule,
|
|
10
|
+
renderVdom,
|
|
11
|
+
setSupportsShadowDom,
|
|
12
|
+
startAutoApplyChanges,
|
|
13
|
+
styles,
|
|
14
|
+
writeTask
|
|
15
|
+
} from "@stencil/core/internal/testing/index.js";
|
|
7
16
|
process.nextTick = (cb) => setTimeout(cb, 0);
|
|
8
|
-
/**
|
|
9
|
-
* in case the user has his tsconfig.json configured to expect "jsx" to be "react"
|
|
10
|
-
*/
|
|
11
|
-
// @ts-expect-error
|
|
12
17
|
window.React = {
|
|
13
|
-
|
|
18
|
+
createElement: h
|
|
14
19
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (opts.
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
styles,
|
|
89
|
-
flushAll,
|
|
90
|
-
unmount: () => container.remove()
|
|
20
|
+
function render(opts) {
|
|
21
|
+
if (!opts) {
|
|
22
|
+
throw new Error("NewSpecPageOptions required");
|
|
23
|
+
}
|
|
24
|
+
const components = opts.components || [];
|
|
25
|
+
const stencilStage = document.querySelector("stencil-stage");
|
|
26
|
+
if (stencilStage) {
|
|
27
|
+
stencilStage.remove();
|
|
28
|
+
}
|
|
29
|
+
const container = document.createElement("stencil-stage");
|
|
30
|
+
document.body.appendChild(container);
|
|
31
|
+
if (Array.isArray(components)) {
|
|
32
|
+
registerComponents(components);
|
|
33
|
+
}
|
|
34
|
+
if (opts.hydrateClientSide) {
|
|
35
|
+
opts.includeAnnotations = true;
|
|
36
|
+
}
|
|
37
|
+
if (opts.hydrateServerSide) {
|
|
38
|
+
opts.includeAnnotations = true;
|
|
39
|
+
setSupportsShadowDom(false);
|
|
40
|
+
} else {
|
|
41
|
+
opts.includeAnnotations = !!opts.includeAnnotations;
|
|
42
|
+
if (opts.supportsShadowDom === false) {
|
|
43
|
+
setSupportsShadowDom(false);
|
|
44
|
+
} else {
|
|
45
|
+
setSupportsShadowDom(true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const cmpTags = /* @__PURE__ */ new Set();
|
|
49
|
+
const lazyBundles = components.map((Cstr) => {
|
|
50
|
+
if (Cstr.COMPILER_META == null) {
|
|
51
|
+
throw new Error('Invalid component class: Missing static "COMPILER_META" property.');
|
|
52
|
+
}
|
|
53
|
+
cmpTags.add(Cstr.COMPILER_META.tagName);
|
|
54
|
+
Cstr.isProxied = false;
|
|
55
|
+
proxyComponentLifeCycles(Cstr);
|
|
56
|
+
const bundleId = `${Cstr.COMPILER_META.tagName}.${Math.round(Math.random() * 899999) + 1e5}`;
|
|
57
|
+
const stylesMeta = Cstr.COMPILER_META.styles;
|
|
58
|
+
if (Array.isArray(stylesMeta)) {
|
|
59
|
+
if (stylesMeta.length > 1) {
|
|
60
|
+
const styles2 = {};
|
|
61
|
+
stylesMeta.forEach((style) => {
|
|
62
|
+
styles2[style.modeName] = style.styleStr;
|
|
63
|
+
});
|
|
64
|
+
Cstr.style = styles2;
|
|
65
|
+
} else if (stylesMeta.length === 1) {
|
|
66
|
+
Cstr.style = stylesMeta[0].styleStr;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
registerModule(bundleId, Cstr);
|
|
70
|
+
if (!customElements.get(Cstr.COMPILER_META.tagName)) {
|
|
71
|
+
customElements.define(Cstr.COMPILER_META.tagName, Cstr);
|
|
72
|
+
}
|
|
73
|
+
const lazyBundleRuntimeMeta = formatLazyBundleRuntimeMeta(bundleId, [Cstr.COMPILER_META]);
|
|
74
|
+
return lazyBundleRuntimeMeta;
|
|
75
|
+
});
|
|
76
|
+
const page = {
|
|
77
|
+
container,
|
|
78
|
+
styles,
|
|
79
|
+
flushAll,
|
|
80
|
+
unmount: () => container.remove()
|
|
81
|
+
};
|
|
82
|
+
if (typeof opts.direction === "string") {
|
|
83
|
+
document.documentElement.setAttribute("dir", opts.direction);
|
|
84
|
+
}
|
|
85
|
+
if (typeof opts.language === "string") {
|
|
86
|
+
document.documentElement.setAttribute("lang", opts.language);
|
|
87
|
+
}
|
|
88
|
+
bootstrapLazy(lazyBundles);
|
|
89
|
+
if (typeof opts.template === "function") {
|
|
90
|
+
const cmpMeta = {
|
|
91
|
+
$flags$: 0,
|
|
92
|
+
$tagName$: "body"
|
|
91
93
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(page, '$container', {
|
|
134
|
-
get() {
|
|
135
|
-
return $(container);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
if (opts.hydrateServerSide) {
|
|
139
|
-
insertVdomAnnotations(document, []);
|
|
140
|
-
}
|
|
141
|
-
if (opts.autoApplyChanges) {
|
|
142
|
-
startAutoApplyChanges();
|
|
143
|
-
}
|
|
144
|
-
return page;
|
|
94
|
+
const ref = {
|
|
95
|
+
$ancestorComponent$: void 0,
|
|
96
|
+
$flags$: 0,
|
|
97
|
+
$modeName$: void 0,
|
|
98
|
+
$cmpMeta$: cmpMeta,
|
|
99
|
+
$hostElement$: container
|
|
100
|
+
};
|
|
101
|
+
renderVdom(ref, opts.template());
|
|
102
|
+
} else if (typeof opts.html === "string") {
|
|
103
|
+
container.innerHTML = opts.html;
|
|
104
|
+
}
|
|
105
|
+
let rootComponent = null;
|
|
106
|
+
Object.defineProperty(page, "root", {
|
|
107
|
+
get() {
|
|
108
|
+
if (!rootComponent) {
|
|
109
|
+
rootComponent = findRootComponent(cmpTags, container);
|
|
110
|
+
}
|
|
111
|
+
if (rootComponent) {
|
|
112
|
+
return rootComponent;
|
|
113
|
+
}
|
|
114
|
+
return container.firstElementChild;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(page, "$root", {
|
|
118
|
+
get() {
|
|
119
|
+
return $(page.root);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(page, "$container", {
|
|
123
|
+
get() {
|
|
124
|
+
return $(container);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
if (opts.hydrateServerSide) {
|
|
128
|
+
insertVdomAnnotations(document, []);
|
|
129
|
+
}
|
|
130
|
+
if (opts.autoApplyChanges) {
|
|
131
|
+
startAutoApplyChanges();
|
|
132
|
+
}
|
|
133
|
+
return page;
|
|
145
134
|
}
|
|
146
|
-
/**
|
|
147
|
-
* A helper method that proxies Stencil lifecycle methods by mutating the provided component class
|
|
148
|
-
* @param Cstr the component class whose lifecycle methods will be proxied
|
|
149
|
-
*/
|
|
150
135
|
function proxyComponentLifeCycles(Cstr) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
writeTask(() => result);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
writeTask(() => Promise.resolve());
|
|
203
|
-
}
|
|
204
|
-
return result;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
136
|
+
if (typeof Cstr.prototype?.__componentWillLoad === "function") {
|
|
137
|
+
Cstr.prototype.componentWillLoad = Cstr.prototype.__componentWillLoad;
|
|
138
|
+
Cstr.prototype.__componentWillLoad = null;
|
|
139
|
+
}
|
|
140
|
+
if (typeof Cstr.prototype?.__componentWillUpdate === "function") {
|
|
141
|
+
Cstr.prototype.componentWillUpdate = Cstr.prototype.__componentWillUpdate;
|
|
142
|
+
Cstr.prototype.__componentWillUpdate = null;
|
|
143
|
+
}
|
|
144
|
+
if (typeof Cstr.prototype?.__componentWillRender === "function") {
|
|
145
|
+
Cstr.prototype.componentWillRender = Cstr.prototype.__componentWillRender;
|
|
146
|
+
Cstr.prototype.__componentWillRender = null;
|
|
147
|
+
}
|
|
148
|
+
if (typeof Cstr.prototype?.componentWillLoad === "function") {
|
|
149
|
+
Cstr.prototype.__componentWillLoad = Cstr.prototype.componentWillLoad;
|
|
150
|
+
Cstr.prototype.componentWillLoad = function() {
|
|
151
|
+
const result = this.__componentWillLoad();
|
|
152
|
+
if (result && typeof result.then === "function") {
|
|
153
|
+
writeTask(() => result);
|
|
154
|
+
} else {
|
|
155
|
+
writeTask(() => Promise.resolve());
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (typeof Cstr.prototype?.componentWillUpdate === "function") {
|
|
161
|
+
Cstr.prototype.__componentWillUpdate = Cstr.prototype.componentWillUpdate;
|
|
162
|
+
Cstr.prototype.componentWillUpdate = function() {
|
|
163
|
+
const result = this.__componentWillUpdate();
|
|
164
|
+
if (result && typeof result.then === "function") {
|
|
165
|
+
writeTask(() => result);
|
|
166
|
+
} else {
|
|
167
|
+
writeTask(() => Promise.resolve());
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (typeof Cstr.prototype?.componentWillRender === "function") {
|
|
173
|
+
Cstr.prototype.__componentWillRender = Cstr.prototype.componentWillRender;
|
|
174
|
+
Cstr.prototype.componentWillRender = function() {
|
|
175
|
+
const result = this.__componentWillRender();
|
|
176
|
+
if (result && typeof result.then === "function") {
|
|
177
|
+
writeTask(() => result);
|
|
178
|
+
} else {
|
|
179
|
+
writeTask(() => Promise.resolve());
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
207
184
|
}
|
|
208
|
-
/**
|
|
209
|
-
* Return the first Element whose {@link Element#nodeName} property matches a tag found in the provided `cmpTags`
|
|
210
|
-
* argument.
|
|
211
|
-
*
|
|
212
|
-
* If the `nodeName` property on the element matches any of the names found in the provided `cmpTags` argument, that
|
|
213
|
-
* element is returned. If no match is found on the current element, the children will be inspected in a depth-first
|
|
214
|
-
* search manner. This process continues until either:
|
|
215
|
-
* - an element is found (and execution ends)
|
|
216
|
-
* - no element is found after an exhaustive search
|
|
217
|
-
*
|
|
218
|
-
* @param cmpTags component tag names to use in the match criteria
|
|
219
|
-
* @param node the node whose children are to be inspected
|
|
220
|
-
* @returns An element whose name matches one of the strings in the provided `cmpTags`. If no match is found, `null` is
|
|
221
|
-
* returned
|
|
222
|
-
*/
|
|
223
185
|
function findRootComponent(cmpTags, node) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
186
|
+
if (node) {
|
|
187
|
+
const children = node.children;
|
|
188
|
+
const childrenLength = children.length;
|
|
189
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
190
|
+
const elm = children[i];
|
|
191
|
+
if (cmpTags.has(elm.nodeName.toLowerCase())) {
|
|
192
|
+
return elm;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
196
|
+
const r = findRootComponent(cmpTags, children[i]);
|
|
197
|
+
if (r) {
|
|
198
|
+
return r;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
function waitForChanges(documentElement = document.documentElement) {
|
|
205
|
+
return new Promise((resolve) => {
|
|
206
|
+
requestAnimationFrame(() => {
|
|
207
|
+
const promiseChain = [];
|
|
208
|
+
const waitComponentOnReady = (elm, promises) => {
|
|
209
|
+
if ("shadowRoot" in elm && elm.shadowRoot instanceof ShadowRoot) {
|
|
210
|
+
waitComponentOnReady(elm.shadowRoot, promises);
|
|
232
211
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
212
|
+
const children = elm.children;
|
|
213
|
+
const len = children.length;
|
|
214
|
+
for (let i = 0; i < len; i++) {
|
|
215
|
+
const childElm = children[i];
|
|
216
|
+
const childStencilElm = childElm;
|
|
217
|
+
if (childElm.tagName.includes("-") && typeof childStencilElm.componentOnReady === "function") {
|
|
218
|
+
promises.push(childStencilElm.componentOnReady().then(() => {
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
waitComponentOnReady(childElm, promises);
|
|
238
222
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Helper method to wait until all Stencil components are rendered
|
|
244
|
-
*/
|
|
245
|
-
export function waitForChanges(documentElement = document.documentElement) {
|
|
246
|
-
return new Promise((resolve) => {
|
|
247
|
-
requestAnimationFrame(() => {
|
|
248
|
-
const promiseChain = [];
|
|
249
|
-
const waitComponentOnReady = (elm, promises) => {
|
|
250
|
-
if ('shadowRoot' in elm && elm.shadowRoot instanceof ShadowRoot) {
|
|
251
|
-
waitComponentOnReady(elm.shadowRoot, promises);
|
|
252
|
-
}
|
|
253
|
-
const children = elm.children;
|
|
254
|
-
const len = children.length;
|
|
255
|
-
for (let i = 0; i < len; i++) {
|
|
256
|
-
const childElm = children[i];
|
|
257
|
-
const childStencilElm = childElm;
|
|
258
|
-
if (childElm.tagName.includes('-') && typeof childStencilElm.componentOnReady === 'function') {
|
|
259
|
-
promises.push(childStencilElm.componentOnReady().then(() => { }));
|
|
260
|
-
}
|
|
261
|
-
waitComponentOnReady(childElm, promises);
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
waitComponentOnReady(documentElement, promiseChain);
|
|
265
|
-
Promise.all(promiseChain)
|
|
266
|
-
.then(() => resolve())
|
|
267
|
-
.catch(() => resolve());
|
|
268
|
-
});
|
|
223
|
+
};
|
|
224
|
+
waitComponentOnReady(documentElement, promiseChain);
|
|
225
|
+
Promise.all(promiseChain).then(() => resolve()).catch(() => resolve());
|
|
269
226
|
});
|
|
227
|
+
});
|
|
270
228
|
}
|
|
271
|
-
|
|
272
|
-
|
|
229
|
+
var CMP_FLAGS = /* @__PURE__ */ ((CMP_FLAGS2) => {
|
|
230
|
+
CMP_FLAGS2[CMP_FLAGS2["shadowDomEncapsulation"] = 1] = "shadowDomEncapsulation";
|
|
231
|
+
CMP_FLAGS2[CMP_FLAGS2["scopedCssEncapsulation"] = 2] = "scopedCssEncapsulation";
|
|
232
|
+
CMP_FLAGS2[CMP_FLAGS2["hasSlotRelocation"] = 4] = "hasSlotRelocation";
|
|
233
|
+
CMP_FLAGS2[CMP_FLAGS2["needsShadowDomShim"] = 8] = "needsShadowDomShim";
|
|
234
|
+
CMP_FLAGS2[CMP_FLAGS2["shadowDelegatesFocus"] = 16] = "shadowDelegatesFocus";
|
|
235
|
+
CMP_FLAGS2[CMP_FLAGS2["hasMode"] = 32] = "hasMode";
|
|
236
|
+
CMP_FLAGS2[CMP_FLAGS2["needsScopedEncapsulation"] = 10] = "needsScopedEncapsulation";
|
|
237
|
+
return CMP_FLAGS2;
|
|
238
|
+
})(CMP_FLAGS || {});
|
|
239
|
+
var formatLazyBundleRuntimeMeta = (bundleId, cmps) => {
|
|
240
|
+
return [bundleId, cmps.map((cmp) => formatComponentRuntimeMeta(cmp, true))];
|
|
273
241
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
const members = formatComponentRuntimeMembers(compilerMeta, includeMethods);
|
|
300
|
-
const hostListeners = formatHostListeners(compilerMeta);
|
|
301
|
-
return trimFalsy([
|
|
302
|
-
flags,
|
|
303
|
-
compilerMeta.tagName,
|
|
304
|
-
Object.keys(members).length > 0 ? members : undefined,
|
|
305
|
-
hostListeners.length > 0 ? hostListeners : undefined,
|
|
306
|
-
]);
|
|
242
|
+
var formatComponentRuntimeMeta = (compilerMeta, includeMethods) => {
|
|
243
|
+
let flags = 0;
|
|
244
|
+
if (compilerMeta.encapsulation === "shadow") {
|
|
245
|
+
flags |= 1 /* shadowDomEncapsulation */;
|
|
246
|
+
if (compilerMeta.shadowDelegatesFocus) {
|
|
247
|
+
flags |= 16 /* shadowDelegatesFocus */;
|
|
248
|
+
}
|
|
249
|
+
} else if (compilerMeta.encapsulation === "scoped") {
|
|
250
|
+
flags |= 2 /* scopedCssEncapsulation */;
|
|
251
|
+
}
|
|
252
|
+
if (compilerMeta.encapsulation !== "shadow" && compilerMeta.htmlTagNames.includes("slot")) {
|
|
253
|
+
flags |= 4 /* hasSlotRelocation */;
|
|
254
|
+
}
|
|
255
|
+
if (compilerMeta.hasMode) {
|
|
256
|
+
flags |= 32 /* hasMode */;
|
|
257
|
+
}
|
|
258
|
+
const members = formatComponentRuntimeMembers(compilerMeta, includeMethods);
|
|
259
|
+
const hostListeners = formatHostListeners(compilerMeta);
|
|
260
|
+
return trimFalsy([
|
|
261
|
+
flags,
|
|
262
|
+
compilerMeta.tagName,
|
|
263
|
+
Object.keys(members).length > 0 ? members : void 0,
|
|
264
|
+
hostListeners.length > 0 ? hostListeners : void 0
|
|
265
|
+
]);
|
|
307
266
|
};
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
267
|
+
var formatComponentRuntimeMembers = (compilerMeta, includeMethods = true) => {
|
|
268
|
+
return {
|
|
269
|
+
...formatPropertiesRuntimeMember(compilerMeta.properties),
|
|
270
|
+
...formatStatesRuntimeMember(compilerMeta.states),
|
|
271
|
+
...includeMethods ? formatMethodsRuntimeMember(compilerMeta.methods) : {}
|
|
272
|
+
};
|
|
314
273
|
};
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
274
|
+
var formatPropertiesRuntimeMember = (properties) => {
|
|
275
|
+
const runtimeMembers = {};
|
|
276
|
+
properties.forEach((member) => {
|
|
277
|
+
runtimeMembers[member.name] = trimFalsy([
|
|
278
|
+
/**
|
|
279
|
+
* [0] member type
|
|
280
|
+
*/
|
|
281
|
+
formatFlags(member),
|
|
282
|
+
formatAttrName(member)
|
|
283
|
+
]);
|
|
284
|
+
});
|
|
285
|
+
return runtimeMembers;
|
|
327
286
|
};
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
287
|
+
var formatFlags = (compilerProperty) => {
|
|
288
|
+
let type = formatPropType(compilerProperty.type);
|
|
289
|
+
if (compilerProperty.mutable) {
|
|
290
|
+
type |= 1024 /* Mutable */;
|
|
291
|
+
}
|
|
292
|
+
if (compilerProperty.reflect) {
|
|
293
|
+
type |= 512 /* ReflectAttr */;
|
|
294
|
+
}
|
|
295
|
+
return type;
|
|
337
296
|
};
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
// property name and attribute name are not the same
|
|
347
|
-
// so we need to return the actual string value
|
|
348
|
-
// example: "multiWord" !== "multi-word"
|
|
349
|
-
return compilerProperty.attribute;
|
|
350
|
-
}
|
|
351
|
-
// we shouldn't even observe an attribute for this property
|
|
352
|
-
return undefined;
|
|
297
|
+
var formatAttrName = (compilerProperty) => {
|
|
298
|
+
if (typeof compilerProperty.attribute === "string") {
|
|
299
|
+
if (compilerProperty.name === compilerProperty.attribute) {
|
|
300
|
+
return void 0;
|
|
301
|
+
}
|
|
302
|
+
return compilerProperty.attribute;
|
|
303
|
+
}
|
|
304
|
+
return void 0;
|
|
353
305
|
};
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
306
|
+
var formatPropType = (type) => {
|
|
307
|
+
if (type === "string") {
|
|
308
|
+
return 1 /* String */;
|
|
309
|
+
}
|
|
310
|
+
if (type === "number") {
|
|
311
|
+
return 2 /* Number */;
|
|
312
|
+
}
|
|
313
|
+
if (type === "boolean") {
|
|
314
|
+
return 4 /* Boolean */;
|
|
315
|
+
}
|
|
316
|
+
if (type === "any") {
|
|
317
|
+
return 8 /* Any */;
|
|
318
|
+
}
|
|
319
|
+
return 16 /* Unknown */;
|
|
368
320
|
};
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
321
|
+
var formatStatesRuntimeMember = (states) => {
|
|
322
|
+
const runtimeMembers = {};
|
|
323
|
+
states.forEach((member) => {
|
|
324
|
+
runtimeMembers[member.name] = [
|
|
325
|
+
/**
|
|
326
|
+
* [0] member flags
|
|
327
|
+
*/
|
|
328
|
+
32 /* State */
|
|
329
|
+
];
|
|
330
|
+
});
|
|
331
|
+
return runtimeMembers;
|
|
377
332
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
333
|
+
var formatMethodsRuntimeMember = (methods) => {
|
|
334
|
+
const runtimeMembers = {};
|
|
335
|
+
methods.forEach((member) => {
|
|
336
|
+
runtimeMembers[member.name] = [
|
|
337
|
+
/**
|
|
338
|
+
* [0] member flags
|
|
339
|
+
*/
|
|
340
|
+
64 /* Method */
|
|
341
|
+
];
|
|
342
|
+
});
|
|
343
|
+
return runtimeMembers;
|
|
386
344
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
345
|
+
var formatHostListeners = (compilerMeta) => {
|
|
346
|
+
return compilerMeta.listeners.map((compilerListener) => {
|
|
347
|
+
const hostListener = [
|
|
348
|
+
computeListenerFlags(compilerListener),
|
|
349
|
+
compilerListener.name,
|
|
350
|
+
compilerListener.method
|
|
351
|
+
];
|
|
352
|
+
return hostListener;
|
|
353
|
+
});
|
|
396
354
|
};
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
355
|
+
var computeListenerFlags = (listener) => {
|
|
356
|
+
let flags = 0;
|
|
357
|
+
if (listener.capture) {
|
|
358
|
+
flags |= 2 /* Capture */;
|
|
359
|
+
}
|
|
360
|
+
if (listener.passive) {
|
|
361
|
+
flags |= 1 /* Passive */;
|
|
362
|
+
}
|
|
363
|
+
switch (listener.target) {
|
|
364
|
+
case "document":
|
|
365
|
+
flags |= 4 /* TargetDocument */;
|
|
366
|
+
break;
|
|
367
|
+
case "window":
|
|
368
|
+
flags |= 8 /* TargetWindow */;
|
|
369
|
+
break;
|
|
370
|
+
case "body":
|
|
371
|
+
flags |= 16 /* TargetBody */;
|
|
372
|
+
break;
|
|
373
|
+
case "parent":
|
|
374
|
+
flags |= 32 /* TargetParent */;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
return flags;
|
|
420
378
|
};
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
379
|
+
var trimFalsy = (data) => {
|
|
380
|
+
const arr = data;
|
|
381
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
382
|
+
if (arr[i]) {
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
arr.pop();
|
|
386
|
+
}
|
|
387
|
+
return arr;
|
|
388
|
+
};
|
|
389
|
+
export {
|
|
390
|
+
CMP_FLAGS,
|
|
391
|
+
formatComponentRuntimeMeta,
|
|
392
|
+
render,
|
|
393
|
+
waitForChanges
|
|
431
394
|
};
|