@wcstack/debounce 1.16.0 → 1.18.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 CHANGED
@@ -123,6 +123,60 @@ npm install @wcstack/debounce
123
123
  | `cancel` | 保留中の発火を捨てる(getter は前回値を保持)。 |
124
124
  | `flush` | 保留中のペイロードを即発火(保留がなければ no-op)。 |
125
125
 
126
+ ## `:state()` による CSS スタイリング
127
+
128
+ `<wcs-debounce>` / `<wcs-throttle>` は 1 つの boolean 出力ステートを
129
+ [`ElementInternals` の `CustomStateSet`](https://developer.mozilla.org/ja/docs/Web/API/CustomStateSet)
130
+ に反映します。そのため `data-wcs` バインディングやクラスの手動トグルなしに、CSS の
131
+ `:state()` 疑似クラスで直接スタイリングできます。
132
+
133
+ | ステート | on になる条件 |
134
+ |----------|----------------|
135
+ | `pending` | `wcs-debounce:pending-changed` が `true` で発火(`false` でクリア) |
136
+
137
+ `<wcs-throttle>` も同じ `pending` ステートを、自身の `wcs-throttle:pending-changed`
138
+ イベントから反映します(`Debounce` 基底クラスを共有しますが、イベント名前空間 —
139
+ ひいては配線先 — はインスタンス自身の `eventPrefix` を追跡します)。
140
+
141
+ ```css
142
+ wcs-debounce:state(pending) ~ .spinner { display: block; }
143
+ wcs-debounce:state(pending) ~ .spinner { display: none; } /* デフォルト */
144
+
145
+ wcs-throttle:state(pending) ~ .indicator { opacity: 1; }
146
+ ```
147
+
148
+ 属性やクラスと異なり `:state()` は要素の外部から書き込めないため、この出力ステートが
149
+ 入力と混同される心配がありません。
150
+
151
+ **対応ブラウザ**(新構文 `:state(x)`): Chrome/Edge 125+、Safari 17.4+、Firefox 126+。
152
+ 非対応の環境ではステートが一切 set されないだけです — `:state()` セレクタがマッチしなく
153
+ なりますが、`<wcs-debounce>` / `<wcs-throttle>` 自体は通常どおり動作し続けます(graceful degradation・never-throw)。
154
+
155
+ **SSR:** `:state()` は HTML にシリアライズできないため、サーバーレンダリングされた
156
+ マークアップの初期ペイントにはこのステートは乗りません。ハイドレーション前の見た目を
157
+ 制御したい場合は、代わりに `wcs-debounce:not(:defined)` と組み合わせてください。
158
+
159
+ ### デバッグ
160
+
161
+ カスタムステートは DevTools の Elements パネルには表示されず、`attachInternals()`
162
+ は同一要素に 2 回呼べないため、コンソールから直接覗く手段がありません。そのための
163
+ デバッグ専用の補助を 2 つ用意しています:
164
+
165
+ - `el.debugStates` — 現在 on になっているステート名の**スナップショット**配列
166
+ (例: `["pending"]`)。`wc-bindable` の一部ではなく(バインド対象ではない)、
167
+ 形状も契約として保証されません — デバッグ用途にのみ使ってください。
168
+ - `debug-states` 属性(opt-in・既定 OFF)は、ステート変化を要素の
169
+ `data-wcs-state-pending` 属性にミラーします。Elements パネルを開いておけば、
170
+ トグルのたびにハイライトされます:
171
+
172
+ ```html
173
+ <wcs-debounce wait="300" debug-states></wcs-debounce>
174
+ ```
175
+
176
+ **CSS は `data-wcs-state-*` ではなく `:state()` に書いてください。** ミラーされた
177
+ 属性は、DevTools を開いた状態でステート変化を可視化するためだけのものであり、
178
+ スタイリング用の正式なフックではありません。
179
+
126
180
  ## 任意の DOM トリガー
127
181
 
128
182
  `config.autoTrigger` が有効(既定)なら、`data-debouncetarget="<id>"` を持つ要素のクリックで、参照先の `<wcs-debounce>` / `<wcs-throttle>` に対し集約済みの `trigger()` を1発撃ちます(クリックの既定動作は抑制)。
package/README.md CHANGED
@@ -127,6 +127,61 @@ npm install @wcstack/debounce
127
127
  | `cancel` | Drop any pending emission without firing (getters keep values). |
128
128
  | `flush` | Emit any buffered payload immediately (no-op if nothing pending). |
129
129
 
130
+ ## CSS styling with `:state()`
131
+
132
+ `<wcs-debounce>` / `<wcs-throttle>` reflect one boolean output state onto their
133
+ [`ElementInternals` `CustomStateSet`](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet),
134
+ so you can style them directly from CSS with the `:state()` pseudo-class — no
135
+ `data-wcs` binding or extra class toggling required.
136
+
137
+ | State | On when |
138
+ |-------|---------|
139
+ | `pending` | `wcs-debounce:pending-changed` fires with `true` (cleared on `false`) |
140
+
141
+ `<wcs-throttle>` reflects the same `pending` state from its own
142
+ `wcs-throttle:pending-changed` event (it shares the `Debounce` base class, but
143
+ the event namespace — and therefore the wiring — tracks its own `eventPrefix`).
144
+
145
+ ```css
146
+ wcs-debounce:state(pending) ~ .spinner { display: block; }
147
+ wcs-debounce:state(pending) ~ .spinner { display: none; } /* default */
148
+
149
+ wcs-throttle:state(pending) ~ .indicator { opacity: 1; }
150
+ ```
151
+
152
+ Unlike attributes or classes, `:state()` cannot be written from outside the
153
+ element, so there is no risk of confusing this output state with an input.
154
+
155
+ **Browser support** (`:state(x)` syntax): Chrome/Edge 125+, Safari 17.4+,
156
+ Firefox 126+. In older browsers the states are simply never set — `:state()`
157
+ selectors never match, but `<wcs-debounce>` / `<wcs-throttle>` themselves keep
158
+ working normally (graceful degradation, never-throw).
159
+
160
+ **SSR**: `:state()` cannot be serialized into HTML, so server-rendered markup
161
+ never carries these states on first paint. If you need to style the
162
+ pre-hydration gap, pair your rule with `wcs-debounce:not(:defined)` instead.
163
+
164
+ ### Debugging
165
+
166
+ Custom states are invisible in DevTools' Elements panel and `attachInternals()`
167
+ cannot be called twice, so there is no console way to inspect them directly.
168
+ Two debug-only aids are provided for that:
169
+
170
+ - `el.debugStates` — a **snapshot** array of the currently-on state names
171
+ (e.g. `["pending"]`). It is not part of `wc-bindable` (not a bind target)
172
+ and its shape is not a guaranteed contract — use it for debugging only.
173
+ - The `debug-states` attribute (opt-in, default off) mirrors state changes
174
+ onto a `data-wcs-state-pending` attribute on the element, so the Elements
175
+ panel highlights it as it toggles:
176
+
177
+ ```html
178
+ <wcs-debounce wait="300" debug-states></wcs-debounce>
179
+ ```
180
+
181
+ **Write your CSS against `:state()`, not `data-wcs-state-*`.** The mirrored
182
+ attribute exists purely to make state changes visible while debugging with
183
+ DevTools open; it is not a supported styling hook.
184
+
130
185
  ## Optional DOM Triggering
131
186
 
132
187
  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).
