@rindo/core 1.8.12 → 2.5.2

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