@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,1947 @@
1
+ import { n as __require } from "./chunk-CjcI7cDX.mjs";
2
+ import "./client-DucyoZT4.mjs";
3
+ import { _ as isString, c as flatOne, p as isFunction, y as noop } from "./serialize-o-Sj1lvg.mjs";
4
+ import { bt as isGlob, dt as TASK_CANCELED_MSG, ft as buildError, ht as catchError, rt as normalizePath, vt as shouldIgnoreError } from "./validation-BR7tMYEv.mjs";
5
+ import path from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ import path$1 from "path";
8
+ import fs from "graceful-fs";
9
+ import chalk from "chalk";
10
+ import { createHash } from "node:crypto";
11
+ import * as os from "node:os";
12
+ import { cpus, freemem, platform, release, tmpdir, totalmem } from "node:os";
13
+ import * as parcelWatcher from "@parcel/watcher";
14
+ import { glob } from "glob";
15
+ import { promisify } from "util";
16
+ import semverLte from "semver/functions/lte.js";
17
+ import major from "semver/functions/major.js";
18
+ import satisfies from "semver/functions/satisfies.js";
19
+ import { cpus as cpus$1, tmpdir as tmpdir$1 } from "os";
20
+ import semverLt from "semver/functions/lt.js";
21
+ import { EventEmitter } from "events";
22
+ import * as cp from "child_process";
23
+ //#region src/compiler/events.ts
24
+ const buildEvents = () => {
25
+ const evCallbacks = [];
26
+ const off = (callback) => {
27
+ const index = evCallbacks.findIndex((ev) => ev.callback === callback);
28
+ if (index > -1) {
29
+ evCallbacks.splice(index, 1);
30
+ return true;
31
+ }
32
+ return false;
33
+ };
34
+ const on = (arg0, arg1) => {
35
+ if (typeof arg0 === "function") {
36
+ const eventName = null;
37
+ const callback = arg0;
38
+ evCallbacks.push({
39
+ eventName,
40
+ callback
41
+ });
42
+ return () => off(callback);
43
+ } else if (typeof arg0 === "string" && typeof arg1 === "function") {
44
+ const eventName = arg0.toLowerCase().trim();
45
+ const callback = arg1;
46
+ evCallbacks.push({
47
+ eventName,
48
+ callback
49
+ });
50
+ return () => off(callback);
51
+ }
52
+ return () => false;
53
+ };
54
+ const emit = (eventName, data) => {
55
+ const normalizedEventName = eventName.toLowerCase().trim();
56
+ const callbacks = evCallbacks.slice();
57
+ for (const ev of callbacks) if (ev.eventName == null) try {
58
+ ev.callback(eventName, data);
59
+ } catch (e) {
60
+ console.error(e);
61
+ }
62
+ else if (ev.eventName === normalizedEventName) try {
63
+ ev.callback(data);
64
+ } catch (e) {
65
+ console.error(e);
66
+ }
67
+ };
68
+ const unsubscribeAll = () => {
69
+ evCallbacks.length = 0;
70
+ };
71
+ return {
72
+ emit,
73
+ on,
74
+ unsubscribeAll
75
+ };
76
+ };
77
+ //#endregion
78
+ //#region src/declarations/stencil-public-compiler.ts
79
+ /**
80
+ * This sets the log level hierarchy for our terminal logger, ranging from
81
+ * most to least verbose.
82
+ *
83
+ * Ordering the levels like this lets us easily check whether we should log a
84
+ * message at a given time. For instance, if the log level is set to `'warn'`,
85
+ * then anything passed to the logger with level `'warn'` or `'error'` should
86
+ * be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
87
+ *
88
+ * If we have a current log level `currentLevel` and a message with level
89
+ * `msgLevel` is passed to the logger, we can determine whether or not we should
90
+ * log it by checking if the log level on the message is further up or at the
91
+ * same level in the hierarchy than `currentLevel`, like so:
92
+ *
93
+ * ```ts
94
+ * LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
95
+ * ```
96
+ *
97
+ * NOTE: for the reasons described above, do not change the order of the entries
98
+ * in this array without good reason!
99
+ */
100
+ const LOG_LEVELS = [
101
+ "debug",
102
+ "info",
103
+ "warn",
104
+ "error"
105
+ ];
106
+ /**
107
+ * The collection of valid export behaviors.
108
+ * Used to generate a type for typed configs as well as output target validation
109
+ * for the `dist-custom-elements` output target.
110
+ *
111
+ * Adding a value to this const array will automatically add it as a valid option on the
112
+ * output target configuration for `customElementsExportBehavior`.
113
+ *
114
+ * - `default`: No additional export or definition behavior will happen.
115
+ * - `auto-define-custom-elements`: Enables the auto-definition of a component and its children (recursively) in the custom elements registry. This
116
+ * functionality allows consumers to bypass the explicit call to define a component, its children, its children's
117
+ * children, etc. Users of this flag should be aware that enabling this functionality may increase bundle size.
118
+ * - `bundle`: A `defineCustomElements` function will be exported from the distribution directory. This behavior was added to allow easy migration
119
+ * from `dist-custom-elements-bundle` to `dist-custom-elements`.
120
+ * - `single-export-module`: All components will be re-exported from the specified directory's root `index.js` file.
121
+ */
122
+ const CustomElementsExportBehaviorOptions = [
123
+ "default",
124
+ "auto-define-custom-elements",
125
+ "bundle",
126
+ "single-export-module"
127
+ ];
128
+ //#endregion
129
+ //#region src/sys/node/logger/terminal-logger.ts
130
+ const { bgRed, blue, bold, cyan, dim, gray, green, magenta, red, yellow } = chalk;
131
+ /**
132
+ * Map of color names to chalk functions for dynamic access
133
+ */
134
+ const chalkColors = {
135
+ yellow: chalk.yellow,
136
+ red: chalk.red,
137
+ magenta: chalk.magenta,
138
+ green: chalk.green,
139
+ gray: chalk.gray,
140
+ cyan: chalk.cyan,
141
+ blue: chalk.blue,
142
+ bold: chalk.bold,
143
+ dim: chalk.dim
144
+ };
145
+ /**
146
+ * Create a logger for outputting information to a terminal environment
147
+ * @param loggerSys an underlying logger system entity used to create the terminal logger
148
+ * @returns the created logger
149
+ */
150
+ const createTerminalLogger = (loggerSys) => {
151
+ let currentLogLevel = "info";
152
+ let logFilePath = null;
153
+ const writeLogQueue = [];
154
+ const setLevel = (l) => currentLogLevel = l;
155
+ const getLevel = () => currentLogLevel;
156
+ const setLogFilePath = (p) => logFilePath = p;
157
+ const info = (...msg) => {
158
+ if (shouldLog(currentLogLevel, "info")) {
159
+ const lines = wordWrap(msg, loggerSys.getColumns());
160
+ infoPrefix(lines);
161
+ console.log(lines.join("\n"));
162
+ }
163
+ queueWriteLog("I", msg);
164
+ };
165
+ const infoPrefix = (lines) => {
166
+ if (lines.length > 0) {
167
+ const prefix = formatPrefixTimestamp();
168
+ lines[0] = dim(prefix) + lines[0].slice(prefix.length);
169
+ }
170
+ };
171
+ const warn = (...msg) => {
172
+ if (shouldLog(currentLogLevel, "warn")) {
173
+ const lines = wordWrap(msg, loggerSys.getColumns());
174
+ warnPrefix(lines);
175
+ console.warn("\n" + lines.join("\n") + "\n");
176
+ }
177
+ queueWriteLog("W", msg);
178
+ };
179
+ const warnPrefix = (lines) => {
180
+ if (lines.length) lines[0] = bold(yellow("[ WARN ]")) + lines[0].slice(9);
181
+ };
182
+ const error = (...msg) => {
183
+ for (let i = 0; i < msg.length; i++) if (msg[i] instanceof Error) {
184
+ const err = msg[i];
185
+ msg[i] = err.message;
186
+ if (err.stack) msg[i] += "\n" + err.stack;
187
+ }
188
+ if (shouldLog(currentLogLevel, "error")) {
189
+ const lines = wordWrap(msg, loggerSys.getColumns());
190
+ errorPrefix(lines);
191
+ console.error("\n" + lines.join("\n") + "\n");
192
+ }
193
+ queueWriteLog("E", msg);
194
+ };
195
+ const errorPrefix = (lines) => {
196
+ if (lines.length) lines[0] = bold(red("[ ERROR ]")) + lines[0].slice(9);
197
+ };
198
+ const debug = (...msg) => {
199
+ if (shouldLog(currentLogLevel, "debug")) {
200
+ formatMemoryUsage(msg);
201
+ const lines = wordWrap(msg, loggerSys.getColumns());
202
+ debugPrefix(lines);
203
+ console.log(lines.join("\n"));
204
+ }
205
+ queueWriteLog("D", msg);
206
+ };
207
+ const debugPrefix = (lines) => {
208
+ if (lines.length) {
209
+ const prefix = formatPrefixTimestamp();
210
+ lines[0] = cyan(prefix) + lines[0].slice(prefix.length);
211
+ }
212
+ };
213
+ const timespanStart = (startMsg, isDebug, appendTo) => {
214
+ const msg = [`${startMsg} ${dim("...")}`];
215
+ if (isDebug) {
216
+ if (shouldLog(currentLogLevel, "debug")) {
217
+ formatMemoryUsage(msg);
218
+ const lines = wordWrap(msg, loggerSys.getColumns());
219
+ debugPrefix(lines);
220
+ console.log(lines.join("\n"));
221
+ queueWriteLog("D", [`${startMsg} ...`]);
222
+ }
223
+ } else {
224
+ const lines = wordWrap(msg, loggerSys.getColumns());
225
+ infoPrefix(lines);
226
+ console.log(lines.join("\n"));
227
+ queueWriteLog("I", [`${startMsg} ...`]);
228
+ if (appendTo) appendTo.push(`${startMsg} ...`);
229
+ }
230
+ };
231
+ /**
232
+ * A little helper to (conditionally) format and add the current memory usage
233
+ *
234
+ * @param message an array to which the memory usage will be added
235
+ */
236
+ const formatMemoryUsage = (message) => {
237
+ const mem = loggerSys.memoryUsage();
238
+ if (mem > 0) message.push(dim(` MEM: ${(mem / 1e6).toFixed(1)}MB`));
239
+ };
240
+ const timespanFinish = (finishMsg, timeSuffix, colorName, textBold, newLineSuffix, isDebug, appendTo) => {
241
+ let msg = finishMsg;
242
+ if (colorName && chalkColors[colorName]) msg = chalkColors[colorName](finishMsg);
243
+ if (textBold) msg = bold(msg);
244
+ msg += " " + dim(timeSuffix);
245
+ if (isDebug) {
246
+ if (shouldLog(currentLogLevel, "debug")) {
247
+ const m = [msg];
248
+ formatMemoryUsage(m);
249
+ const lines = wordWrap(m, loggerSys.getColumns());
250
+ debugPrefix(lines);
251
+ console.log(lines.join("\n"));
252
+ }
253
+ queueWriteLog("D", [`${finishMsg} ${timeSuffix}`]);
254
+ } else {
255
+ const lines = wordWrap([msg], loggerSys.getColumns());
256
+ infoPrefix(lines);
257
+ console.log(lines.join("\n"));
258
+ queueWriteLog("I", [`${finishMsg} ${timeSuffix}`]);
259
+ if (appendTo) appendTo.push(`${finishMsg} ${timeSuffix}`);
260
+ }
261
+ if (newLineSuffix) console.log("");
262
+ };
263
+ const createTimeSpan = (startMsg, isDebug = false, appendTo) => {
264
+ const start = Date.now();
265
+ const duration = () => Date.now() - start;
266
+ const timeSpan = {
267
+ duration,
268
+ finish: (finishMsg, colorName, textBold, newLineSuffix) => {
269
+ const dur = duration();
270
+ let time;
271
+ if (dur > 1e3) time = "in " + (dur / 1e3).toFixed(2) + " s";
272
+ else if (parseFloat(dur.toFixed(3)) > 0) time = "in " + dur + " ms";
273
+ else time = "in less than 1 ms";
274
+ timespanFinish(finishMsg, time, colorName, !!textBold, !!newLineSuffix, isDebug, appendTo);
275
+ return dur;
276
+ }
277
+ };
278
+ timespanStart(startMsg, isDebug, appendTo);
279
+ return timeSpan;
280
+ };
281
+ const queueWriteLog = (prefix, msg) => {
282
+ if (logFilePath) {
283
+ const d = /* @__PURE__ */ new Date();
284
+ const log = "" + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) + ":" + ("0" + d.getSeconds()).slice(-2) + "." + ("0" + Math.floor(d.getMilliseconds() / 1e3 * 10)) + " " + ("000" + (loggerSys.memoryUsage() / 1e6).toFixed(1)).slice(-6) + "MB " + prefix + " " + msg.join(", ");
285
+ writeLogQueue.push(log);
286
+ }
287
+ };
288
+ const writeLogs = (append) => {
289
+ if (logFilePath) try {
290
+ queueWriteLog("F", ["--------------------------------------"]);
291
+ loggerSys.writeLogs(logFilePath, writeLogQueue.join("\n"), append);
292
+ } catch {}
293
+ writeLogQueue.length = 0;
294
+ };
295
+ /**
296
+ * Callback to enable / disable colored output in logs
297
+ * @param useColors whether to enable colors (chalk.level = 3) or disable (chalk.level = 0)
298
+ */
299
+ const enableColors = (useColors) => {
300
+ chalk.level = useColors ? 3 : 0;
301
+ };
302
+ /**
303
+ * Print all diagnostics to the console
304
+ * @param diagnostics the diagnostics to print
305
+ * @param cwd the current working directory
306
+ */
307
+ const printDiagnostics = (diagnostics, cwd) => {
308
+ if (!diagnostics || diagnostics.length === 0) return;
309
+ let outputLines = [""];
310
+ diagnostics.forEach((d) => {
311
+ outputLines = outputLines.concat(printDiagnostic(d, cwd));
312
+ });
313
+ console.log(outputLines.join("\n"));
314
+ };
315
+ /**
316
+ * Formats a single diagnostic to be printed
317
+ * @param diagnostic the diagnostic to prepare for printing
318
+ * @param cwd the current working directory
319
+ * @returns the message from the diagnostic, formatted and split into multiple lines
320
+ */
321
+ const printDiagnostic = (diagnostic, cwd) => {
322
+ const outputLines = wordWrap([diagnostic.messageText], loggerSys.getColumns());
323
+ let header = "";
324
+ if (diagnostic.header && diagnostic.header !== "Build Error") header += diagnostic.header;
325
+ if (typeof diagnostic.absFilePath === "string" && typeof diagnostic.relFilePath !== "string") {
326
+ if (typeof cwd !== "string") cwd = loggerSys.cwd();
327
+ diagnostic.relFilePath = loggerSys.relativePath(cwd, diagnostic.absFilePath);
328
+ if (!diagnostic.relFilePath.includes("/")) diagnostic.relFilePath = "./" + diagnostic.relFilePath;
329
+ }
330
+ let filePath = diagnostic.relFilePath;
331
+ if (typeof filePath !== "string") filePath = diagnostic.absFilePath;
332
+ if (typeof filePath === "string") {
333
+ if (header.length > 0) header += ": ";
334
+ header += cyan(filePath);
335
+ if (typeof diagnostic.lineNumber === "number" && diagnostic.lineNumber > -1) {
336
+ header += dim(`:`);
337
+ header += yellow(`${diagnostic.lineNumber}`);
338
+ if (typeof diagnostic.columnNumber === "number" && diagnostic.columnNumber > -1) {
339
+ header += dim(`:`);
340
+ header += yellow(`${diagnostic.columnNumber}`);
341
+ }
342
+ }
343
+ }
344
+ if (header.length > 0) outputLines.unshift(INDENT$1 + header);
345
+ outputLines.push("");
346
+ if (diagnostic.lines && diagnostic.lines.length) {
347
+ removeLeadingWhitespace(diagnostic.lines).forEach((l) => {
348
+ if (!isMeaningfulLine(l.text)) return;
349
+ let msg = ``;
350
+ if (l.lineNumber > -1) msg = `L${l.lineNumber}: `;
351
+ while (msg.length < INDENT$1.length) msg = " " + msg;
352
+ let text = l.text;
353
+ if (l.errorCharStart > -1) text = highlightError(text, l.errorCharStart, l.errorLength);
354
+ msg = dim(msg);
355
+ if (diagnostic.language === "typescript" || diagnostic.language === "javascript") msg += javaScriptSyntaxHighlight(text);
356
+ else if (diagnostic.language === "scss" || diagnostic.language === "css") msg += cssSyntaxHighlight(text);
357
+ else msg += text;
358
+ outputLines.push(msg);
359
+ });
360
+ outputLines.push("");
361
+ }
362
+ if (diagnostic.level === "error") errorPrefix(outputLines);
363
+ else if (diagnostic.level === "warn") warnPrefix(outputLines);
364
+ else if (diagnostic.level === "debug") debugPrefix(outputLines);
365
+ else infoPrefix(outputLines);
366
+ if (diagnostic.debugText != null && currentLogLevel === "debug") {
367
+ outputLines.push(diagnostic.debugText);
368
+ debugPrefix(wordWrap([diagnostic.debugText], loggerSys.getColumns()));
369
+ }
370
+ return outputLines;
371
+ };
372
+ /**
373
+ * Highlights an error
374
+ * @param errorLine the line containing the error
375
+ * @param errorCharStart the character at which the error starts
376
+ * @param errorLength the length of the error, how many characters should be highlighted
377
+ * @returns the highlighted error
378
+ */
379
+ const highlightError = (errorLine, errorCharStart, errorLength = 0) => {
380
+ let rightSideChars = errorLine.length - errorCharStart + errorLength - 1;
381
+ while (errorLine.length + INDENT$1.length > loggerSys.getColumns()) if (errorCharStart > errorLine.length - errorCharStart + errorLength && errorCharStart > 5) {
382
+ errorLine = errorLine.slice(1);
383
+ errorCharStart--;
384
+ } else if (rightSideChars > 1) {
385
+ errorLine = errorLine.slice(0, -1);
386
+ rightSideChars--;
387
+ } else break;
388
+ const lineChars = [];
389
+ const lineLength = Math.max(errorLine.length, errorCharStart + errorLength);
390
+ for (let i = 0; i < lineLength; i++) {
391
+ let chr = errorLine.charAt(i);
392
+ if (i >= errorCharStart && i < errorCharStart + errorLength) chr = bgRed(chr === "" ? " " : chr);
393
+ lineChars.push(chr);
394
+ }
395
+ return lineChars.join("");
396
+ };
397
+ /**
398
+ * Highlights JavaScript/TypeScript syntax, taking in text and selectively highlighting keywords from the language
399
+ * @param text the text to highlight
400
+ * @returns the text with highlighted JS/TS
401
+ */
402
+ const javaScriptSyntaxHighlight = (text) => {
403
+ if (text.trim().startsWith("//")) return dim(text);
404
+ return text.split(" ").map((word) => {
405
+ if (JS_KEYWORDS.indexOf(word) > -1) return cyan(word);
406
+ return word;
407
+ }).join(" ");
408
+ };
409
+ /**
410
+ * Highlights CSS syntax, taking in text and selectively highlighting keywords from the language
411
+ * @param text the text to highlight
412
+ * @returns the text with highlighted CSS
413
+ */
414
+ const cssSyntaxHighlight = (text) => {
415
+ let cssProp = true;
416
+ const safeChars = "abcdefghijklmnopqrstuvwxyz-_";
417
+ const notProp = ".#,:}@$[]/*";
418
+ const chars = [];
419
+ for (let i = 0; i < text.length; i++) {
420
+ const c = text.charAt(i);
421
+ if (c === ";" || c === "{") cssProp = true;
422
+ else if (notProp.indexOf(c) > -1) cssProp = false;
423
+ if (cssProp && safeChars.indexOf(c.toLowerCase()) > -1) {
424
+ chars.push(cyan(c));
425
+ continue;
426
+ }
427
+ chars.push(c);
428
+ }
429
+ return chars.join("");
430
+ };
431
+ return {
432
+ createLineUpdater: loggerSys.createLineUpdater,
433
+ createTimeSpan,
434
+ debug,
435
+ emoji: loggerSys.emoji,
436
+ enableColors,
437
+ error,
438
+ getLevel,
439
+ info,
440
+ printDiagnostics,
441
+ setLevel,
442
+ setLogFilePath,
443
+ warn,
444
+ writeLogs,
445
+ bgRed,
446
+ blue,
447
+ bold,
448
+ cyan,
449
+ dim,
450
+ gray,
451
+ green,
452
+ magenta,
453
+ red,
454
+ yellow
455
+ };
456
+ };
457
+ /**
458
+ * Helper function to determine, based on the current log level setting, whether
459
+ * a message at a given log level should be logged or not.
460
+ *
461
+ * @param currentSetting the current log level setting
462
+ * @param messageLevel the log level to check
463
+ * @returns whether we should log or not!
464
+ */
465
+ const shouldLog = (currentSetting, messageLevel) => LOG_LEVELS.indexOf(messageLevel) >= LOG_LEVELS.indexOf(currentSetting);
466
+ /**
467
+ * Format a simple timestamp string for log prefixes
468
+ *
469
+ * @returns a formatted timestamp
470
+ */
471
+ const formatPrefixTimestamp = () => {
472
+ const currentTime = /* @__PURE__ */ new Date();
473
+ return `[${clampTwoDigits(currentTime.getMinutes())}:${clampTwoDigits(currentTime.getSeconds())}.${Math.floor(currentTime.getMilliseconds() / 1e3 * 10)}]`;
474
+ };
475
+ /**
476
+ * Format a number as a string and clamp it to exactly
477
+ * two digits, e.g.
478
+ *
479
+ * ```ts
480
+ * clampTwoDigits(3) // '03'
481
+ * clampTwoDigits(14) // '14'
482
+ * clampTwoDigits(104) // '04'
483
+ * ```
484
+ *
485
+ * @param n the number to clamp
486
+ * @returns a formatted string
487
+ */
488
+ const clampTwoDigits = (n) => ("0" + n.toString()).slice(-2);
489
+ /**
490
+ * Helper function for word wrapping
491
+ * @param msg the message to wrap
492
+ * @param columns the maximum number of columns to occupy per line
493
+ * @returns the wrapped message
494
+ */
495
+ const wordWrap = (msg, columns) => {
496
+ const lines = [];
497
+ const words = [];
498
+ msg.forEach((m) => {
499
+ if (m === null) words.push("null");
500
+ else if (typeof m === "undefined") words.push("undefined");
501
+ else if (typeof m === "string") m.replace(/\s/gm, " ").split(" ").forEach((strWord) => {
502
+ if (strWord.trim().length) words.push(strWord.trim());
503
+ });
504
+ else if (typeof m === "number" || typeof m === "boolean" || typeof m === "function") words.push(m.toString());
505
+ else if (Array.isArray(m)) words.push(() => {
506
+ return m.toString();
507
+ });
508
+ else if (Object(m) === m) words.push(() => {
509
+ return m.toString();
510
+ });
511
+ else words.push(m.toString());
512
+ });
513
+ let line = INDENT$1;
514
+ words.forEach((word) => {
515
+ if (lines.length > 25) return;
516
+ if (typeof word === "function") {
517
+ if (line.trim().length) lines.push(line);
518
+ lines.push(word());
519
+ line = INDENT$1;
520
+ } else if (INDENT$1.length + word.length > columns - 1) {
521
+ if (line.trim().length) lines.push(line);
522
+ lines.push(INDENT$1 + word);
523
+ line = INDENT$1;
524
+ } else if (word.length + line.length > columns - 1) {
525
+ lines.push(line);
526
+ line = INDENT$1 + word + " ";
527
+ } else line += word + " ";
528
+ });
529
+ if (line.trim().length) lines.push(line);
530
+ return lines.map((l) => {
531
+ return l.trimRight();
532
+ });
533
+ };
534
+ /**
535
+ * Prepare the code associated with the error/warning to be logged by stripping variable length, leading whitespace
536
+ * @param orgLines the lines of code to log
537
+ * @returns the code, with leading whitespace stripped
538
+ */
539
+ const removeLeadingWhitespace = (orgLines) => {
540
+ const numberOfTries = 100;
541
+ const lines = JSON.parse(JSON.stringify(orgLines));
542
+ for (let i = 0; i < numberOfTries; i++) {
543
+ if (!eachLineHasLeadingWhitespace(lines)) return lines;
544
+ for (let j = 0; j < lines.length; j++) {
545
+ lines[j].text = lines[j].text.slice(1);
546
+ lines[j].errorCharStart--;
547
+ if (!lines[j].text.length) return lines;
548
+ }
549
+ }
550
+ return lines;
551
+ };
552
+ /**
553
+ * Determine if any of the provided lines begin with whitespace or not
554
+ * @param lines the lines to check for whitespace
555
+ * @returns true if each of the provided `lines` has some leading whitespace, false otherwise
556
+ */
557
+ const eachLineHasLeadingWhitespace = (lines) => {
558
+ if (!lines.length) return false;
559
+ for (let i = 0; i < lines.length; i++) {
560
+ if (!lines[i].text || lines[i].text.length < 1) return false;
561
+ const firstChar = lines[i].text.charAt(0);
562
+ if (firstChar !== " " && firstChar !== " ") return false;
563
+ }
564
+ return true;
565
+ };
566
+ /**
567
+ * Verify that a given line has more than just whitespace
568
+ * @param line the line to check
569
+ * @returns true if a line has characters other than whitespace in it, false otherwise
570
+ */
571
+ const isMeaningfulLine = (line) => {
572
+ if (line) {
573
+ line = line.trim();
574
+ return line.length > 0;
575
+ }
576
+ return false;
577
+ };
578
+ const JS_KEYWORDS = [
579
+ "abstract",
580
+ "any",
581
+ "as",
582
+ "break",
583
+ "boolean",
584
+ "case",
585
+ "catch",
586
+ "class",
587
+ "console",
588
+ "const",
589
+ "continue",
590
+ "debugger",
591
+ "declare",
592
+ "default",
593
+ "delete",
594
+ "do",
595
+ "else",
596
+ "enum",
597
+ "export",
598
+ "extends",
599
+ "false",
600
+ "finally",
601
+ "for",
602
+ "from",
603
+ "function",
604
+ "get",
605
+ "if",
606
+ "import",
607
+ "in",
608
+ "implements",
609
+ "Infinity",
610
+ "instanceof",
611
+ "let",
612
+ "module",
613
+ "namespace",
614
+ "NaN",
615
+ "new",
616
+ "number",
617
+ "null",
618
+ "public",
619
+ "private",
620
+ "protected",
621
+ "require",
622
+ "return",
623
+ "static",
624
+ "set",
625
+ "string",
626
+ "super",
627
+ "switch",
628
+ "this",
629
+ "throw",
630
+ "try",
631
+ "true",
632
+ "type",
633
+ "typeof",
634
+ "undefined",
635
+ "var",
636
+ "void",
637
+ "with",
638
+ "while",
639
+ "yield"
640
+ ];
641
+ /**
642
+ * This is used to prefix lines with whitespace which is then
643
+ * replaced by various prefixes like [ WARN ] and so on
644
+ */
645
+ const INDENT$1 = " ";
646
+ //#endregion
647
+ //#region src/sys/node/logger/index.ts
648
+ /**
649
+ * Create a logger to run in a Node environment
650
+ *
651
+ * @returns the created logger
652
+ */
653
+ const createNodeLogger = () => {
654
+ return createTerminalLogger(createNodeLoggerSys());
655
+ };
656
+ /**
657
+ * Create a logger sys object for use in a Node.js environment
658
+ *
659
+ * The `TerminalLoggerSys` interface basically abstracts away some
660
+ * environment-specific details so that the terminal logger can deal with
661
+ * things in a (potentially) platform-agnostic way.
662
+ *
663
+ * @returns a configured logger sys object
664
+ */
665
+ function createNodeLoggerSys() {
666
+ const cwd = () => process.cwd();
667
+ const emoji = (e) => process.platform !== "win32" ? e : "";
668
+ /**
669
+ * Get the number of columns for the terminal to use when printing
670
+ * @returns the number of columns to use
671
+ */
672
+ const getColumns = () => {
673
+ const min_columns = 60;
674
+ const max_columns = 120;
675
+ const terminalWidth = process?.stdout?.columns ?? 80;
676
+ return Math.max(Math.min(terminalWidth, max_columns), min_columns);
677
+ };
678
+ const memoryUsage = () => process.memoryUsage().rss;
679
+ const relativePath = (from, to) => path$1.relative(from, to);
680
+ const writeLogs = (logFilePath, log, append) => {
681
+ if (append) try {
682
+ fs.accessSync(logFilePath);
683
+ } catch {
684
+ append = false;
685
+ }
686
+ if (append) fs.appendFileSync(logFilePath, log);
687
+ else fs.writeFileSync(logFilePath, log);
688
+ };
689
+ const createLineUpdater = async () => {
690
+ const readline = await import("readline");
691
+ let promise = Promise.resolve();
692
+ const update = (text) => {
693
+ text = text.substring(0, process.stdout.columns - 5) + "\x1B[0m";
694
+ return promise = promise.then(() => {
695
+ return new Promise((resolve) => {
696
+ readline.clearLine(process.stdout, 0);
697
+ readline.cursorTo(process.stdout, 0, void 0);
698
+ process.stdout.write(text, resolve);
699
+ });
700
+ });
701
+ };
702
+ const stop = () => {
703
+ return update("\x1B[?25h");
704
+ };
705
+ process.stdout.write("\x1B[?25l");
706
+ return {
707
+ update,
708
+ stop
709
+ };
710
+ };
711
+ return {
712
+ cwd,
713
+ emoji,
714
+ getColumns,
715
+ memoryUsage,
716
+ relativePath,
717
+ writeLogs,
718
+ createLineUpdater
719
+ };
720
+ }
721
+ //#endregion
722
+ //#region src/sys/node/node-setup-process.ts
723
+ function setupNodeProcess(c) {
724
+ c.process.on(`unhandledRejection`, (e) => {
725
+ if (!shouldIgnoreError(e)) {
726
+ let msg = "unhandledRejection";
727
+ if (e != null) {
728
+ if (typeof e === "string") msg += ": " + e;
729
+ else if (e.stack) msg += ": " + e.stack;
730
+ else if (e.message) msg += ": " + e.message;
731
+ }
732
+ c.logger.error(msg);
733
+ }
734
+ });
735
+ }
736
+ //#endregion
737
+ //#region src/sys/node/node-fs-promisify.ts
738
+ const copyFile = promisify(fs.copyFile);
739
+ const mkdir = promisify(fs.mkdir);
740
+ const readdir = promisify(fs.readdir);
741
+ const stat = promisify(fs.stat);
742
+ //#endregion
743
+ //#region src/sys/node/node-copy-tasks.ts
744
+ /**
745
+ * Copy a file with retry logic for transient Windows errors (EBUSY, EPERM, EACCES).
746
+ * These errors commonly occur on Windows CI when antivirus or indexing services
747
+ * temporarily lock files.
748
+ *
749
+ * @param src - The source file path to copy from
750
+ * @param dest - The destination file path to copy to
751
+ * @param maxRetries - Maximum number of retry attempts (default: 3)
752
+ * @returns A promise that resolves when the file is successfully copied
753
+ * @throws The original error if all retry attempts fail or the error is not retryable
754
+ */
755
+ async function copyFileWithRetry(src, dest, maxRetries = 3) {
756
+ for (let attempt = 0; attempt <= maxRetries; attempt++) try {
757
+ await copyFile(src, dest);
758
+ return;
759
+ } catch (err) {
760
+ if (![
761
+ "EBUSY",
762
+ "EPERM",
763
+ "EACCES"
764
+ ].includes(err.code) || attempt === maxRetries) throw err;
765
+ await new Promise((resolve) => setTimeout(resolve, 100 * Math.pow(2, attempt)));
766
+ }
767
+ }
768
+ async function nodeCopyTasks(copyTasks, srcDir) {
769
+ const results = {
770
+ diagnostics: [],
771
+ dirPaths: [],
772
+ filePaths: []
773
+ };
774
+ try {
775
+ copyTasks = flatOne(await Promise.all(copyTasks.map((task) => processGlobs(task, srcDir))));
776
+ const allCopyTasks = [];
777
+ while (copyTasks.length > 0) {
778
+ const tasks = copyTasks.splice(0, 100);
779
+ await Promise.all(tasks.map((copyTask) => processCopyTask(results, allCopyTasks, copyTask)));
780
+ }
781
+ const mkDirs = ensureDirs(allCopyTasks);
782
+ try {
783
+ await Promise.all(mkDirs.map((dir) => mkdir(dir, { recursive: true })));
784
+ } catch {}
785
+ while (allCopyTasks.length > 0) {
786
+ const tasks = allCopyTasks.splice(0, 100);
787
+ await Promise.all(tasks.map((copyTask) => copyFileWithRetry(copyTask.src, copyTask.dest)));
788
+ }
789
+ } catch (e) {
790
+ catchError(results.diagnostics, e);
791
+ }
792
+ return results;
793
+ }
794
+ async function processGlobs(copyTask, srcDir) {
795
+ return isGlob(copyTask.src) ? await processGlobTask(copyTask, srcDir) : [{
796
+ src: getSrcAbsPath(srcDir, copyTask.src),
797
+ dest: copyTask.keepDirStructure ? path$1.join(copyTask.dest, copyTask.src) : copyTask.dest,
798
+ warn: copyTask.warn,
799
+ ignore: copyTask.ignore,
800
+ keepDirStructure: copyTask.keepDirStructure
801
+ }];
802
+ }
803
+ function getSrcAbsPath(srcDir, src) {
804
+ if (path$1.isAbsolute(src)) return src;
805
+ return path$1.join(srcDir, src);
806
+ }
807
+ async function processGlobTask(copyTask, srcDir) {
808
+ return (await asyncGlob(copyTask.src, {
809
+ cwd: srcDir,
810
+ nodir: true,
811
+ ignore: copyTask.ignore
812
+ })).map((globRelPath) => createGlobCopyTask(copyTask, srcDir, globRelPath));
813
+ }
814
+ function createGlobCopyTask(copyTask, srcDir, globRelPath) {
815
+ const dest = path$1.join(copyTask.dest, copyTask.keepDirStructure ? globRelPath : path$1.basename(globRelPath));
816
+ return {
817
+ src: path$1.join(srcDir, globRelPath),
818
+ dest,
819
+ ignore: copyTask.ignore,
820
+ warn: copyTask.warn,
821
+ keepDirStructure: copyTask.keepDirStructure
822
+ };
823
+ }
824
+ async function processCopyTask(results, allCopyTasks, copyTask) {
825
+ try {
826
+ copyTask.src = normalizePath(copyTask.src);
827
+ copyTask.dest = normalizePath(copyTask.dest);
828
+ if ((await stat(copyTask.src)).isDirectory()) {
829
+ if (!results.dirPaths.includes(copyTask.dest)) results.dirPaths.push(copyTask.dest);
830
+ await processCopyTaskDirectory(results, allCopyTasks, copyTask);
831
+ } else if (!shouldIgnore(copyTask)) {
832
+ if (!results.filePaths.includes(copyTask.dest)) results.filePaths.push(copyTask.dest);
833
+ allCopyTasks.push(copyTask);
834
+ }
835
+ } catch (e) {
836
+ if (copyTask.warn !== false) {
837
+ const err = buildError(results.diagnostics);
838
+ if (e instanceof Error) err.messageText = e.message;
839
+ }
840
+ }
841
+ }
842
+ async function processCopyTaskDirectory(results, allCopyTasks, copyTask) {
843
+ try {
844
+ const dirItems = await readdir(copyTask.src);
845
+ await Promise.all(dirItems.map(async (dirItem) => {
846
+ await processCopyTask(results, allCopyTasks, {
847
+ src: path$1.join(copyTask.src, dirItem),
848
+ dest: path$1.join(copyTask.dest, dirItem),
849
+ warn: copyTask.warn
850
+ });
851
+ }));
852
+ } catch (e) {
853
+ catchError(results.diagnostics, e);
854
+ }
855
+ }
856
+ function ensureDirs(copyTasks) {
857
+ const mkDirs = [];
858
+ copyTasks.forEach((copyTask) => {
859
+ addMkDir(mkDirs, path$1.dirname(copyTask.dest));
860
+ });
861
+ mkDirs.sort((a, b) => {
862
+ const partsA = a.split("/").length;
863
+ const partsB = b.split("/").length;
864
+ if (partsA < partsB) return -1;
865
+ if (partsA > partsB) return 1;
866
+ if (a < b) return -1;
867
+ if (a > b) return 1;
868
+ return 0;
869
+ });
870
+ return mkDirs;
871
+ }
872
+ function addMkDir(mkDirs, destDir) {
873
+ destDir = normalizePath(destDir);
874
+ if (destDir === ROOT_DIR || destDir + "/" === ROOT_DIR || destDir === "") return;
875
+ if (!mkDirs.includes(destDir)) mkDirs.push(destDir);
876
+ }
877
+ const ROOT_DIR = normalizePath(path$1.resolve("/"));
878
+ function shouldIgnore({ src, ignore = [] }) {
879
+ const filePath = src.trim().toLowerCase();
880
+ return ignore.some((ignoreFile) => filePath.endsWith(ignoreFile));
881
+ }
882
+ function asyncGlob(pattern, opts) {
883
+ return glob(pattern, opts);
884
+ }
885
+ //#endregion
886
+ //#region src/sys/node/node-lazy-require.ts
887
+ /**
888
+ * Lazy requirer for Node, with functionality for specifying version ranges and
889
+ * returning diagnostic errors if requirements aren't met.
890
+ */
891
+ var NodeLazyRequire = class {
892
+ ensured = /* @__PURE__ */ new Set();
893
+ /**
894
+ * Create a NodeLazyRequire instance
895
+ *
896
+ * @param nodeResolveModule an object which wraps up module resolution functionality
897
+ * @param lazyDependencies the dependency requirements we want to enforce here
898
+ */
899
+ constructor(nodeResolveModule, lazyDependencies) {
900
+ this.nodeResolveModule = nodeResolveModule;
901
+ this.lazyDependencies = lazyDependencies;
902
+ }
903
+ /**
904
+ * Ensure that a dependency within our supported range is installed in the
905
+ * current environment. This function will check all the dependency
906
+ * requirements passed in when the class is instantiated and return
907
+ * diagnostics if there are any issues.
908
+ *
909
+ * @param fromDir the directory from which we'll attempt to resolve the
910
+ * dependencies, typically this will be project's root directory.
911
+ * @param ensureModuleIds an array of module names whose versions we're going
912
+ * to check
913
+ * @returns a Promise holding diagnostics if any of the dependencies either
914
+ * were not resolved _or_ did not meet our version requirements.
915
+ */
916
+ async ensure(fromDir, ensureModuleIds) {
917
+ const diagnostics = [];
918
+ const problemDeps = [];
919
+ ensureModuleIds.forEach((ensureModuleId) => {
920
+ if (!this.ensured.has(ensureModuleId)) {
921
+ const { minVersion, recommendedVersion, maxVersion } = this.lazyDependencies[ensureModuleId];
922
+ try {
923
+ const pkgJsonPath = this.nodeResolveModule.resolveModule(fromDir, ensureModuleId);
924
+ const installedPkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
925
+ if (maxVersion ? satisfies(installedPkgJson.version, `${minVersion} - ${major(maxVersion)}.x`) : semverLte(minVersion, installedPkgJson.version)) {
926
+ this.ensured.add(ensureModuleId);
927
+ return;
928
+ }
929
+ } catch {}
930
+ problemDeps.push(`${ensureModuleId}@${recommendedVersion}`);
931
+ }
932
+ });
933
+ if (problemDeps.length > 0) {
934
+ const err = buildError(diagnostics);
935
+ err.header = `Please install supported versions of dev dependencies with either npm or yarn.`;
936
+ err.messageText = `npm install --save-dev ${problemDeps.join(" ")}`;
937
+ }
938
+ return diagnostics;
939
+ }
940
+ require(fromDir, moduleId) {
941
+ return __require(this.getModulePath(fromDir, moduleId));
942
+ }
943
+ getModulePath(fromDir, moduleId) {
944
+ const modulePath = this.nodeResolveModule.resolveModule(fromDir, moduleId);
945
+ return path$1.dirname(modulePath);
946
+ }
947
+ };
948
+ //#endregion
949
+ //#region src/sys/node/node-resolve-module.ts
950
+ var NodeResolveModule = class {
951
+ resolveModuleCache = /* @__PURE__ */ new Map();
952
+ resolveModule(fromDir, moduleId, opts) {
953
+ const cacheKey = `${fromDir}:${moduleId}`;
954
+ const cachedPath = this.resolveModuleCache.get(cacheKey);
955
+ if (cachedPath) return cachedPath;
956
+ if (opts && opts.manuallyResolve) return this.resolveModuleManually(fromDir, moduleId, cacheKey);
957
+ if (moduleId.startsWith("@types/")) return this.resolveTypesModule(fromDir, moduleId, cacheKey);
958
+ const Module = __require("module");
959
+ fromDir = path$1.resolve(fromDir);
960
+ const fromFile = path$1.join(fromDir, "noop.js");
961
+ let dir = normalizePath(Module._resolveFilename(moduleId, {
962
+ id: fromFile,
963
+ filename: fromFile,
964
+ paths: Module._nodeModulePaths(fromDir)
965
+ }));
966
+ const root = normalizePath(path$1.parse(fromDir).root);
967
+ let packageJsonFilePath;
968
+ while (dir !== root) {
969
+ dir = normalizePath(path$1.dirname(dir));
970
+ packageJsonFilePath = path$1.join(dir, "package.json");
971
+ if (!fs.existsSync(packageJsonFilePath)) continue;
972
+ this.resolveModuleCache.set(cacheKey, packageJsonFilePath);
973
+ return packageJsonFilePath;
974
+ }
975
+ throw new Error(`error loading "${moduleId}" from "${fromDir}"`);
976
+ }
977
+ resolveTypesModule(fromDir, moduleId, cacheKey) {
978
+ const moduleSplt = moduleId.split("/");
979
+ const root = normalizePath(path$1.parse(fromDir).root);
980
+ let dir = normalizePath(path$1.join(fromDir, "noop.js"));
981
+ let typesPackageJsonFilePath;
982
+ while (dir !== root) {
983
+ dir = normalizePath(path$1.dirname(dir));
984
+ typesPackageJsonFilePath = path$1.join(dir, "node_modules", moduleSplt[0], moduleSplt[1], "package.json");
985
+ if (!fs.existsSync(typesPackageJsonFilePath)) continue;
986
+ this.resolveModuleCache.set(cacheKey, typesPackageJsonFilePath);
987
+ return typesPackageJsonFilePath;
988
+ }
989
+ throw new Error(`error loading "${moduleId}" from "${fromDir}"`);
990
+ }
991
+ resolveModuleManually(fromDir, moduleId, cacheKey) {
992
+ const root = normalizePath(path$1.parse(fromDir).root);
993
+ let dir = normalizePath(path$1.join(fromDir, "noop.js"));
994
+ let packageJsonFilePath;
995
+ while (dir !== root) {
996
+ dir = normalizePath(path$1.dirname(dir));
997
+ packageJsonFilePath = path$1.join(dir, "node_modules", moduleId, "package.json");
998
+ if (!fs.existsSync(packageJsonFilePath)) continue;
999
+ this.resolveModuleCache.set(cacheKey, packageJsonFilePath);
1000
+ return packageJsonFilePath;
1001
+ }
1002
+ throw new Error(`error loading "${moduleId}" from "${fromDir}"`);
1003
+ }
1004
+ };
1005
+ //#endregion
1006
+ //#region src/sys/node/node-stencil-version-checker.ts
1007
+ const REGISTRY_URL = `https://registry.npmjs.org/@stencil/core`;
1008
+ const CHECK_INTERVAL = 1e3 * 60 * 60 * 24 * 7;
1009
+ const CHANGELOG = `https://github.com/stenciljs/core/blob/main/CHANGELOG.md`;
1010
+ async function checkVersion(logger, currentVersion) {
1011
+ try {
1012
+ const latestVersion = await getLatestCompilerVersion(logger);
1013
+ if (latestVersion != null) return () => {
1014
+ if (semverLt(currentVersion, latestVersion)) printUpdateMessage(logger, currentVersion, latestVersion);
1015
+ else console.debug(`${logger.cyan("@stencil/core")} version ${logger.green(currentVersion)} is the latest version`);
1016
+ };
1017
+ } catch (e) {
1018
+ logger.debug(`unable to load latest compiler version: ${e}`);
1019
+ }
1020
+ return noop;
1021
+ }
1022
+ async function getLatestCompilerVersion(logger) {
1023
+ try {
1024
+ const lastCheck = await getLastCheck();
1025
+ if (lastCheck == null) {
1026
+ setLastCheck();
1027
+ return null;
1028
+ }
1029
+ if (!requiresCheck(Date.now(), lastCheck, CHECK_INTERVAL)) return null;
1030
+ const setPromise = setLastCheck();
1031
+ const body = await requestUrl(REGISTRY_URL);
1032
+ const data = JSON.parse(body);
1033
+ await setPromise;
1034
+ return data["dist-tags"].latest;
1035
+ } catch (e) {
1036
+ logger.debug(`getLatestCompilerVersion error: ${e}`);
1037
+ }
1038
+ return null;
1039
+ }
1040
+ async function requestUrl(url) {
1041
+ const https = await import("https");
1042
+ return new Promise((resolve, reject) => {
1043
+ const req = https.request(url, (res) => {
1044
+ if (res.statusCode > 299) {
1045
+ reject(`url: ${url}, staus: ${res.statusCode}`);
1046
+ return;
1047
+ }
1048
+ res.once("error", reject);
1049
+ const ret = [];
1050
+ res.once("end", () => {
1051
+ resolve(ret.join(""));
1052
+ });
1053
+ res.on("data", (data) => {
1054
+ ret.push(data);
1055
+ });
1056
+ });
1057
+ req.once("error", reject);
1058
+ req.end();
1059
+ });
1060
+ }
1061
+ function requiresCheck(now, lastCheck, checkInterval) {
1062
+ return lastCheck + checkInterval < now;
1063
+ }
1064
+ function getLastCheck() {
1065
+ return new Promise((resolve) => {
1066
+ fs.readFile(getLastCheckStoragePath(), "utf8", (err, data) => {
1067
+ if (!err && isString(data)) try {
1068
+ resolve(JSON.parse(data));
1069
+ } catch {}
1070
+ resolve(null);
1071
+ });
1072
+ });
1073
+ }
1074
+ function setLastCheck() {
1075
+ return new Promise((resolve) => {
1076
+ const now = JSON.stringify(Date.now());
1077
+ fs.writeFile(getLastCheckStoragePath(), now, () => {
1078
+ resolve();
1079
+ });
1080
+ });
1081
+ }
1082
+ function getLastCheckStoragePath() {
1083
+ return path$1.join(tmpdir$1(), "stencil_last_version_node.json");
1084
+ }
1085
+ function printUpdateMessage(logger, currentVersion, latestVersion) {
1086
+ const installMessage = `npm install @stencil/core`;
1087
+ const msg = [
1088
+ `Update available: ${currentVersion} ${ARROW} ${latestVersion}`,
1089
+ `To get the latest, please run:`,
1090
+ installMessage,
1091
+ CHANGELOG
1092
+ ];
1093
+ const lineLength = msg.reduce((longest, line) => line.length > longest ? line.length : longest, 0);
1094
+ const o = [];
1095
+ let top = BOX_TOP_LEFT;
1096
+ while (top.length <= lineLength + PADDING * 2) top += BOX_HORIZONTAL;
1097
+ top += BOX_TOP_RIGHT;
1098
+ o.push(top);
1099
+ msg.forEach((m) => {
1100
+ let line = BOX_VERTICAL;
1101
+ for (let i = 0; i < PADDING; i++) line += ` `;
1102
+ line += m;
1103
+ while (line.length <= lineLength + PADDING * 2) line += ` `;
1104
+ line += BOX_VERTICAL;
1105
+ o.push(line);
1106
+ });
1107
+ let bottom = BOX_BOTTOM_LEFT;
1108
+ while (bottom.length <= lineLength + PADDING * 2) bottom += BOX_HORIZONTAL;
1109
+ bottom += BOX_BOTTOM_RIGHT;
1110
+ o.push(bottom);
1111
+ let output = `${INDENT}${o.join(`\n${INDENT}`)}\n`;
1112
+ output = output.replace(currentVersion, logger.red(currentVersion));
1113
+ output = output.replace(latestVersion, logger.green(latestVersion));
1114
+ output = output.replace(installMessage, logger.cyan(installMessage));
1115
+ output = output.replace(CHANGELOG, logger.dim(CHANGELOG));
1116
+ console.log(output);
1117
+ }
1118
+ const ARROW = `→`;
1119
+ const BOX_TOP_LEFT = `╭`;
1120
+ const BOX_TOP_RIGHT = `╮`;
1121
+ const BOX_BOTTOM_LEFT = `╰`;
1122
+ const BOX_BOTTOM_RIGHT = `╯`;
1123
+ const BOX_VERTICAL = `│`;
1124
+ const BOX_HORIZONTAL = `─`;
1125
+ const PADDING = 2;
1126
+ const INDENT = ` `;
1127
+ //#endregion
1128
+ //#region src/sys/node/node-worker-main.ts
1129
+ /**
1130
+ * A class that holds a reference to a node worker sub-process within the main
1131
+ * thread so that messages may be passed to it.
1132
+ */
1133
+ var NodeWorkerMain = class extends EventEmitter {
1134
+ /**
1135
+ * A handle for the OS process that is running our worker code
1136
+ */
1137
+ childProcess;
1138
+ tasks = /* @__PURE__ */ new Map();
1139
+ exitCode = null;
1140
+ processQueue = true;
1141
+ sendQueue = [];
1142
+ stopped = false;
1143
+ successfulMessage = false;
1144
+ totalTasksAssigned = 0;
1145
+ /**
1146
+ * Create an object for holding and interacting with a reference to a worker
1147
+ * child-process.
1148
+ *
1149
+ * @param id a unique ID
1150
+ * @param forkModulePath the path to the module which should be run by the
1151
+ * child process
1152
+ */
1153
+ constructor(id, forkModulePath) {
1154
+ super();
1155
+ this.id = id;
1156
+ this.fork(forkModulePath);
1157
+ }
1158
+ fork(forkModulePath) {
1159
+ const options = {
1160
+ execArgv: process.execArgv.filter((v) => !/^--(debug|inspect)/.test(v)),
1161
+ env: process.env,
1162
+ cwd: process.cwd(),
1163
+ silent: true
1164
+ };
1165
+ this.childProcess = cp.fork(forkModulePath, [], options);
1166
+ this.childProcess.stdout.setEncoding("utf8");
1167
+ this.childProcess.stdout.on("data", (data) => {
1168
+ console.log(data);
1169
+ });
1170
+ this.childProcess.stderr.setEncoding("utf8");
1171
+ this.childProcess.stderr.on("data", (data) => {
1172
+ console.error(data);
1173
+ });
1174
+ this.childProcess.on("message", this.receiveFromWorker.bind(this));
1175
+ this.childProcess.on("error", (err) => {
1176
+ this.emit("error", err);
1177
+ });
1178
+ this.childProcess.once("exit", (code) => {
1179
+ this.exitCode = code;
1180
+ this.emit("exit", code);
1181
+ });
1182
+ }
1183
+ run(task) {
1184
+ this.totalTasksAssigned++;
1185
+ this.tasks.set(task.stencilId, task);
1186
+ const [method, ...args] = task.inputArgs;
1187
+ this.sendToWorker({
1188
+ stencilId: task.stencilId,
1189
+ method,
1190
+ args
1191
+ });
1192
+ }
1193
+ sendToWorker(msg) {
1194
+ if (!this.processQueue) {
1195
+ this.sendQueue.push(msg);
1196
+ return;
1197
+ }
1198
+ if (!this.childProcess.send(msg, (error) => {
1199
+ if (error && error instanceof Error) return;
1200
+ this.processQueue = true;
1201
+ if (this.sendQueue.length > 0) {
1202
+ const queueCopy = this.sendQueue.slice();
1203
+ this.sendQueue = [];
1204
+ queueCopy.forEach((d) => this.sendToWorker(d));
1205
+ }
1206
+ }) || process.platform.startsWith("win")) this.processQueue = false;
1207
+ }
1208
+ receiveFromWorker(msgFromWorker) {
1209
+ this.successfulMessage = true;
1210
+ if (this.stopped) return;
1211
+ const task = this.tasks.get(msgFromWorker.stencilId);
1212
+ if (!task) {
1213
+ if (msgFromWorker.stencilRtnError != null) this.emit("error", msgFromWorker.stencilRtnError);
1214
+ return;
1215
+ }
1216
+ if (msgFromWorker.stencilRtnError != null) task.reject(msgFromWorker.stencilRtnError);
1217
+ else task.resolve(msgFromWorker.stencilRtnValue);
1218
+ this.tasks.delete(msgFromWorker.stencilId);
1219
+ this.emit("response", msgFromWorker);
1220
+ }
1221
+ stop() {
1222
+ this.stopped = true;
1223
+ this.tasks.forEach((t) => t.reject(TASK_CANCELED_MSG));
1224
+ this.tasks.clear();
1225
+ if (this.successfulMessage) {
1226
+ this.childProcess.send({ exit: true });
1227
+ setTimeout(() => {
1228
+ if (this.exitCode === null) this.childProcess.kill("SIGKILL");
1229
+ }, 100);
1230
+ } else this.childProcess.kill("SIGKILL");
1231
+ }
1232
+ };
1233
+ //#endregion
1234
+ //#region src/sys/node/node-worker-controller.ts
1235
+ /**
1236
+ * A custom EventEmitter which provides centralizes dispatching and control for
1237
+ * node.js workers ({@link NodeWorkerMain} instances)
1238
+ */
1239
+ var NodeWorkerController = class extends EventEmitter {
1240
+ workerIds = 0;
1241
+ stencilId = 0;
1242
+ isEnding = false;
1243
+ taskQueue = [];
1244
+ workers = [];
1245
+ maxWorkers;
1246
+ useForkedWorkers;
1247
+ mainThreadRunner;
1248
+ /**
1249
+ * Create a node.js-specific worker controller, which controls and
1250
+ * coordinates distributing tasks to a series of child processes (tracked by
1251
+ * {@link NodeWorkerMain} instances). These child processes are node
1252
+ * processes executing a special worker script (`src/sys/node/worker.ts`)
1253
+ * which listens for {@link d.MsgToWorker} messages and runs certain tasks in
1254
+ * response.
1255
+ *
1256
+ * @param forkModulePath the path to the module which k
1257
+ * @param maxConcurrentWorkers the max number of worker threads to spin up
1258
+ */
1259
+ constructor(forkModulePath, maxConcurrentWorkers) {
1260
+ super();
1261
+ this.forkModulePath = forkModulePath;
1262
+ const osCpus = cpus$1().length;
1263
+ this.useForkedWorkers = maxConcurrentWorkers > 0;
1264
+ this.maxWorkers = Math.max(Math.min(maxConcurrentWorkers, osCpus), 2) - 1;
1265
+ if (this.useForkedWorkers) this.startWorkers();
1266
+ else this.mainThreadRunner = __require(forkModulePath);
1267
+ }
1268
+ onError(err, workerId) {
1269
+ if (err.code === "ERR_IPC_CHANNEL_CLOSED") return this.stopWorker(workerId);
1270
+ if (err.code !== "EPIPE") console.error(err);
1271
+ }
1272
+ onExit(workerId) {
1273
+ setTimeout(() => {
1274
+ let doQueue = false;
1275
+ const worker = this.workers.find((w) => w.id === workerId);
1276
+ if (worker) {
1277
+ worker.tasks.forEach((t) => {
1278
+ t.retries++;
1279
+ this.taskQueue.unshift(t);
1280
+ doQueue = true;
1281
+ });
1282
+ worker.tasks.clear();
1283
+ }
1284
+ this.stopWorker(workerId);
1285
+ if (doQueue) this.processTaskQueue();
1286
+ }, 10);
1287
+ }
1288
+ startWorkers() {
1289
+ while (this.workers.length < this.maxWorkers) this.startWorker();
1290
+ }
1291
+ startWorker() {
1292
+ const workerId = this.workerIds++;
1293
+ const worker = new NodeWorkerMain(workerId, this.forkModulePath);
1294
+ worker.on("response", this.processTaskQueue.bind(this));
1295
+ worker.once("exit", () => {
1296
+ this.onExit(workerId);
1297
+ });
1298
+ worker.on("error", (err) => {
1299
+ this.onError(err, workerId);
1300
+ });
1301
+ this.workers.push(worker);
1302
+ }
1303
+ stopWorker(workerId) {
1304
+ const worker = this.workers.find((w) => w.id === workerId);
1305
+ if (worker) {
1306
+ worker.stop();
1307
+ const index = this.workers.indexOf(worker);
1308
+ if (index > -1) this.workers.splice(index, 1);
1309
+ }
1310
+ }
1311
+ processTaskQueue() {
1312
+ if (this.isEnding) return;
1313
+ if (this.useForkedWorkers) this.startWorkers();
1314
+ while (this.taskQueue.length > 0) {
1315
+ const worker = getNextWorker(this.workers);
1316
+ if (!worker) break;
1317
+ worker.run(this.taskQueue.shift());
1318
+ }
1319
+ }
1320
+ send(...args) {
1321
+ if (this.isEnding) return Promise.reject(TASK_CANCELED_MSG);
1322
+ if (this.useForkedWorkers) return new Promise((resolve, reject) => {
1323
+ const task = {
1324
+ stencilId: this.stencilId++,
1325
+ inputArgs: args,
1326
+ retries: 0,
1327
+ resolve,
1328
+ reject
1329
+ };
1330
+ this.taskQueue.push(task);
1331
+ this.processTaskQueue();
1332
+ });
1333
+ return this.mainThreadRunner[args[0]].apply(null, args.slice(1));
1334
+ }
1335
+ handler(name) {
1336
+ return (...args) => {
1337
+ return this.send(name, ...args);
1338
+ };
1339
+ }
1340
+ cancelTasks() {
1341
+ for (const worker of this.workers) {
1342
+ worker.tasks.forEach((t) => t.reject(TASK_CANCELED_MSG));
1343
+ worker.tasks.clear();
1344
+ }
1345
+ this.taskQueue.length = 0;
1346
+ }
1347
+ destroy() {
1348
+ if (!this.isEnding) {
1349
+ this.isEnding = true;
1350
+ for (const task of this.taskQueue) task.reject(TASK_CANCELED_MSG);
1351
+ this.taskQueue.length = 0;
1352
+ const workerIds = this.workers.map((w) => w.id);
1353
+ for (const workerId of workerIds) this.stopWorker(workerId);
1354
+ }
1355
+ }
1356
+ };
1357
+ function getNextWorker(workers) {
1358
+ const availableWorkers = workers.filter((w) => {
1359
+ if (w.stopped) return false;
1360
+ return true;
1361
+ });
1362
+ if (availableWorkers.length === 0) return null;
1363
+ return availableWorkers.sort((a, b) => {
1364
+ if (a.tasks.size < b.tasks.size) return -1;
1365
+ if (a.tasks.size > b.tasks.size) return 1;
1366
+ if (a.totalTasksAssigned < b.totalTasksAssigned) return -1;
1367
+ if (a.totalTasksAssigned > b.totalTasksAssigned) return 1;
1368
+ return 0;
1369
+ })[0];
1370
+ }
1371
+ //#endregion
1372
+ //#region src/sys/node/node-sys.ts
1373
+ const __dirname = import.meta.dirname;
1374
+ /**
1375
+ * Create a node.js-specific {@link CompilerSystem} to be used when Stencil is
1376
+ * run from the CLI or via the public API in a node context.
1377
+ *
1378
+ * This takes an optional param supplying a `process` object to be used.
1379
+ *
1380
+ * @param c an optional object wrapping `process` and `logger` objects
1381
+ * @returns a node.js `CompilerSystem` object
1382
+ */
1383
+ function createNodeSys(c = {}) {
1384
+ const prcs = c?.process ?? global.process;
1385
+ const logger = c?.logger;
1386
+ const destroys = /* @__PURE__ */ new Set();
1387
+ const onInterruptsCallbacks = [];
1388
+ const sysCpus = cpus();
1389
+ const hardwareConcurrency = sysCpus.length;
1390
+ const osPlatform = platform();
1391
+ const compilerExecutingPath = path.join(__dirname, "compiler", "index.mjs");
1392
+ const runInterruptsCallbacks = () => {
1393
+ const returnValues = [];
1394
+ let cb;
1395
+ while (isFunction(cb = onInterruptsCallbacks.pop())) try {
1396
+ const rtn = cb();
1397
+ returnValues.push(rtn);
1398
+ } catch {}
1399
+ return Promise.all(returnValues).then(() => {});
1400
+ };
1401
+ const sys = {
1402
+ name: "node",
1403
+ version: prcs.versions.node,
1404
+ access(p) {
1405
+ return new Promise((resolve) => {
1406
+ fs.access(p, (err) => resolve(!err));
1407
+ });
1408
+ },
1409
+ accessSync(p) {
1410
+ let hasAccess = false;
1411
+ try {
1412
+ fs.accessSync(p);
1413
+ hasAccess = true;
1414
+ } catch {}
1415
+ return hasAccess;
1416
+ },
1417
+ addDestroy(cb) {
1418
+ destroys.add(cb);
1419
+ },
1420
+ removeDestroy(cb) {
1421
+ destroys.delete(cb);
1422
+ },
1423
+ applyPrerenderGlobalPatch(opts) {
1424
+ opts.window.fetch = global.fetch;
1425
+ opts.window.Headers = global.Headers;
1426
+ opts.window.Request = global.Request;
1427
+ opts.window.Response = global.Response;
1428
+ },
1429
+ fetch: global.fetch,
1430
+ checkVersion,
1431
+ copyFile(src, dst) {
1432
+ return new Promise((resolve) => {
1433
+ fs.copyFile(src, dst, (err) => {
1434
+ resolve(!err);
1435
+ });
1436
+ });
1437
+ },
1438
+ createDir(p, opts) {
1439
+ return new Promise((resolve) => {
1440
+ if (opts) fs.mkdir(p, opts, (err) => {
1441
+ resolve({
1442
+ basename: path.basename(p),
1443
+ dirname: path.dirname(p),
1444
+ path: p,
1445
+ newDirs: [],
1446
+ error: err
1447
+ });
1448
+ });
1449
+ else fs.mkdir(p, (err) => {
1450
+ resolve({
1451
+ basename: path.basename(p),
1452
+ dirname: path.dirname(p),
1453
+ path: p,
1454
+ newDirs: [],
1455
+ error: err
1456
+ });
1457
+ });
1458
+ });
1459
+ },
1460
+ createDirSync(p, opts) {
1461
+ const results = {
1462
+ basename: path.basename(p),
1463
+ dirname: path.dirname(p),
1464
+ path: p,
1465
+ newDirs: [],
1466
+ error: null
1467
+ };
1468
+ try {
1469
+ fs.mkdirSync(p, opts);
1470
+ } catch (e) {
1471
+ results.error = e;
1472
+ }
1473
+ return results;
1474
+ },
1475
+ createWorkerController(maxConcurrentWorkers) {
1476
+ return new NodeWorkerController(path.join(__dirname, "sys", "node", "worker.mjs"), maxConcurrentWorkers);
1477
+ },
1478
+ async destroy() {
1479
+ const waits = [];
1480
+ destroys.forEach((cb) => {
1481
+ try {
1482
+ const rtn = cb();
1483
+ if (rtn && typeof rtn.then === "function") waits.push(rtn);
1484
+ } catch (e) {
1485
+ console.error(`node sys destroy: ${e}`);
1486
+ }
1487
+ });
1488
+ if (waits.length > 0) await Promise.all(waits);
1489
+ destroys.clear();
1490
+ },
1491
+ dynamicImport(p) {
1492
+ return import(pathToFileURL(p).href);
1493
+ },
1494
+ encodeToBase64(str) {
1495
+ return Buffer.from(str).toString("base64");
1496
+ },
1497
+ async ensureDependencies() {
1498
+ console.warn(`ensureDependencies will be removed in a future version of Stencil.`);
1499
+ console.warn(`To get the stencilPath, please use getCompilerExecutingPath().`);
1500
+ return {
1501
+ stencilPath: sys.getCompilerExecutingPath(),
1502
+ diagnostics: []
1503
+ };
1504
+ },
1505
+ async ensureResources() {
1506
+ console.warn(`ensureResources is a no-op, and will be removed in a future version of Stencil`);
1507
+ },
1508
+ exit: async (exitCode) => {
1509
+ await runInterruptsCallbacks();
1510
+ process.exitCode = exitCode;
1511
+ },
1512
+ getCurrentDirectory() {
1513
+ return normalizePath(prcs.cwd());
1514
+ },
1515
+ getCompilerExecutingPath() {
1516
+ return compilerExecutingPath;
1517
+ },
1518
+ getEnvironmentVar(key) {
1519
+ return process.env[key];
1520
+ },
1521
+ getLocalModulePath() {
1522
+ return null;
1523
+ },
1524
+ getRemoteModuleUrl() {
1525
+ return null;
1526
+ },
1527
+ glob: asyncGlob,
1528
+ hardwareConcurrency,
1529
+ isSymbolicLink(p) {
1530
+ return new Promise((resolve) => {
1531
+ try {
1532
+ fs.lstat(p, (err, stats) => {
1533
+ if (err) resolve(false);
1534
+ else resolve(stats.isSymbolicLink());
1535
+ });
1536
+ } catch {
1537
+ resolve(false);
1538
+ }
1539
+ });
1540
+ },
1541
+ nextTick: prcs.nextTick,
1542
+ normalizePath,
1543
+ onProcessInterrupt: (cb) => {
1544
+ if (!onInterruptsCallbacks.includes(cb)) onInterruptsCallbacks.push(cb);
1545
+ },
1546
+ platformPath: path,
1547
+ readDir(p) {
1548
+ return new Promise((resolve) => {
1549
+ fs.readdir(p, (err, files) => {
1550
+ if (err) resolve([]);
1551
+ else resolve(files.map((f) => {
1552
+ return normalizePath(path.join(p, f));
1553
+ }));
1554
+ });
1555
+ });
1556
+ },
1557
+ isTTY() {
1558
+ return !!process?.stdout?.isTTY;
1559
+ },
1560
+ readDirSync(p) {
1561
+ try {
1562
+ return fs.readdirSync(p).map((f) => {
1563
+ return normalizePath(path.join(p, f));
1564
+ });
1565
+ } catch {}
1566
+ return [];
1567
+ },
1568
+ readFile(p, encoding) {
1569
+ if (encoding === "binary") return new Promise((resolve) => {
1570
+ fs.readFile(p, (_, data) => {
1571
+ resolve(data);
1572
+ });
1573
+ });
1574
+ return new Promise((resolve) => {
1575
+ fs.readFile(p, "utf8", (_, data) => {
1576
+ resolve(data);
1577
+ });
1578
+ });
1579
+ },
1580
+ readFileSync(p) {
1581
+ try {
1582
+ return fs.readFileSync(p, "utf8");
1583
+ } catch {}
1584
+ },
1585
+ homeDir() {
1586
+ try {
1587
+ return os.homedir();
1588
+ } catch {}
1589
+ },
1590
+ realpath(p) {
1591
+ return new Promise((resolve) => {
1592
+ fs.realpath(p, "utf8", (e, data) => {
1593
+ resolve({
1594
+ path: data,
1595
+ error: e
1596
+ });
1597
+ });
1598
+ });
1599
+ },
1600
+ realpathSync(p) {
1601
+ const results = {
1602
+ path: void 0,
1603
+ error: null
1604
+ };
1605
+ try {
1606
+ results.path = fs.realpathSync(p, "utf8");
1607
+ } catch (e) {
1608
+ results.error = e;
1609
+ }
1610
+ return results;
1611
+ },
1612
+ rename(oldPath, newPath) {
1613
+ return new Promise((resolve) => {
1614
+ fs.rename(oldPath, newPath, (error) => {
1615
+ resolve({
1616
+ oldPath,
1617
+ newPath,
1618
+ error,
1619
+ oldDirs: [],
1620
+ oldFiles: [],
1621
+ newDirs: [],
1622
+ newFiles: [],
1623
+ renamed: [],
1624
+ isFile: false,
1625
+ isDirectory: false
1626
+ });
1627
+ });
1628
+ });
1629
+ },
1630
+ resolvePath(p) {
1631
+ return normalizePath(p);
1632
+ },
1633
+ removeDir(p, opts) {
1634
+ return new Promise((resolve) => {
1635
+ if (!!(opts && opts.recursive)) fs.rm(p, {
1636
+ recursive: true,
1637
+ force: true
1638
+ }, (err) => {
1639
+ resolve({
1640
+ basename: path.basename(p),
1641
+ dirname: path.dirname(p),
1642
+ path: p,
1643
+ removedDirs: [],
1644
+ removedFiles: [],
1645
+ error: err
1646
+ });
1647
+ });
1648
+ else fs.rmdir(p, (err) => {
1649
+ resolve({
1650
+ basename: path.basename(p),
1651
+ dirname: path.dirname(p),
1652
+ path: p,
1653
+ removedDirs: [],
1654
+ removedFiles: [],
1655
+ error: err
1656
+ });
1657
+ });
1658
+ });
1659
+ },
1660
+ removeDirSync(p, opts) {
1661
+ try {
1662
+ if (!!(opts && opts.recursive)) fs.rmSync(p, {
1663
+ recursive: true,
1664
+ force: true
1665
+ });
1666
+ else fs.rmdirSync(p);
1667
+ return {
1668
+ basename: path.basename(p),
1669
+ dirname: path.dirname(p),
1670
+ path: p,
1671
+ removedDirs: [],
1672
+ removedFiles: [],
1673
+ error: null
1674
+ };
1675
+ } catch (e) {
1676
+ return {
1677
+ basename: path.basename(p),
1678
+ dirname: path.dirname(p),
1679
+ path: p,
1680
+ removedDirs: [],
1681
+ removedFiles: [],
1682
+ error: e
1683
+ };
1684
+ }
1685
+ },
1686
+ removeFile(p) {
1687
+ return new Promise((resolve) => {
1688
+ fs.unlink(p, (err) => {
1689
+ resolve({
1690
+ basename: path.basename(p),
1691
+ dirname: path.dirname(p),
1692
+ path: p,
1693
+ error: err
1694
+ });
1695
+ });
1696
+ });
1697
+ },
1698
+ removeFileSync(p) {
1699
+ const results = {
1700
+ basename: path.basename(p),
1701
+ dirname: path.dirname(p),
1702
+ path: p,
1703
+ error: null
1704
+ };
1705
+ try {
1706
+ fs.unlinkSync(p);
1707
+ } catch (e) {
1708
+ results.error = e;
1709
+ }
1710
+ return results;
1711
+ },
1712
+ setupCompiler(_c) {
1713
+ sys.watchTimeout = 80;
1714
+ sys.events = buildEvents();
1715
+ const activeSubscriptions = /* @__PURE__ */ new Map();
1716
+ /**
1717
+ * Watch a directory for changes using @parcel/watcher.
1718
+ * Uses native file system events (FSEvents on macOS, inotify on Linux, ReadDirectoryChangesW on Windows)
1719
+ * for efficient, low-latency change detection.
1720
+ *
1721
+ * @param p - the directory path to watch
1722
+ * @param callback - the callback function when changes occur
1723
+ * @param _recursive - unused recursive flag
1724
+ * @returns a file watcher with a close method
1725
+ */
1726
+ sys.watchDirectory = (p, callback, _recursive) => {
1727
+ logger?.debug(`NODE_SYS_DEBUG::watchDir ${p}`);
1728
+ const subscriptionPromise = parcelWatcher.subscribe(p, (err, events) => {
1729
+ if (err) {
1730
+ logger?.error(`Watch error for ${p}: ${err.message}`);
1731
+ return;
1732
+ }
1733
+ for (const event of events) {
1734
+ const fileName = normalizePath(event.path);
1735
+ logger?.debug(`NODE_SYS_DEBUG::watchDir:callback dir=${p} changedPath=${fileName} type=${event.type}`);
1736
+ if (event.type === "create") callback(fileName, "fileAdd");
1737
+ else if (event.type === "update") callback(fileName, "fileUpdate");
1738
+ else if (event.type === "delete") callback(fileName, "fileDelete");
1739
+ }
1740
+ }, { ignore: [
1741
+ ".git",
1742
+ "node_modules",
1743
+ ".stencil",
1744
+ "dist",
1745
+ "www",
1746
+ ".cache"
1747
+ ] }).catch((err) => {
1748
+ logger?.debug(`Watch subscribe failed for ${p}: ${err.message}`);
1749
+ return null;
1750
+ });
1751
+ activeSubscriptions.set(p, subscriptionPromise);
1752
+ const close = () => {
1753
+ const sub = activeSubscriptions.get(p);
1754
+ if (sub) {
1755
+ activeSubscriptions.delete(p);
1756
+ sub.then((s) => s?.unsubscribe()).catch(() => {});
1757
+ }
1758
+ };
1759
+ sys.addDestroy(close);
1760
+ return { close() {
1761
+ sys.removeDestroy(close);
1762
+ close();
1763
+ } };
1764
+ };
1765
+ /**
1766
+ * Watch an individual file for changes using @parcel/watcher.
1767
+ * Watches the parent directory and filters events for the specific file.
1768
+ *
1769
+ * @param filePath - the file path to watch
1770
+ * @param callback - the callback function when the file changes
1771
+ * @returns a file watcher with a close method
1772
+ */
1773
+ sys.watchFile = (filePath, callback) => {
1774
+ logger?.debug(`NODE_SYS_DEBUG::watchFile ${filePath}`);
1775
+ const normalizedPath = normalizePath(filePath);
1776
+ const dirPath = path.dirname(filePath);
1777
+ const subscriptionPromise = parcelWatcher.subscribe(dirPath, (err, events) => {
1778
+ if (err) {
1779
+ logger?.error(`Watch error for ${filePath}: ${err.message}`);
1780
+ return;
1781
+ }
1782
+ for (const event of events) {
1783
+ const eventPath = normalizePath(event.path);
1784
+ if (eventPath === normalizedPath) {
1785
+ logger?.debug(`NODE_SYS_DEBUG::watchFile:callback file=${filePath} type=${event.type}`);
1786
+ if (event.type === "create") {
1787
+ callback(eventPath, "fileAdd");
1788
+ sys.events.emit("fileAdd", eventPath);
1789
+ } else if (event.type === "update") {
1790
+ callback(eventPath, "fileUpdate");
1791
+ sys.events.emit("fileUpdate", eventPath);
1792
+ } else if (event.type === "delete") {
1793
+ callback(eventPath, "fileDelete");
1794
+ sys.events.emit("fileDelete", eventPath);
1795
+ }
1796
+ }
1797
+ }
1798
+ }, { ignore: [".git", "node_modules"] }).catch((err) => {
1799
+ logger?.debug(`Watch subscribe failed for ${filePath}: ${err.message}`);
1800
+ return null;
1801
+ });
1802
+ const subscriptionKey = `file:${filePath}`;
1803
+ activeSubscriptions.set(subscriptionKey, subscriptionPromise);
1804
+ const close = () => {
1805
+ const sub = activeSubscriptions.get(subscriptionKey);
1806
+ if (sub) {
1807
+ activeSubscriptions.delete(subscriptionKey);
1808
+ sub.then((s) => s?.unsubscribe()).catch(() => {});
1809
+ }
1810
+ };
1811
+ sys.addDestroy(close);
1812
+ return { close() {
1813
+ sys.removeDestroy(close);
1814
+ close();
1815
+ } };
1816
+ };
1817
+ },
1818
+ stat(p) {
1819
+ return new Promise((resolve) => {
1820
+ fs.stat(p, (err, fsStat) => {
1821
+ if (err) resolve({
1822
+ isDirectory: false,
1823
+ isFile: false,
1824
+ isSymbolicLink: false,
1825
+ size: 0,
1826
+ mtimeMs: 0,
1827
+ error: err
1828
+ });
1829
+ else resolve({
1830
+ isDirectory: fsStat.isDirectory(),
1831
+ isFile: fsStat.isFile(),
1832
+ isSymbolicLink: fsStat.isSymbolicLink(),
1833
+ size: fsStat.size,
1834
+ mtimeMs: fsStat.mtimeMs,
1835
+ error: null
1836
+ });
1837
+ });
1838
+ });
1839
+ },
1840
+ statSync(p) {
1841
+ try {
1842
+ const fsStat = fs.statSync(p);
1843
+ return {
1844
+ isDirectory: fsStat.isDirectory(),
1845
+ isFile: fsStat.isFile(),
1846
+ isSymbolicLink: fsStat.isSymbolicLink(),
1847
+ size: fsStat.size,
1848
+ mtimeMs: fsStat.mtimeMs,
1849
+ error: null
1850
+ };
1851
+ } catch (e) {
1852
+ return {
1853
+ isDirectory: false,
1854
+ isFile: false,
1855
+ isSymbolicLink: false,
1856
+ size: 0,
1857
+ mtimeMs: 0,
1858
+ error: e
1859
+ };
1860
+ }
1861
+ },
1862
+ tmpDirSync() {
1863
+ return tmpdir();
1864
+ },
1865
+ writeFile(p, content) {
1866
+ return new Promise((resolve) => {
1867
+ fs.writeFile(p, content, (err) => {
1868
+ resolve({
1869
+ path: p,
1870
+ error: err
1871
+ });
1872
+ });
1873
+ });
1874
+ },
1875
+ writeFileSync(p, content) {
1876
+ const results = {
1877
+ path: p,
1878
+ error: null
1879
+ };
1880
+ try {
1881
+ fs.writeFileSync(p, content);
1882
+ } catch (e) {
1883
+ results.error = e;
1884
+ }
1885
+ return results;
1886
+ },
1887
+ generateContentHash(content, length) {
1888
+ let hash = createHash("sha1").update(content).digest("hex").toLowerCase();
1889
+ if (typeof length === "number") hash = hash.slice(0, length);
1890
+ return Promise.resolve(hash);
1891
+ },
1892
+ generateFileHash(filePath, length) {
1893
+ return new Promise((resolve, reject) => {
1894
+ const h = createHash("sha1");
1895
+ fs.createReadStream(filePath).on("error", (err) => reject(err)).on("data", (data) => h.update(data)).on("end", () => {
1896
+ let hash = h.digest("hex").toLowerCase();
1897
+ if (typeof length === "number") hash = hash.slice(0, length);
1898
+ resolve(hash);
1899
+ });
1900
+ });
1901
+ },
1902
+ copy: nodeCopyTasks,
1903
+ details: {
1904
+ cpuModel: (Array.isArray(sysCpus) && sysCpus.length > 0 ? sysCpus[0] && sysCpus[0].model : "") || "",
1905
+ freemem() {
1906
+ return freemem();
1907
+ },
1908
+ platform: osPlatform === "darwin" || osPlatform === "linux" ? osPlatform : osPlatform === "win32" ? "windows" : "",
1909
+ release: release(),
1910
+ totalmem: totalmem()
1911
+ }
1912
+ };
1913
+ sys.lazyRequire = new NodeLazyRequire(new NodeResolveModule(), {
1914
+ "@types/jest": {
1915
+ minVersion: "24.9.1",
1916
+ recommendedVersion: "29",
1917
+ maxVersion: "29.0.0"
1918
+ },
1919
+ jest: {
1920
+ minVersion: "24.9.0",
1921
+ recommendedVersion: "29",
1922
+ maxVersion: "29.0.0"
1923
+ },
1924
+ "jest-cli": {
1925
+ minVersion: "24.9.0",
1926
+ recommendedVersion: "29",
1927
+ maxVersion: "29.0.0"
1928
+ },
1929
+ puppeteer: {
1930
+ minVersion: "10.0.0",
1931
+ recommendedVersion: "20"
1932
+ },
1933
+ "puppeteer-core": {
1934
+ minVersion: "10.0.0",
1935
+ recommendedVersion: "20"
1936
+ },
1937
+ "workbox-build": {
1938
+ minVersion: "4.3.1",
1939
+ recommendedVersion: "4.3.1"
1940
+ }
1941
+ });
1942
+ prcs.on("SIGINT", runInterruptsCallbacks);
1943
+ prcs.on("exit", runInterruptsCallbacks);
1944
+ return sys;
1945
+ }
1946
+ //#endregion
1947
+ export { LOG_LEVELS as a, CustomElementsExportBehaviorOptions as i, setupNodeProcess as n, buildEvents as o, createNodeLogger as r, createNodeSys as t };