@rindo/core 2.17.4 → 2.22.2

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 (108) hide show
  1. package/cli/config-flags.d.ts +33 -21
  2. package/cli/index.cjs +693 -401
  3. package/cli/index.d.ts +3 -0
  4. package/cli/index.js +693 -401
  5. package/cli/package.json +1 -1
  6. package/compiler/lib.dom.d.ts +898 -184
  7. package/compiler/lib.dom.iterable.d.ts +22 -4
  8. package/compiler/lib.es2015.collection.d.ts +62 -1
  9. package/compiler/lib.es2015.core.d.ts +3 -3
  10. package/compiler/lib.es2015.iterable.d.ts +2 -1
  11. package/compiler/lib.es2015.promise.d.ts +9 -4
  12. package/compiler/lib.es2015.proxy.d.ts +91 -2
  13. package/compiler/lib.es2015.reflect.d.ts +26 -3
  14. package/compiler/lib.es2015.symbol.wellknown.d.ts +3 -3
  15. package/compiler/lib.es2017.intl.d.ts +16 -1
  16. package/compiler/lib.es2019.d.ts +1 -0
  17. package/compiler/lib.es2019.intl.d.ts +25 -0
  18. package/compiler/lib.es2020.bigint.d.ts +7 -5
  19. package/compiler/lib.es2020.d.ts +2 -0
  20. package/compiler/lib.es2020.date.d.ts +44 -0
  21. package/compiler/lib.es2020.intl.d.ts +81 -16
  22. package/compiler/lib.es2020.number.d.ts +30 -0
  23. package/compiler/lib.es2021.intl.d.ts +116 -6
  24. package/compiler/lib.es2022.array.d.ts +123 -0
  25. package/compiler/lib.es2022.d.ts +27 -0
  26. package/compiler/lib.es2022.error.d.ts +75 -0
  27. package/compiler/lib.es2022.full.d.ts +25 -0
  28. package/compiler/lib.es2022.intl.d.ts +111 -0
  29. package/compiler/lib.es2022.object.d.ts +28 -0
  30. package/compiler/lib.es2022.sharedmemory.d.ts +27 -0
  31. package/compiler/lib.es2022.string.d.ts +27 -0
  32. package/compiler/lib.es5.d.ts +62 -31
  33. package/compiler/lib.esnext.d.ts +1 -1
  34. package/compiler/lib.esnext.intl.d.ts +8 -1
  35. package/compiler/lib.webworker.d.ts +540 -81
  36. package/compiler/lib.webworker.iterable.d.ts +19 -4
  37. package/compiler/package.json +1 -1
  38. package/compiler/rindo.d.ts +3 -25
  39. package/compiler/rindo.js +54678 -52205
  40. package/compiler/rindo.min.js +2 -2
  41. package/compiler/sys/in-memory-fs.d.ts +218 -0
  42. package/compiler/transpile.d.ts +32 -0
  43. package/dependencies.json +12 -1
  44. package/dev-server/client/app-error.d.ts +1 -1
  45. package/dev-server/client/index.d.ts +2 -2
  46. package/dev-server/client/index.js +241 -241
  47. package/dev-server/client/package.json +1 -1
  48. package/dev-server/connector.html +3 -3
  49. package/dev-server/index.d.ts +1 -1
  50. package/dev-server/index.js +2 -2
  51. package/dev-server/open-in-editor-api.js +1 -1
  52. package/dev-server/package.json +1 -1
  53. package/dev-server/server-process.js +1192 -1158
  54. package/dev-server/ws.js +1 -1
  55. package/internal/app-data/package.json +1 -1
  56. package/internal/client/css-shim.js +2 -2
  57. package/internal/client/dom.js +1 -1
  58. package/internal/client/index.js +1130 -823
  59. package/internal/client/package.json +1 -1
  60. package/internal/client/patch-browser.js +19 -1
  61. package/internal/client/patch-esm.js +1 -1
  62. package/internal/client/polyfills/css-shim.js +1 -1
  63. package/internal/client/shadow-css.js +1 -1
  64. package/internal/hydrate/index.js +154 -143
  65. package/internal/hydrate/package.json +1 -1
  66. package/internal/hydrate/runner.d.ts +1 -1
  67. package/internal/hydrate/runner.js +106 -106
  68. package/internal/package.json +1 -1
  69. package/internal/rindo-core/index.d.ts +9 -10
  70. package/internal/rindo-private.d.ts +149 -184
  71. package/internal/rindo-public-compiler.d.ts +83 -38
  72. package/internal/rindo-public-docs.d.ts +24 -0
  73. package/internal/rindo-public-runtime.d.ts +79 -7
  74. package/internal/testing/index.js +187 -175
  75. package/internal/testing/package.json +1 -1
  76. package/mock-doc/index.cjs +526 -501
  77. package/mock-doc/index.d.ts +15 -14
  78. package/mock-doc/index.js +526 -501
  79. package/mock-doc/package.json +1 -1
  80. package/package.json +48 -59
  81. package/readme.md +44 -31
  82. package/screenshot/compare/build/p-f4745c2f.entry.js +1 -1
  83. package/screenshot/index.d.ts +1 -1
  84. package/screenshot/index.js +13 -13
  85. package/screenshot/package.json +1 -1
  86. package/screenshot/pixel-match.js +983 -849
  87. package/sys/node/autoprefixer.js +2 -2
  88. package/sys/node/glob.js +1 -1
  89. package/sys/node/index.d.ts +4 -0
  90. package/sys/node/index.js +399 -413
  91. package/sys/node/package.json +1 -1
  92. package/sys/node/prompts.js +1 -1
  93. package/sys/node/worker.js +1 -1
  94. package/testing/index.d.ts +6 -6
  95. package/testing/index.js +684 -839
  96. package/testing/jest/jest-config.d.ts +1 -1
  97. package/testing/jest/jest-preprocessor.d.ts +3 -3
  98. package/testing/jest/jest-serializer.d.ts +1 -2
  99. package/testing/matchers/index.d.ts +3 -3
  100. package/testing/mock-fetch.d.ts +1 -1
  101. package/testing/mocks.d.ts +2 -2
  102. package/testing/package.json +1 -1
  103. package/testing/puppeteer/puppeteer-declarations.d.ts +5 -5
  104. package/testing/puppeteer/puppeteer-element.d.ts +2 -2
  105. package/testing/puppeteer/puppeteer-events.d.ts +1 -1
  106. package/testing/testing-logger.d.ts +1 -1
  107. package/testing/testing-utils.d.ts +6 -5
  108. package/testing/testing.d.ts +1 -1
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Virtual DOM patching algorithm based on Snabbdom by
3
+ * Simon Friis Vindum (@paldepind)
4
+ * Licensed under the MIT License
5
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
6
+ *
7
+ * Modified for Rindo's renderer and slot projection
8
+ */
1
9
  let scopeId;
2
10
  let contentRef;
3
11
  let hostTagName;
@@ -11,129 +19,21 @@ let renderingRef = null;
11
19
  let queueCongestion = 0;
12
20
  let queuePending = false;
13
21
  /*
14
- Rindo Client Platform v2.17.4 | MIT Licensed | https://rindojs.web.app
22
+ Rindo Client Platform v2.22.2 | MIT Licensed | https://rindojs.web.app
15
23
  */
16
24
  import { BUILD, NAMESPACE } from '@rindo/core/internal/app-data';
17
- const win = typeof window !== 'undefined' ? window : {};
18
- const CSS = BUILD.cssVarShim ? win.CSS : null;
19
- const doc = win.document || { head: {} };
20
- const H = (win.HTMLElement || class {
21
- });
22
- const plt = {
23
- $flags$: 0,
24
- $resourcesUrl$: '',
25
- jmp: (h) => h(),
26
- raf: (h) => requestAnimationFrame(h),
27
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
28
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
29
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
30
- };
31
- const setPlatformHelpers = (helpers) => {
32
- Object.assign(plt, helpers);
25
+ const Build = {
26
+ isDev: BUILD.isDev ? true : false,
27
+ isBrowser: true,
28
+ isServer: false,
29
+ isTesting: BUILD.isTesting ? true : false,
33
30
  };
34
- const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
35
- ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
36
- : true;
37
- const supportsListenerOptions = /*@__PURE__*/ (() => {
38
- let supportsListenerOptions = false;
39
- try {
40
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
41
- get() {
42
- supportsListenerOptions = true;
43
- },
44
- }));
45
- }
46
- catch (e) { }
47
- return supportsListenerOptions;
48
- })();
49
- const promiseResolve = (v) => Promise.resolve(v);
50
- const supportsConstructableStylesheets = BUILD.constructableCSS
51
- ? /*@__PURE__*/ (() => {
52
- try {
53
- new CSSStyleSheet();
54
- return typeof new CSSStyleSheet().replaceSync === 'function';
55
- }
56
- catch (e) { }
57
- return false;
58
- })()
59
- : false;
60
31
  const Context = {};
