@barefootjs/shared 0.10.1 → 0.11.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.
- package/dist/index.d.ts +1 -0
- package/dist/profiler-events.d.ts +62 -0
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/src/profiler-events.ts +77 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { BF_SCOPE, BF_SLOT, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_COND, BF_ITEM, BF_PORTAL_OWNER, BF_PORTAL_ID, BF_PORTAL_PLACEHOLDER, BF_PARENT_OWNED_PREFIX, BF_SCOPE_COMMENT_PREFIX, BF_LOOP_START, BF_LOOP_END, BF_LOOP_ITEM, loopItemMarker, loopStartMarker, loopEndMarker, BF_KEY, BF_KEY_PREFIX, BF_PLACEHOLDER, BF_ASYNC, BF_ASYNC_RESOLVE, BF_PARENT_SCOPE_PLACEHOLDER, } from './markers.ts';
|
|
2
2
|
export { classifyDOMProp, toHTMLAttrName, toHTMLAttrNameRuntime, isBooleanAttr, isEventProp, BOOLEAN_ATTRS, } from './dom-prop.ts';
|
|
3
3
|
export type { DOMPropKind, DOMPropClassification } from './dom-prop.ts';
|
|
4
|
+
export type { ProfilerEvent, ProfilerEventType, ProfilerSubscriberKind, } from './profiler-events.ts';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profiler event wire contract (#1690, SR2).
|
|
3
|
+
*
|
|
4
|
+
* This is the shared shape between the *producer* (the client runtime's
|
|
5
|
+
* `createRecordingSink`, which collects instrumentation into this log) and the
|
|
6
|
+
* *consumer* (the `@barefootjs/jsx` analyses + SR4 IR join). It lives in
|
|
7
|
+
* `@barefootjs/shared` — the leaf both packages depend on and which builds
|
|
8
|
+
* first — so neither side owns the other's type and the jsx↔client peer
|
|
9
|
+
* relationship stays free of a build-order cycle.
|
|
10
|
+
*
|
|
11
|
+
* Pure data: no runtime, dev-only by construction (only an instrumented run
|
|
12
|
+
* ever produces these).
|
|
13
|
+
*/
|
|
14
|
+
/** Subscriber kinds the reactive instrumentation reports (SR1). */
|
|
15
|
+
export type ProfilerSubscriberKind = 'effect' | 'memo' | 'root';
|
|
16
|
+
/** The instrumentation points, as a discriminated `type` tag. */
|
|
17
|
+
export type ProfilerEventType = 'signalSet' | 'subscribeAdd' | 'subscribeRemove' | 'effectCreate' | 'effectEnter' | 'effectExit' | 'effectOutput' | 'effectDispose' | 'batchBegin' | 'batchFlush' | 'turnBegin' | 'turnEnd';
|
|
18
|
+
/**
|
|
19
|
+
* One normalized instrumentation event (SR2). Flat with optional fields rather
|
|
20
|
+
* than a per-type union so the analyses can scan a homogeneous log; `type`
|
|
21
|
+
* discriminates which fields are populated.
|
|
22
|
+
*/
|
|
23
|
+
export interface ProfilerEvent {
|
|
24
|
+
type: ProfilerEventType;
|
|
25
|
+
/** Monotonic order of emission — stable across runs for a fixed scenario. */
|
|
26
|
+
seq: number;
|
|
27
|
+
/** Handler id of the turn in scope when this fired, or `null` outside a turn. */
|
|
28
|
+
turn: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Unique invocation counter for the turn in scope — distinguishes repeated
|
|
31
|
+
* invocations of the *same* handler (e.g. clicking several list rows, which
|
|
32
|
+
* share a `turn` id) so per-turn metrics count interactions, not handler ids.
|
|
33
|
+
* `null` outside a turn.
|
|
34
|
+
*/
|
|
35
|
+
turnSeq: number | null;
|
|
36
|
+
/** Triggering signal id (`signalSet`) or the subscribed-to signal (`subscribe*`). */
|
|
37
|
+
signal?: string;
|
|
38
|
+
/** The effect/memo id (`effect*`) or the subscriber side of a subscription. */
|
|
39
|
+
subscriber?: string;
|
|
40
|
+
/** Effect run duration in ms (`effectExit` only). */
|
|
41
|
+
dur?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Output fingerprint for the run (`effectOutput` only): `true` when the run
|
|
44
|
+
* produced new output (a memo value that differs by `Object.is`, or a DOM
|
|
45
|
+
* write that changed the node), `false` when the run recomputed but produced
|
|
46
|
+
* output identical to its previous run — a *wasted* re-run (§4.2.2). Emitted
|
|
47
|
+
* only for runs whose output is fingerprintable; a run with no `effectOutput`
|
|
48
|
+
* event simply isn't counted by the wasted-re-runs analysis.
|
|
49
|
+
*/
|
|
50
|
+
changed?: boolean;
|
|
51
|
+
/** Subscriber kind (`effectCreate` only). */
|
|
52
|
+
kind?: ProfilerSubscriberKind;
|
|
53
|
+
/** Whether the set happened inside a `batch()` (`signalSet` only). */
|
|
54
|
+
batched?: boolean;
|
|
55
|
+
/** Open batch depth (`batchBegin` only). */
|
|
56
|
+
depth?: number;
|
|
57
|
+
/** Effects flushed by a batch (`batchFlush` only). */
|
|
58
|
+
flushed?: number;
|
|
59
|
+
/** Turn handler id + optional source loc (`turnBegin` only). */
|
|
60
|
+
handlerId?: string;
|
|
61
|
+
loc?: string;
|
|
62
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profiler event wire contract (#1690, SR2).
|
|
3
|
+
*
|
|
4
|
+
* This is the shared shape between the *producer* (the client runtime's
|
|
5
|
+
* `createRecordingSink`, which collects instrumentation into this log) and the
|
|
6
|
+
* *consumer* (the `@barefootjs/jsx` analyses + SR4 IR join). It lives in
|
|
7
|
+
* `@barefootjs/shared` — the leaf both packages depend on and which builds
|
|
8
|
+
* first — so neither side owns the other's type and the jsx↔client peer
|
|
9
|
+
* relationship stays free of a build-order cycle.
|
|
10
|
+
*
|
|
11
|
+
* Pure data: no runtime, dev-only by construction (only an instrumented run
|
|
12
|
+
* ever produces these).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Subscriber kinds the reactive instrumentation reports (SR1). */
|
|
16
|
+
export type ProfilerSubscriberKind = 'effect' | 'memo' | 'root'
|
|
17
|
+
|
|
18
|
+
/** The instrumentation points, as a discriminated `type` tag. */
|
|
19
|
+
export type ProfilerEventType =
|
|
20
|
+
| 'signalSet'
|
|
21
|
+
| 'subscribeAdd'
|
|
22
|
+
| 'subscribeRemove'
|
|
23
|
+
| 'effectCreate'
|
|
24
|
+
| 'effectEnter'
|
|
25
|
+
| 'effectExit'
|
|
26
|
+
| 'effectOutput'
|
|
27
|
+
| 'effectDispose'
|
|
28
|
+
| 'batchBegin'
|
|
29
|
+
| 'batchFlush'
|
|
30
|
+
| 'turnBegin'
|
|
31
|
+
| 'turnEnd'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* One normalized instrumentation event (SR2). Flat with optional fields rather
|
|
35
|
+
* than a per-type union so the analyses can scan a homogeneous log; `type`
|
|
36
|
+
* discriminates which fields are populated.
|
|
37
|
+
*/
|
|
38
|
+
export interface ProfilerEvent {
|
|
39
|
+
type: ProfilerEventType
|
|
40
|
+
/** Monotonic order of emission — stable across runs for a fixed scenario. */
|
|
41
|
+
seq: number
|
|
42
|
+
/** Handler id of the turn in scope when this fired, or `null` outside a turn. */
|
|
43
|
+
turn: string | null
|
|
44
|
+
/**
|
|
45
|
+
* Unique invocation counter for the turn in scope — distinguishes repeated
|
|
46
|
+
* invocations of the *same* handler (e.g. clicking several list rows, which
|
|
47
|
+
* share a `turn` id) so per-turn metrics count interactions, not handler ids.
|
|
48
|
+
* `null` outside a turn.
|
|
49
|
+
*/
|
|
50
|
+
turnSeq: number | null
|
|
51
|
+
/** Triggering signal id (`signalSet`) or the subscribed-to signal (`subscribe*`). */
|
|
52
|
+
signal?: string
|
|
53
|
+
/** The effect/memo id (`effect*`) or the subscriber side of a subscription. */
|
|
54
|
+
subscriber?: string
|
|
55
|
+
/** Effect run duration in ms (`effectExit` only). */
|
|
56
|
+
dur?: number
|
|
57
|
+
/**
|
|
58
|
+
* Output fingerprint for the run (`effectOutput` only): `true` when the run
|
|
59
|
+
* produced new output (a memo value that differs by `Object.is`, or a DOM
|
|
60
|
+
* write that changed the node), `false` when the run recomputed but produced
|
|
61
|
+
* output identical to its previous run — a *wasted* re-run (§4.2.2). Emitted
|
|
62
|
+
* only for runs whose output is fingerprintable; a run with no `effectOutput`
|
|
63
|
+
* event simply isn't counted by the wasted-re-runs analysis.
|
|
64
|
+
*/
|
|
65
|
+
changed?: boolean
|
|
66
|
+
/** Subscriber kind (`effectCreate` only). */
|
|
67
|
+
kind?: ProfilerSubscriberKind
|
|
68
|
+
/** Whether the set happened inside a `batch()` (`signalSet` only). */
|
|
69
|
+
batched?: boolean
|
|
70
|
+
/** Open batch depth (`batchBegin` only). */
|
|
71
|
+
depth?: number
|
|
72
|
+
/** Effects flushed by a batch (`batchFlush` only). */
|
|
73
|
+
flushed?: number
|
|
74
|
+
/** Turn handler id + optional source loc (`turnBegin` only). */
|
|
75
|
+
handlerId?: string
|
|
76
|
+
loc?: string
|
|
77
|
+
}
|