@stencil/core 4.43.3 → 5.0.0-alpha.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 (377) hide show
  1. package/bin/stencil.mjs +2 -0
  2. package/dist/chunk-CjcI7cDX.mjs +15 -0
  3. package/dist/client-DucyoZT4.mjs +4524 -0
  4. package/dist/compiler/index.d.mts +192 -0
  5. package/dist/compiler/index.mjs +3 -0
  6. package/dist/compiler/utils/index.d.mts +2 -0
  7. package/dist/compiler/utils/index.mjs +3 -0
  8. package/dist/compiler-DyK1_szo.mjs +21783 -0
  9. package/{internal → dist/declarations}/stencil-ext-modules.d.ts +8 -8
  10. package/dist/declarations/stencil-public-compiler.d.ts +2 -0
  11. package/dist/declarations/stencil-public-compiler.js +53 -0
  12. package/dist/declarations/stencil-public-docs.d.ts +2 -0
  13. package/dist/declarations/stencil-public-runtime.d.ts +2 -0
  14. package/dist/declarations/stencil-public-runtime.js +0 -0
  15. package/dist/index-BONzXKJt.d.ts +1893 -0
  16. package/{internal/app-data/index.d.ts → dist/index-CHjZtib0.d.ts} +11 -7
  17. package/dist/index-D-LlB2nw.d.mts +6918 -0
  18. package/dist/index-fIuYTL9f.d.mts +178 -0
  19. package/{internal/stencil-core/index.d.ts → dist/index.d.mts} +10 -3
  20. package/dist/index.mjs +2 -0
  21. package/dist/jsx-runtime-DBzBJLKk.d.ts +28 -0
  22. package/dist/jsx-runtime.d.ts +2 -0
  23. package/dist/jsx-runtime.js +2 -0
  24. package/dist/mock-doc.d.mts +1 -0
  25. package/dist/mock-doc.mjs +2 -0
  26. package/dist/node-BWBQAh8C.mjs +1947 -0
  27. package/dist/runtime/app-data/index.d.ts +2 -0
  28. package/dist/runtime/app-data/index.js +99 -0
  29. package/dist/runtime/app-globals/index.d.ts +5 -0
  30. package/dist/runtime/app-globals/index.js +5 -0
  31. package/dist/runtime/client/index.d.ts +2358 -0
  32. package/dist/runtime/client/index.js +4879 -0
  33. package/dist/runtime/index.d.ts +182 -0
  34. package/dist/runtime/index.js +2 -0
  35. package/dist/runtime/server/index.d.mts +1146 -0
  36. package/dist/runtime/server/index.mjs +4958 -0
  37. package/dist/runtime/server/runner.d.mts +323 -0
  38. package/dist/runtime/server/runner.mjs +14072 -0
  39. package/dist/runtime-CqlPYKjW.js +4761 -0
  40. package/dist/serialize-o-Sj1lvg.mjs +792 -0
  41. package/dist/stencil-public-compiler-C_X1iolo.d.ts +4455 -0
  42. package/dist/stencil-public-runtime-DlV8o7-z.d.ts +1845 -0
  43. package/dist/sys/node/index.d.mts +32 -0
  44. package/dist/sys/node/index.mjs +2 -0
  45. package/dist/sys/node/worker.d.mts +1 -0
  46. package/dist/sys/node/worker.mjs +48 -0
  47. package/dist/testing/index.d.mts +209 -0
  48. package/dist/testing/index.mjs +1169 -0
  49. package/dist/validation-BR7tMYEv.mjs +1441 -0
  50. package/package.json +99 -228
  51. package/bin/stencil +0 -57
  52. package/cli/config-flags.d.ts +0 -132
  53. package/cli/index.cjs +0 -6041
  54. package/cli/index.d.ts +0 -19
  55. package/cli/index.js +0 -6034
  56. package/cli/package.json +0 -14
  57. package/compiler/lib.d.ts +0 -22
  58. package/compiler/lib.decorators.d.ts +0 -384
  59. package/compiler/lib.decorators.legacy.d.ts +0 -22
  60. package/compiler/lib.dom.asynciterable.d.ts +0 -41
  61. package/compiler/lib.dom.d.ts +0 -29610
  62. package/compiler/lib.dom.iterable.d.ts +0 -493
  63. package/compiler/lib.es2015.collection.d.ts +0 -147
  64. package/compiler/lib.es2015.core.d.ts +0 -597
  65. package/compiler/lib.es2015.d.ts +0 -28
  66. package/compiler/lib.es2015.generator.d.ts +0 -77
  67. package/compiler/lib.es2015.iterable.d.ts +0 -605
  68. package/compiler/lib.es2015.promise.d.ts +0 -81
  69. package/compiler/lib.es2015.proxy.d.ts +0 -128
  70. package/compiler/lib.es2015.reflect.d.ts +0 -144
  71. package/compiler/lib.es2015.symbol.d.ts +0 -46
  72. package/compiler/lib.es2015.symbol.wellknown.d.ts +0 -326
  73. package/compiler/lib.es2016.array.include.d.ts +0 -116
  74. package/compiler/lib.es2016.d.ts +0 -21
  75. package/compiler/lib.es2016.full.d.ts +0 -23
  76. package/compiler/lib.es2016.intl.d.ts +0 -31
  77. package/compiler/lib.es2017.arraybuffer.d.ts +0 -21
  78. package/compiler/lib.es2017.d.ts +0 -26
  79. package/compiler/lib.es2017.date.d.ts +0 -31
  80. package/compiler/lib.es2017.full.d.ts +0 -23
  81. package/compiler/lib.es2017.intl.d.ts +0 -44
  82. package/compiler/lib.es2017.object.d.ts +0 -49
  83. package/compiler/lib.es2017.sharedmemory.d.ts +0 -135
  84. package/compiler/lib.es2017.string.d.ts +0 -45
  85. package/compiler/lib.es2017.typedarrays.d.ts +0 -53
  86. package/compiler/lib.es2018.asyncgenerator.d.ts +0 -77
  87. package/compiler/lib.es2018.asynciterable.d.ts +0 -53
  88. package/compiler/lib.es2018.d.ts +0 -24
  89. package/compiler/lib.es2018.full.d.ts +0 -24
  90. package/compiler/lib.es2018.intl.d.ts +0 -83
  91. package/compiler/lib.es2018.promise.d.ts +0 -30
  92. package/compiler/lib.es2018.regexp.d.ts +0 -37
  93. package/compiler/lib.es2019.array.d.ts +0 -79
  94. package/compiler/lib.es2019.d.ts +0 -24
  95. package/compiler/lib.es2019.full.d.ts +0 -24
  96. package/compiler/lib.es2019.intl.d.ts +0 -23
  97. package/compiler/lib.es2019.object.d.ts +0 -33
  98. package/compiler/lib.es2019.string.d.ts +0 -37
  99. package/compiler/lib.es2019.symbol.d.ts +0 -24
  100. package/compiler/lib.es2020.bigint.d.ts +0 -765
  101. package/compiler/lib.es2020.d.ts +0 -27
  102. package/compiler/lib.es2020.date.d.ts +0 -42
  103. package/compiler/lib.es2020.full.d.ts +0 -24
  104. package/compiler/lib.es2020.intl.d.ts +0 -474
  105. package/compiler/lib.es2020.number.d.ts +0 -28
  106. package/compiler/lib.es2020.promise.d.ts +0 -47
  107. package/compiler/lib.es2020.sharedmemory.d.ts +0 -99
  108. package/compiler/lib.es2020.string.d.ts +0 -44
  109. package/compiler/lib.es2020.symbol.wellknown.d.ts +0 -41
  110. package/compiler/lib.es2021.d.ts +0 -23
  111. package/compiler/lib.es2021.full.d.ts +0 -24
  112. package/compiler/lib.es2021.intl.d.ts +0 -166
  113. package/compiler/lib.es2021.promise.d.ts +0 -48
  114. package/compiler/lib.es2021.string.d.ts +0 -33
  115. package/compiler/lib.es2021.weakref.d.ts +0 -78
  116. package/compiler/lib.es2022.array.d.ts +0 -121
  117. package/compiler/lib.es2022.d.ts +0 -25
  118. package/compiler/lib.es2022.error.d.ts +0 -75
  119. package/compiler/lib.es2022.full.d.ts +0 -24
  120. package/compiler/lib.es2022.intl.d.ts +0 -121
  121. package/compiler/lib.es2022.object.d.ts +0 -26
  122. package/compiler/lib.es2022.regexp.d.ts +0 -39
  123. package/compiler/lib.es2022.string.d.ts +0 -25
  124. package/compiler/lib.es2023.array.d.ts +0 -924
  125. package/compiler/lib.es2023.collection.d.ts +0 -21
  126. package/compiler/lib.es2023.d.ts +0 -22
  127. package/compiler/lib.es2023.full.d.ts +0 -24
  128. package/compiler/lib.es2023.intl.d.ts +0 -56
  129. package/compiler/lib.es2024.arraybuffer.d.ts +0 -65
  130. package/compiler/lib.es2024.collection.d.ts +0 -29
  131. package/compiler/lib.es2024.d.ts +0 -26
  132. package/compiler/lib.es2024.full.d.ts +0 -24
  133. package/compiler/lib.es2024.object.d.ts +0 -29
  134. package/compiler/lib.es2024.promise.d.ts +0 -35
  135. package/compiler/lib.es2024.regexp.d.ts +0 -25
  136. package/compiler/lib.es2024.sharedmemory.d.ts +0 -68
  137. package/compiler/lib.es2024.string.d.ts +0 -29
  138. package/compiler/lib.es5.d.ts +0 -4594
  139. package/compiler/lib.es6.d.ts +0 -23
  140. package/compiler/lib.esnext.array.d.ts +0 -35
  141. package/compiler/lib.esnext.collection.d.ts +0 -96
  142. package/compiler/lib.esnext.d.ts +0 -27
  143. package/compiler/lib.esnext.decorators.d.ts +0 -28
  144. package/compiler/lib.esnext.disposable.d.ts +0 -193
  145. package/compiler/lib.esnext.float16.d.ts +0 -443
  146. package/compiler/lib.esnext.full.d.ts +0 -24
  147. package/compiler/lib.esnext.intl.d.ts +0 -21
  148. package/compiler/lib.esnext.iterator.d.ts +0 -148
  149. package/compiler/lib.esnext.promise.d.ts +0 -34
  150. package/compiler/lib.scripthost.d.ts +0 -322
  151. package/compiler/lib.webworker.asynciterable.d.ts +0 -41
  152. package/compiler/lib.webworker.d.ts +0 -9894
  153. package/compiler/lib.webworker.importscripts.d.ts +0 -23
  154. package/compiler/lib.webworker.iterable.d.ts +0 -287
  155. package/compiler/package.json +0 -8
  156. package/compiler/stencil.d.ts +0 -73
  157. package/compiler/stencil.js +0 -288027
  158. package/compiler/sys/in-memory-fs.d.ts +0 -227
  159. package/compiler/transpile.d.ts +0 -32
  160. package/dev-server/client/app-error.d.ts +0 -20
  161. package/dev-server/client/events.d.ts +0 -6
  162. package/dev-server/client/hmr-components.d.ts +0 -12
  163. package/dev-server/client/hmr-external-styles.d.ts +0 -1
  164. package/dev-server/client/hmr-images.d.ts +0 -1
  165. package/dev-server/client/hmr-inline-styles.d.ts +0 -1
  166. package/dev-server/client/hmr-util.d.ts +0 -39
  167. package/dev-server/client/hmr-window.d.ts +0 -10
  168. package/dev-server/client/index.d.ts +0 -6
  169. package/dev-server/client/index.js +0 -793
  170. package/dev-server/client/logger.d.ts +0 -6
  171. package/dev-server/client/package.json +0 -8
  172. package/dev-server/client/progress.d.ts +0 -3
  173. package/dev-server/client/status.d.ts +0 -4
  174. package/dev-server/client/test/hmr-util.spec.d.ts +0 -1
  175. package/dev-server/client/test/status.spec.d.ts +0 -1
  176. package/dev-server/connector.html +0 -6
  177. package/dev-server/index.d.ts +0 -3
  178. package/dev-server/index.js +0 -247
  179. package/dev-server/package.json +0 -8
  180. package/dev-server/server-process.js +0 -12304
  181. package/dev-server/server-worker-thread.js +0 -39
  182. package/dev-server/static/favicon.ico +0 -0
  183. package/dev-server/templates/directory-index.html +0 -176
  184. package/dev-server/templates/initial-load.html +0 -168
  185. package/dev-server/visualstudio.vbs +0 -82
  186. package/dev-server/xdg-open +0 -1066
  187. package/internal/app-data/index.cjs +0 -119
  188. package/internal/app-data/index.js +0 -92
  189. package/internal/app-data/package.json +0 -15
  190. package/internal/app-globals/index.d.ts +0 -2
  191. package/internal/app-globals/index.js +0 -14
  192. package/internal/app-globals/package.json +0 -14
  193. package/internal/child_process.d.ts +0 -7
  194. package/internal/client/index.js +0 -4736
  195. package/internal/client/package.json +0 -10
  196. package/internal/client/patch-browser.js +0 -45
  197. package/internal/client/polyfills/core-js.js +0 -11
  198. package/internal/client/polyfills/dom.js +0 -79
  199. package/internal/client/polyfills/es5-html-element.js +0 -1
  200. package/internal/client/polyfills/index.js +0 -34
  201. package/internal/client/polyfills/system.js +0 -6
  202. package/internal/client/shadow-css.js +0 -414
  203. package/internal/hydrate/index.js +0 -6880
  204. package/internal/hydrate/package.json +0 -7
  205. package/internal/hydrate/runner.d.ts +0 -287
  206. package/internal/hydrate/runner.js +0 -18157
  207. package/internal/index.d.ts +0 -4
  208. package/internal/index.js +0 -2
  209. package/internal/package.json +0 -9
  210. package/internal/stencil-core/index.cjs +0 -1
  211. package/internal/stencil-core/index.js +0 -18
  212. package/internal/stencil-core/jsx-dev-runtime.cjs +0 -7
  213. package/internal/stencil-core/jsx-dev-runtime.d.ts +0 -41
  214. package/internal/stencil-core/jsx-dev-runtime.js +0 -2
  215. package/internal/stencil-core/jsx-runtime.cjs +0 -8
  216. package/internal/stencil-core/jsx-runtime.d.ts +0 -40
  217. package/internal/stencil-core/jsx-runtime.js +0 -2
  218. package/internal/stencil-private.d.ts +0 -2549
  219. package/internal/stencil-public-compiler.d.ts +0 -2922
  220. package/internal/stencil-public-docs.d.ts +0 -472
  221. package/internal/stencil-public-runtime.d.ts +0 -1860
  222. package/internal/testing/index.js +0 -6737
  223. package/internal/testing/jsx-dev-runtime.d.ts +0 -2
  224. package/internal/testing/jsx-dev-runtime.js +0 -8
  225. package/internal/testing/jsx-runtime.d.ts +0 -2
  226. package/internal/testing/jsx-runtime.js +0 -9
  227. package/internal/testing/package.json +0 -7
  228. package/internal/utils/index.d.ts +0 -1
  229. package/internal/utils/result.d.ts +0 -112
  230. package/mock-doc/index.cjs +0 -10163
  231. package/mock-doc/index.d.ts +0 -1172
  232. package/mock-doc/index.js +0 -10142
  233. package/mock-doc/package.json +0 -15
  234. package/readme.md +0 -94
  235. package/screenshot/compare/assets/favicon.ico +0 -0
  236. package/screenshot/compare/assets/logo.png +0 -0
  237. package/screenshot/compare/build/app.css +0 -1
  238. package/screenshot/compare/build/app.esm.js +0 -1
  239. package/screenshot/compare/build/app.js +0 -33
  240. package/screenshot/compare/build/p-081b0641.js +0 -1
  241. package/screenshot/compare/build/p-227a1e18.entry.js +0 -1
  242. package/screenshot/compare/build/p-2c298727.entry.js +0 -1
  243. package/screenshot/compare/build/p-5479268c.entry.js +0 -1
  244. package/screenshot/compare/build/p-573ec8a4.entry.js +0 -1
  245. package/screenshot/compare/build/p-6ba08604.entry.js +0 -1
  246. package/screenshot/compare/build/p-6bc63295.entry.js +0 -1
  247. package/screenshot/compare/build/p-7a3759fd.entry.js +0 -1
  248. package/screenshot/compare/build/p-7b4e3ba7.js +0 -1
  249. package/screenshot/compare/build/p-988eb362.css +0 -1
  250. package/screenshot/compare/build/p-9b6a9315.js +0 -1
  251. package/screenshot/compare/build/p-b4cc611c.entry.js +0 -1
  252. package/screenshot/compare/build/p-d1bf53f5.entry.js +0 -1
  253. package/screenshot/compare/build/p-e2efe0df.js +0 -1
  254. package/screenshot/compare/build/p-e8ca6d97.entry.js +0 -1
  255. package/screenshot/compare/build/p-ec2f13e0.entry.js +0 -1
  256. package/screenshot/compare/build/p-f0b99977.entry.js +0 -1
  257. package/screenshot/compare/build/p-f4745c2f.entry.js +0 -1
  258. package/screenshot/compare/build/p-fbbae598.js +0 -1
  259. package/screenshot/compare/host.config.json +0 -15
  260. package/screenshot/compare/index.html +0 -1
  261. package/screenshot/compare/manifest.json +0 -13
  262. package/screenshot/connector-base.d.ts +0 -42
  263. package/screenshot/connector-local.d.ts +0 -7
  264. package/screenshot/connector.js +0 -2
  265. package/screenshot/index.d.ts +0 -3
  266. package/screenshot/index.js +0 -2642
  267. package/screenshot/local-connector.js +0 -2
  268. package/screenshot/package.json +0 -15
  269. package/screenshot/pixel-match.d.ts +0 -1
  270. package/screenshot/pixel-match.js +0 -2315
  271. package/screenshot/screenshot-compare.d.ts +0 -20
  272. package/screenshot/screenshot-fs.d.ts +0 -14
  273. package/sys/node/460.node-fetch.js +0 -451
  274. package/sys/node/autoprefixer.js +0 -9
  275. package/sys/node/glob.js +0 -1
  276. package/sys/node/graceful-fs.js +0 -1
  277. package/sys/node/index.d.ts +0 -39
  278. package/sys/node/index.js +0 -62
  279. package/sys/node/node-fetch.js +0 -12
  280. package/sys/node/package.json +0 -8
  281. package/sys/node/prompts.js +0 -1
  282. package/sys/node/worker.js +0 -4
  283. package/testing/index.d.ts +0 -9
  284. package/testing/index.js +0 -13273
  285. package/testing/jest/jest-27-and-under/jest-config.d.ts +0 -16
  286. package/testing/jest/jest-27-and-under/jest-environment.d.ts +0 -2
  287. package/testing/jest/jest-27-and-under/jest-facade.d.ts +0 -155
  288. package/testing/jest/jest-27-and-under/jest-preprocessor.d.ts +0 -59
  289. package/testing/jest/jest-27-and-under/jest-preset.d.ts +0 -3
  290. package/testing/jest/jest-27-and-under/jest-runner.d.ts +0 -11
  291. package/testing/jest/jest-27-and-under/jest-screenshot.d.ts +0 -2
  292. package/testing/jest/jest-27-and-under/jest-serializer.d.ts +0 -4
  293. package/testing/jest/jest-27-and-under/jest-setup-test-framework.d.ts +0 -9
  294. package/testing/jest/jest-27-and-under/matchers/attributes.d.ts +0 -14
  295. package/testing/jest/jest-27-and-under/matchers/class-list.d.ts +0 -12
  296. package/testing/jest/jest-27-and-under/matchers/events.d.ts +0 -25
  297. package/testing/jest/jest-27-and-under/matchers/html.d.ts +0 -13
  298. package/testing/jest/jest-27-and-under/matchers/index.d.ts +0 -24
  299. package/testing/jest/jest-27-and-under/matchers/screenshot.d.ts +0 -5
  300. package/testing/jest/jest-27-and-under/matchers/text.d.ts +0 -4
  301. package/testing/jest/jest-27-and-under/test/jest-config.spec.d.ts +0 -1
  302. package/testing/jest/jest-27-and-under/test/jest-preprocessor.spec.d.ts +0 -1
  303. package/testing/jest/jest-27-and-under/test/jest-runner.spec.d.ts +0 -1
  304. package/testing/jest/jest-27-and-under/test/jest-serializer.spec.d.ts +0 -1
  305. package/testing/jest/jest-27-and-under/test/jest-setup-test-framework.spec.d.ts +0 -1
  306. package/testing/jest/jest-28/jest-config.d.ts +0 -16
  307. package/testing/jest/jest-28/jest-environment.d.ts +0 -2
  308. package/testing/jest/jest-28/jest-facade.d.ts +0 -134
  309. package/testing/jest/jest-28/jest-preprocessor.d.ts +0 -35
  310. package/testing/jest/jest-28/jest-preset.d.ts +0 -3
  311. package/testing/jest/jest-28/jest-runner.d.ts +0 -11
  312. package/testing/jest/jest-28/jest-screenshot.d.ts +0 -2
  313. package/testing/jest/jest-28/jest-serializer.d.ts +0 -4
  314. package/testing/jest/jest-28/jest-setup-test-framework.d.ts +0 -9
  315. package/testing/jest/jest-28/matchers/attributes.d.ts +0 -14
  316. package/testing/jest/jest-28/matchers/class-list.d.ts +0 -12
  317. package/testing/jest/jest-28/matchers/events.d.ts +0 -25
  318. package/testing/jest/jest-28/matchers/html.d.ts +0 -13
  319. package/testing/jest/jest-28/matchers/index.d.ts +0 -24
  320. package/testing/jest/jest-28/matchers/screenshot.d.ts +0 -5
  321. package/testing/jest/jest-28/matchers/text.d.ts +0 -4
  322. package/testing/jest/jest-28/test/jest-config.spec.d.ts +0 -1
  323. package/testing/jest/jest-28/test/jest-preprocessor.spec.d.ts +0 -1
  324. package/testing/jest/jest-28/test/jest-runner.spec.d.ts +0 -1
  325. package/testing/jest/jest-28/test/jest-serializer.spec.d.ts +0 -1
  326. package/testing/jest/jest-28/test/jest-setup-test-framework.spec.d.ts +0 -1
  327. package/testing/jest/jest-29/jest-config.d.ts +0 -16
  328. package/testing/jest/jest-29/jest-environment.d.ts +0 -2
  329. package/testing/jest/jest-29/jest-facade.d.ts +0 -136
  330. package/testing/jest/jest-29/jest-preprocessor.d.ts +0 -35
  331. package/testing/jest/jest-29/jest-preset.d.ts +0 -3
  332. package/testing/jest/jest-29/jest-runner.d.ts +0 -11
  333. package/testing/jest/jest-29/jest-screenshot.d.ts +0 -2
  334. package/testing/jest/jest-29/jest-serializer.d.ts +0 -4
  335. package/testing/jest/jest-29/jest-setup-test-framework.d.ts +0 -9
  336. package/testing/jest/jest-29/matchers/attributes.d.ts +0 -14
  337. package/testing/jest/jest-29/matchers/class-list.d.ts +0 -12
  338. package/testing/jest/jest-29/matchers/events.d.ts +0 -25
  339. package/testing/jest/jest-29/matchers/html.d.ts +0 -13
  340. package/testing/jest/jest-29/matchers/index.d.ts +0 -24
  341. package/testing/jest/jest-29/matchers/screenshot.d.ts +0 -5
  342. package/testing/jest/jest-29/matchers/text.d.ts +0 -4
  343. package/testing/jest/jest-29/test/jest-config.spec.d.ts +0 -1
  344. package/testing/jest/jest-29/test/jest-preprocessor.spec.d.ts +0 -1
  345. package/testing/jest/jest-29/test/jest-runner.spec.d.ts +0 -1
  346. package/testing/jest/jest-29/test/jest-serializer.spec.d.ts +0 -1
  347. package/testing/jest/jest-29/test/jest-setup-test-framework.spec.d.ts +0 -1
  348. package/testing/jest/jest-apis.d.ts +0 -86
  349. package/testing/jest/jest-facade.d.ts +0 -74
  350. package/testing/jest/jest-stencil-connector.d.ts +0 -65
  351. package/testing/jest/test/jest-stencil-connector.spec.d.ts +0 -1
  352. package/testing/jest-environment.js +0 -3
  353. package/testing/jest-preprocessor.js +0 -3
  354. package/testing/jest-preset.js +0 -2
  355. package/testing/jest-runner.js +0 -3
  356. package/testing/jest-setuptestframework.js +0 -3
  357. package/testing/mock-fetch.d.ts +0 -11
  358. package/testing/mocks.d.ts +0 -56
  359. package/testing/package.json +0 -8
  360. package/testing/puppeteer/index.d.ts +0 -2
  361. package/testing/puppeteer/puppeteer-browser.d.ts +0 -6
  362. package/testing/puppeteer/puppeteer-declarations.d.ts +0 -414
  363. package/testing/puppeteer/puppeteer-element.d.ts +0 -67
  364. package/testing/puppeteer/puppeteer-emulate.d.ts +0 -2
  365. package/testing/puppeteer/puppeteer-events.d.ts +0 -21
  366. package/testing/puppeteer/puppeteer-page.d.ts +0 -2
  367. package/testing/puppeteer/puppeteer-screenshot.d.ts +0 -27
  368. package/testing/puppeteer/test/puppeteer-screenshot.spec.d.ts +0 -1
  369. package/testing/reset-build-conditionals.d.ts +0 -12
  370. package/testing/spec-page.d.ts +0 -7
  371. package/testing/test/testing-utils.spec.d.ts +0 -1
  372. package/testing/test-transpile.d.ts +0 -2
  373. package/testing/testing-logger.d.ts +0 -26
  374. package/testing/testing-sys.d.ts +0 -6
  375. package/testing/testing-utils.d.ts +0 -80
  376. package/testing/testing.d.ts +0 -2
  377. /package/{screenshot/compare/build/index.esm.js → dist/declarations/stencil-public-docs.js} +0 -0
