@easemate/web-kit 0.1.0

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 (358) hide show
  1. package/README.md +824 -0
  2. package/build/components/code/index.cjs +152 -0
  3. package/build/components/code/index.d.cts +11 -0
  4. package/build/components/code/index.d.ts +11 -0
  5. package/build/components/code/index.js +148 -0
  6. package/build/components/code/utils/highlight-api.cjs +18 -0
  7. package/build/components/code/utils/highlight-api.d.cts +7 -0
  8. package/build/components/code/utils/highlight-api.d.ts +7 -0
  9. package/build/components/code/utils/highlight-api.js +14 -0
  10. package/build/components/code/utils/syntax-grammars.cjs +62 -0
  11. package/build/components/code/utils/syntax-grammars.d.cts +7 -0
  12. package/build/components/code/utils/syntax-grammars.d.ts +7 -0
  13. package/build/components/code/utils/syntax-grammars.js +59 -0
  14. package/build/components/code/utils/syntax-highlighter-theme.cjs +27 -0
  15. package/build/components/code/utils/syntax-highlighter-theme.d.cts +3 -0
  16. package/build/components/code/utils/syntax-highlighter-theme.d.ts +3 -0
  17. package/build/components/code/utils/syntax-highlighter-theme.js +23 -0
  18. package/build/components/code/utils/syntax-highlighter-types.cjs +2 -0
  19. package/build/components/code/utils/syntax-highlighter-types.d.cts +12 -0
  20. package/build/components/code/utils/syntax-highlighter-types.d.ts +12 -0
  21. package/build/components/code/utils/syntax-highlighter-types.js +1 -0
  22. package/build/components/code/utils/syntax-tokenizer.cjs +63 -0
  23. package/build/components/code/utils/syntax-tokenizer.d.cts +3 -0
  24. package/build/components/code/utils/syntax-tokenizer.d.ts +3 -0
  25. package/build/components/code/utils/syntax-tokenizer.js +58 -0
  26. package/build/components/curve/bezier-conversion.cjs +23 -0
  27. package/build/components/curve/bezier-conversion.d.cts +2 -0
  28. package/build/components/curve/bezier-conversion.d.ts +2 -0
  29. package/build/components/curve/bezier-conversion.js +19 -0
  30. package/build/components/curve/canvas-controls.cjs +300 -0
  31. package/build/components/curve/canvas-controls.d.cts +12 -0
  32. package/build/components/curve/canvas-controls.d.ts +12 -0
  33. package/build/components/curve/canvas-controls.js +296 -0
  34. package/build/components/curve/canvas.cjs +1208 -0
  35. package/build/components/curve/canvas.d.cts +24 -0
  36. package/build/components/curve/canvas.d.ts +24 -0
  37. package/build/components/curve/canvas.js +1204 -0
  38. package/build/components/curve/constants.cjs +203 -0
  39. package/build/components/curve/constants.d.cts +23 -0
  40. package/build/components/curve/constants.d.ts +23 -0
  41. package/build/components/curve/constants.js +200 -0
  42. package/build/components/curve/controls.cjs +942 -0
  43. package/build/components/curve/controls.d.cts +37 -0
  44. package/build/components/curve/controls.d.ts +37 -0
  45. package/build/components/curve/controls.js +938 -0
  46. package/build/components/curve/index.cjs +335 -0
  47. package/build/components/curve/index.d.cts +31 -0
  48. package/build/components/curve/index.d.ts +31 -0
  49. package/build/components/curve/index.js +330 -0
  50. package/build/components/curve/output.cjs +141 -0
  51. package/build/components/curve/output.d.cts +19 -0
  52. package/build/components/curve/output.d.ts +19 -0
  53. package/build/components/curve/output.js +137 -0
  54. package/build/components/curve/styles.cjs +493 -0
  55. package/build/components/curve/styles.d.cts +6 -0
  56. package/build/components/curve/styles.d.ts +6 -0
  57. package/build/components/curve/styles.js +490 -0
  58. package/build/components/curve/svg-renderer.cjs +185 -0
  59. package/build/components/curve/svg-renderer.d.cts +9 -0
  60. package/build/components/curve/svg-renderer.d.ts +9 -0
  61. package/build/components/curve/svg-renderer.js +175 -0
  62. package/build/components/curve/toolbar.cjs +368 -0
  63. package/build/components/curve/toolbar.d.cts +26 -0
  64. package/build/components/curve/toolbar.d.ts +26 -0
  65. package/build/components/curve/toolbar.js +364 -0
  66. package/build/components/curve/types.cjs +10 -0
  67. package/build/components/curve/types.d.cts +33 -0
  68. package/build/components/curve/types.d.ts +33 -0
  69. package/build/components/curve/types.js +7 -0
  70. package/build/components/curve/utils.cjs +541 -0
  71. package/build/components/curve/utils.d.cts +33 -0
  72. package/build/components/curve/utils.d.ts +33 -0
  73. package/build/components/curve/utils.js +521 -0
  74. package/build/components/index.cjs +18 -0
  75. package/build/components/index.d.cts +2 -0
  76. package/build/components/index.d.ts +2 -0
  77. package/build/components/index.js +2 -0
  78. package/build/decorators/Component.cjs +127 -0
  79. package/build/decorators/Component.d.cts +28 -0
  80. package/build/decorators/Component.d.ts +28 -0
  81. package/build/decorators/Component.js +123 -0
  82. package/build/decorators/Listen.cjs +154 -0
  83. package/build/decorators/Listen.d.cts +18 -0
  84. package/build/decorators/Listen.d.ts +18 -0
  85. package/build/decorators/Listen.js +151 -0
  86. package/build/decorators/OutsideClick.cjs +64 -0
  87. package/build/decorators/OutsideClick.d.cts +16 -0
  88. package/build/decorators/OutsideClick.d.ts +16 -0
  89. package/build/decorators/OutsideClick.js +59 -0
  90. package/build/decorators/Prop.cjs +273 -0
  91. package/build/decorators/Prop.d.cts +22 -0
  92. package/build/decorators/Prop.d.ts +22 -0
  93. package/build/decorators/Prop.js +270 -0
  94. package/build/decorators/Query.cjs +79 -0
  95. package/build/decorators/Query.d.cts +27 -0
  96. package/build/decorators/Query.d.ts +27 -0
  97. package/build/decorators/Query.js +76 -0
  98. package/build/decorators/Watch.cjs +52 -0
  99. package/build/decorators/Watch.d.cts +11 -0
  100. package/build/decorators/Watch.d.ts +11 -0
  101. package/build/decorators/Watch.js +49 -0
  102. package/build/decorators/index.cjs +15 -0
  103. package/build/decorators/index.d.cts +6 -0
  104. package/build/decorators/index.d.ts +6 -0
  105. package/build/decorators/index.js +6 -0
  106. package/build/elements/button/index.cjs +214 -0
  107. package/build/elements/button/index.d.cts +11 -0
  108. package/build/elements/button/index.d.ts +11 -0
  109. package/build/elements/button/index.js +210 -0
  110. package/build/elements/checkbox/index.cjs +316 -0
  111. package/build/elements/checkbox/index.d.cts +14 -0
  112. package/build/elements/checkbox/index.d.ts +14 -0
  113. package/build/elements/checkbox/index.js +312 -0
  114. package/build/elements/color/index.cjs +154 -0
  115. package/build/elements/color/index.d.cts +18 -0
  116. package/build/elements/color/index.d.ts +18 -0
  117. package/build/elements/color/index.js +150 -0
  118. package/build/elements/color/picker.cjs +544 -0
  119. package/build/elements/color/picker.d.cts +37 -0
  120. package/build/elements/color/picker.d.ts +37 -0
  121. package/build/elements/color/picker.js +540 -0
  122. package/build/elements/color/utils.cjs +235 -0
  123. package/build/elements/color/utils.d.cts +37 -0
  124. package/build/elements/color/utils.d.ts +37 -0
  125. package/build/elements/color/utils.js +218 -0
  126. package/build/elements/dropdown/index.cjs +875 -0
  127. package/build/elements/dropdown/index.d.cts +30 -0
  128. package/build/elements/dropdown/index.d.ts +30 -0
  129. package/build/elements/dropdown/index.js +871 -0
  130. package/build/elements/field/index.cjs +82 -0
  131. package/build/elements/field/index.d.cts +4 -0
  132. package/build/elements/field/index.d.ts +4 -0
  133. package/build/elements/field/index.js +78 -0
  134. package/build/elements/icons/animation/chevron.cjs +57 -0
  135. package/build/elements/icons/animation/chevron.d.cts +10 -0
  136. package/build/elements/icons/animation/chevron.d.ts +10 -0
  137. package/build/elements/icons/animation/chevron.js +53 -0
  138. package/build/elements/icons/animation/clear.cjs +74 -0
  139. package/build/elements/icons/animation/clear.d.cts +3 -0
  140. package/build/elements/icons/animation/clear.d.ts +3 -0
  141. package/build/elements/icons/animation/clear.js +70 -0
  142. package/build/elements/icons/animation/grid.cjs +77 -0
  143. package/build/elements/icons/animation/grid.d.cts +8 -0
  144. package/build/elements/icons/animation/grid.d.ts +8 -0
  145. package/build/elements/icons/animation/grid.js +73 -0
  146. package/build/elements/icons/animation/loading.cjs +68 -0
  147. package/build/elements/icons/animation/loading.d.cts +3 -0
  148. package/build/elements/icons/animation/loading.d.ts +3 -0
  149. package/build/elements/icons/animation/loading.js +64 -0
  150. package/build/elements/icons/animation/snap.cjs +133 -0
  151. package/build/elements/icons/animation/snap.d.cts +8 -0
  152. package/build/elements/icons/animation/snap.d.ts +8 -0
  153. package/build/elements/icons/animation/snap.js +129 -0
  154. package/build/elements/icons/index.cjs +40 -0
  155. package/build/elements/icons/index.d.cts +24 -0
  156. package/build/elements/icons/index.d.ts +24 -0
  157. package/build/elements/icons/index.js +24 -0
  158. package/build/elements/icons/interface/anchor-add.cjs +35 -0
  159. package/build/elements/icons/interface/anchor-add.d.cts +3 -0
  160. package/build/elements/icons/interface/anchor-add.d.ts +3 -0
  161. package/build/elements/icons/interface/anchor-add.js +31 -0
  162. package/build/elements/icons/interface/anchor-remove.cjs +34 -0
  163. package/build/elements/icons/interface/anchor-remove.d.cts +3 -0
  164. package/build/elements/icons/interface/anchor-remove.d.ts +3 -0
  165. package/build/elements/icons/interface/anchor-remove.js +30 -0
  166. package/build/elements/icons/interface/arrow-up.cjs +30 -0
  167. package/build/elements/icons/interface/arrow-up.d.cts +3 -0
  168. package/build/elements/icons/interface/arrow-up.d.ts +3 -0
  169. package/build/elements/icons/interface/arrow-up.js +26 -0
  170. package/build/elements/icons/interface/arrows-vertical.cjs +30 -0
  171. package/build/elements/icons/interface/arrows-vertical.d.cts +3 -0
  172. package/build/elements/icons/interface/arrows-vertical.d.ts +3 -0
  173. package/build/elements/icons/interface/arrows-vertical.js +26 -0
  174. package/build/elements/icons/interface/bezier-angle.cjs +33 -0
  175. package/build/elements/icons/interface/bezier-angle.d.cts +3 -0
  176. package/build/elements/icons/interface/bezier-angle.d.ts +3 -0
  177. package/build/elements/icons/interface/bezier-angle.js +29 -0
  178. package/build/elements/icons/interface/bezier-distribute.cjs +34 -0
  179. package/build/elements/icons/interface/bezier-distribute.d.cts +3 -0
  180. package/build/elements/icons/interface/bezier-distribute.d.ts +3 -0
  181. package/build/elements/icons/interface/bezier-distribute.js +30 -0
  182. package/build/elements/icons/interface/bezier-length.cjs +31 -0
  183. package/build/elements/icons/interface/bezier-length.d.cts +3 -0
  184. package/build/elements/icons/interface/bezier-length.d.ts +3 -0
  185. package/build/elements/icons/interface/bezier-length.js +27 -0
  186. package/build/elements/icons/interface/bezier-mirror.cjs +31 -0
  187. package/build/elements/icons/interface/bezier-mirror.d.cts +3 -0
  188. package/build/elements/icons/interface/bezier-mirror.d.ts +3 -0
  189. package/build/elements/icons/interface/bezier-mirror.js +27 -0
  190. package/build/elements/icons/interface/bezier.cjs +26 -0
  191. package/build/elements/icons/interface/bezier.d.cts +3 -0
  192. package/build/elements/icons/interface/bezier.d.ts +3 -0
  193. package/build/elements/icons/interface/bezier.js +22 -0
  194. package/build/elements/icons/interface/check.cjs +30 -0
  195. package/build/elements/icons/interface/check.d.cts +3 -0
  196. package/build/elements/icons/interface/check.d.ts +3 -0
  197. package/build/elements/icons/interface/check.js +26 -0
  198. package/build/elements/icons/interface/circle-arrow-left.cjs +30 -0
  199. package/build/elements/icons/interface/circle-arrow-left.d.cts +3 -0
  200. package/build/elements/icons/interface/circle-arrow-left.d.ts +3 -0
  201. package/build/elements/icons/interface/circle-arrow-left.js +26 -0
  202. package/build/elements/icons/interface/circle-arrow-right.cjs +30 -0
  203. package/build/elements/icons/interface/circle-arrow-right.d.cts +3 -0
  204. package/build/elements/icons/interface/circle-arrow-right.d.ts +3 -0
  205. package/build/elements/icons/interface/circle-arrow-right.js +26 -0
  206. package/build/elements/icons/interface/code.cjs +30 -0
  207. package/build/elements/icons/interface/code.d.cts +3 -0
  208. package/build/elements/icons/interface/code.d.ts +3 -0
  209. package/build/elements/icons/interface/code.js +26 -0
  210. package/build/elements/icons/interface/dots.cjs +32 -0
  211. package/build/elements/icons/interface/dots.d.cts +3 -0
  212. package/build/elements/icons/interface/dots.d.ts +3 -0
  213. package/build/elements/icons/interface/dots.js +28 -0
  214. package/build/elements/icons/interface/mention.cjs +30 -0
  215. package/build/elements/icons/interface/mention.d.cts +3 -0
  216. package/build/elements/icons/interface/mention.d.ts +3 -0
  217. package/build/elements/icons/interface/mention.js +26 -0
  218. package/build/elements/icons/interface/minus.cjs +30 -0
  219. package/build/elements/icons/interface/minus.d.cts +3 -0
  220. package/build/elements/icons/interface/minus.d.ts +3 -0
  221. package/build/elements/icons/interface/minus.js +26 -0
  222. package/build/elements/icons/interface/picker.cjs +34 -0
  223. package/build/elements/icons/interface/picker.d.cts +3 -0
  224. package/build/elements/icons/interface/picker.d.ts +3 -0
  225. package/build/elements/icons/interface/picker.js +30 -0
  226. package/build/elements/icons/interface/plus.cjs +30 -0
  227. package/build/elements/icons/interface/plus.d.cts +3 -0
  228. package/build/elements/icons/interface/plus.d.ts +3 -0
  229. package/build/elements/icons/interface/plus.js +26 -0
  230. package/build/elements/icons/interface/settings.cjs +30 -0
  231. package/build/elements/icons/interface/settings.d.cts +3 -0
  232. package/build/elements/icons/interface/settings.d.ts +3 -0
  233. package/build/elements/icons/interface/settings.js +26 -0
  234. package/build/elements/index.cjs +62 -0
  235. package/build/elements/index.d.cts +22 -0
  236. package/build/elements/index.d.ts +22 -0
  237. package/build/elements/index.js +22 -0
  238. package/build/elements/input/index.cjs +273 -0
  239. package/build/elements/input/index.d.cts +17 -0
  240. package/build/elements/input/index.d.ts +17 -0
  241. package/build/elements/input/index.js +269 -0
  242. package/build/elements/logo/index.cjs +732 -0
  243. package/build/elements/logo/index.d.cts +17 -0
  244. package/build/elements/logo/index.d.ts +17 -0
  245. package/build/elements/logo/index.js +728 -0
  246. package/build/elements/monitor/fps.cjs +432 -0
  247. package/build/elements/monitor/fps.d.cts +21 -0
  248. package/build/elements/monitor/fps.d.ts +21 -0
  249. package/build/elements/monitor/fps.js +428 -0
  250. package/build/elements/monitor/index.cjs +670 -0
  251. package/build/elements/monitor/index.d.cts +112 -0
  252. package/build/elements/monitor/index.d.ts +112 -0
  253. package/build/elements/monitor/index.js +666 -0
  254. package/build/elements/number/index.cjs +173 -0
  255. package/build/elements/number/index.d.cts +19 -0
  256. package/build/elements/number/index.d.ts +19 -0
  257. package/build/elements/number/index.js +169 -0
  258. package/build/elements/origin/index.cjs +169 -0
  259. package/build/elements/origin/index.d.cts +12 -0
  260. package/build/elements/origin/index.d.ts +12 -0
  261. package/build/elements/origin/index.js +165 -0
  262. package/build/elements/popover/index.cjs +209 -0
  263. package/build/elements/popover/index.d.cts +19 -0
  264. package/build/elements/popover/index.d.ts +19 -0
  265. package/build/elements/popover/index.js +205 -0
  266. package/build/elements/radio/index.cjs +301 -0
  267. package/build/elements/radio/index.d.cts +13 -0
  268. package/build/elements/radio/index.d.ts +13 -0
  269. package/build/elements/radio/index.js +283 -0
  270. package/build/elements/radio/input.cjs +329 -0
  271. package/build/elements/radio/input.d.cts +15 -0
  272. package/build/elements/radio/input.d.ts +15 -0
  273. package/build/elements/radio/input.js +325 -0
  274. package/build/elements/radio/option.cjs +15 -0
  275. package/build/elements/radio/option.d.cts +3 -0
  276. package/build/elements/radio/option.d.ts +3 -0
  277. package/build/elements/radio/option.js +11 -0
  278. package/build/elements/shared.cjs +66 -0
  279. package/build/elements/shared.d.cts +40 -0
  280. package/build/elements/shared.d.ts +40 -0
  281. package/build/elements/shared.js +59 -0
  282. package/build/elements/slider/index.cjs +232 -0
  283. package/build/elements/slider/index.d.cts +20 -0
  284. package/build/elements/slider/index.d.ts +20 -0
  285. package/build/elements/slider/index.js +228 -0
  286. package/build/elements/state/index.cjs +681 -0
  287. package/build/elements/state/index.d.cts +86 -0
  288. package/build/elements/state/index.d.ts +86 -0
  289. package/build/elements/state/index.js +677 -0
  290. package/build/elements/toggle/index.cjs +151 -0
  291. package/build/elements/toggle/index.d.cts +9 -0
  292. package/build/elements/toggle/index.d.ts +9 -0
  293. package/build/elements/toggle/index.js +147 -0
  294. package/build/elements/tooltip/index.cjs +187 -0
  295. package/build/elements/tooltip/index.d.cts +17 -0
  296. package/build/elements/tooltip/index.d.ts +17 -0
  297. package/build/elements/tooltip/index.js +183 -0
  298. package/build/index.cjs +40 -0
  299. package/build/index.d.cts +6 -0
  300. package/build/index.d.ts +6 -0
  301. package/build/index.js +12 -0
  302. package/build/init.cjs +325 -0
  303. package/build/init.d.cts +157 -0
  304. package/build/init.d.ts +157 -0
  305. package/build/init.js +289 -0
  306. package/build/internal/component-loaders.cjs +206 -0
  307. package/build/internal/component-loaders.d.cts +52 -0
  308. package/build/internal/component-loaders.d.ts +52 -0
  309. package/build/internal/component-loaders.js +167 -0
  310. package/build/internal/fonts.cjs +128 -0
  311. package/build/internal/fonts.d.cts +32 -0
  312. package/build/internal/fonts.d.ts +32 -0
  313. package/build/internal/fonts.js +123 -0
  314. package/build/internal/lazy-load.cjs +89 -0
  315. package/build/internal/lazy-load.d.cts +32 -0
  316. package/build/internal/lazy-load.d.ts +32 -0
  317. package/build/internal/lazy-load.js +86 -0
  318. package/build/internal/style-inject.cjs +236 -0
  319. package/build/internal/style-inject.d.cts +44 -0
  320. package/build/internal/style-inject.d.ts +44 -0
  321. package/build/internal/style-inject.js +226 -0
  322. package/build/register.cjs +36 -0
  323. package/build/register.d.cts +32 -0
  324. package/build/register.d.ts +32 -0
  325. package/build/register.js +34 -0
  326. package/build/theme/index.cjs +452 -0
  327. package/build/theme/index.d.cts +146 -0
  328. package/build/theme/index.d.ts +146 -0
  329. package/build/theme/index.js +423 -0
  330. package/build/theme/presets.cjs +54 -0
  331. package/build/theme/presets.d.cts +19 -0
  332. package/build/theme/presets.d.ts +19 -0
  333. package/build/theme/presets.js +51 -0
  334. package/build/theme/registry.cjs +204 -0
  335. package/build/theme/registry.d.cts +99 -0
  336. package/build/theme/registry.d.ts +99 -0
  337. package/build/theme/registry.js +194 -0
  338. package/build/theme/tokens.cjs +148 -0
  339. package/build/theme/tokens.d.cts +163 -0
  340. package/build/theme/tokens.d.ts +163 -0
  341. package/build/theme/tokens.js +145 -0
  342. package/build/utils/dismiss-controller.cjs +77 -0
  343. package/build/utils/dismiss-controller.d.cts +14 -0
  344. package/build/utils/dismiss-controller.d.ts +14 -0
  345. package/build/utils/dismiss-controller.js +73 -0
  346. package/build/utils/index.cjs +18 -0
  347. package/build/utils/index.d.cts +3 -0
  348. package/build/utils/index.d.ts +3 -0
  349. package/build/utils/index.js +3 -0
  350. package/build/utils/outside-click.cjs +82 -0
  351. package/build/utils/outside-click.d.cts +18 -0
  352. package/build/utils/outside-click.d.ts +18 -0
  353. package/build/utils/outside-click.js +74 -0
  354. package/build/utils/template-helpers.cjs +39 -0
  355. package/build/utils/template-helpers.d.cts +13 -0
  356. package/build/utils/template-helpers.d.ts +13 -0
  357. package/build/utils/template-helpers.js +28 -0
  358. package/package.json +96 -0