61
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
62
- if (BUILD.hostListener && listeners) {
63
- // this is called immediately within the element's constructor
64
- // initialize our event listeners on the host element
65
- // we do this now so that we can listen to events that may
66
- // have fired even before the instance is ready
67
- if (BUILD.hostListenerTargetParent) {
68
- // this component may have event listeners that should be attached to the parent
69
- if (attachParentListeners) {
70
- // this is being ran from within the connectedCallback
71
- // which is important so that we know the host element actually has a parent element
72
- // filter out the listeners to only have the ones that ARE being attached to the parent
73
- listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
74
- }
75
- else {
76
- // this is being ran from within the component constructor
77
- // everything BUT the parent element listeners should be attached at this time
78
- // filter out the listeners that are NOT being attached to the parent
79
- listeners = listeners.filter(([flags]) => !(flags & 32 /* TargetParent */));
80
- }
81
- }
82
- listeners.map(([flags, name, method]) => {
83
- const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
84
- const handler = hostListenerProxy(hostRef, method);
85
- const opts = hostListenerOpts(flags);
86
- plt.ael(target, name, handler, opts);
87
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
88
- });
89
- }
90
- };
91
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
92
- try {
93
- if (BUILD.lazyLoad) {
94
- if (hostRef.$flags$ & 256 /* isListenReady */) {
95
- // instance is ready, let's call it's member method for this event
96
- hostRef.$lazyInstance$[methodName](ev);
97
- }
98
- else {
99
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
100
- }
101
- }
102
- else {
103
- hostRef.$hostElement$[methodName](ev);
104
- }
105
- }
106
- catch (e) {
107
- consoleError(e);
108
- }
109
- };
110
- const getHostListenerTarget = (elm, flags) => {
111
- if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
112
- return doc;
113
- if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
114
- return win;
115
- if (BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */)
116
- return doc.body;
117
- if (BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */)
118
- return elm.parentElement;
119
- return elm;
32
+ const getAssetPath = (path) => {
33
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
34
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
120
35
  };
121
- // prettier-ignore
122
- const hostListenerOpts = (flags) => supportsListenerOptions
123
- ? ({
124
- passive: (flags & 1 /* Passive */) !== 0,
125
- capture: (flags & 2 /* Capture */) !== 0,
126
- })
127
- : (flags & 2 /* Capture */) !== 0;
128
- const CONTENT_REF_ID = 'r';
129
- const ORG_LOCATION_ID = 'o';
130
- const SLOT_NODE_ID = 's';
131
- const TEXT_NODE_ID = 't';
132
- const HYDRATE_ID = 's-id';
133
- const HYDRATED_STYLE_ID = 'sty-id';
134
- const HYDRATE_CHILD_ID = 'c-id';
135
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
136
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
36
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
137
37
  const createTime = (fnName, tagName = '') => {
138
38
  if (BUILD.profile && performance.mark) {
139
39
  const key = `st:${fnName}:${tagName}:${i++}`;
@@ -150,11 +50,11 @@ const createTime = (fnName, tagName = '') => {
150
50
  };
151
51
  const uniqueTime = (key, measureText) => {
152
52
  if (BUILD.profile && performance.mark) {
153
- if (performance.getEntriesByName(key).length === 0) {
53
+ if (performance.getEntriesByName(key, 'mark').length === 0) {
154
54
  performance.mark(key);
155
55
  }
156
56
  return () => {
157
- if (performance.getEntriesByName(measureText).length === 0) {
57
+ if (performance.getEntriesByName(measureText, 'measure').length === 0) {
158
58
  performance.measure(measureText, key);
159
59
  }
160
60
  };
@@ -175,52 +75,575 @@ const inspect = (ref) => {
175
75
  return {
176
76
  renderCount: hostRef.$renderCount$,
177
77
  flags: {
178
- hasRendered: !!(flags & 2 /* hasRendered */),
179
- hasConnected: !!(flags & 1 /* hasConnected */),
180
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
181
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
182
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
183
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
184
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
185
- isWatchReady: !!(flags & 128 /* isWatchReady */),
186
- isListenReady: !!(flags & 256 /* isListenReady */),
187
- needsRerender: !!(flags & 512 /* needsRerender */),
78
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
79
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
80
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
81
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
82
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
83
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
84
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
85
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
86
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
87
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
88
+ },
89
+ instanceValues: hostRef.$instanceValues$,
90
+ ancestorComponent: hostRef.$ancestorComponent$,
91
+ hostElement,
92
+ lazyInstance: hostRef.$lazyInstance$,
93
+ vnode: hostRef.$vnode$,
94
+ modeName: hostRef.$modeName$,
95
+ onReadyPromise: hostRef.$onReadyPromise$,
96
+ onReadyResolve: hostRef.$onReadyResolve$,
97
+ onInstancePromise: hostRef.$onInstancePromise$,
98
+ onInstanceResolve: hostRef.$onInstanceResolve$,
99
+ onRenderResolve: hostRef.$onRenderResolve$,
100
+ queuedListeners: hostRef.$queuedListeners$,
101
+ rmListeners: hostRef.$rmListeners$,
102
+ ['s-id']: hostElement['s-id'],
103
+ ['s-cr']: hostElement['s-cr'],
104
+ ['s-lr']: hostElement['s-lr'],
105
+ ['s-p']: hostElement['s-p'],
106
+ ['s-rc']: hostElement['s-rc'],
107
+ ['s-sc']: hostElement['s-sc'],
108
+ };
109
+ };
110
+ const installDevTools = () => {
111
+ if (BUILD.devTools) {
112
+ const rindo = (win.rindo = win.rindo || {});
113
+ const originalInspect = rindo.inspect;
114
+ rindo.inspect = (ref) => {
115
+ let result = inspect(ref);
116
+ if (!result && typeof originalInspect === 'function') {
117
+ result = originalInspect(ref);
118
+ }
119
+ return result;
120
+ };
121
+ }
122
+ };
123
+ const CONTENT_REF_ID = 'r';
124
+ const ORG_LOCATION_ID = 'o';
125
+ const SLOT_NODE_ID = 's';
126
+ const TEXT_NODE_ID = 't';
127
+ const HYDRATE_ID = 's-id';
128
+ const HYDRATED_STYLE_ID = 'sty-id';
129
+ const HYDRATE_CHILD_ID = 'c-id';
130
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
131
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
132
+ /**
133
+ * Default style mode id
134
+ */
135
+ /**
136
+ * Reusable empty obj/array
137
+ * Don't add values to these!!
138
+ */
139
+ const EMPTY_OBJ = {};
140
+ /**
141
+ * Namespaces
142
+ */
143
+ const SVG_NS = 'http://www.w3.org/2000/svg';
144
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
145
+ const isDef = (v) => v != null;
146
+ const isComplexType = (o) => {
147
+ // https://jsperf.com/typeof-fn-object/5
148
+ o = typeof o;
149
+ return o === 'object' || o === 'function';
150
+ };
151
+ /**
152
+ * Helper method for querying a `meta` tag that contains a nonce value
153
+ * out of a DOM's head.
154
+ *
155
+ * @param doc The DOM containing the `head` to query against
156
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
157
+ * exists or the tag has no content.
158
+ */
159
+ function queryNonceMetaTagContent(doc) {
160
+ var _a, _b, _c;
161
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
162
+ }
163
+ /**
164
+ * Production h() function based on Preact by
165
+ * Jason Miller (@developit)
166
+ * Licensed under the MIT License
167
+ * https://github.com/developit/preact/blob/master/LICENSE
168
+ *
169
+ * Modified for Rindo's compiler and vdom
170
+ */
171
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
172
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
173
+ const h = (nodeName, vnodeData, ...children) => {
174
+ let child = null;
175
+ let key = null;
176
+ let slotName = null;
177
+ let simple = false;
178
+ let lastSimple = false;
179
+ const vNodeChildren = [];
180
+ const walk = (c) => {
181
+ for (let i = 0; i < c.length; i++) {
182
+ child = c[i];
183
+ if (Array.isArray(child)) {
184
+ walk(child);
185
+ }
186
+ else if (child != null && typeof child !== 'boolean') {
187
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
188
+ child = String(child);
189
+ }
190
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
191
+ consoleDevError(`vNode passed as children has unexpected type.
192
+ Make sure it's using the correct h() function.
193
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
194
+ }
195
+ if (simple && lastSimple) {
196
+ // If the previous child was simple (string), we merge both
197
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
198
+ }
199
+ else {
200
+ // Append a new vNode, if it's text, we create a text vNode
201
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
202
+ }
203
+ lastSimple = simple;
204
+ }
205
+ }
206
+ };
207
+ walk(children);
208
+ if (vnodeData) {
209
+ if (BUILD.isDev && nodeName === 'input') {
210
+ validateInputProperties(vnodeData);
211
+ }
212
+ // normalize class / classname attributes
213
+ if (BUILD.vdomKey && vnodeData.key) {
214
+ key = vnodeData.key;
215
+ }
216
+ if (BUILD.slotRelocation && vnodeData.name) {
217
+ slotName = vnodeData.name;
218
+ }
219
+ if (BUILD.vdomClass) {
220
+ const classData = vnodeData.className || vnodeData.class;
221
+ if (classData) {
222
+ vnodeData.class =
223
+ typeof classData !== 'object'
224
+ ? classData
225
+ : Object.keys(classData)
226
+ .filter((k) => classData[k])
227
+ .join(' ');
228
+ }
229
+ }
230
+ }
231
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
232
+ consoleDevError(`The <Host> must be the single root component. Make sure:
233
+ - You are NOT using hostData() and <Host> in the same component.
234
+ - <Host> is used once, and it's the single root component of the render() function.`);
235
+ }
236
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
237
+ // nodeName is a functional component
238
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
239
+ }
240
+ const vnode = newVNode(nodeName, null);
241
+ vnode.$attrs$ = vnodeData;
242
+ if (vNodeChildren.length > 0) {
243
+ vnode.$children$ = vNodeChildren;
244
+ }
245
+ if (BUILD.vdomKey) {
246
+ vnode.$key$ = key;
247
+ }
248
+ if (BUILD.slotRelocation) {
249
+ vnode.$name$ = slotName;
250
+ }
251
+ return vnode;
252
+ };
253
+ /**
254
+ * A utility function for creating a virtual DOM node from a tag and some
255
+ * possible text content.
256
+ *
257
+ * @param tag the tag for this element
258
+ * @param text possible text content for the node
259
+ * @returns a newly-minted virtual DOM node
260
+ */
261
+ const newVNode = (tag, text) => {
262
+ const vnode = {
263
+ $flags$: 0,
264
+ $tag$: tag,
265
+ $text$: text,
266
+ $elm$: null,
267
+ $children$: null,
268
+ };
269
+ if (BUILD.vdomAttribute) {
270
+ vnode.$attrs$ = null;
271
+ }
272
+ if (BUILD.vdomKey) {
273
+ vnode.$key$ = null;
274
+ }
275
+ if (BUILD.slotRelocation) {
276
+ vnode.$name$ = null;
277
+ }
278
+ return vnode;
279
+ };
280
+ const Host = {};
281
+ /**
282
+ * Check whether a given node is a Host node or not
283
+ *
284
+ * @param node the virtual DOM node to check
285
+ * @returns whether it's a Host node or not
286
+ */
287
+ const isHost = (node) => node && node.$tag$ === Host;
288
+ /**
289
+ * Implementation of {@link d.FunctionalUtilities} for Rindo's VDom.
290
+ *
291
+ * Note that these functions convert from {@link d.VNode} to
292
+ * {@link d.ChildNode} to give functional component developers a friendly
293
+ * interface.
294
+ */
295
+ const vdomFnUtils = {
296
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
297
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
298
+ };
299
+ /**
300
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
301
+ * friendlier public interface (hence, 'convertToPublic').
302
+ *
303
+ * @param node the virtual DOM node to convert
304
+ * @returns a converted child node
305
+ */
306
+ const convertToPublic = (node) => ({
307
+ vattrs: node.$attrs$,
308
+ vchildren: node.$children$,
309
+ vkey: node.$key$,
310
+ vname: node.$name$,
311
+ vtag: node.$tag$,
312
+ vtext: node.$text$,
313
+ });
314
+ /**
315
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
316
+ * order to use the resulting object in the virtual DOM. The initial object was
317
+ * likely created as part of presenting a public API, so converting it back
318
+ * involved making it 'private' again (hence, `convertToPrivate`).
319
+ *
320
+ * @param node the child node to convert
321
+ * @returns a converted virtual DOM node
322
+ */
323
+ const convertToPrivate = (node) => {
324
+ if (typeof node.vtag === 'function') {
325
+ const vnodeData = Object.assign({}, node.vattrs);
326
+ if (node.vkey) {
327
+ vnodeData.key = node.vkey;
328
+ }
329
+ if (node.vname) {
330
+ vnodeData.name = node.vname;
331
+ }
332
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
333
+ }
334
+ const vnode = newVNode(node.vtag, node.vtext);
335
+ vnode.$attrs$ = node.vattrs;
336
+ vnode.$children$ = node.vchildren;
337
+ vnode.$key$ = node.vkey;
338
+ vnode.$name$ = node.vname;
339
+ return vnode;
340
+ };
341
+ /**
342
+ * Validates the ordering of attributes on an input element
343
+ *
344
+ * @param inputElm the element to validate
345
+ */
346
+ const validateInputProperties = (inputElm) => {
347
+ const props = Object.keys(inputElm);
348
+ const value = props.indexOf('value');
349
+ if (value === -1) {
350
+ return;
351
+ }
352
+ const typeIndex = props.indexOf('type');
353
+ const minIndex = props.indexOf('min');
354
+ const maxIndex = props.indexOf('max');
355
+ const stepIndex = props.indexOf('step');
356
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
357
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
358
+ }
359
+ };
360
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
361
+ const endHydrate = createTime('hydrateClient', tagName);
362
+ const shadowRoot = hostElm.shadowRoot;
363
+ const childRenderNodes = [];
364
+ const slotNodes = [];
365
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
366
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
367
+ if (!plt.$orgLocNodes$) {
368
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
369
+ }
370
+ hostElm[HYDRATE_ID] = hostId;
371
+ hostElm.removeAttribute(HYDRATE_ID);
372
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
373
+ childRenderNodes.map((c) => {
374
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
375
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
376
+ const node = c.$elm$;
377
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
378
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
379
+ }
380
+ if (!shadowRoot) {
381
+ node['s-hn'] = tagName;
382
+ if (orgLocationNode) {
383
+ node['s-ol'] = orgLocationNode;
384
+ node['s-ol']['s-nr'] = node;
385
+ }
386
+ }
387
+ plt.$orgLocNodes$.delete(orgLocationId);
388
+ });
389
+ if (BUILD.shadowDom && shadowRoot) {
390
+ shadowRootNodes.map((shadowRootNode) => {
391
+ if (shadowRootNode) {
392
+ shadowRoot.appendChild(shadowRootNode);
393
+ }
394
+ });
395
+ }
396
+ endHydrate();
397
+ };
398
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
399
+ let childNodeType;
400
+ let childIdSplt;
401
+ let childVNode;
402
+ let i;
403
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
404
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
405
+ if (childNodeType) {
406
+ // got the node data from the element's attribute
407
+ // `${hostId}.${nodeId}.${depth}.${index}`
408
+ childIdSplt = childNodeType.split('.');
409
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
410
+ childVNode = {
411
+ $flags$: 0,
412
+ $hostId$: childIdSplt[0],
413
+ $nodeId$: childIdSplt[1],
414
+ $depth$: childIdSplt[2],
415
+ $index$: childIdSplt[3],
416
+ $tag$: node.tagName.toLowerCase(),
417
+ $elm$: node,
418
+ $attrs$: null,
419
+ $children$: null,
420
+ $key$: null,
421
+ $name$: null,
422
+ $text$: null,
423
+ };
424
+ childRenderNodes.push(childVNode);
425
+ node.removeAttribute(HYDRATE_CHILD_ID);
426
+ // this is a new child vnode
427
+ // so ensure its parent vnode has the vchildren array
428
+ if (!parentVNode.$children$) {
429
+ parentVNode.$children$ = [];
430
+ }
431
+ // add our child vnode to a specific index of the vnode's children
432
+ parentVNode.$children$[childVNode.$index$] = childVNode;
433
+ // this is now the new parent vnode for all the next child checks
434
+ parentVNode = childVNode;
435
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
436
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
437
+ }
438
+ }
439
+ }
440
+ // recursively drill down, end to start so we can remove nodes
441
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
442
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
443
+ }
444
+ if (node.shadowRoot) {
445
+ // keep drilling down through the shadow root nodes
446
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
447
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
448
+ }
449
+ }
450
+ }
451
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
452
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
453
+ childIdSplt = node.nodeValue.split('.');
454
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
455
+ // comment node for either the host id or a 0 host id
456
+ childNodeType = childIdSplt[0];
457
+ childVNode = {
458
+ $flags$: 0,
459
+ $hostId$: childIdSplt[1],
460
+ $nodeId$: childIdSplt[2],
461
+ $depth$: childIdSplt[3],
462
+ $index$: childIdSplt[4],
463
+ $elm$: node,
464
+ $attrs$: null,
465
+ $children$: null,
466
+ $key$: null,
467
+ $name$: null,
468
+ $tag$: null,
469
+ $text$: null,
470
+ };
471
+ if (childNodeType === TEXT_NODE_ID) {
472
+ childVNode.$elm$ = node.nextSibling;
473
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
474
+ childVNode.$text$ = childVNode.$elm$.textContent;
475
+ childRenderNodes.push(childVNode);
476
+ // remove the text comment since it's no longer needed
477
+ node.remove();
478
+ if (!parentVNode.$children$) {
479
+ parentVNode.$children$ = [];
480
+ }
481
+ parentVNode.$children$[childVNode.$index$] = childVNode;
482
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
483
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
484
+ }
485
+ }
486
+ }
487
+ else if (childVNode.$hostId$ === hostId) {
488
+ // this comment node is specifcally for this host id
489
+ if (childNodeType === SLOT_NODE_ID) {
490
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
491
+ childVNode.$tag$ = 'slot';
492
+ if (childIdSplt[5]) {
493
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
494
+ }
495
+ else {
496
+ node['s-sn'] = '';
497
+ }
498
+ node['s-sr'] = true;
499
+ if (BUILD.shadowDom && shadowRootNodes) {
500
+ // browser support shadowRoot and this is a shadow dom component
501
+ // create an actual slot element
502
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
503
+ if (childVNode.$name$) {
504
+ // add the slot name attribute
505
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
506
+ }
507
+ // insert the new slot element before the slot comment
508
+ node.parentNode.insertBefore(childVNode.$elm$, node);
509
+ // remove the slot comment since it's not needed for shadow
510
+ node.remove();
511
+ if (childVNode.$depth$ === '0') {
512
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
513
+ }
514
+ }
515
+ slotNodes.push(childVNode);
516
+ if (!parentVNode.$children$) {
517
+ parentVNode.$children$ = [];
518
+ }
519
+ parentVNode.$children$[childVNode.$index$] = childVNode;
520
+ }
521
+ else if (childNodeType === CONTENT_REF_ID) {
522
+ // `${CONTENT_REF_ID}.${hostId}`;
523
+ if (BUILD.shadowDom && shadowRootNodes) {
524
+ // remove the content ref comment since it's not needed for shadow
525
+ node.remove();
526
+ }
527
+ else if (BUILD.slotRelocation) {
528
+ hostElm['s-cr'] = node;
529
+ node['s-cn'] = true;
530
+ }
531
+ }
532
+ }
533
+ }
534
+ }
535
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
536
+ const vnode = newVNode(null, node.textContent);
537
+ vnode.$elm$ = node;
538
+ vnode.$index$ = '0';
539
+ parentVNode.$children$ = [vnode];
540
+ }
541
+ };
542
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
543
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
544
+ let i = 0;
545
+ for (; i < node.childNodes.length; i++) {
546
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
547
+ }
548
+ if (node.shadowRoot) {
549
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
550
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
551
+ }
552
+ }
553
+ }
554
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
555
+ const childIdSplt = node.nodeValue.split('.');
556
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
557
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
558
+ node.nodeValue = '';
559
+ // useful to know if the original location is
560
+ // the root light-dom of a shadow dom component
561
+ node['s-en'] = childIdSplt[3];
562
+ }
563
+ }
564
+ };
565
+ // Private
566
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
567
+ // Public
568
+ const setMode = (handler) => modeResolutionChain.push(handler);
569
+ const getMode = (ref) => getHostRef(ref).$modeName$;
570
+ /**
571
+ * Parse a new property value for a given property type.
572
+ *
573
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
574
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
575
+ * 1. `any`, the type given to `propValue` in the function signature
576
+ * 2. the type stored from `propType`.
577
+ *
578
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
579
+ *
580
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
581
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
582
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
583
+ * ```tsx
584
+ * <my-cmp prop-val={0}></my-cmp>
585
+ * ```
586
+ *
587
+ * HTML prop values on the other hand, will always a string
588
+ *
589
+ * @param propValue the new value to coerce to some type
590
+ * @param propType the type of the prop, expressed as a binary number
591
+ * @returns the parsed/coerced value
592
+ */
593
+ const parsePropertyValue = (propValue, propType) => {
594
+ // ensure this value is of the correct prop type
595
+ if (propValue != null && !isComplexType(propValue)) {
596
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
597
+ // per the HTML spec, any string value means it is a boolean true value
598
+ // but we'll cheat here and say that the string "false" is the boolean false
599
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
600
+ }
601
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
602
+ // force it to be a number
603
+ return parseFloat(propValue);
604
+ }
605
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
606
+ // could have been passed as a number or boolean
607
+ // but we still want it as a string
608
+ return String(propValue);
609
+ }
610
+ // redundant return here for better minification
611
+ return propValue;
612
+ }
613
+ // not sure exactly what type we want
614
+ // so no need to change to a different type
615
+ return propValue;
616
+ };
617
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
618
+ const createEvent = (ref, name, flags) => {
619
+ const elm = getElement(ref);
620
+ return {
621
+ emit: (detail) => {
622
+ if (BUILD.isDev && !elm.isConnected) {
623
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
624
+ }
625
+ return emitEvent(elm, name, {
626
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
627
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
628
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
629
+ detail,
630
+ });
188
631
  },
189
- instanceValues: hostRef.$instanceValues$,
190
- ancestorComponent: hostRef.$ancestorComponent$,
191
- hostElement,
192
- lazyInstance: hostRef.$lazyInstance$,
193
- vnode: hostRef.$vnode$,
194
- modeName: hostRef.$modeName$,
195
- onReadyPromise: hostRef.$onReadyPromise$,
196
- onReadyResolve: hostRef.$onReadyResolve$,
197
- onInstancePromise: hostRef.$onInstancePromise$,
198
- onInstanceResolve: hostRef.$onInstanceResolve$,
199
- onRenderResolve: hostRef.$onRenderResolve$,
200
- queuedListeners: hostRef.$queuedListeners$,
201
- rmListeners: hostRef.$rmListeners$,
202
- ['s-id']: hostElement['s-id'],
203
- ['s-cr']: hostElement['s-cr'],
204
- ['s-lr']: hostElement['s-lr'],
205
- ['s-p']: hostElement['s-p'],
206
- ['s-rc']: hostElement['s-rc'],
207
- ['s-sc']: hostElement['s-sc'],
208
632
  };
209
633
  };
