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