@fusion.dev/helix-core 0.135.0 → 0.136.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.
@@ -8078,6 +8078,22 @@
8078
8078
  "module": "./utils/relative-time/relative-time.js"
8079
8079
  }
8080
8080
  },
8081
+ {
8082
+ "kind": "js",
8083
+ "name": "reportUsage",
8084
+ "declaration": {
8085
+ "name": "reportUsage",
8086
+ "module": "./utils/report-usage/report-usage.js"
8087
+ }
8088
+ },
8089
+ {
8090
+ "kind": "js",
8091
+ "name": "USAGE_SLOT",
8092
+ "declaration": {
8093
+ "name": "USAGE_SLOT",
8094
+ "module": "./utils/report-usage/report-usage.js"
8095
+ }
8096
+ },
8081
8097
  {
8082
8098
  "kind": "js",
8083
8099
  "name": "reportValues",
@@ -14312,6 +14328,53 @@
14312
14328
  }
14313
14329
  ]
14314
14330
  },
14331
+ {
14332
+ "kind": "javascript-module",
14333
+ "path": "src/utils/report-usage/report-usage.ts",
14334
+ "declarations": [
14335
+ {
14336
+ "kind": "variable",
14337
+ "name": "USAGE_SLOT",
14338
+ "description": "The key the listener is kept under. `@fusion.dev/helix-diagnostics` names the same string."
14339
+ },
14340
+ {
14341
+ "kind": "function",
14342
+ "name": "reportUsage",
14343
+ "return": {
14344
+ "type": {
14345
+ "text": "void"
14346
+ }
14347
+ },
14348
+ "parameters": [
14349
+ {
14350
+ "name": "element",
14351
+ "type": {
14352
+ "text": "HTMLElement"
14353
+ }
14354
+ }
14355
+ ],
14356
+ "description": "Tells the listener, where there is one, that `element` has rendered for the\nfirst time.\n\n**A listener that throws never breaks the element.** The error is thrown\nagain on a later microtask, so it reaches the console and the page's error\nhandlers, and the render that called this finishes as if nothing listened."
14357
+ }
14358
+ ],
14359
+ "exports": [
14360
+ {
14361
+ "kind": "js",
14362
+ "name": "USAGE_SLOT",
14363
+ "declaration": {
14364
+ "name": "USAGE_SLOT",
14365
+ "module": "src/utils/report-usage/report-usage.ts"
14366
+ }
14367
+ },
14368
+ {
14369
+ "kind": "js",
14370
+ "name": "reportUsage",
14371
+ "declaration": {
14372
+ "name": "reportUsage",
14373
+ "module": "src/utils/report-usage/report-usage.ts"
14374
+ }
14375
+ }
14376
+ ]
14377
+ },
14315
14378
  {
14316
14379
  "kind": "javascript-module",
14317
14380
  "path": "src/utils/report-values/report-values.ts",
@@ -1,5 +1,6 @@
1
1
  import { css, LitElement } from 'lit';
2
2
  import { unsafeStatic } from 'lit/static-html.js';
3
+ import { reportUsage } from '../utils/report-usage/report-usage.js';
3
4
  import { applyReactProperties, auditReactProps, bindReactHandler, reactPropsOf, } from './react-bridge.js';
4
5
  const BOX_SIZING = css `
5
6
  *,
@@ -114,6 +115,7 @@ export class HelixElement extends LitElement {
114
115
  }
115
116
  firstUpdated(changed) {
116
117
  super.firstUpdated(changed);
118
+ reportUsage(this);
117
119
  let applied = applyReactProperties(this);
118
120
  requestAnimationFrame(() => {
119
121
  this.toggleState('settled', true);
package/dist/index.d.ts CHANGED
@@ -63,6 +63,7 @@ export { onUnlessFalse } from './utils/on-unless-false/on-unless-false.js';
63
63
  export { type ColorBytes, readColor } from './utils/read-color/read-color.js';
64
64
  export { type Row, type RowCell, readRows, readSeries, type Series, type SeriesPoint, } from './utils/read-series/read-series.js';
65
65
  export { type Relative, relativeTime, } from './utils/relative-time/relative-time.js';
66
+ export { reportUsage, USAGE_SLOT } from './utils/report-usage/report-usage.js';
66
67
  export { reportValues } from './utils/report-values/report-values.js';
67
68
  export { type ChangeRequestOptions, requestChange, } from './utils/request-change/request-change.js';
68
69
  export { type ActivatableItem, resolveActiveItem, } from './utils/resolve-active-item/resolve-active-item.js';
package/dist/index.js CHANGED
@@ -63,6 +63,7 @@ export { onUnlessFalse } from './utils/on-unless-false/on-unless-false.js';
63
63
  export { readColor } from './utils/read-color/read-color.js';
64
64
  export { readRows, readSeries, } from './utils/read-series/read-series.js';
65
65
  export { relativeTime, } from './utils/relative-time/relative-time.js';
66
+ export { reportUsage, USAGE_SLOT } from './utils/report-usage/report-usage.js';
66
67
  export { reportValues } from './utils/report-values/report-values.js';
67
68
  export { requestChange, } from './utils/request-change/request-change.js';
68
69
  export { resolveActiveItem, } from './utils/resolve-active-item/resolve-active-item.js';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Where a rendered element is told to whoever is counting usage.
3
+ *
4
+ * **One slot on `globalThis`, under a registered symbol, and empty by default.**
5
+ * `@fusion.dev/helix-diagnostics` fills it from `watch()` and counts what
6
+ * renders: the tags, the axes set on them, and the named slots filled. With
7
+ * nothing in the slot, which is every page that has not asked, an element pays
8
+ * one property read and a type check once, after its first render.
9
+ *
10
+ * **A registered symbol and not an export**, for two reasons. Diagnostics does
11
+ * not depend on the library it diagnoses, so it cannot import a setter from
12
+ * here, and a page holding two copies of Helix runs two copies of this module:
13
+ * `Symbol.for` is the one key both copies and the collector agree on, so every
14
+ * copy's elements are counted.
15
+ *
16
+ * **Counting only, never sending.** This module holds no network code and
17
+ * never will; what the listener does with an element is the listener's.
18
+ */
19
+ /** The key the listener is kept under. `@fusion.dev/helix-diagnostics` names the same string. */
20
+ export declare const USAGE_SLOT: unique symbol;
21
+ /**
22
+ * Tells the listener, where there is one, that `element` has rendered for the
23
+ * first time.
24
+ *
25
+ * **A listener that throws never breaks the element.** The error is thrown
26
+ * again on a later microtask, so it reaches the console and the page's error
27
+ * handlers, and the render that called this finishes as if nothing listened.
28
+ */
29
+ export declare const reportUsage: (element: HTMLElement) => void;
@@ -0,0 +1,15 @@
1
+ export const USAGE_SLOT = Symbol.for('fusion.dev/helix/usage');
2
+ export const reportUsage = (element) => {
3
+ const listener = globalThis[USAGE_SLOT];
4
+ if (typeof listener !== 'function') {
5
+ return;
6
+ }
7
+ try {
8
+ listener(element);
9
+ }
10
+ catch (error) {
11
+ queueMicrotask(() => {
12
+ throw error;
13
+ });
14
+ }
15
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fusion.dev/helix-core",
3
3
  "description": "Helix element primitives: base classes, mixins, decorators, utilities.",
4
- "version": "0.135.0",
4
+ "version": "0.136.0",
5
5
  "license": "MIT",
6
6
  "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
7
  "repository": {
@@ -34,11 +34,11 @@
34
34
  "bugs": "https://github.com/project-fusion/fusion/issues",
35
35
  "dependencies": {
36
36
  "@floating-ui/dom": "^1.8.0",
37
- "@fusion.dev/helix-icons": "0.135.0"
37
+ "@fusion.dev/helix-icons": "0.136.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@fusion.dev/helix-cem": "0.135.0",
41
- "@fusion.dev/helix-testing": "0.135.0",
40
+ "@fusion.dev/helix-cem": "0.136.0",
41
+ "@fusion.dev/helix-testing": "0.136.0",
42
42
  "@lit-labs/ssr": "^4.1.0",
43
43
  "lit": "^3.2.1"
44
44
  },