210
- const installDevTools = () => {
211
- if (BUILD.devTools) {
212
- const rindo = (win.rindo = win.rindo || {});
213
- const originalInspect = rindo.inspect;
214
- rindo.inspect = (ref) => {
215
- let result = inspect(ref);
216
- if (!result && typeof originalInspect === 'function') {
217
- result = originalInspect(ref);
218
- }
219
- return result;
220
- };
221
- }
634
+ /**
635
+ * Helper function to create & dispatch a custom Event on a provided target
636
+ * @param elm the target of the Event
637
+ * @param name the name to give the custom Event
638
+ * @param opts options for configuring a custom Event
639
+ * @returns the custom Event
640
+ */
641
+ const emitEvent = (elm, name, opts) => {
642
+ const ev = plt.ce(name, opts);
643
+ elm.dispatchEvent(ev);
644
+ return ev;
222
645
  };
223
- const rootAppliedStyles = new WeakMap();
646
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
224
647
  const registerStyle = (scopeId, cssText, allowCS) => {
225
648
  let style = styles.get(scopeId);
226
649
  if (supportsConstructableStylesheets && allowCS) {
@@ -238,6 +661,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
238
661
  styles.set(scopeId, style);
239
662
  };
240
663
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
664
+ var _a;
241
665
  let scopeId = getScopeId(cmpMeta, mode);
242
666
  const style = styles.get(scopeId);
243
667
  if (!BUILD.attachStyles) {
@@ -245,7 +669,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
245
669
  }
246
670
  // if an element is NOT connected then getRootNode() will return the wrong root node
247
671
  // so the fallback is to always use the document for the root node in those cases
248
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
672
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
249
673
  if (style) {
250
674
  if (typeof style === 'string') {
251
675
  styleContainerNode = styleContainerNode.head || styleContainerNode;
@@ -263,7 +687,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
263
687
  }
264
688
  else {
265
689
  if (BUILD.cssVarShim && plt.$cssShim$) {
266
- styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
690
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
267
691
  const newScopeId = styleElm['s-sc'];
268
692
  if (newScopeId) {
269
693
  scopeId = newScopeId;
@@ -277,6 +701,11 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
277
701
  styleElm = doc.createElement('style');
278
702
  styleElm.innerHTML = style;
279
703
  }
704
+ // Apply CSP nonce to the style tag if it exists
705
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
706
+ if (nonce != null) {
707
+ styleElm.setAttribute('nonce', nonce);
708
+ }
280
709
  if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
281
710
  styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
282
711
  }
@@ -299,7 +728,7 @@ const attachStyles = (hostRef) => {
299
728
  const flags = cmpMeta.$flags$;
300
729
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
301
730
  const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
302
- if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
731
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
303
732
  // only required when we're NOT using native shadow dom (slot)
304
733
  // or this browser doesn't support native shadow dom
305
734
  // and this host element was NOT created with SSR
@@ -309,198 +738,14 @@ const attachStyles = (hostRef) => {
309
738
  // DOM WRITE!!
310
739
  elm['s-sc'] = scopeId;
311
740
  elm.classList.add(scopeId + '-h');
312
- if (BUILD.scoped && flags & 2 /* scopedCssEncapsulation */) {
741
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
313
742
  elm.classList.add(scopeId + '-s');
314
743
  }
315
744
  }
316
745
  endAttachStyles();
317
746
  };
318
- const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
747
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
319
748
  const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
320
- // Private
321
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
322
- // Public
323
- const setMode = (handler) => modeResolutionChain.push(handler);
324
- const getMode = (ref) => getHostRef(ref).$modeName$;
325
- /**
326
- * Default style mode id
327
- */
328
- /**
329
- * Reusable empty obj/array
330
- * Don't add values to these!!
331
- */
332
- const EMPTY_OBJ = {};
333
- /**
334
- * Namespaces
335
- */
336
- const SVG_NS = 'http://www.w3.org/2000/svg';
337
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
338
- const isDef = (v) => v != null;
339
- const isComplexType = (o) => {
340
- // https://jsperf.com/typeof-fn-object/5
341
- o = typeof o;
342
- return o === 'object' || o === 'function';
343
- };
344
- /**
345
- * Production h() function based on Preact by
346
- * Jason Miller (@developit)
347
- * Licensed under the MIT License
348
- * https://github.com/developit/preact/blob/master/LICENSE
349
- *
350
- * Modified for Rindo's compiler and vdom
351
- */
352
- // const stack: any[] = [];
353
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
354
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
355
- const h = (nodeName, vnodeData, ...children) => {
356
- let child = null;
357
- let key = null;
358
- let slotName = null;
359
- let simple = false;
360
- let lastSimple = false;
361
- const vNodeChildren = [];
362
- const walk = (c) => {
363
- for (let i = 0; i < c.length; i++) {
364
- child = c[i];
365
- if (Array.isArray(child)) {
366
- walk(child);
367
- }
368
- else if (child != null && typeof child !== 'boolean') {
369
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
370
- child = String(child);
371
- }
372
- else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
373
- consoleDevError(`vNode passed as children has unexpected type.
374
- Make sure it's using the correct h() function.
375
- Empty objects can also be the cause, look for JSX comments that became objects.`);
376
- }
377
- if (simple && lastSimple) {
378
- // If the previous child was simple (string), we merge both
379
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
380
- }
381
- else {
382
- // Append a new vNode, if it's text, we create a text vNode
383
- vNodeChildren.push(simple ? newVNode(null, child) : child);
384
- }
385
- lastSimple = simple;
386
- }
387
- }
388
- };
389
- walk(children);
390
- if (vnodeData) {
391
- if (BUILD.isDev && nodeName === 'input') {
392
- validateInputProperties(vnodeData);
393
- }
394
- // normalize class / classname attributes
395
- if (BUILD.vdomKey && vnodeData.key) {
396
- key = vnodeData.key;
397
- }
398
- if (BUILD.slotRelocation && vnodeData.name) {
399
- slotName = vnodeData.name;
400
- }
401
- if (BUILD.vdomClass) {
402
- const classData = vnodeData.className || vnodeData.class;
403
- if (classData) {
404
- vnodeData.class =
405
- typeof classData !== 'object'
406
- ? classData
407
- : Object.keys(classData)
408
- .filter((k) => classData[k])
409
- .join(' ');
410
- }
411
- }
412
- }
413
- if (BUILD.isDev && vNodeChildren.some(isHost)) {
414
- consoleDevError(`The <Host> must be the single root component. Make sure:
415
- - You are NOT using hostData() and <Host> in the same component.
416
- - <Host> is used once, and it's the single root component of the render() function.`);
417
- }
418
- if (BUILD.vdomFunctional && typeof nodeName === 'function') {
419
- // nodeName is a functional component
420
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
421
- }
422
- const vnode = newVNode(nodeName, null);
423
- vnode.$attrs$ = vnodeData;
424
- if (vNodeChildren.length > 0) {
425
- vnode.$children$ = vNodeChildren;
426
- }
427
- if (BUILD.vdomKey) {
428
- vnode.$key$ = key;
429
- }
430
- if (BUILD.slotRelocation) {
431
- vnode.$name$ = slotName;
432
- }
433
- return vnode;
434
- };
435
- const newVNode = (tag, text) => {
436
- const vnode = {
437
- $flags$: 0,
438
- $tag$: tag,
439
- $text$: text,
440
- $elm$: null,
441
- $children$: null,
442
- };
443
- if (BUILD.vdomAttribute) {
444
- vnode.$attrs$ = null;
445
- }
446
- if (BUILD.vdomKey) {
447
- vnode.$key$ = null;
448
- }
449
- if (BUILD.slotRelocation) {
450
- vnode.$name$ = null;
451
- }
452
- return vnode;
453
- };
454
- const Host = {};
455
- const isHost = (node) => node && node.$tag$ === Host;
456
- const vdomFnUtils = {
457
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
458
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
459
- };
460
- const convertToPublic = (node) => ({
461
- vattrs: node.$attrs$,
462
- vchildren: node.$children$,
463
- vkey: node.$key$,
464
- vname: node.$name$,
465
- vtag: node.$tag$,
466
- vtext: node.$text$,
467
- });
468
- const convertToPrivate = (node) => {
469
- if (typeof node.vtag === 'function') {
470
- const vnodeData = Object.assign({}, node.vattrs);
471
- if (node.vkey) {
472
- vnodeData.key = node.vkey;
473
- }
474
- if (node.vname) {
475
- vnodeData.name = node.vname;
476
- }
477
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
478
- }
479
- const vnode = newVNode(node.vtag, node.vtext);
480
- vnode.$attrs$ = node.vattrs;
481
- vnode.$children$ = node.vchildren;
482
- vnode.$key$ = node.vkey;
483
- vnode.$name$ = node.vname;
484
- return vnode;
485
- };
486
- /**
487
- * Validates the ordering of attributes on an input element
488
- * @param inputElm the element to validate
489
- */
490
- const validateInputProperties = (inputElm) => {
491
- const props = Object.keys(inputElm);
492
- const value = props.indexOf('value');
493
- if (value === -1) {
494
- return;
495
- }
496
- const typeIndex = props.indexOf('type');
497
- const minIndex = props.indexOf('min');
498
- const maxIndex = props.indexOf('max');
499
- const stepIndex = props.indexOf('step');
500
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
501
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
502
- }
503
- };
504
749
  /**
505
750
  * Production setAccessor() function based on Preact by
506
751
  * Jason Miller (@developit)
@@ -638,7 +883,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
638
883
  }
639
884
  }
640
885
  }
641
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
886
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
642
887
  newValue = newValue === true ? '' : newValue;
643
888
  if (BUILD.vdomXlink && xlink) {
644
889
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -656,7 +901,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
656
901
  // if the element passed in is a shadow root, which is a document fragment
657
902
  // then we want to be adding attrs/props to the shadow root's "host" element
658
903
  // if it's not a shadow root, then we add attrs/props to the same element
659
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
904
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
660
905
  ? newVnode.$elm$.host
661
906
  : newVnode.$elm$;
662
907
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -674,6 +919,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
674
919
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
675
920
  }
676
921
  };
922
+ /**
923
+ * Create a DOM Node corresponding to one of the children of a given VNode.
924
+ *
925
+ * @param oldParentVNode the parent VNode from the previous render
926
+ * @param newParentVNode the parent VNode from the current render
927
+ * @param childIndex the index of the VNode, in the _new_ parent node's
928
+ * children, for which we will create a new DOM node
929
+ * @param parentElm the parent DOM node which our new node will be a child of
930
+ * @returns the newly created node
931
+ */
677
932
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
678
933
  // tslint:disable-next-line: prefer-const
679
934
  const newVNode = newParentVNode.$children$[childIndex];
@@ -691,9 +946,9 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
691
946
  }
