@wcstack/devtools 1.27.0 → 1.29.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 CHANGED
@@ -60,6 +60,34 @@ interface IStateElementSummaryLike {
60
60
  readonly eventTokenNames: ReadonlySet<string>;
61
61
  readonly staticDependency: ReadonlyMap<string, readonly string[]>;
62
62
  readonly dynamicDependency: ReadonlyMap<string, readonly string[]>;
63
+ /**
64
+ * `$watch` の宣言パス集合(protocol v1 追補・配線カバレッジの宣言面)。
65
+ * 旧ランタイムにはフィールド自体が無いため optional。宣言なしは null。
66
+ */
67
+ readonly watchPaths?: ReadonlySet<string> | null;
68
+ }
69
+ /**
70
+ * 宣言レベルのバインディング 1 件(getDeclaredBindings の要素・protocol v1 追補)。
71
+ * ランタイム正本パーサの結果が構造的に流れる。宣言タプルで dedupe 済みの
72
+ * 「宣言の集合」であり、レンダリング行数に比例したインスタンス列ではない。
73
+ */
74
+ interface IDeclaredBindingLike {
75
+ /** 代表ノード(fragment 由来 = 構造テンプレート内部は null)。 */
76
+ readonly node: Node | null;
77
+ readonly propName: string;
78
+ readonly statePathName: string;
79
+ readonly stateName: string;
80
+ readonly bindingType: string;
81
+ readonly inFilters: readonly {
82
+ readonly filterName: string;
83
+ readonly args: readonly string[];
84
+ }[];
85
+ readonly outFilters: readonly {
86
+ readonly filterName: string;
87
+ readonly args: readonly string[];
88
+ }[];
89
+ readonly origin: "attribute" | "comment" | "fragment";
90
+ readonly raw: string;
63
91
  }