package/dist/index.d.ts CHANGED
@@ -212,7 +212,11 @@ declare class Debounce extends HTMLElement {
212
212
  protected _core: DebounceCore;
213
213
  private _source;
214
214
  private _connectedCallbackPromise;
215
+ private _internals;
215
216
  constructor();
217
+ get debugStates(): string[];
218
+ private _initInternals;
219
+ private _wireStates;
216
220
  get connectedCallbackPromise(): Promise<void>;
217
221
  get wait(): number;
218
222
  set wait(value: number);
package/dist/index.esm.js CHANGED
@@ -444,9 +444,65 @@ class Debounce extends HTMLElement {
444
444
  _core;
445
445
  _source = undefined;
446
446
  _connectedCallbackPromise = Promise.resolve();
447
+ _internals = null;
447
448
  constructor() {
448
449
  super();
449
450
  this._core = new DebounceCore(this.constructor.eventPrefix, this);
451
+ this._internals = this._initInternals();
452
+ // `<wcs-throttle>` extends this class without overriding the constructor, so
453
+ // `this.constructor` resolves to the actual subclass here too — the map key
454
+ // tracks whichever `eventPrefix` the instance dispatches under
455
+ // (docs/custom-state-reflection-design.md §3.4).
456
+ const prefix = this.constructor.eventPrefix;
457
+ this._wireStates({ [`${prefix}:pending-changed`]: (d) => ({ pending: d === true }) });
458
+ }
459
+ // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of
460
+ // wc-bindable (not a bind target); see README "CSS styling with :state()".
461
+ // MUST NOT return the live CustomStateSet (that would let callers write
462
+ // states from outside, defeating the point of :state() being read-only).
463
+ get debugStates() {
464
+ return this._internals ? [...this._internals.states] : [];
465
+ }
466
+ _initInternals() {
467
+ // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent
468
+ // in happy-dom / older environments, and pre-125 Chromium rejects
469
+ // non-dashed state names from states.add() (probed and discarded here).
470
+ // Either case silently disables reflection — the component still works,
471
+ // it just doesn't expose :state() selectors.
472
+ try {
473
+ if (typeof this.attachInternals !== "function")
474
+ return null;
475
+ const internals = this.attachInternals();
476
+ internals.states.add("wcs-probe");
477
+ internals.states.delete("wcs-probe");
478
+ return internals;
479
+ }
480
+ catch {
481
+ return null;
482
+ }
483
+ }
484
+ _wireStates(map) {
485
+ if (this._internals === null)
486
+ return;
487
+ const states = this._internals.states;
488
+ for (const [event, toStates] of Object.entries(map)) {
489
+ this.addEventListener(event, (e) => {
490
+ const debug = this.hasAttribute("debug-states");
491
+ for (const [name, on] of Object.entries(toStates(e.detail))) {
492
+ try {
493
+ if (on) {
494
+ states.add(name);
495
+ }
496
+ else {
497
+ states.delete(name);
498
+ }
499
+ }
500
+ catch { /* never-throw */ }
501
+ if (debug)
502
+ this.toggleAttribute(`data-wcs-state-${name}`, on);
503
+ }
504
+ });
505
+ }
450
506
  }
451
507
  get connectedCallbackPromise() {
452
508
  return this._connectedCallbackPromise;
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/components/Debounce.ts","../src/components/Throttle.ts","../src/registerComponents.ts","../src/bootstrapDebounce.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n debounce: string;\n throttle: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-debouncetarget\",\n tagNames: {\n debounce: \"wcs-debounce\",\n throttle: \"wcs-throttle\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindableProperty } from \"./types.js\";\n\n/**\n * Build the wc-bindable `properties` list for a debounce/throttle element, with\n * every event name derived from a single `prefix`. `<wcs-debounce>` uses\n * `\"wcs-debounce\"`, `<wcs-throttle>` uses `\"wcs-throttle\"`, so the two tags share\n * one engine (DebounceCore) yet advertise distinct event namespaces from one\n * source of truth — no hand-duplicated property tables (cf. the geolocation Shell\n * which overrode its wcBindable by hand).\n *\n * - `value` — the debounced value of the latest `source` write (value surface),\n * read from the `<prefix>:settled` event.\n * - `fired` — the coalesced args of the latest `trigger()` pulse (signal\n * surface), read from the `<prefix>:fired` event. Declared as a\n * property (not just an event) so state can subscribe via the\n * event-token protocol (`eventToken.fired: <name>`).\n * - `pending` — whether a debounce is currently in flight.\n */\nexport function makeDebounceProperties(prefix: string): IWcBindableProperty[] {\n return [\n { name: \"value\", event: `${prefix}:settled`, getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed` },\n ];\n}\n","import { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\ntype PendingKind = \"value\" | \"signal\" | null;\n\n/**\n * Headless debounce/throttle primitive. A framework-agnostic port of lodash's\n * `debounce` algorithm (`shouldInvoke` / `leadingEdge` / `trailingEdge` /\n * `remainingWait`, timed via `Date.now()`), exposed through the wc-bindable\n * protocol.\n *\n * It coalesces a stream of *signals* and emits at most one per quiet period.\n * Two surfaces share the single timer:\n *\n * - **value** — writing {@link setSource} schedules a settle; on fire the\n * debounced value is published via the `<prefix>:settled` event and the\n * `value` getter. Wire it as `source: src; value: debounced`.\n * - **signal** — calling {@link trigger}`(...args)` coalesces a burst of pulses;\n * on fire one `<prefix>:fired` event carries the latest args (relayed by state\n * through the command-token / event-token protocols).\n *\n * A given instance is meant to be used for one surface at a time. Because each\n * surface keeps its own field (`_value` vs `_lastArgs`), the getters never\n * pollute each other; if both are driven on one instance the *last* scheduled\n * signal wins (lodash's last-args semantics).\n *\n * Throttle is the same engine with `maxWait === wait` (and `leading` on by\n * default), so `<wcs-throttle>` reuses this class with a different `eventPrefix`.\n */\nexport class DebounceCore extends EventTarget {\n // The static contract advertises the *default* `wcs-debounce:*` event names. A\n // headless Core constructed with a non-default `eventPrefix` (e.g.\n // `\"wcs-throttle\"`) dispatches under that prefix, so its events won't match\n // this metadata — rebuild the property table with `makeDebounceProperties(prefix)`\n // for that case. (The `<wcs-throttle>` Shell already overrides its own\n // `wcBindable` this way, so binding through an element is always consistent.)\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n private readonly _prefix: string;\n private _target: EventTarget;\n\n // Tuning (lodash knobs).\n private _wait: number = 0;\n private _leading: boolean = false;\n private _trailing: boolean = true;\n private _maxWait: number = 0;\n private _hasMaxWait: boolean = false;\n\n // Timing bookkeeping.\n private _lastCallTime: number | undefined = undefined;\n private _lastInvokeTime: number = 0;\n private _timerId: ReturnType<typeof setTimeout> | null = null;\n // Generation stamped onto the live timer at arm time, compared in\n // `_timerExpired` against `_gen` to drop callbacks that outlived a dispose().\n private _timerGen: number = 0;\n\n // Last-wins pending payload. `_pendingKind === null` doubles as the \"consumed /\n // empty\" sentinel (lodash clears `lastArgs` in invokeFunc): a trailing edge with\n // no fresh call since the last fire sees `null` and does not re-fire, which is\n // what stops a single leading pulse from also firing on the trailing edge.\n private _pendingKind: PendingKind = null;\n private _pendingValue: any = undefined;\n private _pendingArgs: any[] | undefined = undefined;\n\n // Observable state (getter backing).\n private _value: any = undefined;\n private _lastArgs: any[] = [];\n private _pending: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() so a timer that survives a\n // tear-down can no longer settle into a detached element. A pending timer is\n // also cleared by dispose() → cancel(), so the guard is defensive: it stops\n // any callback that has already been dequeued by the host event loop from\n // writing state after dispose().\n private _gen = 0;\n // SSR (§3.8): the debounce engine is purely timer-driven with no asynchronous\n // probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(prefix: string = \"wcs-debounce\", target?: EventTarget, options?: DebounceOptions) {\n super();\n this._prefix = prefix;\n this._target = target ?? this;\n if (options) {\n this.configure(options);\n }\n }\n\n // --- Lifecycle (§3.5 / §3.8) ---\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Debounce is command-driven (setSource / trigger schedule work on demand)\n // with no subscription to establish, so observe() is an idempotent no-op that\n // resolves once ready.\n observe(): Promise<void> {\n return this._ready;\n }\n\n // Tear down the pending timer and invalidate the generation so a stale timer\n // callback cannot fire after the element is detached.\n dispose(): void {\n this._gen++;\n this.cancel();\n }\n\n // --- Configuration ---\n\n /**\n * Update the tuning knobs. The Shell calls this with the element's current\n * attributes before each schedule, so live attribute edits take effect on the\n * next signal. `maxWait` is clamped to at least `wait` (lodash semantics); an\n * absent / invalid `maxWait` disables maxWait entirely.\n */\n configure(options: DebounceOptions = {}): void {\n if (typeof options.wait === \"number\" && Number.isFinite(options.wait) && options.wait >= 0) {\n this._wait = options.wait;\n }\n if (typeof options.leading === \"boolean\") {\n this._leading = options.leading;\n }\n if (typeof options.trailing === \"boolean\") {\n this._trailing = options.trailing;\n }\n const mw = options.maxWait;\n if (typeof mw === \"number\" && Number.isFinite(mw) && mw >= 0) {\n this._maxWait = Math.max(mw, this._wait);\n this._hasMaxWait = true;\n } else {\n this._maxWait = 0;\n this._hasMaxWait = false;\n }\n }\n\n // --- Observable getters ---\n\n get value(): any {\n return this._value;\n }\n\n get fired(): any[] {\n return this._lastArgs;\n }\n\n get pending(): boolean {\n return this._pending;\n }\n\n // --- Public entry points ---\n\n /** Value surface: schedule a settle carrying `value` (last write wins). */\n setSource(value: any): void {\n this._schedule(\"value\", value, undefined);\n }\n\n /** Signal surface: coalesce a pulse carrying `args` (last call wins). */\n trigger(...args: any[]): void {\n this._schedule(\"signal\", undefined, args);\n }\n\n /** Drop any pending fire without emitting. Getters keep their last values. */\n cancel(): void {\n this._clearTimer();\n this._lastInvokeTime = 0;\n this._lastCallTime = undefined;\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n /**\n * Emit any buffered payload immediately, then clear pending. Unlike lodash's\n * `flush` (which honours `trailing`), this fires whatever is buffered — the\n * command's intent is \"publish now\" — but is a no-op when nothing is pending.\n */\n flush(): void {\n if (this._timerId === null && this._pendingKind === null) return;\n const now = Date.now();\n this._clearTimer();\n if (this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n // --- Engine (lodash port) ---\n\n private _schedule(kind: Exclude<PendingKind, null>, value: any, args: any[] | undefined): void {\n const now = Date.now();\n const isInvoking = this._shouldInvoke(now);\n\n this._pendingKind = kind;\n if (kind === \"value\") {\n this._pendingValue = value;\n } else {\n this._pendingArgs = args;\n }\n this._lastCallTime = now;\n this._setPending(true);\n\n if (isInvoking) {\n if (this._timerId === null) {\n this._leadingEdge(now);\n return;\n }\n if (this._hasMaxWait) {\n // Continuous input that has reached maxWait: restart the steady timer and\n // invoke now so a fire happens at least every maxWait ms (throttle path).\n // Clear the pending handle first (lodash's \"tight loop\" branch does the\n // same) — overwriting `_timerId` without clearing would orphan the old\n // timer and let it fire spuriously later.\n this._clearTimer();\n this._armTimer(this._wait);\n this._invoke(now);\n return;\n }\n }\n if (this._timerId === null) {\n this._armTimer(this._wait);\n }\n }\n\n private _shouldInvoke(now: number): boolean {\n if (this._lastCallTime === undefined) return true;\n const timeSinceLastCall = now - this._lastCallTime;\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n return (\n timeSinceLastCall >= this._wait ||\n timeSinceLastCall < 0 ||\n (this._hasMaxWait && timeSinceLastInvoke >= this._maxWait)\n );\n }\n\n private _remainingWait(now: number): number {\n const timeSinceLastCall = now - (this._lastCallTime as number);\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n const timeWaiting = this._wait - timeSinceLastCall;\n return this._hasMaxWait\n ? Math.min(timeWaiting, this._maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n private _timerExpired = (): void => {\n // §3.4 generation guard: a timer dequeued by the host before dispose() could\n // clear it must not settle into a torn-down element. Capture the generation\n // when the timer is scheduled (via `_armTimer`) and bail if it is stale.\n if (this._timerGen !== this._gen) return;\n const now = Date.now();\n if (this._shouldInvoke(now)) {\n this._trailingEdge(now);\n return;\n }\n // Fired before the quiet period elapsed (a later call moved the deadline) —\n // re-arm for the remaining time instead of settling now.\n this._armTimer(this._remainingWait(now));\n };\n\n private _leadingEdge(now: number): void {\n this._lastInvokeTime = now;\n this._armTimer(this._wait);\n if (this._leading) {\n this._invoke(now);\n }\n }\n\n private _trailingEdge(now: number): void {\n this._timerId = null;\n // Only fire when there is an unconsumed payload (a call arrived since the last\n // invoke). After a lone leading fire `_pendingKind` is null, so a single pulse\n // does not double-fire on its trailing edge.\n if (this._trailing && this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n private _invoke(now: number): void {\n this._lastInvokeTime = now;\n const kind = this._pendingKind;\n if (kind === \"value\") {\n this._value = this._pendingValue;\n this._dispatch(`${this._prefix}:settled`, { value: this._value });\n } else if (kind === \"signal\") {\n this._lastArgs = this._pendingArgs ?? [];\n this._dispatch(`${this._prefix}:fired`, { args: this._lastArgs });\n }\n // Mark consumed (mirrors lodash clearing `lastArgs`).\n this._pendingKind = null;\n }\n\n private _setPending(pending: boolean): void {\n if (this._pending === pending) return;\n this._pending = pending;\n this._dispatch(`${this._prefix}:pending-changed`, pending);\n }\n\n private _dispatch(type: string, detail: any): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n // Arm the settle timer, stamping the current generation so a callback that the\n // host dequeues after a dispose() can detect it is stale (§3.4).\n private _armTimer(delay: number): void {\n this._timerGen = this._gen;\n this._timerId = setTimeout(this._timerExpired, delay);\n }\n\n private _clearTimer(): void {\n if (this._timerId !== null) {\n clearTimeout(this._timerId);\n this._timerId = null;\n }\n }\n}\n","import { config } from \"./config.js\";\n\nlet registered = false;\n\ninterface Triggerable extends Element {\n trigger(...args: unknown[]): void;\n}\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const id = triggerElement.getAttribute(config.triggerAttribute);\n if (!id) return;\n\n // Resolve the registered constructors at call time (avoids a components ⇄\n // autoTrigger import cycle, mirroring <wcs-timer>). The DOM trigger fires a\n // single coalesced pulse on the referenced <wcs-debounce> / <wcs-throttle>.\n const DebounceCtor = customElements.get(config.tagNames.debounce);\n const ThrottleCtor = customElements.get(config.tagNames.throttle);\n const el = document.getElementById(id);\n if (!el) return;\n const isDebounce = DebounceCtor && el instanceof DebounceCtor;\n const isThrottle = ThrottleCtor && el instanceof ThrottleCtor;\n if (!isDebounce && !isThrottle) return;\n\n // Suppress the element's default action so a debounce can fire without\n // navigating. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (el as unknown as Triggerable).trigger();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { DebounceCore } from \"../core/DebounceCore.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nconst DEFAULT_WAIT = 250;\n\n/**\n * `<wcs-debounce>` — declarative debounce. See {@link DebounceCore} for the\n * engine. The `eventPrefix` defaults to `\"wcs-debounce\"`; `<wcs-throttle>`\n * subclasses this with `\"wcs-throttle\"` and throttle defaults.\n */\nexport class Debounce extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n protected static eventPrefix = \"wcs-debounce\";\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n // `source` is the value-surface input (its debounced echo comes back on the\n // `value` property). `trigger` / `cancel` / `flush` are commands from the\n // Core. No momentary boolean `trigger` property exists — the signal surface\n // is driven by the `trigger` command (command-token) or a DOM click\n // (autoTrigger), which sidesteps the attribute/method name clash that forced\n // <wcs-geo>'s watch → watchPosition rename.\n inputs: [\n { name: \"source\" },\n { name: \"wait\", attribute: \"wait\" },\n // No `attribute` hint on leading / trailing: their setters already reflect\n // to the backing attribute themselves (the fetch-Shell idiom), and — more\n // importantly — the backing attribute is NOT the input name. `trailing`\n // reflects to the inverted `no-trailing` (default true; a bare `trailing`\n // attribute can't express false), and the `<wcs-throttle>` subclass reads\n // `leading` from the inverted `no-leading` (default on). A single\n // input-name→attribute hint can't be correct for both polarities/subclasses,\n // so binders drive these through the property setter instead.\n { name: \"leading\" },\n { name: \"trailing\" },\n { name: \"maxWait\", attribute: \"max-wait\" },\n ],\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n protected _core: DebounceCore;\n private _source: any = undefined;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new DebounceCore((this.constructor as typeof Debounce).eventPrefix, this);\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get wait(): number {\n const attr = this.getAttribute(\"wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultWait();\n // Strict parse via Number() (\"100px\" -> NaN, not 100). Fall back to the\n // default for any non-finite or negative value.\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultWait();\n }\n\n set wait(value: number) {\n this.setAttribute(\"wait\", String(value));\n }\n\n get leading(): boolean {\n return this.hasAttribute(\"leading\");\n }\n\n set leading(value: boolean) {\n if (value) {\n this.setAttribute(\"leading\", \"\");\n } else {\n this.removeAttribute(\"leading\");\n }\n }\n\n // `trailing` defaults to true; the boolean `no-trailing` attribute opts out (a\n // bare `trailing` attribute can't express \"false\", so the negative flag carries\n // the override).\n get trailing(): boolean {\n return !this.hasAttribute(\"no-trailing\");\n }\n\n set trailing(value: boolean) {\n if (value) {\n this.removeAttribute(\"no-trailing\");\n } else {\n this.setAttribute(\"no-trailing\", \"\");\n }\n }\n\n get maxWait(): number | undefined {\n const attr = this.getAttribute(\"max-wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultMaxWait();\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultMaxWait();\n }\n\n set maxWait(value: number) {\n this.setAttribute(\"max-wait\", String(value));\n }\n\n // --- Value-surface input ---\n\n get source(): any {\n return this._source;\n }\n\n set source(value: any) {\n this._source = value;\n this._core.configure(this._options());\n this._core.setSource(value);\n }\n\n // --- Core delegated getters ---\n\n get value(): any {\n return this._core.value;\n }\n\n get fired(): any[] {\n return this._core.fired;\n }\n\n get pending(): boolean {\n return this._core.pending;\n }\n\n // --- Commands ---\n\n trigger(...args: any[]): void {\n this._core.configure(this._options());\n this._core.trigger(...args);\n }\n\n cancel(): void {\n this._core.cancel();\n }\n\n flush(): void {\n this._core.flush();\n }\n\n // --- Internal ---\n\n // Overridden by <wcs-throttle> to bias the defaults toward throttle (leading\n // on, maxWait pinned to wait).\n protected _defaultWait(): number {\n return DEFAULT_WAIT;\n }\n\n // Resolves the effective `leading` value (not a static default). It is a method\n // rather than reading `this.leading` directly because <wcs-throttle> inverts the\n // default (on, opt out via `no-leading`) while sharing the inherited `leading`\n // attribute setter — overriding the getter alone would desync getter and setter.\n protected _resolveLeading(): boolean {\n return this.leading;\n }\n\n protected _defaultMaxWait(): number | undefined {\n return undefined;\n }\n\n protected _options(): DebounceOptions {\n return {\n wait: this.wait,\n leading: this._resolveLeading(),\n trailing: this.trailing,\n maxWait: this.maxWait,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // §4.1/§4.4 Shell SSR: expose connectedCallbackPromise backed by observe().\n // observe() is a no-op resolving once ready (the engine is command-driven).\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n // Drop any in-flight timer so a detached element leaks nothing, and bump the\n // Core generation so a surviving timer callback cannot settle (§3.5).\n this._core.dispose();\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { Debounce } from \"./Debounce.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\n/**\n * `<wcs-throttle>` — the same {@link DebounceCore} engine biased to throttle:\n * `maxWait === wait` (a fire happens at least every `wait` ms under continuous\n * input) and `leading` on by default. It advertises its own `wcs-throttle:*`\n * event namespace (via `makeDebounceProperties(\"wcs-throttle\")`), and the Core\n * dispatches under that prefix because the constructor passes it through.\n */\nexport class Throttle extends Debounce {\n protected static eventPrefix = \"wcs-throttle\";\n static wcBindable: IWcBindable = {\n ...Debounce.wcBindable,\n properties: makeDebounceProperties(\"wcs-throttle\"),\n };\n\n // leading defaults on for throttle; `no-leading` opts out (symmetric with the\n // inherited `no-trailing`).\n protected _resolveLeading(): boolean {\n return !this.hasAttribute(\"no-leading\");\n }\n\n // Pin maxWait to wait so throttle fires on a steady cadence; an explicit\n // `max-wait` attribute still overrides via the inherited getter.\n protected _defaultMaxWait(): number | undefined {\n return this.wait;\n }\n}\n","import { Debounce } from \"./components/Debounce.js\";\nimport { Throttle } from \"./components/Throttle.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.debounce)) {\n customElements.define(config.tagNames.debounce, Debounce);\n }\n if (!customElements.get(config.tagNames.throttle)) {\n customElements.define(config.tagNames.throttle, Throttle);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapDebounce(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAWA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,qBAAqB;AACvC,IAAA,QAAQ,EAAE;AACR,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,QAAQ,EAAE,cAAc;AACzB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,O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AAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACjD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC3D;AACA,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACjD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC3D;AACF;;ACPM,SAAU,iBAAiB,CAAC,UAA4B,EAAA;IAC5D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/components/Debounce.ts","../src/components/Throttle.ts","../src/registerComponents.ts","../src/bootstrapDebounce.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n debounce: string;\n throttle: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-debouncetarget\",\n tagNames: {\n debounce: \"wcs-debounce\",\n throttle: \"wcs-throttle\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindableProperty } from \"./types.js\";\n\n/**\n * Build the wc-bindable `properties` list for a debounce/throttle element, with\n * every event name derived from a single `prefix`. `<wcs-debounce>` uses\n * `\"wcs-debounce\"`, `<wcs-throttle>` uses `\"wcs-throttle\"`, so the two tags share\n * one engine (DebounceCore) yet advertise distinct event namespaces from one\n * source of truth — no hand-duplicated property tables (cf. the geolocation Shell\n * which overrode its wcBindable by hand).\n *\n * - `value` — the debounced value of the latest `source` write (value surface),\n * read from the `<prefix>:settled` event.\n * - `fired` — the coalesced args of the latest `trigger()` pulse (signal\n * surface), read from the `<prefix>:fired` event. Declared as a\n * property (not just an event) so state can subscribe via the\n * event-token protocol (`eventToken.fired: <name>`).\n * - `pending` — whether a debounce is currently in flight.\n */\nexport function makeDebounceProperties(prefix: string): IWcBindableProperty[] {\n return [\n { name: \"value\", event: `${prefix}:settled`, getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed` },\n ];\n}\n","import { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\ntype PendingKind = \"value\" | \"signal\" | null;\n\n/**\n * Headless debounce/throttle primitive. A framework-agnostic port of lodash's\n * `debounce` algorithm (`shouldInvoke` / `leadingEdge` / `trailingEdge` /\n * `remainingWait`, timed via `Date.now()`), exposed through the wc-bindable\n * protocol.\n *\n * It coalesces a stream of *signals* and emits at most one per quiet period.\n * Two surfaces share the single timer:\n *\n * - **value** — writing {@link setSource} schedules a settle; on fire the\n * debounced value is published via the `<prefix>:settled` event and the\n * `value` getter. Wire it as `source: src; value: debounced`.\n * - **signal** — calling {@link trigger}`(...args)` coalesces a burst of pulses;\n * on fire one `<prefix>:fired` event carries the latest args (relayed by state\n * through the command-token / event-token protocols).\n *\n * A given instance is meant to be used for one surface at a time. Because each\n * surface keeps its own field (`_value` vs `_lastArgs`), the getters never\n * pollute each other; if both are driven on one instance the *last* scheduled\n * signal wins (lodash's last-args semantics).\n *\n * Throttle is the same engine with `maxWait === wait` (and `leading` on by\n * default), so `<wcs-throttle>` reuses this class with a different `eventPrefix`.\n */\nexport class DebounceCore extends EventTarget {\n // The static contract advertises the *default* `wcs-debounce:*` event names. A\n // headless Core constructed with a non-default `eventPrefix` (e.g.\n // `\"wcs-throttle\"`) dispatches under that prefix, so its events won't match\n // this metadata — rebuild the property table with `makeDebounceProperties(prefix)`\n // for that case. (The `<wcs-throttle>` Shell already overrides its own\n // `wcBindable` this way, so binding through an element is always consistent.)\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n private readonly _prefix: string;\n private _target: EventTarget;\n\n // Tuning (lodash knobs).\n private _wait: number = 0;\n private _leading: boolean = false;\n private _trailing: boolean = true;\n private _maxWait: number = 0;\n private _hasMaxWait: boolean = false;\n\n // Timing bookkeeping.\n private _lastCallTime: number | undefined = undefined;\n private _lastInvokeTime: number = 0;\n private _timerId: ReturnType<typeof setTimeout> | null = null;\n // Generation stamped onto the live timer at arm time, compared in\n // `_timerExpired` against `_gen` to drop callbacks that outlived a dispose().\n private _timerGen: number = 0;\n\n // Last-wins pending payload. `_pendingKind === null` doubles as the \"consumed /\n // empty\" sentinel (lodash clears `lastArgs` in invokeFunc): a trailing edge with\n // no fresh call since the last fire sees `null` and does not re-fire, which is\n // what stops a single leading pulse from also firing on the trailing edge.\n private _pendingKind: PendingKind = null;\n private _pendingValue: any = undefined;\n private _pendingArgs: any[] | undefined = undefined;\n\n // Observable state (getter backing).\n private _value: any = undefined;\n private _lastArgs: any[] = [];\n private _pending: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() so a timer that survives a\n // tear-down can no longer settle into a detached element. A pending timer is\n // also cleared by dispose() → cancel(), so the guard is defensive: it stops\n // any callback that has already been dequeued by the host event loop from\n // writing state after dispose().\n private _gen = 0;\n // SSR (§3.8): the debounce engine is purely timer-driven with no asynchronous\n // probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(prefix: string = \"wcs-debounce\", target?: EventTarget, options?: DebounceOptions) {\n super();\n this._prefix = prefix;\n this._target = target ?? this;\n if (options) {\n this.configure(options);\n }\n }\n\n // --- Lifecycle (§3.5 / §3.8) ---\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Debounce is command-driven (setSource / trigger schedule work on demand)\n // with no subscription to establish, so observe() is an idempotent no-op that\n // resolves once ready.\n observe(): Promise<void> {\n return this._ready;\n }\n\n // Tear down the pending timer and invalidate the generation so a stale timer\n // callback cannot fire after the element is detached.\n dispose(): void {\n this._gen++;\n this.cancel();\n }\n\n // --- Configuration ---\n\n /**\n * Update the tuning knobs. The Shell calls this with the element's current\n * attributes before each schedule, so live attribute edits take effect on the\n * next signal. `maxWait` is clamped to at least `wait` (lodash semantics); an\n * absent / invalid `maxWait` disables maxWait entirely.\n */\n configure(options: DebounceOptions = {}): void {\n if (typeof options.wait === \"number\" && Number.isFinite(options.wait) && options.wait >= 0) {\n this._wait = options.wait;\n }\n if (typeof options.leading === \"boolean\") {\n this._leading = options.leading;\n }\n if (typeof options.trailing === \"boolean\") {\n this._trailing = options.trailing;\n }\n const mw = options.maxWait;\n if (typeof mw === \"number\" && Number.isFinite(mw) && mw >= 0) {\n this._maxWait = Math.max(mw, this._wait);\n this._hasMaxWait = true;\n } else {\n this._maxWait = 0;\n this._hasMaxWait = false;\n }\n }\n\n // --- Observable getters ---\n\n get value(): any {\n return this._value;\n }\n\n get fired(): any[] {\n return this._lastArgs;\n }\n\n get pending(): boolean {\n return this._pending;\n }\n\n // --- Public entry points ---\n\n /** Value surface: schedule a settle carrying `value` (last write wins). */\n setSource(value: any): void {\n this._schedule(\"value\", value, undefined);\n }\n\n /** Signal surface: coalesce a pulse carrying `args` (last call wins). */\n trigger(...args: any[]): void {\n this._schedule(\"signal\", undefined, args);\n }\n\n /** Drop any pending fire without emitting. Getters keep their last values. */\n cancel(): void {\n this._clearTimer();\n this._lastInvokeTime = 0;\n this._lastCallTime = undefined;\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n /**\n * Emit any buffered payload immediately, then clear pending. Unlike lodash's\n * `flush` (which honours `trailing`), this fires whatever is buffered — the\n * command's intent is \"publish now\" — but is a no-op when nothing is pending.\n */\n flush(): void {\n if (this._timerId === null && this._pendingKind === null) return;\n const now = Date.now();\n this._clearTimer();\n if (this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n // --- Engine (lodash port) ---\n\n private _schedule(kind: Exclude<PendingKind, null>, value: any, args: any[] | undefined): void {\n const now = Date.now();\n const isInvoking = this._shouldInvoke(now);\n\n this._pendingKind = kind;\n if (kind === \"value\") {\n this._pendingValue = value;\n } else {\n this._pendingArgs = args;\n }\n this._lastCallTime = now;\n this._setPending(true);\n\n if (isInvoking) {\n if (this._timerId === null) {\n this._leadingEdge(now);\n return;\n }\n if (this._hasMaxWait) {\n // Continuous input that has reached maxWait: restart the steady timer and\n // invoke now so a fire happens at least every maxWait ms (throttle path).\n // Clear the pending handle first (lodash's \"tight loop\" branch does the\n // same) — overwriting `_timerId` without clearing would orphan the old\n // timer and let it fire spuriously later.\n this._clearTimer();\n this._armTimer(this._wait);\n this._invoke(now);\n return;\n }\n }\n if (this._timerId === null) {\n this._armTimer(this._wait);\n }\n }\n\n private _shouldInvoke(now: number): boolean {\n if (this._lastCallTime === undefined) return true;\n const timeSinceLastCall = now - this._lastCallTime;\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n return (\n timeSinceLastCall >= this._wait ||\n timeSinceLastCall < 0 ||\n (this._hasMaxWait && timeSinceLastInvoke >= this._maxWait)\n );\n }\n\n private _remainingWait(now: number): number {\n const timeSinceLastCall = now - (this._lastCallTime as number);\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n const timeWaiting = this._wait - timeSinceLastCall;\n return this._hasMaxWait\n ? Math.min(timeWaiting, this._maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n private _timerExpired = (): void => {\n // §3.4 generation guard: a timer dequeued by the host before dispose() could\n // clear it must not settle into a torn-down element. Capture the generation\n // when the timer is scheduled (via `_armTimer`) and bail if it is stale.\n if (this._timerGen !== this._gen) return;\n const now = Date.now();\n if (this._shouldInvoke(now)) {\n this._trailingEdge(now);\n return;\n }\n // Fired before the quiet period elapsed (a later call moved the deadline) —\n // re-arm for the remaining time instead of settling now.\n this._armTimer(this._remainingWait(now));\n };\n\n private _leadingEdge(now: number): void {\n this._lastInvokeTime = now;\n this._armTimer(this._wait);\n if (this._leading) {\n this._invoke(now);\n }\n }\n\n private _trailingEdge(now: number): void {\n this._timerId = null;\n // Only fire when there is an unconsumed payload (a call arrived since the last\n // invoke). After a lone leading fire `_pendingKind` is null, so a single pulse\n // does not double-fire on its trailing edge.\n if (this._trailing && this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n private _invoke(now: number): void {\n this._lastInvokeTime = now;\n const kind = this._pendingKind;\n if (kind === \"value\") {\n this._value = this._pendingValue;\n this._dispatch(`${this._prefix}:settled`, { value: this._value });\n } else if (kind === \"signal\") {\n this._lastArgs = this._pendingArgs ?? [];\n this._dispatch(`${this._prefix}:fired`, { args: this._lastArgs });\n }\n // Mark consumed (mirrors lodash clearing `lastArgs`).\n this._pendingKind = null;\n }\n\n private _setPending(pending: boolean): void {\n if (this._pending === pending) return;\n this._pending = pending;\n this._dispatch(`${this._prefix}:pending-changed`, pending);\n }\n\n private _dispatch(type: string, detail: any): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n // Arm the settle timer, stamping the current generation so a callback that the\n // host dequeues after a dispose() can detect it is stale (§3.4).\n private _armTimer(delay: number): void {\n this._timerGen = this._gen;\n this._timerId = setTimeout(this._timerExpired, delay);\n }\n\n private _clearTimer(): void {\n if (this._timerId !== null) {\n clearTimeout(this._timerId);\n this._timerId = null;\n }\n }\n}\n","import { config } from \"./config.js\";\n\nlet registered = false;\n\ninterface Triggerable extends Element {\n trigger(...args: unknown[]): void;\n}\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const id = triggerElement.getAttribute(config.triggerAttribute);\n if (!id) return;\n\n // Resolve the registered constructors at call time (avoids a components ⇄\n // autoTrigger import cycle, mirroring <wcs-timer>). The DOM trigger fires a\n // single coalesced pulse on the referenced <wcs-debounce> / <wcs-throttle>.\n const DebounceCtor = customElements.get(config.tagNames.debounce);\n const ThrottleCtor = customElements.get(config.tagNames.throttle);\n const el = document.getElementById(id);\n if (!el) return;\n const isDebounce = DebounceCtor && el instanceof DebounceCtor;\n const isThrottle = ThrottleCtor && el instanceof ThrottleCtor;\n if (!isDebounce && !isThrottle) return;\n\n // Suppress the element's default action so a debounce can fire without\n // navigating. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (el as unknown as Triggerable).trigger();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { DebounceCore } from \"../core/DebounceCore.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nconst DEFAULT_WAIT = 250;\n\n/**\n * `<wcs-debounce>` — declarative debounce. See {@link DebounceCore} for the\n * engine. The `eventPrefix` defaults to `\"wcs-debounce\"`; `<wcs-throttle>`\n * subclasses this with `\"wcs-throttle\"` and throttle defaults.\n */\nexport class Debounce extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n protected static eventPrefix = \"wcs-debounce\";\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n // `source` is the value-surface input (its debounced echo comes back on the\n // `value` property). `trigger` / `cancel` / `flush` are commands from the\n // Core. No momentary boolean `trigger` property exists — the signal surface\n // is driven by the `trigger` command (command-token) or a DOM click\n // (autoTrigger), which sidesteps the attribute/method name clash that forced\n // <wcs-geo>'s watch → watchPosition rename.\n inputs: [\n { name: \"source\" },\n { name: \"wait\", attribute: \"wait\" },\n // No `attribute` hint on leading / trailing: their setters already reflect\n // to the backing attribute themselves (the fetch-Shell idiom), and — more\n // importantly — the backing attribute is NOT the input name. `trailing`\n // reflects to the inverted `no-trailing` (default true; a bare `trailing`\n // attribute can't express false), and the `<wcs-throttle>` subclass reads\n // `leading` from the inverted `no-leading` (default on). A single\n // input-name→attribute hint can't be correct for both polarities/subclasses,\n // so binders drive these through the property setter instead.\n { name: \"leading\" },\n { name: \"trailing\" },\n { name: \"maxWait\", attribute: \"max-wait\" },\n ],\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n protected _core: DebounceCore;\n private _source: any = undefined;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new DebounceCore((this.constructor as typeof Debounce).eventPrefix, this);\n this._internals = this._initInternals();\n // `<wcs-throttle>` extends this class without overriding the constructor, so\n // `this.constructor` resolves to the actual subclass here too — the map key\n // tracks whichever `eventPrefix` the instance dispatches under\n // (docs/custom-state-reflection-design.md §3.4).\n const prefix = (this.constructor as typeof Debounce).eventPrefix;\n this._wireStates({ [`${prefix}:pending-changed`]: (d) => ({ pending: d === true }) });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get wait(): number {\n const attr = this.getAttribute(\"wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultWait();\n // Strict parse via Number() (\"100px\" -> NaN, not 100). Fall back to the\n // default for any non-finite or negative value.\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultWait();\n }\n\n set wait(value: number) {\n this.setAttribute(\"wait\", String(value));\n }\n\n get leading(): boolean {\n return this.hasAttribute(\"leading\");\n }\n\n set leading(value: boolean) {\n if (value) {\n this.setAttribute(\"leading\", \"\");\n } else {\n this.removeAttribute(\"leading\");\n }\n }\n\n // `trailing` defaults to true; the boolean `no-trailing` attribute opts out (a\n // bare `trailing` attribute can't express \"false\", so the negative flag carries\n // the override).\n get trailing(): boolean {\n return !this.hasAttribute(\"no-trailing\");\n }\n\n set trailing(value: boolean) {\n if (value) {\n this.removeAttribute(\"no-trailing\");\n } else {\n this.setAttribute(\"no-trailing\", \"\");\n }\n }\n\n get maxWait(): number | undefined {\n const attr = this.getAttribute(\"max-wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultMaxWait();\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultMaxWait();\n }\n\n set maxWait(value: number) {\n this.setAttribute(\"max-wait\", String(value));\n }\n\n // --- Value-surface input ---\n\n get source(): any {\n return this._source;\n }\n\n set source(value: any) {\n this._source = value;\n this._core.configure(this._options());\n this._core.setSource(value);\n }\n\n // --- Core delegated getters ---\n\n get value(): any {\n return this._core.value;\n }\n\n get fired(): any[] {\n return this._core.fired;\n }\n\n get pending(): boolean {\n return this._core.pending;\n }\n\n // --- Commands ---\n\n trigger(...args: any[]): void {\n this._core.configure(this._options());\n this._core.trigger(...args);\n }\n\n cancel(): void {\n this._core.cancel();\n }\n\n flush(): void {\n this._core.flush();\n }\n\n // --- Internal ---\n\n // Overridden by <wcs-throttle> to bias the defaults toward throttle (leading\n // on, maxWait pinned to wait).\n protected _defaultWait(): number {\n return DEFAULT_WAIT;\n }\n\n // Resolves the effective `leading` value (not a static default). It is a method\n // rather than reading `this.leading` directly because <wcs-throttle> inverts the\n // default (on, opt out via `no-leading`) while sharing the inherited `leading`\n // attribute setter — overriding the getter alone would desync getter and setter.\n protected _resolveLeading(): boolean {\n return this.leading;\n }\n\n protected _defaultMaxWait(): number | undefined {\n return undefined;\n }\n\n protected _options(): DebounceOptions {\n return {\n wait: this.wait,\n leading: this._resolveLeading(),\n trailing: this.trailing,\n maxWait: this.maxWait,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // §4.1/§4.4 Shell SSR: expose connectedCallbackPromise backed by observe().\n // observe() is a no-op resolving once ready (the engine is command-driven).\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n // Drop any in-flight timer so a detached element leaks nothing, and bump the\n // Core generation so a surviving timer callback cannot settle (§3.5).\n this._core.dispose();\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { Debounce } from \"./Debounce.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\n/**\n * `<wcs-throttle>` — the same {@link DebounceCore} engine biased to throttle:\n * `maxWait === wait` (a fire happens at least every `wait` ms under continuous\n * input) and `leading` on by default. It advertises its own `wcs-throttle:*`\n * event namespace (via `makeDebounceProperties(\"wcs-throttle\")`), and the Core\n * dispatches under that prefix because the constructor passes it through.\n */\nexport class Throttle extends Debounce {\n protected static eventPrefix = \"wcs-throttle\";\n static wcBindable: IWcBindable = {\n ...Debounce.wcBindable,\n properties: makeDebounceProperties(\"wcs-throttle\"),\n };\n\n // leading defaults on for throttle; `no-leading` opts out (symmetric with the\n // inherited `no-trailing`).\n protected _resolveLeading(): boolean {\n return !this.hasAttribute(\"no-leading\");\n }\n\n // Pin maxWait to wait so throttle fires on a steady cadence; an explicit\n // `max-wait` attribute still overrides via the inherited getter.\n protected _defaultMaxWait(): number | undefined {\n return this.wait;\n }\n}\n","import { Debounce } from \"./components/Debounce.js\";\nimport { Throttle } from \"./components/Throttle.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.debounce)) {\n customElements.define(config.tagNames.debounce, Debounce);\n }\n if (!customElements.get(config.tagNames.throttle)) {\n customElements.define(config.tagNames.throttle, Throttle);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapDebounce(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAWA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,qBAAqB;AACvC,IAAA,QAAQ,EAAE;AACR,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,QAAQ,EAAE,cAAc;AACzB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IA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nD;;;IAIS,eAAe,GAAA;AACvB,QAAA,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;IACzC;;;IAIU,eAAe,GAAA;QACvB,OAAO,IAAI,CAAC,IAAI;IAClB;;;SCxBc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACjD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC3D;AACA,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACjD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC3D;AACF;;ACPM,SAAU,iBAAiB,CAAC,UAA4B,EAAA;IAC5D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
@@ -1,2 +1,2 @@
1
- const t={autoTrigger:!0,triggerAttribute:"data-debouncetarget",tagNames:{debounce:"wcs-debounce",throttle:"wcs-throttle"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const i of Object.keys(t))e(t[i]);return t}function i(t){if(null===t||"object"!=typeof t)return t;const e={};for(const n of Object.keys(t))e[n]=i(t[n]);return e}let n=null;const s=t;function r(){return n||(n=e(i(t))),n}function a(t){return[{name:"value",event:`${t}:settled`,getter:t=>t.detail.value},{name:"fired",event:`${t}:fired`,getter:t=>t.detail.args},{name:"pending",event:`${t}:pending-changed`}]}class l extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:a("wcs-debounce"),commands:[{name:"trigger"},{name:"cancel"},{name:"flush"}]};_prefix;_target;_wait=0;_leading=!1;_trailing=!0;_maxWait=0;_hasMaxWait=!1;_lastCallTime=void 0;_lastInvokeTime=0;_timerId=null;_timerGen=0;_pendingKind=null;_pendingValue=void 0;_pendingArgs=void 0;_value=void 0;_lastArgs=[];_pending=!1;_gen=0;_ready=Promise.resolve();constructor(t="wcs-debounce",e,i){super(),this._prefix=t,this._target=e??this,i&&this.configure(i)}get ready(){return this._ready}observe(){return this._ready}dispose(){this._gen++,this.cancel()}configure(t={}){"number"==typeof t.wait&&Number.isFinite(t.wait)&&t.wait>=0&&(this._wait=t.wait),"boolean"==typeof t.leading&&(this._leading=t.leading),"boolean"==typeof t.trailing&&(this._trailing=t.trailing);const e=t.maxWait;"number"==typeof e&&Number.isFinite(e)&&e>=0?(this._maxWait=Math.max(e,this._wait),this._hasMaxWait=!0):(this._maxWait=0,this._hasMaxWait=!1)}get value(){return this._value}get fired(){return this._lastArgs}get pending(){return this._pending}setSource(t){this._schedule("value",t,void 0)}trigger(...t){this._schedule("signal",void 0,t)}cancel(){this._clearTimer(),this._lastInvokeTime=0,this._lastCallTime=void 0,this._pendingKind=null,this._pendingValue=void 0,this._pendingArgs=void 0,this._setPending(!1)}flush(){if(null===this._timerId&&null===this._pendingKind)return;const t=Date.now();this._clearTimer(),null!==this._pendingKind&&this._invoke(t),this._pendingKind=null,this._pendingValue=void 0,this._pendingArgs=void 0,this._setPending(!1)}_schedule(t,e,i){const n=Date.now(),s=this._shouldInvoke(n);if(this._pendingKind=t,"value"===t?this._pendingValue=e:this._pendingArgs=i,this._lastCallTime=n,this._setPending(!0),s){if(null===this._timerId)return void this._leadingEdge(n);if(this._hasMaxWait)return this._clearTimer(),this._armTimer(this._wait),void this._invoke(n)}null===this._timerId&&this._armTimer(this._wait)}_shouldInvoke(t){if(void 0===this._lastCallTime)return!0;const e=t-this._lastCallTime,i=t-this._lastInvokeTime;return e>=this._wait||e<0||this._hasMaxWait&&i>=this._maxWait}_remainingWait(t){const e=t-this._lastCallTime,i=t-this._lastInvokeTime,n=this._wait-e;return this._hasMaxWait?Math.min(n,this._maxWait-i):n}_timerExpired=()=>{if(this._timerGen!==this._gen)return;const t=Date.now();this._shouldInvoke(t)?this._trailingEdge(t):this._armTimer(this._remainingWait(t))};_leadingEdge(t){this._lastInvokeTime=t,this._armTimer(this._wait),this._leading&&this._invoke(t)}_trailingEdge(t){this._timerId=null,this._trailing&&null!==this._pendingKind&&this._invoke(t),this._pendingKind=null,this._pendingValue=void 0,this._pendingArgs=void 0,this._setPending(!1)}_invoke(t){this._lastInvokeTime=t;const e=this._pendingKind;"value"===e?(this._value=this._pendingValue,this._dispatch(`${this._prefix}:settled`,{value:this._value})):"signal"===e&&(this._lastArgs=this._pendingArgs??[],this._dispatch(`${this._prefix}:fired`,{args:this._lastArgs})),this._pendingKind=null}_setPending(t){this._pending!==t&&(this._pending=t,this._dispatch(`${this._prefix}:pending-changed`,t))}_dispatch(t,e){this._target.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}_armTimer(t){this._timerGen=this._gen,this._timerId=setTimeout(this._timerExpired,t)}_clearTimer(){null!==this._timerId&&(clearTimeout(this._timerId),this._timerId=null)}}let o=!1;function h(t){const e=t.target;if(!(e instanceof Element))return;const i=e.closest(`[${s.triggerAttribute}]`);if(!i)return;const n=i.getAttribute(s.triggerAttribute);if(!n)return;const r=customElements.get(s.tagNames.debounce),a=customElements.get(s.tagNames.throttle),l=document.getElementById(n);if(!l)return;(r&&l instanceof r||a&&l instanceof a)&&(t.preventDefault(),l.trigger())}class g extends HTMLElement{static hasConnectedCallbackPromise=!0;static eventPrefix="wcs-debounce";static wcBindable={protocol:"wc-bindable",version:1,properties:a("wcs-debounce"),inputs:[{name:"source"},{name:"wait",attribute:"wait"},{name:"leading"},{name:"trailing"},{name:"maxWait",attribute:"max-wait"}],commands:[{name:"trigger"},{name:"cancel"},{name:"flush"}]};_core;_source=void 0;_connectedCallbackPromise=Promise.resolve();constructor(){super(),this._core=new l(this.constructor.eventPrefix,this)}get connectedCallbackPromise(){return this._connectedCallbackPromise}get wait(){const t=this.getAttribute("wait");if(null===t||""===t.trim())return this._defaultWait();const e=Number(t);return Number.isFinite(e)&&e>=0?e:this._defaultWait()}set wait(t){this.setAttribute("wait",String(t))}get leading(){return this.hasAttribute("leading")}set leading(t){t?this.setAttribute("leading",""):this.removeAttribute("leading")}get trailing(){return!this.hasAttribute("no-trailing")}set trailing(t){t?this.removeAttribute("no-trailing"):this.setAttribute("no-trailing","")}get maxWait(){const t=this.getAttribute("max-wait");if(null===t||""===t.trim())return this._defaultMaxWait();const e=Number(t);return Number.isFinite(e)&&e>=0?e:this._defaultMaxWait()}set maxWait(t){this.setAttribute("max-wait",String(t))}get source(){return this._source}set source(t){this._source=t,this._core.configure(this._options()),this._core.setSource(t)}get value(){return this._core.value}get fired(){return this._core.fired}get pending(){return this._core.pending}trigger(...t){this._core.configure(this._options()),this._core.trigger(...t)}cancel(){this._core.cancel()}flush(){this._core.flush()}_defaultWait(){return 250}_resolveLeading(){return this.leading}_defaultMaxWait(){}_options(){return{wait:this.wait,leading:this._resolveLeading(),trailing:this.trailing,maxWait:this.maxWait}}connectedCallback(){this.style.display="none",s.autoTrigger&&(o||(o=!0,document.addEventListener("click",h))),this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this._core.dispose()}}class u extends g{static eventPrefix="wcs-throttle";static wcBindable={...g.wcBindable,properties:a("wcs-throttle")};_resolveLeading(){return!this.hasAttribute("no-leading")}_defaultMaxWait(){return this.wait}}function d(e){var i;e&&("boolean"==typeof(i=e).autoTrigger&&(t.autoTrigger=i.autoTrigger),"string"==typeof i.triggerAttribute&&(t.triggerAttribute=i.triggerAttribute),i.tagNames&&Object.assign(t.tagNames,i.tagNames),n=null),customElements.get(s.tagNames.debounce)||customElements.define(s.tagNames.debounce,g),customElements.get(s.tagNames.throttle)||customElements.define(s.tagNames.throttle,u)}export{l as DebounceCore,g as WcsDebounce,u as WcsThrottle,d as bootstrapDebounce,r as getConfig,a as makeDebounceProperties};
1
+ const t={autoTrigger:!0,triggerAttribute:"data-debouncetarget",tagNames:{debounce:"wcs-debounce",throttle:"wcs-throttle"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const i of Object.keys(t))e(t[i]);return t}function i(t){if(null===t||"object"!=typeof t)return t;const e={};for(const n of Object.keys(t))e[n]=i(t[n]);return e}let n=null;const s=t;function r(){return n||(n=e(i(t))),n}function a(t){return[{name:"value",event:`${t}:settled`,getter:t=>t.detail.value},{name:"fired",event:`${t}:fired`,getter:t=>t.detail.args},{name:"pending",event:`${t}:pending-changed`}]}class l extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:a("wcs-debounce"),commands:[{name:"trigger"},{name:"cancel"},{name:"flush"}]};_prefix;_target;_wait=0;_leading=!1;_trailing=!0;_maxWait=0;_hasMaxWait=!1;_lastCallTime=void 0;_lastInvokeTime=0;_timerId=null;_timerGen=0;_pendingKind=null;_pendingValue=void 0;_pendingArgs=void 0;_value=void 0;_lastArgs=[];_pending=!1;_gen=0;_ready=Promise.resolve();constructor(t="wcs-debounce",e,i){super(),this._prefix=t,this._target=e??this,i&&this.configure(i)}get ready(){return this._ready}observe(){return this._ready}dispose(){this._gen++,this.cancel()}configure(t={}){"number"==typeof t.wait&&Number.isFinite(t.wait)&&t.wait>=0&&(this._wait=t.wait),"boolean"==typeof t.leading&&(this._leading=t.leading),"boolean"==typeof t.trailing&&(this._trailing=t.trailing);const e=t.maxWait;"number"==typeof e&&Number.isFinite(e)&&e>=0?(this._maxWait=Math.max(e,this._wait),this._hasMaxWait=!0):(this._maxWait=0,this._hasMaxWait=!1)}get value(){return this._value}get fired(){return this._lastArgs}get pending(){return this._pending}setSource(t){this._schedule("value",t,void 0)}trigger(...t){this._schedule("signal",void 0,t)}cancel(){this._clearTimer(),this._lastInvokeTime=0,this._lastCallTime=void 0,this._pendingKind=null,this._pendingValue=void 0,this._pendingArgs=void 0,this._setPending(!1)}flush(){if(null===this._timerId&&null===this._pendingKind)return;const t=Date.now();this._clearTimer(),null!==this._pendingKind&&this._invoke(t),this._pendingKind=null,this._pendingValue=void 0,this._pendingArgs=void 0,this._setPending(!1)}_schedule(t,e,i){const n=Date.now(),s=this._shouldInvoke(n);if(this._pendingKind=t,"value"===t?this._pendingValue=e:this._pendingArgs=i,this._lastCallTime=n,this._setPending(!0),s){if(null===this._timerId)return void this._leadingEdge(n);if(this._hasMaxWait)return this._clearTimer(),this._armTimer(this._wait),void this._invoke(n)}null===this._timerId&&this._armTimer(this._wait)}_shouldInvoke(t){if(void 0===this._lastCallTime)return!0;const e=t-this._lastCallTime,i=t-this._lastInvokeTime;return e>=this._wait||e<0||this._hasMaxWait&&i>=this._maxWait}_remainingWait(t){const e=t-this._lastCallTime,i=t-this._lastInvokeTime,n=this._wait-e;return this._hasMaxWait?Math.min(n,this._maxWait-i):n}_timerExpired=()=>{if(this._timerGen!==this._gen)return;const t=Date.now();this._shouldInvoke(t)?this._trailingEdge(t):this._armTimer(this._remainingWait(t))};_leadingEdge(t){this._lastInvokeTime=t,this._armTimer(this._wait),this._leading&&this._invoke(t)}_trailingEdge(t){this._timerId=null,this._trailing&&null!==this._pendingKind&&this._invoke(t),this._pendingKind=null,this._pendingValue=void 0,this._pendingArgs=void 0,this._setPending(!1)}_invoke(t){this._lastInvokeTime=t;const e=this._pendingKind;"value"===e?(this._value=this._pendingValue,this._dispatch(`${this._prefix}:settled`,{value:this._value})):"signal"===e&&(this._lastArgs=this._pendingArgs??[],this._dispatch(`${this._prefix}:fired`,{args:this._lastArgs})),this._pendingKind=null}_setPending(t){this._pending!==t&&(this._pending=t,this._dispatch(`${this._prefix}:pending-changed`,t))}_dispatch(t,e){this._target.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}_armTimer(t){this._timerGen=this._gen,this._timerId=setTimeout(this._timerExpired,t)}_clearTimer(){null!==this._timerId&&(clearTimeout(this._timerId),this._timerId=null)}}let o=!1;function h(t){const e=t.target;if(!(e instanceof Element))return;const i=e.closest(`[${s.triggerAttribute}]`);if(!i)return;const n=i.getAttribute(s.triggerAttribute);if(!n)return;const r=customElements.get(s.tagNames.debounce),a=customElements.get(s.tagNames.throttle),l=document.getElementById(n);if(!l)return;(r&&l instanceof r||a&&l instanceof a)&&(t.preventDefault(),l.trigger())}class u extends HTMLElement{static hasConnectedCallbackPromise=!0;static eventPrefix="wcs-debounce";static wcBindable={protocol:"wc-bindable",version:1,properties:a("wcs-debounce"),inputs:[{name:"source"},{name:"wait",attribute:"wait"},{name:"leading"},{name:"trailing"},{name:"maxWait",attribute:"max-wait"}],commands:[{name:"trigger"},{name:"cancel"},{name:"flush"}]};_core;_source=void 0;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new l(this.constructor.eventPrefix,this),this._internals=this._initInternals();const t=this.constructor.eventPrefix;this._wireStates({[`${t}:pending-changed`]:t=>({pending:!0===t})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[i,n]of Object.entries(t))this.addEventListener(i,t=>{const i=this.hasAttribute("debug-states");for(const[s,r]of Object.entries(n(t.detail))){try{r?e.add(s):e.delete(s)}catch{}i&&this.toggleAttribute(`data-wcs-state-${s}`,r)}})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get wait(){const t=this.getAttribute("wait");if(null===t||""===t.trim())return this._defaultWait();const e=Number(t);return Number.isFinite(e)&&e>=0?e:this._defaultWait()}set wait(t){this.setAttribute("wait",String(t))}get leading(){return this.hasAttribute("leading")}set leading(t){t?this.setAttribute("leading",""):this.removeAttribute("leading")}get trailing(){return!this.hasAttribute("no-trailing")}set trailing(t){t?this.removeAttribute("no-trailing"):this.setAttribute("no-trailing","")}get maxWait(){const t=this.getAttribute("max-wait");if(null===t||""===t.trim())return this._defaultMaxWait();const e=Number(t);return Number.isFinite(e)&&e>=0?e:this._defaultMaxWait()}set maxWait(t){this.setAttribute("max-wait",String(t))}get source(){return this._source}set source(t){this._source=t,this._core.configure(this._options()),this._core.setSource(t)}get value(){return this._core.value}get fired(){return this._core.fired}get pending(){return this._core.pending}trigger(...t){this._core.configure(this._options()),this._core.trigger(...t)}cancel(){this._core.cancel()}flush(){this._core.flush()}_defaultWait(){return 250}_resolveLeading(){return this.leading}_defaultMaxWait(){}_options(){return{wait:this.wait,leading:this._resolveLeading(),trailing:this.trailing,maxWait:this.maxWait}}connectedCallback(){this.style.display="none",s.autoTrigger&&(o||(o=!0,document.addEventListener("click",h))),this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this._core.dispose()}}class d extends u{static eventPrefix="wcs-throttle";static wcBindable={...u.wcBindable,properties:a("wcs-throttle")};_resolveLeading(){return!this.hasAttribute("no-leading")}_defaultMaxWait(){return this.wait}}function g(e){var i;e&&("boolean"==typeof(i=e).autoTrigger&&(t.autoTrigger=i.autoTrigger),"string"==typeof i.triggerAttribute&&(t.triggerAttribute=i.triggerAttribute),i.tagNames&&Object.assign(t.tagNames,i.tagNames),n=null),customElements.get(s.tagNames.debounce)||customElements.define(s.tagNames.debounce,u),customElements.get(s.tagNames.throttle)||customElements.define(s.tagNames.throttle,d)}export{l as DebounceCore,u as WcsDebounce,d as WcsThrottle,g as bootstrapDebounce,r as getConfig,a as makeDebounceProperties};
2
2
  //# sourceMappingURL=index.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/components/Debounce.ts","../src/components/Throttle.ts","../src/bootstrapDebounce.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n debounce: string;\n throttle: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-debouncetarget\",\n tagNames: {\n debounce: \"wcs-debounce\",\n throttle: \"wcs-throttle\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindableProperty } from \"./types.js\";\n\n/**\n * Build the wc-bindable `properties` list for a debounce/throttle element, with\n * every event name derived from a single `prefix`. `<wcs-debounce>` uses\n * `\"wcs-debounce\"`, `<wcs-throttle>` uses `\"wcs-throttle\"`, so the two tags share\n * one engine (DebounceCore) yet advertise distinct event namespaces from one\n * source of truth — no hand-duplicated property tables (cf. the geolocation Shell\n * which overrode its wcBindable by hand).\n *\n * - `value` — the debounced value of the latest `source` write (value surface),\n * read from the `<prefix>:settled` event.\n * - `fired` — the coalesced args of the latest `trigger()` pulse (signal\n * surface), read from the `<prefix>:fired` event. Declared as a\n * property (not just an event) so state can subscribe via the\n * event-token protocol (`eventToken.fired: <name>`).\n * - `pending` — whether a debounce is currently in flight.\n */\nexport function makeDebounceProperties(prefix: string): IWcBindableProperty[] {\n return [\n { name: \"value\", event: `${prefix}:settled`, getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed` },\n ];\n}\n","import { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\ntype PendingKind = \"value\" | \"signal\" | null;\n\n/**\n * Headless debounce/throttle primitive. A framework-agnostic port of lodash's\n * `debounce` algorithm (`shouldInvoke` / `leadingEdge` / `trailingEdge` /\n * `remainingWait`, timed via `Date.now()`), exposed through the wc-bindable\n * protocol.\n *\n * It coalesces a stream of *signals* and emits at most one per quiet period.\n * Two surfaces share the single timer:\n *\n * - **value** — writing {@link setSource} schedules a settle; on fire the\n * debounced value is published via the `<prefix>:settled` event and the\n * `value` getter. Wire it as `source: src; value: debounced`.\n * - **signal** — calling {@link trigger}`(...args)` coalesces a burst of pulses;\n * on fire one `<prefix>:fired` event carries the latest args (relayed by state\n * through the command-token / event-token protocols).\n *\n * A given instance is meant to be used for one surface at a time. Because each\n * surface keeps its own field (`_value` vs `_lastArgs`), the getters never\n * pollute each other; if both are driven on one instance the *last* scheduled\n * signal wins (lodash's last-args semantics).\n *\n * Throttle is the same engine with `maxWait === wait` (and `leading` on by\n * default), so `<wcs-throttle>` reuses this class with a different `eventPrefix`.\n */\nexport class DebounceCore extends EventTarget {\n // The static contract advertises the *default* `wcs-debounce:*` event names. A\n // headless Core constructed with a non-default `eventPrefix` (e.g.\n // `\"wcs-throttle\"`) dispatches under that prefix, so its events won't match\n // this metadata — rebuild the property table with `makeDebounceProperties(prefix)`\n // for that case. (The `<wcs-throttle>` Shell already overrides its own\n // `wcBindable` this way, so binding through an element is always consistent.)\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n private readonly _prefix: string;\n private _target: EventTarget;\n\n // Tuning (lodash knobs).\n private _wait: number = 0;\n private _leading: boolean = false;\n private _trailing: boolean = true;\n private _maxWait: number = 0;\n private _hasMaxWait: boolean = false;\n\n // Timing bookkeeping.\n private _lastCallTime: number | undefined = undefined;\n private _lastInvokeTime: number = 0;\n private _timerId: ReturnType<typeof setTimeout> | null = null;\n // Generation stamped onto the live timer at arm time, compared in\n // `_timerExpired` against `_gen` to drop callbacks that outlived a dispose().\n private _timerGen: number = 0;\n\n // Last-wins pending payload. `_pendingKind === null` doubles as the \"consumed /\n // empty\" sentinel (lodash clears `lastArgs` in invokeFunc): a trailing edge with\n // no fresh call since the last fire sees `null` and does not re-fire, which is\n // what stops a single leading pulse from also firing on the trailing edge.\n private _pendingKind: PendingKind = null;\n private _pendingValue: any = undefined;\n private _pendingArgs: any[] | undefined = undefined;\n\n // Observable state (getter backing).\n private _value: any = undefined;\n private _lastArgs: any[] = [];\n private _pending: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() so a timer that survives a\n // tear-down can no longer settle into a detached element. A pending timer is\n // also cleared by dispose() → cancel(), so the guard is defensive: it stops\n // any callback that has already been dequeued by the host event loop from\n // writing state after dispose().\n private _gen = 0;\n // SSR (§3.8): the debounce engine is purely timer-driven with no asynchronous\n // probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(prefix: string = \"wcs-debounce\", target?: EventTarget, options?: DebounceOptions) {\n super();\n this._prefix = prefix;\n this._target = target ?? this;\n if (options) {\n this.configure(options);\n }\n }\n\n // --- Lifecycle (§3.5 / §3.8) ---\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Debounce is command-driven (setSource / trigger schedule work on demand)\n // with no subscription to establish, so observe() is an idempotent no-op that\n // resolves once ready.\n observe(): Promise<void> {\n return this._ready;\n }\n\n // Tear down the pending timer and invalidate the generation so a stale timer\n // callback cannot fire after the element is detached.\n dispose(): void {\n this._gen++;\n this.cancel();\n }\n\n // --- Configuration ---\n\n /**\n * Update the tuning knobs. The Shell calls this with the element's current\n * attributes before each schedule, so live attribute edits take effect on the\n * next signal. `maxWait` is clamped to at least `wait` (lodash semantics); an\n * absent / invalid `maxWait` disables maxWait entirely.\n */\n configure(options: DebounceOptions = {}): void {\n if (typeof options.wait === \"number\" && Number.isFinite(options.wait) && options.wait >= 0) {\n this._wait = options.wait;\n }\n if (typeof options.leading === \"boolean\") {\n this._leading = options.leading;\n }\n if (typeof options.trailing === \"boolean\") {\n this._trailing = options.trailing;\n }\n const mw = options.maxWait;\n if (typeof mw === \"number\" && Number.isFinite(mw) && mw >= 0) {\n this._maxWait = Math.max(mw, this._wait);\n this._hasMaxWait = true;\n } else {\n this._maxWait = 0;\n this._hasMaxWait = false;\n }\n }\n\n // --- Observable getters ---\n\n get value(): any {\n return this._value;\n }\n\n get fired(): any[] {\n return this._lastArgs;\n }\n\n get pending(): boolean {\n return this._pending;\n }\n\n // --- Public entry points ---\n\n /** Value surface: schedule a settle carrying `value` (last write wins). */\n setSource(value: any): void {\n this._schedule(\"value\", value, undefined);\n }\n\n /** Signal surface: coalesce a pulse carrying `args` (last call wins). */\n trigger(...args: any[]): void {\n this._schedule(\"signal\", undefined, args);\n }\n\n /** Drop any pending fire without emitting. Getters keep their last values. */\n cancel(): void {\n this._clearTimer();\n this._lastInvokeTime = 0;\n this._lastCallTime = undefined;\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n /**\n * Emit any buffered payload immediately, then clear pending. Unlike lodash's\n * `flush` (which honours `trailing`), this fires whatever is buffered — the\n * command's intent is \"publish now\" — but is a no-op when nothing is pending.\n */\n flush(): void {\n if (this._timerId === null && this._pendingKind === null) return;\n const now = Date.now();\n this._clearTimer();\n if (this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n // --- Engine (lodash port) ---\n\n private _schedule(kind: Exclude<PendingKind, null>, value: any, args: any[] | undefined): void {\n const now = Date.now();\n const isInvoking = this._shouldInvoke(now);\n\n this._pendingKind = kind;\n if (kind === \"value\") {\n this._pendingValue = value;\n } else {\n this._pendingArgs = args;\n }\n this._lastCallTime = now;\n this._setPending(true);\n\n if (isInvoking) {\n if (this._timerId === null) {\n this._leadingEdge(now);\n return;\n }\n if (this._hasMaxWait) {\n // Continuous input that has reached maxWait: restart the steady timer and\n // invoke now so a fire happens at least every maxWait ms (throttle path).\n // Clear the pending handle first (lodash's \"tight loop\" branch does the\n // same) — overwriting `_timerId` without clearing would orphan the old\n // timer and let it fire spuriously later.\n this._clearTimer();\n this._armTimer(this._wait);\n this._invoke(now);\n return;\n }\n }\n if (this._timerId === null) {\n this._armTimer(this._wait);\n }\n }\n\n private _shouldInvoke(now: number): boolean {\n if (this._lastCallTime === undefined) return true;\n const timeSinceLastCall = now - this._lastCallTime;\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n return (\n timeSinceLastCall >= this._wait ||\n timeSinceLastCall < 0 ||\n (this._hasMaxWait && timeSinceLastInvoke >= this._maxWait)\n );\n }\n\n private _remainingWait(now: number): number {\n const timeSinceLastCall = now - (this._lastCallTime as number);\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n const timeWaiting = this._wait - timeSinceLastCall;\n return this._hasMaxWait\n ? Math.min(timeWaiting, this._maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n private _timerExpired = (): void => {\n // §3.4 generation guard: a timer dequeued by the host before dispose() could\n // clear it must not settle into a torn-down element. Capture the generation\n // when the timer is scheduled (via `_armTimer`) and bail if it is stale.\n if (this._timerGen !== this._gen) return;\n const now = Date.now();\n if (this._shouldInvoke(now)) {\n this._trailingEdge(now);\n return;\n }\n // Fired before the quiet period elapsed (a later call moved the deadline) —\n // re-arm for the remaining time instead of settling now.\n this._armTimer(this._remainingWait(now));\n };\n\n private _leadingEdge(now: number): void {\n this._lastInvokeTime = now;\n this._armTimer(this._wait);\n if (this._leading) {\n this._invoke(now);\n }\n }\n\n private _trailingEdge(now: number): void {\n this._timerId = null;\n // Only fire when there is an unconsumed payload (a call arrived since the last\n // invoke). After a lone leading fire `_pendingKind` is null, so a single pulse\n // does not double-fire on its trailing edge.\n if (this._trailing && this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n private _invoke(now: number): void {\n this._lastInvokeTime = now;\n const kind = this._pendingKind;\n if (kind === \"value\") {\n this._value = this._pendingValue;\n this._dispatch(`${this._prefix}:settled`, { value: this._value });\n } else if (kind === \"signal\") {\n this._lastArgs = this._pendingArgs ?? [];\n this._dispatch(`${this._prefix}:fired`, { args: this._lastArgs });\n }\n // Mark consumed (mirrors lodash clearing `lastArgs`).\n this._pendingKind = null;\n }\n\n private _setPending(pending: boolean): void {\n if (this._pending === pending) return;\n this._pending = pending;\n this._dispatch(`${this._prefix}:pending-changed`, pending);\n }\n\n private _dispatch(type: string, detail: any): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n // Arm the settle timer, stamping the current generation so a callback that the\n // host dequeues after a dispose() can detect it is stale (§3.4).\n private _armTimer(delay: number): void {\n this._timerGen = this._gen;\n this._timerId = setTimeout(this._timerExpired, delay);\n }\n\n private _clearTimer(): void {\n if (this._timerId !== null) {\n clearTimeout(this._timerId);\n this._timerId = null;\n }\n }\n}\n","import { config } from \"./config.js\";\n\nlet registered = false;\n\ninterface Triggerable extends Element {\n trigger(...args: unknown[]): void;\n}\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const id = triggerElement.getAttribute(config.triggerAttribute);\n if (!id) return;\n\n // Resolve the registered constructors at call time (avoids a components ⇄\n // autoTrigger import cycle, mirroring <wcs-timer>). The DOM trigger fires a\n // single coalesced pulse on the referenced <wcs-debounce> / <wcs-throttle>.\n const DebounceCtor = customElements.get(config.tagNames.debounce);\n const ThrottleCtor = customElements.get(config.tagNames.throttle);\n const el = document.getElementById(id);\n if (!el) return;\n const isDebounce = DebounceCtor && el instanceof DebounceCtor;\n const isThrottle = ThrottleCtor && el instanceof ThrottleCtor;\n if (!isDebounce && !isThrottle) return;\n\n // Suppress the element's default action so a debounce can fire without\n // navigating. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (el as unknown as Triggerable).trigger();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { DebounceCore } from \"../core/DebounceCore.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nconst DEFAULT_WAIT = 250;\n\n/**\n * `<wcs-debounce>` — declarative debounce. See {@link DebounceCore} for the\n * engine. The `eventPrefix` defaults to `\"wcs-debounce\"`; `<wcs-throttle>`\n * subclasses this with `\"wcs-throttle\"` and throttle defaults.\n */\nexport class Debounce extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n protected static eventPrefix = \"wcs-debounce\";\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n // `source` is the value-surface input (its debounced echo comes back on the\n // `value` property). `trigger` / `cancel` / `flush` are commands from the\n // Core. No momentary boolean `trigger` property exists — the signal surface\n // is driven by the `trigger` command (command-token) or a DOM click\n // (autoTrigger), which sidesteps the attribute/method name clash that forced\n // <wcs-geo>'s watch → watchPosition rename.\n inputs: [\n { name: \"source\" },\n { name: \"wait\", attribute: \"wait\" },\n // No `attribute` hint on leading / trailing: their setters already reflect\n // to the backing attribute themselves (the fetch-Shell idiom), and — more\n // importantly — the backing attribute is NOT the input name. `trailing`\n // reflects to the inverted `no-trailing` (default true; a bare `trailing`\n // attribute can't express false), and the `<wcs-throttle>` subclass reads\n // `leading` from the inverted `no-leading` (default on). A single\n // input-name→attribute hint can't be correct for both polarities/subclasses,\n // so binders drive these through the property setter instead.\n { name: \"leading\" },\n { name: \"trailing\" },\n { name: \"maxWait\", attribute: \"max-wait\" },\n ],\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n protected _core: DebounceCore;\n private _source: any = undefined;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new DebounceCore((this.constructor as typeof Debounce).eventPrefix, this);\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get wait(): number {\n const attr = this.getAttribute(\"wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultWait();\n // Strict parse via Number() (\"100px\" -> NaN, not 100). Fall back to the\n // default for any non-finite or negative value.\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultWait();\n }\n\n set wait(value: number) {\n this.setAttribute(\"wait\", String(value));\n }\n\n get leading(): boolean {\n return this.hasAttribute(\"leading\");\n }\n\n set leading(value: boolean) {\n if (value) {\n this.setAttribute(\"leading\", \"\");\n } else {\n this.removeAttribute(\"leading\");\n }\n }\n\n // `trailing` defaults to true; the boolean `no-trailing` attribute opts out (a\n // bare `trailing` attribute can't express \"false\", so the negative flag carries\n // the override).\n get trailing(): boolean {\n return !this.hasAttribute(\"no-trailing\");\n }\n\n set trailing(value: boolean) {\n if (value) {\n this.removeAttribute(\"no-trailing\");\n } else {\n this.setAttribute(\"no-trailing\", \"\");\n }\n }\n\n get maxWait(): number | undefined {\n const attr = this.getAttribute(\"max-wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultMaxWait();\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultMaxWait();\n }\n\n set maxWait(value: number) {\n this.setAttribute(\"max-wait\", String(value));\n }\n\n // --- Value-surface input ---\n\n get source(): any {\n return this._source;\n }\n\n set source(value: any) {\n this._source = value;\n this._core.configure(this._options());\n this._core.setSource(value);\n }\n\n // --- Core delegated getters ---\n\n get value(): any {\n return this._core.value;\n }\n\n get fired(): any[] {\n return this._core.fired;\n }\n\n get pending(): boolean {\n return this._core.pending;\n }\n\n // --- Commands ---\n\n trigger(...args: any[]): void {\n this._core.configure(this._options());\n this._core.trigger(...args);\n }\n\n cancel(): void {\n this._core.cancel();\n }\n\n flush(): void {\n this._core.flush();\n }\n\n // --- Internal ---\n\n // Overridden by <wcs-throttle> to bias the defaults toward throttle (leading\n // on, maxWait pinned to wait).\n protected _defaultWait(): number {\n return DEFAULT_WAIT;\n }\n\n // Resolves the effective `leading` value (not a static default). It is a method\n // rather than reading `this.leading` directly because <wcs-throttle> inverts the\n // default (on, opt out via `no-leading`) while sharing the inherited `leading`\n // attribute setter — overriding the getter alone would desync getter and setter.\n protected _resolveLeading(): boolean {\n return this.leading;\n }\n\n protected _defaultMaxWait(): number | undefined {\n return undefined;\n }\n\n protected _options(): DebounceOptions {\n return {\n wait: this.wait,\n leading: this._resolveLeading(),\n trailing: this.trailing,\n maxWait: this.maxWait,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // §4.1/§4.4 Shell SSR: expose connectedCallbackPromise backed by observe().\n // observe() is a no-op resolving once ready (the engine is command-driven).\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n // Drop any in-flight timer so a detached element leaks nothing, and bump the\n // Core generation so a surviving timer callback cannot settle (§3.5).\n this._core.dispose();\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { Debounce } from \"./Debounce.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\n/**\n * `<wcs-throttle>` — the same {@link DebounceCore} engine biased to throttle:\n * `maxWait === wait` (a fire happens at least every `wait` ms under continuous\n * input) and `leading` on by default. It advertises its own `wcs-throttle:*`\n * event namespace (via `makeDebounceProperties(\"wcs-throttle\")`), and the Core\n * dispatches under that prefix because the constructor passes it through.\n */\nexport class Throttle extends Debounce {\n protected static eventPrefix = \"wcs-throttle\";\n static wcBindable: IWcBindable = {\n ...Debounce.wcBindable,\n properties: makeDebounceProperties(\"wcs-throttle\"),\n };\n\n // leading defaults on for throttle; `no-leading` opts out (symmetric with the\n // inherited `no-trailing`).\n protected _resolveLeading(): boolean {\n return !this.hasAttribute(\"no-leading\");\n }\n\n // Pin maxWait to wait so throttle fires on a steady cadence; an explicit\n // `max-wait` attribute still overrides via the inherited getter.\n protected _defaultMaxWait(): number | undefined {\n return this.wait;\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapDebounce(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { Debounce } from \"./components/Debounce.js\";\nimport { Throttle } from \"./components/Throttle.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.debounce)) {\n customElements.define(config.tagNames.debounce, Debounce);\n }\n if (!customElements.get(config.tagNames.throttle)) {\n customElements.define(config.tagNames.throttle, Throttle);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","debounce","throttle","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","makeDebounceProperties","prefix","name","event","getter","e","detail","value","args","DebounceCore","EventTarget","static","protocol","version","properties","commands","_prefix","_target","_wait","_leading","_trailing","_maxWait","_hasMaxWait","_lastCallTime","undefined","_lastInvokeTime","_timerId","_timerGen","_pendingKind","_pendingValue","_pendingArgs","_value","_lastArgs","_pending","_gen","_ready","Promise","resolve","constructor","target","options","super","this","configure","ready","observe","dispose","cancel","wait","Number","isFinite","leading","trailing","mw","maxWait","Math","max","fired","pending","setSource","_schedule","trigger","_clearTimer","_setPending","flush","now","Date","_invoke","kind","isInvoking","_shouldInvoke","_leadingEdge","_armTimer","timeSinceLastCall","timeSinceLastInvoke","_remainingWait","timeWaiting","min","_timerExpired","_trailingEdge","_dispatch","type","dispatchEvent","CustomEvent","bubbles","delay","setTimeout","clearTimeout","registered","handleClick","Element","triggerElement","closest","id","getAttribute","DebounceCtor","customElements","get","ThrottleCtor","el","document","getElementById","preventDefault","Debounce","HTMLElement","inputs","attribute","_core","_source","_connectedCallbackPromise","eventPrefix","connectedCallbackPromise","attr","trim","_defaultWait","parsed","setAttribute","String","hasAttribute","removeAttribute","_defaultMaxWait","source","_options","_resolveLeading","connectedCallback","style","display","addEventListener","disconnectedCallback","Throttle","wcBindable","bootstrapDebounce","userConfig","partialConfig","assign","define"],"mappings":"AAWA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,sBAClBC,SAAU,CACRC,SAAU,eACVC,SAAU,iBAId,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,EAAYC,EAAgCG,IAE9C,OAAOH,CACT,CAEA,SAASK,EAAaL,GACpB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpD,MAAMM,EAAiC,CAAA,EACvC,IAAK,MAAMH,KAAOF,OAAOG,KAAKJ,GAC5BM,EAAMH,GAAOE,EAAWL,EAAgCG,IAE1D,OAAOG,CACT,CAEA,IAAIC,EAA+B,KAE5B,MAAMC,EAAkBf,WAEfgB,IAId,OAHKF,IACHA,EAAeR,EAAWM,EAAUZ,KAE/Bc,CACT,CC7BM,SAAUG,EAAuBC,GACrC,MAAO,CACL,CAAEC,KAAM,QAASC,MAAO,GAAGF,YAAkBG,OAASC,G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EAAQG,SAAUmJ,EAAcnJ,UAEhDW,EAAe,MOtDVmG,eAAeC,IAAInG,EAAOZ,SAASC,WACtC6G,eAAeuC,OAAOzI,EAAOZ,SAASC,SAAUoH,GAE7CP,eAAeC,IAAInG,EAAOZ,SAASE,WACtC4G,eAAeuC,OAAOzI,EAAOZ,SAASE,SAAU6I,EDApD"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/components/Debounce.ts","../src/components/Throttle.ts","../src/bootstrapDebounce.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n debounce: string;\n throttle: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-debouncetarget\",\n tagNames: {\n debounce: \"wcs-debounce\",\n throttle: \"wcs-throttle\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindableProperty } from \"./types.js\";\n\n/**\n * Build the wc-bindable `properties` list for a debounce/throttle element, with\n * every event name derived from a single `prefix`. `<wcs-debounce>` uses\n * `\"wcs-debounce\"`, `<wcs-throttle>` uses `\"wcs-throttle\"`, so the two tags share\n * one engine (DebounceCore) yet advertise distinct event namespaces from one\n * source of truth — no hand-duplicated property tables (cf. the geolocation Shell\n * which overrode its wcBindable by hand).\n *\n * - `value` — the debounced value of the latest `source` write (value surface),\n * read from the `<prefix>:settled` event.\n * - `fired` — the coalesced args of the latest `trigger()` pulse (signal\n * surface), read from the `<prefix>:fired` event. Declared as a\n * property (not just an event) so state can subscribe via the\n * event-token protocol (`eventToken.fired: <name>`).\n * - `pending` — whether a debounce is currently in flight.\n */\nexport function makeDebounceProperties(prefix: string): IWcBindableProperty[] {\n return [\n { name: \"value\", event: `${prefix}:settled`, getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed` },\n ];\n}\n","import { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\ntype PendingKind = \"value\" | \"signal\" | null;\n\n/**\n * Headless debounce/throttle primitive. A framework-agnostic port of lodash's\n * `debounce` algorithm (`shouldInvoke` / `leadingEdge` / `trailingEdge` /\n * `remainingWait`, timed via `Date.now()`), exposed through the wc-bindable\n * protocol.\n *\n * It coalesces a stream of *signals* and emits at most one per quiet period.\n * Two surfaces share the single timer:\n *\n * - **value** — writing {@link setSource} schedules a settle; on fire the\n * debounced value is published via the `<prefix>:settled` event and the\n * `value` getter. Wire it as `source: src; value: debounced`.\n * - **signal** — calling {@link trigger}`(...args)` coalesces a burst of pulses;\n * on fire one `<prefix>:fired` event carries the latest args (relayed by state\n * through the command-token / event-token protocols).\n *\n * A given instance is meant to be used for one surface at a time. Because each\n * surface keeps its own field (`_value` vs `_lastArgs`), the getters never\n * pollute each other; if both are driven on one instance the *last* scheduled\n * signal wins (lodash's last-args semantics).\n *\n * Throttle is the same engine with `maxWait === wait` (and `leading` on by\n * default), so `<wcs-throttle>` reuses this class with a different `eventPrefix`.\n */\nexport class DebounceCore extends EventTarget {\n // The static contract advertises the *default* `wcs-debounce:*` event names. A\n // headless Core constructed with a non-default `eventPrefix` (e.g.\n // `\"wcs-throttle\"`) dispatches under that prefix, so its events won't match\n // this metadata — rebuild the property table with `makeDebounceProperties(prefix)`\n // for that case. (The `<wcs-throttle>` Shell already overrides its own\n // `wcBindable` this way, so binding through an element is always consistent.)\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n private readonly _prefix: string;\n private _target: EventTarget;\n\n // Tuning (lodash knobs).\n private _wait: number = 0;\n private _leading: boolean = false;\n private _trailing: boolean = true;\n private _maxWait: number = 0;\n private _hasMaxWait: boolean = false;\n\n // Timing bookkeeping.\n private _lastCallTime: number | undefined = undefined;\n private _lastInvokeTime: number = 0;\n private _timerId: ReturnType<typeof setTimeout> | null = null;\n // Generation stamped onto the live timer at arm time, compared in\n // `_timerExpired` against `_gen` to drop callbacks that outlived a dispose().\n private _timerGen: number = 0;\n\n // Last-wins pending payload. `_pendingKind === null` doubles as the \"consumed /\n // empty\" sentinel (lodash clears `lastArgs` in invokeFunc): a trailing edge with\n // no fresh call since the last fire sees `null` and does not re-fire, which is\n // what stops a single leading pulse from also firing on the trailing edge.\n private _pendingKind: PendingKind = null;\n private _pendingValue: any = undefined;\n private _pendingArgs: any[] | undefined = undefined;\n\n // Observable state (getter backing).\n private _value: any = undefined;\n private _lastArgs: any[] = [];\n private _pending: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() so a timer that survives a\n // tear-down can no longer settle into a detached element. A pending timer is\n // also cleared by dispose() → cancel(), so the guard is defensive: it stops\n // any callback that has already been dequeued by the host event loop from\n // writing state after dispose().\n private _gen = 0;\n // SSR (§3.8): the debounce engine is purely timer-driven with no asynchronous\n // probe to await, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(prefix: string = \"wcs-debounce\", target?: EventTarget, options?: DebounceOptions) {\n super();\n this._prefix = prefix;\n this._target = target ?? this;\n if (options) {\n this.configure(options);\n }\n }\n\n // --- Lifecycle (§3.5 / §3.8) ---\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Debounce is command-driven (setSource / trigger schedule work on demand)\n // with no subscription to establish, so observe() is an idempotent no-op that\n // resolves once ready.\n observe(): Promise<void> {\n return this._ready;\n }\n\n // Tear down the pending timer and invalidate the generation so a stale timer\n // callback cannot fire after the element is detached.\n dispose(): void {\n this._gen++;\n this.cancel();\n }\n\n // --- Configuration ---\n\n /**\n * Update the tuning knobs. The Shell calls this with the element's current\n * attributes before each schedule, so live attribute edits take effect on the\n * next signal. `maxWait` is clamped to at least `wait` (lodash semantics); an\n * absent / invalid `maxWait` disables maxWait entirely.\n */\n configure(options: DebounceOptions = {}): void {\n if (typeof options.wait === \"number\" && Number.isFinite(options.wait) && options.wait >= 0) {\n this._wait = options.wait;\n }\n if (typeof options.leading === \"boolean\") {\n this._leading = options.leading;\n }\n if (typeof options.trailing === \"boolean\") {\n this._trailing = options.trailing;\n }\n const mw = options.maxWait;\n if (typeof mw === \"number\" && Number.isFinite(mw) && mw >= 0) {\n this._maxWait = Math.max(mw, this._wait);\n this._hasMaxWait = true;\n } else {\n this._maxWait = 0;\n this._hasMaxWait = false;\n }\n }\n\n // --- Observable getters ---\n\n get value(): any {\n return this._value;\n }\n\n get fired(): any[] {\n return this._lastArgs;\n }\n\n get pending(): boolean {\n return this._pending;\n }\n\n // --- Public entry points ---\n\n /** Value surface: schedule a settle carrying `value` (last write wins). */\n setSource(value: any): void {\n this._schedule(\"value\", value, undefined);\n }\n\n /** Signal surface: coalesce a pulse carrying `args` (last call wins). */\n trigger(...args: any[]): void {\n this._schedule(\"signal\", undefined, args);\n }\n\n /** Drop any pending fire without emitting. Getters keep their last values. */\n cancel(): void {\n this._clearTimer();\n this._lastInvokeTime = 0;\n this._lastCallTime = undefined;\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n /**\n * Emit any buffered payload immediately, then clear pending. Unlike lodash's\n * `flush` (which honours `trailing`), this fires whatever is buffered — the\n * command's intent is \"publish now\" — but is a no-op when nothing is pending.\n */\n flush(): void {\n if (this._timerId === null && this._pendingKind === null) return;\n const now = Date.now();\n this._clearTimer();\n if (this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n // --- Engine (lodash port) ---\n\n private _schedule(kind: Exclude<PendingKind, null>, value: any, args: any[] | undefined): void {\n const now = Date.now();\n const isInvoking = this._shouldInvoke(now);\n\n this._pendingKind = kind;\n if (kind === \"value\") {\n this._pendingValue = value;\n } else {\n this._pendingArgs = args;\n }\n this._lastCallTime = now;\n this._setPending(true);\n\n if (isInvoking) {\n if (this._timerId === null) {\n this._leadingEdge(now);\n return;\n }\n if (this._hasMaxWait) {\n // Continuous input that has reached maxWait: restart the steady timer and\n // invoke now so a fire happens at least every maxWait ms (throttle path).\n // Clear the pending handle first (lodash's \"tight loop\" branch does the\n // same) — overwriting `_timerId` without clearing would orphan the old\n // timer and let it fire spuriously later.\n this._clearTimer();\n this._armTimer(this._wait);\n this._invoke(now);\n return;\n }\n }\n if (this._timerId === null) {\n this._armTimer(this._wait);\n }\n }\n\n private _shouldInvoke(now: number): boolean {\n if (this._lastCallTime === undefined) return true;\n const timeSinceLastCall = now - this._lastCallTime;\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n return (\n timeSinceLastCall >= this._wait ||\n timeSinceLastCall < 0 ||\n (this._hasMaxWait && timeSinceLastInvoke >= this._maxWait)\n );\n }\n\n private _remainingWait(now: number): number {\n const timeSinceLastCall = now - (this._lastCallTime as number);\n const timeSinceLastInvoke = now - this._lastInvokeTime;\n const timeWaiting = this._wait - timeSinceLastCall;\n return this._hasMaxWait\n ? Math.min(timeWaiting, this._maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n private _timerExpired = (): void => {\n // §3.4 generation guard: a timer dequeued by the host before dispose() could\n // clear it must not settle into a torn-down element. Capture the generation\n // when the timer is scheduled (via `_armTimer`) and bail if it is stale.\n if (this._timerGen !== this._gen) return;\n const now = Date.now();\n if (this._shouldInvoke(now)) {\n this._trailingEdge(now);\n return;\n }\n // Fired before the quiet period elapsed (a later call moved the deadline) —\n // re-arm for the remaining time instead of settling now.\n this._armTimer(this._remainingWait(now));\n };\n\n private _leadingEdge(now: number): void {\n this._lastInvokeTime = now;\n this._armTimer(this._wait);\n if (this._leading) {\n this._invoke(now);\n }\n }\n\n private _trailingEdge(now: number): void {\n this._timerId = null;\n // Only fire when there is an unconsumed payload (a call arrived since the last\n // invoke). After a lone leading fire `_pendingKind` is null, so a single pulse\n // does not double-fire on its trailing edge.\n if (this._trailing && this._pendingKind !== null) {\n this._invoke(now);\n }\n this._pendingKind = null;\n this._pendingValue = undefined;\n this._pendingArgs = undefined;\n this._setPending(false);\n }\n\n private _invoke(now: number): void {\n this._lastInvokeTime = now;\n const kind = this._pendingKind;\n if (kind === \"value\") {\n this._value = this._pendingValue;\n this._dispatch(`${this._prefix}:settled`, { value: this._value });\n } else if (kind === \"signal\") {\n this._lastArgs = this._pendingArgs ?? [];\n this._dispatch(`${this._prefix}:fired`, { args: this._lastArgs });\n }\n // Mark consumed (mirrors lodash clearing `lastArgs`).\n this._pendingKind = null;\n }\n\n private _setPending(pending: boolean): void {\n if (this._pending === pending) return;\n this._pending = pending;\n this._dispatch(`${this._prefix}:pending-changed`, pending);\n }\n\n private _dispatch(type: string, detail: any): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n // Arm the settle timer, stamping the current generation so a callback that the\n // host dequeues after a dispose() can detect it is stale (§3.4).\n private _armTimer(delay: number): void {\n this._timerGen = this._gen;\n this._timerId = setTimeout(this._timerExpired, delay);\n }\n\n private _clearTimer(): void {\n if (this._timerId !== null) {\n clearTimeout(this._timerId);\n this._timerId = null;\n }\n }\n}\n","import { config } from \"./config.js\";\n\nlet registered = false;\n\ninterface Triggerable extends Element {\n trigger(...args: unknown[]): void;\n}\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const id = triggerElement.getAttribute(config.triggerAttribute);\n if (!id) return;\n\n // Resolve the registered constructors at call time (avoids a components ⇄\n // autoTrigger import cycle, mirroring <wcs-timer>). The DOM trigger fires a\n // single coalesced pulse on the referenced <wcs-debounce> / <wcs-throttle>.\n const DebounceCtor = customElements.get(config.tagNames.debounce);\n const ThrottleCtor = customElements.get(config.tagNames.throttle);\n const el = document.getElementById(id);\n if (!el) return;\n const isDebounce = DebounceCtor && el instanceof DebounceCtor;\n const isThrottle = ThrottleCtor && el instanceof ThrottleCtor;\n if (!isDebounce && !isThrottle) return;\n\n // Suppress the element's default action so a debounce can fire without\n // navigating. See README \"Optional DOM Triggering\".\n event.preventDefault();\n (el as unknown as Triggerable).trigger();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable, DebounceOptions } from \"../types.js\";\nimport { DebounceCore } from \"../core/DebounceCore.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nconst DEFAULT_WAIT = 250;\n\n/**\n * `<wcs-debounce>` — declarative debounce. See {@link DebounceCore} for the\n * engine. The `eventPrefix` defaults to `\"wcs-debounce\"`; `<wcs-throttle>`\n * subclasses this with `\"wcs-throttle\"` and throttle defaults.\n */\nexport class Debounce extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n protected static eventPrefix = \"wcs-debounce\";\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: makeDebounceProperties(\"wcs-debounce\"),\n // `source` is the value-surface input (its debounced echo comes back on the\n // `value` property). `trigger` / `cancel` / `flush` are commands from the\n // Core. No momentary boolean `trigger` property exists — the signal surface\n // is driven by the `trigger` command (command-token) or a DOM click\n // (autoTrigger), which sidesteps the attribute/method name clash that forced\n // <wcs-geo>'s watch → watchPosition rename.\n inputs: [\n { name: \"source\" },\n { name: \"wait\", attribute: \"wait\" },\n // No `attribute` hint on leading / trailing: their setters already reflect\n // to the backing attribute themselves (the fetch-Shell idiom), and — more\n // importantly — the backing attribute is NOT the input name. `trailing`\n // reflects to the inverted `no-trailing` (default true; a bare `trailing`\n // attribute can't express false), and the `<wcs-throttle>` subclass reads\n // `leading` from the inverted `no-leading` (default on). A single\n // input-name→attribute hint can't be correct for both polarities/subclasses,\n // so binders drive these through the property setter instead.\n { name: \"leading\" },\n { name: \"trailing\" },\n { name: \"maxWait\", attribute: \"max-wait\" },\n ],\n commands: [\n { name: \"trigger\" },\n { name: \"cancel\" },\n { name: \"flush\" },\n ],\n };\n\n protected _core: DebounceCore;\n private _source: any = undefined;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new DebounceCore((this.constructor as typeof Debounce).eventPrefix, this);\n this._internals = this._initInternals();\n // `<wcs-throttle>` extends this class without overriding the constructor, so\n // `this.constructor` resolves to the actual subclass here too — the map key\n // tracks whichever `eventPrefix` the instance dispatches under\n // (docs/custom-state-reflection-design.md §3.4).\n const prefix = (this.constructor as typeof Debounce).eventPrefix;\n this._wireStates({ [`${prefix}:pending-changed`]: (d) => ({ pending: d === true }) });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get wait(): number {\n const attr = this.getAttribute(\"wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultWait();\n // Strict parse via Number() (\"100px\" -> NaN, not 100). Fall back to the\n // default for any non-finite or negative value.\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultWait();\n }\n\n set wait(value: number) {\n this.setAttribute(\"wait\", String(value));\n }\n\n get leading(): boolean {\n return this.hasAttribute(\"leading\");\n }\n\n set leading(value: boolean) {\n if (value) {\n this.setAttribute(\"leading\", \"\");\n } else {\n this.removeAttribute(\"leading\");\n }\n }\n\n // `trailing` defaults to true; the boolean `no-trailing` attribute opts out (a\n // bare `trailing` attribute can't express \"false\", so the negative flag carries\n // the override).\n get trailing(): boolean {\n return !this.hasAttribute(\"no-trailing\");\n }\n\n set trailing(value: boolean) {\n if (value) {\n this.removeAttribute(\"no-trailing\");\n } else {\n this.setAttribute(\"no-trailing\", \"\");\n }\n }\n\n get maxWait(): number | undefined {\n const attr = this.getAttribute(\"max-wait\");\n if (attr === null || attr.trim() === \"\") return this._defaultMaxWait();\n const parsed = Number(attr);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : this._defaultMaxWait();\n }\n\n set maxWait(value: number) {\n this.setAttribute(\"max-wait\", String(value));\n }\n\n // --- Value-surface input ---\n\n get source(): any {\n return this._source;\n }\n\n set source(value: any) {\n this._source = value;\n this._core.configure(this._options());\n this._core.setSource(value);\n }\n\n // --- Core delegated getters ---\n\n get value(): any {\n return this._core.value;\n }\n\n get fired(): any[] {\n return this._core.fired;\n }\n\n get pending(): boolean {\n return this._core.pending;\n }\n\n // --- Commands ---\n\n trigger(...args: any[]): void {\n this._core.configure(this._options());\n this._core.trigger(...args);\n }\n\n cancel(): void {\n this._core.cancel();\n }\n\n flush(): void {\n this._core.flush();\n }\n\n // --- Internal ---\n\n // Overridden by <wcs-throttle> to bias the defaults toward throttle (leading\n // on, maxWait pinned to wait).\n protected _defaultWait(): number {\n return DEFAULT_WAIT;\n }\n\n // Resolves the effective `leading` value (not a static default). It is a method\n // rather than reading `this.leading` directly because <wcs-throttle> inverts the\n // default (on, opt out via `no-leading`) while sharing the inherited `leading`\n // attribute setter — overriding the getter alone would desync getter and setter.\n protected _resolveLeading(): boolean {\n return this.leading;\n }\n\n protected _defaultMaxWait(): number | undefined {\n return undefined;\n }\n\n protected _options(): DebounceOptions {\n return {\n wait: this.wait,\n leading: this._resolveLeading(),\n trailing: this.trailing,\n maxWait: this.maxWait,\n };\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // §4.1/§4.4 Shell SSR: expose connectedCallbackPromise backed by observe().\n // observe() is a no-op resolving once ready (the engine is command-driven).\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n // Drop any in-flight timer so a detached element leaks nothing, and bump the\n // Core generation so a surviving timer callback cannot settle (§3.5).\n this._core.dispose();\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { Debounce } from \"./Debounce.js\";\nimport { makeDebounceProperties } from \"../wcBindableFactory.js\";\n\n/**\n * `<wcs-throttle>` — the same {@link DebounceCore} engine biased to throttle:\n * `maxWait === wait` (a fire happens at least every `wait` ms under continuous\n * input) and `leading` on by default. It advertises its own `wcs-throttle:*`\n * event namespace (via `makeDebounceProperties(\"wcs-throttle\")`), and the Core\n * dispatches under that prefix because the constructor passes it through.\n */\nexport class Throttle extends Debounce {\n protected static eventPrefix = \"wcs-throttle\";\n static wcBindable: IWcBindable = {\n ...Debounce.wcBindable,\n properties: makeDebounceProperties(\"wcs-throttle\"),\n };\n\n // leading defaults on for throttle; `no-leading` opts out (symmetric with the\n // inherited `no-trailing`).\n protected _resolveLeading(): boolean {\n return !this.hasAttribute(\"no-leading\");\n }\n\n // Pin maxWait to wait so throttle fires on a steady cadence; an explicit\n // `max-wait` attribute still overrides via the inherited getter.\n protected _defaultMaxWait(): number | undefined {\n return this.wait;\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapDebounce(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { Debounce } from \"./components/Debounce.js\";\nimport { Throttle } from \"./components/Throttle.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.debounce)) {\n customElements.define(config.tagNames.debounce, Debounce);\n }\n if (!customElements.get(config.tagNames.throttle)) {\n customElements.define(config.tagNames.throttle, Throttle);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","debounce","throttle","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","makeDebounceProperties","prefix","name","event","getter","e","detail","value","args","DebounceCore","EventTarget","static","protocol","version","properties","commands","_prefix","_target","_wait","_leading","_trailing","_maxWait","_hasMaxWait","_lastCallTime","undefined","_lastInvokeTime","_timerId","_timerGen","_pendingKind","_pendingValue","_pendingArgs","_value","_lastArgs","_pending","_gen","_ready","Promise","resolve","constructor","target","options","super","this","configure","ready","observe","dispose","cancel","wait","Number","isFinite","leading","trailing","mw","maxWait","Math","max","fired","pending","setSource","_schedule","trigger","_clearTimer","_setPending","flush","now","Date","_invoke","kind","isInvoking","_shouldInvoke","_leadingEdge","_armTimer","timeSinceLastCall","timeSinceLastInvoke","_remainingWait","timeWaiting","min","_timerExpired","_trailingEdge","_dispatch","type","dispatchEvent","CustomEvent","bubbles","delay","setTimeout","clearTimeout","registered","handleClick","Element","triggerElement","closest","id","getAttribute","DebounceCtor","customElements","get","ThrottleCtor","el","document","getElementById","preventDefault","Debounce","HTMLElement","inputs","attribute","_core","_source","_connectedCallbackPromise","_internals","eventPrefix","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","addEventListener","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","attr","trim","_defaultWait","parsed","setAttribute","String","removeAttribute","_defaultMaxWait","source","_options","_resolveLeading","connectedCallback","style","display","disconnectedCallback","Throttle","wcBindable","bootstrapDebounce","userConfig","partialConfig","assign","define"],"mappings":"AAWA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,sBAClBC,SAAU,CACRC,SAAU,eACVC,SAAU,iBAId,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd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vBD,EAAQC,YAAcqK,EAAcrK,aAEQ,iBAAnCqK,EAAcpK,mBACvBF,EAAQE,iBAAmBoK,EAAcpK,kBAEvCoK,EAAcnK,UAChBK,OAAO+J,OAAOvK,EAAQG,SAAUmK,EAAcnK,UAEhDW,EAAe,MOtDVmG,eAAeC,IAAInG,EAAOZ,SAASC,WACtC6G,eAAeuD,OAAOzJ,EAAOZ,SAASC,SAAUoH,GAE7CP,eAAeC,IAAInG,EAAOZ,SAASE,WACtC4G,eAAeuD,OAAOzJ,EAAOZ,SAASE,SAAU6J,EDApD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/debounce",
3
- "version": "1.16.0",
3
+ "version": "1.18.0",
4
4
  "description": "Declarative debounce/throttle components for Web Components. Framework-agnostic signal coalescing via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",