@stencil/core 4.43.5 → 5.0.0-alpha.10

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