@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.
Files changed (47) hide show
  1. package/build/browser/driver.js +249 -234
  2. package/build/browser/expect.js +107 -148
  3. package/build/browser/frameworks/mocha.d.ts.map +1 -1
  4. package/build/browser/integrations/stencil.js +370 -407
  5. package/build/browser/mock.d.ts +3 -2
  6. package/build/browser/mock.d.ts.map +1 -1
  7. package/build/browser/mock.js +78 -34
  8. package/build/browser/setup.js +313 -37
  9. package/build/browser/spy.d.ts.map +1 -1
  10. package/build/browser/spy.js +29 -40
  11. package/build/browser/utils.d.ts +7 -0
  12. package/build/browser/utils.d.ts.map +1 -1
  13. package/build/index.d.ts.map +1 -1
  14. package/build/index.js +1465 -171
  15. package/build/types.d.ts +19 -2
  16. package/build/types.d.ts.map +1 -1
  17. package/build/utils.d.ts +3 -3
  18. package/build/utils.d.ts.map +1 -1
  19. package/build/vite/constants.d.ts +3 -0
  20. package/build/vite/constants.d.ts.map +1 -1
  21. package/build/vite/plugins/esbuild.d.ts.map +1 -1
  22. package/build/vite/plugins/testrunner.d.ts.map +1 -1
  23. package/build/vite/server.d.ts +0 -1
  24. package/build/vite/server.d.ts.map +1 -1
  25. package/build/vite/utils.d.ts.map +1 -1
  26. package/package.json +57 -26
  27. package/build/browser/commands/debug.js +0 -6
  28. package/build/browser/frameworks/mocha.js +0 -320
  29. package/build/browser/utils.js +0 -61
  30. package/build/communicator.js +0 -82
  31. package/build/constants.js +0 -89
  32. package/build/types.js +0 -1
  33. package/build/utils.js +0 -86
  34. package/build/vite/constants.js +0 -55
  35. package/build/vite/frameworks/index.js +0 -19
  36. package/build/vite/frameworks/nuxt.js +0 -61
  37. package/build/vite/frameworks/stencil.js +0 -165
  38. package/build/vite/frameworks/tailwindcss.js +0 -28
  39. package/build/vite/mock.js +0 -50
  40. package/build/vite/plugins/esbuild.js +0 -25
  41. package/build/vite/plugins/mockHoisting.js +0 -312
  42. package/build/vite/plugins/testrunner.js +0 -152
  43. package/build/vite/plugins/worker.js +0 -12
  44. package/build/vite/server.js +0 -104
  45. package/build/vite/types.js +0 -1
  46. package/build/vite/utils.js +0 -223
  47. /package/{LICENSE-MIT → LICENSE} +0 -0