64
92
  type DevtoolsEventLike = {
65
93
  readonly type: "state:element-registered";
@@ -108,6 +136,41 @@ type DevtoolsEventLike = {
108
136
  readonly type: "state:watch-chain-limit";
109
137
  readonly maxDepth: number;
110
138
  readonly paths: readonly string[];
139
+ } | {
140
+ readonly type: "state:watch-fired";
141
+ readonly stateName: string;
142
+ readonly path: string;
143
+ } | {
144
+ readonly type: "propagation:suppressed";
145
+ readonly reason: "confirmation" | "visited-edge";
146
+ readonly transactionId: number;
147
+ readonly edgeId: number;
148
+ readonly node: Node;
149
+ readonly member: string;
150
+ } | {
151
+ readonly type: "propagation:coalesced";
152
+ readonly absoluteAddress: IAbsoluteAddressLike;
153
+ readonly droppedTransactionId: number;
154
+ readonly winnerTransactionId: number;
155
+ } | {
156
+ readonly type: "propagation:hop-limit";
157
+ readonly absoluteAddress: IAbsoluteAddressLike;
158
+ readonly transactionId: number;
159
+ readonly hop: number;
160
+ } | {
161
+ readonly type: "contract:manifest-read";
162
+ readonly tag: string;
163
+ readonly loaded: boolean;
164
+ } | {
165
+ readonly type: "contract:unsupported-extension";
166
+ readonly namespace: string;
167
+ } | {
168
+ readonly type: "contract:drift";
169
+ readonly reason: "component-not-loaded" | "missing-member" | "event-mismatch";
170
+ readonly tag: string;
171
+ readonly member?: string;
172
+ readonly sidecarEvent?: string;
173
+ readonly liveEvent?: string;
111
174
  };
112
175
  type DevtoolsSinkLike = (event: DevtoolsEventLike) => void;
113
176
  interface IDevtoolsSourceLike {
@@ -119,6 +182,11 @@ interface IDevtoolsSourceLike {
119
182
  keys?(name: string, rootNode: Node): string[];
120
183
  read(name: string, rootNode: Node, path: string, indexes?: number[]): unknown;
121
184
  write(name: string, rootNode: Node, path: string, value: unknown, indexes?: number[]): void;
185
+ /**
186
+ * protocol v1 追補 API(optional 扱いで呼ぶ)。ランタイム正本パーサによる
187
+ * 宣言レベルバインディングの集合(declaredScan の簡易パーサを置き換える正本)。
188
+ */
189
+ getDeclaredBindings?(rootNode: Node): IDeclaredBindingLike[];
122
190
  _setSink(sink: DevtoolsSinkLike | null): void;
123
191
  }
124
192
  interface IDevtoolsListenerLike {
@@ -151,7 +219,7 @@ interface IDevtoolsHookRegistryLike {
151
219
 
152
220
  /** 予約 state 名 prefix(protocol §5)。この prefix の要素・イベントは常に除外 */
153
221
  declare const RESERVED_STATE_NAME_PREFIX = "wcs-devtools";
154
- type TimelineKind = "write" | "batch" | "command" | "event" | "element-registered" | "element-unregistered" | "watch-error" | "watch-chain-limit";
222
+ type TimelineKind = "write" | "batch" | "command" | "event" | "element-registered" | "element-unregistered" | "watch-error" | "watch-chain-limit" | "propagation-suppressed" | "propagation-coalesced" | "propagation-hop-limit" | "contract-drift";
155
223
  interface ITimelineEntry {
156
224
  readonly seq: number;
157
225
  readonly time: number;
@@ -176,8 +244,28 @@ interface IWiringEntry {
176
244
  readonly bindingType: string;
177
245
  readonly bindingRef: WeakRef<IBindingLike>;
178
246
  }
179
- type CoreChangeKind = "sources" | "roster" | "wiring" | "timeline";
247
+ type CoreChangeKind = "sources" | "roster" | "wiring" | "timeline" | "coverage";
180
248
  type CoreChangeListener = (kind: CoreChangeKind) => void;
249
+ /**
250
+ * 配線カバレッジ 1 行(static-wiring-dx-design.md §4 — 宣言 × 実測の突合)。
251
+ * - watch: `fired`(count 回)/ `never` / `prerequisite-missing`
252
+ * (ワイルドカード行 watch はリストが `for` バインドされていないと発火前提が
253
+ * 成立しない — 「未発火」と区別しないと誤警告になる)
254
+ * - command / eventToken: `emitted`(count 回)/ `never` /
255
+ * `emitted-unheard`(全 emit が subscriberCount 0 = 空撃ち。§4 の突合対象)
256
+ * - binding: canonical declared がある場合のみ。`attached` / `never-attached`
257
+ * (attached は「観測開始以降に一度でも attach された」— live 台帳は WeakRef
258
+ * pruning で縮むため、瞬間値で判定すると attached が never-attached へ戻る)
259
+ */
260
+ type CoverageStatus = "fired" | "emitted" | "emitted-unheard" | "attached" | "never" | "prerequisite-missing" | "never-attached";
261
+ interface ICoverageEntry {
262
+ readonly stateName: string;
263
+ readonly kind: "watch" | "command" | "eventToken" | "binding";
264
+ readonly name: string;
265
+ readonly status: CoverageStatus;
266
+ readonly count: number;
267
+ readonly note: string | null;
268
+ }
181
269
  interface IDevtoolsCoreOptions {
182
270
  /** タイムライン ring buffer 件数(既定 500) */
183
271
  timelineCapacity?: number;
@@ -196,6 +284,17 @@ declare class DevtoolsCore {
196
284
  private _seq;
197
285
  private _paused;
198
286
  private _changeListeners;
287
+ /** 観測開始時刻(connect 時の performance.now。未接続は null)。 */
288
+ private _observingSince;
289
+ /** watch 発火回数(stateName + NUL + path → count)。カバレッジの実測面。 */
290
+ private _watchFiredCounts;
291
+ /** token emit 実測(stateName + NUL + kind + NUL + name → 回数と空撃ち回数)。 */
292
+ private _tokenEmitCounts;
293
+ /** 観測開始以降に一度でも attach を観測した宣言キー(attachKeyOf)。
294
+ * live 配線台帳は WeakRef pruning / binding-removed で縮むため、binding
295
+ * カバレッジの attached 判定はこちらで行う(瞬間値で判定すると行の
296
+ * 破棄・GC のたびに attached が never-attached へ逆戻りする)。 */
297
+ private _everAttachedKeys;
199
298
  constructor(options?: IDevtoolsCoreOptions);
200
299
  get connected(): boolean;
201
300
  get paused(): boolean;
@@ -205,6 +304,8 @@ declare class DevtoolsCore {
205
304
  connect(): void;
206
305
  /** 購読解除 + 台帳クリア(タイムラインは保持。protocol §7-2 の残留ゼロ) */
207
306
  disconnect(): void;
307
+ /** 観測開始時刻(performance.now 基準。未接続は null)。 */
308
+ get observingSince(): number | null;
208
309
  onChange(listener: CoreChangeListener): () => void;
209
310
  getSources(): IDevtoolsSourceLike[];
210
311
  getRoster(): IRosterEntry[];
@@ -218,6 +319,19 @@ declare class DevtoolsCore {
218
319
  getAllWiring(): IWiringEntry[];
219
320
  /** 指定ノード(またはその子孫のバインドノード)に載る配線 */
220
321
  getWiringForNode(node: Node): IWiringEntry[];
322
+ /**
323
+ * ランタイム正本パーサによる宣言バインディング集合(protocol v1 追補)。
324
+ * getDeclaredBindings を実装した source が 1 つも無ければ null(消費側は
325
+ * declaredScan の簡易パーサへフォールバックする)。root は roster の rootNode
326
+ * を source ごとに重複排除して渡す。
327
+ */
328
+ getCanonicalDeclared(): IDeclaredBindingLike[] | null;
329
+ /**
330
+ * 配線カバレッジ(§4): 宣言面(watchPaths / token 宣言 / canonical declared)と
331
+ * 実測面(watch-fired・token-emit の台帳・live 配線台帳)の突合。
332
+ * 「観測開始以降」の実測であることは observingSince を UI が常時表示して明示する。
333
+ */
334
+ getCoverageReport(): ICoverageEntry[];
221
335
  /** roster entry の state からトップレベルキーを列挙(keys 未実装ランタイムは空) */
222
336
  keysOf(entry: IRosterEntry): string[];
223
337
  readValue(entry: IRosterEntry, path: string, indexes?: number[]): unknown;
@@ -253,6 +367,8 @@ declare class WcsDevtools extends HTMLElement {
253
367
  private _badge;
254
368
  private _stateSelect;
255
369
  private _paneElements;
370
+ /** Wiring ペインの表示モード(配線一覧 / カバレッジ突合)。 */
371
+ private _wiringView;
256
372
  private _highlightLayer;
257
373
  private _dirtyPanes;
258
374
  private _renderScheduled;
@@ -287,6 +403,14 @@ declare class WcsDevtools extends HTMLElement {
287
403
  private _renderTreeNode;
288
404
  private _beginEdit;
289
405
  private _renderWiringPane;
406
+ /**
407
+ * カバレッジビュー: 宣言(watchPaths / token 宣言 / canonical declared)×
408
+ * 実測(発火・emit・attach)の突合表。観測開始以降の実測であることを常時明示する
409
+ * (protocol §6 — 台帳の過去は再構成できない)。
410
+ */
411
+ private _renderCoverageView;
412
+ /** canonical declared(正本パーサ由来・宣言集合)の 1 行。 */
413
+ private _canonicalDeclaredRow;
290
414
  private _scanRootOf;
291
415
  private _wiringRow;
292
416
  private _declaredRow;