@rindo/core 1.8.12 → 1.17.4

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