692
947
  newVNode.$flags$ |= newVNode.$children$
693
948
  ? // slot element has fallback content
694
- 2 /* isSlotFallback */
949
+ 2 /* VNODE_FLAGS.isSlotFallback */
695
950
  : // slot element does not have fallback content
696
- 1 /* isSlotReference */;
951
+ 1 /* VNODE_FLAGS.isSlotReference */;
697
952
  }
698
953
  }
699
954
  if (BUILD.isDev && newVNode.$elm$) {
@@ -703,7 +958,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
703
958
  // create text node
704
959
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
705
960
  }
706
- else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* isSlotReference */) {
961
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
707
962
  // create a slot reference node
708
963
  elm = newVNode.$elm$ =
709
964
  BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
@@ -714,10 +969,10 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
714
969
  }
715
970
  // create element
716
971
  elm = newVNode.$elm$ = (BUILD.svg
717
- ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
972
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
718
973
  ? 'slot-fb'
719
974
  : newVNode.$tag$)
720
- : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
975
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
721
976
  ? 'slot-fb'
722
977
  : newVNode.$tag$));
723
978
  if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
@@ -756,7 +1011,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
756
1011
  }
757
1012
  if (BUILD.slotRelocation) {
758
1013
  elm['s-hn'] = hostTagName;
759
- if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
1014
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
760
1015
  // remember the content reference comment
761
1016
  elm['s-sr'] = true;
762
1017
  // remember the content reference comment
@@ -775,7 +1030,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
775
1030
  return elm;
776
1031
  };
777
1032
  const putBackInOriginalLocation = (parentElm, recursive) => {
778
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1033
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
779
1034
  const oldSlotChildNodes = parentElm.childNodes;
780
1035
  for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
781
1036
  const childNode = oldSlotChildNodes[i];
@@ -796,8 +1051,23 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
796
1051
  putBackInOriginalLocation(childNode, recursive);
797
1052
  }
798
1053
  }
799
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1054
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
800
1055
  };
1056
+ /**
1057
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
1058
+ * add them to the DOM in the appropriate place.
1059
+ *
1060
+ * @param parentElm the DOM node which should be used as a parent for the new
1061
+ * DOM nodes
1062
+ * @param before a child of the `parentElm` which the new children should be
1063
+ * inserted before (optional)
1064
+ * @param parentVNode the parent virtual DOM node
1065
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
1066
+ * @param startIdx the index in the child virtual DOM nodes at which to start
1067
+ * creating DOM nodes (inclusive)
1068
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
1069
+ * creating DOM nodes (inclusive)
1070
+ */
801
1071
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
802
1072
  let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
803
1073
  let childNode;
@@ -814,6 +1084,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
814
1084
  }
815
1085
  }
816
1086
  };
1087
+ /**
1088
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
1089
+ * This can be used to, for instance, clean up after a list of children which
1090
+ * should no longer be shown.
1091
+ *
1092
+ * This function also handles some of Rindo's slot relocation logic.
1093
+ *
1094
+ * @param vnodes a list of virtual DOM nodes to remove
1095
+ * @param startIdx the index at which to start removing nodes (inclusive)
1096
+ * @param endIdx the index at which to stop removing nodes (inclusive)
1097
+ * @param vnode a VNode
1098
+ * @param elm an element
1099
+ */
817
1100
  const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
818
1101
  for (; startIdx <= endIdx; ++startIdx) {
819
1102
  if ((vnode = vnodes[startIdx])) {
@@ -838,6 +1121,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
838
1121
  }
839
1122
  }
840
1123
  };
1124
+ /**
1125
+ * Reconcile the children of a new VNode with the children of an old VNode by
1126
+ * traversing the two collections of children, identifying nodes that are
1127
+ * conserved or changed, calling out to `patch` to make any necessary
1128
+ * updates to the DOM, and rearranging DOM nodes as needed.
1129
+ *
1130
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
1131
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1132
+ * 'windows' by storing start and end indices and references to the
1133
+ * corresponding array entries. Initially the two 'windows' are basically equal
1134
+ * to the entire array, but we progressively narrow the windows until there are
1135
+ * no children left to update by doing the following:
1136
+ *
1137
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1138
+ * that if we have an initial array like the following we'll end up dealing
1139
+ * only with a window bounded by the highlighted elements:
1140
+ *
1141
+ * [null, null, VNode1 , ... , VNode2, null, null]
1142
+ * ^^^^^^ ^^^^^^
1143
+ *
1144
+ * 2. Check to see if the elements at the head and tail positions are equal
1145
+ * across the windows. This will basically detect elements which haven't
1146
+ * been added, removed, or changed position, i.e. if you had the following
1147
+ * VNode elements (represented as HTML):
1148
+ *
1149
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
1150
+ * newVNode: `<div><p><span>THERE</span></p></div>`
1151
+ *
1152
+ * Then when comparing the children of the `<div>` tag we check the equality
1153
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
1154
+ * same tag in the same position, we'd be able to avoid completely
1155
+ * re-rendering the subtree under them with a new DOM element and would just
1156
+ * call out to `patch` to handle reconciling their children and so on.
1157
+ *
1158
+ * 3. Check, for both windows, to see if the element at the beginning of the
1159
+ * window corresponds to the element at the end of the other window. This is
1160
+ * a heuristic which will let us identify _some_ situations in which
1161
+ * elements have changed position, for instance it _should_ detect that the
1162
+ * children nodes themselves have not changed but merely moved in the
1163
+ * following example:
1164
+ *
1165
+ * oldVNode: `<div><element-one /><element-two /></div>`
1166
+ * newVNode: `<div><element-two /><element-one /></div>`
1167
+ *
1168
+ * If we find cases like this then we also need to move the concrete DOM
1169
+ * elements corresponding to the moved children to write the re-order to the
1170
+ * DOM.
1171
+ *
1172
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1173
+ * nodes in the old children which have the same key as the first element in
1174
+ * our window on the new children. If we find such a node we handle calling
1175
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1176
+ * what we find.
1177
+ *
1178
+ * Finally, once we've narrowed our 'windows' to the point that either of them
1179
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
1180
+ * insertion or deletion that needs to happen to get a DOM state that correctly
1181
+ * reflects the new child VNodes. If, for instance, after our window on the old
1182
+ * children has collapsed we still have more nodes on the new children that
1183
+ * we haven't dealt with yet then we need to add them, or if the new children
1184
+ * collapse but we still have unhandled _old_ children then we need to make
1185
+ * sure the corresponding DOM nodes are removed.
1186
+ *
1187
+ * @param parentElm the node into which the parent VNode is rendered
1188
+ * @param oldCh the old children of the parent node
1189
+ * @param newVNode the new VNode which will replace the parent
1190
+ * @param newCh the new children of the parent node
1191
+ */
841
1192
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
842
1193
  let oldStartIdx = 0;
843
1194
  let newStartIdx = 0;
@@ -853,7 +1204,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
853
1204
  let elmToMove;
854
1205
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
855
1206
  if (oldStartVnode == null) {
856
- // Vnode might have been moved left
1207
+ // VNode might have been moved left
857
1208
  oldStartVnode = oldCh[++oldStartIdx];
858
1209
  }
859
1210
  else if (oldEndVnode == null) {
@@ -866,37 +1217,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
866
1217
  newEndVnode = newCh[--newEndIdx];
867
1218
  }
868
1219
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
1220
+ // if the start nodes are the same then we should patch the new VNode
1221
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1222
+ // indices to reflect that. We don't need to move any DOM Nodes around
1223
+ // since things are matched up in order.
869
1224
  patch(oldStartVnode, newStartVnode);
870
1225
  oldStartVnode = oldCh[++oldStartIdx];
871
1226
  newStartVnode = newCh[++newStartIdx];
872
1227
  }
873
1228
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
1229
+ // likewise, if the end nodes are the same we patch new onto old and
1230
+ // decrement our end indices, and also likewise in this case we don't
1231
+ // need to move any DOM Nodes.
874
1232
  patch(oldEndVnode, newEndVnode);
875
1233
  oldEndVnode = oldCh[--oldEndIdx];
876
1234
  newEndVnode = newCh[--newEndIdx];
877
1235
  }
878
1236
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
879
- // Vnode moved right
1237
+ // case: "Vnode moved right"
1238
+ //
1239
+ // We've found that the last node in our window on the new children is
1240
+ // the same VNode as the _first_ node in our window on the old children
1241
+ // we're dealing with now. Visually, this is the layout of these two
1242
+ // nodes:
1243
+ //
1244
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1245
+ // ^^^^^^^^^^^
1246
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1247
+ // ^^^^^^^^^^^^^
1248
+ //
1249
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1250
+ // and move the DOM element for `oldStartVnode`.
880
1251
  if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
881
1252
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
882
1253
  }
883
1254
  patch(oldStartVnode, newEndVnode);
1255
+ // We need to move the element for `oldStartVnode` into a position which
1256
+ // will be appropriate for `newEndVnode`. For this we can use
1257
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1258
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1259
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1260
+ //
1261
+ // <old-start-node />
1262
+ // <some-intervening-node />
1263
+ // <old-end-node />
1264
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1265
+ // <next-sibling />
1266
+ //
1267
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1268
+ // the node for `oldStartVnode` at the end of the children of
1269
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1270
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
1271
+ // append it to the children of the parent element.
884
1272
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
885
1273
  oldStartVnode = oldCh[++oldStartIdx];
886
1274
  newEndVnode = newCh[--newEndIdx];
887
1275
  }
888
1276
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
889
- // Vnode moved left
1277
+ // case: "Vnode moved left"
1278
+ //
1279
+ // We've found that the first node in our window on the new children is
1280
+ // the same VNode as the _last_ node in our window on the old children.
1281
+ // Visually, this is the layout of these two nodes:
1282
+ //
1283
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1284
+ // ^^^^^^^^^^^^^
1285
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1286
+ // ^^^^^^^^^^^
1287
+ //
1288
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1289
+ // (which will handle updating any changed attributes, reconciling their
1290
+ // children etc) but we also need to move the DOM node to which
1291
+ // `oldEndVnode` corresponds.
890
1292
  if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
891
1293
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
892
1294
  }
893
1295
  patch(oldEndVnode, newStartVnode);
1296
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
1297
+ // the same node, so since we're here we know that they are not. Thus we
1298
+ // can move the element for `oldEndVnode` _before_ the element for
1299
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1300
+ // future.
894
1301
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
895
1302
  oldEndVnode = oldCh[--oldEndIdx];
896
1303
  newStartVnode = newCh[++newStartIdx];
897
1304
  }
898
1305
  else {
899
- // createKeyToOldIdx
1306
+ // Here we do some checks to match up old and new nodes based on the
1307
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1308
+ // in the JSX for a DOM element in the implementation of a Rindo
1309
+ // component.
1310
+ //
1311
+ // First we check to see if there are any nodes in the array of old
1312
+ // children which have the same key as the first node in the new
1313
+ // children.
900
1314
  idxInOld = -1;
901
1315
  if (BUILD.vdomKey) {
902
1316
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
@@ -907,23 +1321,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
907
1321
  }
908
1322
  }
909
1323
  if (BUILD.vdomKey && idxInOld >= 0) {
1324
+ // We found a node in the old children which matches up with the first
1325
+ // node in the new children! So let's deal with that
910
1326
  elmToMove = oldCh[idxInOld];
911
1327
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1328
+ // the tag doesn't match so we'll need a new DOM element
912
1329
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
913
1330
  }
914
1331
  else {
915
1332
  patch(elmToMove, newStartVnode);
1333
+ // invalidate the matching old node so that we won't try to update it
1334
+ // again later on
916
1335
  oldCh[idxInOld] = undefined;
917
1336
  node = elmToMove.$elm$;
918
1337
  }