@@ -1,431 +1,394 @@
1
- import { h } from '@stencil/core';
2
- import { $ } from '@wdio/globals';
3
- /**
4
- * Emulate Node.js `nextTick` function in browser.
5
- * This is used by Stencil.js internally.
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
- createElement: h
18
+ createElement: h
14
19
  };
15
- import { bootstrapLazy, flushAll, insertVdomAnnotations, registerComponents, registerModule, renderVdom, setSupportsShadowDom, startAutoApplyChanges, styles, writeTask,
16
- // @ts-expect-error
17
- } from '@stencil/core/internal/testing/index.js';
18
- /**
19
- * Creates a new spec page for unit testing
20
- * @param opts the options to apply to the spec page that influence its configuration and operation
21
- * @returns the created spec page
22
- */
23
- export function render(opts) {
24
- if (!opts) {
25
- throw new Error('NewSpecPageOptions required');
26
- }
27
- const components = opts.components || [];
28
- const stencilStage = document.querySelector('stencil-stage');
29
- if (stencilStage) {
30
- stencilStage.remove();
31
- }
32
- const container = document.createElement('stencil-stage');
33
- document.body.appendChild(container);
34
- if (Array.isArray(components)) {
35
- registerComponents(components);
36
- }
37
- if (opts.hydrateClientSide) {
38
- opts.includeAnnotations = true;
39
- }
40
- if (opts.hydrateServerSide) {
41
- opts.includeAnnotations = true;
42
- setSupportsShadowDom(false);
43
- }
44
- else {
45
- opts.includeAnnotations = !!opts.includeAnnotations;
46
- if (opts.supportsShadowDom === false) {
47
- setSupportsShadowDom(false);
48
- }
49
- else {
50
- setSupportsShadowDom(true);
51
- }
52
- }
53
- const cmpTags = new Set();
54
- const lazyBundles = components.map((Cstr) => {
55
- // eslint-disable-next-line eqeqeq
56
- if (Cstr.COMPILER_META == null) {
57
- throw new Error('Invalid component class: Missing static "COMPILER_META" property.');
58
- }
59
- cmpTags.add(Cstr.COMPILER_META.tagName);
60
- Cstr.isProxied = false;
61
- proxyComponentLifeCycles(Cstr);
62
- const bundleId = `${Cstr.COMPILER_META.tagName}.${Math.round(Math.random() * 899999) + 100000}`;
63
- const stylesMeta = Cstr.COMPILER_META.styles;
64
- if (Array.isArray(stylesMeta)) {
65
- if (stylesMeta.length > 1) {
66
- const styles = {};
67
- stylesMeta.forEach((style) => {
68
- styles[style.modeName] = style.styleStr;
69
- });
70
- Cstr.style = styles;
71
- }
72
- else if (stylesMeta.length === 1) {
73
- Cstr.style = stylesMeta[0].styleStr;
74
- }
75
- }
76
- registerModule(bundleId, Cstr);
77
- /**
78
- * Register the component as a custom element only if not already registered
79
- */
80
- if (!customElements.get(Cstr.COMPILER_META.tagName)) {
81
- customElements.define(Cstr.COMPILER_META.tagName, Cstr);
82
- }
83
- const lazyBundleRuntimeMeta = formatLazyBundleRuntimeMeta(bundleId, [Cstr.COMPILER_META]);
84
- return lazyBundleRuntimeMeta;
85
- });
86
- const page = {
87
- container,
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
- if (typeof opts.direction === 'string') {
93
- document.documentElement.setAttribute('dir', opts.direction);
94
- }
95
- if (typeof opts.language === 'string') {
96
- document.documentElement.setAttribute('lang', opts.language);
97
- }
98
- bootstrapLazy(lazyBundles);
99
- if (typeof opts.template === 'function') {
100
- const cmpMeta = {
101
- $flags$: 0,
102
- $tagName$: 'body',
103
- };
104
- const ref = {
105
- $ancestorComponent$: undefined,
106
- $flags$: 0,
107
- $modeName$: undefined,
108
- $cmpMeta$: cmpMeta,
109
- $hostElement$: container,
110
- };
111
- renderVdom(ref, opts.template());
112
- }
113
- else if (typeof opts.html === 'string') {
114
- container.innerHTML = opts.html;
115
- }
116
- let rootComponent = null;
117
- Object.defineProperty(page, 'root', {
118
- get() {
119
- if (!rootComponent) {
120
- rootComponent = findRootComponent(cmpTags, container);
121
- }
122
- if (rootComponent) {
123
- return rootComponent;
124
- }
125
- return container.firstElementChild;
126
- },
127
- });
128
- Object.defineProperty(page, '$root', {
129
- get() {
130
- return $(page.root);
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
- // we may have called this function on the class before, reset the state of the class
152
- if (typeof Cstr.prototype?.__componentWillLoad === 'function') {
153
- Cstr.prototype.componentWillLoad = Cstr.prototype.__componentWillLoad;
154
- Cstr.prototype.__componentWillLoad = null;
155
- }
156
- if (typeof Cstr.prototype?.__componentWillUpdate === 'function') {
157
- Cstr.prototype.componentWillUpdate = Cstr.prototype.__componentWillUpdate;
158
- Cstr.prototype.__componentWillUpdate = null;
159
- }
160
- if (typeof Cstr.prototype?.__componentWillRender === 'function') {
161
- Cstr.prototype.componentWillRender = Cstr.prototype.__componentWillRender;
162
- Cstr.prototype.__componentWillRender = null;
163
- }
164
- // the class should be in a known 'good' state to proxy functions
165
- if (typeof Cstr.prototype?.componentWillLoad === 'function') {
166
- Cstr.prototype.__componentWillLoad = Cstr.prototype.componentWillLoad;
167
- Cstr.prototype.componentWillLoad = function () {
168
- // @ts-expect-error
169
- const result = this.__componentWillLoad();
170
- if (result && typeof result.then === 'function') {
171
- writeTask(() => result);
172
- }
173
- else {
174
- writeTask(() => Promise.resolve());
175
- }
176
- return result;
177
- };
178
- }
179
- if (typeof Cstr.prototype?.componentWillUpdate === 'function') {
180
- Cstr.prototype.__componentWillUpdate = Cstr.prototype.componentWillUpdate;
181
- Cstr.prototype.componentWillUpdate = function () {
182
- // @ts-expect-error
183
- const result = this.__componentWillUpdate();
184
- if (result && typeof result.then === 'function') {
185
- writeTask(() => result);
186
- }
187
- else {
188
- writeTask(() => Promise.resolve());
189
- }
190
- return result;
191
- };
192
- }
193
- if (typeof Cstr.prototype?.componentWillRender === 'function') {
194
- Cstr.prototype.__componentWillRender = Cstr.prototype.componentWillRender;
195
- Cstr.prototype.componentWillRender = function () {
196
- // @ts-expect-error
197
- const result = this.__componentWillRender();
198
- if (result && typeof result.then === 'function') {
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
- if (node) {
225
- const children = node.children;
226
- const childrenLength = children.length;
227
- for (let i = 0; i < childrenLength; i++) {
228
- const elm = children[i];
229
- if (cmpTags.has(elm.nodeName.toLowerCase())) {
230
- return elm;
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
- for (let i = 0; i < childrenLength; i++) {
234
- const r = findRootComponent(cmpTags, children[i]);
235
- if (r) {
236
- return r;
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
- return null;
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
- const formatLazyBundleRuntimeMeta = (bundleId, cmps) => {
272
- return [bundleId, cmps.map((cmp) => formatComponentRuntimeMeta(cmp, true))];
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
- * Transform metadata about a component from the compiler to a compact form for
276
- * use at runtime.
277
- *
278
- * @param compilerMeta component metadata gathered during compilation
279
- * @param includeMethods include methods in the component's members or not
280
- * @returns a compact format for component metadata, intended for runtime use
281
- */
282
- export const formatComponentRuntimeMeta = (compilerMeta, includeMethods) => {
283
- let flags = 0;
284
- if (compilerMeta.encapsulation === 'shadow') {
285
- flags |= 1 /* CMP_FLAGS.shadowDomEncapsulation */;
286
- if (compilerMeta.shadowDelegatesFocus) {
287
- flags |= 16 /* CMP_FLAGS.shadowDelegatesFocus */;
288
- }
289
- }
290
- else if (compilerMeta.encapsulation === 'scoped') {
291
- flags |= 2 /* CMP_FLAGS.scopedCssEncapsulation */;
292
- }
293
- if (compilerMeta.encapsulation !== 'shadow' && compilerMeta.htmlTagNames.includes('slot')) {
294
- flags |= 4 /* CMP_FLAGS.hasSlotRelocation */;
295
- }
296
- if (compilerMeta.hasMode) {
297
- flags |= 32 /* CMP_FLAGS.hasMode */;
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
- const formatComponentRuntimeMembers = (compilerMeta, includeMethods = true) => {
309
- return {
310
- ...formatPropertiesRuntimeMember(compilerMeta.properties),
311
- ...formatStatesRuntimeMember(compilerMeta.states),
312
- ...(includeMethods ? formatMethodsRuntimeMember(compilerMeta.methods) : {}),
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
- const formatPropertiesRuntimeMember = (properties) => {
316
- const runtimeMembers = {};
317
- properties.forEach((member) => {
318
- runtimeMembers[member.name] = trimFalsy([
319
- /**
320
- * [0] member type
321
- */
322
- formatFlags(member),
323
- formatAttrName(member),
324
- ]);
325
- });
326
- return runtimeMembers;
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
- const formatFlags = (compilerProperty) => {
329
- let type = formatPropType(compilerProperty.type);
330
- if (compilerProperty.mutable) {
331
- type |= 1024 /* MEMBER_FLAGS.Mutable */;
332
- }
333
- if (compilerProperty.reflect) {
334
- type |= 512 /* MEMBER_FLAGS.ReflectAttr */;
335
- }
336
- return type;
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
- const formatAttrName = (compilerProperty) => {
339
- if (typeof compilerProperty.attribute === 'string') {
340
- // string attr name means we should observe this attribute
341
- if (compilerProperty.name === compilerProperty.attribute) {
342
- // property name and attribute name are the exact same
343
- // true value means to use the property name for the attribute name
344
- return undefined;
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
- const formatPropType = (type) => {
355
- if (type === 'string') {
356
- return 1 /* MEMBER_FLAGS.String */;
357
- }
358
- if (type === 'number') {
359
- return 2 /* MEMBER_FLAGS.Number */;
360
- }
361
- if (type === 'boolean') {
362
- return 4 /* MEMBER_FLAGS.Boolean */;
363
- }
364
- if (type === 'any') {
365
- return 8 /* MEMBER_FLAGS.Any */;
366
- }
367
- return 16 /* MEMBER_FLAGS.Unknown */;
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
- const formatStatesRuntimeMember = (states) => {
370
- const runtimeMembers = {};
371
- states.forEach((member) => {
372
- runtimeMembers[member.name] = [
373
- 32 /* MEMBER_FLAGS.State */,
374
- ];
375
- });
376
- return runtimeMembers;
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
- const formatMethodsRuntimeMember = (methods) => {
379
- const runtimeMembers = {};
380
- methods.forEach((member) => {
381
- runtimeMembers[member.name] = [
382
- 64 /* MEMBER_FLAGS.Method */,
383
- ];
384
- });
385
- return runtimeMembers;
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
- const formatHostListeners = (compilerMeta) => {
388
- return compilerMeta.listeners.map((compilerListener) => {
389
- const hostListener = [
390
- computeListenerFlags(compilerListener),
391
- compilerListener.name,
392
- compilerListener.method,
393
- ];
394
- return hostListener;
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
- const computeListenerFlags = (listener) => {
398
- let flags = 0;
399
- if (listener.capture) {
400
- flags |= 2 /* LISTENER_FLAGS.Capture */;
401
- }
402
- if (listener.passive) {
403
- flags |= 1 /* LISTENER_FLAGS.Passive */;
404
- }
405
- switch (listener.target) {
406
- case 'document':
407
- flags |= 4 /* LISTENER_FLAGS.TargetDocument */;
408
- break;
409
- case 'window':
410
- flags |= 8 /* LISTENER_FLAGS.TargetWindow */;
411
- break;
412
- case 'body':
413
- flags |= 16 /* LISTENER_FLAGS.TargetBody */;
414
- break;
415
- case 'parent':
416
- flags |= 32 /* LISTENER_FLAGS.TargetParent */;
417
- break;
418
- }
419
- return flags;
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
- const trimFalsy = (data) => {
422
- const arr = data;
423
- for (let i = arr.length - 1; i >= 0; i--) {
424
- if (arr[i]) {
425
- break;
426
- }
427
- // if falsy, safe to pop()
428
- arr.pop();
429
- }
430
- return arr;
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
  };