@wcstack/devtools 1.33.0 → 2.0.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
@@ -22,12 +22,12 @@ declare function bootstrapDevtools(): void;
22
22
  /** グローバル registry のプロパティ名 */
23
23
  declare const DEVTOOLS_HOOK_GLOBAL = "__WCSTACK_DEVTOOLS_HOOK__";
24
24
  /** プロトコル版。additive change では上げない(protocol §2) */
25
- declare const DEVTOOLS_PROTOCOL_VERSION = 1;
25
+ declare const DEVTOOLS_PROTOCOL_VERSION = 2;
26
26
  interface IPathInfoLike {
27
27
  readonly path: string;
28
28
  }
29
29
  interface IAbsolutePathInfoLike {
30
- readonly stateName: string;
30
+ readonly stateElement: unknown;
31
31
  readonly pathInfo: IPathInfoLike;
32
32
  }
33
33
  interface IListIndexLike {
@@ -41,13 +41,11 @@ interface IAbsoluteAddressLike {
41
41
  interface IBindingLike {
42
42
  readonly propName: string;
43
43
  readonly statePathName: string;
44
- readonly stateName: string;
45
44
  readonly bindingType: string;
46
45
  readonly node: Node;
47
46
  readonly replaceNode: Node;
48
47
  }
49
48
  interface IStateElementSummaryLike {
50
- readonly name: string;
51
49
  readonly rootNode: Node;
52
50
  readonly element: unknown;
53
51
  readonly paths: {
@@ -84,7 +82,6 @@ interface IDeclaredBindingLike {
84
82
  readonly node: Node | null;
85
83
  readonly propName: string;
86
84
  readonly statePathName: string;
87
- readonly stateName: string;
88
85
  readonly bindingType: string;
89
86
  readonly inFilters: readonly {
90
87
  readonly filterName: string;
@@ -99,12 +96,10 @@ interface IDeclaredBindingLike {
99
96
  }
100
97
  type DevtoolsEventLike = {
101
98
  readonly type: "state:element-registered";
102
- readonly name: string;
103
99
  readonly rootNode: Node;
104
100
  readonly element: unknown;
105
101
  } | {
106
102
  readonly type: "state:element-unregistered";
107
- readonly name: string;
108
103
  readonly rootNode: Node;
109
104
  readonly element: unknown;
110
105
  } | {
@@ -130,14 +125,12 @@ type DevtoolsEventLike = {
130
125
  } | {
131
126
  readonly type: "state:token-emit";
132
127
  readonly kind: "command" | "event";
133
- readonly stateName: string | null;
134
128
  readonly tokenName: string;
135
129
  readonly args: readonly unknown[];
136
130
  readonly subscriberCount: number;
137
131
  } | {
138
132
  readonly type: "state:watch-error";
139
133
  readonly phase: "prime" | "evaluate" | "handler";
140
- readonly stateName: string;
141
134
  readonly path: string;
142
135
  readonly error: unknown;
143
136
  } | {
@@ -146,17 +139,14 @@ type DevtoolsEventLike = {
146
139
  readonly paths: readonly string[];
147
140
  } | {
148
141
  readonly type: "state:watch-fired";
149
- readonly stateName: string;
150
142
  readonly path: string;
151
143
  } | {
152
144
  readonly type: "state:path-unresolved";
153
145
  readonly source: "binding" | "watch";
154
- readonly stateName: string;
155
146
  readonly path: string;
156
147
  readonly missingSegment: string;
157
148
  } | {
158
149
  readonly type: "state:binding-apply-error";
159
- readonly stateName: string;
160
150
  readonly path: string;
161
151
  readonly bindingType: string;
162
152
  readonly error: unknown;
@@ -199,9 +189,9 @@ interface IDevtoolsSourceLike {
199
189
  readonly packageVersion: string;
200
190
  getStateElements(): IStateElementSummaryLike[];
201
191
  /** protocol v1 追補 API。古いランタイムには無い可能性があるため optional 扱いで呼ぶ */
202
- keys?(name: string, rootNode: Node): string[];
203
- read(name: string, rootNode: Node, path: string, indexes?: number[]): unknown;
204
- write(name: string, rootNode: Node, path: string, value: unknown, indexes?: number[]): void;
192
+ keys?(rootNode: Node): string[];
193
+ read(rootNode: Node, path: string, indexes?: number[]): unknown;
194
+ write(rootNode: Node, path: string, value: unknown, indexes?: number[]): void;
205
195
  /**
206
196
  * protocol v1 追補 API(optional 扱いで呼ぶ)。ランタイム正本パーサによる
207
197
  * 宣言レベルバインディングの集合(declaredScan の簡易パーサを置き換える正本)。
@@ -237,32 +227,35 @@ interface IDevtoolsHookRegistryLike {
237
227
  * sources / roster / wiring をクリアし、残留参照を持たない。
238
228
  */
239
229
 
240
- /** 予約 state 名 prefix(protocol §5)。この prefix の要素・イベントは常に除外 */
241
- declare const RESERVED_STATE_NAME_PREFIX = "wcs-devtools";
242
230
  type TimelineKind = "write" | "batch" | "command" | "event" | "element-registered" | "element-unregistered" | "watch-error" | "watch-chain-limit" | "path-unresolved" | "binding-apply-error" | "propagation-suppressed" | "propagation-coalesced" | "propagation-hop-limit" | "contract-drift";
243
231
  interface ITimelineEntry {
244
232
  readonly seq: number;
245
233
  readonly time: number;
246
234
  readonly sourceId: string;
247
235
  readonly kind: TimelineKind;
248
- readonly stateName: string | null;
249
236
  readonly label: string;
250
237
  readonly detail: string;
251
238
  readonly subscriberCount: number | null;
252
239
  }
253
240
  interface IRosterEntry {
254
241
  readonly sourceId: string;
255
- readonly name: string;
242
+ /** 表示・選択用のルート由来ラベル(document / ホストタグ、重複は #n を付ける) */
243
+ readonly label: string;
256
244
  readonly rootNode: Node;
257
245
  readonly summary: IStateElementSummaryLike;
258
246
  }
259
247
  interface IWiringEntry {
260
248
  readonly sourceId: string;
261
- readonly stateName: string;
262
249
  readonly path: string;
263
250
  readonly propName: string;
264
251
  readonly bindingType: string;
265
252
  readonly bindingRef: WeakRef<IBindingLike>;
253
+ /**
254
+ * 属する state 要素(absoluteAddress.absolutePathInfo.stateElement)。v2 は名前次元が
255
+ * 無いため、複数ツリーの同名パスは要素同一性で区別する(getWiringForPath のスコープ)。
256
+ * WeakRef なのはこの台帳が要素の寿命を延ばさないため。payload に無ければ null。
257
+ */
258
+ readonly stateElementRef: WeakRef<object> | null;
266
259
  }
267
260
  type CoreChangeKind = "sources" | "roster" | "wiring" | "timeline" | "coverage";
268
261
  type CoreChangeListener = (kind: CoreChangeKind) => void;
@@ -279,7 +272,6 @@ type CoreChangeListener = (kind: CoreChangeKind) => void;
279
272
  */
280
273
  type CoverageStatus = "fired" | "emitted" | "emitted-unheard" | "attached" | "never" | "prerequisite-missing" | "never-attached";
281
274
  interface ICoverageEntry {
282
- readonly stateName: string;
283
275
  readonly kind: "watch" | "command" | "eventToken" | "binding";
284
276
  readonly name: string;
285
277
  readonly status: CoverageStatus;
@@ -289,12 +281,9 @@ interface ICoverageEntry {
289
281
  interface IDevtoolsCoreOptions {
290
282
  /** タイムライン ring buffer 件数(既定 500) */
291
283
  timelineCapacity?: number;
292
- /** 追加で除外する state 名(予約 prefix は常に除外) */
293
- hiddenStateNames?: readonly string[];
294
284
  }
295
285
  declare class DevtoolsCore {
296
286
  private _timelineCapacity;
297
- private _hiddenStateNames;
298
287
  private _removeListener;
299
288
  private _sources;
300
289
  private _roster;
@@ -306,9 +295,12 @@ declare class DevtoolsCore {
306
295
  private _changeListeners;
307
296
  /** 観測開始時刻(connect 時の performance.now。未接続は null)。 */
308
297
  private _observingSince;
309
- /** watch 発火回数(stateName + NUL + path → count)。カバレッジの実測面。 */
298
+ /** watch 発火回数(path → count)。カバレッジの実測面。
299
+ * 既知の限界: `state:watch-fired` / `state:token-emit` の payload はツリー識別を
300
+ * 持たないため、複数ツリーが同名の watch パス / token 名を宣言するページでは
301
+ * 実測が合算される(ツリー別に分けるにはプロトコル追補が要る — slice 29 記録)。 */
310
302
  private _watchFiredCounts;
311
- /** token emit 実測(stateName + NUL + kind + NUL + name → 回数と空撃ち回数)。 */
303
+ /** token emit 実測(kind + NUL + name → 回数と空撃ち回数)。上の限界注記と同じ。 */
312
304
  private _tokenEmitCounts;
313
305
  /** 観測開始以降に一度でも attach を観測した宣言キー(attachKeyOf)。
314
306
  * live 配線台帳は WeakRef pruning / binding-removed で縮むため、binding
@@ -319,8 +311,6 @@ declare class DevtoolsCore {
319
311
  get connected(): boolean;
320
312
  get paused(): boolean;
321
313
  set paused(value: boolean);
322
- /** 表示から除外する state 名か(予約 prefix + hiddenStateNames、protocol §5) */
323
- isHiddenStateName(name: string | null): boolean;
324
314
  connect(): void;
325
315
  /** 購読解除 + 台帳クリア(タイムラインは保持。protocol §7-2 の残留ゼロ) */
326
316
  disconnect(): void;
@@ -333,8 +323,13 @@ declare class DevtoolsCore {
333
323
  refreshRoster(): void;
334
324
  getTimeline(): readonly ITimelineEntry[];
335
325
  clearTimeline(): void;
336
- /** 指定パスに束縛された配線(生存している binding のみ) */
337
- getWiringForPath(stateName: string, path: string): IWiringEntry[];
326
+ /**
327
+ * 指定パスに束縛された配線(生存している binding のみ)。
328
+ * stateElement を渡すとそのツリーの配線だけに絞る(v2 は名前次元が無いため、
329
+ * 複数ツリーの同名パスは要素同一性で区別する)。stateElement を持たない
330
+ * 旧 payload 由来の entry は絞り込みでも残す(欠測を欠落にしない)。
331
+ */
332
+ getWiringForPath(path: string, stateElement?: unknown): IWiringEntry[];
338
333
  /** 全配線のスナップショット(生存している binding のみ) */
339
334
  getAllWiring(): IWiringEntry[];
340
335
  /** 指定ノード(またはその子孫のバインドノード)に載る配線 */
@@ -475,7 +470,7 @@ declare function formatArgs(args: readonly unknown[]): string;
475
470
  * 「宣言レベルの配線ビュー」を組む。ライブ台帳と違い binding 実体・
476
471
  * 接続状態は分からない(UI では "declared" バッジで区別する)。
477
472
  *
478
- * パースは表示目的の簡易版(`prop[#mod]: path[@state][|filters]` を
473
+ * パースは表示目的の簡易版(`prop[#mod]: path[|filters]` を
479
474
  * `;` 区切りで分解するだけ)。正確なセマンティクスの正本は
480
475
  * @wcstack/state の bindTextParser であり、ここでは追随しない。
481
476
  */
@@ -484,7 +479,6 @@ interface IDeclaredBinding {
484
479
  readonly element: Element;
485
480
  readonly propName: string;
486
481
  readonly path: string;
487
- readonly stateName: string;
488
482
  readonly filters: readonly string[];
489
483
  /** 宣言ソース: data-wcs 属性か comment ノードか */
490
484
  readonly origin: "attribute" | "comment";
@@ -514,5 +508,5 @@ declare global {
514
508
  }
515
509
  }
516
510
 
517
- export { DEVTOOLS_HOOK_GLOBAL, DEVTOOLS_PROTOCOL_VERSION, DevtoolsCore, RESERVED_STATE_NAME_PREFIX, WcsDevtools, bootstrapDevtools, formatArgs, formatValue, getOrCreateHookRegistry, scanDeclaredBindings };
511
+ export { DEVTOOLS_HOOK_GLOBAL, DEVTOOLS_PROTOCOL_VERSION, DevtoolsCore, WcsDevtools, bootstrapDevtools, formatArgs, formatValue, getOrCreateHookRegistry, scanDeclaredBindings };
518
512
  export type { CoreChangeKind, CoreChangeListener, DevtoolsEventLike, DevtoolsSinkLike, IAbsoluteAddressLike, IAbsolutePathInfoLike, IBindingLike, IDeclaredBinding, IDevtoolsCoreOptions, IDevtoolsHookRegistryLike, IDevtoolsListenerLike, IDevtoolsSourceLike, IListIndexLike, IPathInfoLike, IRosterEntry, IStateElementSummaryLike, ITimelineEntry, IWiringEntry, TimelineKind };