@wcstack/debounce 1.12.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/README.ja.md ADDED
@@ -0,0 +1,153 @@
1
+ # @wcstack/debounce
2
+
3
+ `@wcstack/debounce` は wcstack エコシステム向けのヘッドレスな debounce / throttle コンポーネントです。
4
+
5
+ これは見た目を持つ UI ウィジェットではありません。
6
+ ノイズの多いシグナルの連打を、静止後の1回の発火に集約する **非同期プリミティブノード** です(`@wcstack/timer` が時間経過をリアクティブな状態にするのと同じ発想)。
7
+
8
+ 1つのエンジンの上に2つのカスタム要素を提供します。
9
+
10
+ - `<wcs-debounce>` — シグナルが `wait` ms 静止したら1回発火。
11
+ - `<wcs-throttle>` — 最大で `wait` ms に1回発火(`maxWait === wait`・leading 既定 on の debounce)。
12
+
13
+ [CSBC](https://github.com/csbc-dev/arch/blob/main/README.md)(Core / Shell / Binding Contract)アーキテクチャに従います。
14
+
15
+ - **Core**(`DebounceCore`)が lodash の debounce アルゴリズム(`leading` / `trailing` / `maxWait`)を移植し、結果をイベントで公開。
16
+ - **Shell**(`<wcs-debounce>` / `<wcs-throttle>`)が DOM 属性・ライフサイクル・宣言的コマンドへ接続。
17
+ - **Binding Contract**(`static wcBindable`)が観測可能な `properties`・書き込み可能な `inputs`・呼び出し可能な `commands` を宣言。
18
+
19
+ ## 2つのサーフェス
20
+
21
+ 本質は「シグナルのデバウンス」です。シグナルは **値** を運ぶか、**引数付きのパルス** かのどちらかなので、サーフェスは2つあります(1要素につき片方を使う)。
22
+
23
+ ### 値サーフェス — `source` → `value`
24
+
25
+ `source` に書き込むと、静止後にデバウンス済みの値が `value` プロパティ(イベント `wcs-debounce:settled`)で公開されます。`source: src; value: debounced` と配線すると `value` が state に書き戻ります。
26
+
27
+ ### シグナルサーフェス — `trigger(...args)` → `fired`
28
+
29
+ `trigger` コマンドを連打すると、静止後に `wcs-debounce:fired` イベント1発が最後の args を載せて発火します。state は一過性のパルスを値として読めないため、中継にはトークンを使います。
30
+
31
+ ```
32
+ source →(command-token)→ debounce.trigger →[coalesce]→ fired →(event-token)→ state → target.method
33
+ ```
34
+
35
+ state は [command-token プロトコル](../state/)(`command.trigger: $command.X`)で入口を撃ち、[event-token プロトコル](../state/)(`eventToken.fired: Y`)で集約された1発を受け、本来のメソッドへ再配線します。
36
+
37
+ > 1つの要素インスタンスは **片方** のサーフェス専用です。同じ要素で `source` と `trigger` を両方駆動すると、最後にスケジュールされたシグナルが勝ちます(lodash の last-args セマンティクス)。
38
+
39
+ ## インストール
40
+
41
+ ```bash
42
+ npm install @wcstack/debounce
43
+ ```
44
+
45
+ ## クイックスタート
46
+
47
+ ### 1. 入力値のデバウンス
48
+
49
+ ```html
50
+ <script type="module" src="https://esm.run/@wcstack/state/auto"></script>
51
+ <script type="module" src="https://esm.run/@wcstack/debounce/auto"></script>
52
+
53
+ <wcs-state>
54
+ <script type="module">
55
+ export default { query: "", debouncedQuery: "" };
56
+ </script>
57
+ </wcs-state>
58
+
59
+ <input data-wcs="value: query">
60
+ <wcs-debounce wait="300" data-wcs="source: query; value: debouncedQuery"></wcs-debounce>
61
+ <p>検索: {{ debouncedQuery }}</p>
62
+ ```
63
+
64
+ ### 2. メソッド呼び出しのデバウンス(シグナルサーフェス)
65
+
66
+ ```html
67
+ <wcs-state>
68
+ <script type="module">
69
+ export default {
70
+ $commandTokens: ["search"],
71
+ $eventTokens: ["searchSettled"],
72
+ query: "",
73
+ $on: {
74
+ searchSettled: (state, event) => {
75
+ const [q] = event.detail.args; // 最後のキー入力から 300ms 後に1回だけ
76
+ state.results = doSearch(q);
77
+ }
78
+ }
79
+ };
80
+ </script>
81
+ </wcs-state>
82
+
83
+ <input data-wcs="oninput: $command.search">
84
+ <wcs-debounce
85
+ wait="300"
86
+ data-wcs="command.trigger: $command.search; eventToken.fired: searchSettled">
87
+ </wcs-debounce>
88
+ ```
89
+
90
+ ### 3. 高頻度な値ストリームのスロットル
91
+
92
+ ```html
93
+ <wcs-throttle wait="100" data-wcs="source: scrollY; value: throttledScrollY"></wcs-throttle>
94
+ ```
95
+
96
+ `<wcs-throttle>` は既定で leading(即時発火し、以後は最大 `wait` ms に1回)。
97
+
98
+ ## 属性 / Inputs
99
+
100
+ | 属性 | 型 | 既定 (`<wcs-debounce>`) | 既定 (`<wcs-throttle>`) | 説明 |
101
+ | ------------- | ------- | ----------------------- | ----------------------- | ---- |
102
+ | `wait` | number | `250` | `250` | 静止期間 (ms)。不正・負・非数値は既定値にフォールバック。 |
103
+ | `leading` | boolean | off | **on**(`no-leading` で無効化) | バースト先頭で発火。 |
104
+ | `no-trailing` | boolean | off(trailing 有効) | off(trailing 有効) | 末尾発火を無効化。 |
105
+ | `max-wait` | number | なし | `wait` | 連続入力中でも最大 `max-wait` ms ごとに発火を強制。`>= wait` にクランプ。 |
106
+ | `source` | any | — | — | 値サーフェスの入力。デバウンス結果は `value` に返る。 |
107
+
108
+ ## 観測可能プロパティ(outputs)
109
+
110
+ | プロパティ | イベント | 説明 |
111
+ | ---------- | ------------------------------ | ------------------------------------------ |
112
+ | `value` | `wcs-debounce:settled` | 最後の `source` 書き込みのデバウンス済み値。 |
113
+ | `fired` | `wcs-debounce:fired` | 最後の `trigger()` パルスの集約 args。 |
114
+ | `pending` | `wcs-debounce:pending-changed` | デバウンス進行中は `true`。 |
115
+
116
+ `<wcs-throttle>` は同じ形を `wcs-throttle:*` 名前空間で公開します。
117
+
118
+ ## コマンド
119
+
120
+ | コマンド | 説明 |
121
+ | --------- | ---------------------------------------------------------- |
122
+ | `trigger` | シグナルサーフェスの入口。`...args` を載せてパルスを集約。 |
123
+ | `cancel` | 保留中の発火を捨てる(getter は前回値を保持)。 |
124
+ | `flush` | 保留中のペイロードを即発火(保留がなければ no-op)。 |
125
+
126
+ ## 任意の DOM トリガー
127
+
128
+ `config.autoTrigger` が有効(既定)なら、`data-debouncetarget="<id>"` を持つ要素のクリックで、参照先の `<wcs-debounce>` / `<wcs-throttle>` に対し集約済みの `trigger()` を1発撃ちます(クリックの既定動作は抑制)。
129
+
130
+ ## ヘッドレス利用(`DebounceCore`)
131
+
132
+ Core は DOM 非依存で、`@wc-bindable/core` の `bind()` から直接利用できます。
133
+
134
+ ```typescript
135
+ import { DebounceCore } from "@wcstack/debounce";
136
+
137
+ const core = new DebounceCore("wcs-debounce", undefined, { wait: 300 });
138
+ core.addEventListener("wcs-debounce:settled", (e) => {
139
+ console.log((e as CustomEvent).detail.value);
140
+ });
141
+ core.setSource("a");
142
+ core.setSource("b"); // "b" だけが 300ms 後に settle
143
+ ```
144
+
145
+ throttle は prefix と `maxWait === wait` を変えた同じエンジンです。
146
+
147
+ ```typescript
148
+ const throttle = new DebounceCore("wcs-throttle", undefined, { wait: 100, leading: true, maxWait: 100 });
149
+ ```
150
+
151
+ ## ライセンス
152
+
153
+ MIT
package/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # @wcstack/debounce
2
+
3
+ `@wcstack/debounce` is a headless debounce / throttle component for the wcstack ecosystem.
4
+
5
+ It is not a visual UI widget.
6
+ It is an **async primitive node** that coalesces a noisy stream of signals into a single quiet-period emission — the same way `@wcstack/timer` turns the passage of time into reactive state.
7
+
8
+ It ships two custom elements over one engine:
9
+
10
+ - `<wcs-debounce>` — emit once after the signal has been idle for `wait` ms.
11
+ - `<wcs-throttle>` — emit at most once per `wait` ms (debounce with `maxWait === wait`, leading on).
12
+
13
+ `@wcstack/debounce` follows the [CSBC](https://github.com/csbc-dev/arch/blob/main/README.md) (Core / Shell / Binding Contract) architecture:
14
+
15
+ - **Core** (`DebounceCore`) ports lodash's debounce algorithm (`leading` / `trailing` / `maxWait`) and publishes results as events.
16
+ - **Shell** (`<wcs-debounce>` / `<wcs-throttle>`) connects that engine to DOM attributes, lifecycle, and declarative commands.
17
+ - **Binding Contract** (`static wcBindable`) declares observable `properties`, writable `inputs`, and callable `commands`.
18
+
19
+ ## Two surfaces
20
+
21
+ The essence is "debouncing a signal". A signal can carry a **value** or be a bare **pulse with arguments**, so there are two surfaces — use one per element.
22
+
23
+ ### Value surface — `source` → `value`
24
+
25
+ Write to `source`; after the quiet period the debounced value is published on the `value` property (event `wcs-debounce:settled`). Wire it as `source: src; value: debounced` — `value` flows back into state.
26
+
27
+ ### Signal surface — `trigger(...args)` → `fired`
28
+
29
+ Call the `trigger` command repeatedly; after the quiet period one `wcs-debounce:fired` event carries the last args. Because state cannot read a transient pulse as a value, the relay uses tokens:
30
+
31
+ ```
32
+ source →(command-token)→ debounce.trigger →[coalesce]→ fired →(event-token)→ state → target.method
33
+ ```
34
+
35
+ State fires the entry with the [command-token protocol](../state/) (`command.trigger: $command.X`) and receives the single coalesced pulse with the [event-token protocol](../state/) (`eventToken.fired: Y`), then re-dispatches it to the real method.
36
+
37
+ > A single element instance is meant for **one** surface. If both `source` and `trigger` are driven on the same element, the last scheduled signal wins (lodash's last-args semantics).
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm install @wcstack/debounce
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ### 1. Debounce an input value
48
+
49
+ ```html
50
+ <script type="module" src="https://esm.run/@wcstack/state/auto"></script>
51
+ <script type="module" src="https://esm.run/@wcstack/debounce/auto"></script>
52
+
53
+ <wcs-state>
54
+ <script type="module">
55
+ export default {
56
+ query: "",
57
+ debouncedQuery: ""
58
+ };
59
+ </script>
60
+ </wcs-state>
61
+
62
+ <input data-wcs="value: query">
63
+ <wcs-debounce wait="300" data-wcs="source: query; value: debouncedQuery"></wcs-debounce>
64
+ <p>Searching for: {{ debouncedQuery }}</p>
65
+ ```
66
+
67
+ ### 2. Debounce a method call (signal surface)
68
+
69
+ ```html
70
+ <wcs-state>
71
+ <script type="module">
72
+ export default {
73
+ $commandTokens: ["search"],
74
+ $eventTokens: ["searchSettled"],
75
+ query: "",
76
+ $on: {
77
+ searchSettled: (state, event) => {
78
+ // fires once, 300ms after the last keystroke
79
+ const [q] = event.detail.args;
80
+ state.results = doSearch(q);
81
+ }
82
+ }
83
+ };
84
+ </script>
85
+ </wcs-state>
86
+
87
+ <input data-wcs="oninput: $command.search">
88
+ <wcs-debounce
89
+ wait="300"
90
+ data-wcs="command.trigger: $command.search; eventToken.fired: searchSettled">
91
+ </wcs-debounce>
92
+ ```
93
+
94
+ ### 3. Throttle a fast value stream
95
+
96
+ ```html
97
+ <wcs-throttle wait="100" data-wcs="source: scrollY; value: throttledScrollY"></wcs-throttle>
98
+ ```
99
+
100
+ `<wcs-throttle>` leads by default (emits immediately, then at most once per `wait` ms).
101
+
102
+ ## Attributes / Inputs
103
+
104
+ | Attribute | Type | Default (`<wcs-debounce>`) | Default (`<wcs-throttle>`) | Description |
105
+ | ------------- | ------- | -------------------------- | -------------------------- | ----------- |
106
+ | `wait` | number | `250` | `250` | Quiet period in ms. Invalid / negative / non-numeric values fall back to the default. |
107
+ | `leading` | boolean | off | **on** (`no-leading` opts out) | Emit on the first signal of a burst. |
108
+ | `no-trailing` | boolean | off (trailing on) | off (trailing on) | Opt out of the trailing-edge emission. |
109
+ | `max-wait` | number | none | `wait` | Force an emission at least every `max-wait` ms under continuous input. Clamped to `>= wait`. |
110
+ | `source` | any | — | — | Value-surface input; its debounced echo returns on `value`. |
111
+
112
+ ## Observable Properties (outputs)
113
+
114
+ | Property | Event | Description |
115
+ | --------- | ------------------------------ | ---------------------------------------------------- |
116
+ | `value` | `wcs-debounce:settled` | The debounced value of the latest `source` write. |
117
+ | `fired` | `wcs-debounce:fired` | The coalesced args of the latest `trigger()` pulse. |
118
+ | `pending` | `wcs-debounce:pending-changed` | `true` while a debounce is in flight. |
119
+
120
+ `<wcs-throttle>` publishes the same shape under the `wcs-throttle:*` namespace.
121
+
122
+ ## Commands
123
+
124
+ | Command | Description |
125
+ | --------- | ---------------------------------------------------------------- |
126
+ | `trigger` | Signal-surface entry: coalesce a pulse carrying `...args`. |
127
+ | `cancel` | Drop any pending emission without firing (getters keep values). |
128
+ | `flush` | Emit any buffered payload immediately (no-op if nothing pending). |
129
+
130
+ ## Optional DOM Triggering
131
+
132
+ When `config.autoTrigger` is on (default), a click on an element carrying `data-debouncetarget="<id>"` fires a single coalesced `trigger()` pulse on the referenced `<wcs-debounce>` / `<wcs-throttle>` (the click's default action is suppressed).
133
+
134
+ ## Headless usage (`DebounceCore`)
135
+
136
+ The Core has no DOM dependency and can be used directly with `bind()` from `@wc-bindable/core`:
137
+
138
+ ```typescript
139
+ import { DebounceCore } from "@wcstack/debounce";
140
+
141
+ const core = new DebounceCore("wcs-debounce", undefined, { wait: 300 });
142
+ core.addEventListener("wcs-debounce:settled", (e) => {
143
+ console.log((e as CustomEvent).detail.value);
144
+ });
145
+ core.setSource("a");
146
+ core.setSource("b"); // only "b" settles, 300ms later
147
+ ```
148
+
149
+ Throttle is the same engine with a different prefix and `maxWait === wait`:
150
+
151
+ ```typescript
152
+ const throttle = new DebounceCore("wcs-throttle", undefined, { wait: 100, leading: true, maxWait: 100 });
153
+ ```
154
+
155
+ ## License
156
+
157
+ MIT
package/dist/auto.js ADDED
@@ -0,0 +1,3 @@
1
+ import { bootstrapDebounce } from "./index.esm.js";
2
+
3
+ bootstrapDebounce();
@@ -0,0 +1,3 @@
1
+ import { bootstrapDebounce } from "./index.esm.min.js";
2
+
3
+ bootstrapDebounce();
@@ -0,0 +1,245 @@
1
+ interface ITagNames {
2
+ readonly debounce: string;
3
+ readonly throttle: string;
4
+ }
5
+ interface IWritableTagNames {
6
+ debounce?: string;
7
+ throttle?: string;
8
+ }
9
+ interface IConfig {
10
+ readonly autoTrigger: boolean;
11
+ readonly triggerAttribute: string;
12
+ readonly tagNames: ITagNames;
13
+ }
14
+ interface IWritableConfig {
15
+ autoTrigger?: boolean;
16
+ triggerAttribute?: string;
17
+ tagNames?: IWritableTagNames;
18
+ }
19
+ interface IWcBindableProperty {
20
+ readonly name: string;
21
+ readonly event: string;
22
+ readonly getter?: (event: Event) => any;
23
+ }
24
+ interface IWcBindableInput {
25
+ readonly name: string;
26
+ readonly attribute?: string;
27
+ }
28
+ interface IWcBindableCommand {
29
+ readonly name: string;
30
+ readonly async?: boolean;
31
+ }
32
+ interface IWcBindable {
33
+ readonly protocol: "wc-bindable";
34
+ readonly version: number;
35
+ readonly properties: IWcBindableProperty[];
36
+ readonly inputs?: IWcBindableInput[];
37
+ readonly commands?: IWcBindableCommand[];
38
+ }
39
+ /**
40
+ * Tuning options for {@link DebounceCore}. Mirrors lodash's `debounce` knobs.
41
+ * - `wait`: quiet period (ms) the signal must be idle before a trailing fire.
42
+ * - `leading`: fire on the first signal of a burst.
43
+ * - `trailing`: fire after the quiet period at the end of a burst.
44
+ * - `maxWait`: cap the total time a fire can be deferred under continuous input.
45
+ * (Throttle is expressed as `maxWait === wait`.)
46
+ */
47
+ interface DebounceOptions {
48
+ wait?: number;
49
+ leading?: boolean;
50
+ trailing?: boolean;
51
+ maxWait?: number;
52
+ }
53
+ /**
54
+ * Payload carried by the `<prefix>:settled` event (the value surface).
55
+ * `value` is the debounced value of the most recent `source` write.
56
+ */
57
+ interface WcsDebounceSettledDetail {
58
+ value: any;
59
+ }
60
+ /**
61
+ * Payload carried by the `<prefix>:fired` event (the signal surface).
62
+ * `args` are the coalesced arguments of the most recent `trigger(...args)` pulse.
63
+ */
64
+ interface WcsDebounceFiredDetail {
65
+ args: any[];
66
+ }
67
+ /**
68
+ * Value types for DebounceCore (headless) — the observable state properties.
69
+ * Use with `bind()` from `@wc-bindable/core` for compile-time type checking.
70
+ */
71
+ interface WcsDebounceCoreValues {
72
+ value: any;
73
+ fired: any[];
74
+ pending: boolean;
75
+ }
76
+ /**
77
+ * Value types for the Shell (`<wcs-debounce>` / `<wcs-throttle>`) — identical
78
+ * observable surface to the Core.
79
+ */
80
+ type WcsDebounceValues = WcsDebounceCoreValues;
81
+ interface WcsDebounceInputs {
82
+ source: any;
83
+ wait: number;
84
+ leading: boolean;
85
+ trailing: boolean;
86
+ maxWait?: number;
87
+ }
88
+ interface WcsDebounceCoreCommands {
89
+ trigger(...args: any[]): void;
90
+ cancel(): void;
91
+ flush(): void;
92
+ }
93
+ type WcsDebounceCommands = WcsDebounceCoreCommands;
94
+
95
+ declare function bootstrapDebounce(userConfig?: IWritableConfig): void;
96
+
97
+ declare function getConfig(): IConfig;
98
+
99
+ /**
100
+ * Headless debounce/throttle primitive. A framework-agnostic port of lodash's
101
+ * `debounce` algorithm (`shouldInvoke` / `leadingEdge` / `trailingEdge` /
102
+ * `remainingWait`, timed via `Date.now()`), exposed through the wc-bindable
103
+ * protocol.
104
+ *
105
+ * It coalesces a stream of *signals* and emits at most one per quiet period.
106
+ * Two surfaces share the single timer:
107
+ *
108
+ * - **value** — writing {@link setSource} schedules a settle; on fire the
109
+ * debounced value is published via the `<prefix>:settled` event and the
110
+ * `value` getter. Wire it as `source: src; value: debounced`.
111
+ * - **signal** — calling {@link trigger}`(...args)` coalesces a burst of pulses;
112
+ * on fire one `<prefix>:fired` event carries the latest args (relayed by state
113
+ * through the command-token / event-token protocols).
114
+ *
115
+ * A given instance is meant to be used for one surface at a time. Because each
116
+ * surface keeps its own field (`_value` vs `_lastArgs`), the getters never
117
+ * pollute each other; if both are driven on one instance the *last* scheduled
118
+ * signal wins (lodash's last-args semantics).
119
+ *
120
+ * Throttle is the same engine with `maxWait === wait` (and `leading` on by
121
+ * default), so `<wcs-throttle>` reuses this class with a different `eventPrefix`.
122
+ */
123
+ declare class DebounceCore extends EventTarget {
124
+ static wcBindable: IWcBindable;
125
+ private readonly _prefix;
126
+ private _target;
127
+ private _wait;
128
+ private _leading;
129
+ private _trailing;
130
+ private _maxWait;
131
+ private _hasMaxWait;
132
+ private _lastCallTime;
133
+ private _lastInvokeTime;
134
+ private _timerId;
135
+ private _pendingKind;
136
+ private _pendingValue;
137
+ private _pendingArgs;
138
+ private _value;
139
+ private _lastArgs;
140
+ private _pending;
141
+ constructor(prefix?: string, target?: EventTarget, options?: DebounceOptions);
142
+ /**
143
+ * Update the tuning knobs. The Shell calls this with the element's current
144
+ * attributes before each schedule, so live attribute edits take effect on the
145
+ * next signal. `maxWait` is clamped to at least `wait` (lodash semantics); an
146
+ * absent / invalid `maxWait` disables maxWait entirely.
147
+ */
148
+ configure(options?: DebounceOptions): void;
149
+ get value(): any;
150
+ get fired(): any[];
151
+ get pending(): boolean;
152
+ /** Value surface: schedule a settle carrying `value` (last write wins). */
153
+ setSource(value: any): void;
154
+ /** Signal surface: coalesce a pulse carrying `args` (last call wins). */
155
+ trigger(...args: any[]): void;
156
+ /** Drop any pending fire without emitting. Getters keep their last values. */
157
+ cancel(): void;
158
+ /**
159
+ * Emit any buffered payload immediately, then clear pending. Unlike lodash's
160
+ * `flush` (which honours `trailing`), this fires whatever is buffered — the
161
+ * command's intent is "publish now" — but is a no-op when nothing is pending.
162
+ */
163
+ flush(): void;
164
+ private _schedule;
165
+ private _shouldInvoke;
166
+ private _remainingWait;
167
+ private _timerExpired;
168
+ private _leadingEdge;
169
+ private _trailingEdge;
170
+ private _invoke;
171
+ private _setPending;
172
+ private _dispatch;
173
+ private _clearTimer;
174
+ }
175
+
176
+ /**
177
+ * Build the wc-bindable `properties` list for a debounce/throttle element, with
178
+ * every event name derived from a single `prefix`. `<wcs-debounce>` uses
179
+ * `"wcs-debounce"`, `<wcs-throttle>` uses `"wcs-throttle"`, so the two tags share
180
+ * one engine (DebounceCore) yet advertise distinct event namespaces from one
181
+ * source of truth — no hand-duplicated property tables (cf. the geolocation Shell
182
+ * which overrode its wcBindable by hand).
183
+ *
184
+ * - `value` — the debounced value of the latest `source` write (value surface),
185
+ * read from the `<prefix>:settled` event.
186
+ * - `fired` — the coalesced args of the latest `trigger()` pulse (signal
187
+ * surface), read from the `<prefix>:fired` event. Declared as a
188
+ * property (not just an event) so state can subscribe via the
189
+ * event-token protocol (`eventToken.fired: <name>`).
190
+ * - `pending` — whether a debounce is currently in flight.
191
+ */
192
+ declare function makeDebounceProperties(prefix: string): IWcBindableProperty[];
193
+
194
+ /**
195
+ * `<wcs-debounce>` — declarative debounce. See {@link DebounceCore} for the
196
+ * engine. The `eventPrefix` defaults to `"wcs-debounce"`; `<wcs-throttle>`
197
+ * subclasses this with `"wcs-throttle"` and throttle defaults.
198
+ */
199
+ declare class Debounce extends HTMLElement {
200
+ static hasConnectedCallbackPromise: boolean;
201
+ protected static eventPrefix: string;
202
+ static wcBindable: IWcBindable;
203
+ protected _core: DebounceCore;
204
+ private _source;
205
+ constructor();
206
+ get wait(): number;
207
+ set wait(value: number);
208
+ get leading(): boolean;
209
+ set leading(value: boolean);
210
+ get trailing(): boolean;
211
+ set trailing(value: boolean);
212
+ get maxWait(): number | undefined;
213
+ set maxWait(value: number);
214
+ get source(): any;
215
+ set source(value: any);
216
+ get value(): any;
217
+ get fired(): any[];
218
+ get pending(): boolean;
219
+ trigger(...args: any[]): void;
220
+ cancel(): void;
221
+ flush(): void;
222
+ protected _defaultWait(): number;
223
+ protected _resolveLeading(): boolean;
224
+ protected _defaultMaxWait(): number | undefined;
225
+ protected _options(): DebounceOptions;
226
+ connectedCallback(): void;
227
+ disconnectedCallback(): void;
228
+ }
229
+
230
+ /**
231
+ * `<wcs-throttle>` — the same {@link DebounceCore} engine biased to throttle:
232
+ * `maxWait === wait` (a fire happens at least every `wait` ms under continuous
233
+ * input) and `leading` on by default. It advertises its own `wcs-throttle:*`
234
+ * event namespace (via `makeDebounceProperties("wcs-throttle")`), and the Core
235
+ * dispatches under that prefix because the constructor passes it through.
236
+ */
237
+ declare class Throttle extends Debounce {
238
+ protected static eventPrefix: string;
239
+ static wcBindable: IWcBindable;
240
+ protected _resolveLeading(): boolean;
241
+ protected _defaultMaxWait(): number | undefined;
242
+ }
243
+
244
+ export { DebounceCore, Debounce as WcsDebounce, Throttle as WcsThrottle, bootstrapDebounce, getConfig, makeDebounceProperties };
245
+ export type { DebounceOptions, IWritableConfig, IWritableTagNames, WcsDebounceCommands, WcsDebounceCoreCommands, WcsDebounceCoreValues, WcsDebounceFiredDetail, WcsDebounceInputs, WcsDebounceSettledDetail, WcsDebounceValues };