@rindo/core 1.8.12

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 (463) hide show
  1. package/LICENSE.md +27 -0
  2. package/bin/rindo +22 -0
  3. package/build-conditionals/index.d.ts +2 -0
  4. package/build-conditionals/index.mjs +66 -0
  5. package/build-conditionals/package.json +6 -0
  6. package/compiler/index.js +2 -0
  7. package/compiler/package.json +6 -0
  8. package/compiler/rindo.js +6765 -0
  9. package/dist/cli/index.js +6068 -0
  10. package/dist/client/css-shim-14a9812e.js +656 -0
  11. package/dist/client/css-shim-69821662.js +658 -0
  12. package/dist/client/declarations/rindo.core.d.ts +1347 -0
  13. package/dist/client/dom-68c8fe31.js +139 -0
  14. package/dist/client/dom-af01458a.js +137 -0
  15. package/dist/client/index.js +2937 -0
  16. package/dist/client/index.mjs +2820 -0
  17. package/dist/client/polyfills/core-js.js +10 -0
  18. package/dist/client/polyfills/css-shim.js +656 -0
  19. package/dist/client/polyfills/dom.js +146 -0
  20. package/dist/client/polyfills/es5-html-element.js +18 -0
  21. package/dist/client/polyfills/index.js +35 -0
  22. package/dist/client/polyfills/promise.js +9 -0
  23. package/dist/client/polyfills/system.js +6 -0
  24. package/dist/client/shadow-css-6ef31c68.js +386 -0
  25. package/dist/client/shadow-css-8fd1a9e4.js +388 -0
  26. package/dist/compiler/app-core/app-es5-disabled.d.ts +2 -0
  27. package/dist/compiler/app-core/app-polyfills.d.ts +3 -0
  28. package/dist/compiler/app-core/build-conditionals.d.ts +6 -0
  29. package/dist/compiler/app-core/bundle-app-core.d.ts +6 -0
  30. package/dist/compiler/app-core/component-styles.d.ts +4 -0
  31. package/dist/compiler/app-core/format-component-runtime-meta.d.ts +4 -0
  32. package/dist/compiler/app-core/optimize-module.d.ts +7 -0
  33. package/dist/compiler/browser/build-conditionals-client.d.ts +3 -0
  34. package/dist/compiler/browser/compile-options.d.ts +12 -0
  35. package/dist/compiler/browser/compile.d.ts +2 -0
  36. package/dist/compiler/browser/create-compiler.d.ts +14 -0
  37. package/dist/compiler/browser/index.d.ts +11 -0
  38. package/dist/compiler/build/build-ctx.d.ts +74 -0
  39. package/dist/compiler/build/build-finish.d.ts +3 -0
  40. package/dist/compiler/build/build-hmr.d.ts +2 -0
  41. package/dist/compiler/build/build-results.d.ts +2 -0
  42. package/dist/compiler/build/build-stats.d.ts +3 -0
  43. package/dist/compiler/build/build.d.ts +2 -0
  44. package/dist/compiler/build/cache-stats.d.ts +4 -0
  45. package/dist/compiler/build/compiler-build-id.d.ts +6 -0
  46. package/dist/compiler/build/compiler-ctx.d.ts +44 -0
  47. package/dist/compiler/build/init-index-html.d.ts +2 -0
  48. package/dist/compiler/build/validate-files.d.ts +2 -0
  49. package/dist/compiler/build/write-build.d.ts +2 -0
  50. package/dist/compiler/cache.d.ts +22 -0
  51. package/dist/compiler/compiler.d.ts +27 -0
  52. package/dist/compiler/component-hydrate/bundle-hydrate-factory.d.ts +3 -0
  53. package/dist/compiler/component-hydrate/generate-hydrate-app.d.ts +2 -0
  54. package/dist/compiler/component-hydrate/hydrate-factory-closure.d.ts +2 -0
  55. package/dist/compiler/component-hydrate/update-to-hydrate-components.d.ts +2 -0
  56. package/dist/compiler/component-hydrate/write-hydrate-outputs.d.ts +3 -0
  57. package/dist/compiler/component-lazy/generate-cjs.d.ts +3 -0
  58. package/dist/compiler/component-lazy/generate-esm-browser.d.ts +3 -0
  59. package/dist/compiler/component-lazy/generate-esm.d.ts +3 -0
  60. package/dist/compiler/component-lazy/generate-lazy-app.d.ts +3 -0
  61. package/dist/compiler/component-lazy/generate-lazy-module.d.ts +4 -0
  62. package/dist/compiler/component-lazy/generate-system.d.ts +3 -0
  63. package/dist/compiler/component-lazy/update-to-lazy-component.d.ts +2 -0
  64. package/dist/compiler/component-lazy/write-lazy-entry-module.d.ts +2 -0
  65. package/dist/compiler/component-native/update-to-native-component.d.ts +2 -0
  66. package/dist/compiler/config/config-reload.d.ts +3 -0
  67. package/dist/compiler/config/config-utils.d.ts +4 -0
  68. package/dist/compiler/config/validate-config.d.ts +4 -0
  69. package/dist/compiler/config/validate-copy.d.ts +2 -0
  70. package/dist/compiler/config/validate-dev-server.d.ts +2 -0
  71. package/dist/compiler/config/validate-docs.d.ts +2 -0
  72. package/dist/compiler/config/validate-namespace.d.ts +3 -0
  73. package/dist/compiler/config/validate-output-stats.d.ts +2 -0
  74. package/dist/compiler/config/validate-outputs-angular.d.ts +2 -0
  75. package/dist/compiler/config/validate-outputs-custom.d.ts +2 -0
  76. package/dist/compiler/config/validate-outputs-dist-module.d.ts +2 -0
  77. package/dist/compiler/config/validate-outputs-dist.d.ts +2 -0
  78. package/dist/compiler/config/validate-outputs-hydrate-script.d.ts +2 -0
  79. package/dist/compiler/config/validate-outputs-www.d.ts +2 -0
  80. package/dist/compiler/config/validate-outputs.d.ts +2 -0
  81. package/dist/compiler/config/validate-paths.d.ts +2 -0
  82. package/dist/compiler/config/validate-plugins.d.ts +2 -0
  83. package/dist/compiler/config/validate-prerender.d.ts +2 -0
  84. package/dist/compiler/config/validate-rollup-config.d.ts +2 -0
  85. package/dist/compiler/config/validate-service-worker.d.ts +2 -0
  86. package/dist/compiler/config/validate-testing.d.ts +2 -0
  87. package/dist/compiler/config/validate-workers.d.ts +2 -0
  88. package/dist/compiler/copy/assets-copy-tasks.d.ts +3 -0
  89. package/dist/compiler/copy/hashed-copy.d.ts +2 -0
  90. package/dist/compiler/copy/local-copy-tasks.d.ts +3 -0
  91. package/dist/compiler/docs/constants.d.ts +2 -0
  92. package/dist/compiler/docs/custom/index.d.ts +2 -0
  93. package/dist/compiler/docs/docs.d.ts +2 -0
  94. package/dist/compiler/docs/generate-doc-data.d.ts +3 -0
  95. package/dist/compiler/docs/json/index.d.ts +3 -0
  96. package/dist/compiler/docs/readme/docs-util.d.ts +13 -0
  97. package/dist/compiler/docs/readme/index.d.ts +3 -0
  98. package/dist/compiler/docs/readme/markdown-css-props.d.ts +2 -0
  99. package/dist/compiler/docs/readme/markdown-dependencies.d.ts +2 -0
  100. package/dist/compiler/docs/readme/markdown-events.d.ts +2 -0
  101. package/dist/compiler/docs/readme/markdown-methods.d.ts +2 -0
  102. package/dist/compiler/docs/readme/markdown-props.d.ts +2 -0
  103. package/dist/compiler/docs/readme/markdown-slots.d.ts +2 -0
  104. package/dist/compiler/docs/readme/markdown-usage.d.ts +6 -0
  105. package/dist/compiler/docs/readme/output-docs.d.ts +3 -0
  106. package/dist/compiler/docs/style-docs.d.ts +2 -0
  107. package/dist/compiler/docs/vscode/index.d.ts +2 -0
  108. package/dist/compiler/entries/component-bundles.d.ts +3 -0
  109. package/dist/compiler/entries/component-graph.d.ts +2 -0
  110. package/dist/compiler/entries/default-bundles.d.ts +3 -0
  111. package/dist/compiler/entries/entry-modules.d.ts +6 -0
  112. package/dist/compiler/entries/resolve-component-dependencies.d.ts +2 -0
  113. package/dist/compiler/events.d.ts +15 -0
  114. package/dist/compiler/fs-watch/fs-watch-init.d.ts +2 -0
  115. package/dist/compiler/fs-watch/fs-watch-log.d.ts +2 -0
  116. package/dist/compiler/fs-watch/fs-watch-rebuild.d.ts +7 -0
  117. package/dist/compiler/html/inject-module-preloads.d.ts +3 -0
  118. package/dist/compiler/html/inject-sw-script.d.ts +4 -0
  119. package/dist/compiler/html/inline-esm-import.d.ts +2 -0
  120. package/dist/compiler/html/inline-style-sheets.d.ts +2 -0
  121. package/dist/compiler/html/update-global-styles-link.d.ts +2 -0
  122. package/dist/compiler/html/used-components.d.ts +2 -0
  123. package/dist/compiler/html/utils.d.ts +2 -0
  124. package/dist/compiler/html/validate-manifest-json.d.ts +2 -0
  125. package/dist/compiler/index.d.ts +10 -0
  126. package/dist/compiler/index.js +18008 -0
  127. package/dist/compiler/output-targets/empty-dir.d.ts +6 -0
  128. package/dist/compiler/output-targets/index.d.ts +2 -0
  129. package/dist/compiler/output-targets/output-angular.d.ts +4 -0
  130. package/dist/compiler/output-targets/output-app.d.ts +4 -0
  131. package/dist/compiler/output-targets/output-collection.d.ts +3 -0
  132. package/dist/compiler/output-targets/output-copy.d.ts +2 -0
  133. package/dist/compiler/output-targets/output-custom.d.ts +2 -0
  134. package/dist/compiler/output-targets/output-docs.d.ts +2 -0
  135. package/dist/compiler/output-targets/output-hydrate.d.ts +2 -0
  136. package/dist/compiler/output-targets/output-lazy-loader.d.ts +2 -0
  137. package/dist/compiler/output-targets/output-module.d.ts +4 -0
  138. package/dist/compiler/output-targets/output-prerender.d.ts +2 -0
  139. package/dist/compiler/output-targets/output-service-workers.d.ts +2 -0
  140. package/dist/compiler/output-targets/output-types.d.ts +2 -0
  141. package/dist/compiler/output-targets/output-utils.d.ts +54 -0
  142. package/dist/compiler/output-targets/output-www.d.ts +2 -0
  143. package/dist/compiler/plugin/plugin.d.ts +6 -0
  144. package/dist/compiler/polyfills.d.ts +0 -0
  145. package/dist/compiler/prerender/crawl-urls.d.ts +3 -0
  146. package/dist/compiler/prerender/host-config.d.ts +12 -0
  147. package/dist/compiler/prerender/prerender-config.d.ts +2 -0
  148. package/dist/compiler/prerender/prerender-main.d.ts +2 -0
  149. package/dist/compiler/prerender/prerender-queue.d.ts +3 -0
  150. package/dist/compiler/prerender/prerender-template-html.d.ts +2 -0
  151. package/dist/compiler/prerender/prerendered-write-path.d.ts +2 -0
  152. package/dist/compiler/prerender/robots-txt.d.ts +2 -0
  153. package/dist/compiler/prerender/sitemap-xml.d.ts +3 -0
  154. package/dist/compiler/rollup-plugins/component-entry.d.ts +3 -0
  155. package/dist/compiler/rollup-plugins/css-transformer.d.ts +3 -0
  156. package/dist/compiler/rollup-plugins/global-scripts.d.ts +4 -0
  157. package/dist/compiler/rollup-plugins/image-plugin.d.ts +3 -0
  158. package/dist/compiler/rollup-plugins/in-memory-fs-read.d.ts +3 -0
  159. package/dist/compiler/rollup-plugins/loader.d.ts +4 -0
  160. package/dist/compiler/rollup-plugins/plugin-helper.d.ts +5 -0
  161. package/dist/compiler/rollup-plugins/rindo-build-conditionals.d.ts +7 -0
  162. package/dist/compiler/rollup-plugins/rindo-client.d.ts +3 -0
  163. package/dist/compiler/rollup-plugins/rindo-external-runtime.d.ts +2 -0
  164. package/dist/compiler/rollup-plugins/rindo-hydrate.d.ts +3 -0
  165. package/dist/compiler/rollup-plugins/rindo-public-plugin.d.ts +2 -0
  166. package/dist/compiler/service-worker/generate-sw.d.ts +7 -0
  167. package/dist/compiler/service-worker/service-worker-util.d.ts +2 -0
  168. package/dist/compiler/style/cached-styles.d.ts +5 -0
  169. package/dist/compiler/style/component-styles.d.ts +2 -0
  170. package/dist/compiler/style/css-imports.d.ts +9 -0
  171. package/dist/compiler/style/css-to-esm.d.ts +5 -0
  172. package/dist/compiler/style/generate-styles.d.ts +2 -0
  173. package/dist/compiler/style/global-styles.d.ts +3 -0
  174. package/dist/compiler/style/normalize-styles.d.ts +2 -0
  175. package/dist/compiler/style/optimize-css.d.ts +2 -0
  176. package/dist/compiler/style/scope-css.d.ts +3 -0
  177. package/dist/compiler/style/style-utils.d.ts +10 -0
  178. package/dist/compiler/transformers/add-component-meta-proxy.d.ts +3 -0
  179. package/dist/compiler/transformers/add-component-meta-static.d.ts +4 -0
  180. package/dist/compiler/transformers/add-imports.d.ts +3 -0
  181. package/dist/compiler/transformers/collections/add-external-import.d.ts +2 -0
  182. package/dist/compiler/transformers/collections/parse-collection-components.d.ts +2 -0
  183. package/dist/compiler/transformers/collections/parse-collection-deprecated.d.ts +2 -0
  184. package/dist/compiler/transformers/collections/parse-collection-manifest.d.ts +7 -0
  185. package/dist/compiler/transformers/collections/parse-collection-module.d.ts +2 -0
  186. package/dist/compiler/transformers/component-build-conditionals.d.ts +2 -0
  187. package/dist/compiler/transformers/component-hydrate/hydrate-component.d.ts +3 -0
  188. package/dist/compiler/transformers/component-hydrate/hydrate-runtime-cmp-meta.d.ts +3 -0
  189. package/dist/compiler/transformers/component-hydrate/tranform-to-hydrate-component.d.ts +2 -0
  190. package/dist/compiler/transformers/component-lazy/lazy-component.d.ts +3 -0
  191. package/dist/compiler/transformers/component-lazy/lazy-constructor.d.ts +3 -0
  192. package/dist/compiler/transformers/component-lazy/lazy-element-getter.d.ts +3 -0
  193. package/dist/compiler/transformers/component-lazy/transform-lazy-component.d.ts +4 -0
  194. package/dist/compiler/transformers/component-native/native-component.d.ts +3 -0
  195. package/dist/compiler/transformers/component-native/native-connected-callback.d.ts +3 -0
  196. package/dist/compiler/transformers/component-native/native-constructor.d.ts +3 -0
  197. package/dist/compiler/transformers/component-native/native-element-getter.d.ts +3 -0
  198. package/dist/compiler/transformers/component-native/native-static-style.d.ts +3 -0
  199. package/dist/compiler/transformers/component-native/tranform-to-native-component.d.ts +4 -0
  200. package/dist/compiler/transformers/core-runtime-apis.d.ts +30 -0
  201. package/dist/compiler/transformers/create-event.d.ts +3 -0
  202. package/dist/compiler/transformers/decorators-to-static/component-decorator.d.ts +3 -0
  203. package/dist/compiler/transformers/decorators-to-static/convert-decorators.d.ts +3 -0
  204. package/dist/compiler/transformers/decorators-to-static/decorator-utils.d.ts +10 -0
  205. package/dist/compiler/transformers/decorators-to-static/element-decorator.d.ts +3 -0
  206. package/dist/compiler/transformers/decorators-to-static/event-decorator.d.ts +4 -0
  207. package/dist/compiler/transformers/decorators-to-static/listen-decorator.d.ts +6 -0
  208. package/dist/compiler/transformers/decorators-to-static/method-decorator.d.ts +3 -0
  209. package/dist/compiler/transformers/decorators-to-static/prop-decorator.d.ts +4 -0
  210. package/dist/compiler/transformers/decorators-to-static/state-decorator.d.ts +3 -0
  211. package/dist/compiler/transformers/decorators-to-static/style-to-static.d.ts +3 -0
  212. package/dist/compiler/transformers/decorators-to-static/watch-decorator.d.ts +3 -0
  213. package/dist/compiler/transformers/define-custom-element.d.ts +3 -0
  214. package/dist/compiler/transformers/host-data-transform.d.ts +3 -0
  215. package/dist/compiler/transformers/legacy-props.d.ts +3 -0
  216. package/dist/compiler/transformers/remove-static-meta-properties.d.ts +2 -0
  217. package/dist/compiler/transformers/reserved-public-members.d.ts +3 -0
  218. package/dist/compiler/transformers/rindo-import-path.d.ts +3 -0
  219. package/dist/compiler/transformers/static-to-meta/call-expression.d.ts +3 -0
  220. package/dist/compiler/transformers/static-to-meta/class-methods.d.ts +3 -0
  221. package/dist/compiler/transformers/static-to-meta/component.d.ts +3 -0
  222. package/dist/compiler/transformers/static-to-meta/element-ref.d.ts +2 -0
  223. package/dist/compiler/transformers/static-to-meta/encapsulation.d.ts +3 -0
  224. package/dist/compiler/transformers/static-to-meta/events.d.ts +3 -0
  225. package/dist/compiler/transformers/static-to-meta/import.d.ts +3 -0
  226. package/dist/compiler/transformers/static-to-meta/listeners.d.ts +3 -0
  227. package/dist/compiler/transformers/static-to-meta/methods.d.ts +3 -0
  228. package/dist/compiler/transformers/static-to-meta/props.d.ts +3 -0
  229. package/dist/compiler/transformers/static-to-meta/states.d.ts +3 -0
  230. package/dist/compiler/transformers/static-to-meta/string-literal.d.ts +3 -0
  231. package/dist/compiler/transformers/static-to-meta/styles.d.ts +3 -0
  232. package/dist/compiler/transformers/static-to-meta/vdom.d.ts +3 -0
  233. package/dist/compiler/transformers/static-to-meta/visitor.d.ts +3 -0
  234. package/dist/compiler/transformers/static-to-meta/watchers.d.ts +3 -0
  235. package/dist/compiler/transformers/style-imports.d.ts +3 -0
  236. package/dist/compiler/transformers/transform-utils.d.ts +31 -0
  237. package/dist/compiler/transformers/update-component-class.d.ts +3 -0
  238. package/dist/compiler/transformers/update-rindo-core-import.d.ts +3 -0
  239. package/dist/compiler/transformers/watcher-meta-transform.d.ts +3 -0
  240. package/dist/compiler/transpile/compiler-options.d.ts +4 -0
  241. package/dist/compiler/transpile/transpile-app.d.ts +2 -0
  242. package/dist/compiler/transpile/transpile-module.d.ts +5 -0
  243. package/dist/compiler/transpile/transpile-service.d.ts +3 -0
  244. package/dist/compiler/transpile/transpile-to-es5-main.d.ts +2 -0
  245. package/dist/compiler/transpile/validate-types-main.d.ts +2 -0
  246. package/dist/compiler/types/generate-app-types.d.ts +2 -0
  247. package/dist/compiler/types/generate-component-types.d.ts +8 -0
  248. package/dist/compiler/types/generate-event-types.d.ts +2 -0
  249. package/dist/compiler/types/generate-method-types.d.ts +2 -0
  250. package/dist/compiler/types/generate-prop-types.d.ts +2 -0
  251. package/dist/compiler/types/generate-types.d.ts +2 -0
  252. package/dist/compiler/types/rindo-types.d.ts +3 -0
  253. package/dist/compiler/types/types-utils.d.ts +4 -0
  254. package/dist/compiler/types/update-import-refs.d.ts +11 -0
  255. package/dist/compiler/types/validate-package-json.d.ts +9 -0
  256. package/dist/declarations/assets.d.ts +17 -0
  257. package/dist/declarations/browser-compile.d.ts +47 -0
  258. package/dist/declarations/build-conditionals.d.ts +91 -0
  259. package/dist/declarations/build-events.d.ts +19 -0
  260. package/dist/declarations/build.d.ts +247 -0
  261. package/dist/declarations/cache.d.ts +11 -0
  262. package/dist/declarations/collection-manifest.d.ts +106 -0
  263. package/dist/declarations/collection.d.ts +139 -0
  264. package/dist/declarations/compiler.d.ts +53 -0
  265. package/dist/declarations/component-compiler-meta.d.ts +198 -0
  266. package/dist/declarations/component-constructor.d.ts +61 -0
  267. package/dist/declarations/component-interfaces.d.ts +123 -0
  268. package/dist/declarations/config.d.ts +409 -0
  269. package/dist/declarations/css-var-shim.d.ts +9 -0
  270. package/dist/declarations/decorators.d.ts +150 -0
  271. package/dist/declarations/dev-server.d.ts +135 -0
  272. package/dist/declarations/diagnostics.d.ts +21 -0
  273. package/dist/declarations/docs.d.ts +101 -0
  274. package/dist/declarations/entry.d.ts +28 -0
  275. package/dist/declarations/events.d.ts +13 -0
  276. package/dist/declarations/file-system.d.ts +91 -0
  277. package/dist/declarations/fs-watch.d.ts +15 -0
  278. package/dist/declarations/host-element.d.ts +53 -0
  279. package/dist/declarations/hydrate.d.ts +99 -0
  280. package/dist/declarations/in-memory-fs.d.ts +59 -0
  281. package/dist/declarations/index.d.ts +45 -0
  282. package/dist/declarations/jsdoc.d.ts +16 -0
  283. package/dist/declarations/jsx.d.ts +1050 -0
  284. package/dist/declarations/logger.d.ts +25 -0
  285. package/dist/declarations/minify-js.d.ts +11 -0
  286. package/dist/declarations/module.d.ts +35 -0
  287. package/dist/declarations/optimize-css.d.ts +12 -0
  288. package/dist/declarations/output-targets.d.ts +189 -0
  289. package/dist/declarations/plugin.d.ts +23 -0
  290. package/dist/declarations/prerender.d.ts +79 -0
  291. package/dist/declarations/render.d.ts +62 -0
  292. package/dist/declarations/runtime.d.ts +92 -0
  293. package/dist/declarations/screenshots.d.ts +192 -0
  294. package/dist/declarations/server.d.ts +19 -0
  295. package/dist/declarations/style.d.ts +35 -0
  296. package/dist/declarations/system.d.ts +174 -0
  297. package/dist/declarations/testing.d.ts +523 -0
  298. package/dist/declarations/transpile.d.ts +24 -0
  299. package/dist/declarations/types.d.ts +24 -0
  300. package/dist/declarations/vdom.d.ts +55 -0
  301. package/dist/declarations/worker.d.ts +33 -0
  302. package/dist/dev-server/content-type-db.json +1 -0
  303. package/dist/dev-server/index.js +887 -0
  304. package/dist/dev-server/static/app-error.css +257 -0
  305. package/dist/dev-server/static/dev-server-client.html +13 -0
  306. package/dist/dev-server/static/favicon.ico +0 -0
  307. package/dist/dev-server/templates/directory-index.html +132 -0
  308. package/dist/dev-server/templates/initial-load.html +160 -0
  309. package/dist/hydrate/index.d.ts +101 -0
  310. package/dist/hydrate/index.mjs +1281 -0
  311. package/dist/hydrate/platform.mjs +347 -0
  312. package/dist/index.d.ts +99 -0
  313. package/dist/index.js +1 -0
  314. package/dist/mock-doc/index.d.ts +851 -0
  315. package/dist/mock-doc/index.js +3982 -0
  316. package/dist/mock-doc/index.mjs +3954 -0
  317. package/dist/runtime/index.js +2576 -0
  318. package/dist/runtime/index.mjs +2521 -0
  319. package/dist/runtime/shadow-css-6ef31c68.js +386 -0
  320. package/dist/runtime/shadow-css-8fd1a9e4.js +388 -0
  321. package/dist/screenshot/connector-base.d.ts +42 -0
  322. package/dist/screenshot/connector-local.d.ts +7 -0
  323. package/dist/screenshot/index.d.ts +3 -0
  324. package/dist/screenshot/index.js +520 -0
  325. package/dist/screenshot/pixel-match.d.ts +1 -0
  326. package/dist/screenshot/screenshot-fs.d.ts +15 -0
  327. package/dist/sys/node/graceful-fs.js +975 -0
  328. package/dist/sys/node/index.js +33545 -0
  329. package/dist/sys/node/node-fetch.js +1779 -0
  330. package/dist/sys/node/open-in-editor.js +734 -0
  331. package/dist/sys/node/sys-worker.js +67035 -0
  332. package/dist/sys/node/visualstudio.vbs +82 -0
  333. package/dist/sys/node/websocket.js +3728 -0
  334. package/dist/sys/node/xdg-open +1066 -0
  335. package/dist/testing/build-conditionals.d.ts +4 -0
  336. package/dist/testing/build-conditionals.js +43 -0
  337. package/dist/testing/core.d.ts +35 -0
  338. package/dist/testing/core.js +52 -0
  339. package/dist/testing/index.d.ts +13 -0
  340. package/dist/testing/index.js +40511 -0
  341. package/dist/testing/jest/jest-config.d.ts +4 -0
  342. package/dist/testing/jest/jest-environment.d.ts +12 -0
  343. package/dist/testing/jest/jest-preprocessor.d.ts +10 -0
  344. package/dist/testing/jest/jest-runner.d.ts +5 -0
  345. package/dist/testing/jest/jest-screenshot.d.ts +2 -0
  346. package/dist/testing/jest/jest-serializer.d.ts +5 -0
  347. package/dist/testing/jest/jest-setup-test-framework.d.ts +1 -0
  348. package/dist/testing/matchers/attributes.d.ts +14 -0
  349. package/dist/testing/matchers/class-list.d.ts +12 -0
  350. package/dist/testing/matchers/events.d.ts +13 -0
  351. package/dist/testing/matchers/html.d.ts +12 -0
  352. package/dist/testing/matchers/index.d.ts +21 -0
  353. package/dist/testing/matchers/screenshot.d.ts +5 -0
  354. package/dist/testing/matchers/text.d.ts +4 -0
  355. package/dist/testing/mock-fetch.d.ts +46 -0
  356. package/dist/testing/mocks.d.ts +12 -0
  357. package/dist/testing/platform.d.ts +23 -0
  358. package/dist/testing/platform.js +321 -0
  359. package/dist/testing/puppeteer/puppeteer-browser.d.ts +6 -0
  360. package/dist/testing/puppeteer/puppeteer-declarations.d.ts +396 -0
  361. package/dist/testing/puppeteer/puppeteer-element.d.ts +65 -0
  362. package/dist/testing/puppeteer/puppeteer-emulate.d.ts +2 -0
  363. package/dist/testing/puppeteer/puppeteer-events.d.ts +21 -0
  364. package/dist/testing/puppeteer/puppeteer-find.d.ts +5 -0
  365. package/dist/testing/puppeteer/puppeteer-page.d.ts +2 -0
  366. package/dist/testing/puppeteer/puppeteer-screenshot.d.ts +4 -0
  367. package/dist/testing/spec-page.d.ts +5 -0
  368. package/dist/testing/task-queue.d.ts +15 -0
  369. package/dist/testing/test-transpile.d.ts +5 -0
  370. package/dist/testing/testing-fs.d.ts +31 -0
  371. package/dist/testing/testing-logger.d.ts +23 -0
  372. package/dist/testing/testing-sys.d.ts +19 -0
  373. package/dist/testing/testing-utils.d.ts +5 -0
  374. package/dist/testing/testing.d.ts +12 -0
  375. package/dist/utils/index.js +1575 -0
  376. package/dist/utils/index.mjs +1511 -0
  377. package/internal/client/build-conditionals.mjs +82 -0
  378. package/internal/client/css-shim.rindo-client.mjs +656 -0
  379. package/internal/client/dom.rindo-client.mjs +137 -0
  380. package/internal/client/index.mjs +2859 -0
  381. package/internal/client/polyfills/core-js.js +10 -0
  382. package/internal/client/polyfills/css-shim.js +656 -0
  383. package/internal/client/polyfills/dom.js +146 -0
  384. package/internal/client/polyfills/es5-html-element.js +18 -0
  385. package/internal/client/polyfills/index.js +35 -0
  386. package/internal/client/polyfills/promise.js +9 -0
  387. package/internal/client/polyfills/system.js +6 -0
  388. package/internal/client/shadow-css.rindo-client.mjs +386 -0
  389. package/internal/images.d.ts +5 -0
  390. package/internal/index.d.ts +18 -0
  391. package/internal/index.js +1 -0
  392. package/internal/package.json +6 -0
  393. package/mock-doc/index.js +2 -0
  394. package/mock-doc/package.json +10 -0
  395. package/package.json +186 -0
  396. package/readme.md +174 -0
  397. package/runtime/package.json +5 -0
  398. package/screenshot/compare/assets/favicon.ico +0 -0
  399. package/screenshot/compare/assets/logo.png +0 -0
  400. package/screenshot/compare/build/app.css +1 -0
  401. package/screenshot/compare/build/app.esm.js +1 -0
  402. package/screenshot/compare/build/app.js +818 -0
  403. package/screenshot/compare/build/p-020f8d73.js +1 -0
  404. package/screenshot/compare/build/p-09qdknbg.system.entry.js +1 -0
  405. package/screenshot/compare/build/p-0a13mpsc.system.entry.js +1 -0
  406. package/screenshot/compare/build/p-113f7459.js +1 -0
  407. package/screenshot/compare/build/p-168ec2c4.system.js +1 -0
  408. package/screenshot/compare/build/p-2ab1fdf1.system.js +1 -0
  409. package/screenshot/compare/build/p-2pxcsgrj.entry.js +1 -0
  410. package/screenshot/compare/build/p-42fb7034.system.js +1 -0
  411. package/screenshot/compare/build/p-54d9d7c2.system.js +1 -0
  412. package/screenshot/compare/build/p-67c1f911.js +1 -0
  413. package/screenshot/compare/build/p-68613371.system.js +1 -0
  414. package/screenshot/compare/build/p-7dvsjpu0.entry.js +1 -0
  415. package/screenshot/compare/build/p-aa67fb06.js +1 -0
  416. package/screenshot/compare/build/p-aeb3cec1.system.js +1 -0
  417. package/screenshot/compare/build/p-b6e44a24.js +1 -0
  418. package/screenshot/compare/build/p-c1c25b8a.js +1 -0
  419. package/screenshot/compare/build/p-c9bopbjy.system.entry.js +1 -0
  420. package/screenshot/compare/build/p-c9iqz1pp.system.entry.js +1 -0
  421. package/screenshot/compare/build/p-dizjz8rg.entry.js +1 -0
  422. package/screenshot/compare/build/p-dnta0rwp.system.entry.js +1 -0
  423. package/screenshot/compare/build/p-e9670d22.system.js +1 -0
  424. package/screenshot/compare/build/p-efb0eac6.js +1 -0
  425. package/screenshot/compare/build/p-ei9jkpd0.system.entry.js +1 -0
  426. package/screenshot/compare/build/p-ejpsp3kx.js +1 -0
  427. package/screenshot/compare/build/p-ejwcppol.entry.js +1 -0
  428. package/screenshot/compare/build/p-f6612d5d.system.js +1 -0
  429. package/screenshot/compare/build/p-foiivsfc.css +1 -0
  430. package/screenshot/compare/build/p-gpjjyogx.entry.js +1 -0
  431. package/screenshot/compare/build/p-howklem2.system.entry.js +1 -0
  432. package/screenshot/compare/build/p-knv9wvoc.entry.js +1 -0
  433. package/screenshot/compare/build/p-nsqsfhhy.entry.js +1 -0
  434. package/screenshot/compare/build/p-ojt278pp.entry.js +1 -0
  435. package/screenshot/compare/build/p-oywass99.entry.js +1 -0
  436. package/screenshot/compare/build/p-q3ujhub6.entry.js +1 -0
  437. package/screenshot/compare/build/p-qw4xnmxv.entry.js +1 -0
  438. package/screenshot/compare/build/p-t1wvevhc.system.entry.js +1 -0
  439. package/screenshot/compare/build/p-tnjarrex.system.entry.js +1 -0
  440. package/screenshot/compare/build/p-vhfpd6kk.system.entry.js +1 -0
  441. package/screenshot/compare/build/p-vk6rhemd.system.entry.js +1 -0
  442. package/screenshot/compare/build/p-w6bnm16k.entry.js +1 -0
  443. package/screenshot/compare/build/p-xje6d7zl.system.entry.js +1 -0
  444. package/screenshot/compare/build/p-y5jlrcha.system.entry.js +1 -0
  445. package/screenshot/compare/build/p-yh170wkt.entry.js +1 -0
  446. package/screenshot/compare/host.config.json +15 -0
  447. package/screenshot/compare/index.html +1 -0
  448. package/screenshot/compare/manifest.json +13 -0
  449. package/screenshot/connector.js +3 -0
  450. package/screenshot/index.js +2 -0
  451. package/screenshot/local-connector.js +3 -0
  452. package/screenshot/package.json +13 -0
  453. package/screenshot/pixel-match.js +2660 -0
  454. package/sys/node/index.js +2 -0
  455. package/sys/node/package.json +5 -0
  456. package/testing/index.js +2 -0
  457. package/testing/jest-environment.js +3 -0
  458. package/testing/jest-preprocessor.js +3 -0
  459. package/testing/jest-preset.js +40 -0
  460. package/testing/jest-runner.js +3 -0
  461. package/testing/jest-setuptestframework.js +3 -0
  462. package/testing/jest.preprocessor.js +7 -0
  463. package/testing/package.json +6 -0