919
1338
  newStartVnode = newCh[++newStartIdx];
920
1339
  }
921
1340
  else {
922
- // new element
1341
+ // We either didn't find an element in the old children that matches
1342
+ // the key of the first new child OR the build is not using `key`
1343
+ // attributes at all. In either case we need to create a new element
1344
+ // for the new node.
923
1345
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
924
1346
  newStartVnode = newCh[++newStartIdx];
925
1347
  }
926
1348
  if (node) {
1349
+ // if we created a new node then handle inserting it to the DOM
927
1350
  if (BUILD.slotRelocation) {
928
1351
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
929
1352
  }
@@ -934,21 +1357,44 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
934
1357
  }
935
1358
  }
936
1359
  if (oldStartIdx > oldEndIdx) {
1360
+ // we have some more new nodes to add which don't match up with old nodes
937
1361
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
938
1362
  }
939
1363
  else if (BUILD.updatable && newStartIdx > newEndIdx) {
1364
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
1365
+ // in the new array, so lets remove them (which entails cleaning up the
1366
+ // relevant DOM nodes)
940
1367
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
941
1368
  }
942
1369
  };
943
- const isSameVnode = (vnode1, vnode2) => {
1370
+ /**
1371
+ * Compare two VNodes to determine if they are the same
1372
+ *
1373
+ * **NB**: This function is an equality _heuristic_ based on the available
1374
+ * information set on the two VNodes and can be misleading under certain
1375
+ * circumstances. In particular, if the two nodes do not have `key` attrs
1376
+ * (available under `$key$` on VNodes) then the function falls back on merely
1377
+ * checking that they have the same tag.
1378
+ *
1379
+ * So, in other words, if `key` attrs are not set on VNodes which may be
1380
+ * changing order within a `children` array or something along those lines then
1381
+ * we could obtain a false negative and then have to do needless re-rendering
1382
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1383
+ *
1384
+ * @param leftVNode the first VNode to check
1385
+ * @param rightVNode the second VNode to check
1386
+ * @returns whether they're equal or not
1387
+ */
1388
+ const isSameVnode = (leftVNode, rightVNode) => {
944
1389
  // compare if two vnode to see if they're "technically" the same
945
1390
  // need to have the same element tag, and same key to be the same
946
- if (vnode1.$tag$ === vnode2.$tag$) {
947
- if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
948
- return vnode1.$name$ === vnode2.$name$;
1391
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1392
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1393
+ return leftVNode.$name$ === rightVNode.$name$;
949
1394
  }
1395
+ // this will be set if components in the build have `key` attrs set on them
950
1396
  if (BUILD.vdomKey) {
951
- return vnode1.$key$ === vnode2.$key$;
1397
+ return leftVNode.$key$ === rightVNode.$key$;
952
1398
  }
953
1399
  return true;
954
1400
  }
@@ -962,6 +1408,14 @@ const referenceNode = (node) => {
962
1408
  return (node && node['s-ol']) || node;
963
1409
  };
964
1410
  const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1411
+ /**
1412
+ * Handle reconciling an outdated VNode with a new one which corresponds to
1413
+ * it. This function handles flushing updates to the DOM and reconciling the
1414
+ * children of the two nodes (if any).
1415
+ *
1416
+ * @param oldVNode an old VNode whose DOM element and children we want to update
1417
+ * @param newVNode a new VNode representing an updated version of the old one
1418
+ */
965
1419
  const patch = (oldVNode, newVNode) => {
966
1420
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
967
1421
  const oldChildren = oldVNode.$children$;
@@ -975,7 +1429,6 @@ const patch = (oldVNode, newVNode) => {
975
1429
  // only add this to the when the compiler sees we're using an svg somewhere
976
1430
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
977
1431
  }
978
- // element node
979
1432
  if (BUILD.vdomAttribute || BUILD.reflect) {
980
1433
  if (BUILD.slot && tag === 'slot')
981
1434
  ;
@@ -988,6 +1441,7 @@ const patch = (oldVNode, newVNode) => {
988
1441
  }
989
1442
  if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
990
1443
  // looks like there's child vnodes for both the old and new vnodes
1444
+ // so we need to call `updateChildren` to reconcile them
991
1445
  updateChildren(elm, oldChildren, newVNode, newChildren);
992
1446
  }
993
1447
  else if (newChildren !== null) {
@@ -1028,7 +1482,7 @@ const updateFallbackSlotVisibility = (elm) => {
1028
1482
  let nodeType;
1029
1483
  for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1030
1484
  childNode = childNodes[i];
1031
- if (childNode.nodeType === 1 /* ElementNode */) {
1485
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1032
1486
  if (childNode['s-sr']) {
1033
1487
  // this is a slot fallback node
1034
1488
  // get the slot name for this slot reference node
@@ -1040,7 +1494,7 @@ const updateFallbackSlotVisibility = (elm) => {
1040
1494
  nodeType = childNodes[j].nodeType;
1041
1495
  if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1042
1496
  // this sibling node is from a different component OR is a named fallback slot node
1043
- if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1497
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1044
1498
  childNode.hidden = true;
1045
1499
  break;
1046
1500
  }
@@ -1049,8 +1503,8 @@ const updateFallbackSlotVisibility = (elm) => {
1049
1503
  // this is a default fallback slot node
1050
1504
  // any element or text node (with content)
1051
1505
  // should hide the default fallback slot node
1052
- if (nodeType === 1 /* ElementNode */ ||
1053
- (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1506
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1507
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
1054
1508
  childNode.hidden = true;
1055
1509
  break;
1056
1510
  }
@@ -1128,13 +1582,13 @@ const relocateSlotContent = (elm) => {
1128
1582
  }
1129
1583
  }
1130
1584
  }
1131
- if (childNode.nodeType === 1 /* ElementNode */) {
1585
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1132
1586
  relocateSlotContent(childNode);
1133
1587
  }
1134
1588
  }
1135
1589
  };
1136
1590
  const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1137
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1591
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1138
1592
  if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1139
1593
  return true;
1140
1594
  }
@@ -1154,6 +1608,18 @@ const callNodeRefs = (vNode) => {
1154
1608
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
1155
1609
  }
1156
1610
  };
1611
+ /**
1612
+ * The main entry point for Rindo's virtual DOM-based rendering engine
1613
+ *
1614
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1615
+ * function will handle creating a virtual DOM tree with a single root, patching
1616
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1617
+ * relocation, and reflecting attributes.
1618
+ *
1619
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1620
+ * the DOM node into which it should be rendered.
1621
+ * @param renderFnResults the virtual DOM nodes to be rendered
1622
+ */
1157
1623
  const renderVdom = (hostRef, renderFnResults) => {
1158
1624
  const hostElm = hostRef.$hostElement$;
1159
1625
  const cmpMeta = hostRef.$cmpMeta$;
@@ -1180,7 +1646,7 @@ render() {
1180
1646
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1181
1647
  }
1182
1648
  rootVnode.$tag$ = null;
1183
- rootVnode.$flags$ |= 4 /* isHost */;
1649
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1184
1650
  hostRef.$vnode$ = rootVnode;
1185
1651
  rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1186
1652
  if (BUILD.scoped || BUILD.shadowDom) {
@@ -1188,7 +1654,7 @@ render() {
1188
1654
  }
1189
1655
  if (BUILD.slotRelocation) {
1190
1656
  contentRef = hostElm['s-cr'];
1191
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1657
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1192
1658
  // always reset
1193
1659
  checkSlotFallbackVisibility = false;
1194
1660
  }
@@ -1197,7 +1663,7 @@ render() {
1197
1663
  if (BUILD.slotRelocation) {
1198
1664
  // while we're moving nodes around existing nodes, temporarily disable
1199
1665
  // the disconnectCallback from working
1200
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1666
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1201
1667
  if (checkSlotRelocate) {
1202
1668
  relocateSlotContent(rootVnode.$elm$);
1203
1669
  let relocateData;
@@ -1257,7 +1723,7 @@ render() {
1257
1723
  }
1258
1724
  else {
1259
1725
  // this node doesn't have a slot home to go to, so let's hide it
1260
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1726
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1261
1727
  nodeToRelocate.hidden = true;
1262
1728
  }
1263
1729
  }
@@ -1268,7 +1734,7 @@ render() {
1268
1734
  }
1269
1735
  // done moving nodes around
1270
1736
  // allow the disconnect callback to work again
1271
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1737
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1272
1738
  // always reset
1273
1739
  relocateNodes.length = 0;
1274
1740
  }
@@ -1280,35 +1746,6 @@ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-loc
1280
1746
  (nodeToRelocate.localName
1281
1747
  ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1282
1748
  : `[${nodeToRelocate.textContent}]`));
1283
- const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
1284
- const createEvent = (ref, name, flags) => {
1285
- const elm = getElement(ref);
1286
- return {
1287
- emit: (detail) => {
1288
- if (BUILD.isDev && !elm.isConnected) {
1289
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1290
- }
1291
- return emitEvent(elm, name, {
1292
- bubbles: !!(flags & 4 /* Bubbles */),
1293
- composed: !!(flags & 2 /* Composed */),
1294
- cancelable: !!(flags & 1 /* Cancellable */),
1295
- detail,
1296
- });
1297
- },
1298
- };
1299
- };
1300
- /**
1301
- * Helper function to create & dispatch a custom Event on a provided target
1302
- * @param elm the target of the Event
1303
- * @param name the name to give the custom Event
1304
- * @param opts options for configuring a custom Event
1305
- * @returns the custom Event
1306
- */
1307
- const emitEvent = (elm, name, opts) => {
1308
- const ev = plt.ce(name, opts);
1309
- elm.dispatchEvent(ev);
1310
- return ev;
1311
- };
1312
1749
  const attachToAncestor = (hostRef, ancestorComponent) => {
1313
1750
  if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1314
1751
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -1316,10 +1753,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
1316
1753
  };
1317
1754
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1318
1755
  if (BUILD.taskQueue && BUILD.updatable) {
1319
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1756
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1320
1757
  }
1321
- if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1322
- hostRef.$flags$ |= 512 /* needsRerender */;
1758
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1759
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1323
1760
  return;
1324
1761
  }
1325
1762
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -1336,7 +1773,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
1336
1773
  let promise;
1337
1774
  if (isInitialLoad) {
1338
1775
  if (BUILD.lazyLoad && BUILD.hostListener) {
1339
- hostRef.$flags$ |= 256 /* isListenReady */;
1776
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1340
1777
  if (hostRef.$queuedListeners$) {
1341
1778
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1342
1779
  hostRef.$queuedListeners$ = null;
@@ -1371,7 +1808,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1371
1808
  }
1372
1809
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1373
1810
  if (BUILD.isDev) {
1374
- hostRef.$flags$ |= 1024 /* devOnRender */;
1811
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1375
1812
  }
1376
1813
  if (BUILD.hydrateServerSide) {
1377
1814
  await callRender(hostRef, instance, elm);
@@ -1384,7 +1821,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1384
1821
  }
1385
1822
  if (BUILD.isDev) {
1386
1823
  hostRef.$renderCount$++;
1387
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1824
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1388
1825
  }
1389
1826
  if (BUILD.hydrateServerSide) {
1390
1827
  try {
@@ -1392,10 +1829,10 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1392
1829
  serverSideConnected(elm);
1393
1830
  if (isInitialLoad) {
1394
1831
  // using only during server-side hydrate
1395
- if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1832
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1396
1833
  elm['s-en'] = '';
1397
1834
  }
1398
- else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
1835
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1399
1836
  elm['s-en'] = 'c';
1400
1837
  }
1401
1838
  }
@@ -1421,7 +1858,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1421
1858
  }
1422
1859
  else {
1423
1860
  Promise.all(childrenPromises).then(postUpdate);
1424
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1861
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1425
1862
  childrenPromises.length = 0;
1426
1863
  }
1427
1864
  }
@@ -1441,10 +1878,10 @@ const callRender = (hostRef, instance, elm) => {
1441
1878
  renderingRef = instance;
1442
1879
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
1443
1880
  if (updatable && taskQueue) {
1444
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1881
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1445
1882
  }
1446
1883
  if (updatable || lazyLoad) {
1447
- hostRef.$flags$ |= 2 /* hasRendered */;
1884
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1448
1885
  }
1449
1886
  if (BUILD.hasRenderFn || BUILD.reflect) {
1450
1887
  if (BUILD.vdomRender || BUILD.reflect) {
@@ -1478,27 +1915,27 @@ const postUpdateComponent = (hostRef) => {
1478
1915
  const ancestorComponent = hostRef.$ancestorComponent$;
1479
1916
  if (BUILD.cmpDidRender) {
1480
1917
  if (BUILD.isDev) {
1481
- hostRef.$flags$ |= 1024 /* devOnRender */;
1918
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1482
1919
  }
1483
1920
  safeCall(instance, 'componentDidRender');
1484
1921
  if (BUILD.isDev) {
1485
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1922
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1486
1923
  }
1487
1924
  }
1488
1925
  emitLifecycleEvent(elm, 'componentDidRender');
1489
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1490
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1926
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1927
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1491
1928
  if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1492
1929
  // DOM WRITE!
1493
1930
  addHydratedFlag(elm);
1494
1931
  }
1495
1932
  if (BUILD.cmpDidLoad) {
1496
1933
  if (BUILD.isDev) {
1497
- hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1934
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1498
1935
  }
1499
1936
  safeCall(instance, 'componentDidLoad');
1500
1937
  if (BUILD.isDev) {
1501
- hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1938
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1502
1939
  }
1503
1940
  }
1504
1941
  emitLifecycleEvent(elm, 'componentDidLoad');
@@ -1517,11 +1954,11 @@ const postUpdateComponent = (hostRef) => {
1517
1954
  // componentDidUpdate runs AFTER render() has been called
1518
1955
  // and all child components have finished updating
1519
1956
  if (BUILD.isDev) {
1520
- hostRef.$flags$ |= 1024 /* devOnRender */;
1957
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1521
1958
  }
1522
1959
  safeCall(instance, 'componentDidUpdate');
1523
1960
  if (BUILD.isDev) {
1524
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1961
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1525
1962
  }
1526
1963
  }
1527
1964
  emitLifecycleEvent(elm, 'componentDidUpdate');
@@ -1540,10 +1977,10 @@ const postUpdateComponent = (hostRef) => {
1540
1977
  hostRef.$onRenderResolve$();
1541
1978
  hostRef.$onRenderResolve$ = undefined;
1542
1979
  }
1543
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1980
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1544
1981
  nextTick(() => scheduleUpdate(hostRef, false));
1545
1982
  }
1546
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1983
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1547
1984
  }
1548
1985
  // ( •_•)
1549
1986
  // ( •_•)>⌐■-■
@@ -1554,7 +1991,7 @@ const forceUpdate = (ref) => {
1554
1991
  const hostRef = getHostRef(ref);
1555
1992
  const isConnected = hostRef.$hostElement$.isConnected;
1556
1993
  if (isConnected &&
1557
- (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1994
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1558
1995
  scheduleUpdate(hostRef, false);
1559
1996
  }
1560
1997
  // Returns "true" when the forced update was successfully scheduled
@@ -1565,310 +2002,58 @@ const forceUpdate = (ref) => {
1565
2002
  const appDidLoad = (who) => {
1566
2003
  // on appload
1567
2004
  // we have finish the first big initial render
1568
- if (BUILD.cssAnnotations) {
1569
- addHydratedFlag(doc.documentElement);
1570
- }
1571
- if (BUILD.asyncQueue) {
1572
- plt.$flags$ |= 2 /* appLoaded */;
1573
- }
1574
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1575
- if (BUILD.profile && performance.measure) {
1576
- performance.measure(`[Rindo] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1577
- }
1578
- };
1579
- const safeCall = (instance, method, arg) => {
1580
- if (instance && instance[method]) {
1581
- try {
1582
- return instance[method](arg);
1583
- }
1584
- catch (e) {
1585
- consoleError(e);
1586
- }
1587
- }
1588
- return undefined;
1589
- };
1590
- const then = (promise, thenFn) => {
1591
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1592
- };
1593
- const emitLifecycleEvent = (elm, lifecycleName) => {
1594
- if (BUILD.lifecycleDOMEvents) {
1595
- emitEvent(elm, 'rindo_' + lifecycleName, {
1596
- bubbles: true,
1597
- composed: true,
1598
- detail: {
1599
- namespace: NAMESPACE,
1600
- },
1601
- });
1602
- }
1603
- };
1604
- const addHydratedFlag = (elm) => BUILD.hydratedClass
1605
- ? elm.classList.add('hydrated')
1606
- : BUILD.hydratedAttribute
1607
- ? elm.setAttribute('hydrated', '')
1608
- : undefined;
1609
- const serverSideConnected = (elm) => {
1610
- const children = elm.children;
1611
- if (children != null) {
1612
- for (let i = 0, ii = children.length; i < ii; i++) {
1613
- const childElm = children[i];
1614
- if (typeof childElm.connectedCallback === 'function') {
1615
- childElm.connectedCallback();
1616
- }
1617
- serverSideConnected(childElm);
1618
- }
1619
- }
1620
- };
1621
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1622
- const endHydrate = createTime('hydrateClient', tagName);
1623
- const shadowRoot = hostElm.shadowRoot;
1624
- const childRenderNodes = [];
1625
- const slotNodes = [];
1626
- const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
1627
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
1628
- if (!plt.$orgLocNodes$) {
1629
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
1630
- }
1631
- hostElm[HYDRATE_ID] = hostId;
1632
- hostElm.removeAttribute(HYDRATE_ID);
1633
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1634
- childRenderNodes.map((c) => {
1635
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1636
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1637
- const node = c.$elm$;
1638
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
1639
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1640
- }
1641
- if (!shadowRoot) {
1642
- node['s-hn'] = tagName;
1643
- if (orgLocationNode) {
1644
- node['s-ol'] = orgLocationNode;
1645
- node['s-ol']['s-nr'] = node;
1646
- }
1647
- }
1648
- plt.$orgLocNodes$.delete(orgLocationId);
1649
- });
1650
- if (BUILD.shadowDom && shadowRoot) {
1651
- shadowRootNodes.map((shadowRootNode) => {
1652
- if (shadowRootNode) {
1653
- shadowRoot.appendChild(shadowRootNode);
1654
- }
1655
- });
1656
- }
1657
- endHydrate();
1658
- };
1659
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1660
- let childNodeType;
1661
- let childIdSplt;
1662
- let childVNode;
1663
- let i;
1664
- if (node.nodeType === 1 /* ElementNode */) {
1665
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1666
- if (childNodeType) {
1667
- // got the node data from the element's attribute
1668
- // `${hostId}.${nodeId}.${depth}.${index}`
1669
- childIdSplt = childNodeType.split('.');
1670
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1671
- childVNode = {
1672
- $flags$: 0,
1673
- $hostId$: childIdSplt[0],
1674
- $nodeId$: childIdSplt[1],
1675
- $depth$: childIdSplt[2],
1676
- $index$: childIdSplt[3],
1677
- $tag$: node.tagName.toLowerCase(),
1678
- $elm$: node,
1679
- $attrs$: null,
1680
- $children$: null,
1681
- $key$: null,
1682
- $name$: null,
1683
- $text$: null,
1684
- };
1685
- childRenderNodes.push(childVNode);
1686
- node.removeAttribute(HYDRATE_CHILD_ID);
1687
- // this is a new child vnode
1688
- // so ensure its parent vnode has the vchildren array
1689
- if (!parentVNode.$children$) {
1690
- parentVNode.$children$ = [];
1691
- }
1692
- // add our child vnode to a specific index of the vnode's children
1693
- parentVNode.$children$[childVNode.$index$] = childVNode;
1694
- // this is now the new parent vnode for all the next child checks
1695
- parentVNode = childVNode;
1696
- if (shadowRootNodes && childVNode.$depth$ === '0') {
1697
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1698
- }
1699
- }
1700
- }
1701
- // recursively drill down, end to start so we can remove nodes
1702
- for (i = node.childNodes.length - 1; i >= 0; i--) {
1703
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1704
- }
1705
- if (node.shadowRoot) {
1706
- // keep drilling down through the shadow root nodes
1707
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1708
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1709
- }
1710
- }
1711
- }
1712
- else if (node.nodeType === 8 /* CommentNode */) {
1713
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1714
- childIdSplt = node.nodeValue.split('.');
1715
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1716
- // comment node for either the host id or a 0 host id
1717
- childNodeType = childIdSplt[0];
1718
- childVNode = {
1719
- $flags$: 0,
1720
- $hostId$: childIdSplt[1],
1721
- $nodeId$: childIdSplt[2],
1722
- $depth$: childIdSplt[3],
1723
- $index$: childIdSplt[4],
1724
- $elm$: node,
1725
- $attrs$: null,
1726
- $children$: null,
1727
- $key$: null,
1728
- $name$: null,
1729
- $tag$: null,
1730
- $text$: null,
1731
- };
1732
- if (childNodeType === TEXT_NODE_ID) {
1733
- childVNode.$elm$ = node.nextSibling;
1734
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1735
- childVNode.$text$ = childVNode.$elm$.textContent;
1736
- childRenderNodes.push(childVNode);
1737
- // remove the text comment since it's no longer needed
1738
- node.remove();
1739
- if (!parentVNode.$children$) {
1740
- parentVNode.$children$ = [];
1741
- }
1742
- parentVNode.$children$[childVNode.$index$] = childVNode;
1743
- if (shadowRootNodes && childVNode.$depth$ === '0') {
1744
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1745
- }
1746
- }
1747
- }
1748
- else if (childVNode.$hostId$ === hostId) {
1749
- // this comment node is specifcally for this host id
1750
- if (childNodeType === SLOT_NODE_ID) {
1751
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1752
- childVNode.$tag$ = 'slot';
1753
- if (childIdSplt[5]) {
1754
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1755
- }
1756
- else {
1757
- node['s-sn'] = '';
1758
- }
1759
- node['s-sr'] = true;
1760
- if (BUILD.shadowDom && shadowRootNodes) {
1761
- // browser support shadowRoot and this is a shadow dom component
1762
- // create an actual slot element
1763
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1764
- if (childVNode.$name$) {
1765
- // add the slot name attribute
1766
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
1767
- }
1768
- // insert the new slot element before the slot comment
1769
- node.parentNode.insertBefore(childVNode.$elm$, node);
1770
- // remove the slot comment since it's not needed for shadow
1771
- node.remove();
1772
- if (childVNode.$depth$ === '0') {
1773
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1774
- }
1775
- }
1776
- slotNodes.push(childVNode);
1777
- if (!parentVNode.$children$) {
1778
- parentVNode.$children$ = [];
1779
- }
1780
- parentVNode.$children$[childVNode.$index$] = childVNode;
1781
- }
1782
- else if (childNodeType === CONTENT_REF_ID) {
1783
- // `${CONTENT_REF_ID}.${hostId}`;
1784
- if (BUILD.shadowDom && shadowRootNodes) {
1785
- // remove the content ref comment since it's not needed for shadow
1786
- node.remove();
1787
- }
1788
- else if (BUILD.slotRelocation) {
1789
- hostElm['s-cr'] = node;
1790
- node['s-cn'] = true;
1791
- }
1792
- }
1793
- }
1794
- }
2005
+ if (BUILD.cssAnnotations) {
2006
+ addHydratedFlag(doc.documentElement);
1795
2007
  }
1796
- else if (parentVNode && parentVNode.$tag$ === 'style') {
1797
- const vnode = newVNode(null, node.textContent);
1798
- vnode.$elm$ = node;
1799
- vnode.$index$ = '0';
1800
- parentVNode.$children$ = [vnode];
2008
+ if (BUILD.asyncQueue) {
2009
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2010
+ }
2011
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2012
+ if (BUILD.profile && performance.measure) {
2013
+ performance.measure(`[Rindo] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1801
2014
  }
1802
2015
  };
1803
- const initializeDocumentHydrate = (node, orgLocNodes) => {
1804
- if (node.nodeType === 1 /* ElementNode */) {
1805
- let i = 0;
1806
- for (; i < node.childNodes.length; i++) {
1807
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
2016
+ const safeCall = (instance, method, arg) => {
2017
+ if (instance && instance[method]) {
2018
+ try {
2019
+ return instance[method](arg);
1808
2020
  }
1809
- if (node.shadowRoot) {
1810
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
1811
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1812
- }
2021
+ catch (e) {
2022
+ consoleError(e);
1813
2023
  }
1814
2024
  }
1815
- else if (node.nodeType === 8 /* CommentNode */) {
1816
- const childIdSplt = node.nodeValue.split('.');
1817
- if (childIdSplt[0] === ORG_LOCATION_ID) {
1818
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
1819
- node.nodeValue = '';
1820
- // useful to know if the original location is
1821
- // the root light-dom of a shadow dom component
1822
- node['s-en'] = childIdSplt[3];
1823
- }
2025
+ return undefined;
2026
+ };
2027
+ const then = (promise, thenFn) => {
2028
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
2029
+ };
2030
+ const emitLifecycleEvent = (elm, lifecycleName) => {
2031
+ if (BUILD.lifecycleDOMEvents) {
2032
+ emitEvent(elm, 'rindo_' + lifecycleName, {
2033
+ bubbles: true,
2034
+ composed: true,
2035
+ detail: {
2036
+ namespace: NAMESPACE,
2037
+ },
2038
+ });
1824
2039
  }
1825
2040
  };
1826
- /**
1827
- * Parse a new property value for a given property type.
1828
- *
1829
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1830
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1831
- * 1. `any`, the type given to `propValue` in the function signature
1832
- * 2. the type stored from `propType`.
1833
- *
1834
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1835
- *
1836
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1837
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1838
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1839
- * ```tsx
1840
- * <my-cmp prop-val={0}></my-cmp>
1841
- * ```
1842
- *
1843
- * HTML prop values on the other hand, will always a string
1844
- *
1845
- * @param propValue the new value to coerce to some type
1846
- * @param propType the type of the prop, expressed as a binary number
1847
- * @returns the parsed/coerced value
1848
- */
1849
- const parsePropertyValue = (propValue, propType) => {
1850
- // ensure this value is of the correct prop type
1851
- if (propValue != null && !isComplexType(propValue)) {
1852
- if (BUILD.propBoolean && propType & 4 /* Boolean */) {
1853
- // per the HTML spec, any string value means it is a boolean true value
1854
- // but we'll cheat here and say that the string "false" is the boolean false
1855
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1856
- }
1857
- if (BUILD.propNumber && propType & 2 /* Number */) {
1858
- // force it to be a number
1859
- return parseFloat(propValue);
1860
- }
1861
- if (BUILD.propString && propType & 1 /* String */) {
1862
- // could have been passed as a number or boolean
1863
- // but we still want it as a string
1864
- return String(propValue);
2041
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
2042
+ ? elm.classList.add('hydrated')
2043
+ : BUILD.hydratedAttribute
2044
+ ? elm.setAttribute('hydrated', '')
2045
+ : undefined;
2046
+ const serverSideConnected = (elm) => {
2047
+ const children = elm.children;
2048
+ if (children != null) {
2049
+ for (let i = 0, ii = children.length; i < ii; i++) {
2050
+ const childElm = children[i];
2051
+ if (typeof childElm.connectedCallback === 'function') {
2052
+ childElm.connectedCallback();
2053
+ }
2054
+ serverSideConnected(childElm);
1865
2055
  }
1866
- // redundant return here for better minification
1867
- return propValue;
1868
2056
  }
1869
- // not sure exactly what type we want
1870
- // so no need to change to a different type
1871
- return propValue;
1872
2057
  };
1873
2058
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1874
2059
  const setValue = (ref, propName, newVal, cmpMeta) => {
@@ -1882,21 +2067,21 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1882
2067
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1883
2068
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1884
2069
  const didValueChange = newVal !== oldVal && !areBothNaN;
1885
- if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2070
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1886
2071
  // gadzooks! the property's value has changed!!
1887
2072
  // set our new value!
1888
2073
  hostRef.$instanceValues$.set(propName, newVal);
1889
2074
  if (BUILD.isDev) {
1890
- if (hostRef.$flags$ & 1024 /* devOnRender */) {
2075
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
1891
2076
  consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1892
2077
  }
1893
- else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
2078
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
1894
2079
  consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1895
2080
  }
1896
2081
  }
1897
2082
  if (!BUILD.lazyLoad || instance) {
1898
2083
  // get an array of method names of watch functions to call
1899
- if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
2084
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1900
2085
  const watchMethods = cmpMeta.$watchers$[propName];
1901
2086
  if (watchMethods) {
1902
2087
  // this instance is watching for when this property changed
@@ -1912,7 +2097,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1912
2097
  }
1913
2098
  }
1914
2099
  if (BUILD.updatable &&
1915
- (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
2100
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1916
2101
  if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1917
2102
  if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1918
2103
  return;
@@ -1927,6 +2112,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1927
2112
  }
1928
2113
  }
1929
2114
  };
2115
+ /**
2116
+ * Attach a series of runtime constructs to a compiled Rindo component
2117
+ * constructor, including getters and setters for the `@Prop` and `@State`
2118
+ * decorators, callbacks for when attributes change, and so on.
2119
+ *
2120
+ * @param Cstr the constructor for a component that we need to process
2121
+ * @param cmpMeta metadata collected previously about the component
2122
+ * @param flags a number used to store a series of bit flags
2123
+ * @returns a reference to the same constructor passed in (but now mutated)
2124
+ */
1930
2125
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1931
2126
  if (BUILD.member && cmpMeta.$members$) {
1932
2127
  if (BUILD.watchCallback && Cstr.watchers) {
@@ -1937,8 +2132,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1937
2132
  const prototype = Cstr.prototype;
1938
2133
  members.map(([memberName, [memberFlags]]) => {
1939
2134
  if ((BUILD.prop || BUILD.state) &&
1940
- (memberFlags & 31 /* Prop */ ||
1941
- ((!BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
2135
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2136
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1942
2137
  // proxyComponent - prop
1943
2138
  Object.defineProperty(prototype, memberName, {
1944
2139
  get() {
@@ -1951,13 +2146,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1951
2146
  const ref = getHostRef(this);
1952
2147
  if (
1953
2148
  // we are proxying the instance (not element)
1954
- (flags & 1 /* isElementConstructor */) === 0 &&
2149
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
1955
2150
  // the element is not constructing
1956
- (ref.$flags$ & 8 /* isConstructingInstance */) === 0 &&
2151
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
1957
2152
  // the member is a prop
1958
- (memberFlags & 31 /* Prop */) !== 0 &&
2153
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
1959
2154
  // the member is not mutable
1960
- (memberFlags & 1024 /* Mutable */) === 0) {
2155
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
1961
2156
  consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://rindojs.web.app/docs/properties#prop-mutability`);
1962
2157
  }
1963
2158
  }
@@ -1970,8 +2165,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1970
2165
  }
1971
2166
  else if (BUILD.lazyLoad &&
1972
2167
  BUILD.method &&
1973
- flags & 1 /* isElementConstructor */ &&
1974
- memberFlags & 64 /* Method */) {
2168
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2169
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1975
2170
  // proxyComponent - method
1976
2171
  Object.defineProperty(prototype, memberName, {
1977
2172
  value(...args) {
@@ -1981,7 +2176,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1981
2176
  });
1982
2177
  }
1983
2178
  });
1984
- if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
2179
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1985
2180
  const attrNameToPropName = new Map();
1986
2181
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1987
2182
  plt.jmp(() => {
@@ -2016,7 +2211,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
2016
2211
  //
2017
2212
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2018
2213
  //
2019
- // TODO: we should think about whether or not we actually want to be reflecting the attributes to
2214
+ // TODO we should think about whether or not we actually want to be reflecting the attributes to
2020
2215
  // properties here given that this goes against best practices outlined here
2021
2216
  // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2022
2217
  if (this.hasOwnProperty(propName)) {
@@ -2037,11 +2232,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
2037
2232
  // create an array of attributes to observe
2038
2233
  // and also create a map of html attribute name to js property name
2039
2234
  Cstr.observedAttributes = members
2040
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
2235
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
2041
2236
  .map(([propName, m]) => {
2042
2237
  const attrName = m[1] || propName;
2043
2238
  attrNameToPropName.set(attrName, propName);
2044
- if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
2239
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2045
2240
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
2046
2241
  }
2047
2242
  return attrName;
@@ -2053,10 +2248,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
2053
2248
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2054
2249
  // initializeComponent
2055
2250
  if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2056
- (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2251
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2057
2252
  if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2058
2253
  // we haven't initialized this element yet
2059
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2254
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2060
2255
  // lazy loaded components
2061
2256
  // request the component's implementation to be
2062
2257
  // wired up with the host element
@@ -2077,7 +2272,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2077
2272
  if (BUILD.watchCallback) {
2078
2273
  cmpMeta.$watchers$ = Cstr.watchers;
2079
2274
  }
2080
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
2275
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2081
2276
  Cstr.isProxied = true;
2082
2277
  }
2083
2278
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -2085,7 +2280,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2085
2280
  // but let's keep track of when we start and stop
2086
2281
  // so that the getters/setters don't incorrectly step on data
2087
2282
  if (BUILD.member) {
2088
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
2283
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2089
2284
  }
2090
2285
  // construct the lazy-loaded component implementation
2091
2286
  // passing the hostRef is very important during
@@ -2098,10 +2293,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2098
2293
  consoleError(e);
2099
2294
  }
2100
2295
  if (BUILD.member) {
2101
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
2296
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2102
2297
  }
2103
2298
  if (BUILD.watchCallback) {
2104
- hostRef.$flags$ |= 128 /* isWatchReady */;
2299
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2105
2300
  }
2106
2301
  endNewInstance();
2107
2302
  fireConnectedCallback(hostRef.$lazyInstance$);
@@ -2109,11 +2304,11 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2109
2304
  else {
2110
2305
  // sync constructor component
2111
2306
  Cstr = elm.constructor;
2112
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2307
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2113
2308
  // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2114
2309
  // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2115
2310
  // Rindo has completed instantiating the component.
2116
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* isWatchReady */));
2311
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2117
2312
  }
2118
2313
  if (BUILD.style && Cstr.style) {
2119
2314
  // this component has styles but we haven't registered them yet
@@ -2130,10 +2325,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2130
2325
  if (!BUILD.hydrateServerSide &&
2131
2326
  BUILD.shadowDom &&
2132
2327
  BUILD.shadowDomShim &&
2133
- cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2328
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2134
2329
  style = await import('./shadow-css.js').then((m) => m.scopeCss(style, scopeId, false));
2135
2330
  }
2136
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2331
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2137
2332
  endRegisterStyles();
2138
2333
  }
2139
2334
  }
@@ -2160,7 +2355,7 @@ const fireConnectedCallback = (instance) => {
2160
2355
  }
2161
2356
  };
2162
2357
  const connectedCallback = (elm) => {
2163
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2358
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2164
2359
  const hostRef = getHostRef(elm);
2165
2360
  const cmpMeta = hostRef.$cmpMeta$;
2166
2361
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
@@ -2168,14 +2363,14 @@ const connectedCallback = (elm) => {
2168
2363
  // only run if we have listeners being attached to a parent
2169
2364
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2170
2365
  }
2171
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2366
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2172
2367
  // first time this component has connected
2173
- hostRef.$flags$ |= 1 /* hasConnected */;
2368
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2174
2369
  let hostId;
2175
2370
  if (BUILD.hydrateClientSide) {
2176
2371
  hostId = elm.getAttribute(HYDRATE_ID);
2177
2372
  if (hostId) {
2178
- if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2373
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2179
2374
  const scopeId = BUILD.mode
2180
2375
  ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2181
2376
  : addStyle(elm.shadowRoot, cmpMeta);
@@ -2191,7 +2386,7 @@ const connectedCallback = (elm) => {
2191
2386
  // host element has been connected to the DOM
2192
2387
  if (BUILD.hydrateServerSide ||
2193
2388
  ((BUILD.slot || BUILD.shadowDom) &&
2194
- cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
2389
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2195
2390
  setContentReference(elm);
2196
2391
  }
2197
2392
  }
@@ -2203,7 +2398,7 @@ const connectedCallback = (elm) => {
2203
2398
  // climb up the ancestors looking for the first
2204
2399
  // component that hasn't finished its lifecycle update yet
2205
2400
  if ((BUILD.hydrateClientSide &&
2206
- ancestorComponent.nodeType === 1 /* ElementNode */ &&
2401
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2207
2402
  ancestorComponent.hasAttribute('s-id') &&
2208
2403
  ancestorComponent['s-p']) ||
2209
2404
  ancestorComponent['s-p']) {
@@ -2218,7 +2413,7 @@ const connectedCallback = (elm) => {
2218
2413
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2219
2414
  if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2220
2415
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2221
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2416
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2222
2417
  const value = elm[memberName];
2223
2418
  delete elm[memberName];
2224
2419
  elm[memberName] = value;
@@ -2259,7 +2454,7 @@ const setContentReference = (elm) => {
2259
2454
  elm.insertBefore(contentRefElm, elm.firstChild);
2260
2455
  };
2261
2456
  const disconnectedCallback = (elm) => {
2262
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2457
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2263
2458
  const hostRef = getHostRef(elm);
2264
2459
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2265
2460
  if (BUILD.hostListener) {
@@ -2300,8 +2495,8 @@ const proxyCustomElement = (Cstr, compactMeta) => {
2300
2495
  if (BUILD.reflect) {
2301
2496
  cmpMeta.$attrsToReflect$ = [];
2302
2497
  }
2303
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2304
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2498
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2499
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2305
2500
  }
2306
2501
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
2307
2502
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
@@ -2326,7 +2521,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
2326
2521
  if (BUILD.shadowDelegatesFocus) {
2327
2522
  this.attachShadow({
2328
2523
  mode: 'open',
2329
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2524
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2330
2525
  });
2331
2526
  }
2332
2527
  else {
@@ -2339,7 +2534,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
2339
2534
  },
2340
2535
  });
2341
2536
  Cstr.is = cmpMeta.$tagName$;
2342
- return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2537
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2343
2538
  };
2344
2539
  const forceModeUpdate = (elm) => {
2345
2540
  if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
@@ -2353,7 +2548,7 @@ const forceModeUpdate = (elm) => {
2353
2548
  const flags = cmpMeta.$flags$;
2354
2549
  if (style) {
2355
2550
  if (!styles.has(scopeId)) {
2356
- registerStyle(scopeId, style, !!(flags & 1 /* shadowDomEncapsulation */));
2551
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2357
2552
  }
2358
2553
  hostRef.$modeName$ = mode;
2359
2554
  elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
@@ -2363,23 +2558,6 @@ const forceModeUpdate = (elm) => {
2363
2558
  }
2364
2559
  }
2365
2560
  };
2366
- const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2367
- // ¯\_(ツ)_/¯
2368
- const hostRef = getHostRef(elm);
2369
- // reset state flags to only have been connected
2370
- hostRef.$flags$ = 1 /* hasConnected */;
2371
- // TODO
2372
- // detatch any event listeners that may have been added
2373
- // because we're not passing an exact event name it'll
2374
- // remove all of this element's event, which is good
2375
- // create a callback for when this component finishes hmr
2376
- elm['s-hmr-load'] = () => {
2377
- // finished hmr for this element
2378
- delete elm['s-hmr-load'];
2379
- };
2380
- // re-initialize the component
2381
- initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2382
- };
2383
2561
  const patchCloneNode = (HostElementPrototype) => {
2384
2562
  const orgCloneNode = HostElementPrototype.cloneNode;
2385
2563
  HostElementPrototype.cloneNode = function (deep) {
@@ -2442,7 +2620,7 @@ const patchSlotAppendChild = (HostElementPrototype) => {
2442
2620
  * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2443
2621
  */
2444
2622
  const patchTextContent = (hostElementPrototype, cmpMeta) => {
2445
- if (BUILD.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2623
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2446
2624
  const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2447
2625
  Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2448
2626
  Object.defineProperty(hostElementPrototype, 'textContent', {
@@ -2453,7 +2631,7 @@ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2453
2631
  const slotNode = getHostSlotNode(this.childNodes, '');
2454
2632
  // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2455
2633
  // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2456
- if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2634
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2457
2635
  return slotNode.nextSibling.textContent;
2458
2636
  }
2459
2637
  else if (slotNode) {
@@ -2472,7 +2650,7 @@ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2472
2650
  // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2473
2651
  // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2474
2652
  // sibling.
2475
- if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2653
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2476
2654
  slotNode.nextSibling.textContent = value;
2477
2655
  }
2478
2656
  else if (slotNode) {
@@ -2498,7 +2676,7 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
2498
2676
  return this[n];
2499
2677
  }
2500
2678
  }
2501
- if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2679
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2502
2680
  const childNodesFn = elm.__lookupGetter__('childNodes');
2503
2681
  Object.defineProperty(elm, 'children', {
2504
2682
  get() {
@@ -2513,8 +2691,8 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
2513
2691
  Object.defineProperty(elm, 'childNodes', {
2514
2692
  get() {
2515
2693
  const childNodes = childNodesFn.call(this);
2516
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 &&
2517
- getHostRef(this).$flags$ & 2 /* hasRendered */) {
2694
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2695
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2518
2696
  const result = new FakeNodeList();
2519
2697
  for (let i = 0; i < childNodes.length; i++) {
2520
2698
  const slot = childNodes[i]['s-nr'];
@@ -2558,7 +2736,25 @@ const getHostSlotChildNodes = (n, slotName) => {
2558
2736
  }
2559
2737
  return childNodes;
2560
2738
  };
2739
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2740
+ // ¯\_(ツ)_/¯
2741
+ const hostRef = getHostRef(elm);
2742
+ // reset state flags to only have been connected
2743
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2744
+ // TODO
2745
+ // detatch any event listeners that may have been added
2746
+ // because we're not passing an exact event name it'll
2747
+ // remove all of this element's event, which is good
2748
+ // create a callback for when this component finishes hmr
2749
+ elm['s-hmr-load'] = () => {
2750
+ // finished hmr for this element
2751
+ delete elm['s-hmr-load'];
2752
+ };
2753
+ // re-initialize the component
2754
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2755
+ };
2561
2756
  const bootstrapLazy = (lazyBundles, options = {}) => {
2757
+ var _a;
2562
2758
  if (BUILD.profile && performance.mark) {
2563
2759
  performance.mark('st:app:start');
2564
2760
  }
@@ -2579,13 +2775,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2579
2775
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2580
2776
  if (BUILD.asyncQueue) {
2581
2777
  if (options.syncQueue) {
2582
- plt.$flags$ |= 4 /* queueSync */;
2778
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2583
2779
  }
2584
2780
  }
2585
2781
  if (BUILD.hydrateClientSide) {
2586
2782
  // If the app is already hydrated there is not point to disable the
2587
2783
  // async queue. This will improve the first input delay
2588
- plt.$flags$ |= 2 /* appLoaded */;
2784
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2589
2785
  }
2590
2786
  if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2591
2787
  for (; i < styles.length; i++) {
@@ -2612,8 +2808,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2612
2808
  if (BUILD.watchCallback) {
2613
2809
  cmpMeta.$watchers$ = {};
2614
2810
  }
2615
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2616
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2811
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2812
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2617
2813
  }
2618
2814
  const tagName = BUILD.transformTagName && options.transformTagName
2619
2815
  ? options.transformTagName(cmpMeta.$tagName$)
@@ -2625,7 +2821,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2625
2821
  super(self);
2626
2822
  self = this;
2627
2823
  registerHost(self, cmpMeta);
2628
- if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2824
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2629
2825
  // this component is using shadow dom
2630
2826
  // and this browser supports shadow dom
2631
2827
  // add the read-only property "shadowRoot" to the host element
@@ -2634,7 +2830,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2634
2830
  if (BUILD.shadowDelegatesFocus) {
2635
2831
  self.attachShadow({
2636
2832
  mode: 'open',
2637
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2833
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2638
2834
  });
2639
2835
  }
2640
2836
  else {
@@ -2686,13 +2882,18 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2686
2882
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
2687
2883
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2688
2884
  cmpTags.push(tagName);
2689
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
2885
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2690
2886
  }
2691
2887
  });
2692
2888
  });
2693
2889
  if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2694
2890
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2695
2891
  visibilityStyle.setAttribute('data-styles', '');
2892
+ // Apply CSP nonce to the style tag if it exists
2893
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2894
+ if (nonce != null) {
2895
+ visibilityStyle.setAttribute('nonce', nonce);
2896
+ }
2696
2897
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2697
2898
  }
2698
2899
  // Process deferred connectedCallbacks now all components have been registered
@@ -2711,11 +2912,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2711
2912
  // Fallback appLoad event
2712
2913
  endBootstrap();
2713
2914
  };
2714
- const getAssetPath = (path) => {
2715
- const assetUrl = new URL(path, plt.$resourcesUrl$);
2716
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
2717
- };
2718
- const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
2719
2915
  const getConnect = (_ref, tagName) => {
2720
2916
  const componentOnReady = () => {
2721
2917
  let elm = doc.querySelector(tagName);
@@ -2765,6 +2961,82 @@ const getContext = (_elm, context) => {
2765
2961
  }
2766
2962
  return undefined;
2767
2963
  };
2964
+ const Fragment = (_, children) => children;
2965
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2966
+ if (BUILD.hostListener && listeners) {
2967
+ // this is called immediately within the element's constructor
2968
+ // initialize our event listeners on the host element
2969
+ // we do this now so that we can listen to events that may
2970
+ // have fired even before the instance is ready
2971
+ if (BUILD.hostListenerTargetParent) {
2972
+ // this component may have event listeners that should be attached to the parent
2973
+ if (attachParentListeners) {
2974
+ // this is being ran from within the connectedCallback
2975
+ // which is important so that we know the host element actually has a parent element
2976
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2977
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
2978
+ }
2979
+ else {
2980
+ // this is being ran from within the component constructor
2981
+ // everything BUT the parent element listeners should be attached at this time
2982
+ // filter out the listeners that are NOT being attached to the parent
2983
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
2984
+ }
2985
+ }
2986
+ listeners.map(([flags, name, method]) => {
2987
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
2988
+ const handler = hostListenerProxy(hostRef, method);
2989
+ const opts = hostListenerOpts(flags);
2990
+ plt.ael(target, name, handler, opts);
2991
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2992
+ });
2993
+ }
2994
+ };
2995
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
2996
+ try {
2997
+ if (BUILD.lazyLoad) {
2998
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2999
+ // instance is ready, let's call it's member method for this event
3000
+ hostRef.$lazyInstance$[methodName](ev);
3001
+ }
3002
+ else {
3003
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
3004
+ }
3005
+ }
3006
+ else {
3007
+ hostRef.$hostElement$[methodName](ev);
3008
+ }
3009
+ }
3010
+ catch (e) {
3011
+ consoleError(e);
3012
+ }
3013
+ };
3014
+ const getHostListenerTarget = (elm, flags) => {
3015
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3016
+ return doc;
3017
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3018
+ return win;
3019
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
3020
+ return doc.body;
3021
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
3022
+ return elm.parentElement;
3023
+ return elm;
3024
+ };
3025
+ // prettier-ignore
3026
+ const hostListenerOpts = (flags) => supportsListenerOptions
3027
+ ? ({
3028
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3029
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3030
+ })
3031
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3032
+ /**
3033
+ * Assigns the given value to the nonce property on the runtime platform object.
3034
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
3035
+ * @param nonce The value to be assigned to the platform nonce property.
3036
+ * @returns void
3037
+ */
3038
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
3039
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
2768
3040
  const insertVdomAnnotations = (doc, staticComponents) => {
2769
3041
  if (doc != null) {
2770
3042
  const docData = {
@@ -2785,10 +3057,10 @@ const insertVdomAnnotations = (doc, staticComponents) => {
2785
3057
  docData.rootLevelIds++;
2786
3058
  nodeId = docData.rootLevelIds;
2787
3059
  childId = `${hostId}.${nodeId}`;
2788
- if (nodeRef.nodeType === 1 /* ElementNode */) {
3060
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
2789
3061
  nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2790
3062
  }
2791
- else if (nodeRef.nodeType === 3 /* TextNode */) {
3063
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
2792
3064
  if (hostId === 0) {
2793
3065
  const textContent = nodeRef.nodeValue.trim();
2794
3066
  if (textContent === '') {
@@ -2830,7 +3102,7 @@ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
2830
3102
  if (node['s-nr'] != null) {
2831
3103
  orgLocationNodes.push(node);
2832
3104
  }
2833
- if (node.nodeType === 1 /* ElementNode */) {
3105
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
2834
3106
  node.childNodes.forEach((childNode) => {
2835
3107
  const hostRef = getHostRef(childNode);
2836
3108
  if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
@@ -2860,7 +3132,7 @@ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
2860
3132
  const parent = hostElm.parentElement;
2861
3133
  if (parent && parent.childNodes) {
2862
3134
  const parentChildNodes = Array.from(parent.childNodes);
2863
- const comment = parentChildNodes.find((node) => node.nodeType === 8 /* CommentNode */ && node['s-sr']);
3135
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
2864
3136
  if (comment) {
2865
3137
  const index = parentChildNodes.indexOf(hostElm) - 1;
2866
3138
  vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
@@ -2878,10 +3150,10 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
2878
3150
  const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2879
3151
  childElm['s-host-id'] = hostId;
2880
3152
  childElm['s-node-id'] = nodeId;
2881
- if (childElm.nodeType === 1 /* ElementNode */) {
3153
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
2882
3154
  childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2883
3155
  }
2884
- else if (childElm.nodeType === 3 /* TextNode */) {
3156
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
2885
3157
  const parentNode = childElm.parentNode;
2886
3158
  const nodeName = parentNode.nodeName;
2887
3159
  if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
@@ -2890,7 +3162,7 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
2890
3162
  parentNode.insertBefore(commentBeforeTextNode, childElm);
2891
3163
  }
2892
3164
  }
2893
- else if (childElm.nodeType === 8 /* CommentNode */) {
3165
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
2894
3166
  if (childElm['s-sr']) {
2895
3167
  const slotName = childElm['s-sn'] || '';
2896
3168
  const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
@@ -2904,9 +3176,7 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
2904
3176
  });
2905
3177
  }
2906
3178
  };
2907
- const setPlatformOptions = (opts) => Object.assign(plt, opts);
2908
- const Fragment = (_, children) => children;
2909
- const hostRefs = new WeakMap();
3179
+ const hostRefs = /*@__PURE__*/ new WeakMap();
2910
3180
  const getHostRef = (ref) => hostRefs.get(ref);
2911
3181
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2912
3182
  const registerHost = (elm, cmpMeta) => {
@@ -2968,8 +3238,51 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2968
3238
  return importedModule[exportName];
2969
3239
  }, consoleError);
2970
3240
  };
2971
- const styles = new Map();
3241
+ const styles = /*@__PURE__*/ new Map();
2972
3242
  const modeResolutionChain = [];
3243
+ const win = typeof window !== 'undefined' ? window : {};
3244
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
3245
+ const doc = win.document || { head: {} };
3246
+ const H = (win.HTMLElement || class {
3247
+ });
3248
+ const plt = {
3249
+ $flags$: 0,
3250
+ $resourcesUrl$: '',
3251
+ jmp: (h) => h(),
3252
+ raf: (h) => requestAnimationFrame(h),
3253
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3254
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3255
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
3256
+ };
3257
+ const setPlatformHelpers = (helpers) => {
3258
+ Object.assign(plt, helpers);
3259
+ };
3260
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
3261
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3262
+ : true;
3263
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3264
+ let supportsListenerOptions = false;
3265
+ try {
3266
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3267
+ get() {
3268
+ supportsListenerOptions = true;
3269
+ },
3270
+ }));
3271
+ }
3272
+ catch (e) { }
3273
+ return supportsListenerOptions;
3274
+ })();
3275
+ const promiseResolve = (v) => Promise.resolve(v);
3276
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3277
+ ? /*@__PURE__*/ (() => {
3278
+ try {
3279
+ new CSSStyleSheet();
3280
+ return typeof new CSSStyleSheet().replaceSync === 'function';
3281
+ }
3282
+ catch (e) { }
3283
+ return false;
3284
+ })()
3285
+ : false;
2973
3286
  const queueDomReads = [];
2974
3287
  const queueDomWrites = [];
2975
3288
  const queueDomWritesLow = [];
@@ -2977,7 +3290,7 @@ const queueTask = (queue, write) => (cb) => {
2977
3290
  queue.push(cb);
2978
3291
  if (!queuePending) {
2979
3292
  queuePending = true;
2980
- if (write && plt.$flags$ & 4 /* queueSync */) {
3293
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2981
3294
  nextTick(flush);
2982
3295
  }
2983
3296
  else {
@@ -3024,7 +3337,7 @@ const flush = () => {
3024
3337
  consume(queueDomReads);
3025
3338
  // DOM WRITES!!!
3026
3339
  if (BUILD.asyncQueue) {
3027
- const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
3340
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3028
3341
  ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3029
3342
  : Infinity;
3030
3343
  consumeTimeout(queueDomWrites, timeout);
@@ -3054,11 +3367,5 @@ const flush = () => {
3054
3367
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3055
3368
  const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3056
3369
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3057
- const Build = {
3058
- isDev: BUILD.isDev ? true : false,
3059
- isBrowser: true,
3060
- isServer: false,
3061
- isTesting: BUILD.isTesting ? true : false,
3062
- };
3063
3370
  export { BUILD, Env, NAMESPACE } from '@rindo/core/internal/app-data';
3064
- export { Build, CSS, Context, Fragment, H, H as HTMLElement, Host, RINDO_DEV_MODE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceModeUpdate, forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingRef, getValue, h, insertVdomAnnotations, isMemberInElement, loadModule, modeResolutionChain, nextTick, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setPlatformHelpers, setPlatformOptions, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsShadow, win, writeTask };
3371
+ export { Build, CSS, Context, Fragment, H, H as HTMLElement, Host, RINDO_DEV_MODE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceModeUpdate, forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingRef, getValue, h, insertVdomAnnotations, isMemberInElement, loadModule, modeResolutionChain, nextTick, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsShadow, win, writeTask };