@@ -0,0 +1,1169 @@
1
+ import { B as Env, T as reWireGetterSetter, _ as h, a as Mixin, c as forceUpdate, d as createEvent, f as getElement, g as Host, l as getRenderingRef, o as Fragment, p as getMode, s as bootstrapLazy, t as insertVdomAnnotations, u as renderVdom, v as getAssetPath, y as setAssetPath, z as BUILD } from "../client-DucyoZT4.mjs";
2
+ import { D as CMP_FLAGS, G as EVENT_FLAGS, y as noop } from "../serialize-o-Sj1lvg.mjs";
3
+ import { _ as getBuildFeatures, c as createWorkerContext, h as BuildContext, i as createSystem, m as Cache, p as createInMemoryFs } from "../compiler-DyK1_szo.mjs";
4
+ import { St as formatLazyBundleRuntimeMeta } from "../validation-BR7tMYEv.mjs";
5
+ import { o as buildEvents } from "../node-BWBQAh8C.mjs";
6
+ import path from "node:path";
7
+ import path$1 from "path";
8
+ import { MockWindow, setupGlobal } from "@stencil/mock-doc";
9
+ import { createHash } from "crypto";
10
+ import { afterAll, vi } from "vitest";
11
+ //#region src/testing/testing-logger.ts
12
+ var TestingLogger = class {
13
+ isEnabled = false;
14
+ enable() {
15
+ this.isEnabled = true;
16
+ }
17
+ setLevel(_level) {}
18
+ getLevel() {
19
+ return "info";
20
+ }
21
+ enableColors(_useColors) {}
22
+ emoji(_) {
23
+ return "";
24
+ }
25
+ info(...msg) {
26
+ if (this.isEnabled) console.log(...msg);
27
+ }
28
+ warn(...msg) {
29
+ if (this.isEnabled) console.warn(...msg);
30
+ }
31
+ error(...msg) {
32
+ if (this.isEnabled) console.error(...msg);
33
+ }
34
+ debug(...msg) {
35
+ if (this.isEnabled) console.log(...msg);
36
+ }
37
+ color(_msg, _color) {}
38
+ red(msg) {
39
+ return msg;
40
+ }
41
+ green(msg) {
42
+ return msg;
43
+ }
44
+ yellow(msg) {
45
+ return msg;
46
+ }
47
+ blue(msg) {
48
+ return msg;
49
+ }
50
+ magenta(msg) {
51
+ return msg;
52
+ }
53
+ cyan(msg) {
54
+ return msg;
55
+ }
56
+ gray(msg) {
57
+ return msg;
58
+ }
59
+ bold(msg) {
60
+ return msg;
61
+ }
62
+ dim(msg) {
63
+ return msg;
64
+ }
65
+ bgRed(msg) {
66
+ return msg;
67
+ }
68
+ createTimeSpan(_startMsg, _debug = false) {
69
+ return {
70
+ duration() {
71
+ return 0;
72
+ },
73
+ finish() {
74
+ return 0;
75
+ }
76
+ };
77
+ }
78
+ printDiagnostics(_diagnostics) {}
79
+ };
80
+ //#endregion
81
+ //#region src/testing/testing-sys.ts
82
+ function isTestingSystem(sys) {
83
+ return "diskReads" in sys && "diskWrites" in sys;
84
+ }
85
+ const createTestingSystem = () => {
86
+ let diskReads = 0;
87
+ let diskWrites = 0;
88
+ const sys = createSystem();
89
+ sys.platformPath = path$1;
90
+ sys.generateContentHash = (content, length) => {
91
+ let hash = createHash("sha1").update(content).digest("hex").toLowerCase();
92
+ if (typeof length === "number") hash = hash.slice(0, length);
93
+ return Promise.resolve(hash);
94
+ };
95
+ const wrapRead = (fn) => {
96
+ const orgFn = fn;
97
+ return (...args) => {
98
+ diskReads++;
99
+ return orgFn.apply(orgFn, args);
100
+ };
101
+ };
102
+ const wrapWrite = (fn) => {
103
+ const orgFn = fn;
104
+ return (...args) => {
105
+ diskWrites++;
106
+ return orgFn.apply(orgFn, args);
107
+ };
108
+ };
109
+ sys.access = wrapRead(sys.access);
110
+ sys.accessSync = wrapRead(sys.accessSync);
111
+ sys.homeDir = wrapRead(sys.homeDir);
112
+ sys.readFile = wrapRead(sys.readFile);
113
+ sys.readFileSync = wrapRead(sys.readFileSync);
114
+ sys.readDir = wrapRead(sys.readDir);
115
+ sys.readDirSync = wrapRead(sys.readDirSync);
116
+ sys.stat = wrapRead(sys.stat);
117
+ sys.statSync = wrapRead(sys.statSync);
118
+ sys.copyFile = wrapWrite(sys.copyFile);
119
+ sys.createDir = wrapWrite(sys.createDir);
120
+ sys.createDirSync = wrapWrite(sys.createDirSync);
121
+ sys.removeFile = wrapWrite(sys.removeFile);
122
+ sys.removeFileSync = wrapWrite(sys.removeFileSync);
123
+ sys.writeFile = wrapWrite(sys.writeFile);
124
+ sys.writeFileSync = wrapWrite(sys.writeFileSync);
125
+ sys.getCompilerExecutingPath = () => "bin/stencil.js";
126
+ Object.defineProperties(sys, {
127
+ diskReads: {
128
+ get() {
129
+ return diskReads;
130
+ },
131
+ set(val) {
132
+ diskReads = val;
133
+ }
134
+ },
135
+ diskWrites: {
136
+ get() {
137
+ return diskWrites;
138
+ },
139
+ set(val) {
140
+ diskWrites = val;
141
+ }
142
+ }
143
+ });
144
+ if (!isTestingSystem(sys)) throw new Error("could not generate TestingSystem");
145
+ return sys;
146
+ };
147
+ //#endregion
148
+ //#region src/testing/mocks.ts
149
+ /**
150
+ * Generates a stub {@link d.ComponentCompilerMeta}. This function uses sensible defaults for the initial stub. However,
151
+ * any field in the object may be overridden via the `overrides` argument.
152
+ * @param overrides a partial implementation of `ComponentCompilerMeta`. Any provided fields will override the
153
+ * defaults provided by this function.
154
+ * @returns the stubbed `ComponentCompilerMeta`
155
+ */
156
+ const mockComponentMeta = (overrides = {}) => ({
157
+ assetsDirs: [],
158
+ attachInternalsMemberName: null,
159
+ attachInternalsCustomStates: [],
160
+ componentClassName: "StubCmp",
161
+ dependencies: [],
162
+ dependents: [],
163
+ deserializers: [],
164
+ directDependencies: [],
165
+ directDependents: [],
166
+ docs: {
167
+ text: "docs",
168
+ tags: []
169
+ },
170
+ doesExtend: false,
171
+ elementRef: "",
172
+ encapsulation: "none",
173
+ events: [],
174
+ excludeFromCollection: false,
175
+ formAssociated: false,
176
+ hasAttribute: false,
177
+ hasAttributeChangedCallbackFn: false,
178
+ hasComponentDidLoadFn: false,
179
+ hasComponentDidRenderFn: false,
180
+ hasComponentDidUpdateFn: false,
181
+ hasComponentShouldUpdateFn: false,
182
+ hasComponentWillLoadFn: false,
183
+ hasComponentWillRenderFn: false,
184
+ hasComponentWillUpdateFn: false,
185
+ hasConnectedCallbackFn: false,
186
+ hasDeserializer: false,
187
+ hasDisconnectedCallbackFn: false,
188
+ hasElement: false,
189
+ hasEvent: false,
190
+ hasLifecycle: false,
191
+ hasListener: false,
192
+ hasListenerTarget: false,
193
+ hasListenerTargetBody: false,
194
+ hasListenerTargetDocument: false,
195
+ hasListenerTargetParent: false,
196
+ hasListenerTargetWindow: false,
197
+ hasMember: false,
198
+ hasMethod: false,
199
+ hasMode: false,
200
+ hasModernPropertyDecls: false,
201
+ hasProp: false,
202
+ hasPropBoolean: false,
203
+ hasPropMutable: false,
204
+ hasPropNumber: false,
205
+ hasPropString: false,
206
+ hasReflect: false,
207
+ hasRenderFn: false,
208
+ hasSerializer: false,
209
+ hasSlot: false,
210
+ hasState: false,
211
+ hasStyle: false,
212
+ hasVdomAttribute: false,
213
+ hasVdomClass: false,
214
+ hasVdomFunctional: false,
215
+ hasVdomKey: false,
216
+ hasVdomListener: false,
217
+ hasVdomPropOrAttr: false,
218
+ hasVdomRef: false,
219
+ hasVdomRender: false,
220
+ hasVdomStyle: false,
221
+ hasVdomText: false,
222
+ hasVdomXlink: false,
223
+ hasWatchCallback: false,
224
+ htmlAttrNames: [],
225
+ htmlParts: [],
226
+ htmlTagNames: [],
227
+ internal: false,
228
+ isCollectionDependency: false,
229
+ isPlain: false,
230
+ isUpdateable: false,
231
+ jsFilePath: "/some/stubbed/path/my-component.js",
232
+ listeners: [],
233
+ methods: [],
234
+ potentialCmpRefs: [],
235
+ properties: [],
236
+ serializers: [],
237
+ shadowDelegatesFocus: false,
238
+ slotAssignment: null,
239
+ sourceFilePath: "/some/stubbed/path/my-component.tsx",
240
+ sourceMapPath: "/some/stubbed/path/my-component.js.map",
241
+ states: [],
242
+ styleDocs: [],
243
+ styles: [],
244
+ tagName: "stub-cmp",
245
+ virtualProperties: [],
246
+ watchers: [],
247
+ ...overrides
248
+ });
249
+ /**
250
+ * Creates a mock instance of an internal, validated Stencil configuration object
251
+ * the caller
252
+ * @param overrides a partial implementation of `ValidatedConfig`. Any provided fields will override the defaults
253
+ * provided by this function.
254
+ * @returns the mock Stencil configuration
255
+ */
256
+ function mockValidatedConfig(overrides = {}) {
257
+ const baseConfig = mockConfig(overrides);
258
+ const rootDir = path.resolve("/");
259
+ return {
260
+ ...baseConfig,
261
+ buildEs5: false,
262
+ cacheDir: ".stencil",
263
+ devMode: true,
264
+ devServer: {},
265
+ extras: {},
266
+ fsNamespace: "testing",
267
+ hashFileNames: false,
268
+ hashedFileNameLength: 8,
269
+ hydratedFlag: null,
270
+ logLevel: "info",
271
+ logger: mockLogger(),
272
+ minifyCss: false,
273
+ minifyJs: false,
274
+ namespace: "Testing",
275
+ outputTargets: baseConfig.outputTargets ?? [],
276
+ packageJsonFilePath: path.join(rootDir, "package.json"),
277
+ rootDir,
278
+ sourceMap: true,
279
+ srcDir: "/src",
280
+ srcIndexHtml: "src/index.html",
281
+ suppressReservedPublicNameWarnings: false,
282
+ sys: createTestingSystem(),
283
+ testing: {},
284
+ transformAliasedImportPaths: true,
285
+ rollupConfig: {
286
+ inputOptions: {},
287
+ outputOptions: {}
288
+ },
289
+ validatePrimaryPackageOutputTarget: false,
290
+ ...overrides
291
+ };
292
+ }
293
+ /**
294
+ * Creates a mock instance of a Stencil configuration entity. The mocked configuration has no guarantees around the
295
+ * types/validity of its data.
296
+ * @param overrides a partial implementation of `UnvalidatedConfig`. Any provided fields will override the defaults
297
+ * provided by this function.
298
+ * @returns the mock Stencil configuration
299
+ */
300
+ function mockConfig(overrides = {}) {
301
+ const rootDir = path.resolve("/");
302
+ let { sys } = overrides;
303
+ if (!sys) sys = createTestingSystem();
304
+ sys.getCurrentDirectory = () => rootDir;
305
+ return {
306
+ _isTesting: true,
307
+ buildAppCore: false,
308
+ buildDist: true,
309
+ buildEs5: false,
310
+ bundles: null,
311
+ devMode: true,
312
+ enableCache: false,
313
+ extras: {},
314
+ globalScript: null,
315
+ hashFileNames: false,
316
+ logger: new TestingLogger(),
317
+ maxConcurrentWorkers: 0,
318
+ minifyCss: false,
319
+ minifyJs: false,
320
+ namespace: "Testing",
321
+ nodeResolve: { customResolveOptions: {} },
322
+ outputTargets: null,
323
+ rollupPlugins: {
324
+ before: [],
325
+ after: []
326
+ },
327
+ rootDir,
328
+ sourceMap: true,
329
+ suppressReservedPublicNameWarnings: false,
330
+ sys,
331
+ testing: null,
332
+ validateTypes: false,
333
+ ...overrides
334
+ };
335
+ }
336
+ /**
337
+ * Creates a configuration object used to bootstrap a Stencil task invocation
338
+ *
339
+ * Several fields are intentionally undefined for this entity. While it would be trivial to stub them out, this mock
340
+ * generation function operates under the assumption that entities like loggers and compiler system abstractions will
341
+ * be shared by multiple entities in a test suite, who should provide those entities to this function
342
+ *
343
+ * @param overrides the properties on the default entity to manually override
344
+ * @returns the default configuration initialization object, with any overrides applied
345
+ */
346
+ const mockLoadConfigInit = (overrides) => {
347
+ return {
348
+ config: {},
349
+ configPath: void 0,
350
+ initTsConfig: true,
351
+ logger: void 0,
352
+ sys: void 0,
353
+ ...overrides
354
+ };
355
+ };
356
+ function mockCompilerCtx(config) {
357
+ const innerConfig = config || mockValidatedConfig();
358
+ const compilerCtx = {
359
+ version: 1,
360
+ activeBuildId: 0,
361
+ activeDirsAdded: [],
362
+ activeDirsDeleted: [],
363
+ activeFilesAdded: [],
364
+ activeFilesDeleted: [],
365
+ activeFilesUpdated: [],
366
+ addWatchDir: noop,
367
+ addWatchFile: noop,
368
+ cachedGlobalStyle: null,
369
+ changedFiles: /* @__PURE__ */ new Set(),
370
+ changedModules: /* @__PURE__ */ new Set(),
371
+ collections: [],
372
+ compilerOptions: null,
373
+ cache: null,
374
+ cssModuleImports: /* @__PURE__ */ new Map(),
375
+ events: buildEvents(),
376
+ fs: null,
377
+ hasSuccessfulBuild: false,
378
+ isActivelyBuilding: false,
379
+ lastBuildResults: null,
380
+ moduleMap: /* @__PURE__ */ new Map(),
381
+ nodeMap: /* @__PURE__ */ new WeakMap(),
382
+ reset: noop,
383
+ resolvedCollections: /* @__PURE__ */ new Set(),
384
+ rollupCache: /* @__PURE__ */ new Map(),
385
+ rollupCacheHydrate: null,
386
+ rollupCacheLazy: null,
387
+ rollupCacheNative: null,
388
+ styleModeNames: /* @__PURE__ */ new Set(),
389
+ worker: createWorkerContext(innerConfig.sys)
390
+ };
391
+ Object.defineProperty(compilerCtx, "fs", { get() {
392
+ if (this._fs == null) this._fs = createInMemoryFs(innerConfig.sys);
393
+ return this._fs;
394
+ } });
395
+ Object.defineProperty(compilerCtx, "cache", { get() {
396
+ if (this._cache == null) this._cache = mockCache(innerConfig, compilerCtx);
397
+ return this._cache;
398
+ } });
399
+ return compilerCtx;
400
+ }
401
+ function mockBuildCtx(config, compilerCtx) {
402
+ const validatedConfig = config || mockValidatedConfig();
403
+ return new BuildContext(validatedConfig, compilerCtx || mockCompilerCtx(validatedConfig));
404
+ }
405
+ function mockCache(config, compilerCtx) {
406
+ config.enableCache = true;
407
+ const cache = new Cache(config, compilerCtx.fs);
408
+ cache.initCacheDir();
409
+ return cache;
410
+ }
411
+ function mockLogger() {
412
+ return new TestingLogger();
413
+ }
414
+ /**
415
+ * Create a {@link d.CompilerSystem} entity for testing the compiler.
416
+ *
417
+ * This function acts as a thin wrapper around a {@link TestingSystem} entity creation. It exists to provide a logical
418
+ * place in the codebase where we might expect Stencil engineers to reach for when attempting to mock a
419
+ * {@link d.CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
420
+ * reconsider if this wrapper is necessary.
421
+ *
422
+ * @returns a System instance for testing purposes.
423
+ */
424
+ function mockCompilerSystem() {
425
+ return createTestingSystem();
426
+ }
427
+ function mockDocument(html = null) {
428
+ return new MockWindow(html).document;
429
+ }
430
+ function mockWindow(html) {
431
+ return new MockWindow(html);
432
+ }
433
+ /**
434
+ * This gives you a mock Module, an interface which is the internal compiler
435
+ * representation of a module. It includes a bunch of information necessary for
436
+ * compilation, this mock basically sets sane defaults for all those values.
437
+ *
438
+ * @param mod is an override module that you can supply to set particular values
439
+ * @returns a module object ready to use in tests!
440
+ */
441
+ const mockModule = (mod = {}) => ({
442
+ cmps: [],
443
+ isExtended: false,
444
+ isMixin: false,
445
+ hasExportableMixins: false,
446
+ coreRuntimeApis: [],
447
+ outputTargetCoreRuntimeApis: {},
448
+ collectionName: "",
449
+ dtsFilePath: "",
450
+ excludeFromCollection: false,
451
+ externalImports: [],
452
+ htmlAttrNames: [],
453
+ htmlTagNames: [],
454
+ htmlParts: [],
455
+ isCollectionDependency: false,
456
+ isLegacy: false,
457
+ jsFilePath: "",
458
+ localImports: [],
459
+ functionalComponentDeps: [],
460
+ originalImports: [],
461
+ originalCollectionComponentPath: "",
462
+ potentialCmpRefs: [],
463
+ sourceFilePath: "",
464
+ staticSourceFile: "",
465
+ staticSourceFileText: "",
466
+ sourceMapPath: "",
467
+ sourceMapFileText: "",
468
+ hasVdomAttribute: false,
469
+ hasVdomClass: false,
470
+ hasVdomFunctional: false,
471
+ hasVdomKey: false,
472
+ hasVdomListener: false,
473
+ hasVdomPropOrAttr: false,
474
+ hasVdomRef: false,
475
+ hasVdomRender: false,
476
+ hasVdomStyle: false,
477
+ hasVdomText: false,
478
+ hasVdomXlink: false,
479
+ ...mod
480
+ });
481
+ //#endregion
482
+ //#region src/testing/platform/testing-constants.ts
483
+ const styles = /* @__PURE__ */ new Map();
484
+ const modeResolutionChain = [];
485
+ /**
486
+ * A mapping of custom element tags (e.g. `my-component`) to their constructor
487
+ */
488
+ const cstrs = /* @__PURE__ */ new Map();
489
+ /**
490
+ * A collection of callbacks to run on a NodeJS process 'tick'
491
+ */
492
+ const queuedTicks = [];
493
+ const queuedWriteTasks = [];
494
+ const queuedReadTasks = [];
495
+ const moduleLoaded = /* @__PURE__ */ new Map();
496
+ const queuedLoadModules = [];
497
+ /**
498
+ * A collection of errors that were detected to surface during the rendering process
499
+ */
500
+ const caughtErrors = [];
501
+ //#endregion
502
+ //#region src/testing/platform/testing-build.ts
503
+ const Build = {
504
+ isDev: true,
505
+ isBrowser: false,
506
+ isServer: true,
507
+ isTesting: true
508
+ };
509
+ //#endregion
510
+ //#region src/testing/platform/testing-host-ref.ts
511
+ /**
512
+ * Retrieve the data structure tracking the component by its runtime reference
513
+ * @param elm the reference to the element
514
+ * @returns the corresponding Stencil reference data structure, or undefined if one cannot be found
515
+ */
516
+ const getHostRef = (elm) => {
517
+ if (elm.__stencil__getHostRef) return elm.__stencil__getHostRef();
518
+ };
519
+ /**
520
+ * Add the provided `hostRef` instance to the global {@link hostRefs} map, using the provided `lazyInstance` as a key.
521
+ * @param lazyInstance a Stencil component instance
522
+ * @param hostRef an optional reference to Stencil's tracking data for the component. If none is provided, one will be created.
523
+ * @throws if the provided `lazyInstance` coerces to `null`, or if the `lazyInstance` does not have a `constructor`
524
+ * property
525
+ */
526
+ const registerInstance = (lazyInstance, hostRef) => {
527
+ if (lazyInstance == null || lazyInstance.constructor == null) throw new Error(`Invalid component constructor`);
528
+ if (hostRef == null) {
529
+ const Cstr = lazyInstance.constructor;
530
+ const tagName = Cstr.COMPILER_META && Cstr.COMPILER_META.tagName ? Cstr.COMPILER_META.tagName : "div";
531
+ const elm = document.createElement(tagName);
532
+ registerHost(elm, {
533
+ $flags$: 0,
534
+ $tagName$: tagName
535
+ });
536
+ hostRef = getHostRef(elm);
537
+ }
538
+ lazyInstance.__stencil__getHostRef = () => hostRef;
539
+ hostRef.$lazyInstance$ = lazyInstance;
540
+ if (hostRef.$cmpMeta$?.$flags$ & CMP_FLAGS.hasModernPropertyDecls && (BUILD.state || BUILD.prop)) reWireGetterSetter(lazyInstance, hostRef);
541
+ const Cstr = lazyInstance.constructor;
542
+ const allEvents = [];
543
+ const seenEventMethods = /* @__PURE__ */ new Set();
544
+ if (Cstr.COMPILER_META && Cstr.COMPILER_META.events) Cstr.COMPILER_META.events.forEach((event) => {
545
+ if (!seenEventMethods.has(event.method)) {
546
+ allEvents.push(event);
547
+ seenEventMethods.add(event.method);
548
+ }
549
+ });
550
+ let currentProto = Object.getPrototypeOf(Cstr);
551
+ while (currentProto && currentProto !== Function.prototype && currentProto.name) {
552
+ if (typeof currentProto.events === "object" && Array.isArray(currentProto.events)) currentProto.events.forEach((event) => {
553
+ if (!seenEventMethods.has(event.method)) {
554
+ allEvents.push(event);
555
+ seenEventMethods.add(event.method);
556
+ }
557
+ });
558
+ currentProto = Object.getPrototypeOf(currentProto);
559
+ }
560
+ allEvents.forEach((eventMeta) => {
561
+ if (!lazyInstance[eventMeta.method]) {
562
+ let flags = 0;
563
+ if (eventMeta.bubbles) flags |= EVENT_FLAGS.Bubbles;
564
+ if (eventMeta.composed) flags |= EVENT_FLAGS.Composed;
565
+ if (eventMeta.cancelable) flags |= EVENT_FLAGS.Cancellable;
566
+ lazyInstance[eventMeta.method] = createEvent(lazyInstance, eventMeta.name, flags);
567
+ }
568
+ });
569
+ };
570
+ /**
571
+ * Create a new {@link d.HostRef} instance to the global {@link hostRefs} map, using the provided `elm` as a key.
572
+ * @param elm an HTMLElement instance associated with the Stencil component
573
+ * @param cmpMeta the component compiler metadata associated with the component
574
+ */
575
+ const registerHost = (elm, cmpMeta) => {
576
+ const hostRef = {
577
+ $flags$: 0,
578
+ $hostElement$: elm,
579
+ $cmpMeta$: cmpMeta,
580
+ $instanceValues$: /* @__PURE__ */ new Map(),
581
+ $serializerValues$: /* @__PURE__ */ new Map(),
582
+ $renderCount$: 0
583
+ };
584
+ hostRef.$fetchedCbList$ = [];
585
+ hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
586
+ hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
587
+ elm["s-p"] = [];
588
+ elm["s-rc"] = [];
589
+ elm.__stencil__getHostRef = () => hostRef;
590
+ };
591
+ const setErrorHandler = (handler) => handler;
592
+ //#endregion
593
+ //#region src/testing/platform/testing-task-queue.ts
594
+ /**
595
+ * Reset the various data structures related to the testing rendering pipeline
596
+ */
597
+ function resetTaskQueue() {
598
+ queuedTicks.length = 0;
599
+ queuedWriteTasks.length = 0;
600
+ queuedReadTasks.length = 0;
601
+ moduleLoaded.clear();
602
+ queuedLoadModules.length = 0;
603
+ caughtErrors.length = 0;
604
+ }
605
+ /**
606
+ * Execute the callbacks in {@link queuedTicks} on the next NodeJS tick.
607
+ *
608
+ * Callbacks are invoked in the order that they appear in `queuedTasks` at the time this function is invoked.
609
+ * Async callbacks are not `await`ed.
610
+ *
611
+ * Any callbacks that are added to `queuedTasks` while this function is running are scheduled to be flushed on the
612
+ * next tick.
613
+ */
614
+ function flushTicks() {
615
+ return new Promise((resolve, reject) => {
616
+ function drain() {
617
+ try {
618
+ if (queuedTicks.length > 0) {
619
+ const writeTasks = queuedTicks.slice();
620
+ queuedTicks.length = 0;
621
+ let cb;
622
+ while (cb = writeTasks.shift()) cb(Date.now());
623
+ }
624
+ if (queuedTicks.length > 0) process.nextTick(drain);
625
+ else resolve();
626
+ } catch (e) {
627
+ reject(`flushTicks: ${e}`);
628
+ }
629
+ }
630
+ process.nextTick(drain);
631
+ });
632
+ }
633
+ /**
634
+ * Push a RequestAnimationFrame callback onto the {@link queuedWriteTasks} data structure
635
+ * @param cb the callback to push onto `queuedWriteTasks`
636
+ */
637
+ function writeTask(cb) {
638
+ queuedWriteTasks.push(cb);
639
+ }
640
+ /**
641
+ * Push a RequestAnimationFrame callback onto the {@link queuedReadTasks} data structure
642
+ * @param cb the callback to push onto `queuedReadTasks`
643
+ */
644
+ function readTask(cb) {
645
+ queuedReadTasks.push(cb);
646
+ }
647
+ /**
648
+ * Flush the {@link queuedReadTasks} and {@link queuedWriteTasks} data structures on the next NodeJS process tick.
649
+ *
650
+ * The read task queue is drained first, followed by the write task queue.
651
+ * For each queue:
652
+ * - Each task is processed in the order it is found in its respective data structure at the time `queuedReadTasks` and
653
+ * `queuedWriteTasks` are read (note: these queues are not read at the same time).
654
+ * - When a task queue is processed, it is marked as empty before acting on the entries in the queue.
655
+ * - Items added to either queue after it has been read for processing will be handled on the subsequent tick.
656
+ * - Async items will be `await`ed
657
+ */
658
+ function flushQueue() {
659
+ return new Promise((resolve, reject) => {
660
+ async function drain() {
661
+ try {
662
+ if (queuedReadTasks.length > 0) {
663
+ const readTasks = queuedReadTasks.slice();
664
+ queuedReadTasks.length = 0;
665
+ let cb;
666
+ while (cb = readTasks.shift()) {
667
+ const result = cb(Date.now());
668
+ if (result != null && typeof result.then === "function") await result;
669
+ }
670
+ }
671
+ if (queuedWriteTasks.length > 0) {
672
+ const writeTasks = queuedWriteTasks.slice();
673
+ queuedWriteTasks.length = 0;
674
+ let cb;
675
+ while (cb = writeTasks.shift()) {
676
+ const result = cb(Date.now());
677
+ if (result != null && typeof result.then === "function") await result;
678
+ }
679
+ }
680
+ if (queuedReadTasks.length + queuedWriteTasks.length > 0) process.nextTick(drain);
681
+ else resolve();
682
+ } catch (e) {
683
+ reject(`flushQueue: ${e}`);
684
+ }
685
+ }
686
+ process.nextTick(drain);
687
+ });
688
+ }
689
+ async function flushAll() {
690
+ while (queuedTicks.length + queuedLoadModules.length + queuedWriteTasks.length + queuedReadTasks.length > 0) {
691
+ await flushTicks();
692
+ await flushLoadModule();
693
+ await flushQueue();
694
+ }
695
+ if (caughtErrors.length > 0) {
696
+ const err = caughtErrors[0];
697
+ if (err == null) throw new Error("Error!");
698
+ if (typeof err === "string") throw new Error(err);
699
+ throw err;
700
+ }
701
+ return new Promise((resolve) => process.nextTick(resolve));
702
+ }
703
+ function flushLoadModule(bundleId) {
704
+ return new Promise((resolve, reject) => {
705
+ try {
706
+ process.nextTick(() => {
707
+ if (bundleId != null) {
708
+ for (let i = 0; i < queuedLoadModules.length; i++) if (queuedLoadModules[i].bundleId === bundleId) {
709
+ queuedLoadModules[i].resolve();
710
+ queuedLoadModules.splice(i, 1);
711
+ i--;
712
+ }
713
+ } else {
714
+ let queuedLoadModule;
715
+ while (queuedLoadModule = queuedLoadModules.shift()) queuedLoadModule.resolve();
716
+ }
717
+ resolve();
718
+ });
719
+ } catch (e) {
720
+ reject(`flushLoadModule: ${e}`);
721
+ }
722
+ });
723
+ }
724
+ //#endregion
725
+ //#region src/testing/platform/testing-window.ts
726
+ const isVitestEnvironment = typeof process !== "undefined" && process.env?.VITEST;
727
+ const existingWindow = typeof globalThis !== "undefined" && globalThis.window;
728
+ const win = isVitestEnvironment && existingWindow ? existingWindow : setupGlobal(global);
729
+ const plt = {
730
+ $flags$: 0,
731
+ $resourcesUrl$: "",
732
+ jmp: (h) => h(),
733
+ raf: (h) => requestAnimationFrame(h),
734
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
735
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
736
+ ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
737
+ };
738
+ /**
739
+ * Helper function to programmatically set shadow DOM support in testing scenarios.
740
+ *
741
+ * This function modifies the global {@link supportsShadow} variable.
742
+ *
743
+ * @param supports `true` if shadow DOM is supported, `false` otherwise
744
+ */
745
+ const setSupportsShadowDom = (supports) => {};
746
+ /**
747
+ * Resets global testing variables and collections, so that a new set of tests can be started with a "clean slate".
748
+ *
749
+ * It is expected that this function be called between spec tests, and should be automatically configured by Stencil to
750
+ * do so.
751
+ *
752
+ * @param defaults default options for the {@link d.PlatformRuntime} used during testing. The values in this object
753
+ * with be assigned to the global {@link plt} object used during testing.
754
+ */
755
+ function resetPlatform(defaults = {}) {
756
+ if (win && typeof win.close === "function") win.close();
757
+ styles.clear();
758
+ plt.$flags$ = 0;
759
+ Object.assign(plt, defaults);
760
+ if (plt.$orgLocNodes$ != null) {
761
+ plt.$orgLocNodes$.clear();
762
+ plt.$orgLocNodes$ = void 0;
763
+ }
764
+ resetTaskQueue();
765
+ stopAutoApplyChanges();
766
+ cstrs.clear();
767
+ }
768
+ let isAutoApplyingChanges = false;
769
+ let autoApplyTimer = void 0;
770
+ /**
771
+ * Cancels the JavaScript task of automatically flushing the render queue & applying DOM changes in tests
772
+ */
773
+ function stopAutoApplyChanges() {
774
+ isAutoApplyingChanges = false;
775
+ if (autoApplyTimer) {
776
+ clearTimeout(autoApplyTimer);
777
+ autoApplyTimer = void 0;
778
+ }
779
+ }
780
+ /**
781
+ * Creates a JavaScript task to flush the render pipeline without the user having to do so manually in their tests.
782
+ */
783
+ async function startAutoApplyChanges() {
784
+ isAutoApplyingChanges = true;
785
+ flushAll().then(() => {
786
+ if (isAutoApplyingChanges) autoApplyTimer = setTimeout(() => {
787
+ startAutoApplyChanges();
788
+ }, 100);
789
+ });
790
+ }
791
+ /**
792
+ * Registers a collection of component constructors with the global {@link cstrs} data structure
793
+ * @param Cstrs the component constructors to register
794
+ */
795
+ const registerComponents = (Cstrs) => {
796
+ Cstrs.filter((Cstr) => Cstr.COMPILER_META).forEach((Cstr) => {
797
+ cstrs.set(Cstr.COMPILER_META.tagName, Cstr);
798
+ });
799
+ };
800
+ /**
801
+ * Add the provided component constructor, `Cstr`, to the {@link moduleLoaded} mapping, using the provided `bundleId`
802
+ * as the key
803
+ * @param bundleId the bundle identifier to use to store/retrieve the component constructor
804
+ * @param Cstr the component constructor to store
805
+ */
806
+ function registerModule(bundleId, Cstr) {
807
+ moduleLoaded.set(bundleId, Cstr);
808
+ }
809
+ //#endregion
810
+ //#region src/testing/platform/index.ts
811
+ const setMode = (handler) => {
812
+ modeResolutionChain.length = 0;
813
+ modeResolutionChain.push(handler);
814
+ };
815
+ //#endregion
816
+ //#region src/testing/reset-build-conditionals.ts
817
+ /**
818
+ * Reset build conditionals used for testing to a known "good state".
819
+ *
820
+ * This function does not return a value, but rather mutates its argument in place.
821
+ * Certain values are set to `true` or `false` for testing purpose (see this function's implementation for the full
822
+ * list). Build conditional options _not_ in that list that are set to `true` when this function is invoked will remain
823
+ * set to `true`.
824
+ *
825
+ * @param b the build conditionals to reset.
826
+ */
827
+ function resetBuildConditionals(b) {
828
+ Object.keys(b).forEach((key) => {
829
+ b[key] = true;
830
+ });
831
+ b.isDev = true;
832
+ b.isTesting = true;
833
+ b.isDebug = false;
834
+ b.lazyLoad = true;
835
+ b.member = true;
836
+ b.reflect = true;
837
+ b.scoped = true;
838
+ b.shadowDom = true;
839
+ b.slotRelocation = true;
840
+ b.asyncLoading = true;
841
+ b.svg = true;
842
+ b.updatable = true;
843
+ b.vdomAttribute = true;
844
+ b.vdomClass = true;
845
+ b.vdomFunctional = true;
846
+ b.vdomKey = true;
847
+ b.vdomPropOrAttr = true;
848
+ b.vdomRef = true;
849
+ b.vdomListener = true;
850
+ b.vdomStyle = true;
851
+ b.vdomText = true;
852
+ b.vdomXlink = true;
853
+ b.allRenderFn = false;
854
+ b.devTools = false;
855
+ b.hydrateClientSide = false;
856
+ b.hydrateServerSide = false;
857
+ b.cssAnnotations = false;
858
+ b.style = false;
859
+ b.hydratedAttribute = false;
860
+ b.hydratedClass = true;
861
+ b.invisiblePrehydration = true;
862
+ b.appendChildSlotFix = false;
863
+ b.cloneNodeFix = false;
864
+ b.hotModuleReplacement = false;
865
+ b.scopedSlotTextContentFix = false;
866
+ b.slotChildNodesFix = false;
867
+ b.experimentalSlotFixes = false;
868
+ b.experimentalScopedSlotChanges = false;
869
+ }
870
+ //#endregion
871
+ //#region src/testing/spec-page.ts
872
+ /**
873
+ * Generates a random number for use in generating a bundle id
874
+ * @returns a random number between 100000 and 999999
875
+ */
876
+ const generateRandBundleId = () => Math.round(Math.random() * 899999) + 1e5;
877
+ /**
878
+ * Creates a new spec page for unit testing
879
+ * @param opts the options to apply to the spec page that influence its configuration and operation
880
+ * @returns the created spec page
881
+ */
882
+ async function newSpecPage(opts) {
883
+ if (opts == null) throw new Error(`NewSpecPageOptions required`);
884
+ resetPlatform(opts.platform ?? {});
885
+ resetBuildConditionals(BUILD);
886
+ if (Array.isArray(opts.components)) registerComponents(opts.components);
887
+ if (opts.hydrateClientSide) opts.includeAnnotations = true;
888
+ if (opts.hydrateServerSide) {
889
+ opts.includeAnnotations = true;
890
+ setSupportsShadowDom(false);
891
+ } else {
892
+ opts.includeAnnotations = !!opts.includeAnnotations;
893
+ if (opts.supportsShadowDom === false) setSupportsShadowDom(false);
894
+ else setSupportsShadowDom(true);
895
+ }
896
+ BUILD.cssAnnotations = opts.includeAnnotations;
897
+ const cmpTags = /* @__PURE__ */ new Set();
898
+ win["__stencil_spec_options"] = opts;
899
+ const doc = win.document;
900
+ const page = {
901
+ win,
902
+ doc,
903
+ body: doc.body,
904
+ build: BUILD,
905
+ styles,
906
+ setContent: (html) => {
907
+ doc.body.innerHTML = html;
908
+ return flushAll();
909
+ },
910
+ waitForChanges: flushAll,
911
+ flushLoadModule,
912
+ flushQueue
913
+ };
914
+ const lazyBundles = opts.components.map((Cstr) => {
915
+ /**
916
+ * just pass through functional components that don't have styles nor any other metadata
917
+ */
918
+ if (Cstr.COMPILER_META == null) return formatLazyBundleRuntimeMeta(`fc.${generateRandBundleId()}`, []);
919
+ cmpTags.add(Cstr.COMPILER_META.tagName);
920
+ Cstr.isProxied = false;
921
+ proxyComponentLifeCycles(Cstr);
922
+ const bundleId = `${Cstr.COMPILER_META.tagName}.${generateRandBundleId()}`;
923
+ const stylesMeta = Cstr.COMPILER_META.styles;
924
+ if (Array.isArray(stylesMeta)) {
925
+ if (stylesMeta.length > 1) {
926
+ const styleModes = {};
927
+ stylesMeta.forEach((style) => {
928
+ styleModes[style.modeName] = style.styleStr;
929
+ });
930
+ Cstr.style = styleModes;
931
+ } else if (stylesMeta.length === 1) Cstr.style = stylesMeta[0].styleStr;
932
+ }
933
+ registerModule(bundleId, Cstr);
934
+ return formatLazyBundleRuntimeMeta(bundleId, [Cstr.COMPILER_META]);
935
+ });
936
+ const cmpBuild = getBuildFeatures(opts.components.filter((Cstr) => Cstr.COMPILER_META != null).map((Cstr) => Cstr.COMPILER_META));
937
+ if (opts.strictBuild) Object.assign(BUILD, cmpBuild);
938
+ else Object.keys(cmpBuild).forEach((key) => {
939
+ if (cmpBuild[key] === true) BUILD[key] = true;
940
+ });
941
+ BUILD.asyncLoading = true;
942
+ if (opts.hydrateClientSide) {
943
+ BUILD.hydrateClientSide = true;
944
+ BUILD.hydrateServerSide = false;
945
+ } else if (opts.hydrateServerSide) {
946
+ BUILD.hydrateServerSide = true;
947
+ BUILD.hydrateClientSide = false;
948
+ }
949
+ BUILD.cloneNodeFix = false;
950
+ BUILD.shadowDomShim = false;
951
+ BUILD.attachStyles = !!opts.attachStyles;
952
+ if (typeof opts.url === "string") page.win.location.href = opts.url;
953
+ if (typeof opts.direction === "string") page.doc.documentElement.setAttribute("dir", opts.direction);
954
+ if (typeof opts.language === "string") page.doc.documentElement.setAttribute("lang", opts.language);
955
+ if (typeof opts.cookie === "string") try {
956
+ page.doc.cookie = opts.cookie;
957
+ } catch {}
958
+ if (typeof opts.referrer === "string") try {
959
+ page.doc.referrer = opts.referrer;
960
+ } catch {}
961
+ if (typeof opts.userAgent === "string") try {
962
+ page.win.navigator.userAgent = opts.userAgent;
963
+ } catch {}
964
+ bootstrapLazy(lazyBundles);
965
+ if (typeof opts.template === "function") renderVdom({
966
+ $ancestorComponent$: void 0,
967
+ $flags$: 0,
968
+ $modeName$: void 0,
969
+ $cmpMeta$: {
970
+ $flags$: 0,
971
+ $tagName$: "body"
972
+ },
973
+ $hostElement$: page.body
974
+ }, opts.template());
975
+ else if (typeof opts.html === "string") page.body.innerHTML = opts.html;
976
+ if (opts.flushQueue !== false) await page.waitForChanges();
977
+ let rootComponent = null;
978
+ Object.defineProperty(page, "root", { get() {
979
+ if (rootComponent == null) rootComponent = findRootComponent(cmpTags, page.body);
980
+ if (rootComponent != null) return rootComponent;
981
+ const firstElementChild = page.body.firstElementChild;
982
+ if (firstElementChild != null) return firstElementChild;
983
+ return null;
984
+ } });
985
+ Object.defineProperty(page, "rootInstance", { get() {
986
+ const hostRef = getHostRef(page.root);
987
+ if (hostRef != null) return hostRef.$lazyInstance$;
988
+ return null;
989
+ } });
990
+ if (opts.hydrateServerSide) insertVdomAnnotations(doc, []);
991
+ if (opts.autoApplyChanges) {
992
+ startAutoApplyChanges();
993
+ page.waitForChanges = () => {
994
+ console.error("waitForChanges() cannot be used manually if the \"startAutoApplyChanges\" option is enabled");
995
+ return Promise.resolve();
996
+ };
997
+ }
998
+ return page;
999
+ }
1000
+ /**
1001
+ * A helper method that proxies Stencil lifecycle methods by mutating the provided component class
1002
+ * @param Cstr the component class whose lifecycle methods will be proxied
1003
+ */
1004
+ function proxyComponentLifeCycles(Cstr) {
1005
+ if (typeof Cstr.prototype?.__componentWillLoad === "function") {
1006
+ Cstr.prototype.componentWillLoad = Cstr.prototype.__componentWillLoad;
1007
+ Cstr.prototype.__componentWillLoad = null;
1008
+ }
1009
+ if (typeof Cstr.prototype?.__componentWillUpdate === "function") {
1010
+ Cstr.prototype.componentWillUpdate = Cstr.prototype.__componentWillUpdate;
1011
+ Cstr.prototype.__componentWillUpdate = null;
1012
+ }
1013
+ if (typeof Cstr.prototype?.__componentWillRender === "function") {
1014
+ Cstr.prototype.componentWillRender = Cstr.prototype.__componentWillRender;
1015
+ Cstr.prototype.__componentWillRender = null;
1016
+ }
1017
+ if (typeof Cstr.prototype?.componentWillLoad === "function") {
1018
+ Cstr.prototype.__componentWillLoad = Cstr.prototype.componentWillLoad;
1019
+ /** @returns the result from the original componentWillLoad */
1020
+ Cstr.prototype.componentWillLoad = function() {
1021
+ const result = this.__componentWillLoad();
1022
+ if (result != null && typeof result.then === "function") writeTask(() => result);
1023
+ else writeTask(() => Promise.resolve());
1024
+ return result;
1025
+ };
1026
+ }
1027
+ if (typeof Cstr.prototype?.componentWillUpdate === "function") {
1028
+ Cstr.prototype.__componentWillUpdate = Cstr.prototype.componentWillUpdate;
1029
+ /** @returns the result from the original componentWillUpdate */
1030
+ Cstr.prototype.componentWillUpdate = function() {
1031
+ const result = this.__componentWillUpdate();
1032
+ if (result != null && typeof result.then === "function") writeTask(() => result);
1033
+ else writeTask(() => Promise.resolve());
1034
+ return result;
1035
+ };
1036
+ }
1037
+ if (typeof Cstr.prototype?.componentWillRender === "function") {
1038
+ Cstr.prototype.__componentWillRender = Cstr.prototype.componentWillRender;
1039
+ /** @returns the result from the original componentWillRender */
1040
+ Cstr.prototype.componentWillRender = function() {
1041
+ const result = this.__componentWillRender();
1042
+ if (result != null && typeof result.then === "function") writeTask(() => result);
1043
+ else writeTask(() => Promise.resolve());
1044
+ return result;
1045
+ };
1046
+ }
1047
+ }
1048
+ /**
1049
+ * Return the first Element whose {@link Element#nodeName} property matches a tag found in the provided `cmpTags`
1050
+ * argument.
1051
+ *
1052
+ * If the `nodeName` property on the element matches any of the names found in the provided `cmpTags` argument, that
1053
+ * element is returned. If no match is found on the current element, the children will be inspected in a depth-first
1054
+ * search manner. This process continues until either:
1055
+ * - an element is found (and execution ends)
1056
+ * - no element is found after an exhaustive search
1057
+ *
1058
+ * @param cmpTags component tag names to use in the match criteria
1059
+ * @param node the node whose children are to be inspected
1060
+ * @returns An element whose name matches one of the strings in the provided `cmpTags`. If no match is found, `null` is
1061
+ * returned
1062
+ */
1063
+ function findRootComponent(cmpTags, node) {
1064
+ if (node != null) {
1065
+ const children = node.children;
1066
+ const childrenLength = children.length;
1067
+ for (let i = 0; i < childrenLength; i++) {
1068
+ const elm = children[i];
1069
+ if (cmpTags.has(elm.nodeName.toLowerCase())) return elm;
1070
+ }
1071
+ for (let i = 0; i < childrenLength; i++) {
1072
+ const r = findRootComponent(cmpTags, children[i]);
1073
+ if (r != null) return r;
1074
+ }
1075
+ }
1076
+ return null;
1077
+ }
1078
+ //#endregion
1079
+ //#region src/testing/testing-utils.ts
1080
+ /**
1081
+ * Shuffle an array using Fisher-Yates algorithm
1082
+ * http://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
1083
+ *
1084
+ * @param array - the array to shuffle
1085
+ * @returns the shuffled array
1086
+ */
1087
+ function shuffleArray(array) {
1088
+ let currentIndex = array.length;
1089
+ let temporaryValue;
1090
+ let randomIndex;
1091
+ while (0 !== currentIndex) {
1092
+ randomIndex = Math.floor(Math.random() * currentIndex);
1093
+ currentIndex -= 1;
1094
+ temporaryValue = array[currentIndex];
1095
+ array[currentIndex] = array[randomIndex];
1096
+ array[randomIndex] = temporaryValue;
1097
+ }
1098
+ return array;
1099
+ }
1100
+ /**
1101
+ * Utility for silencing `console` functions in tests.
1102
+ *
1103
+ * When this function is first called it grabs a reference to the `log`,
1104
+ * `error`, and `warn` functions on `console` and then returns a per-test setup
1105
+ * function which sets up a fresh set of mocks (via `jest.fn()`) and then
1106
+ * assigns them to each of these functions. This setup function will return a
1107
+ * reference to each of the three mock functions so tests can make assertions
1108
+ * about their calls and so on.
1109
+ *
1110
+ * Because references to the original `.log`, `.error`, and `.warn` functions
1111
+ * exist in closure within the function, it can use an `afterAll` call to clean
1112
+ * up after itself and ensure that the original implementations are restored
1113
+ * after the test suite finishes.
1114
+ *
1115
+ * An example of using this to silence log statements in a single test could look
1116
+ * like this:
1117
+ *
1118
+ * ```ts
1119
+ * describe("my-test-suite", () => {
1120
+ * const { setupConsoleMocks, teardownConsoleMocks } = setupConsoleMocker()
1121
+ *
1122
+ * it("should log a message", () => {
1123
+ * const { logMock } = setupConsoleMocks();
1124
+ * myFunctionWhichLogs(foo, bar);
1125
+ * expect(logMock).toBeCalledWith('my log message');
1126
+ * teardownConsoleMocks();
1127
+ * })
1128
+ * })
1129
+ * ```
1130
+ *
1131
+ * @returns a per-test mock setup function
1132
+ */
1133
+ function setupConsoleMocker() {
1134
+ const originalLog = console.log;
1135
+ const originalWarn = console.warn;
1136
+ const originalError = console.error;
1137
+ /**
1138
+ * Function to tear down console mocks where you're done with them! Ideally
1139
+ * this would be called right after the assertion you're looking to make in
1140
+ * your test.
1141
+ */
1142
+ function teardownConsoleMocks() {
1143
+ console.log = originalLog;
1144
+ console.warn = originalWarn;
1145
+ console.error = originalError;
1146
+ }
1147
+ afterAll(() => {
1148
+ teardownConsoleMocks();
1149
+ });
1150
+ function setupConsoleMocks() {
1151
+ const logMock = vi.fn();
1152
+ const warnMock = vi.fn();
1153
+ const errorMock = vi.fn();
1154
+ console.log = logMock;
1155
+ console.warn = warnMock;
1156
+ console.error = errorMock;
1157
+ return {
1158
+ logMock,
1159
+ warnMock,
1160
+ errorMock
1161
+ };
1162
+ }
1163
+ return {
1164
+ setupConsoleMocks,
1165
+ teardownConsoleMocks
1166
+ };
1167
+ }
1168
+ //#endregion
1169
+ export { Build, Env, Fragment, Host, Mixin, createEvent, createTestingSystem, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, h, mockBuildCtx, mockCompilerCtx, mockCompilerSystem, mockComponentMeta, mockConfig, mockDocument, mockLoadConfigInit, mockLogger, mockModule, mockValidatedConfig, mockWindow, newSpecPage, readTask, registerHost, registerInstance, setAssetPath, setErrorHandler, setMode, setupConsoleMocker, shuffleArray, writeTask };