@@ -0,0 +1,670 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Monitor = void 0;
4
+ const lit_html_1 = require("lit-html");
5
+ const Component_1 = require("~/decorators/Component");
6
+ const Listen_1 = require("~/decorators/Listen");
7
+ const Watch_1 = require("~/decorators/Watch");
8
+ const template_helpers_1 = require("~/utils/template-helpers");
9
+ require("./fps.cjs");
10
+ const METRIC_THRESHOLDS = {
11
+ LCP: { good: 2500, poor: 4000 },
12
+ INP: { good: 200, poor: 500 },
13
+ CLS: { good: 0.1, poor: 0.25 },
14
+ FCP: { good: 1800, poor: 3000 },
15
+ ttfb: { good: 800, poor: 1800 },
16
+ loadTime: { good: 3000, poor: 6000 },
17
+ domInteractive: { good: 1500, poor: 3500 },
18
+ fps: { good: 55, poor: 30 },
19
+ TBT: { good: 200, poor: 600 }
20
+ };
21
+ const GLOBAL_BENCHMARKS = {
22
+ LCP: 2400,
23
+ INP: 250,
24
+ CLS: 0.05,
25
+ FCP: 1600,
26
+ TBT: 300
27
+ };
28
+ const rateMetric = (metric, value) => {
29
+ if (value === null) {
30
+ return 'unknown';
31
+ }
32
+ const thresholds = METRIC_THRESHOLDS[metric];
33
+ if (!thresholds) {
34
+ return 'unknown';
35
+ }
36
+ if (metric === 'fps') {
37
+ if (value >= thresholds.good) {
38
+ return 'good';
39
+ }
40
+ if (value >= thresholds.poor) {
41
+ return 'needs-improvement';
42
+ }
43
+ return 'poor';
44
+ }
45
+ if (value <= thresholds.good) {
46
+ return 'good';
47
+ }
48
+ if (value < thresholds.poor) {
49
+ return 'needs-improvement';
50
+ }
51
+ return 'poor';
52
+ };
53
+ const formatMetric = (metric, value) => {
54
+ if (value === null) {
55
+ return 'N/A';
56
+ }
57
+ if (metric === 'CLS') {
58
+ return value.toFixed(3);
59
+ }
60
+ if (metric === 'fps') {
61
+ return `${Math.round(value)}`;
62
+ }
63
+ if (value < 1000) {
64
+ return `${Math.round(value)}ms`;
65
+ }
66
+ return `${(value / 1000).toFixed(2)}s`;
67
+ };
68
+ const formatBytes = (bytes, decimals = 1) => {
69
+ if (bytes == null || !Number.isFinite(bytes) || bytes <= 0) {
70
+ return '0 B';
71
+ }
72
+ const k = 1024;
73
+ const dm = decimals < 0 ? 0 : decimals;
74
+ const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
75
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
76
+ return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
77
+ };
78
+ const estimateCarbonFootprint = (totalBytes) => {
79
+ if (totalBytes <= 0) {
80
+ return '0g CO2 eq.';
81
+ }
82
+ const emissions = (totalBytes / 1000000000) * 0.81;
83
+ return `${emissions.toFixed(3)}g CO2 eq.`;
84
+ };
85
+ @(0, Component_1.Component)({
86
+ tag: 'ease-monitor',
87
+ styles: `
88
+ :host {
89
+ position: relative;
90
+ z-index: 100000;
91
+ user-select: none;
92
+ -webkit-user-select: none;
93
+
94
+ }
95
+
96
+ [part="container"] {
97
+ width: 320px;
98
+ overflow: hidden;
99
+ }
100
+
101
+ [part="header"] {
102
+ display: flex;
103
+ justify-content: space-between;
104
+ align-items: center;
105
+ }
106
+
107
+ [part="title"] {
108
+ display: flex;
109
+ align-items: center;
110
+ gap: 0.5em;
111
+ }
112
+
113
+ [part="content"] {
114
+ display: grid;
115
+ gap: 1em;
116
+ max-height: 80vh;
117
+ overflow-y: auto;
118
+ }
119
+
120
+ .metrics-grid {
121
+ display: grid;
122
+ grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
123
+ gap: 0.5em;
124
+ }
125
+
126
+ .metric-box {
127
+ text-align: center;
128
+ cursor: help;
129
+ }
130
+
131
+ .metric-value {
132
+ font-variant-numeric: tabular-nums;
133
+ }
134
+
135
+ .rating-good {
136
+ color: #22c55e;
137
+ }
138
+ .rating-needs-improvement {
139
+ color: #eab308;
140
+ }
141
+ .rating-poor {
142
+ color: #ef4444;
143
+ }
144
+ .rating-unknown {
145
+ color: #6b7280;
146
+ }
147
+
148
+ .status-indicator.rating-good {
149
+ background-color: #22c55e;
150
+ }
151
+ .status-indicator.rating-needs-improvement {
152
+ background-color: #eab308;
153
+ }
154
+ .status-indicator.rating-poor {
155
+ background-color: #ef4444;
156
+ }
157
+ .status-indicator.rating-unknown {
158
+ background-color: #6b7280;
159
+ }
160
+
161
+ .memory-used.rating-good {
162
+ background-color: #22c55e;
163
+ }
164
+ .memory-used.rating-needs-improvement {
165
+ background-color: #eab308;
166
+ }
167
+ .memory-used.rating-poor {
168
+ background-color: #ef4444;
169
+ }
170
+
171
+ .resource-list, .memory-usage, .network-info {
172
+ display: grid;
173
+ gap: 0.25em;
174
+ }
175
+
176
+ .resource-item, .network-item, .longtask-item {
177
+ display: flex;
178
+ justify-content: space-between;
179
+ font-variant-numeric: tabular-nums;
180
+ }
181
+
182
+ .memory-bar {
183
+ height: 10px;
184
+ overflow: hidden;
185
+ position: relative;
186
+ }
187
+
188
+ .memory-used {
189
+ height: 100%;
190
+ transition: width 0.5s ease-in-out;
191
+ }
192
+
193
+ .status-indicator {
194
+ width: 8px;
195
+ height: 8px;
196
+ border-radius: 50%;
197
+ }
198
+
199
+ .carbon-estimate {
200
+ text-align: right;
201
+ }
202
+
203
+ .trend-indicator {
204
+ display: inline-block;
205
+ width: 1em;
206
+ text-align: center;
207
+ }
208
+ `
209
+ })
210
+ class Monitor extends HTMLElement {
211
+ @(0, Watch_1.Watch)({})
212
+ accessor metrics = {
213
+ navigation: { loadTime: null, domInteractive: null, ttfb: null },
214
+ coreWebVitals: { LCP: null, INP: null, CLS: 0, FCP: null, TBT: 0 },
215
+ resources: {
216
+ js: { count: 0, size: 0 },
217
+ css: { count: 0, size: 0 },
218
+ img: { count: 0, size: 0 },
219
+ other: { count: 0, size: 0 },
220
+ totalSize: 0
221
+ },
222
+ memory: null,
223
+ fps: null,
224
+ longTasks: { count: 0, totalDuration: 0 }
225
+ };
226
+ @(0, Watch_1.Watch)({})
227
+ accessor network = {
228
+ effectiveType: 'N/A',
229
+ rtt: 0
230
+ };
231
+ observers = [];
232
+ memoryInterval = null;
233
+ clsEntries = [];
234
+ inpEntries = [];
235
+ maxINP = 0;
236
+ longTaskEntries = [];
237
+ trendHistory = {};
238
+ maxTrendLength = 5;
239
+ connectedCallback() {
240
+ this.initObservers();
241
+ this.collectInitialMetrics();
242
+ this.startMemoryMonitoring();
243
+ this.initNetworkMonitoring();
244
+ if (document.readyState !== 'complete') {
245
+ window.addEventListener('load', this.handlePageLoad);
246
+ }
247
+ else {
248
+ this.handlePageLoad();
249
+ }
250
+ }
251
+ disconnectedCallback() {
252
+ this.observers.forEach((observer) => {
253
+ observer.disconnect();
254
+ });
255
+ this.observers = [];
256
+ this.stopMemoryMonitoring();
257
+ this.stopNetworkMonitoring();
258
+ window.removeEventListener('load', this.handlePageLoad);
259
+ }
260
+ @(0, Listen_1.Listen)('monitor-fps')
261
+ handleFpsUpdate(event) {
262
+ const fps = event.detail?.fps ?? null;
263
+ this.metrics.fps = fps;
264
+ this.updateTrend('fps', fps);
265
+ this.requestRender();
266
+ }
267
+ handlePageLoad = () => {
268
+ setTimeout(() => {
269
+ this.collectNavigationTiming();
270
+ this.requestRender();
271
+ }, 500);
272
+ };
273
+ initObservers() {
274
+ if (!('PerformanceObserver' in window)) {
275
+ console.warn('PerformanceObserver API not supported.');
276
+ return;
277
+ }
278
+ try {
279
+ const observer = new PerformanceObserver((list) => {
280
+ for (const entry of list.getEntries()) {
281
+ this.processPerformanceEntry(entry);
282
+ }
283
+ });
284
+ observer.observe({ type: 'largest-contentful-paint', buffered: true });
285
+ observer.observe({ type: 'event', buffered: true });
286
+ observer.observe({ type: 'layout-shift', buffered: true });
287
+ observer.observe({ type: 'paint', buffered: true });
288
+ observer.observe({ type: 'resource', buffered: true });
289
+ observer.observe({ type: 'longtask', buffered: true });
290
+ this.observers.push(observer);
291
+ }
292
+ catch (e) {
293
+ console.error('Error initializing PerformanceObserver:', e);
294
+ }
295
+ }
296
+ collectInitialMetrics() {
297
+ this.collectNavigationTiming();
298
+ const resourceEntries = performance.getEntriesByType('resource');
299
+ this.processResourceEntries(resourceEntries);
300
+ }
301
+ collectNavigationTiming() {
302
+ const navigationEntries = performance.getEntriesByType('navigation');
303
+ if (navigationEntries.length > 0) {
304
+ const navTiming = navigationEntries[0];
305
+ let ttfb = null;
306
+ if (navTiming.responseStart > 0 && navTiming.fetchStart > 0) {
307
+ ttfb = navTiming.responseStart - navTiming.fetchStart;
308
+ }
309
+ let loadTime = null;
310
+ if (navTiming.loadEventEnd > 0) {
311
+ loadTime = navTiming.loadEventEnd - navTiming.startTime;
312
+ }
313
+ let domInteractive = null;
314
+ if (navTiming.domInteractive > 0) {
315
+ domInteractive = navTiming.domInteractive - navTiming.startTime;
316
+ }
317
+ this.metrics.navigation = { ttfb, loadTime, domInteractive };
318
+ this.updateTrend('loadTime', loadTime);
319
+ this.updateTrend('ttfb', ttfb);
320
+ }
321
+ }
322
+ processPerformanceEntry(entry) {
323
+ switch (entry.entryType) {
324
+ case 'largest-contentful-paint':
325
+ this.metrics.coreWebVitals.LCP = entry.startTime;
326
+ this.updateTrend('LCP', entry.startTime);
327
+ break;
328
+ case 'event': {
329
+ const eventEntry = entry;
330
+ if (eventEntry.interactionId && eventEntry.duration > this.maxINP) {
331
+ this.maxINP = eventEntry.duration;
332
+ this.metrics.coreWebVitals.INP = this.maxINP;
333
+ this.updateTrend('INP', this.maxINP);
334
+ }
335
+ this.inpEntries.push(eventEntry);
336
+ break;
337
+ }
338
+ case 'layout-shift': {
339
+ const lsEntry = entry;
340
+ if (!lsEntry.hadRecentInput) {
341
+ this.clsEntries.push(lsEntry);
342
+ this.calculateSessionWindowCLS();
343
+ }
344
+ break;
345
+ }
346
+ case 'paint':
347
+ if (entry.name === 'first-contentful-paint') {
348
+ this.metrics.coreWebVitals.FCP = entry.startTime;
349
+ this.updateTrend('FCP', entry.startTime);
350
+ }
351
+ break;
352
+ case 'resource':
353
+ this.processResourceEntries([entry]);
354
+ return;
355
+ case 'longtask': {
356
+ const ltEntry = entry;
357
+ this.longTaskEntries.push(ltEntry);
358
+ this.calculateLongTasksAndTBT();
359
+ break;
360
+ }
361
+ }
362
+ this.requestRender();
363
+ }
364
+ calculateSessionWindowCLS() {
365
+ let maxCls = 0;
366
+ let currentSessionCls = 0;
367
+ let sessionStartTime = Infinity;
368
+ let lastTime = -Infinity;
369
+ this.clsEntries.sort((a, b) => a.startTime - b.startTime);
370
+ for (const entry of this.clsEntries) {
371
+ const timeDiff = entry.startTime - lastTime;
372
+ if (timeDiff > 1000 || entry.startTime - sessionStartTime > 5000) {
373
+ if (currentSessionCls > 0) {
374
+ maxCls = Math.max(maxCls, currentSessionCls);
375
+ }
376
+ currentSessionCls = 0;
377
+ sessionStartTime = entry.startTime;
378
+ }
379
+ currentSessionCls += entry.value;
380
+ lastTime = entry.startTime;
381
+ }
382
+ maxCls = Math.max(maxCls, currentSessionCls);
383
+ this.metrics.coreWebVitals.CLS = maxCls;
384
+ this.updateTrend('CLS', maxCls);
385
+ }
386
+ processResourceEntries(entries) {
387
+ const summary = this.metrics.resources;
388
+ entries.forEach((entry) => {
389
+ const size = entry.transferSize || 0;
390
+ const initiator = entry.initiatorType;
391
+ const name = entry.name.toLowerCase();
392
+ if (initiator === 'script' || name.endsWith('.js')) {
393
+ summary.js.count++;
394
+ summary.js.size += size;
395
+ }
396
+ else if (initiator === 'css' || name.endsWith('.css') || initiator === 'link') {
397
+ summary.css.count++;
398
+ summary.css.size += size;
399
+ }
400
+ else if (initiator === 'img' || initiator === 'image' || /\.(jpg|jpeg|png|gif|svg|webp|avif)$/.test(name)) {
401
+ summary.img.count++;
402
+ summary.img.size += size;
403
+ }
404
+ else {
405
+ summary.other.count++;
406
+ summary.other.size += size;
407
+ }
408
+ summary.totalSize += size;
409
+ });
410
+ }
411
+ calculateLongTasksAndTBT() {
412
+ let tbt = 0;
413
+ let count = 0;
414
+ const referenceTime = this.metrics.coreWebVitals.FCP ?? 0;
415
+ this.longTaskEntries.forEach((task) => {
416
+ if (task.startTime >= referenceTime) {
417
+ count++;
418
+ if (task.duration > 50) {
419
+ tbt += task.duration - 50;
420
+ }
421
+ }
422
+ });
423
+ this.metrics.longTasks = { count, totalDuration: tbt };
424
+ this.metrics.coreWebVitals.TBT = tbt;
425
+ this.updateTrend('TBT', tbt);
426
+ }
427
+ startMemoryMonitoring() {
428
+ if (!performance.memory) {
429
+ return;
430
+ }
431
+ const updateMemory = () => {
432
+ if (performance.memory) {
433
+ const mem = performance.memory;
434
+ this.metrics.memory = {
435
+ jsHeapSizeLimit: Number(mem.jsHeapSizeLimit) || 0,
436
+ totalJSHeapSize: Number(mem.totalJSHeapSize) || 0,
437
+ usedJSHeapSize: Number(mem.usedJSHeapSize) || 0
438
+ };
439
+ this.requestRender();
440
+ }
441
+ };
442
+ updateMemory();
443
+ this.memoryInterval = window.setInterval(updateMemory, 3000);
444
+ }
445
+ stopMemoryMonitoring() {
446
+ if (this.memoryInterval) {
447
+ clearInterval(this.memoryInterval);
448
+ this.memoryInterval = null;
449
+ }
450
+ }
451
+ initNetworkMonitoring() {
452
+ if (navigator.connection) {
453
+ this.updateNetworkInfo();
454
+ navigator.connection.addEventListener('change', this.updateNetworkInfo);
455
+ }
456
+ }
457
+ stopNetworkMonitoring() {
458
+ if (navigator.connection) {
459
+ navigator.connection.removeEventListener('change', this.updateNetworkInfo);
460
+ }
461
+ }
462
+ updateNetworkInfo = () => {
463
+ if (navigator.connection) {
464
+ this.network = {
465
+ effectiveType: navigator.connection.effectiveType ?? 'N/A',
466
+ rtt: navigator.connection.rtt ?? 0
467
+ };
468
+ }
469
+ };
470
+ updateTrend(key, value) {
471
+ if (value === null) {
472
+ return;
473
+ }
474
+ const history = this.trendHistory[key] || [];
475
+ history.push(value);
476
+ if (history.length > this.maxTrendLength) {
477
+ history.shift();
478
+ }
479
+ this.trendHistory[key] = history;
480
+ }
481
+ getTrendDirection(key) {
482
+ const history = this.trendHistory[key];
483
+ if (!history || history.length < 2) {
484
+ return '';
485
+ }
486
+ const currentValue = history[history.length - 1];
487
+ const previousAvg = history.slice(0, history.length - 1).reduce((a, b) => a + b, 0) / (history.length - 1);
488
+ const threshold = Math.abs(previousAvg * 0.05);
489
+ const delta = currentValue ?? 0 - previousAvg;
490
+ if (Math.abs(delta) < threshold) {
491
+ return '→';
492
+ }
493
+ if (key === 'fps') {
494
+ return delta > 0 ? '↑' : '↓';
495
+ }
496
+ else {
497
+ return delta < 0 ? '↓' : '↑';
498
+ }
499
+ }
500
+ getOverallStatus() {
501
+ const ratings = [
502
+ rateMetric('LCP', this.metrics.coreWebVitals.LCP),
503
+ rateMetric('CLS', this.metrics.coreWebVitals.CLS),
504
+ rateMetric('INP', this.metrics.coreWebVitals.INP),
505
+ rateMetric('fps', this.metrics.fps)
506
+ ];
507
+ if (ratings.includes('poor')) {
508
+ return 'poor';
509
+ }
510
+ if (ratings.includes('needs-improvement')) {
511
+ return 'needs-improvement';
512
+ }
513
+ if (ratings.every((r) => r === 'unknown')) {
514
+ return 'unknown';
515
+ }
516
+ if (ratings.some((r) => r === 'good')) {
517
+ return 'good';
518
+ }
519
+ return 'unknown';
520
+ }
521
+ render() {
522
+ return (0, lit_html_1.html) `
523
+ <div part="container">
524
+ ${this.renderExpanded()}
525
+ </div>
526
+ `;
527
+ }
528
+ renderExpanded() {
529
+ return (0, lit_html_1.html) `
530
+ <div part="header">
531
+ <div part="title">
532
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline><polyline points="17 6 23 6 23 12"></polyline></svg>
533
+ Performance Monitor
534
+ </div>
535
+ </div>
536
+ <div part="content">
537
+ ${this.renderVitalsAndTiming()}
538
+ ${this.renderRealtime()}
539
+ ${this.renderNetworkInfo()}
540
+ ${this.renderResources()}
541
+ </div>
542
+ `;
543
+ }
544
+ renderMetricBox(label, key, value, description) {
545
+ const rating = rateMetric(key, value);
546
+ const formattedValue = formatMetric(key, value);
547
+ const trend = this.getTrendDirection(key);
548
+ const benchmark = GLOBAL_BENCHMARKS[key];
549
+ const vsBenchmark = benchmark ? ` (vs avg ${formatMetric(key, benchmark)})` : '';
550
+ return (0, lit_html_1.html) `
551
+ <div class="metric-box" title="${description}${vsBenchmark}">
552
+ <div part="metric-label" class="metric-label">${label}</div>
553
+ <div part="metric-value" class="metric-value rating-${rating}" data-rating=${rating}>
554
+ ${formattedValue}
555
+ <span class="trend-indicator">${trend}</span>
556
+ </div>
557
+ </div>
558
+ `;
559
+ }
560
+ renderVitalsAndTiming() {
561
+ const { LCP, INP, CLS, FCP, TBT } = this.metrics.coreWebVitals;
562
+ const { ttfb, loadTime } = this.metrics.navigation;
563
+ return (0, lit_html_1.html) `
564
+ <section>
565
+ <div part="section-title" class="section-title">Vitals & Timing</div>
566
+ <div class="metrics-grid">
567
+ ${this.renderMetricBox('LCP', 'LCP', LCP, 'Largest Contentful Paint: Measures loading performance.')}
568
+ ${this.renderMetricBox('INP', 'INP', INP, 'Interaction to Next Paint: Measures responsiveness.')}
569
+ ${this.renderMetricBox('CLS', 'CLS', CLS, 'Cumulative Layout Shift: Measures visual stability.')}
570
+ ${this.renderMetricBox('FCP', 'FCP', FCP, 'First Contentful Paint: When the browser renders the first bit of content.')}
571
+ ${this.renderMetricBox('TBT', 'TBT', TBT, 'Total Blocking Time: Sum of blocking portions of long tasks.')}
572
+ ${this.renderMetricBox('TTFB', 'ttfb', ttfb, 'Time to First Byte: Measures server responsiveness.')}
573
+ ${this.renderMetricBox('Load', 'loadTime', loadTime, 'Total Page Load Time.')}
574
+ </div>
575
+ </section>
576
+ `;
577
+ }
578
+ renderRealtime() {
579
+ const { memory, longTasks } = this.metrics;
580
+ return (0, lit_html_1.html) `
581
+ <section>
582
+ <div part="section-title" class="section-title">Realtime Monitoring</div>
583
+ <ease-monitor-fps></ease-monitor-fps>
584
+ <div class="longtask-item">
585
+ <span>Long Tasks (Count / Blocked ms)</span>
586
+ <span>${longTasks.count} / ${longTasks.totalDuration.toFixed(0)}ms</span>
587
+ </div>
588
+ ${this.renderMemory(memory)}
589
+ </section>
590
+ `;
591
+ }
592
+ renderMemory(memory) {
593
+ if (!memory) {
594
+ return (0, lit_html_1.html) `
595
+ <div class="memory-usage">
596
+ (performance.memory API not supported)
597
+ </div>
598
+ `;
599
+ }
600
+ const usedPercent = memory.totalJSHeapSize > 0 ? (memory.usedJSHeapSize / memory.totalJSHeapSize) * 100 : 0;
601
+ let rating = 'good';
602
+ if (usedPercent > 85) {
603
+ rating = 'poor';
604
+ }
605
+ else if (usedPercent > 60) {
606
+ rating = 'needs-improvement';
607
+ }
608
+ return (0, lit_html_1.html) `
609
+ <div class="memory-usage">
610
+ <div class="resource-item">
611
+ <span>Used / Total Heap</span>
612
+ <span>${formatBytes(memory.usedJSHeapSize)} / ${formatBytes(memory.totalJSHeapSize)}</span>
613
+ </div>
614
+ <div class="memory-bar" title="${usedPercent.toFixed(1)}% Used">
615
+ <div class="memory-used rating-${rating}" style=${(0, template_helpers_1.styleObject)({ width: `${Math.min(100, usedPercent)}%` })} data-rating=${rating}></div>
616
+ </div>
617
+ <div class="resource-item">
618
+ <span>Heap Limit</span>
619
+ <span>${formatBytes(memory.jsHeapSizeLimit)}</span>
620
+ </div>
621
+ </div>
622
+ `;
623
+ }
624
+ renderNetworkInfo() {
625
+ const { effectiveType, rtt } = this.network;
626
+ return (0, lit_html_1.html) `
627
+ <section>
628
+ <div part="section-title" class="section-title">Network Connection</div>
629
+ <div class="network-info">
630
+ <div class="network-item">
631
+ <span>Effective Type</span>
632
+ <span>${effectiveType.toUpperCase()}</span>
633
+ </div>
634
+ <div class="network-item">
635
+ <span>Round Trip Time (RTT)</span>
636
+ <span>${rtt > 0 ? `${rtt}ms` : 'N/A'}</span>
637
+ </div>
638
+ </div>
639
+ </section>
640
+ `;
641
+ }
642
+ renderResources() {
643
+ const { js, css, img, other, totalSize } = this.metrics.resources;
644
+ const totalCount = js.count + css.count + img.count + other.count;
645
+ const renderItem = (label, data) => (0, lit_html_1.html) `
646
+ <div class="resource-item">
647
+ <span>${label} (${data.count})</span>
648
+ <span>${formatBytes(data.size)}</span>
649
+ </div>
650
+ `;
651
+ return (0, lit_html_1.html) `
652
+ <section>
653
+ <div part="section-title" class="section-title">Resources (Total: ${formatBytes(totalSize)} / ${totalCount} reqs)</div>
654
+ <div class="resource-list">
655
+ ${renderItem('JS', js)}
656
+ ${renderItem('CSS/Links', css)}
657
+ ${renderItem('Images', img)}
658
+ ${renderItem('Other', other)}
659
+ </div>
660
+ <div part="carbon-estimate" class="carbon-estimate">
661
+ Est. Carbon: ${estimateCarbonFootprint(totalSize)}
662
+ </div>
663
+ <div>
664
+ Overall Status: ${this.getOverallStatus()}
665
+ </div>
666
+ </section>
667
+ `;
668
+ }
669
+ }
670
+ exports.Monitor = Monitor;