@@ -0,0 +1,2859 @@
1
+ import { BUILD, NAMESPACE } from '@rindo/core/internal/client/build-conditionals';
2
+
3
+ const win = typeof window !== 'undefined' ? window : {};
4
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
5
+ const doc = win.document || { head: {} };
6
+ const H = (win.HTMLElement || class {
7
+ });
8
+ const plt = {
9
+ $flags$: 0,
10
+ $resourcesUrl$: '',
11
+ jmp: (h) => h(),
12
+ raf: (h) => requestAnimationFrame(h),
13
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
14
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
15
+ };
16
+ const supportsShadowDom = BUILD.shadowDomShim ? (BUILD.shadowDom) ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)() : false : true;
17
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
18
+ let supportsListenerOptions = false;
19
+ try {
20
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
21
+ get() { supportsListenerOptions = true; }
22
+ }));
23
+ }
24
+ catch (e) { }
25
+ return supportsListenerOptions;
26
+ })();
27
+ const promiseResolve = (v) => Promise.resolve(v);
28
+ const supportsConstructibleStylesheets = BUILD.constructableCSS ? /*@__PURE__*/ (() => {
29
+ try {
30
+ new CSSStyleSheet();
31
+ return true;
32
+ }
33
+ catch (e) { }
34
+ return false;
35
+ })() : false;
36
+
37
+ const Context = {};
38
+
39
+ const hostRefs = new WeakMap();
40
+ const getHostRef = (ref) => hostRefs.get(ref);
41
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
42
+ const registerHost = (elm) => {
43
+ const hostRef = {
44
+ $flags$: 0,
45
+ $hostElement$: elm,
46
+ $instanceValues$: new Map()
47
+ };
48
+ if (BUILD.isDev) {
49
+ hostRef.$renderCount$ = 0;
50
+ }
51
+ if (BUILD.method && BUILD.lazyLoad) {
52
+ hostRef.$onInstancePromise$ = new Promise(r => hostRef.$onInstanceResolve$ = r);
53
+ }
54
+ if (BUILD.asyncLoading) {
55
+ hostRef.$onReadyPromise$ = new Promise(r => hostRef.$onReadyResolve$ = r);
56
+ elm['s-p'] = [];
57
+ elm['s-rc'] = [];
58
+ }
59
+ return hostRefs.set(elm, hostRef);
60
+ };
61
+ const isMemberInElement = (elm, memberName) => memberName in elm;
62
+
63
+ const RINDO_DEV_MODE = ['%c[RINDO-DEV-MODE]', 'color:#4c47ff;font-weight: bold'];
64
+ const consoleDevError = (...m) => console.error(...RINDO_DEV_MODE, ...m);
65
+ const consoleDevWarn = (...m) => console.warn(...RINDO_DEV_MODE, ...m);
66
+ const consoleDevInfo = (...m) => console.info(...RINDO_DEV_MODE, ...m);
67
+ const consoleError = (e) => console.error(e);
68
+
69
+ const moduleCache = /*@__PURE__*/ new Map();
70
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
71
+ // loadModuleImport
72
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
73
+ const bundleId = ((BUILD.mode && typeof cmpMeta.$lazyBundleIds$ !== 'string')
74
+ ? cmpMeta.$lazyBundleIds$[hostRef.$modeName$]
75
+ : cmpMeta.$lazyBundleIds$);
76
+ const module = !BUILD.hotModuleReplacement ? moduleCache.get(bundleId) : false;
77
+ if (module) {
78
+ return module[exportName];
79
+ }
80
+ return import(
81
+ /* webpackInclude: /\.entry\.js$/ */
82
+ /* webpackExclude: /\.system\.entry\.js$/ */
83
+ /* webpackMode: "lazy" */
84
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`).then(importedModule => {
85
+ if (!BUILD.hotModuleReplacement) {
86
+ moduleCache.set(bundleId, importedModule);
87
+ }
88
+ return importedModule[exportName];
89
+ }, consoleError);
90
+ };
91
+
92
+ const styles = new Map();
93
+
94
+ let queueCongestion = 0;
95
+ let queuePending = false;
96
+ const queueDomReads = [];
97
+ const queueDomWrites = [];
98
+ const queueDomWritesLow = [];
99
+ const queueTask = (queue, write) => (cb) => {
100
+ queue.push(cb);
101
+ if (!queuePending) {
102
+ queuePending = true;
103
+ if (write && plt.$flags$ & 4 /* queueSync */) {
104
+ nextTick(flush);
105
+ }
106
+ else {
107
+ plt.raf(flush);
108
+ }
109
+ }
110
+ };
111
+ const consume = (queue) => {
112
+ for (let i = 0; i < queue.length; i++) {
113
+ try {
114
+ queue[i](performance.now());
115
+ }
116
+ catch (e) {
117
+ consoleError(e);
118
+ }
119
+ }
120
+ queue.length = 0;
121
+ };
122
+ const consumeTimeout = (queue, timeout) => {
123
+ let i = 0;
124
+ let ts = 0;
125
+ while (i < queue.length && (ts = performance.now()) < timeout) {
126
+ try {
127
+ queue[i++](ts);
128
+ }
129
+ catch (e) {
130
+ consoleError(e);
131
+ }
132
+ }
133
+ if (i === queue.length) {
134
+ queue.length = 0;
135
+ }
136
+ else if (i !== 0) {
137
+ queue.splice(0, i);
138
+ }
139
+ };
140
+ const flush = () => {
141
+ queueCongestion++;
142
+ // always force a bunch of medium callbacks to run, but still have
143
+ // a throttle on how many can run in a certain time
144
+ // DOM READS!!!
145
+ consume(queueDomReads);
146
+ const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
147
+ ? performance.now() + (10 * Math.ceil(queueCongestion * (1.0 / 22.0)))
148
+ : Infinity;
149
+ // DOM WRITES!!!
150
+ consumeTimeout(queueDomWrites, timeout);
151
+ consumeTimeout(queueDomWritesLow, timeout);
152
+ if (queueDomWrites.length > 0) {
153
+ queueDomWritesLow.push(...queueDomWrites);
154
+ queueDomWrites.length = 0;
155
+ }
156
+ if (queuePending = ((queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length) > 0)) {
157
+ // still more to do yet, but we've run out of time
158
+ // let's let this thing cool off and try again in the next tick
159
+ plt.raf(flush);
160
+ }
161
+ else {
162
+ queueCongestion = 0;
163
+ }
164
+ };
165
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
166
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
167
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
168
+
169
+ const Build = {
170
+ isDev: BUILD.isDev ? true : false,
171
+ isBrowser: true
172
+ };
173
+
174
+ /**
175
+ * Default style mode id
176
+ */
177
+ /**
178
+ * Reusable empty obj/array
179
+ * Don't add values to these!!
180
+ */
181
+ const EMPTY_OBJ = {};
182
+ /**
183
+ * Namespaces
184
+ */
185
+ const SVG_NS = 'http://www.w3.org/2000/svg';
186
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
187
+
188
+ const isDef = (v) => v != null;
189
+ const isComplexType = (o) => {
190
+ // https://jsperf.com/typeof-fn-object/5
191
+ o = typeof o;
192
+ return o === 'object' || o === 'function';
193
+ };
194
+
195
+ const getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
196
+
197
+ const patchEsm = () => {
198
+ // @ts-ignore
199
+ if (BUILD.cssVarShim && !(CSS && CSS.supports && CSS.supports('color', 'var(--c)'))) {
200
+ // @ts-ignore
201
+ return import(/* webpackChunkName: "rindo-polyfills-css-shim" */ './css-shim.rindo-client.mjs').then(() => {
202
+ if (plt.$cssShim$ = win.__cssshim) {
203
+ return plt.$cssShim$.i();
204
+ }
205
+ else {
206
+ // for better minification
207
+ return 0;
208
+ }
209
+ });
210
+ }
211
+ return promiseResolve();
212
+ };
213
+ const patchBrowser = () => {
214
+ // NOTE!! This fn cannot use async/await!
215
+ if (BUILD.isDev) {
216
+ consoleDevInfo('Rindo is running in the development mode.');
217
+ }
218
+ if (BUILD.cssVarShim) {
219
+ // shim css vars
220
+ plt.$cssShim$ = win.__cssshim;
221
+ }
222
+ if (BUILD.cloneNodeFix) {
223
+ // opted-in to polyfill cloneNode() for slot polyfilled components
224
+ patchCloneNodeFix(H.prototype);
225
+ }
226
+ if (BUILD.profile && !performance.mark) {
227
+ // not all browsers support performance.mark/measure (Safari 10)
228
+ performance.mark = performance.measure = () => { };
229
+ performance.getEntriesByName = () => [];
230
+ }
231
+ // @ts-ignore
232
+ const scriptElm = (BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim) ?
233
+ Array.from(doc.querySelectorAll('script')).find(s => (new RegExp(`\/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) ||
234
+ s.getAttribute('data-rindo-namespace') === NAMESPACE)) : null;
235
+ const importMeta = import.meta.url;
236
+ const opts = BUILD.scriptDataOpts ? scriptElm['data-opts'] || {} : {};
237
+ if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {
238
+ // Safari < v11 support: This IF is true if it's Safari below v11.
239
+ // This fn cannot use async/await since Safari didn't support it until v11,
240
+ // however, Safari 10 did support modules. Safari 10 also didn't support "nomodule",
241
+ // so both the ESM file and nomodule file would get downloaded. Only Safari
242
+ // has 'onbeforeload' in the script, and "history.scrollRestoration" was added
243
+ // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.
244
+ // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.
245
+ return { then() { } };
246
+ }
247
+ if (!BUILD.safari10 && importMeta !== '') {
248
+ opts.resourcesUrl = new URL('.', importMeta).href;
249
+ }
250
+ else if (BUILD.dynamicImportShim || BUILD.safari10) {
251
+ opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;
252
+ patchDynamicImport(opts.resourcesUrl, scriptElm);
253
+ if (BUILD.dynamicImportShim && !win.customElements) {
254
+ // module support, but no custom elements support (Old Edge)
255
+ // @ts-ignore
256
+ return import(/* webpackChunkName: "rindo-polyfills-dom" */ './dom.rindo-client.mjs').then(() => opts);
257
+ }
258
+ }
259
+ return promiseResolve(opts);
260
+ };
261
+ const patchDynamicImport = (base, orgScriptElm) => {
262
+ const importFunctionName = getDynamicImportFunction(NAMESPACE);
263
+ try {
264
+ // test if this browser supports dynamic imports
265
+ // There is a caching issue in V8, that breaks using import() in Function
266
+ // By generating a random string, we can workaround it
267
+ // Check https://bugs.chromium.org/p/v8/issues/detail?id=9558 for more info
268
+ win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);
269
+ }
270
+ catch (e) {
271
+ // this shim is specifically for browsers that do support "esm" imports
272
+ // however, they do NOT support "dynamic" imports
273
+ // basically this code is for old Edge, v18 and below
274
+ const moduleMap = new Map();
275
+ win[importFunctionName] = (src) => {
276
+ const url = new URL(src, base).href;
277
+ let mod = moduleMap.get(url);
278
+ if (!mod) {
279
+ const script = doc.createElement('script');
280
+ script.type = 'module';
281
+ script.crossOrigin = orgScriptElm.crossOrigin;
282
+ script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], { type: 'application/javascript' }));
283
+ mod = new Promise(resolve => {
284
+ script.onload = () => {
285
+ resolve(win[importFunctionName].m);
286
+ script.remove();
287
+ };
288
+ });
289
+ moduleMap.set(url, mod);
290
+ doc.head.appendChild(script);
291
+ }
292
+ return mod;
293
+ };
294
+ }
295
+ };
296
+ const patchCloneNodeFix = (HTMLElementPrototype) => {
297
+ const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;
298
+ HTMLElementPrototype.cloneNode = function (deep) {
299
+ if (this.nodeName === 'TEMPLATE') {
300
+ return nativeCloneNodeFn.call(this, deep);
301
+ }
302
+ const clonedNode = nativeCloneNodeFn.call(this, false);
303
+ const srcChildNodes = this.childNodes;
304
+ if (deep) {
305
+ for (let i = 0; i < srcChildNodes.length; i++) {
306
+ // Node.ATTRIBUTE_NODE === 2, and checking because IE11
307
+ if (srcChildNodes[i].nodeType !== 2) {
308
+ clonedNode.appendChild(srcChildNodes[i].cloneNode(true));
309
+ }
310
+ }
311
+ }
312
+ return clonedNode;
313
+ };
314
+ };
315
+
316
+ const CONTENT_REF_ID = 'r';
317
+ const ORG_LOCATION_ID = 'o';
318
+ const SLOT_NODE_ID = 's';
319
+ const TEXT_NODE_ID = 't';
320
+ const HYDRATE_ID = 's-id';
321
+ const HYDRATED_STYLE_ID = 'sty-id';
322
+ const HYDRATE_CHILD_ID = 'c-id';
323
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
324
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
325
+
326
+ let i = 0;
327
+ const createTime = (fnName, tagName = '') => {
328
+ if (BUILD.profile) {
329
+ const key = `st:${fnName}:${tagName}:${i++}`;
330
+ // Start
331
+ performance.mark(key);
332
+ // End
333
+ return () => performance.measure(`[Rindo] ${fnName}() <${tagName}>`, key);
334
+ }
335
+ else {
336
+ return () => { return; };
337
+ }
338
+ };
339
+ const uniqueTime = (key, measureText) => {
340
+ if (BUILD.profile) {
341
+ if (performance.getEntriesByName(key).length === 0) {
342
+ performance.mark(key);
343
+ }
344
+ return () => {
345
+ if (performance.getEntriesByName(measureText).length === 0) {
346
+ performance.measure(measureText, key);
347
+ }
348
+ };
349
+ }
350
+ else {
351
+ return () => { return; };
352
+ }
353
+ };
354
+ const inspect = (ref) => {
355
+ const hostRef = getHostRef(ref);
356
+ if (!hostRef) {
357
+ return undefined;
358
+ }
359
+ const flags = hostRef.$flags$;
360
+ const hostElement = hostRef.$hostElement$;
361
+ return {
362
+ renderCount: hostRef.$renderCount$,
363
+ flags: {
364
+ hasRendered: !!(flags & 2 /* hasRendered */),
365
+ hasConnected: !!(flags & 1 /* hasConnected */),
366
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
367
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
368
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
369
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
370
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
371
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
372
+ isListenReady: !!(flags & 256 /* isListenReady */),
373
+ needsRerender: !!(flags & 512 /* needsRerender */),
374
+ },
375
+ instanceValues: hostRef.$instanceValues$,
376
+ ancestorComponent: hostRef.$ancestorComponent$,
377
+ hostElement,
378
+ lazyInstance: hostRef.$lazyInstance$,
379
+ vnode: hostRef.$vnode$,
380
+ modeName: hostRef.$modeName$,
381
+ onReadyPromise: hostRef.$onReadyPromise$,
382
+ onReadyResolve: hostRef.$onReadyResolve$,
383
+ onInstancePromise: hostRef.$onInstancePromise$,
384
+ onInstanceResolve: hostRef.$onInstanceResolve$,
385
+ onRenderResolve: hostRef.$onRenderResolve$,
386
+ queuedListeners: hostRef.$queuedListeners$,
387
+ rmListeners: hostRef.$rmListeners$,
388
+ ['s-id']: hostElement['s-id'],
389
+ ['s-cr']: hostElement['s-cr'],
390
+ ['s-lr']: hostElement['s-lr'],
391
+ ['s-p']: hostElement['s-p'],
392
+ ['s-rc']: hostElement['s-rc'],
393
+ ['s-sc']: hostElement['s-sc'],
394
+ };
395
+ };
396
+ const installDevTools = () => {
397
+ if (BUILD.devTools) {
398
+ const rindo = win.rindo = win.rindo || {};
399
+ const originalInspect = rindo.inspect;
400
+ rindo.inspect = (ref) => {
401
+ let result = inspect(ref);
402
+ if (!result && typeof originalInspect === 'function') {
403
+ result = originalInspect(ref);
404
+ }
405
+ return result;
406
+ };
407
+ }
408
+ };
409
+
410
+ const rootAppliedStyles = new WeakMap();
411
+ const registerStyle = (scopeId, cssText, allowCS) => {
412
+ let style = styles.get(scopeId);
413
+ if (supportsConstructibleStylesheets && allowCS) {
414
+ style = (style || new CSSStyleSheet());
415
+ style.replace(cssText);
416
+ }
417
+ else {
418
+ style = cssText;
419
+ }
420
+ styles.set(scopeId, style);
421
+ };
422
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
423
+ let scopeId = BUILD.mode ? getScopeId(cmpMeta.$tagName$, mode) : getScopeId(cmpMeta.$tagName$);
424
+ let style = styles.get(scopeId);
425
+ // if an element is NOT connected then getRootNode() will return the wrong root node
426
+ // so the fallback is to always use the document for the root node in those cases
427
+ styleContainerNode = (styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc);
428
+ if (BUILD.mode && !style) {
429
+ scopeId = getScopeId(cmpMeta.$tagName$);
430
+ style = styles.get(scopeId);
431
+ }
432
+ if (style) {
433
+ if (typeof style === 'string') {
434
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
435
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
436
+ let styleElm;
437
+ if (!appliedStyles) {
438
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = new Set());
439
+ }
440
+ if (!appliedStyles.has(scopeId)) {
441
+ if (BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
442
+ // This is only happening on native shadow-dom, do not needs CSS var shim
443
+ styleElm.innerHTML = style;
444
+ }
445
+ else {
446
+ if (BUILD.cssVarShim && plt.$cssShim$) {
447
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
448
+ const newScopeId = styleElm['s-sc'];
449
+ if (newScopeId) {
450
+ scopeId = newScopeId;
451
+ // we don't want to add this styleID to the appliedStyles Set
452
+ // since the cssVarShim might need to apply several different
453
+ // stylesheets for the same component
454
+ appliedStyles = null;
455
+ }
456
+ }
457
+ else {
458
+ styleElm = doc.createElement('style');
459
+ styleElm.innerHTML = style;
460
+ }
461
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
462
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
463
+ }
464
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
465
+ }
466
+ if (appliedStyles) {
467
+ appliedStyles.add(scopeId);
468
+ }
469
+ }
470
+ }
471
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
472
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
473
+ }
474
+ }
475
+ return scopeId;
476
+ };
477
+ const attachStyles = (elm, cmpMeta, mode) => {
478
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
479
+ const scopeId = addStyle((BUILD.shadowDom && supportsShadowDom && elm.shadowRoot)
480
+ ? elm.shadowRoot
481
+ : elm.getRootNode(), cmpMeta, mode, elm);
482
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */) {
483
+ // only required when we're NOT using native shadow dom (slot)
484
+ // or this browser doesn't support native shadow dom
485
+ // and this host element was NOT created with SSR
486
+ // let's pick out the inner content for slot projection
487
+ // create a node to represent where the original
488
+ // content was first placed, which is useful later on
489
+ // DOM WRITE!!
490
+ elm['s-sc'] = scopeId;
491
+ elm.classList.add(scopeId + '-h');
492
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
493
+ elm.classList.add(scopeId + '-s');
494
+ }
495
+ }
496
+ endAttachStyles();
497
+ };
498
+ const getScopeId = (tagName, mode) => 'sc-' + ((BUILD.mode && mode) ? tagName + '-' + mode : tagName);
499
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
500
+
501
+ /**
502
+ * Production h() function based on Preact by
503
+ * Jason Miller (@developit)
504
+ * Licensed under the MIT License
505
+ * https://github.com/developit/preact/blob/master/LICENSE
506
+ *
507
+ * Modified for Rindo's compiler and vdom
508
+ */
509
+ // const stack: any[] = [];
510
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
511
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
512
+ const h = (nodeName, vnodeData, ...children) => {
513
+ let child = null;
514
+ let key = null;
515
+ let slotName = null;
516
+ let simple = false;
517
+ let lastSimple = false;
518
+ let vNodeChildren = [];
519
+ const walk = (c) => {
520
+ for (let i = 0; i < c.length; i++) {
521
+ child = c[i];
522
+ if (Array.isArray(child)) {
523
+ walk(child);
524
+ }
525
+ else if (child != null && typeof child !== 'boolean') {
526
+ if (simple = typeof nodeName !== 'function' && !isComplexType(child)) {
527
+ child = String(child);
528
+ }
529
+ else if (BUILD.isDev && child.$flags$ === undefined) {
530
+ consoleDevError(`vNode passed as children has unexpected type.
531
+ Make sure it's using the correct h() function.
532
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
533
+ }
534
+ if (simple && lastSimple) {
535
+ // If the previous child was simple (string), we merge both
536
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
537
+ }
538
+ else {
539
+ // Append a new vNode, if it's text, we create a text vNode
540
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
541
+ }
542
+ lastSimple = simple;
543
+ }
544
+ }
545
+ };
546
+ walk(children);
547
+ if (vnodeData) {
548
+ if (BUILD.isDev && nodeName === 'input') {
549
+ validateInputProperties(vnodeData);
550
+ }
551
+ // normalize class / classname attributes
552
+ if (BUILD.vdomKey && vnodeData.key) {
553
+ key = vnodeData.key;
554
+ }
555
+ if (BUILD.slotRelocation && vnodeData.name) {
556
+ slotName = vnodeData.name;
557
+ }
558
+ if (BUILD.vdomClass) {
559
+ const classData = vnodeData.className || vnodeData.class;
560
+ if (classData) {
561
+ vnodeData.class = typeof classData !== 'object'
562
+ ? classData
563
+ : Object.keys(classData)
564
+ .filter(k => classData[k])
565
+ .join(' ');
566
+ }
567
+ }
568
+ }
569
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
570
+ consoleDevError(`The <Host> must be the single root component. Make sure:
571
+ - You are NOT using hostData() and <Host> in the same component.
572
+ - <Host> is used once, and it's the single root component of the render() function.`);
573
+ }
574
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
575
+ // nodeName is a functional component
576
+ return nodeName(vnodeData, vNodeChildren, vdomFnUtils);
577
+ }
578
+ const vnode = newVNode(nodeName, null);
579
+ vnode.$attrs$ = vnodeData;
580
+ if (vNodeChildren.length > 0) {
581
+ vnode.$children$ = vNodeChildren;
582
+ }
583
+ if (BUILD.vdomKey) {
584
+ vnode.$key$ = key;
585
+ }
586
+ if (BUILD.slotRelocation) {
587
+ vnode.$name$ = slotName;
588
+ }
589
+ return vnode;
590
+ };
591
+ const newVNode = (tag, text) => {
592
+ const vnode = {
593
+ $flags$: 0,
594
+ $tag$: tag,
595
+ $text$: text,
596
+ $elm$: null,
597
+ $children$: null
598
+ };
599
+ if (BUILD.vdomAttribute) {
600
+ vnode.$attrs$ = null;
601
+ }
602
+ if (BUILD.vdomKey) {
603
+ vnode.$key$ = null;
604
+ }
605
+ if (BUILD.slotRelocation) {
606
+ vnode.$name$ = null;
607
+ }
608
+ return vnode;
609
+ };
610
+ const Host = {};
611
+ const isHost = (node) => node && node.$tag$ === Host;
612
+ const vdomFnUtils = {
613
+ 'forEach': (children, cb) => children.map(convertToPublic).forEach(cb),
614
+ 'map': (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
615
+ };
616
+ const convertToPublic = (node) => {
617
+ return {
618
+ vattrs: node.$attrs$,
619
+ vchildren: node.$children$,
620
+ vkey: node.$key$,
621
+ vname: node.$name$,
622
+ vtag: node.$tag$,
623
+ vtext: node.$text$
624
+ };
625
+ };
626
+ const convertToPrivate = (node) => {
627
+ const vnode = newVNode(node.vtag, node.vtext);
628
+ vnode.$attrs$ = node.vattrs;
629
+ vnode.$children$ = node.vchildren;
630
+ vnode.$key$ = node.vkey;
631
+ vnode.$name$ = node.vname;
632
+ return vnode;
633
+ };
634
+ const validateInputProperties = (vnodeData) => {
635
+ const props = Object.keys(vnodeData);
636
+ const typeIndex = props.indexOf('type');
637
+ const minIndex = props.indexOf('min');
638
+ const maxIndex = props.indexOf('max');
639
+ const stepIndex = props.indexOf('min');
640
+ const value = props.indexOf('value');
641
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
642
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
643
+ }
644
+ };
645
+
646
+ /**
647
+ * Production setAccessor() function based on Preact by
648
+ * Jason Miller (@developit)
649
+ * Licensed under the MIT License
650
+ * https://github.com/developit/preact/blob/master/LICENSE
651
+ *
652
+ * Modified for Rindo's compiler and vdom
653
+ */
654
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
655
+ if (oldValue !== newValue) {
656
+ let isProp = isMemberInElement(elm, memberName);
657
+ let ln = memberName.toLowerCase();
658
+ if (BUILD.vdomClass && memberName === 'class') {
659
+ const classList = elm.classList;
660
+ const oldClasses = parseClassList(oldValue);
661
+ const newClasses = parseClassList(newValue);
662
+ classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
663
+ classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
664
+ }
665
+ else if (BUILD.vdomStyle && memberName === 'style') {
666
+ // update style attribute, css properties and values
667
+ if (BUILD.updatable) {
668
+ for (const prop in oldValue) {
669
+ if (!newValue || newValue[prop] == null) {
670
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
671
+ elm.style.removeProperty(prop);
672
+ }
673
+ else {
674
+ elm.style[prop] = '';
675
+ }
676
+ }
677
+ }
678
+ }
679
+ for (const prop in newValue) {
680
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
681
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
682
+ elm.style.setProperty(prop, newValue[prop]);
683
+ }
684
+ else {
685
+ elm.style[prop] = newValue[prop];
686
+ }
687
+ }
688
+ }
689
+ }
690
+ else if (BUILD.vdomKey && memberName === 'key') ;
691
+ else if (BUILD.vdomRef && memberName === 'ref') {
692
+ // minifier will clean this up
693
+ if (newValue) {
694
+ newValue(elm);
695
+ }
696
+ }
697
+ else if (BUILD.vdomListener &&
698
+ (BUILD.lazyLoad
699
+ ? !isProp
700
+ : !elm.__lookupSetter__(memberName)) &&
701
+ memberName[0] === 'o' && memberName[1] === 'n') {
702
+ // Event Handlers
703
+ // so if the member name starts with "on" and the 3rd characters is
704
+ // a capital letter, and it's not already a member on the element,
705
+ // then we're assuming it's an event listener
706
+ if (memberName[2] === '-') {
707
+ // on- prefixed events
708
+ // allows to be explicit about the dom event to listen without any magic
709
+ // under the hood:
710
+ // <my-cmp on-click> // listens for "click"
711
+ // <my-cmp on-Click> // listens for "Click"
712
+ // <my-cmp on-ionChange> // listens for "ionChange"
713
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
714
+ memberName = memberName.slice(3);
715
+ }
716
+ else if (isMemberInElement(win, ln)) {
717
+ // standard event
718
+ // the JSX attribute could have been "onMouseOver" and the
719
+ // member name "onmouseover" is on the window's prototype
720
+ // so let's add the listener "mouseover", which is all lowercased
721
+ memberName = ln.slice(2);
722
+ }
723
+ else {
724
+ // custom event
725
+ // the JSX attribute could have been "onMyCustomEvent"
726
+ // so let's trim off the "on" prefix and lowercase the first character
727
+ // and add the listener "myCustomEvent"
728
+ // except for the first character, we keep the event name case
729
+ memberName = ln[2] + memberName.slice(3);
730
+ }
731
+ if (oldValue) {
732
+ plt.rel(elm, memberName, oldValue, false);
733
+ }
734
+ if (newValue) {
735
+ plt.ael(elm, memberName, newValue, false);
736
+ }
737
+ }
738
+ else if (BUILD.vdomPropOrAttr) {
739
+ // Set property if it exists and it's not a SVG
740
+ const isComplex = isComplexType(newValue);
741
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
742
+ try {
743
+ if (!elm.tagName.includes('-')) {
744
+ let n = newValue == null ? '' : newValue;
745
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
746
+ if (memberName === 'list') {
747
+ isProp = false;
748
+ // tslint:disable-next-line: triple-equals
749
+ }
750
+ else if (oldValue == null || elm[memberName] != n) {
751
+ elm[memberName] = n;
752
+ }
753
+ }
754
+ else {
755
+ elm[memberName] = newValue;
756
+ }
757
+ }
758
+ catch (e) { }
759
+ }
760
+ /**
761
+ * Need to manually update attribute if:
762
+ * - memberName is not an attribute
763
+ * - if we are rendering the host element in order to reflect attribute
764
+ * - if it's a SVG, since properties might not work in <svg>
765
+ * - if the newValue is null/undefined or 'false'.
766
+ */
767
+ let xlink = false;
768
+ if (BUILD.vdomXlink) {
769
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
770
+ memberName = ln;
771
+ xlink = true;
772
+ }
773
+ }
774
+ if (newValue == null || newValue === false) {
775
+ if (BUILD.vdomXlink && xlink) {
776
+ elm.removeAttributeNS(XLINK_NS, memberName);
777
+ }
778
+ else {
779
+ elm.removeAttribute(memberName);
780
+ }
781
+ }
782
+ else if ((!isProp || (flags & 4 /* isHost */) || isSvg) && !isComplex) {
783
+ newValue = newValue === true ? '' : newValue;
784
+ if (BUILD.vdomXlink && xlink) {
785
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
786
+ }
787
+ else {
788
+ elm.setAttribute(memberName, newValue);
789
+ }
790
+ }
791
+ }
792
+ }
793
+ };
794
+ const parseClassListRegex = /\s/;
795
+ const parseClassList = (value) => (!value) ? [] : value.split(parseClassListRegex);
796
+
797
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
798
+ // if the element passed in is a shadow root, which is a document fragment
799
+ // then we want to be adding attrs/props to the shadow root's "host" element
800
+ // if it's not a shadow root, then we add attrs/props to the same element
801
+ const elm = (newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host) ? newVnode.$elm$.host : newVnode.$elm$;
802
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
803
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
804
+ if (BUILD.updatable) {
805
+ // remove attributes no longer present on the vnode by setting them to undefined
806
+ for (memberName in oldVnodeAttrs) {
807
+ if (!(memberName in newVnodeAttrs)) {
808
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
809
+ }
810
+ }
811
+ }
812
+ // add new & update changed attributes
813
+ for (memberName in newVnodeAttrs) {
814
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
815
+ }
816
+ };
817
+
818
+ let scopeId;
819
+ let contentRef;
820
+ let hostTagName;
821
+ let useNativeShadowDom = false;
822
+ let checkSlotFallbackVisibility = false;
823
+ let checkSlotRelocate = false;
824
+ let isSvgMode = false;
825
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
826
+ // tslint:disable-next-line: prefer-const
827
+ let newVNode = newParentVNode.$children$[childIndex];
828
+ let i = 0;
829
+ let elm;
830
+ let childNode;
831
+ let oldVNode;
832
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
833
+ // remember for later we need to check to relocate nodes
834
+ checkSlotRelocate = true;
835
+ if (newVNode.$tag$ === 'slot') {
836
+ if (scopeId) {
837
+ // scoped css needs to add its scoped id to the parent element
838
+ parentElm.classList.add(scopeId + '-s');
839
+ }
840
+ newVNode.$flags$ |= (newVNode.$children$)
841
+ // slot element has fallback content
842
+ // still create an element that "mocks" the slot element
843
+ ? 2 /* isSlotFallback */
844
+ // slot element does not have fallback content
845
+ // create an html comment we'll use to always reference
846
+ // where actual slot content should sit next to
847
+ : 1 /* isSlotReference */;
848
+ }
849
+ }
850
+ if (BUILD.isDev && newVNode.$elm$) {
851
+ consoleError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://rindojs.web.app/docs/templating-jsx#avoid-shared-jsx-nodes`);
852
+ }
853
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
854
+ // create text node
855
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
856
+ }
857
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* isSlotReference */) {
858
+ // create a slot reference node
859
+ elm = newVNode.$elm$ = (BUILD.isDebug || BUILD.hydrateServerSide) ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
860
+ }
861
+ else {
862
+ if (BUILD.svg && !isSvgMode) {
863
+ isSvgMode = newVNode.$tag$ === 'svg';
864
+ }
865
+ // create element
866
+ elm = newVNode.$elm$ = ((BUILD.svg)
867
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, (BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */) ? 'slot-fb' : newVNode.$tag$)
868
+ : doc.createElement((BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */) ? 'slot-fb' : newVNode.$tag$));
869
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
870
+ isSvgMode = false;
871
+ }
872
+ // add css classes, attrs, props, listeners, etc.
873
+ if (BUILD.vdomAttribute) {
874
+ updateElement(null, newVNode, isSvgMode);
875
+ }
876
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
877
+ // if there is a scopeId and this is the initial render
878
+ // then let's add the scopeId as a css class
879
+ elm.classList.add((elm['s-si'] = scopeId));
880
+ }
881
+ if (newVNode.$children$) {
882
+ for (i = 0; i < newVNode.$children$.length; ++i) {
883
+ // create the node
884
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
885
+ // return node could have been null
886
+ if (childNode) {
887
+ // append our new node
888
+ elm.appendChild(childNode);
889
+ }
890
+ }
891
+ }
892
+ if (BUILD.svg) {
893
+ if (newVNode.$tag$ === 'svg') {
894
+ // Only reset the SVG context when we're exiting <svg> element
895
+ isSvgMode = false;
896
+ }
897
+ else if (elm.tagName === 'foreignObject') {
898
+ // Reenter SVG context when we're exiting <foreignObject> element
899
+ isSvgMode = true;
900
+ }
901
+ }
902
+ }
903
+ if (BUILD.slotRelocation) {
904
+ elm['s-hn'] = hostTagName;
905
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
906
+ // remember the content reference comment
907
+ elm['s-sr'] = true;
908
+ // remember the content reference comment
909
+ elm['s-cr'] = contentRef;
910
+ // remember the slot name, or empty string for default slot
911
+ elm['s-sn'] = newVNode.$name$ || '';
912
+ // check if we've got an old vnode for this slot
913
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
914
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
915
+ // we've got an old slot vnode and the wrapper is being replaced
916
+ // so let's move the old slot content back to it's original location
917
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
918
+ }
919
+ }
920
+ }
921
+ return elm;
922
+ };
923
+ const putBackInOriginalLocation = (parentElm, recursive) => {
924
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
925
+ const oldSlotChildNodes = parentElm.childNodes;
926
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
927
+ const childNode = oldSlotChildNodes[i];
928
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
929
+ // // this child node in the old element is from another component
930
+ // // remove this node from the old slot's parent
931
+ // childNode.remove();
932
+ // and relocate it back to it's original location
933
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
934
+ // remove the old original location comment entirely
935
+ // later on the patch function will know what to do
936
+ // and move this to the correct spot in need be
937
+ childNode['s-ol'].remove();
938
+ childNode['s-ol'] = undefined;
939
+ checkSlotRelocate = true;
940
+ }
941
+ if (recursive) {
942
+ putBackInOriginalLocation(childNode, recursive);
943
+ }
944
+ }
945
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
946
+ };
947
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
948
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
949
+ let childNode;
950
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
951
+ containerElm = containerElm.shadowRoot;
952
+ }
953
+ for (; startIdx <= endIdx; ++startIdx) {
954
+ if (vnodes[startIdx]) {
955
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
956
+ if (childNode) {
957
+ vnodes[startIdx].$elm$ = childNode;
958
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
959
+ }
960
+ }
961
+ }
962
+ };
963
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
964
+ for (; startIdx <= endIdx; ++startIdx) {
965
+ if (vnode = vnodes[startIdx]) {
966
+ elm = vnode.$elm$;
967
+ callNodeRefs(vnode);
968
+ if (BUILD.slotRelocation) {
969
+ // we're removing this element
970
+ // so it's possible we need to show slot fallback content now
971
+ checkSlotFallbackVisibility = true;
972
+ if (elm['s-ol']) {
973
+ // remove the original location comment
974
+ elm['s-ol'].remove();
975
+ }
976
+ else {
977
+ // it's possible that child nodes of the node
978
+ // that's being removed are slot nodes
979
+ putBackInOriginalLocation(elm, true);
980
+ }
981
+ }
982
+ // remove the vnode's element from the dom
983
+ elm.remove();
984
+ }
985
+ }
986
+ };
987
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
988
+ let oldStartIdx = 0;
989
+ let newStartIdx = 0;
990
+ let idxInOld = 0;
991
+ let i = 0;
992
+ let oldEndIdx = oldCh.length - 1;
993
+ let oldStartVnode = oldCh[0];
994
+ let oldEndVnode = oldCh[oldEndIdx];
995
+ let newEndIdx = newCh.length - 1;
996
+ let newStartVnode = newCh[0];
997
+ let newEndVnode = newCh[newEndIdx];
998
+ let node;
999
+ let elmToMove;
1000
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1001
+ if (oldStartVnode == null) {
1002
+ // Vnode might have been moved left
1003
+ oldStartVnode = oldCh[++oldStartIdx];
1004
+ }
1005
+ else if (oldEndVnode == null) {
1006
+ oldEndVnode = oldCh[--oldEndIdx];
1007
+ }
1008
+ else if (newStartVnode == null) {
1009
+ newStartVnode = newCh[++newStartIdx];
1010
+ }
1011
+ else if (newEndVnode == null) {
1012
+ newEndVnode = newCh[--newEndIdx];
1013
+ }
1014
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
1015
+ patch(oldStartVnode, newStartVnode);
1016
+ oldStartVnode = oldCh[++oldStartIdx];
1017
+ newStartVnode = newCh[++newStartIdx];
1018
+ }
1019
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
1020
+ patch(oldEndVnode, newEndVnode);
1021
+ oldEndVnode = oldCh[--oldEndIdx];
1022
+ newEndVnode = newCh[--newEndIdx];
1023
+ }
1024
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
1025
+ // Vnode moved right
1026
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1027
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1028
+ }
1029
+ patch(oldStartVnode, newEndVnode);
1030
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1031
+ oldStartVnode = oldCh[++oldStartIdx];
1032
+ newEndVnode = newCh[--newEndIdx];
1033
+ }
1034
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
1035
+ // Vnode moved left
1036
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1037
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1038
+ }
1039
+ patch(oldEndVnode, newStartVnode);
1040
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1041
+ oldEndVnode = oldCh[--oldEndIdx];
1042
+ newStartVnode = newCh[++newStartIdx];
1043
+ }
1044
+ else {
1045
+ // createKeyToOldIdx
1046
+ idxInOld = -1;
1047
+ if (BUILD.vdomKey) {
1048
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1049
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1050
+ idxInOld = i;
1051
+ break;
1052
+ }
1053
+ }
1054
+ }
1055
+ if (BUILD.vdomKey && idxInOld >= 0) {
1056
+ elmToMove = oldCh[idxInOld];
1057
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1058
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1059
+ }
1060
+ else {
1061
+ patch(elmToMove, newStartVnode);
1062
+ oldCh[idxInOld] = undefined;
1063
+ node = elmToMove.$elm$;
1064
+ }
1065
+ newStartVnode = newCh[++newStartIdx];
1066
+ }
1067
+ else {
1068
+ // new element
1069
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1070
+ newStartVnode = newCh[++newStartIdx];
1071
+ }
1072
+ if (node) {
1073
+ if (BUILD.slotRelocation) {
1074
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1075
+ }
1076
+ else {
1077
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1078
+ }
1079
+ }
1080
+ }
1081
+ }
1082
+ if (oldStartIdx > oldEndIdx) {
1083
+ addVnodes(parentElm, (newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$), newVNode, newCh, newStartIdx, newEndIdx);
1084
+ }
1085
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
1086
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1087
+ }
1088
+ };
1089
+ const isSameVnode = (vnode1, vnode2) => {
1090
+ // compare if two vnode to see if they're "technically" the same
1091
+ // need to have the same element tag, and same key to be the same
1092
+ if (vnode1.$tag$ === vnode2.$tag$) {
1093
+ if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
1094
+ return vnode1.$name$ === vnode2.$name$;
1095
+ }
1096
+ if (BUILD.vdomKey) {
1097
+ return vnode1.$key$ === vnode2.$key$;
1098
+ }
1099
+ return true;
1100
+ }
1101
+ return false;
1102
+ };
1103
+ const referenceNode = (node) => {
1104
+ // this node was relocated to a new location in the dom
1105
+ // because of some other component's slot
1106
+ // but we still have an html comment in place of where
1107
+ // it's original location was according to it's original vdom
1108
+ return (node && node['s-ol']) || node;
1109
+ };
1110
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1111
+ const patch = (oldVNode, newVNode) => {
1112
+ const elm = newVNode.$elm$ = oldVNode.$elm$;
1113
+ const oldChildren = oldVNode.$children$;
1114
+ const newChildren = newVNode.$children$;
1115
+ const tag = newVNode.$tag$;
1116
+ const text = newVNode.$text$;
1117
+ let defaultHolder;
1118
+ if (!BUILD.vdomText || text === null) {
1119
+ if (BUILD.svg) {
1120
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1121
+ // only add this to the when the compiler sees we're using an svg somewhere
1122
+ isSvgMode = (tag === 'svg')
1123
+ ? true
1124
+ : (tag === 'foreignObject')
1125
+ ? false
1126
+ : isSvgMode;
1127
+ }
1128
+ // element node
1129
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1130
+ if (BUILD.slot && tag === 'slot') ;
1131
+ else {
1132
+ // either this is the first render of an element OR it's an update
1133
+ // AND we already know it's possible it could have changed
1134
+ // this updates the element's css classes, attrs, props, listeners, etc.
1135
+ updateElement(oldVNode, newVNode, isSvgMode);
1136
+ }
1137
+ }
1138
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1139
+ // looks like there's child vnodes for both the old and new vnodes
1140
+ updateChildren(elm, oldChildren, newVNode, newChildren);
1141
+ }
1142
+ else if (newChildren !== null) {
1143
+ // no old child vnodes, but there are new child vnodes to add
1144
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1145
+ // the old vnode was text, so be sure to clear it out
1146
+ elm.textContent = '';
1147
+ }
1148
+ // add the new vnode children
1149
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1150
+ }
1151
+ else if (BUILD.updatable && oldChildren !== null) {
1152
+ // no new child vnodes, but there are old child vnodes to remove
1153
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1154
+ }
1155
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1156
+ isSvgMode = false;
1157
+ }
1158
+ }
1159
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1160
+ // this element has slotted content
1161
+ defaultHolder.parentNode.textContent = text;
1162
+ }
1163
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1164
+ // update the text content for the text only vnode
1165
+ // and also only if the text is different than before
1166
+ elm.data = text;
1167
+ }
1168
+ };
1169
+ const updateFallbackSlotVisibility = (elm) => {
1170
+ // tslint:disable-next-line: prefer-const
1171
+ let childNodes = elm.childNodes;
1172
+ let childNode;
1173
+ let i;
1174
+ let ilen;
1175
+ let j;
1176
+ let slotNameAttr;
1177
+ let nodeType;
1178
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1179
+ childNode = childNodes[i];
1180
+ if (childNode.nodeType === 1 /* ElementNode */) {
1181
+ if (childNode['s-sr']) {
1182
+ // this is a slot fallback node
1183
+ // get the slot name for this slot reference node
1184
+ slotNameAttr = childNode['s-sn'];
1185
+ // by default always show a fallback slot node
1186
+ // then hide it if there are other slots in the light dom
1187
+ childNode.hidden = false;
1188
+ for (j = 0; j < ilen; j++) {
1189
+ if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
1190
+ // this sibling node is from a different component
1191
+ nodeType = childNodes[j].nodeType;
1192
+ if (slotNameAttr !== '') {
1193
+ // this is a named fallback slot node
1194
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1195
+ childNode.hidden = true;
1196
+ break;
1197
+ }
1198
+ }
1199
+ else {
1200
+ // this is a default fallback slot node
1201
+ // any element or text node (with content)
1202
+ // should hide the default fallback slot node
1203
+ if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1204
+ childNode.hidden = true;
1205
+ break;
1206
+ }
1207
+ }
1208
+ }
1209
+ }
1210
+ }
1211
+ // keep drilling down
1212
+ updateFallbackSlotVisibility(childNode);
1213
+ }
1214
+ }
1215
+ };
1216
+ const relocateNodes = [];
1217
+ const relocateSlotContent = (elm) => {
1218
+ // tslint:disable-next-line: prefer-const
1219
+ let childNode;
1220
+ let node;
1221
+ let hostContentNodes;
1222
+ let slotNameAttr;
1223
+ let relocateNodeData;
1224
+ let j;
1225
+ let i = 0;
1226
+ let childNodes = elm.childNodes;
1227
+ let ilen = childNodes.length;
1228
+ for (; i < ilen; i++) {
1229
+ childNode = childNodes[i];
1230
+ if (childNode['s-sr'] && (node = childNode['s-cr'])) {
1231
+ // first got the content reference comment node
1232
+ // then we got it's parent, which is where all the host content is in now
1233
+ hostContentNodes = node.parentNode.childNodes;
1234
+ slotNameAttr = childNode['s-sn'];
1235
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1236
+ node = hostContentNodes[j];
1237
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1238
+ // let's do some relocating to its new home
1239
+ // but never relocate a content reference node
1240
+ // that is suppose to always represent the original content location
1241
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
1242
+ // it's possible we've already decided to relocate this node
1243
+ relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
1244
+ // made some changes to slots
1245
+ // let's make sure we also double check
1246
+ // fallbacks are correctly hidden or shown
1247
+ checkSlotFallbackVisibility = true;
1248
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
1249
+ if (relocateNodeData) {
1250
+ // previously we never found a slot home for this node
1251
+ // but turns out we did, so let's remember it now
1252
+ relocateNodeData.$slotRefNode$ = childNode;
1253
+ }
1254
+ else {
1255
+ // add to our list of nodes to relocate
1256
+ relocateNodes.push({
1257
+ $slotRefNode$: childNode,
1258
+ $nodeToRelocate$: node,
1259
+ });
1260
+ }
1261
+ if (node['s-sr']) {
1262
+ relocateNodes.forEach(relocateNode => {
1263
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1264
+ relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
1265
+ if (relocateNodeData) {
1266
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1267
+ }
1268
+ }
1269
+ });
1270
+ }
1271
+ }
1272
+ else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
1273
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1274
+ // if we never find a home for this element then we'll need to hide it
1275
+ relocateNodes.push({
1276
+ $nodeToRelocate$: node,
1277
+ });
1278
+ }
1279
+ }
1280
+ }
1281
+ }
1282
+ if (childNode.nodeType === 1 /* ElementNode */) {
1283
+ relocateSlotContent(childNode);
1284
+ }
1285
+ }
1286
+ };
1287
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1288
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1289
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1290
+ return true;
1291
+ }
1292
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1293
+ return true;
1294
+ }
1295
+ return false;
1296
+ }
1297
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1298
+ return true;
1299
+ }
1300
+ return slotNameAttr === '';
1301
+ };
1302
+ const callNodeRefs = (vNode) => {
1303
+ if (BUILD.vdomRef) {
1304
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1305
+ vNode.$children$ && vNode.$children$.forEach(callNodeRefs);
1306
+ }
1307
+ };
1308
+ const renderVdom = (hostElm, hostRef, cmpMeta, renderFnResults) => {
1309
+ hostTagName = hostElm.tagName;
1310
+ // <Host> runtime check
1311
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1312
+ throw new Error(`The <Host> must be the single root component.
1313
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1314
+
1315
+ The render() function should look like this instead:
1316
+
1317
+ render() {
1318
+ // Do not return an array
1319
+ return (
1320
+ <Host>{content}</Host>
1321
+ );
1322
+ }
1323
+ `);
1324
+ }
1325
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1326
+ const rootVnode = isHost(renderFnResults)
1327
+ ? renderFnResults
1328
+ : h(null, null, renderFnResults);
1329
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1330
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1331
+ cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]);
1332
+ }
1333
+ rootVnode.$tag$ = null;
1334
+ rootVnode.$flags$ |= 4 /* isHost */;
1335
+ hostRef.$vnode$ = rootVnode;
1336
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1337
+ if (BUILD.scoped || BUILD.shadowDom) {
1338
+ scopeId = hostElm['s-sc'];
1339
+ }
1340
+ if (BUILD.slotRelocation) {
1341
+ contentRef = hostElm['s-cr'];
1342
+ useNativeShadowDom = supportsShadowDom && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1343
+ // always reset
1344
+ checkSlotFallbackVisibility = false;
1345
+ }
1346
+ // synchronous patch
1347
+ patch(oldVNode, rootVnode);
1348
+ if (BUILD.slotRelocation) {
1349
+ if (checkSlotRelocate) {
1350
+ relocateSlotContent(rootVnode.$elm$);
1351
+ let relocateData;
1352
+ let nodeToRelocate;
1353
+ let orgLocationNode;
1354
+ let parentNodeRef;
1355
+ let insertBeforeNode;
1356
+ let refNode;
1357
+ let i = 0;
1358
+ for (; i < relocateNodes.length; i++) {
1359
+ relocateData = relocateNodes[i];
1360
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1361
+ if (!nodeToRelocate['s-ol']) {
1362
+ // add a reference node marking this node's original location
1363
+ // keep a reference to this node for later lookups
1364
+ orgLocationNode = (BUILD.isDebug || BUILD.hydrateServerSide)
1365
+ ? originalLocationDebugNode(nodeToRelocate)
1366
+ : doc.createTextNode('');
1367
+ orgLocationNode['s-nr'] = nodeToRelocate;
1368
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1369
+ }
1370
+ }
1371
+ // while we're moving nodes around existing nodes, temporarily disable
1372
+ // the disconnectCallback from working
1373
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1374
+ for (i = 0; i < relocateNodes.length; i++) {
1375
+ relocateData = relocateNodes[i];
1376
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1377
+ if (relocateData.$slotRefNode$) {
1378
+ // by default we're just going to insert it directly
1379
+ // after the slot reference node
1380
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1381
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1382
+ orgLocationNode = nodeToRelocate['s-ol'];
1383
+ while (orgLocationNode = orgLocationNode.previousSibling) {
1384
+ refNode = orgLocationNode['s-nr'];
1385
+ if (refNode &&
1386
+ refNode['s-sn'] === nodeToRelocate['s-sn'] &&
1387
+ parentNodeRef === refNode.parentNode) {
1388
+ refNode = refNode.nextSibling;
1389
+ if (!refNode || !refNode['s-nr']) {
1390
+ insertBeforeNode = refNode;
1391
+ break;
1392
+ }
1393
+ }
1394
+ }
1395
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1396
+ (nodeToRelocate.nextSibling !== insertBeforeNode)) {
1397
+ // we've checked that it's worth while to relocate
1398
+ // since that the node to relocate
1399
+ // has a different next sibling or parent relocated
1400
+ if (nodeToRelocate !== insertBeforeNode) {
1401
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1402
+ // probably a component in the index.html that doesn't have it's hostname set
1403
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1404
+ }
1405
+ // add it back to the dom but in its new home
1406
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1407
+ }
1408
+ }
1409
+ }
1410
+ else {
1411
+ // this node doesn't have a slot home to go to, so let's hide it
1412
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1413
+ nodeToRelocate.hidden = true;
1414
+ }
1415
+ }
1416
+ }
1417
+ // done moving nodes around
1418
+ // allow the disconnect callback to work again
1419
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1420
+ }
1421
+ if (checkSlotFallbackVisibility) {
1422
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1423
+ }
1424
+ // always reset
1425
+ relocateNodes.length = 0;
1426
+ }
1427
+ };
1428
+ // slot comment debug nodes only created with the `--debug` flag
1429
+ // otherwise these nodes are text nodes w/out content
1430
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ?
1431
+ (' name="' + slotVNode.$name$) + '"' :
1432
+ ''}> (host=${hostTagName.toLowerCase()})`);
1433
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1434
+ (nodeToRelocate.localName ?
1435
+ `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})` :
1436
+ `[${nodeToRelocate.textContent}]`));
1437
+
1438
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1439
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$) {
1440
+ ancestorComponent['s-p'].push(new Promise(r => hostRef.$onRenderResolve$ = r));
1441
+ }
1442
+ };
1443
+ const scheduleUpdate = (elm, hostRef, cmpMeta, isInitialLoad) => {
1444
+ if (BUILD.taskQueue && BUILD.updatable) {
1445
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1446
+ }
1447
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1448
+ hostRef.$flags$ |= 512 /* needsRerender */;
1449
+ return;
1450
+ }
1451
+ const endSchedule = createTime('scheduleUpdate', cmpMeta.$tagName$);
1452
+ const ancestorComponent = hostRef.$ancestorComponent$;
1453
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1454
+ const update = () => updateComponent(elm, hostRef, cmpMeta, instance, isInitialLoad);
1455
+ attachToAncestor(hostRef, ancestorComponent);
1456
+ let promise;
1457
+ if (isInitialLoad) {
1458
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1459
+ hostRef.$flags$ |= 256 /* isListenReady */;
1460
+ if (hostRef.$queuedListeners$) {
1461
+ hostRef.$queuedListeners$.forEach(([methodName, event]) => safeCall(instance, methodName, event));
1462
+ hostRef.$queuedListeners$ = null;
1463
+ }
1464
+ }
1465
+ emitLifecycleEvent(elm, 'componentWillLoad');
1466
+ if (BUILD.cmpWillLoad) {
1467
+ promise = safeCall(instance, 'componentWillLoad');
1468
+ }
1469
+ }
1470
+ else {
1471
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1472
+ if (BUILD.cmpWillUpdate) {
1473
+ promise = safeCall(instance, 'componentWillUpdate');
1474
+ }
1475
+ }
1476
+ emitLifecycleEvent(elm, 'componentWillRender');
1477
+ if (BUILD.cmpWillRender) {
1478
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1479
+ }
1480
+ endSchedule();
1481
+ // there is no ancestorc omponent or the ancestor component
1482
+ // has already fired off its lifecycle update then
1483
+ // fire off the initial update
1484
+ return then(promise, BUILD.taskQueue
1485
+ ? () => writeTask(update)
1486
+ : update);
1487
+ };
1488
+ const updateComponent = (elm, hostRef, cmpMeta, instance, isInitialLoad) => {
1489
+ // updateComponent
1490
+ const endUpdate = createTime('update', cmpMeta.$tagName$);
1491
+ const rc = elm['s-rc'];
1492
+ if (BUILD.style && isInitialLoad) {
1493
+ // DOM WRITE!
1494
+ attachStyles(elm, cmpMeta, hostRef.$modeName$);
1495
+ }
1496
+ const endRender = createTime('render', cmpMeta.$tagName$);
1497
+ if (BUILD.isDev) {
1498
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1499
+ }
1500
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1501
+ if (BUILD.vdomRender || BUILD.reflect) {
1502
+ // looks like we've got child nodes to render into this host element
1503
+ // or we need to update the css class/attrs on the host element
1504
+ // DOM WRITE!
1505
+ renderVdom(elm, hostRef, cmpMeta, callRender(instance, elm));
1506
+ }
1507
+ else {
1508
+ elm.textContent = callRender(instance, elm);
1509
+ }
1510
+ }
1511
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1512
+ plt.$cssShim$.updateHost(elm);
1513
+ }
1514
+ if (BUILD.isDev) {
1515
+ hostRef.$renderCount$++;
1516
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1517
+ }
1518
+ if (BUILD.updatable && BUILD.taskQueue) {
1519
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1520
+ }
1521
+ if (BUILD.hydrateServerSide) {
1522
+ try {
1523
+ // manually connected child components during server-side hydrate
1524
+ serverSideConnected(elm);
1525
+ if (isInitialLoad) {
1526
+ // using only during server-side hydrate
1527
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1528
+ elm['s-en'] = '';
1529
+ }
1530
+ else if (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1531
+ elm['s-en'] = 'c';
1532
+ }
1533
+ }
1534
+ }
1535
+ catch (e) {
1536
+ consoleError(e);
1537
+ }
1538
+ }
1539
+ if (BUILD.updatable || BUILD.lazyLoad) {
1540
+ hostRef.$flags$ |= 2 /* hasRendered */;
1541
+ }
1542
+ if (BUILD.asyncLoading && rc) {
1543
+ // ok, so turns out there are some child host elements
1544
+ // waiting on this parent element to load
1545
+ // let's fire off all update callbacks waiting
1546
+ rc.forEach(cb => cb());
1547
+ elm['s-rc'] = undefined;
1548
+ }
1549
+ endRender();
1550
+ endUpdate();
1551
+ if (BUILD.asyncLoading) {
1552
+ const childrenPromises = elm['s-p'];
1553
+ const postUpdate = () => postUpdateComponent(elm, hostRef, cmpMeta);
1554
+ if (childrenPromises.length === 0) {
1555
+ postUpdate();
1556
+ }
1557
+ else {
1558
+ Promise.all(childrenPromises).then(postUpdate);
1559
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1560
+ childrenPromises.length = 0;
1561
+ }
1562
+ }
1563
+ else {
1564
+ postUpdateComponent(elm, hostRef, cmpMeta);
1565
+ }
1566
+ };
1567
+ let renderingElement = null;
1568
+ const callRender = (instance, elm) => {
1569
+ try {
1570
+ renderingElement = elm;
1571
+ instance = (BUILD.allRenderFn) ? instance.render() : (instance.render && instance.render());
1572
+ }
1573
+ catch (e) {
1574
+ consoleError(e);
1575
+ }
1576
+ renderingElement = null;
1577
+ return instance;
1578
+ };
1579
+ const getRenderingElement = () => renderingElement;
1580
+ const postUpdateComponent = (elm, hostRef, cmpMeta) => {
1581
+ const endPostUpdate = createTime('postUpdate', cmpMeta.$tagName$);
1582
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1583
+ const ancestorComponent = hostRef.$ancestorComponent$;
1584
+ if (BUILD.cmpDidRender) {
1585
+ if (BUILD.isDev) {
1586
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1587
+ }
1588
+ safeCall(instance, 'componentDidRender');
1589
+ if (BUILD.isDev) {
1590
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1591
+ }
1592
+ }
1593
+ emitLifecycleEvent(elm, 'componentDidRender');
1594
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1595
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1596
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1597
+ // DOM WRITE!
1598
+ addHydratedFlag(elm);
1599
+ }
1600
+ if (BUILD.cmpDidLoad) {
1601
+ if (BUILD.isDev) {
1602
+ hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1603
+ }
1604
+ safeCall(instance, 'componentDidLoad');
1605
+ if (BUILD.isDev) {
1606
+ hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1607
+ }
1608
+ }
1609
+ emitLifecycleEvent(elm, 'componentDidLoad');
1610
+ endPostUpdate();
1611
+ if (BUILD.asyncLoading) {
1612
+ hostRef.$onReadyResolve$(elm);
1613
+ if (!ancestorComponent) {
1614
+ appDidLoad(cmpMeta.$tagName$);
1615
+ }
1616
+ }
1617
+ }
1618
+ else {
1619
+ if (BUILD.cmpDidUpdate) {
1620
+ // we've already loaded this component
1621
+ // fire off the user's componentDidUpdate method (if one was provided)
1622
+ // componentDidUpdate runs AFTER render() has been called
1623
+ // and all child components have finished updating
1624
+ if (BUILD.isDev) {
1625
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1626
+ }
1627
+ safeCall(instance, 'componentDidUpdate');
1628
+ if (BUILD.isDev) {
1629
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1630
+ }
1631
+ }
1632
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1633
+ endPostUpdate();
1634
+ }
1635
+ if (BUILD.hotModuleReplacement) {
1636
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1637
+ }
1638
+ if (BUILD.method && BUILD.lazyLoad) {
1639
+ hostRef.$onInstanceResolve$(elm);
1640
+ }
1641
+ // load events fire from bottom to top
1642
+ // the deepest elements load first then bubbles up
1643
+ if (BUILD.asyncLoading) {
1644
+ if (hostRef.$onRenderResolve$) {
1645
+ hostRef.$onRenderResolve$();
1646
+ hostRef.$onRenderResolve$ = undefined;
1647
+ }
1648
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1649
+ nextTick(() => scheduleUpdate(elm, hostRef, cmpMeta, false));
1650
+ }
1651
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1652
+ }
1653
+ // ( •_•)
1654
+ // ( •_•)>⌐■-■
1655
+ // (⌐■_■)
1656
+ };
1657
+ const forceUpdate = (elm, cmpMeta) => {
1658
+ if (BUILD.updatable) {
1659
+ const hostRef = getHostRef(elm);
1660
+ const isConnected = hostRef.$hostElement$.isConnected;
1661
+ if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1662
+ scheduleUpdate(elm, hostRef, cmpMeta, false);
1663
+ }
1664
+ // Returns "true" when the forced update was successfully scheduled
1665
+ return isConnected;
1666
+ }
1667
+ return false;
1668
+ };
1669
+ const appDidLoad = (who) => {
1670
+ // on appload
1671
+ // we have finish the first big initial render
1672
+ if (BUILD.cssAnnotations) {
1673
+ addHydratedFlag(doc.documentElement);
1674
+ }
1675
+ if (!BUILD.hydrateServerSide) {
1676
+ plt.$flags$ |= 2 /* appLoaded */;
1677
+ }
1678
+ emitLifecycleEvent(doc, 'appload');
1679
+ if (BUILD.profile) {
1680
+ performance.measure(`[Rindo] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1681
+ }
1682
+ };
1683
+ const safeCall = (instance, method, arg) => {
1684
+ if (instance && instance[method]) {
1685
+ try {
1686
+ return instance[method](arg);
1687
+ }
1688
+ catch (e) {
1689
+ consoleError(e);
1690
+ }
1691
+ }
1692
+ return undefined;
1693
+ };
1694
+ const then = (promise, thenFn) => {
1695
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1696
+ };
1697
+ const emitLifecycleEvent = (elm, lifecycleName) => {
1698
+ if (BUILD.lifecycleDOMEvents) {
1699
+ elm.dispatchEvent(new CustomEvent('rindo_' + lifecycleName, { 'bubbles': true, 'composed': true }));
1700
+ }
1701
+ };
1702
+ const addHydratedFlag = (elm) => BUILD.hydratedClass ?
1703
+ elm.classList.add('hydrated') :
1704
+ BUILD.hydratedAttribute ?
1705
+ elm.setAttribute('hydrated', '') :
1706
+ undefined;
1707
+ const serverSideConnected = (elm) => {
1708
+ const children = elm.children;
1709
+ if (children != null) {
1710
+ for (let i = 0, ii = children.length; i < ii; i++) {
1711
+ const childElm = children[i];
1712
+ if (typeof childElm.connectedCallback === 'function') {
1713
+ childElm.connectedCallback();
1714
+ }
1715
+ serverSideConnected(childElm);
1716
+ }
1717
+ }
1718
+ };
1719
+
1720
+ const cloneNodeFix = (HostElementPrototype) => {
1721
+ const orgCloneNode = HostElementPrototype.cloneNode;
1722
+ HostElementPrototype.cloneNode = function (deep) {
1723
+ const srcNode = this;
1724
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadowDom : false;
1725
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
1726
+ if (BUILD.slot && !isShadowDom && deep) {
1727
+ let i = 0;
1728
+ let slotted, nonRindoNode;
1729
+ let rindoPrivates = ['s-id', 's-cr', 's-lr', 's-rc', 's-sc', 's-p', 's-cn', 's-sr', 's-sn', 's-hn', 's-ol', 's-nr', 's-si'];
1730
+ for (; i < srcNode.childNodes.length; i++) {
1731
+ slotted = srcNode.childNodes[i]['s-nr'];
1732
+ nonRindoNode = rindoPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
1733
+ if (slotted) {
1734
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
1735
+ clonedNode.__appendChild(slotted.cloneNode(true));
1736
+ }
1737
+ else {
1738
+ clonedNode.appendChild(slotted.cloneNode(true));
1739
+ }
1740
+ }
1741
+ if (nonRindoNode) {
1742
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
1743
+ }
1744
+ }
1745
+ }
1746
+ return clonedNode;
1747
+ };
1748
+ };
1749
+ const appendChildSlotFix = (HostElementPrototype) => {
1750
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1751
+ HostElementPrototype.appendChild = function (newChild) {
1752
+ const slotName = newChild['s-sn'] = getSlotName(newChild);
1753
+ const slotNode = getHostSlotNode(this, slotName);
1754
+ if (slotNode) {
1755
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1756
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
1757
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
1758
+ }
1759
+ return this.__appendChild(newChild);
1760
+ };
1761
+ };
1762
+ const getSlotName = (node) => (node['s-sn']) ||
1763
+ (node.nodeType === 1 && node.getAttribute('slot')) || '';
1764
+ const getHostSlotNode = (elm, slotName) => {
1765
+ let childNodes = elm.childNodes;
1766
+ let i = 0;
1767
+ let childNode;
1768
+ for (; i < childNodes.length; i++) {
1769
+ childNode = childNodes[i];
1770
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
1771
+ return childNode;
1772
+ }
1773
+ childNode = getHostSlotNode(childNode, slotName);
1774
+ if (childNode) {
1775
+ return childNode;
1776
+ }
1777
+ }
1778
+ return null;
1779
+ };
1780
+ const getHostSlotChildNodes = (n, slotName) => {
1781
+ const childNodes = [n];
1782
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
1783
+ childNodes.push(n);
1784
+ }
1785
+ return childNodes;
1786
+ };
1787
+
1788
+ const addEventListeners = (elm, hostRef, listeners) => {
1789
+ hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || [];
1790
+ const removeFns = listeners.map(([flags, name, method]) => {
1791
+ const target = (BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm);
1792
+ const handler = hostListenerProxy(hostRef, method);
1793
+ const opts = hostListenerOpts(flags);
1794
+ plt.ael(target, name, handler, opts);
1795
+ return () => plt.rel(target, name, handler, opts);
1796
+ });
1797
+ return () => removeFns.forEach(fn => fn());
1798
+ };
1799
+ const hostListenerProxy = (hostRef, methodName) => {
1800
+ return (ev) => {
1801
+ if (BUILD.lazyLoad) {
1802
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
1803
+ // instance is ready, let's call it's member method for this event
1804
+ hostRef.$lazyInstance$[methodName](ev);
1805
+ }
1806
+ else {
1807
+ hostRef.$queuedListeners$.push([methodName, ev]);
1808
+ }
1809
+ }
1810
+ else {
1811
+ hostRef.$hostElement$[methodName](ev);
1812
+ }
1813
+ };
1814
+ };
1815
+ const getHostListenerTarget = (elm, flags) => {
1816
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
1817
+ return doc;
1818
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
1819
+ return win;
1820
+ if (BUILD.hostListenerTargetBody && flags & 32 /* TargetBody */)
1821
+ return doc.body;
1822
+ if (BUILD.hostListenerTargetParent && flags & 16 /* TargetParent */)
1823
+ return elm.parentElement;
1824
+ return elm;
1825
+ };
1826
+ const hostListenerOpts = (flags) => supportsListenerOptions ?
1827
+ {
1828
+ 'passive': (flags & 1 /* Passive */) !== 0,
1829
+ 'capture': (flags & 2 /* Capture */) !== 0,
1830
+ }
1831
+ : (flags & 2 /* Capture */) !== 0;
1832
+
1833
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1834
+ const endHydrate = createTime('hydrateClient', tagName);
1835
+ const shadowRoot = hostElm.shadowRoot;
1836
+ const childRenderNodes = [];
1837
+ const slotNodes = [];
1838
+ const shadowRootNodes = (BUILD.shadowDom && shadowRoot ? [] : null);
1839
+ const vnode = hostRef.$vnode$ = newVNode(tagName, null);
1840
+ if (!plt.$orgLocNodes$) {
1841
+ initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = new Map());
1842
+ }
1843
+ hostElm[HYDRATE_ID] = hostId;
1844
+ hostElm.removeAttribute(HYDRATE_ID);
1845
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1846
+ childRenderNodes.forEach(c => {
1847
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1848
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1849
+ const node = c.$elm$;
1850
+ if (orgLocationNode && (supportsShadowDom && orgLocationNode['s-en'] === '')) {
1851
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1852
+ }
1853
+ if (!shadowRoot) {
1854
+ node['s-hn'] = tagName;
1855
+ if (orgLocationNode) {
1856
+ node['s-ol'] = orgLocationNode;
1857
+ node['s-ol']['s-nr'] = node;
1858
+ }
1859
+ }
1860
+ plt.$orgLocNodes$.delete(orgLocationId);
1861
+ });
1862
+ if (BUILD.shadowDom && shadowRoot) {
1863
+ shadowRootNodes.forEach(shadowRootNode => {
1864
+ if (shadowRootNode) {
1865
+ shadowRoot.appendChild(shadowRootNode);
1866
+ }
1867
+ });
1868
+ }
1869
+ endHydrate();
1870
+ };
1871
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1872
+ let childNodeType;
1873
+ let childIdSplt;
1874
+ let childVNode;
1875
+ let i;
1876
+ if (node.nodeType === 1 /* ElementNode */) {
1877
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1878
+ if (childNodeType) {
1879
+ // got the node data from the element's attribute
1880
+ // `${hostId}.${nodeId}.${depth}.${index}`
1881
+ childIdSplt = childNodeType.split('.');
1882
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1883
+ childVNode = {
1884
+ $flags$: 0,
1885
+ $hostId$: childIdSplt[0],
1886
+ $nodeId$: childIdSplt[1],
1887
+ $depth$: childIdSplt[2],
1888
+ $index$: childIdSplt[3],
1889
+ $tag$: node.tagName.toLowerCase(),
1890
+ $elm$: node,
1891
+ $attrs$: null,
1892
+ $children$: null,
1893
+ $key$: null,
1894
+ $name$: null,
1895
+ $text$: null
1896
+ };
1897
+ childRenderNodes.push(childVNode);
1898
+ node.removeAttribute(HYDRATE_CHILD_ID);
1899
+ // this is a new child vnode
1900
+ // so ensure its parent vnode has the vchildren array
1901
+ if (!parentVNode.$children$) {
1902
+ parentVNode.$children$ = [];
1903
+ }
1904
+ // add our child vnode to a specific index of the vnode's children
1905
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1906
+ // this is now the new parent vnode for all the next child checks
1907
+ parentVNode = childVNode;
1908
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
1909
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1910
+ }
1911
+ }
1912
+ }
1913
+ // recursively drill down, end to start so we can remove nodes
1914
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
1915
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1916
+ }
1917
+ if (node.shadowRoot) {
1918
+ // keep drilling down through the shadow root nodes
1919
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1920
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1921
+ }
1922
+ }
1923
+ }
1924
+ else if (node.nodeType === 8 /* CommentNode */) {
1925
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1926
+ childIdSplt = node.nodeValue.split('.');
1927
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1928
+ // comment node for either the host id or a 0 host id
1929
+ childNodeType = childIdSplt[0];
1930
+ childVNode = {
1931
+ $flags$: 0,
1932
+ $hostId$: childIdSplt[1],
1933
+ $nodeId$: childIdSplt[2],
1934
+ $depth$: childIdSplt[3],
1935
+ $index$: childIdSplt[4],
1936
+ $elm$: node,
1937
+ $attrs$: null,
1938
+ $children$: null,
1939
+ $key$: null,
1940
+ $name$: null,
1941
+ $tag$: null,
1942
+ $text$: null
1943
+ };
1944
+ if (childNodeType === TEXT_NODE_ID) {
1945
+ childVNode.$elm$ = node.nextSibling;
1946
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1947
+ childVNode.$text$ = childVNode.$elm$.textContent;
1948
+ childRenderNodes.push(childVNode);
1949
+ // remove the text comment since it's no longer needed
1950
+ node.remove();
1951
+ if (!parentVNode.$children$) {
1952
+ parentVNode.$children$ = [];
1953
+ }
1954
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1955
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
1956
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1957
+ }
1958
+ }
1959
+ }
1960
+ else if (childVNode.$hostId$ === hostId) {
1961
+ // this comment node is specifcally for this host id
1962
+ if (childNodeType === SLOT_NODE_ID) {
1963
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1964
+ childVNode.$tag$ = 'slot';
1965
+ if (childIdSplt[5]) {
1966
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1967
+ }
1968
+ else {
1969
+ node['s-sn'] = '';
1970
+ }
1971
+ node['s-sr'] = true;
1972
+ if (BUILD.shadowDom && shadowRootNodes) {
1973
+ // browser support shadowRoot and this is a shadow dom component
1974
+ // create an actual slot element
1975
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1976
+ if (childVNode.$name$) {
1977
+ // add the slot name attribute
1978
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
1979
+ }
1980
+ // insert the new slot element before the slot comment
1981
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1982
+ // remove the slot comment since it's not needed for shadow
1983
+ node.remove();
1984
+ if (childVNode.$depth$ === '0') {
1985
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1986
+ }
1987
+ }
1988
+ slotNodes.push(childVNode);
1989
+ if (!parentVNode.$children$) {
1990
+ parentVNode.$children$ = [];
1991
+ }
1992
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1993
+ }
1994
+ else if (childNodeType === CONTENT_REF_ID) {
1995
+ // `${CONTENT_REF_ID}.${hostId}`;
1996
+ if (BUILD.shadowDom && shadowRootNodes) {
1997
+ // remove the content ref comment since it's not needed for shadow
1998
+ node.remove();
1999
+ }
2000
+ else if (BUILD.slotRelocation) {
2001
+ hostElm['s-cr'] = node;
2002
+ node['s-cn'] = true;
2003
+ }
2004
+ }
2005
+ }
2006
+ }
2007
+ }
2008
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
2009
+ const vnode = newVNode(null, node.textContent);
2010
+ vnode.$elm$ = node;
2011
+ vnode.$index$ = '0';
2012
+ parentVNode.$children$ = [vnode];
2013
+ }
2014
+ };
2015
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
2016
+ if (node.nodeType === 1 /* ElementNode */) {
2017
+ let i = 0;
2018
+ for (; i < node.childNodes.length; i++) {
2019
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
2020
+ }
2021
+ if (node.shadowRoot) {
2022
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
2023
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
2024
+ }
2025
+ }
2026
+ }
2027
+ else if (node.nodeType === 8 /* CommentNode */) {
2028
+ const childIdSplt = node.nodeValue.split('.');
2029
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
2030
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
2031
+ node.nodeValue = '';
2032
+ // useful to know if the original location is
2033
+ // the root light-dom of a shadow dom component
2034
+ node['s-en'] = childIdSplt[3];
2035
+ }
2036
+ }
2037
+ };
2038
+
2039
+ const parsePropertyValue = (propValue, propType) => {
2040
+ // ensure this value is of the correct prop type
2041
+ if (propValue != null && !isComplexType(propValue)) {
2042
+ if (BUILD.propBoolean && propType & 4 /* Boolean */) {
2043
+ // per the HTML spec, any string value means it is a boolean true value
2044
+ // but we'll cheat here and say that the string "false" is the boolean false
2045
+ return (propValue === 'false' ? false : propValue === '' || !!propValue);
2046
+ }
2047
+ if (BUILD.propNumber && propType & 2 /* Number */) {
2048
+ // force it to be a number
2049
+ return parseFloat(propValue);
2050
+ }
2051
+ if (BUILD.propString && propType & 1 /* String */) {
2052
+ // could have been passed as a number or boolean
2053
+ // but we still want it as a string
2054
+ return String(propValue);
2055
+ }
2056
+ // redundant return here for better minification
2057
+ return propValue;
2058
+ }
2059
+ // not sure exactly what type we want
2060
+ // so no need to change to a different type
2061
+ return propValue;
2062
+ };
2063
+
2064
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
2065
+ const setValue = (ref, propName, newVal, cmpMeta) => {
2066
+ // check our new property value against our internal value
2067
+ const hostRef = getHostRef(ref);
2068
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
2069
+ const oldVal = hostRef.$instanceValues$.get(propName);
2070
+ const flags = hostRef.$flags$;
2071
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2072
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2073
+ if (newVal !== oldVal && (!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined)) {
2074
+ // gadzooks! the property's value has changed!!
2075
+ // set our new value!
2076
+ hostRef.$instanceValues$.set(propName, newVal);
2077
+ if (BUILD.isDev) {
2078
+ if (hostRef.$flags$ & 1024 /* devOnRender */) {
2079
+ 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);
2080
+ }
2081
+ else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
2082
+ 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);
2083
+ }
2084
+ }
2085
+ if (!BUILD.lazyLoad || instance) {
2086
+ // get an array of method names of watch functions to call
2087
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
2088
+ const watchMethods = cmpMeta.$watchers$[propName];
2089
+ if (watchMethods) {
2090
+ // this instance is watching for when this property changed
2091
+ watchMethods.forEach(watchMethodName => {
2092
+ try {
2093
+ // fire off each of the watch methods that are watching this property
2094
+ instance[watchMethodName](newVal, oldVal, propName);
2095
+ }
2096
+ catch (e) {
2097
+ consoleError(e);
2098
+ }
2099
+ });
2100
+ }
2101
+ }
2102
+ if (BUILD.updatable && (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
2103
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
2104
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
2105
+ return;
2106
+ }
2107
+ }
2108
+ // looks like this value actually changed, so we've got work to do!
2109
+ // but only if we've already rendered, otherwise just chill out
2110
+ // queue that we need to do an update, but don't worry about queuing
2111
+ // up millions cuz this function ensures it only runs once
2112
+ scheduleUpdate(elm, hostRef, cmpMeta, false);
2113
+ }
2114
+ }
2115
+ }
2116
+ };
2117
+
2118
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
2119
+ if (BUILD.member && cmpMeta.$members$) {
2120
+ if (BUILD.watchCallback && Cstr.watchers) {
2121
+ cmpMeta.$watchers$ = Cstr.watchers;
2122
+ }
2123
+ // It's better to have a const than two Object.entries()
2124
+ const members = Object.entries(cmpMeta.$members$);
2125
+ const prototype = Cstr.prototype;
2126
+ members.forEach(([memberName, [memberFlags]]) => {
2127
+ if ((BUILD.prop || BUILD.state) && ((memberFlags & 31 /* Prop */) ||
2128
+ ((!BUILD.lazyLoad || flags & 2 /* proxyState */) &&
2129
+ (memberFlags & 32 /* State */)))) {
2130
+ // proxyComponent - prop
2131
+ Object.defineProperty(prototype, memberName, {
2132
+ get() {
2133
+ // proxyComponent, get value
2134
+ return getValue(this, memberName);
2135
+ },
2136
+ set(newValue) {
2137
+ if (
2138
+ // only during dev time
2139
+ (BUILD.isDev) &&
2140
+ // we are proxing the instance (not element)
2141
+ (flags & 1 /* isElementConstructor */) === 0 &&
2142
+ // the member is a non-mutable prop
2143
+ (memberFlags & (31 /* Prop */ | 1024 /* Mutable */)) === 31 /* Prop */) {
2144
+ consoleDevWarn(`@Prop() "${memberName}" on "${cmpMeta.$tagName$}" cannot be modified.\nFurther information: https://rindojs.web.app/docs/properties#prop-mutability`);
2145
+ }
2146
+ // proxyComponent, set value
2147
+ setValue(this, memberName, newValue, cmpMeta);
2148
+ },
2149
+ configurable: true,
2150
+ enumerable: true
2151
+ });
2152
+ }
2153
+ else if (BUILD.lazyLoad && BUILD.method && (flags & 1 /* isElementConstructor */) && (memberFlags & 64 /* Method */)) {
2154
+ // proxyComponent - method
2155
+ Object.defineProperty(prototype, memberName, {
2156
+ value(...args) {
2157
+ const ref = getHostRef(this);
2158
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
2159
+ }
2160
+ });
2161
+ }
2162
+ });
2163
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
2164
+ const attrNameToPropName = new Map();
2165
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
2166
+ plt.jmp(() => {
2167
+ const propName = attrNameToPropName.get(attrName);
2168
+ this[propName] = newValue === null && typeof this[propName] === 'boolean'
2169
+ ? false
2170
+ : newValue;
2171
+ });
2172
+ };
2173
+ // create an array of attributes to observe
2174
+ // and also create a map of html attribute name to js property name
2175
+ Cstr.observedAttributes = members
2176
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
2177
+ .map(([propName, m]) => {
2178
+ const attrName = m[1] || propName;
2179
+ attrNameToPropName.set(attrName, propName);
2180
+ if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
2181
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
2182
+ }
2183
+ return attrName;
2184
+ });
2185
+ }
2186
+ }
2187
+ return Cstr;
2188
+ };
2189
+
2190
+ const modeResolutionChain = [];
2191
+ const computeMode = (elm) => modeResolutionChain.map(h => h(elm)).find(m => !!m);
2192
+ // Public
2193
+ const setMode = (handler) => modeResolutionChain.push(handler);
2194
+ const getMode = (ref) => getHostRef(ref).$modeName$;
2195
+
2196
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2197
+ // initializeComponent
2198
+ if ((BUILD.lazyLoad || BUILD.style) && (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2199
+ // we haven't initialized this element yet
2200
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2201
+ if (BUILD.mode && hostRef.$modeName$ == null) {
2202
+ // initializeComponent
2203
+ // looks like mode wasn't set as a property directly yet
2204
+ // first check if there's an attribute
2205
+ // next check the app's global
2206
+ hostRef.$modeName$ = typeof cmpMeta.$lazyBundleIds$ !== 'string' ? computeMode(elm) : '';
2207
+ }
2208
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2209
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2210
+ }
2211
+ if (BUILD.lazyLoad) {
2212
+ // lazy loaded components
2213
+ // request the component's implementation to be
2214
+ // wired up with the host element
2215
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
2216
+ if (Cstr.then) {
2217
+ // Await creates a micro-task avoid if possible
2218
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Rindo] Load module for <${cmpMeta.$tagName$}>`);
2219
+ Cstr = await Cstr;
2220
+ endLoad();
2221
+ }
2222
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2223
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2224
+ }
2225
+ if (BUILD.member && !Cstr.isProxied) {
2226
+ // we'eve never proxied this Constructor before
2227
+ // let's add the getters/setters to its prototype before
2228
+ // the first time we create an instance of the implementation
2229
+ if (BUILD.watchCallback) {
2230
+ cmpMeta.$watchers$ = Cstr.watchers;
2231
+ }
2232
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
2233
+ Cstr.isProxied = true;
2234
+ }
2235
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2236
+ // ok, time to construct the instance
2237
+ // but let's keep track of when we start and stop
2238
+ // so that the getters/setters don't incorrectly step on data
2239
+ if (BUILD.member) {
2240
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
2241
+ }
2242
+ // construct the lazy-loaded component implementation
2243
+ // passing the hostRef is very important during
2244
+ // construction in order to directly wire together the
2245
+ // host element and the lazy-loaded instance
2246
+ try {
2247
+ new Cstr(hostRef);
2248
+ }
2249
+ catch (e) {
2250
+ consoleError(e);
2251
+ }
2252
+ if (BUILD.member) {
2253
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
2254
+ }
2255
+ if (BUILD.watchCallback) {
2256
+ hostRef.$flags$ |= 128 /* isWatchReady */;
2257
+ }
2258
+ endNewInstance();
2259
+ fireConnectedCallback(hostRef.$lazyInstance$);
2260
+ }
2261
+ else {
2262
+ Cstr = elm.constructor;
2263
+ }
2264
+ const scopeId = BUILD.mode ? getScopeId(cmpMeta.$tagName$, hostRef.$modeName$) : getScopeId(cmpMeta.$tagName$);
2265
+ if (BUILD.style && !styles.has(scopeId) && Cstr.style) {
2266
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2267
+ // this component has styles but we haven't registered them yet
2268
+ let style = Cstr.style;
2269
+ if (BUILD.mode && typeof style !== 'string') {
2270
+ style = style[hostRef.$modeName$];
2271
+ }
2272
+ if (!BUILD.hydrateServerSide && BUILD.shadowDom && BUILD.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2273
+ style = await import('./shadow-css.rindo-client.mjs').then(m => m.scopeCss(style, scopeId, false));
2274
+ }
2275
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2276
+ endRegisterStyles();
2277
+ }
2278
+ }
2279
+ // we've successfully created a lazy instance
2280
+ const ancestorComponent = hostRef.$ancestorComponent$;
2281
+ const schedule = () => scheduleUpdate(elm, hostRef, cmpMeta, true);
2282
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2283
+ // this is the intial load and this component it has an ancestor component
2284
+ // but the ancestor component has NOT fired its will update lifecycle yet
2285
+ // so let's just cool our jets and wait for the ancestor to continue first
2286
+ // this will get fired off when the ancestor component
2287
+ // finally gets around to rendering its lazy self
2288
+ // fire off the initial update
2289
+ ancestorComponent['s-rc'].push(schedule);
2290
+ }
2291
+ else {
2292
+ schedule();
2293
+ }
2294
+ };
2295
+
2296
+ const fireConnectedCallback = (instance) => {
2297
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
2298
+ safeCall(instance, 'connectedCallback');
2299
+ }
2300
+ };
2301
+ const connectedCallback = (elm, cmpMeta) => {
2302
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2303
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2304
+ // connectedCallback
2305
+ const hostRef = getHostRef(elm);
2306
+ if (BUILD.hostListener && cmpMeta.$listeners$) {
2307
+ // initialize our event listeners on the host element
2308
+ // we do this now so that we can listening to events that may
2309
+ // have fired even before the instance is ready
2310
+ hostRef.$rmListeners$ = addEventListeners(elm, hostRef, cmpMeta.$listeners$);
2311
+ }
2312
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2313
+ // first time this component has connected
2314
+ hostRef.$flags$ |= 1 /* hasConnected */;
2315
+ let hostId;
2316
+ if (BUILD.hydrateClientSide) {
2317
+ hostId = elm.getAttribute(HYDRATE_ID);
2318
+ if (hostId) {
2319
+ if (BUILD.shadowDom && supportsShadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2320
+ const scopeId = BUILD.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode')) : addStyle(elm.shadowRoot, cmpMeta);
2321
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2322
+ }
2323
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2324
+ }
2325
+ }
2326
+ if (BUILD.slotRelocation && !hostId) {
2327
+ // initUpdate
2328
+ // if the slot polyfill is required we'll need to put some nodes
2329
+ // in here to act as original content anchors as we move nodes around
2330
+ // host element has been connected to the DOM
2331
+ if ((BUILD.hydrateServerSide) ||
2332
+ (BUILD.slot && cmpMeta.$flags$ & 4 /* hasSlotRelocation */) ||
2333
+ (BUILD.shadowDom && cmpMeta.$flags$ & 8 /* needsShadowDomShim */)) {
2334
+ setContentReference(elm);
2335
+ }
2336
+ }
2337
+ if (BUILD.asyncLoading) {
2338
+ // find the first ancestor component (if there is one) and register
2339
+ // this component as one of the actively loading child components for its ancestor
2340
+ let ancestorComponent = elm;
2341
+ while ((ancestorComponent = (ancestorComponent.parentNode || ancestorComponent.host))) {
2342
+ // climb up the ancestors looking for the first
2343
+ // component that hasn't finished its lifecycle update yet
2344
+ if ((BUILD.hydrateClientSide && ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute('s-id')) ||
2345
+ (ancestorComponent['s-p'])) {
2346
+ // we found this components first ancestor component
2347
+ // keep a reference to this component's ancestor component
2348
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2349
+ break;
2350
+ }
2351
+ }
2352
+ }
2353
+ // Lazy properties
2354
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2355
+ if (BUILD.prop && BUILD.lazyLoad && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2356
+ Object.entries(cmpMeta.$members$).forEach(([memberName, [memberFlags]]) => {
2357
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2358
+ const value = elm[memberName];
2359
+ delete elm[memberName];
2360
+ elm[memberName] = value;
2361
+ }
2362
+ });
2363
+ }
2364
+ if (BUILD.initializeNextTick) {
2365
+ // connectedCallback, taskQueue, initialLoad
2366
+ // angular sets attribute AFTER connectCallback
2367
+ // https://github.com/angular/angular/issues/18909
2368
+ // https://github.com/angular/angular/issues/19940
2369
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2370
+ }
2371
+ else {
2372
+ initializeComponent(elm, hostRef, cmpMeta);
2373
+ }
2374
+ }
2375
+ fireConnectedCallback(hostRef.$lazyInstance$);
2376
+ endConnected();
2377
+ }
2378
+ };
2379
+ const setContentReference = (elm) => {
2380
+ // only required when we're NOT using native shadow dom (slot)
2381
+ // or this browser doesn't support native shadow dom
2382
+ // and this host element was NOT created with SSR
2383
+ // let's pick out the inner content for slot projection
2384
+ // create a node to represent where the original
2385
+ // content was first placed, which is useful later on
2386
+ const contentRefElm = elm['s-cr'] = doc.createComment(BUILD.isDebug
2387
+ ? `content-ref (host=${elm.localName})`
2388
+ : '');
2389
+ contentRefElm['s-cn'] = true;
2390
+ elm.insertBefore(contentRefElm, elm.firstChild);
2391
+ };
2392
+
2393
+ const disconnectedCallback = (elm) => {
2394
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2395
+ const hostRef = getHostRef(elm);
2396
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2397
+ if (BUILD.hostListener) {
2398
+ if (hostRef.$rmListeners$) {
2399
+ hostRef.$rmListeners$();
2400
+ hostRef.$rmListeners$ = undefined;
2401
+ }
2402
+ }
2403
+ // clear CSS var-shim tracking
2404
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2405
+ plt.$cssShim$.removeHost(elm);
2406
+ }
2407
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2408
+ safeCall(instance, 'disconnectedCallback');
2409
+ }
2410
+ if (BUILD.cmpDidUnload) {
2411
+ safeCall(instance, 'componentDidUnload');
2412
+ }
2413
+ }
2414
+ };
2415
+
2416
+ function hmrStart(elm, cmpMeta, hmrVersionId) {
2417
+ // ¯\_(ツ)_/¯
2418
+ const hostRef = getHostRef(elm);
2419
+ // reset state flags to only have been connected
2420
+ hostRef.$flags$ = 1 /* hasConnected */;
2421
+ // TODO
2422
+ // detatch any event listeners that may have been added
2423
+ // because we're not passing an exact event name it'll
2424
+ // remove all of this element's event, which is good
2425
+ // create a callback for when this component finishes hmr
2426
+ elm['s-hmr-load'] = () => {
2427
+ // finished hmr for this element
2428
+ delete elm['s-hmr-load'];
2429
+ };
2430
+ // re-initialize the component
2431
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2432
+ }
2433
+
2434
+ const bootstrapLazy = (lazyBundles, options = {}) => {
2435
+ if (BUILD.profile) {
2436
+ performance.mark('st:app:start');
2437
+ }
2438
+ installDevTools();
2439
+ const endBootstrap = createTime('bootstrapLazy');
2440
+ const cmpTags = [];
2441
+ const exclude = options.exclude || [];
2442
+ const customElements = win.customElements;
2443
+ const head = doc.head;
2444
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2445
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2446
+ const deferredConnectedCallbacks = [];
2447
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2448
+ let appLoadFallback;
2449
+ let isBootstrapping = true;
2450
+ let i = 0;
2451
+ Object.assign(plt, options);
2452
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2453
+ if (options.syncQueue) {
2454
+ plt.$flags$ |= 4 /* queueSync */;
2455
+ }
2456
+ if (BUILD.hydrateClientSide) {
2457
+ // If the app is already hydrated there is not point to disable the
2458
+ // async queue. This will improve the first input delay
2459
+ plt.$flags$ |= 2 /* appLoaded */;
2460
+ }
2461
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2462
+ for (; i < styles.length; i++) {
2463
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2464
+ }
2465
+ }
2466
+ lazyBundles.forEach(lazyBundle => lazyBundle[1].forEach(compactMeta => {
2467
+ const cmpMeta = {
2468
+ $flags$: compactMeta[0],
2469
+ $tagName$: compactMeta[1],
2470
+ $members$: compactMeta[2],
2471
+ $listeners$: compactMeta[3],
2472
+ };
2473
+ if (BUILD.member) {
2474
+ cmpMeta.$members$ = compactMeta[2];
2475
+ }
2476
+ if (BUILD.hostListener) {
2477
+ cmpMeta.$listeners$ = compactMeta[3];
2478
+ }
2479
+ if (BUILD.reflect) {
2480
+ cmpMeta.$attrsToReflect$ = [];
2481
+ }
2482
+ if (BUILD.watchCallback) {
2483
+ cmpMeta.$watchers$ = {};
2484
+ }
2485
+ if (BUILD.shadowDom && !supportsShadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2486
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2487
+ }
2488
+ const tagName = cmpMeta.$tagName$;
2489
+ const HostElement = class extends HTMLElement {
2490
+ // RindoLazyHost
2491
+ constructor(self) {
2492
+ // @ts-ignore
2493
+ super(self);
2494
+ self = this;
2495
+ registerHost(self);
2496
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2497
+ // this component is using shadow dom
2498
+ // and this browser supports shadow dom
2499
+ // add the read-only property "shadowRoot" to the host element
2500
+ // adding the shadow root build conditionals to minimize runtime
2501
+ if (supportsShadowDom) {
2502
+ if (BUILD.shadowDelegatesFocus) {
2503
+ self.attachShadow({
2504
+ mode: 'open',
2505
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2506
+ });
2507
+ }
2508
+ else {
2509
+ self.attachShadow({ mode: 'open' });
2510
+ }
2511
+ }
2512
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2513
+ self.shadowRoot = self;
2514
+ }
2515
+ }
2516
+ }
2517
+ connectedCallback() {
2518
+ if (appLoadFallback) {
2519
+ clearTimeout(appLoadFallback);
2520
+ appLoadFallback = null;
2521
+ }
2522
+ if (isBootstrapping) {
2523
+ // connectedCallback will be processed once all components have been registered
2524
+ deferredConnectedCallbacks.push(this);
2525
+ }
2526
+ else {
2527
+ plt.jmp(() => connectedCallback(this, cmpMeta));
2528
+ }
2529
+ }
2530
+ disconnectedCallback() {
2531
+ plt.jmp(() => disconnectedCallback(this));
2532
+ }
2533
+ forceUpdate() {
2534
+ forceUpdate(this, cmpMeta);
2535
+ }
2536
+ componentOnReady() {
2537
+ return getHostRef(this).$onReadyPromise$;
2538
+ }
2539
+ };
2540
+ if (BUILD.cloneNodeFix) {
2541
+ cloneNodeFix(HostElement.prototype);
2542
+ }
2543
+ if (BUILD.appendChildSlotFix) {
2544
+ appendChildSlotFix(HostElement.prototype);
2545
+ }
2546
+ if (BUILD.hotModuleReplacement) {
2547
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2548
+ hmrStart(this, cmpMeta, hmrVersionId);
2549
+ };
2550
+ }
2551
+ cmpMeta.$lazyBundleIds$ = lazyBundle[0];
2552
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2553
+ cmpTags.push(tagName);
2554
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
2555
+ }
2556
+ }));
2557
+ if (BUILD.hydratedClass || BUILD.hydratedAttribute) {
2558
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2559
+ visibilityStyle.setAttribute('data-styles', '');
2560
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2561
+ }
2562
+ // Process deferred connectedCallbacks now all components have been registered
2563
+ isBootstrapping = false;
2564
+ if (deferredConnectedCallbacks.length > 0) {
2565
+ deferredConnectedCallbacks.forEach(host => host.connectedCallback());
2566
+ }
2567
+ else {
2568
+ if (BUILD.profile) {
2569
+ plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30, 'timeout'));
2570
+ }
2571
+ else {
2572
+ plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
2573
+ }
2574
+ }
2575
+ // Fallback appLoad event
2576
+ endBootstrap();
2577
+ };
2578
+
2579
+ const defineCustomElement = (Cstr, compactMeta) => {
2580
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2581
+ };
2582
+ const proxyCustomElement = (Cstr, compactMeta) => {
2583
+ const cmpMeta = {
2584
+ $flags$: compactMeta[0],
2585
+ $tagName$: compactMeta[1],
2586
+ };
2587
+ if (BUILD.member) {
2588
+ cmpMeta.$members$ = compactMeta[2];
2589
+ }
2590
+ if (BUILD.hostListener) {
2591
+ cmpMeta.$listeners$ = compactMeta[3];
2592
+ }
2593
+ if (BUILD.watchCallback) {
2594
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2595
+ }
2596
+ if (BUILD.reflect) {
2597
+ cmpMeta.$attrsToReflect$ = [];
2598
+ }
2599
+ if (BUILD.shadowDom && !supportsShadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2600
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2601
+ }
2602
+ Object.assign(Cstr.prototype, {
2603
+ forceUpdate() {
2604
+ forceUpdate(this, cmpMeta);
2605
+ },
2606
+ connectedCallback() {
2607
+ connectedCallback(this, cmpMeta);
2608
+ },
2609
+ disconnectedCallback() {
2610
+ disconnectedCallback(this);
2611
+ }
2612
+ });
2613
+ return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2614
+ };
2615
+
2616
+ const attachShadow = (el) => {
2617
+ if (supportsShadowDom) {
2618
+ el.attachShadow({ mode: 'open' });
2619
+ }
2620
+ else {
2621
+ el.shadowRoot = el;
2622
+ }
2623
+ };
2624
+ const proxyNative = (Cstr, compactMeta) => {
2625
+ const cmpMeta = {
2626
+ $flags$: compactMeta[0],
2627
+ $tagName$: compactMeta[1],
2628
+ $members$: compactMeta[2],
2629
+ $listeners$: compactMeta[3],
2630
+ $watchers$: Cstr.$watchers$
2631
+ };
2632
+ if (BUILD.reflect) {
2633
+ cmpMeta.$attrsToReflect$ = [];
2634
+ }
2635
+ if (BUILD.shadowDom && !supportsShadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2636
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2637
+ }
2638
+ Object.assign(Cstr.prototype, {
2639
+ forceUpdate() {
2640
+ forceUpdate(this, cmpMeta);
2641
+ },
2642
+ connectedCallback() {
2643
+ connectedCallback(this, cmpMeta);
2644
+ },
2645
+ disconnectedCallback() {
2646
+ disconnectedCallback(this);
2647
+ }
2648
+ });
2649
+ return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2650
+ };
2651
+
2652
+ const createEvent = (ref, name, flags) => {
2653
+ const elm = getElement(ref);
2654
+ return {
2655
+ emit: (detail) => {
2656
+ if (BUILD.isDev && !elm.isConnected) {
2657
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
2658
+ }
2659
+ const ev = new (BUILD.hydrateServerSide ? win.CustomEvent : CustomEvent)(name, {
2660
+ bubbles: !!(flags & 4 /* Bubbles */),
2661
+ composed: !!(flags & 2 /* Composed */),
2662
+ cancelable: !!(flags & 1 /* Cancellable */),
2663
+ detail
2664
+ });
2665
+ elm.dispatchEvent(ev);
2666
+ return ev;
2667
+ }
2668
+ };
2669
+ };
2670
+
2671
+ const getAssetPath = (path) => {
2672
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
2673
+ return (assetUrl.origin !== win.location.origin)
2674
+ ? assetUrl.href
2675
+ : assetUrl.pathname;
2676
+ };
2677
+
2678
+ const getConnect = (_ref, tagName) => {
2679
+ const componentOnReady = () => {
2680
+ let elm = doc.querySelector(tagName);
2681
+ if (!elm) {
2682
+ elm = doc.createElement(tagName);
2683
+ doc.body.appendChild(elm);
2684
+ }
2685
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2686
+ };
2687
+ const create = (...args) => {
2688
+ return componentOnReady()
2689
+ .then(el => el.create(...args));
2690
+ };
2691
+ return {
2692
+ create,
2693
+ componentOnReady,
2694
+ };
2695
+ };
2696
+
2697
+ const getContext = (_elm, context) => {
2698
+ if (context in Context) {
2699
+ return Context[context];
2700
+ }
2701
+ else if (context === 'window') {
2702
+ return win;
2703
+ }
2704
+ else if (context === 'document') {
2705
+ return doc;
2706
+ }
2707
+ else if (context === 'isServer' || context === 'isPrerender') {
2708
+ return BUILD.hydrateServerSide ? true : false;
2709
+ }
2710
+ else if (context === 'isClient') {
2711
+ return BUILD.hydrateServerSide ? false : true;
2712
+ }
2713
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2714
+ return getAssetPath('.');
2715
+ }
2716
+ else if (context === 'queue') {
2717
+ return {
2718
+ write: writeTask,
2719
+ read: readTask,
2720
+ tick: {
2721
+ then(cb) {
2722
+ return nextTick(cb);
2723
+ }
2724
+ }
2725
+ };
2726
+ }
2727
+ return undefined;
2728
+ };
2729
+
2730
+ const getElement = (ref) => BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
2731
+
2732
+ const insertVdomAnnotations = (doc) => {
2733
+ if (doc != null) {
2734
+ const docData = {
2735
+ hostIds: 0,
2736
+ rootLevelIds: 0
2737
+ };
2738
+ const orgLocationNodes = [];
2739
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
2740
+ orgLocationNodes.forEach(orgLocationNode => {
2741
+ if (orgLocationNode != null) {
2742
+ const nodeRef = orgLocationNode['s-nr'];
2743
+ let hostId = nodeRef['s-host-id'];
2744
+ let nodeId = nodeRef['s-node-id'];
2745
+ let childId = `${hostId}.${nodeId}`;
2746
+ if (hostId == null) {
2747
+ hostId = 0;
2748
+ docData.rootLevelIds++;
2749
+ nodeId = docData.rootLevelIds;
2750
+ childId = `${hostId}.${nodeId}`;
2751
+ if (nodeRef.nodeType === 1 /* ElementNode */) {
2752
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2753
+ }
2754
+ else if (nodeRef.nodeType === 3 /* TextNode */) {
2755
+ if (hostId === 0) {
2756
+ const textContent = nodeRef.nodeValue.trim();
2757
+ if (textContent === '') {
2758
+ // useless whitespace node at the document root
2759
+ orgLocationNode.remove();
2760
+ return;
2761
+ }
2762
+ }
2763
+ const commentBeforeTextNode = doc.createComment(childId);
2764
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2765
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
2766
+ }
2767
+ }
2768
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2769
+ const orgLocationParentNode = orgLocationNode.parentElement;
2770
+ if (orgLocationParentNode) {
2771
+ if (orgLocationParentNode['s-en'] === '') {
2772
+ // ending with a "." means that the parent element
2773
+ // of this node's original location is a SHADOW dom element
2774
+ // and this node is apart of the root level light dom
2775
+ orgLocationNodeId += `.`;
2776
+ }
2777
+ else if (orgLocationParentNode['s-en'] === 'c') {
2778
+ // ending with a ".c" means that the parent element
2779
+ // of this node's original location is a SCOPED element
2780
+ // and this node is apart of the root level light dom
2781
+ orgLocationNodeId += `.c`;
2782
+ }
2783
+ }
2784
+ orgLocationNode.nodeValue = orgLocationNodeId;
2785
+ }
2786
+ });
2787
+ }
2788
+ };
2789
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
2790
+ if (node == null) {
2791
+ return;
2792
+ }
2793
+ if (node['s-nr'] != null) {
2794
+ orgLocationNodes.push(node);
2795
+ }
2796
+ if (node.nodeType === 1 /* ElementNode */) {
2797
+ node.childNodes.forEach(childNode => {
2798
+ const hostRef = getHostRef(childNode);
2799
+ if (hostRef != null) {
2800
+ const cmpData = {
2801
+ nodeIds: 0
2802
+ };
2803
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
2804
+ }
2805
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
2806
+ });
2807
+ }
2808
+ };
2809
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
2810
+ if (vnode != null) {
2811
+ const hostId = ++docData.hostIds;
2812
+ hostElm.setAttribute(HYDRATE_ID, hostId);
2813
+ if (hostElm['s-cr'] != null) {
2814
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
2815
+ }
2816
+ if (vnode.$children$ != null) {
2817
+ const depth = 0;
2818
+ vnode.$children$.forEach((vnodeChild, index) => {
2819
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
2820
+ });
2821
+ }
2822
+ }
2823
+ };
2824
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
2825
+ const childElm = vnodeChild.$elm$;
2826
+ if (childElm == null) {
2827
+ return;
2828
+ }
2829
+ const nodeId = cmpData.nodeIds++;
2830
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2831
+ childElm['s-host-id'] = hostId;
2832
+ childElm['s-node-id'] = nodeId;
2833
+ if (childElm.nodeType === 1 /* ElementNode */) {
2834
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2835
+ }
2836
+ else if (childElm.nodeType === 3 /* TextNode */) {
2837
+ const parentNode = childElm.parentNode;
2838
+ if (parentNode.nodeName !== 'STYLE') {
2839
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2840
+ const commentBeforeTextNode = doc.createComment(textNodeId);
2841
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
2842
+ }
2843
+ }
2844
+ else if (childElm.nodeType === 8 /* CommentNode */) {
2845
+ if (childElm['s-sr']) {
2846
+ const slotName = (childElm['s-sn'] || '');
2847
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
2848
+ childElm.nodeValue = slotNodeId;
2849
+ }
2850
+ }
2851
+ if (vnodeChild.$children$ != null) {
2852
+ const childDepth = depth + 1;
2853
+ vnodeChild.$children$.forEach((vnode, index) => {
2854
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
2855
+ });
2856
+ }
2857
+ };
2858
+
2859
+ export { Build, CSS, Context, H, H as HTMLElement, Host, RINDO_DEV_MODE, attachShadow, bootstrapLazy, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingElement, getValue, h, insertVdomAnnotations, isMemberInElement, loadModule, moduleCache, nextTick, parsePropertyValue, patchBrowser, patchCloneNodeFix, patchDynamicImport, patchEsm, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, proxyNative, readTask, registerHost, registerInstance, renderVdom, setMode, setValue, styles, supportsConstructibleStylesheets, supportsListenerOptions, supportsShadowDom, win, writeTask };